-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathCommonGroupSettingsSection.tsx
More file actions
68 lines (62 loc) · 2.51 KB
/
CommonGroupSettingsSection.tsx
File metadata and controls
68 lines (62 loc) · 2.51 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
import React from 'react';
import {I18n} from 'i18n';
import {useSelector} from 'react-redux';
import {DashTabItemControlSourceType} from 'shared';
import {selectSelectorDialog, selectSelectorsGroup} from 'ui/store/selectors/controlDialog';
import {ConnectionSettings} from './ConnectionSettings/ConnectionSettings';
import {DatasetSelectorSettings} from './DatasetSelectorSettings/DatasetSelectorSettings';
import {ImpactTypeSelect} from './ImpactTypeSelect/ImpactTypeSelect';
import {ParameterNameInput} from './ParameterNameInput/ParameterNameInput';
const i18n = I18n.keyset('dash.control-dialog.edit');
export const CommonGroupSettingsSection = ({
navigationPath,
changeNavigationPath,
enableGlobalSelectors,
className,
}: {
navigationPath: string | null;
changeNavigationPath: (newNavigationPath: string) => void;
enableGlobalSelectors?: boolean;
className?: string;
}) => {
const {sourceType} = useSelector(selectSelectorDialog);
const {group, impactType, impactTabsIds} = useSelector(selectSelectorsGroup);
const hasMultipleSelectors = group.length > 1;
switch (sourceType) {
case DashTabItemControlSourceType.Manual:
return (
<React.Fragment>
<ParameterNameInput
label={i18n('field_field-name')}
note={i18n('field_field-name-note')}
className={className}
/>
{enableGlobalSelectors && (
<ImpactTypeSelect
groupImpactType={impactType}
groupImpactTabsIds={impactTabsIds}
hasMultipleSelectors={hasMultipleSelectors}
/>
)}
</React.Fragment>
);
case DashTabItemControlSourceType.Connection:
return (
<ConnectionSettings
rowClassName={className}
changeNavigationPath={changeNavigationPath}
navigationPath={navigationPath}
enableGlobalSelectors={enableGlobalSelectors}
/>
);
default:
return (
<DatasetSelectorSettings
rowClassName={className}
navigationPath={navigationPath}
changeNavigationPath={changeNavigationPath}
enableGlobalSelectors={enableGlobalSelectors}
/>
);
}
};