From e71e4608b92410267954ea16f4aeb30f2377bf29 Mon Sep 17 00:00:00 2001
From: Boris Sekachev <40690378+bsekachev@users.noreply.github.com>
Date: Tue, 14 Apr 2020 23:16:51 +0300
Subject: [PATCH] React UI: Displaying public ssh keys in UI (#1375)
* Updated changelog
* Typos
---
CHANGELOG.md | 1 +
.../create-task-page/create-task-page.tsx | 49 ++++++++++++++++---
.../create-task-page/create-task-page.tsx | 1 +
cvat-ui/src/reducers/interfaces.ts | 1 +
cvat-ui/src/reducers/tasks-reducer.ts | 3 ++
5 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 76841e35fbd..5296ba66052 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,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
-
diff --git a/cvat-ui/src/components/create-task-page/create-task-page.tsx b/cvat-ui/src/components/create-task-page/create-task-page.tsx
index 7961841016d..439439f9251 100644
--- a/cvat-ui/src/components/create-task-page/create-task-page.tsx
+++ b/cvat-ui/src/components/create-task-page/create-task-page.tsx
@@ -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: (
+ <>
+
+ Please make sure it exists and you have access
+
+
+ Consider adding the following public ssh keys to git:
+
+
+ >
+ ),
+ });
+ }
+ }
+ }, [error]);
+
return (
diff --git a/cvat-ui/src/containers/create-task-page/create-task-page.tsx b/cvat-ui/src/containers/create-task-page/create-task-page.tsx
index 9042a39921c..5fecbd07e1f 100644
--- a/cvat-ui/src/containers/create-task-page/create-task-page.tsx
+++ b/cvat-ui/src/containers/create-task-page/create-task-page.tsx
@@ -12,6 +12,7 @@ import { createTaskAsync } from 'actions/tasks-actions';
interface StateToProps {
status: string;
+ error: string;
installedGit: boolean;
}
diff --git a/cvat-ui/src/reducers/interfaces.ts b/cvat-ui/src/reducers/interfaces.ts
index d794ffd7238..66110ab7dc0 100644
--- a/cvat-ui/src/reducers/interfaces.ts
+++ b/cvat-ui/src/reducers/interfaces.ts
@@ -57,6 +57,7 @@ export interface TasksState {
};
creates: {
status: string;
+ error: string;
};
};
}
diff --git a/cvat-ui/src/reducers/tasks-reducer.ts b/cvat-ui/src/reducers/tasks-reducer.ts
index 2212b71633d..e255d7b95be 100644
--- a/cvat-ui/src/reducers/tasks-reducer.ts
+++ b/cvat-ui/src/reducers/tasks-reducer.ts
@@ -32,6 +32,7 @@ const defaultState: TasksState = {
deletes: {},
creates: {
status: '',
+ error: '',
},
},
};
@@ -238,6 +239,7 @@ export default (state: TasksState = defaultState, action: AnyAction): TasksState
...state.activities,
creates: {
status: '',
+ error: '',
},
},
};
@@ -276,6 +278,7 @@ export default (state: TasksState = defaultState, action: AnyAction): TasksState
creates: {
...state.activities.creates,
status: 'FAILED',
+ error: action.payload.error.toString(),
},
},
};