Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React UI: Displaying public ssh keys in UI #1375

Merged
merged 3 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Increase preview size of a task till 256, 256 on the server
- Minor style updates
- Public ssh-keys are displayed in a dedicated window instead of console when create a task with a repository

### Deprecated
-
Expand Down
49 changes: 42 additions & 7 deletions cvat-ui/src/components/create-task-page/create-task-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,65 @@
// SPDX-License-Identifier: MIT

import './styles.scss';
import React from 'react';

import {
Row,
Col,
} from 'antd';

import React, { useEffect } from 'react';
import { Row, Col } from 'antd/lib/grid';
import Modal from 'antd/lib/modal';
import Text from 'antd/lib/typography/Text';
import Paragraph from 'antd/lib/typography/Paragraph';
import TextArea from 'antd/lib/input/TextArea';

import CreateTaskContent, { CreateTaskData } from './create-task-content';


interface Props {
onCreate: (data: CreateTaskData) => void;
status: string;
error: string;
installedGit: boolean;
}

export default function CreateTaskPage(props: Props): JSX.Element {
const {
error,
status,
onCreate,
installedGit,
} = props;

useEffect(() => {
if (error) {
let errorCopy = error;
const sshKeys: string[] = [];
while (errorCopy.length) {
const startIndex = errorCopy.search(/'ssh/);
if (startIndex === -1) break;
let sshKey = errorCopy.slice(startIndex + 1);
const stopIndex = sshKey.search(/'/);
sshKey = sshKey.slice(0, stopIndex);
sshKeys.push(sshKey);
errorCopy = errorCopy.slice(stopIndex + 1);
}

if (sshKeys.length) {
Modal.error({
width: 800,
title: 'Could not clone the repository',
content: (
<>
<Paragraph>
<Text>Please make sure it exists and you have access</Text>
</Paragraph>
<Paragraph>
<Text>Consider adding the following public ssh keys to git: </Text>
</Paragraph>
<TextArea rows={10} value={sshKeys.join('\n\n')} />
</>
),
});
}
}
}, [error]);

return (
<Row type='flex' justify='center' align='top' className='cvat-create-task-form-wrapper'>
<Col md={20} lg={16} xl={14} xxl={9}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { createTaskAsync } from 'actions/tasks-actions';

interface StateToProps {
status: string;
error: string;
installedGit: boolean;
}

Expand Down
1 change: 1 addition & 0 deletions cvat-ui/src/reducers/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface TasksState {
};
creates: {
status: string;
error: string;
};
};
}
Expand Down
3 changes: 3 additions & 0 deletions cvat-ui/src/reducers/tasks-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const defaultState: TasksState = {
deletes: {},
creates: {
status: '',
error: '',
},
},
};
Expand Down Expand Up @@ -238,6 +239,7 @@ export default (state: TasksState = defaultState, action: AnyAction): TasksState
...state.activities,
creates: {
status: '',
error: '',
},
},
};
Expand Down Expand Up @@ -276,6 +278,7 @@ export default (state: TasksState = defaultState, action: AnyAction): TasksState
creates: {
...state.activities.creates,
status: 'FAILED',
error: action.payload.error.toString(),
},
},
};
Expand Down