@antscorp/antsomi-ui 2.0.39 → 2.0.41
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/HeaderV2/HeaderV2.js +5 -1
- package/es/components/molecules/MatchAnySelect/MatchesAnySelect.js +8 -5
- package/es/components/organism/LeftMenu/hooks/usePermission.js +3 -1
- package/es/components/organism/LeftMenu/utils/index.js +3 -2
- package/es/components/template/Layout/Layout.js +11 -4
- package/es/components/template/Layout/components/RecommendationWorkspace/components/MenuMapping/components/OldLeftMenu/index.js +3 -1
- package/package.json +2 -2
|
@@ -26,7 +26,11 @@ export const HeaderV2 = memo(props => {
|
|
|
26
26
|
// * Prefer to use Header in AppConfigContext
|
|
27
27
|
const { show = true, className, style, breadcrumbs, showLogo = false, rightContent, pageTitle = '', accountSelection = {}, helpConfig, notificationConfig = {}, accountSharingConfig, useURLParam, config, onCLickLogo, } = props;
|
|
28
28
|
/** General config for children component */
|
|
29
|
-
const { env = envContext, language = languageCode,
|
|
29
|
+
const { env = envContext, language = languageCode,
|
|
30
|
+
// NOTE: Just hot fix for change userId to accountId
|
|
31
|
+
userId = isNaN(Number(auth?.accountId || auth?.userId))
|
|
32
|
+
? 0
|
|
33
|
+
: Number(auth?.accountId || auth?.userId), portalId = auth?.portalId, token = auth?.token, permissionDomain = PERMISSION_API, iamDomain = IAM_API, appCode = contextAppCode, menuCode = contextMenuCode, } = config || {};
|
|
30
34
|
const { currentAccount, inputStyle = 'select', onSelectAccount, ...accountSelectionProps } = accountSelection;
|
|
31
35
|
const urlParams = useMemo(() => new URLSearchParams(search), [search]);
|
|
32
36
|
const oidParam = urlParams.get('oid') || currentAccount || 'all';
|
|
@@ -43,7 +43,7 @@ const { t } = i18nInstance;
|
|
|
43
43
|
const { Text } = Typography;
|
|
44
44
|
export function MatchesAny(props) {
|
|
45
45
|
// Props
|
|
46
|
-
const { maxSelectedItem, maxLengthEachItem
|
|
46
|
+
const { maxSelectedItem, maxLengthEachItem, objectName, loading = false, showExtendValue = true, selectedItems: selectedItemsProp, items, groupSelectProps, renderExtraValues, customItemRenders, listEmptyProps, selectedListEmptyProps, selectedTreeData: selectedTreeDataProp, searchValue = '', isExternalSearch, onApply = () => { }, onCancel = () => { }, onLoadMore = () => { }, onChangeSearch, ...restOfProps } = props;
|
|
47
47
|
// State
|
|
48
48
|
const [state, setState] = useState(matchesAnyInitialState);
|
|
49
49
|
const [maxItemsError, setMaxItemsError] = useState(false);
|
|
@@ -55,7 +55,9 @@ export function MatchesAny(props) {
|
|
|
55
55
|
const { description: selectedListEmptyDescription = t(translations.global.selectItemsFromList).toString(), icon: selectedListEmptyIcon = _jsx(DataIcon, { color: globalToken?.bw5, size: 48 }), ...restSelectedListEmptyProps } = selectedListEmptyProps || {};
|
|
56
56
|
useDeepCompareEffect(() => {
|
|
57
57
|
const isOverMaxSelected = maxSelectedItem && selectedItems && selectedItems.length > maxSelectedItem;
|
|
58
|
-
const isSomeTextTooLong =
|
|
58
|
+
const isSomeTextTooLong = maxLengthEachItem
|
|
59
|
+
? selectedItems && selectedItems.some(item => item.key?.toString().length > maxLengthEachItem)
|
|
60
|
+
: false;
|
|
59
61
|
setMaxItemsError(!!isOverMaxSelected);
|
|
60
62
|
setItemOverMaxLength(!!isSomeTextTooLong);
|
|
61
63
|
if (isApply && !isOverMaxSelected && !isSomeTextTooLong)
|
|
@@ -183,7 +185,7 @@ export function MatchesAny(props) {
|
|
|
183
185
|
};
|
|
184
186
|
const handleClickRemoveInvalid = () => {
|
|
185
187
|
selectedItems?.forEach(item => {
|
|
186
|
-
if (item.key?.toString().length > maxLengthEachItem) {
|
|
188
|
+
if (maxLengthEachItem && item.key?.toString().length > maxLengthEachItem) {
|
|
187
189
|
onRemoveItem(item);
|
|
188
190
|
}
|
|
189
191
|
});
|
|
@@ -205,6 +207,7 @@ export function MatchesAny(props) {
|
|
|
205
207
|
: extraValue.render
|
|
206
208
|
: item[extraValue.key] }) }, `${extraValue.key}`))) }))] }), _jsxs(Flex, { align: "center", gap: 10, children: [mode === 'select' && renderItemError(item), mode === 'select' &&
|
|
207
209
|
item.key?.toString().length &&
|
|
210
|
+
maxLengthEachItem &&
|
|
208
211
|
item.key?.toString().length > maxLengthEachItem && _jsx(ErrorIcon, { size: 16 }), isExtendValue && (_jsx(Icon, { type: "icon-ants-empty-flag", size: 20, color: globalToken?.colorPrimary })), _jsx(ActionButton, { className: "select-button", align: "center", justify: "center", onClick: () => {
|
|
209
212
|
// Call onSelectItem function if provided
|
|
210
213
|
if (onSelectItem) {
|
|
@@ -215,7 +218,7 @@ export function MatchesAny(props) {
|
|
|
215
218
|
onRemoveItem(item);
|
|
216
219
|
}
|
|
217
220
|
}, children: _jsx(Icon, { type: `icon-ants-${onSelectItem ? 'double-arrow-up' : 'remove-slim'}`, size: 11 }) })] })] }));
|
|
218
|
-
}, [
|
|
221
|
+
}, [renderExtraValues, customItemRenders, maxLengthEachItem, renderItemError]);
|
|
219
222
|
// Memos
|
|
220
223
|
const { treeData } = useDeepCompareMemo(() => {
|
|
221
224
|
const { results, matchedParents } = recursiveSearchItems({
|
|
@@ -376,7 +379,7 @@ export function MatchesAny(props) {
|
|
|
376
379
|
return (_jsx(ConfigProvider, { theme: MATCHES_ANY_THEME, children: _jsxs(MatchesAnyWrapper, { ...restOfProps, vertical: true, justify: "space-between", children: [_jsxs(Flex, { style: { width: '100%', height: '100%' }, children: [renderSelectList(), renderSelectedList()] }), _jsxs(Flex, { className: "matches-any__footer", align: "center", justify: "space-between", children: [_jsxs(Flex, { align: "center", gap: 10, children: [_jsx(Button, { type: "primary", disabled: isDisableApply, onClick: onClickApply, children: translate(translationsLocale._ACT_APPLY) }), _jsx(Button, { onClick: () => onCancel(), children: translate(translationsLocale._ACT_CANCEL) }), isApply && (maxItemsError || itemOverMaxLength) && (_jsxs(_Fragment, { children: [_jsx(Typography, { style: { color: globalToken?.colorError }, children: translate(translationsLocale._OPERATOR_MATCH_ANY_EX_VALUE_LIMIT) }), itemOverMaxLength && (_jsx(Button, { type: "text", onClick: handleClickRemoveInvalid, children: translate(translationsLocale._OPERATOR_MATCH_ANY_EX_VALUE_LIMIT_REMOVE_INV) }))] }))] }), showExtendValue && (_jsx(ExtendValuePopup, { getPopupContainer: trigger => trigger.parentElement || document.body, onApply: onApplyExtendValue, children: _jsx(Button, { icon: _jsx(Icon, { type: "icon-ants-empty-flag" }), children: t(translations.extendValue.title).toString() }) }))] })] }) }));
|
|
377
380
|
}
|
|
378
381
|
export function MatchesAnySelect(props) {
|
|
379
|
-
const { maxSelectedItem, maxLengthEachItem
|
|
382
|
+
const { maxSelectedItem, maxLengthEachItem, placeholder = 'Select an item', dropdownStyle, objectName, selectedItems, items, loading, popupClassName, groupSelectProps, renderExtraValues, customItemRenders, popoverProps, listEmptyProps, selectedListEmptyProps, selectedTreeData, error, onChangeSearch, onChange = () => { }, onLoadMore, ...restProps } = props;
|
|
380
383
|
// State
|
|
381
384
|
const [state, setState] = useState(initialState);
|
|
382
385
|
// Variables
|
|
@@ -101,7 +101,9 @@ export const usePermission = () => {
|
|
|
101
101
|
auth: {
|
|
102
102
|
token: auth?.token,
|
|
103
103
|
url: permissionDomain || PERMISSION_API,
|
|
104
|
-
|
|
104
|
+
// NOTE: Hot fix for case menu permission working wrong
|
|
105
|
+
// userId: auth?.userId,
|
|
106
|
+
userId: auth?.accountId,
|
|
105
107
|
accountId: auth?.accountId,
|
|
106
108
|
},
|
|
107
109
|
params: {
|
|
@@ -99,9 +99,10 @@ export const recursivePermissionMenu = (menuItems, menuPermissions) => {
|
|
|
99
99
|
*/
|
|
100
100
|
export const getGeneratePath = (path, params) => {
|
|
101
101
|
try {
|
|
102
|
-
const { portalId, userId, dashboardId, channelId } = params || {};
|
|
102
|
+
const { portalId, userId, accountId, dashboardId, channelId } = params || {};
|
|
103
103
|
const paramsObjects = {
|
|
104
|
-
|
|
104
|
+
// NOTE: Hot fix for account_id (login account)
|
|
105
|
+
user_id: accountId ?? userId ?? '-1',
|
|
105
106
|
networkId: portalId ?? -1,
|
|
106
107
|
portalId: portalId ?? -1,
|
|
107
108
|
dashboardId: dashboardId ?? '-1',
|
|
@@ -198,7 +198,8 @@ export const Layout = memo(props => {
|
|
|
198
198
|
permissionDomain,
|
|
199
199
|
socketDomain: SOCKET_API,
|
|
200
200
|
token,
|
|
201
|
-
accountId: userId,
|
|
201
|
+
// accountId: userId,
|
|
202
|
+
accountId,
|
|
202
203
|
userId,
|
|
203
204
|
lang: languageCode,
|
|
204
205
|
networkId: portalId,
|
|
@@ -222,6 +223,12 @@ export const Layout = memo(props => {
|
|
|
222
223
|
: menu_item_name);
|
|
223
224
|
setActiveMenu(activeMenuItem);
|
|
224
225
|
onActiveMenuChange?.(menu_item_code);
|
|
226
|
+
console.log({
|
|
227
|
+
activeItemPath: cloneDeep(activeItemPath),
|
|
228
|
+
flattenPermissionList,
|
|
229
|
+
menuListPermission,
|
|
230
|
+
appItem: activeItemPath[0],
|
|
231
|
+
});
|
|
225
232
|
const hasRole = hasSelectAccountPermission({
|
|
226
233
|
activeItemPath: cloneDeep(activeItemPath),
|
|
227
234
|
flattenPermissionList,
|
|
@@ -251,10 +258,10 @@ export const Layout = memo(props => {
|
|
|
251
258
|
/** Handle replace current userId in params if current userId is not match */
|
|
252
259
|
useDeepCompareEffect(() => {
|
|
253
260
|
const { userId: userIdParam } = (params || {});
|
|
254
|
-
if (userIdParam &&
|
|
255
|
-
replace(`${location.pathname.replace(userIdParam, `${
|
|
261
|
+
if (userIdParam && accountId && +userIdParam !== +accountId && location.pathname) {
|
|
262
|
+
replace(`${location.pathname.replace(userIdParam, `${accountId}`)}${location.search}`);
|
|
256
263
|
}
|
|
257
|
-
}, [params, location.pathname,
|
|
264
|
+
}, [params, location.pathname, accountId, replace]);
|
|
258
265
|
/** If left menu props has customization then set layout loading to false, because we don't need check permission here */
|
|
259
266
|
useDeepCompareEffect(() => {
|
|
260
267
|
if (mergeLeftMenuProps.customization) {
|
|
@@ -43,7 +43,9 @@ export const OldLeftMenu = memo(props => {
|
|
|
43
43
|
auth: {
|
|
44
44
|
token: auth?.token,
|
|
45
45
|
url: PERMISSION_API,
|
|
46
|
-
|
|
46
|
+
// NOTE: Hot fix for case menu permission working wrong
|
|
47
|
+
// userId: auth?.userId,
|
|
48
|
+
userId: auth?.accountId,
|
|
47
49
|
accountId: auth?.accountId,
|
|
48
50
|
},
|
|
49
51
|
params: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antscorp/antsomi-ui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.41",
|
|
4
4
|
"description": "An enterprise-class UI design language and React UI library.",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"dist/*",
|
|
@@ -251,4 +251,4 @@
|
|
|
251
251
|
"react-dom": ">=16.9.0",
|
|
252
252
|
"react-router-dom": ">= 5.1.0"
|
|
253
253
|
}
|
|
254
|
-
}
|
|
254
|
+
}
|