From 6debd1e06060d0417204cd6c0d98f8c9f25b051a Mon Sep 17 00:00:00 2001 From: Hugo Costa Date: Mon, 16 Oct 2023 09:17:04 -0300 Subject: [PATCH] changes request --- .../VersionCard/VersionCard.tsx | 6 ++-- .../components/VersionCardActionButton.tsx | 6 +++- .../components/VersionCardActionItem.tsx | 7 +++- .../components/VersionCardActionItemList.tsx | 2 +- .../VersionCard/components/VersionTag.tsx | 2 +- .../VersionCard/types/VersionActionButton.ts | 6 ---- .../VersionCard/types/VersionActionItem.ts | 8 ----- .../VersionCard/types/VersionStatus.ts | 1 - .../workspaceStatus/WorkspaceStatusRoute.tsx | 28 ++++++++-------- .../ui-client/src/components/FramedIcon.tsx | 32 +++++++++++-------- 10 files changed, 48 insertions(+), 50 deletions(-) delete mode 100644 apps/meteor/client/views/admin/workspaceStatus/VersionCard/types/VersionActionButton.ts delete mode 100644 apps/meteor/client/views/admin/workspaceStatus/VersionCard/types/VersionActionItem.ts delete mode 100644 apps/meteor/client/views/admin/workspaceStatus/VersionCard/types/VersionStatus.ts diff --git a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/VersionCard.tsx b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/VersionCard.tsx index 45aee4e4258a..d57cd55ea152 100644 --- a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/VersionCard.tsx +++ b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/VersionCard.tsx @@ -13,12 +13,12 @@ import { useLicense } from '../../../../hooks/useLicense'; import { useRegistrationStatus } from '../../../../hooks/useRegistrationStatus'; import { isOverLicenseLimits } from '../../../../lib/utils/isOverLicenseLimits'; import VersionCardActionButton from './components/VersionCardActionButton'; +import type { VersionActionButton } from './components/VersionCardActionButton'; +import type { VersionActionItem } from './components/VersionCardActionItem'; import VersionCardActionItemList from './components/VersionCardActionItemList'; import { VersionCardSkeleton } from './components/VersionCardSkeleton'; import { VersionTag } from './components/VersionTag'; -import type { VersionActionButton } from './types/VersionActionButton'; -import type { VersionActionItem } from './types/VersionActionItem'; -import type { VersionStatus } from './types/VersionStatus'; +import type { VersionStatus } from './components/VersionTag'; const SUPPORT_EXTERNAL_LINK = 'https://go.rocket.chat/i/version-support'; const RELEASES_EXTERNAL_LINK = 'https://go.rocket.chat/i/update-product'; diff --git a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionCardActionButton.tsx b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionCardActionButton.tsx index f66ec2e2133c..6c0adeb31ce5 100644 --- a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionCardActionButton.tsx +++ b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionCardActionButton.tsx @@ -5,12 +5,16 @@ import type { ReactElement } from 'react'; import React, { memo } from 'react'; import RegisterWorkspaceModal from '../../../cloud/modals/RegisterWorkspaceModal'; -import type { VersionActionButton } from '../types/VersionActionButton'; type VersionCardActionButtonProps = { actionButton: VersionActionButton; }; +export type VersionActionButton = { + path: string; + label: ReactElement; +}; + const VersionCardActionButton = ({ actionButton }: VersionCardActionButtonProps): ReactElement => { const router = useRouter(); const setModal = useSetModal(); diff --git a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionCardActionItem.tsx b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionCardActionItem.tsx index e10868ccca79..bc3813ae28af 100644 --- a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionCardActionItem.tsx +++ b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionCardActionItem.tsx @@ -1,9 +1,14 @@ import { Box } from '@rocket.chat/fuselage'; +import type { Keys } from '@rocket.chat/icons'; import { FramedIcon } from '@rocket.chat/ui-client'; import type { ReactElement } from 'react'; import React from 'react'; -import type { VersionActionItem } from '../types/VersionActionItem'; +export type VersionActionItem = { + type: 'danger' | 'neutral'; + icon: Keys; + label: ReactElement; +}; type VersionCardActionItemProps = { actionItem: VersionActionItem; diff --git a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionCardActionItemList.tsx b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionCardActionItemList.tsx index d6e71b8daa53..62f11ed9110f 100644 --- a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionCardActionItemList.tsx +++ b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionCardActionItemList.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import type { VersionActionItem } from '../types/VersionActionItem'; +import type { VersionActionItem } from './VersionCardActionItem'; import VersionCardActionItem from './VersionCardActionItem'; type VersionCardActionItemListProps = { diff --git a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionTag.tsx b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionTag.tsx index 3b77ff8ed3f7..c890ba6716e2 100644 --- a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionTag.tsx +++ b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/components/VersionTag.tsx @@ -2,7 +2,7 @@ import { Tag } from '@rocket.chat/fuselage'; import React from 'react'; import { useTranslation } from 'react-i18next'; -import type { VersionStatus } from '../types/VersionStatus'; +export type VersionStatus = 'outdated' | 'latest' | 'available_version' | undefined; type VersionTagProps = { versionStatus: VersionStatus; diff --git a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/types/VersionActionButton.ts b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/types/VersionActionButton.ts deleted file mode 100644 index 8c8a350f8870..000000000000 --- a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/types/VersionActionButton.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { ReactElement } from 'react'; - -export type VersionActionButton = { - path: string; - label: ReactElement; -}; diff --git a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/types/VersionActionItem.ts b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/types/VersionActionItem.ts deleted file mode 100644 index ffd954212dff..000000000000 --- a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/types/VersionActionItem.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { Keys } from '@rocket.chat/icons'; -import type { ReactElement } from 'react'; - -export type VersionActionItem = { - type: 'danger' | 'neutral'; - icon: Keys; - label: ReactElement; -}; diff --git a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/types/VersionStatus.ts b/apps/meteor/client/views/admin/workspaceStatus/VersionCard/types/VersionStatus.ts deleted file mode 100644 index 33170392b104..000000000000 --- a/apps/meteor/client/views/admin/workspaceStatus/VersionCard/types/VersionStatus.ts +++ /dev/null @@ -1 +0,0 @@ -export type VersionStatus = 'outdated' | 'latest' | 'available_version' | undefined; diff --git a/apps/meteor/client/views/admin/workspaceStatus/WorkspaceStatusRoute.tsx b/apps/meteor/client/views/admin/workspaceStatus/WorkspaceStatusRoute.tsx index ad1e1daa52fc..9592fcbe7fb6 100644 --- a/apps/meteor/client/views/admin/workspaceStatus/WorkspaceStatusRoute.tsx +++ b/apps/meteor/client/views/admin/workspaceStatus/WorkspaceStatusRoute.tsx @@ -31,6 +31,10 @@ const WorkspaceStatusRoute = (): ReactElement => { downloadJsonAs(statistics, 'statistics'); }; + if (!canViewStatistics) { + return ; + } + if (isLoading) { return ; } @@ -52,20 +56,16 @@ const WorkspaceStatusRoute = (): ReactElement => { ); } - if (canViewStatistics) { - return ( - - ); - } - - return ; + return ( + + ); }; export default memo(WorkspaceStatusRoute); diff --git a/packages/ui-client/src/components/FramedIcon.tsx b/packages/ui-client/src/components/FramedIcon.tsx index 8f150dc1440f..6fa2b230c661 100644 --- a/packages/ui-client/src/components/FramedIcon.tsx +++ b/packages/ui-client/src/components/FramedIcon.tsx @@ -2,23 +2,27 @@ import { Box, Icon } from '@rocket.chat/fuselage'; import type { Keys } from '@rocket.chat/icons'; import type { FC } from 'react'; -const getColors = (type: string) => { - switch (type) { - case 'danger': - return { color: 'status-font-on-danger', bg: 'status-background-danger' }; - case 'info': - return { color: 'status-font-on-info', bg: 'status-background-info' }; - case 'success': - return { color: 'status-font-on-success', bg: 'status-background-success' }; - case 'warning': - return { color: 'status-font-on-warning', bg: 'status-background-warning' }; - default: - return { color: 'font-secondary-info', bg: 'surface-tint' }; - } +type Variant = 'danger' | 'info' | 'success' | 'warning' | 'neutral'; + +type ColorMapType = { + [key in Variant]: { + color: string; + bg: string; + }; +}; + +const colorMap: ColorMapType = { + danger: { color: 'status-font-on-danger', bg: 'status-background-danger' }, + info: { color: 'status-font-on-info', bg: 'status-background-info' }, + success: { color: 'status-font-on-success', bg: 'status-background-success' }, + warning: { color: 'status-font-on-warning', bg: 'status-background-warning' }, + neutral: { color: 'font-secondary-info', bg: 'surface-tint' }, }; +const getColors = (type: Variant) => colorMap[type] || colorMap.neutral; + type FramedIconProps = { - type: 'danger' | 'info' | 'success' | 'warning' | 'neutral'; + type: Variant; icon: Keys; };