@antscorp/antsomi-ui 1.3.5-beta.596 → 1.3.5-beta.598

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.
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { IconProps } from './types';
3
+ export declare const ExpandMoreIcon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<SVGSVGElement>>;
@@ -0,0 +1,7 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { useIcon } from './hooks/useIcon';
3
+ export const ExpandMoreIcon = forwardRef((props, ref) => {
4
+ const { width, height } = useIcon(props);
5
+ return (React.createElement("svg", Object.assign({ viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, props, { ref: ref, width: width, height: height }),
6
+ React.createElement("path", { d: "M16.5938 8.57812L18 9.98438L12 15.9844L6 9.98438L7.40625 8.57812L12 13.1719L16.5938 8.57812Z", fill: "currentColor" })));
7
+ });
@@ -238,3 +238,4 @@ export { WebIcon } from './WebIcon';
238
238
  export { WebhookIcon } from './WebhookIcon';
239
239
  export { WidgetIcon } from './WidgetIcon';
240
240
  export { WritingAIAssitantIcon } from './WritingAIAssitantIcon';
241
+ export { ExpandMoreIcon } from './ExpandMoreIcon';
@@ -238,3 +238,4 @@ export { WebIcon } from './WebIcon';
238
238
  export { WebhookIcon } from './WebhookIcon';
239
239
  export { WidgetIcon } from './WidgetIcon';
240
240
  export { WritingAIAssitantIcon } from './WritingAIAssitantIcon';
241
+ export { ExpandMoreIcon } from './ExpandMoreIcon';
@@ -42,6 +42,7 @@ export interface HeaderV2Props {
42
42
  permissionDomain?: string;
43
43
  iamDomain?: string;
44
44
  };
45
+ onCLickLogo?: () => void;
45
46
  }
46
47
  export declare const HeaderV2: React.FC<HeaderV2Props>;
47
48
  export {};
