@giteeteam/apps-team-components 1.10.1-alpha.1 → 1.10.2

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.
@@ -3,6 +3,9 @@ import { memo } from 'react';
3
3
  import { ClassNames } from '@emotion/react';
4
4
  import { useCreation } from 'ahooks';
5
5
  import { getArrayValue } from '../../../lib/array.js';
6
+ import useI18n from '../../../lib/hooks/useI18n.js';
7
+ import useTeamConfig from '../../../lib/hooks/useTeamConfig.js';
8
+ import { isInCMCC } from '../../../lib/isInCMCC.js';
6
9
  import EmptyField from '../../common/EmptyField.js';
7
10
  import { tooltipOverflowStyle, getTooltipMaxlineStyle } from '../../common/overflow-tooltip/style/index.js';
8
11
  import { useToWorkspacePage } from './hooks.js';
@@ -11,12 +14,16 @@ import ValueDisplay from './ValueDisplay.js';
11
14
 
12
15
  const BindWorkspaceReadView = memo(props => {
13
16
  const { value: _value, mode } = props;
17
+ const { t } = useI18n();
18
+ const { publicRuntimeConfig } = useTeamConfig();
19
+ const inCMCC = isInCMCC(publicRuntimeConfig);
14
20
  const { toWorkspacePage } = useToWorkspacePage();
15
21
  const value = useCreation(() => getArrayValue(_value), [_value]);
22
+ const title = useCreation(() => (inCMCC ? '' : t('pages.fields.default.toWorkspacePage')), [t, inCMCC]);
16
23
  return (jsx(ClassNames, { children: ({ cx, css }) => {
17
24
  if (!(value === null || value === void 0 ? void 0 : value.length))
18
25
  return jsx(EmptyField, { readonly: true });
19
- return (jsx(ValueDisplay, { mode: mode, value: value, wrapperClassName: cx(css(tooltipOverflowStyle), css(getTooltipMaxlineStyle(1))), itemClassName: cx(css(pointerStyle)), onClick: toWorkspacePage }));
26
+ return (jsx(ValueDisplay, { title: title, mode: mode, value: value, wrapperClassName: cx(css(tooltipOverflowStyle), css(getTooltipMaxlineStyle(1))), itemClassName: cx(css(pointerStyle)), onClick: toWorkspacePage }));
20
27
  } }));
21
28
  });
22
29
  BindWorkspaceReadView.displayName = 'BindWorkspaceReadView';
