@antscorp/antsomi-ui 1.3.5-beta.500 → 1.3.5-beta.501
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/molecules/SearchPopover/components/PopoverAddField/PopoverAddField.d.ts +0 -1
- package/es/components/molecules/SearchPopover/components/PopoverAddField/PopoverAddField.js +18 -104
- package/es/components/molecules/SearchPopover/components/PopoverSelect/PopoverSelect.d.ts +4 -0
- package/es/components/molecules/SearchPopover/components/PopoverSelect/PopoverSelect.js +132 -0
- package/es/components/molecules/SearchPopover/components/PopoverSelect/index.d.ts +1 -0
- package/es/components/molecules/SearchPopover/components/PopoverSelect/index.js +1 -0
- package/es/components/molecules/SearchPopover/components/index.d.ts +1 -0
- package/es/components/molecules/SearchPopover/components/index.js +1 -0
- package/es/components/molecules/SearchPopover/index.d.ts +1 -1
- package/es/components/molecules/SearchPopover/index.js +1 -1
- package/es/components/molecules/SearchPopover/types.d.ts +13 -5
- package/es/components/molecules/index.d.ts +1 -1
- package/es/components/molecules/index.js +1 -1
- package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.js +4 -5
- package/es/components/organism/LeftMenu/utils/index.d.ts +1 -0
- package/es/components/organism/LeftMenu/utils/index.js +18 -7
- package/es/models/LeftMenu/FeatureMenu.d.ts +1 -0
- package/package.json +1 -1
- /package/es/components/molecules/SearchPopover/components/{PopoverAddField → PopoverSelect}/styles.scss +0 -0
|
@@ -9,110 +9,24 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, {
|
|
13
|
-
import {
|
|
14
|
-
import { SearchPopover } from '../../SearchPopover';
|
|
15
|
-
import { Button, Checkbox, Menu } from 'antd';
|
|
12
|
+
import React, { useMemo } from 'react';
|
|
13
|
+
import { clsx } from 'clsx';
|
|
16
14
|
import { renderIconField } from '../../utils';
|
|
17
|
-
import '
|
|
18
|
-
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
19
|
-
import { Icon } from '../../../../atoms';
|
|
20
|
-
import Scrollbars from 'react-custom-scrollbars';
|
|
15
|
+
import { PopoverSelect } from '../PopoverSelect';
|
|
21
16
|
export const PopoverAddField = (props) => {
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
setSearch(searchValue.toString());
|
|
38
|
-
}
|
|
39
|
-
}, [searchValue]);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (selected !== undefined) {
|
|
42
|
-
setSelectedKeys(new Set(selected));
|
|
43
|
-
}
|
|
44
|
-
}, [selected]);
|
|
45
|
-
const filteredField = useMemo(() => {
|
|
46
|
-
let result = fields.filter(field => {
|
|
47
|
-
const labelIncluded = searchStringQuery(field.label, search);
|
|
48
|
-
const keyIncluded = searchStringQuery(field.key, search);
|
|
49
|
-
return labelIncluded || keyIncluded;
|
|
50
|
-
});
|
|
51
|
-
if (showSelected) {
|
|
52
|
-
result = result.filter(field => selectedKeys.has(field.key));
|
|
53
|
-
}
|
|
54
|
-
return result;
|
|
55
|
-
}, [fields, search, showSelected, selectedKeys]);
|
|
56
|
-
const handleToggleField = (field, checked) => {
|
|
57
|
-
const newSelectedKeys = new Set(selectedKeys);
|
|
58
|
-
if (checked) {
|
|
59
|
-
newSelectedKeys.add(field.key);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
newSelectedKeys.delete(field.key);
|
|
63
|
-
}
|
|
64
|
-
setSelectedKeys(newSelectedKeys);
|
|
65
|
-
};
|
|
66
|
-
const handleCancel = () => {
|
|
67
|
-
setOpen(false);
|
|
68
|
-
if (onCancel)
|
|
69
|
-
onCancel();
|
|
70
|
-
};
|
|
71
|
-
const handleApply = () => {
|
|
72
|
-
if (onApply)
|
|
73
|
-
onApply(Array.from(selectedKeys));
|
|
74
|
-
setOpen(false);
|
|
75
|
-
};
|
|
76
|
-
const handleOnSearch = (searchValue) => {
|
|
77
|
-
setSearch(searchValue);
|
|
78
|
-
if (inputSearchProps.onAfterChange) {
|
|
79
|
-
inputSearchProps.onAfterChange(searchValue);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
const handleSelectAll = () => {
|
|
83
|
-
setSelectedKeys(new Set(fields.map(field => field.key)));
|
|
84
|
-
};
|
|
85
|
-
const handleDeselectAll = () => {
|
|
86
|
-
setSelectedKeys(new Set());
|
|
87
|
-
};
|
|
88
|
-
const handleAfterOpenChange = (visible) => {
|
|
89
|
-
if (!visible) {
|
|
90
|
-
setSearch(searchValue ? searchValue.toString() : '');
|
|
91
|
-
setSelectedKeys(selected ? new Set(selected) : new Set());
|
|
92
|
-
}
|
|
93
|
-
if (rest.afterOpenChange) {
|
|
94
|
-
rest.afterOpenChange(visible);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const handleOpenChange = (visible) => {
|
|
98
|
-
setOpen(visible);
|
|
99
|
-
};
|
|
100
|
-
return (React.createElement(SearchPopover, Object.assign({}, rest, { content: React.createElement(React.Fragment, null,
|
|
101
|
-
!!fields.length && (React.createElement("div", { className: "actions" },
|
|
102
|
-
React.createElement(Button, { type: "link", size: "small", onClick: () => setShowSelected(current => !current) }, showSelected ? showAllLabel : showSelectedLabel),
|
|
103
|
-
selectedKeys.size === fields.length ? (React.createElement(Button, { type: "link", onClick: handleDeselectAll }, deselectAllLabel)) : (React.createElement(Button, { type: "link", onClick: handleSelectAll }, selectAllLabel)))),
|
|
104
|
-
!!filteredField.length && (React.createElement(Scrollbars, { autoHeight: true, autoHeightMax: 260 },
|
|
105
|
-
React.createElement(Menu, { className: "list-fields", selectable: false, items: filteredField.map(field => ({
|
|
106
|
-
key: field.key,
|
|
107
|
-
label: (React.createElement(Checkbox, { onChange: e => handleToggleField(field, e.target.checked), checked: selectedKeys.has(field.key) },
|
|
108
|
-
field.dataType && renderIconField(field.dataType),
|
|
109
|
-
field.label)),
|
|
110
|
-
})) }))),
|
|
111
|
-
React.createElement("div", { className: "footer" },
|
|
112
|
-
React.createElement(Button, { onClick: handleCancel }, "Cancel"),
|
|
113
|
-
React.createElement(Button, { onClick: handleApply, disabled: applyDisabled, type: "primary" }, "Apply"))), overlayInnerStyle: {
|
|
114
|
-
'--item-padding': `${((_b = (_a = THEME.components) === null || _a === void 0 ? void 0 : _a.Menu) === null || _b === void 0 ? void 0 : _b.itemPaddingInline) || 10}px`,
|
|
115
|
-
}, trigger: ['click'], placement: "bottomLeft", open: open, inputSearchProps: Object.assign(Object.assign({}, restInputSearchProps), { value: search, onAfterChange: handleOnSearch }), afterOpenChange: handleAfterOpenChange, onOpenChange: handleOpenChange }), children || (React.createElement(Button, { type: "text" },
|
|
116
|
-
React.createElement(Icon, { type: "icon-ants-plus-slim", size: 14 }),
|
|
117
|
-
"Add fields"))));
|
|
17
|
+
const { fields, onSearchPredicate, className } = props, rest = __rest(props, ["fields", "onSearchPredicate", "className"]);
|
|
18
|
+
const originalFieldByKey = useMemo(() => new Map(fields.map(field => [field.key, field])), [fields]);
|
|
19
|
+
const options = useMemo(() => fields.map(field => (Object.assign(Object.assign({}, field), { label: (React.createElement(React.Fragment, null,
|
|
20
|
+
field.dataType && renderIconField(field.dataType),
|
|
21
|
+
field.label)) }))), [fields]);
|
|
22
|
+
const handleOnSearchPredicate = (field) => {
|
|
23
|
+
const originalField = originalFieldByKey.get(field.key);
|
|
24
|
+
if (!originalField)
|
|
25
|
+
return true;
|
|
26
|
+
if (onSearchPredicate && originalField) {
|
|
27
|
+
return onSearchPredicate(originalField);
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
};
|
|
31
|
+
return (React.createElement(PopoverSelect, Object.assign({}, rest, { options: options, onSearchPredicate: handleOnSearchPredicate, className: clsx(className, 'ants-popover-add-fields') })));
|
|
118
32
|
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
13
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
14
|
+
import { SearchPopover } from '../../SearchPopover';
|
|
15
|
+
import { Button, Checkbox, Menu } from 'antd';
|
|
16
|
+
import './styles.scss';
|
|
17
|
+
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
18
|
+
import { Icon } from '../../../../atoms';
|
|
19
|
+
import Scrollbars from 'react-custom-scrollbars';
|
|
20
|
+
export const PopoverSelect = (props) => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const { open: openProp, selected, options = [], onCancel, onApply, inputSearchProps = {}, children, showAllLabel = 'Show all', showSelectedLabel = 'Show selected', selectAllLabel = 'Select all', deselectAllLabel = 'Unselect all', onSearchPredicate } = props, rest = __rest(props, ["open", "selected", "options", "onCancel", "onApply", "inputSearchProps", "children", "showAllLabel", "showSelectedLabel", "selectAllLabel", "deselectAllLabel", "onSearchPredicate"]);
|
|
23
|
+
const { value: searchValue } = inputSearchProps, restInputSearchProps = __rest(inputSearchProps, ["value"]);
|
|
24
|
+
const refOnSearchPredicate = useRef(onSearchPredicate);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
refOnSearchPredicate.current = onSearchPredicate;
|
|
27
|
+
}, [onSearchPredicate]);
|
|
28
|
+
const [open, setOpen] = useState(openProp);
|
|
29
|
+
const [selectedKeys, setSelectedKeys] = useState(new Set());
|
|
30
|
+
const [search, setSearch] = useState('');
|
|
31
|
+
const [showSelected, setShowSelected] = useState(false);
|
|
32
|
+
const applyDisabled = selectedKeys.size === 0;
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (openProp !== undefined) {
|
|
35
|
+
setOpen(openProp);
|
|
36
|
+
}
|
|
37
|
+
}, [openProp]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (searchValue !== undefined) {
|
|
40
|
+
setSearch(searchValue.toString());
|
|
41
|
+
}
|
|
42
|
+
}, [searchValue]);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (selected !== undefined) {
|
|
45
|
+
setSelectedKeys(new Set(selected));
|
|
46
|
+
}
|
|
47
|
+
}, [selected]);
|
|
48
|
+
const filteredField = useMemo(() => {
|
|
49
|
+
let result = options.filter(field => {
|
|
50
|
+
if (refOnSearchPredicate.current) {
|
|
51
|
+
const isFilteredOption = refOnSearchPredicate.current(field);
|
|
52
|
+
return isFilteredOption;
|
|
53
|
+
}
|
|
54
|
+
let labelIncluded = false;
|
|
55
|
+
if (typeof field.label === 'string') {
|
|
56
|
+
labelIncluded = searchStringQuery(field.label, search);
|
|
57
|
+
}
|
|
58
|
+
const keyIncluded = searchStringQuery(field.key, search);
|
|
59
|
+
return keyIncluded || labelIncluded;
|
|
60
|
+
});
|
|
61
|
+
if (showSelected) {
|
|
62
|
+
result = result.filter(field => selectedKeys.has(field.key));
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}, [options, search, showSelected, selectedKeys]);
|
|
66
|
+
const handleToggleField = (field, checked) => {
|
|
67
|
+
const newSelectedKeys = new Set(selectedKeys);
|
|
68
|
+
if (checked) {
|
|
69
|
+
newSelectedKeys.add(field.key);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
newSelectedKeys.delete(field.key);
|
|
73
|
+
}
|
|
74
|
+
setSelectedKeys(newSelectedKeys);
|
|
75
|
+
};
|
|
76
|
+
const handleCancel = () => {
|
|
77
|
+
setOpen(false);
|
|
78
|
+
if (onCancel)
|
|
79
|
+
onCancel();
|
|
80
|
+
};
|
|
81
|
+
const handleApply = () => {
|
|
82
|
+
if (onApply)
|
|
83
|
+
onApply(Array.from(selectedKeys));
|
|
84
|
+
setOpen(false);
|
|
85
|
+
};
|
|
86
|
+
const handleOnSearch = (searchValue) => {
|
|
87
|
+
setSearch(searchValue);
|
|
88
|
+
if (inputSearchProps.onAfterChange) {
|
|
89
|
+
inputSearchProps.onAfterChange(searchValue);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const handleSelectAll = () => {
|
|
93
|
+
setSelectedKeys(new Set(options.map(field => field.key)));
|
|
94
|
+
};
|
|
95
|
+
const handleDeselectAll = () => {
|
|
96
|
+
setSelectedKeys(new Set());
|
|
97
|
+
};
|
|
98
|
+
const handleAfterOpenChange = (visible) => {
|
|
99
|
+
if (!visible) {
|
|
100
|
+
setSearch(searchValue ? searchValue.toString() : '');
|
|
101
|
+
setSelectedKeys(selected ? new Set(selected) : new Set());
|
|
102
|
+
}
|
|
103
|
+
if (rest.afterOpenChange) {
|
|
104
|
+
rest.afterOpenChange(visible);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const handleOpenChange = (visible) => {
|
|
108
|
+
setOpen(visible);
|
|
109
|
+
};
|
|
110
|
+
const renderCheckBoxLabel = (option) => {
|
|
111
|
+
if (typeof option.label === 'function') {
|
|
112
|
+
return option.label({ selected: selectedKeys.has(option.key) });
|
|
113
|
+
}
|
|
114
|
+
return option.label;
|
|
115
|
+
};
|
|
116
|
+
return (React.createElement(SearchPopover, Object.assign({}, rest, { content: React.createElement(React.Fragment, null,
|
|
117
|
+
!!options.length && (React.createElement("div", { className: "actions" },
|
|
118
|
+
React.createElement(Button, { type: "link", size: "small", onClick: () => setShowSelected(current => !current) }, showSelected ? showAllLabel : showSelectedLabel),
|
|
119
|
+
selectedKeys.size === options.length ? (React.createElement(Button, { type: "link", onClick: handleDeselectAll }, deselectAllLabel)) : (React.createElement(Button, { type: "link", onClick: handleSelectAll }, selectAllLabel)))),
|
|
120
|
+
!!filteredField.length && (React.createElement(Scrollbars, { autoHeight: true, autoHeightMax: 260 },
|
|
121
|
+
React.createElement(Menu, { className: "list-fields", selectable: false, items: filteredField.map(option => ({
|
|
122
|
+
key: option.key,
|
|
123
|
+
label: (React.createElement(Checkbox, { onChange: e => handleToggleField(option, e.target.checked), checked: selectedKeys.has(option.key) }, renderCheckBoxLabel(option))),
|
|
124
|
+
})) }))),
|
|
125
|
+
React.createElement("div", { className: "footer" },
|
|
126
|
+
React.createElement(Button, { onClick: handleCancel }, "Cancel"),
|
|
127
|
+
React.createElement(Button, { onClick: handleApply, disabled: applyDisabled, type: "primary" }, "Apply"))), overlayInnerStyle: {
|
|
128
|
+
'--item-padding': `${((_b = (_a = THEME.components) === null || _a === void 0 ? void 0 : _a.Menu) === null || _b === void 0 ? void 0 : _b.itemPaddingInline) || 10}px`,
|
|
129
|
+
}, trigger: ['click'], placement: "bottomLeft", open: open, inputSearchProps: Object.assign(Object.assign({}, restInputSearchProps), { value: search, onAfterChange: handleOnSearch }), afterOpenChange: handleAfterOpenChange, onOpenChange: handleOpenChange }), children || (React.createElement(Button, { type: "text" },
|
|
130
|
+
React.createElement(Icon, { type: "icon-ants-plus-slim", size: 14 }),
|
|
131
|
+
"Add fields"))));
|
|
132
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PopoverSelect } from './PopoverSelect';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PopoverSelect } from './PopoverSelect';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { PopoverAddField } from './components';
|
|
1
|
+
export { PopoverAddField, PopoverSelect } from './components';
|
|
2
2
|
export { SearchPopover } from './SearchPopover';
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { PopoverProps } from 'antd';
|
|
2
2
|
import { InputProps } from '../../atoms/Input';
|
|
3
|
-
import { PropsWithChildren } from 'react';
|
|
3
|
+
import React, { PropsWithChildren } from 'react';
|
|
4
4
|
export type SearchPopoverProps = PropsWithChildren<{
|
|
5
5
|
inputSearchProps?: InputProps;
|
|
6
6
|
} & PopoverProps>;
|
|
7
|
-
export type
|
|
7
|
+
export type Option = {
|
|
8
8
|
key: string;
|
|
9
|
-
label:
|
|
9
|
+
label: React.ReactNode | ((info: {
|
|
10
|
+
selected: boolean;
|
|
11
|
+
}) => React.ReactNode);
|
|
12
|
+
};
|
|
13
|
+
export type Field = Option & {
|
|
10
14
|
dataType?: string | number;
|
|
11
15
|
};
|
|
12
|
-
export type
|
|
13
|
-
|
|
16
|
+
export type PopoverSelectProps<TOption extends Option = Option> = SearchPopoverProps & Partial<{
|
|
17
|
+
options: TOption[];
|
|
14
18
|
selected: string[];
|
|
15
19
|
onCancel: () => void;
|
|
16
20
|
onApply: (selected: string[]) => void;
|
|
@@ -19,4 +23,8 @@ export type PopoverAddFieldProps = SearchPopoverProps & Partial<{
|
|
|
19
23
|
showSelectedLabel: string;
|
|
20
24
|
deselectAllLabel: string;
|
|
21
25
|
selectAllLabel: string;
|
|
26
|
+
onSearchPredicate: (option: TOption) => boolean;
|
|
22
27
|
}>;
|
|
28
|
+
export type PopoverAddFieldProps = Omit<PopoverSelectProps, 'options'> & {
|
|
29
|
+
fields: Field[];
|
|
30
|
+
};
|
|
@@ -47,7 +47,7 @@ export * from './DatePickerV2';
|
|
|
47
47
|
export { ModalSelect } from './ModalSelect';
|
|
48
48
|
export { EditableName } from './EditableName';
|
|
49
49
|
export { VirtualizedMenu } from './VirtualizedMenu';
|
|
50
|
-
export { SearchPopover, PopoverAddField } from './SearchPopover';
|
|
50
|
+
export { SearchPopover, PopoverAddField, PopoverSelect } from './SearchPopover';
|
|
51
51
|
export { CalendarSelection, CalendarSelectionConstants, CalendarSelectionUtils, } from './CalendarSelection';
|
|
52
52
|
export * from './EmptyData';
|
|
53
53
|
export * from './PreviewModal';
|
|
@@ -47,7 +47,7 @@ export * from './DatePickerV2';
|
|
|
47
47
|
export { ModalSelect } from './ModalSelect';
|
|
48
48
|
export { EditableName } from './EditableName';
|
|
49
49
|
export { VirtualizedMenu } from './VirtualizedMenu';
|
|
50
|
-
export { SearchPopover, PopoverAddField } from './SearchPopover';
|
|
50
|
+
export { SearchPopover, PopoverAddField, PopoverSelect } from './SearchPopover';
|
|
51
51
|
export { CalendarSelection, CalendarSelectionConstants, CalendarSelectionUtils, } from './CalendarSelection';
|
|
52
52
|
export * from './EmptyData';
|
|
53
53
|
export * from './PreviewModal';
|
|
@@ -56,12 +56,11 @@ export const useHomeMenu = (props) => {
|
|
|
56
56
|
}, [auth, navigate, replace, urlParams]);
|
|
57
57
|
const customChildren = useMemo(() => appMenuChildren === null || appMenuChildren === void 0 ? void 0 : appMenuChildren.map(appMenuItem => {
|
|
58
58
|
var _a;
|
|
59
|
-
return getMenuItem(Object.assign(Object.assign({}, appMenuItem), { children: (_a = appMenuItem === null || appMenuItem === void 0 ? void 0 : appMenuItem.children) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign(Object.assign({}, item),
|
|
59
|
+
return getMenuItem(Object.assign(Object.assign({}, appMenuItem), { children: (_a = appMenuItem === null || appMenuItem === void 0 ? void 0 : appMenuItem.children) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign(Object.assign({}, item), ((item === null || item === void 0 ? void 0 : item.dashboardEditable)
|
|
60
|
+
? { options: Object.values(CONFIG_OPTIONS), optionCallback: onOptionCallback }
|
|
61
|
+
: {})))) }));
|
|
60
62
|
}), [appMenuChildren, onOptionCallback]);
|
|
61
|
-
const customHoverChildren = useMemo(() => appHoverMenuChildren === null || appHoverMenuChildren === void 0 ? void 0 : appHoverMenuChildren.map(appMenuItem => {
|
|
62
|
-
var _a;
|
|
63
|
-
return getMenuItem(Object.assign(Object.assign({}, appMenuItem), { children: (_a = appMenuItem === null || appMenuItem === void 0 ? void 0 : appMenuItem.children) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign(Object.assign({}, item), { options: Object.values(CONFIG_OPTIONS), optionCallback: onOptionCallback }))) }));
|
|
64
|
-
}), [appHoverMenuChildren, onOptionCallback]);
|
|
63
|
+
const customHoverChildren = useMemo(() => appHoverMenuChildren === null || appHoverMenuChildren === void 0 ? void 0 : appHoverMenuChildren.map(appMenuItem => getMenuItem(Object.assign(Object.assign({}, appMenuItem), { children: appMenuItem === null || appMenuItem === void 0 ? void 0 : appMenuItem.children }))), [appHoverMenuChildren]);
|
|
65
64
|
const onCreateNewReport = useCallback(e => {
|
|
66
65
|
if (onClickCreateDashboard) {
|
|
67
66
|
onClickCreateDashboard(e);
|
|
@@ -59,6 +59,7 @@ export declare const recursiveGetInitialFeatureMenuItem: (featureMenuItem: Parti
|
|
|
59
59
|
page_title?: string | undefined;
|
|
60
60
|
logo_url?: string | undefined;
|
|
61
61
|
children?: TFeatureMenu[] | undefined;
|
|
62
|
+
dashboardEditable?: boolean | undefined;
|
|
62
63
|
};
|
|
63
64
|
export declare const recursiveGetMenuItemByPermission: (featureMenuItem: TFeatureMenu) => TMenuItem;
|
|
64
65
|
/** Map children to each App Item */
|
|
@@ -17,6 +17,7 @@ import { MARKETING_CHANNEL_CODE, KEEP_HASH_PATH_DEV } from '../../../template/La
|
|
|
17
17
|
// Utils
|
|
18
18
|
import { handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
19
19
|
import { ENV } from '@antscorp/antsomi-ui/es/config';
|
|
20
|
+
import { FEATURE_PERMISSIONS } from '@antscorp/antsomi-ui/es/constants';
|
|
20
21
|
const PATH = 'src/components/organism/LeftMenu/utils/index.ts';
|
|
21
22
|
/**
|
|
22
23
|
* Converts a feature menu item to a menu item suitable for rendering in the UI.
|
|
@@ -201,13 +202,23 @@ export const getMappingAppChildren = (args) => {
|
|
|
201
202
|
menu_item_parent: appItem.menu_item,
|
|
202
203
|
menu_item_path: childMenuItem.menu_item_path,
|
|
203
204
|
icon_name: childMenuItem.icon_name,
|
|
204
|
-
})), { children: (_a = dashboardObject === null || dashboardObject === void 0 ? void 0 : dashboardObject[childMenuItem.menu_item_code]) === null || _a === void 0 ? void 0 : _a.map(item =>
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
205
|
+
})), { children: (_a = dashboardObject === null || dashboardObject === void 0 ? void 0 : dashboardObject[childMenuItem.menu_item_code]) === null || _a === void 0 ? void 0 : _a.map(item => {
|
|
206
|
+
const { shareAccess } = item || {};
|
|
207
|
+
const dashboardEditable = (() => {
|
|
208
|
+
var _a, _b;
|
|
209
|
+
if (isEmpty(shareAccess))
|
|
210
|
+
return true;
|
|
211
|
+
return (((_b = (_a = shareAccess === null || shareAccess === void 0 ? void 0 : shareAccess.list_access) === null || _a === void 0 ? void 0 : _a.find(item => item.user_id === (auth === null || auth === void 0 ? void 0 : auth.userId))) === null || _b === void 0 ? void 0 : _b.allow_edit) === FEATURE_PERMISSIONS.EVERYTHING);
|
|
212
|
+
})();
|
|
213
|
+
return Object.assign({}, getInitialFeatureMenuItem({
|
|
214
|
+
menu_item: String(item.dashboardId),
|
|
215
|
+
menu_item_code: String(item.dashboardId),
|
|
216
|
+
menu_item_name: item.dashboardName,
|
|
217
|
+
menu_item_parent: childMenuItem.menu_item_code,
|
|
218
|
+
menu_item_path: getGeneratePath(HOME_REPORT_ROUTES.DETAIL, Object.assign(Object.assign({}, auth), { dashboardId: String(item.dashboardId) })),
|
|
219
|
+
dashboardEditable,
|
|
220
|
+
}));
|
|
221
|
+
}) }));
|
|
211
222
|
});
|
|
212
223
|
break;
|
|
213
224
|
}
|
package/package.json
CHANGED
|
File without changes
|