@@ -32,7 +32,7 @@ export const HeaderV2 = memo(props => {
32
32
  const { search } = useLocation();
33
33
  const { replace } = useCustomRouter();
34
34
  // * Prefer to use Header in AppConfigContext
35
- const { show = true, className, style, breadcrumbs, showLogo = false, rightContent, pageTitle = '', accountSelection = {}, helpConfig, notificationConfig = {}, accountSharingConfig, useURLParam, config, } = props;
35
+ const { show = true, className, style, breadcrumbs, showLogo = false, rightContent, pageTitle = '', accountSelection = {}, helpConfig, notificationConfig = {}, accountSharingConfig, useURLParam, config, onCLickLogo, } = props;
36
36
  /** General config for children component */
37
37
  const { env = envContext, language = languageCode, userId = isNaN(Number(auth === null || auth === void 0 ? void 0 : auth.userId)) ? 0 : Number(auth === null || auth === void 0 ? void 0 : auth.userId), portalId = auth === null || auth === void 0 ? void 0 : auth.portalId, token = auth === null || auth === void 0 ? void 0 : auth.token, permissionDomain = PERMISSION_API, iamDomain = IAM_API, appCode = contextAppCode, menuCode = contextMenuCode, } = config || {};
38
38
  const { currentAccount, inputStyle = 'select', onSelectAccount } = accountSelection, accountSelectionProps = __rest(accountSelection, ["currentAccount", "inputStyle", "onSelectAccount"]);
@@ -110,7 +110,7 @@ export const HeaderV2 = memo(props => {
110
110
  const QUOTE_ENTITY = React.createElement(React.Fragment, null, "\u00BB");
111
111
  return (React.createElement(HeaderV2Styled, { "$show": show, className: className || '', style: style },
112
112
  React.createElement("div", { className: "left-side" },
113
- showLogo && (React.createElement(LogoWrapper, { className: "logo-wrapper" },
113
+ showLogo && (React.createElement(LogoWrapper, { className: "logo-wrapper", onClick: onCLickLogo },
114
114
  React.createElement("img", { src: SubLogoAntsomi, alt: "Antsomi sub logo" }))),
115
115
  React.createElement(AccountSelection, Object.assign({}, accountSelectionProps, { currentAccount: selectedAccount, apiConfig: accountSelectionApiConfig, onChange: handleChangeAccount, inputStyle: inputStyle, refreshOnSelect: true })),
116
116
  React.createElement("div", { className: "title-container" },
@@ -6,6 +6,7 @@ import { THEME, globalToken } from '@antscorp/antsomi-ui/es/constants';
6
6
  export const LogoWrapper = styled.div `
7
7
  height: 30px;
8
8
  width: 30px;
9
+ cursor: pointer;
9
10
 
10
11
  img {
11
12
  height: 100%;
@@ -19,12 +19,12 @@ import CloseIcon from './icons/close';
19
19
  import SearchIcon from './icons/search';
20
20
  import { InnerCardStyled, InputSearchStyled, PackageSharingStyled, TriggerPopoverStyled, } from './styled';
21
21
  // Utils
22
- import { formatUserId } from '@antscorp/antsomi-ui/es/utils';
22
+ import { formatUserId, removeAppCookieSessionSubdomain, removeAppCookieSessionSubdomainPrefix, } from '@antscorp/antsomi-ui/es/utils';
23
23
  import { translate } from './utils';
24
24
  import Icon from '@antscorp/icons';
25
25
  import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounceV2';
26
26
  import { DEFAULT_TRANSLATE_DATA } from './constant';
27
- import { THEME, UOGS_PREFIX } from '@antscorp/antsomi-ui/es/constants';
27
+ import { CDP_ROUTE, THEME, UOGS_PREFIX } from '@antscorp/antsomi-ui/es/constants';
28
28
  import { useAppConfigContext } from '../../..';
29
29
  // Constants
30
30
  import { ENV } from '@antscorp/antsomi-ui/es/config';
@@ -229,18 +229,33 @@ export const AccountSharing = props => {
229
229
  });
230
230
  // const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
231
231
  const onClickButtonLogout = useCallback(() => {
232
- removeCookie(`${UOGS_PREFIX}${networkId}`, Object.assign(Object.assign({}, (env !== ENV.DEV && {
233
- domain: `.${origin.split('.').splice(-2).join('.')}`,
234
- })), { path: '/', sameSite: 'none', secure: true }));
232
+ // Handle remove cookie and redirect to login
233
+ removeAppCookieSessionSubdomainPrefix({ name: UOGS_PREFIX, env });
234
+ removeAppCookieSessionSubdomain({ name: 'c_pid', env });
235
+ removeAppCookieSessionSubdomain({ name: 'api_token', env });
236
+ removeAppCookieSessionSubdomain({ name: 'api_r_token', env });
237
+ removeAppCookieSessionSubdomain({ name: 'api_pid', env });
238
+ removeAppCookieSessionSubdomain({ name: 'user_id', env });
239
+ removeAppCookieSessionSubdomain({ name: 'user_logged_in_email', env });
240
+ removeAppCookieSessionSubdomain({ name: 'user_logged_in_full_name', env });
241
+ removeAppCookieSessionSubdomain({ name: 'user_logged_in_avatar', env });
242
+ removeAppCookieSessionSubdomain({ name: '_fe_ogs_pid', env });
243
+ localStorage.removeItem('cdp_decrypt_permission');
235
244
  if (callbackLogout)
236
245
  callbackLogout();
237
- if (urlLogout) {
238
- window.location.href = urlLogout;
239
- }
240
- else {
246
+ // Check if env is dev
247
+ if (env === ENV.DEV) {
241
248
  window.location.reload();
249
+ return;
242
250
  }
243
- }, [callbackLogout, env, networkId, removeCookie, urlLogout]);
251
+ // Handle logout with cdp domain
252
+ window.location.href = `${CDP_ROUTE[ENV.PROD]}/iam#/login`;
253
+ // if (urlLogout) {
254
+ // window.location.href = urlLogout;
255
+ // } else {
256
+ // window.location.reload();
257
+ // }
258
+ }, [callbackLogout, env]);
244
259
  useEffect(() => {
245
260
  const logoutEvent = (event) => {
246
261
  const { data } = event;
@@ -18,7 +18,7 @@ import { useLeftMenuContext } from './contexts';
18
18
  const SubLogoAntsomi = 'https://st-media-template.antsomi.com/icons/antsomi/antsomi.png';
19
19
  const homePermissionCode = 'DASHBOARD';
20
20
  export const LeftMenuComponent = memo(props => {
21
- const { show = true, style, className, customization, showLogo = true } = props;
21
+ const { show = true, style, className, customization, showLogo = true, onClickLogo } = props;
22
22
  const { showMenuPopover = true, showButtonExpand = true, type, items = [], onMenuItemClick, } = customization || {};
23
23
  const appHoverMenuChildren = useLeftMenuContext(store => store.appHoverMenuChildren);
24
24
  const customHoverMenuChildren = useLeftMenuContext(store => store.customHoverMenuChildren);
@@ -109,7 +109,7 @@ export const LeftMenuComponent = memo(props => {
109
109
  return (React.createElement(LeftMenuNavWrapper, { "$show": show, style: style, "$isExpandMenu": state.isExpandMenu, className: className },
110
110
  React.createElement(LeftMenuNav, { className: "left-menu-nav" },
111
111
  React.createElement(FeatureMenuWrapper, { vertical: true, onMouseEnter: () => onShowPopover(), onMouseLeave: onMouseLeave },
112
- showLogo && (React.createElement(NavLogoWrapper, { align: "center", justify: "center", onMouseEnter: onHoverMenuBar },
112
+ showLogo && (React.createElement(NavLogoWrapper, { align: "center", justify: "center", onMouseEnter: onHoverMenuBar, onClick: onClickLogo },
113
113
  React.createElement("div", { className: "image-wrapper" },
114
114
  React.createElement("img", { src: SubLogoAntsomi, alt: "Antsomi sub logo" })))),
115
115
  React.createElement(FeatureMenu, { role: "menu", className: "antsomi-scroll-box" },
@@ -20,6 +20,7 @@ export interface LeftMenuProps {
20
20
  defaultExpandMenu?: boolean;
21
21
  onMenuItemClick?: (key: string, keyPath: string[]) => void;
22
22
  };
23
+ onClickLogo?: () => void;
23
24
  onActiveMenuCodeChange?: (activeItemPath: TFeatureMenu[], flattenPermissionList?: FeatureMenuPermission[], menuListPermission?: FeatureMenuPermission[]) => void;
24
25
  }
25
26
  export declare const LeftMenu: React.MemoExoticComponent<(props: LeftMenuProps) => React.JSX.Element | null>;
@@ -276,6 +276,12 @@ export const Layout = memo(props => {
276
276
  }
277
277
  }
278
278
  }, [antsProcessingNotificationConfig, env]);
279
+ const onCLickLogo = useCallback(() => {
280
+ // Redirect to recommendation
281
+ if (env !== ENV.DEV) {
282
+ window.location.assign(`${CDP_ROUTE[env || 'development']}/gen2/${portalId}/dashboard/recommendation`);
283
+ }
284
+ }, [env, portalId]);
279
285
  return (React.createElement(LayoutWrapper, { showLeftMenu: !!showLeftMenu },
280
286
  React.createElement(Helmet, null,
281
287
  React.createElement("meta", { charSet: "utf-8" }),
@@ -285,7 +291,7 @@ export const Layout = memo(props => {
285
291
  ? header === null || header === void 0 ? void 0 : header.pageTitle
286
292
  : ''
287
293
  : activePageTitle))),
288
- React.createElement(HeaderV2, Object.assign({}, mergeHeaderProps, { show: !showOnlyContent, showLogo: !showLeftMenu })),
294
+ React.createElement(HeaderV2, Object.assign({}, mergeHeaderProps, { show: !showOnlyContent, showLogo: !showLeftMenu, onCLickLogo: onCLickLogo })),
289
295
  React.createElement(Flex, { className: "layout-body" },
290
296
  React.createElement(LeftMenu, Object.assign({ show: showLeftMenu && !showOnlyContent, className: `layout-body__menu ${leftMenuClassName}` }, mergeLeftMenuProps, { customization: Object.assign(Object.assign({}, mergeLeftMenuProps.customization), {
291
297
  // If user has access denied, disable expandable
@@ -191,14 +191,34 @@ export const GlobalStyle = () => {
191
191
 
192
192
  // NOTE: Just hot fix for easy looking
193
193
  .antsomi-btn-primary.antsomi-btn-compact-item.antsomi-btn-compact-first-item {
194
- padding-right: 4px !important;
194
+ padding-right: 6px !important;
195
195
  }
196
196
  .antsomi-btn-compact-item.antsomi-btn-primary.antsomi-btn-compact-last-item {
197
197
  width: fit-content;
198
- padding: 0px !important;
199
- padding-right: 4px !important;
198
+ //padding: 0px !important;
199
+ padding: 0px 4px !important;
200
200
  &::before {
201
- width: 0px !important;
201
+ content: '';
202
+ position: absolute;
203
+ left: 0px;
204
+ background-color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.blue5} !important;
205
+ top: auto !important;
206
+ height: 80% !important;
207
+ width: 1px !important;
208
+ }
209
+
210
+ &:disabled {
211
+ &::before {
212
+ background-color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw4} !important;
213
+ }
214
+ }
215
+
216
+ &:not(:disabled) {
217
+ &:hover {
218
+ &:: before {
219
+ opacity: 0;
220
+ }
221
+ }
202
222
  }
203
223
  }
204
224
 
@@ -0,0 +1,10 @@
1
+ import { TEnv } from '../types/config';
2
+ interface RemoveCookieSubDomain {
3
+ name: string;
4
+ env?: TEnv;
5
+ cookieOptions?: Record<string, any>;
6
+ }
7
+ export declare const removeCookieSubDomain: ({ name, env, cookieOptions, }: RemoveCookieSubDomain) => void;
8
+ export declare const removeAppCookieSessionSubdomain: (args: RemoveCookieSubDomain) => void;
9
+ export declare const removeAppCookieSessionSubdomainPrefix: (args: RemoveCookieSubDomain) => void;
10
+ export {};
@@ -0,0 +1,23 @@
1
+ // Libraries
2
+ import { Cookies } from 'react-cookie';
3
+ import { ENV } from '../config';
4
+ const cookies = new Cookies();
5
+ export const removeCookieSubDomain = ({ name, env = 'development', cookieOptions, }) => {
6
+ const arrTmp = location.hostname.split('.');
7
+ cookies.remove(name, Object.assign(Object.assign(Object.assign({}, (env !== ENV.DEV && {
8
+ domain: arrTmp.length < 4 ? arrTmp.slice(-2).join('.') : arrTmp.slice(-3).join('.'),
9
+ })), { path: '/', sameSite: 'none', secure: true }), cookieOptions));
10
+ };
11
+ export const removeAppCookieSessionSubdomain = (args) => {
12
+ removeCookieSubDomain(args);
13
+ if (typeof Storage !== undefined) {
14
+ sessionStorage.removeItem(args.name);
15
+ }
16
+ };
17
+ export const removeAppCookieSessionSubdomainPrefix = (args) => {
18
+ Object.keys(cookies.getAll()).forEach(cookieName => {
19
+ if (cookieName.startsWith(args.name)) {
20
+ removeAppCookieSessionSubdomain(args);
21
+ }
22
+ });
23
+ };
@@ -6,3 +6,4 @@ export * from './styles';
6
6
  export * from './variables';
7
7
  export * from './actionButtons';
8
8
  export * from './dataTable';
9
+ export * from './cookie';
package/es/utils/index.js CHANGED
@@ -6,3 +6,4 @@ export * from './styles';
6
6
  export * from './variables';
7
7
  export * from './actionButtons';
8
8
  export * from './dataTable';
9
+ export * from './cookie';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.596",
3
+ "version": "1.3.5-beta.598",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",