@@ -1,4 +1,5 @@
1
1
  interface ValueDisplayBaseProps {
2
+ title?: string;
2
3
  value: any[];
3
4
  onClick?: (workspaceKey: string) => void;
4
5
  wrapperClassName?: string;
@@ -2,20 +2,17 @@ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
2
2
  import { memo, Fragment } from 'react';
3
3
  import OverflowTooltip from '../../common/overflow-tooltip/OverflowTooltip.js';
4
4
  import { getArrayValue } from '../../../lib/array.js';
5
- import useI18n from '../../../lib/hooks/useI18n.js';
6
5
 
7
6
  const WorkspaceLabel = memo(props => {
8
7
  const { title, onClick, className, workspace } = props;
9
8
  const { key, name } = workspace;
10
9
  return (jsx("span", { title: title, onClick: () => onClick(key), className: className, children: name }));
11
10
  });
12
- const SingleValueDisplay = memo(({ value, onClick, wrapperClassName, itemClassName }) => {
13
- const { t } = useI18n();
11
+ const SingleValueDisplay = memo(({ value, onClick, wrapperClassName, itemClassName, title }) => {
14
12
  const [workspace] = getArrayValue(value);
15
- return (jsx(WorkspaceLabel, { title: t('pages.fields.default.toWorkspacePage'), onClick: onClick, className: `${wrapperClassName} ${itemClassName} single`, workspace: workspace }));
13
+ return (jsx(WorkspaceLabel, { title: title, onClick: onClick, className: `${wrapperClassName} ${itemClassName} single`, workspace: workspace }));
16
14
  });
17
- const MultipleValueDisplay = memo(({ value, onClick, itemClassName }) => {
18
- const { t } = useI18n();
15
+ const MultipleValueDisplay = memo(({ value, onClick, itemClassName, title }) => {
19
16
  const showValue = value
20
17
  .map(workspace => workspace === null || workspace === void 0 ? void 0 : workspace.name)
21
18
  .filter(Boolean)
@@ -23,7 +20,7 @@ const MultipleValueDisplay = memo(({ value, onClick, itemClassName }) => {
23
20
  if (!showValue)
24
21
  return null;
25
22
  return (jsx(OverflowTooltip, { title: value.map((workspace, index) => {
26
- return (jsxs(Fragment, { children: [jsx(WorkspaceLabel, { title: t('pages.fields.default.toWorkspacePage'), onClick: onClick, className: itemClassName, workspace: workspace }), index !== value.length - 1 && ','] }, workspace.key));
23
+ return (jsxs(Fragment, { children: [jsx(WorkspaceLabel, { title: title, onClick: onClick, className: itemClassName, workspace: workspace }), index !== value.length - 1 && ','] }, workspace.key));
27
24
  }), enterable: true, alwaysShowTooltip: true, children: showValue }));
28
25
  });
29
26
  MultipleValueDisplay.displayName = 'MultipleValueDisplay';
@@ -1,13 +1,17 @@
1
1
  import { useMemoizedFn } from 'ahooks';
2
2
  import useTeamConfig from '../../../lib/hooks/useTeamConfig.js';
3
3
  import useTenant from '../../../lib/hooks/useTenant.js';
4
+ import { isInCMCC } from '../../../lib/isInCMCC.js';
4
5
  import isInOne from '../../../lib/isInOne.js';
5
6
 
6
7
  const useToWorkspacePage = () => {
7
8
  const { publicRuntimeConfig, isMicroApp } = useTeamConfig();
8
9
  const inOne = isInOne(publicRuntimeConfig.gateway, isMicroApp);
10
+ const inCmcc = isInCMCC(publicRuntimeConfig);
9
11
  const tenant = useTenant();
10
12
  const toWorkspacePage = useMemoizedFn((workspaceKey) => {
13
+ if (inCmcc)
14
+ return;
11
15
  const url = inOne
12
16
  ? `/${tenant}/${workspaceKey}`
13
17
  : `${publicRuntimeConfig.basePath}/${tenant}/workspaces/${workspaceKey}`;
@@ -0,0 +1,3 @@
1
+ type ENV = 'one' | 'cmcc' | 'demo' | 'test' | 'prod';
2
+ export declare const mockENV: ENV;
3
+ export {};
@@ -0,0 +1,5 @@
1
+ import { getLocalStorageItem } from './storage.js';
2
+
3
+ const mockENV = getLocalStorageItem('mockENV');
4
+
5
+ export { mockENV };
@@ -0,0 +1 @@
1
+ export declare const isInCMCC: (config?: Record<string, any>) => boolean;
@@ -0,0 +1,10 @@
1
+ import { mockENV } from './env.js';
2
+
3
+ const isInCMCC = (config) => {
4
+ const { routePath } = config || {};
5
+ if (mockENV === 'cmcc')
6
+ return true;
7
+ return !!routePath;
8
+ };
9
+
10
+ export { isInCMCC };
@@ -1,4 +1,8 @@
1
+ import { mockENV } from './env.js';
2
+
1
3
  const isInOne = (gateway, isMicroApp) => {
4
+ if (mockENV === 'one')
5
+ return true;
2
6
  if (isMicroApp != null)
3
7
  return !!isMicroApp;
4
8
  if (!gateway)
@@ -1,8 +1,8 @@
1
- export declare const getLocalStorageItem: (key: string, defaults?: any) => any;
1
+ export declare const getLocalStorageItem: <T = any>(key: string, defaults?: any) => T;
2
2
  export declare const setLocalStorageItem: (key: string, value: unknown) => boolean;
3
3
  export declare const removeParseItems: () => void;
4
4
  declare const _default: {
5
- getItem: (key: string, defaults?: any) => any;
5
+ getItem: <T = any>(key: string, defaults?: any) => T;
6
6
  setItem: (key: string, value: unknown) => boolean;
7
7
  removeParseItems: () => void;
8
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-team-components",
3
- "version": "1.10.1-alpha.1",
3
+ "version": "1.10.2",
4
4
  "description": "Gitee team components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",