From 72a1e7b0249c69510af7650e19bf939ed88cf550 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Mon, 16 Sep 2024 17:08:58 +0800 Subject: [PATCH] refactor: change edit style and logic, create new MonitorPicker component --- .../components/monitor/MonitorPicker.tsx | 50 ++++++++- .../monitor/StatusPage/EditForm.tsx | 104 +++++++++++------- .../components/website/WebsiteConfig.tsx | 4 +- src/client/components/website/WebsiteInfo.tsx | 4 +- src/client/utils/type.ts | 3 + 5 files changed, 116 insertions(+), 49 deletions(-) create mode 100644 src/client/utils/type.ts diff --git a/src/client/components/monitor/MonitorPicker.tsx b/src/client/components/monitor/MonitorPicker.tsx index 375e308..9eb2dd8 100644 --- a/src/client/components/monitor/MonitorPicker.tsx +++ b/src/client/components/monitor/MonitorPicker.tsx @@ -1,12 +1,23 @@ -import { Select, SelectProps } from 'antd'; +import { Select as AntdSelect, SelectProps as AntdSelectProps } from 'antd'; import React from 'react'; import { trpc } from '../../api/trpc'; import { useCurrentWorkspaceId } from '../../store/user'; import { ColorTag } from '../ColorTag'; import { useTranslation } from '@i18next-toolkit/react'; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '../ui/select'; +import { PropsOf } from '@/utils/type'; -interface MonitorPickerProps extends SelectProps {} -export const MonitorPicker: React.FC = React.memo( +interface MonitorPickerOldProps extends AntdSelectProps {} +/** + * @deprecated please use MonitorPicker + */ +export const MonitorPickerOld: React.FC = React.memo( (props) => { const { t } = useTranslation(); const workspaceId = useCurrentWorkspaceId(); @@ -15,13 +26,40 @@ export const MonitorPicker: React.FC = React.memo( }); return ( - + + + + + {allMonitor.map((m) => ( + + + {m.name} + + ))} + ); } diff --git a/src/client/components/monitor/StatusPage/EditForm.tsx b/src/client/components/monitor/StatusPage/EditForm.tsx index 5212a70..790ecbb 100644 --- a/src/client/components/monitor/StatusPage/EditForm.tsx +++ b/src/client/components/monitor/StatusPage/EditForm.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { MonitorPicker } from '../MonitorPicker'; +import { MonitorPicker, MonitorPickerOld } from '../MonitorPicker'; import { useTranslation } from '@i18next-toolkit/react'; import { Button } from '@/components/ui/button'; import { LuMinusCircle, LuPlus } from 'react-icons/lu'; @@ -23,6 +23,17 @@ import { domainRegex, slugRegex } from '@tianji/shared'; import { useElementSize } from '@/hooks/useResizeObserver'; import { Switch } from '@/components/ui/switch'; import { Separator } from '@/components/ui/separator'; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '@/components/ui/select'; +import { ColorTag } from '@/components/ColorTag'; +import { Collapsible, CollapsibleContent } from '@/components/ui/collapsible'; +import { CollapsibleTrigger } from '@radix-ui/react-collapsible'; +import { CaretSortIcon } from '@radix-ui/react-icons'; const Text = Typography.Text; @@ -135,42 +146,50 @@ export const MonitorStatusPageEditForm: React.FC )} /> - {/* Description */} - ( - - {t('Description')} - - - - - - )} - /> + + + {t('Advanced')} + + + + {/* Description */} + ( + + {t('Description')} + + + + + + )} + /> - {/* Custom Domain */} - ( - - {t('Custom Domain')} - - - - -
- {t( - 'You can config your status page in your own domain, for example: status.example.com' - )} -
-
- -
- )} - /> + {/* Custom Domain */} + ( + + {t('Custom Domain')} + + + + +
+ {t( + 'You can config your status page in your own domain, for example: status.example.com' + )} +
+
+ +
+ )} + /> +
+
{/* MonitorList */} {t('Monitor List')} {fields.map((field, i) => ( <> - {i !== 0 && } + {i !== 0 && } -
+
} + render={({ field }) => ( + + )} />
@@ -214,6 +239,7 @@ export const MonitorStatusPageEditForm: React.FC
))} +