Skip to content

Commit

Permalink
fix: fix issues (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
hetao92 authored Feb 22, 2023
1 parent 92eeaa1 commit dc4fc62
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/pages/Import/FileList/UploadConfigModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const UploadConfigModal = (props: IProps) => {
}, [data]);
const deletePreviewFile = useCallback((e: React.MouseEvent, index: number) => {
e.stopPropagation();
const isActive = activeItem.uid === data[index].uid;
const isActive = activeItem?.uid === data[index].uid;
const newData = data.filter((_, i) => i !== index);
const checkedNum = data.reduce((n, file) => n + (file.withHeader & 1), 0);
setState({
Expand Down Expand Up @@ -175,7 +175,7 @@ const UploadConfigModal = (props: IProps) => {
render: value => <span className={styles.limitWidth}>{value}</span>,
};
})
: [], [previewContent, activeItem]);
: [], [previewContent, activeItem?.withHeader]);
const handleConfirm = useCallback(() => {
const existFileName = fileList.map((file) => file.name);
const repeatFiles = data.filter((file) => existFileName.includes(file.name));
Expand Down
1 change: 1 addition & 0 deletions app/pages/Import/FileList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const FileList = () => {
title={intl.get('common.ask')}
okText={intl.get('common.confirm')}
cancelText={intl.get('common.cancel')}
disabled={!selectFiles.length}
>
<Button className={styles.deleteBtn} disabled={!selectFiles.length}>
{intl.get('import.deleteFiles')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const VIDSetting = observer((props: {
}) => {
const { keyMap: { idKey, idFunction, idPrefix, label }, data } = props;
const { intl } = useI18n();
const { schema } = useStore();
const { spaceVidType } = schema;
return <div className={styles.row}>
<Collapse bordered={false} ghost className={styles.vidCollapse}>
<Panel header={<div className={cls(styles.panelTitle, styles.spaceBetween)}>
Expand All @@ -57,7 +59,7 @@ const VIDSetting = observer((props: {
</div>
</>} />
</div>} key="default">
{idFunction && <div className={styles.rowItem}>
{spaceVidType === 'INT64' && idFunction && <div className={styles.rowItem}>
<span className={styles.label}>{intl.get('import.vidFunction')}</span>
<Select
bordered={false}
Expand Down
2 changes: 1 addition & 1 deletion app/pages/Import/TaskCreate/SchemaConfig/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const SelectMappingTargetHeader = observer((props: IHeaderProps) => {
onClick={e => e.stopPropagation()}
onChange={onSelect}
>
{targetList.filter(t => !config.some(c => c.name === t)).map(t => (
{targetList?.filter(t => !config.some(c => c.name === t)).map(t => (
<Option value={t} key={t}>
{t}
</Option>
Expand Down
8 changes: 5 additions & 3 deletions app/stores/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ export class GlobalStore {
},
},
);
resetStore();
// clear storage before reset store, some store data is related to storage
this.clearStorage();
this.clearCookies();
resetStore();
this.ngqlRunner?.desctory();
this.history.push(`/login${location.search}`);
};
Expand Down Expand Up @@ -120,13 +121,14 @@ export class GlobalStore {

getGraphAddress = async () => {
const { code, data } = await service.execNGQL({ gql: 'show hosts graph;' });
return code !== 0 ? [] : data.tables.reduce((acc, cur) => {
if (isValidIP(cur.Host)) {
const list = code !== 0 ? [] : data.tables.reduce((acc, cur) => {
if (isValidIP(cur.Host) && cur.Status === 'ONLINE') {
acc.push(`${cur.Host}:${cur.Port}`);
}
return acc;
}
, []);
return list.length ? list : [this.host];
};
}

Expand Down

0 comments on commit dc4fc62

Please sign in to comment.