Skip to content

Commit

Permalink
fix: template import userinfo match (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
hetao92 authored Apr 13, 2022
1 parent 976a886 commit 7448c60
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
jobs:
package:
name: build package
runs-on: self-hosted
runs-on: [self-hosted, nebula-fast]
strategy:
matrix:
os:
Expand Down
3 changes: 2 additions & 1 deletion app/config/locale/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@
"uploadTemplateTip": "3. Configure the Yaml file: please keep only the file name (retain the file extension) for all file paths (path, failDataPath, logPath) in the template, e.g. logPath: config.csv",
"reUpload": "Re-upload",
"fileNotExist": "{name} file does not exist!",
"importYaml": "Import the YAML file"
"importYaml": "Import the YAML file",
"templateMatchError": "The {type} in the configuration does not match the current login account/host"
},
"schema": {
"spaceList": "Graph Space List",
Expand Down
3 changes: 2 additions & 1 deletion app/config/locale/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@
"uploadTemplateTip": "3. 配置Yaml文件:模板中所有文件路径(path、failDataPath、logPath)请只保留文件名(保留文件扩展名),例如: 日志路径:config.csv",
"reUpload": "重新上传",
"fileNotExist": "文件 {name} 不存在",
"importYaml": "导入 YAML 文件"
"importYaml": "导入 YAML 文件",
"templateMatchError": "配置中的{type}与当前登录账号/地址不匹配"
},
"schema": {
"spaceList": "图空间列表",
Expand Down
10 changes: 9 additions & 1 deletion app/pages/Import/TaskCreate/SchemaConfig/EdgeConfig/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Select, Table } from 'antd';
import { Select, Table, Tooltip } from 'antd';
import React from 'react';
import intl from 'react-intl-universal';
import { CloseOutlined } from '@ant-design/icons';
Expand Down Expand Up @@ -40,6 +40,14 @@ const EdgeConfig = (configProps: IProps) => {
{
title: intl.get('import.prop'),
dataIndex: 'name',
ellipsis: {
showTitle: false,
},
render: data => (
<Tooltip placement="topLeft" title={data}>
{data}
</Tooltip>
),
},
{
title: intl.get('import.mapping'),
Expand Down
10 changes: 9 additions & 1 deletion app/pages/Import/TaskCreate/SchemaConfig/TagConfig/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Select, Table } from 'antd';
import { Select, Table, Tooltip } from 'antd';
import React from 'react';
import intl from 'react-intl-universal';
import { CloseOutlined } from '@ant-design/icons';
Expand Down Expand Up @@ -40,6 +40,14 @@ const VerticesConfig = (props: IProps) => {
{
title: intl.get('import.prop'),
dataIndex: 'name',
ellipsis: {
showTitle: false,
},
render: data => (
<Tooltip placement="topLeft" title={data}>
{data}
</Tooltip>
),
},
{
title: intl.get('import.mapping'),
Expand Down
1 change: 1 addition & 0 deletions app/pages/Import/TaskCreate/SchemaConfig/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
.left {
display: flex;
align-items: center;
max-width: 95%;
.tagSelect {
min-width: 60px;
:global {
Expand Down
1 change: 1 addition & 0 deletions app/pages/Import/TaskCreate/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
margin-top: 25px;
.configColumn {
flex: 1;
width: 50%;
}
.configColumn:not(:last-child) {
margin-right: 20px;
Expand Down
13 changes: 12 additions & 1 deletion app/pages/Import/TaskList/TemplateModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ const { TextArea } = Input;

interface IProps {
visible: boolean;
username: string;
host: string;
onClose: () => void;
onImport: () => void;
}

const TemplateModal = (props: IProps) => {
const { visible, onClose, onImport } = props;
const { visible, onClose, onImport, username, host } = props;
const [form] = Form.useForm();
const [loading, setLoading] = useState(false);
const [config, setConfig] = useState('');
Expand All @@ -42,6 +44,15 @@ const TemplateModal = (props: IProps) => {
const _taskDir = taskDir.endsWith('/') ? taskDir : taskDir + '/';
const _uploadDir = uploadDir.endsWith('/') ? uploadDir : uploadDir + '/';
parseContent.logPath = `${_taskDir}import.log`;
const connection = parseContent.clientSettings?.connection || {}
if(connection.address !== host) {
message.error(intl.get('import.templateMatchError', { type: 'address' }));
throw new Error();
}
if(connection.username !== username) {
message.error(intl.get('import.templateMatchError', { type: 'username' }));
throw new Error();
}
parseContent.files?.forEach(file => {
if(!files.includes(file.path)) {
message.error(intl.get('import.fileNotExist', { name: file.path }));
Expand Down
5 changes: 4 additions & 1 deletion app/pages/Import/TaskList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ interface ILogDimension {
}
const TaskList = () => {
const timer = useRef<any>(null);
const { dataImport } = useStore();
const { dataImport, global } = useStore();
const history = useHistory();
const { taskList, getTaskList, stopTask, deleteTask, downloadTaskConfig } = dataImport;
const { username, host } = global;
const [modalVisible, setVisible] = useState(false);
const [importModalVisible, setImportModalVisible] = useState(false);
const [logDimension, setLogDimension] = useState<ILogDimension>({} as ILogDimension);
Expand Down Expand Up @@ -116,6 +117,8 @@ const TaskList = () => {
visible={modalVisible} />}
{importModalVisible && <TemplateModal
onClose={() => setImportModalVisible(false)}
username={username}
host={host}
onImport={getTaskList}
visible={importModalVisible} />}
</div>
Expand Down

0 comments on commit 7448c60

Please sign in to comment.