-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathDialogCreateDataset.tsx
More file actions
74 lines (64 loc) · 2.41 KB
/
DialogCreateDataset.tsx
File metadata and controls
74 lines (64 loc) · 2.41 KB
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
import React from 'react';
import {I18n} from '../../../../../i18n';
import type {
DialogCreateWorkbookEntryProps,
EntryDialogBaseProps,
} from '../../../../components/EntryDialogues';
import {DialogCreateWorkbookEntry, EntryDialogBase} from '../../../../components/EntryDialogues';
import {URL_QUERY} from '../../../../constants';
import DatasetUtils from '../../helpers/utils';
const i18n = I18n.keyset('dataset.dataset-creation.create');
type DialogCreateDatasetBaseProps = {
onClose: () => void;
visible: boolean;
};
export type DialogCreateDatasetInNavigationProps = {
onApply: EntryDialogBaseProps<void>['onApply'];
creationScope: 'navigation';
};
export type DialogCreateDatasetInWorkbookProps = {
onApply: DialogCreateWorkbookEntryProps<void>['onApply'];
creationScope: 'workbook';
};
export type DialogCreateDatasetProps =
| (DialogCreateDatasetBaseProps & DialogCreateDatasetInNavigationProps)
| (DialogCreateDatasetBaseProps & DialogCreateDatasetInWorkbookProps);
const DialogCreateDataset = (props: DialogCreateDatasetProps) => {
const {visible, onClose} = props;
const path =
DatasetUtils.getQueryParam(URL_QUERY.CURRENT_PATH) || DatasetUtils.getPersonalFolderPath();
if (props.creationScope === 'workbook') {
return (
<DialogCreateWorkbookEntry
name={i18n('label_name-default')}
defaultName={i18n('label_name-default')}
caption={i18n('section_title')}
placeholder={i18n('label_name-placeholder')}
textButtonApply={i18n('button_apply')}
textButtonCancel={i18n('button_cancel')}
visible={visible}
onApply={props.onApply}
onClose={onClose}
onSuccess={onClose}
/>
);
}
return (
<EntryDialogBase
name={i18n('label_name-default')}
defaultName={i18n('label_name-default')}
path={path}
caption={i18n('section_title')}
placeholder={i18n('label_name-placeholder')}
textButtonApply={i18n('button_apply')}
textButtonCancel={i18n('button_cancel')}
visible={visible}
withInput={true}
onError={() => null}
onApply={props.onApply}
onClose={onClose}
onSuccess={onClose}
/>
);
};
export default DialogCreateDataset;