-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathcreate-task-page.tsx
77 lines (69 loc) · 2.45 KB
/
create-task-page.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT
import './styles.scss';
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}>
<Text className='cvat-title'>Create a new task</Text>
<CreateTaskContent
status={status}
onCreate={onCreate}
installedGit={installedGit}
/>
</Col>
</Row>
);
}