From fd1f81cbe91620c03b30ae61223d1ba10e9ff5d2 Mon Sep 17 00:00:00 2001 From: wangsijie Date: Thu, 16 Feb 2023 10:42:03 +0800 Subject: [PATCH] feat(console): group connector form items (#3115) --- .../components/ConnectorContent.module.scss | 9 +++ .../components/ConnectorContent.tsx | 9 +-- .../pages/ConnectorDetails/index.module.scss | 4 -- ...ndex.module.scss => BasicForm.module.scss} | 0 .../{index.tsx => BasicForm.tsx} | 47 +++------------- .../components/ConnectorForm/ConfigForm.tsx | 55 +++++++++++++++++++ .../components/Guide/index.module.scss | 15 ++--- .../Connectors/components/Guide/index.tsx | 39 ++++++++----- 8 files changed, 106 insertions(+), 72 deletions(-) create mode 100644 packages/console/src/pages/ConnectorDetails/components/ConnectorContent.module.scss rename packages/console/src/pages/Connectors/components/ConnectorForm/{index.module.scss => BasicForm.module.scss} (100%) rename packages/console/src/pages/Connectors/components/ConnectorForm/{index.tsx => BasicForm.tsx} (77%) create mode 100644 packages/console/src/pages/Connectors/components/ConnectorForm/ConfigForm.tsx diff --git a/packages/console/src/pages/ConnectorDetails/components/ConnectorContent.module.scss b/packages/console/src/pages/ConnectorDetails/components/ConnectorContent.module.scss new file mode 100644 index 000000000..59c90ff09 --- /dev/null +++ b/packages/console/src/pages/ConnectorDetails/components/ConnectorContent.module.scss @@ -0,0 +1,9 @@ +@use '@/scss/underscore' as _; + +.configForm { + margin-top: _.unit(6); +} + +.senderTest { + margin-top: _.unit(6); +} diff --git a/packages/console/src/pages/ConnectorDetails/components/ConnectorContent.tsx b/packages/console/src/pages/ConnectorDetails/components/ConnectorContent.tsx index e98915abc..b664cb78a 100644 --- a/packages/console/src/pages/ConnectorDetails/components/ConnectorContent.tsx +++ b/packages/console/src/pages/ConnectorDetails/components/ConnectorContent.tsx @@ -10,13 +10,14 @@ import FormCard from '@/components/FormCard'; import UnsavedChangesAlertModal from '@/components/UnsavedChangesAlertModal'; import useApi from '@/hooks/use-api'; import useDocumentationUrl from '@/hooks/use-documentation-url'; -import ConnectorForm from '@/pages/Connectors/components/ConnectorForm'; +import BasicForm from '@/pages/Connectors/components/ConnectorForm/BasicForm'; +import ConfigForm from '@/pages/Connectors/components/ConnectorForm/ConfigForm'; import { useConfigParser } from '@/pages/Connectors/components/ConnectorForm/hooks'; import { initFormData, parseFormConfig } from '@/pages/Connectors/components/ConnectorForm/utils'; import type { ConnectorFormType } from '@/pages/Connectors/types'; import { SyncProfileMode } from '@/pages/Connectors/types'; -import * as styles from '../index.module.scss'; +import * as styles from './ConnectorContent.module.scss'; import SenderTester from './SenderTester'; type Props = { @@ -99,12 +100,12 @@ const ConnectorContent = ({ isDeleted, connectorData, onConnectorUpdated }: Prop description="connector_details.settings_description" learnMoreLink={getDocumentationUrl('/docs/references/connectors')} > - + {connectorData.type !== ConnectorType.Social && ( { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const { getDocumentationUrl } = useDocumentationUrl(); @@ -136,29 +128,6 @@ const ConnectorForm = ({ )} - {formItems ? ( - - ) : ( - - jsonValidator(value) || t('errors.invalid_json_format'), - }} - render={({ field: { onChange, value } }) => ( - - )} - /> - - )} {connectorType === ConnectorType.Social && ( { + const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); + const { + control, + formState: { errors }, + } = useFormContext(); + + return ( +
+ {formItems ? ( + + ) : ( + + jsonValidator(value) || t('errors.invalid_json_format'), + }} + render={({ field: { onChange, value } }) => ( + + )} + /> + + )} +
+ ); +}; + +export default ConfigForm; diff --git a/packages/console/src/pages/Connectors/components/Guide/index.module.scss b/packages/console/src/pages/Connectors/components/Guide/index.module.scss index e469fba03..29effe646 100644 --- a/packages/console/src/pages/Connectors/components/Guide/index.module.scss +++ b/packages/console/src/pages/Connectors/components/Guide/index.module.scss @@ -46,14 +46,13 @@ } .setup { - background-color: var(--color-layer-1); - border-radius: 16px; - padding: 0 _.unit(6) _.unit(6); margin: _.unit(6) _.unit(18) _.unit(6) _.unit(3); - .title { - font: var(--font-title-1); - margin: _.unit(6) 0; + .block { + background-color: var(--color-layer-1); + border-radius: 16px; + padding: _.unit(6); + margin-bottom: _.unit(6); } .footer { @@ -68,7 +67,3 @@ } } } - -.tester { - margin-top: _.unit(6); -} diff --git a/packages/console/src/pages/Connectors/components/Guide/index.tsx b/packages/console/src/pages/Connectors/components/Guide/index.tsx index 496825a73..6f0277167 100644 --- a/packages/console/src/pages/Connectors/components/Guide/index.tsx +++ b/packages/console/src/pages/Connectors/components/Guide/index.tsx @@ -21,7 +21,8 @@ import SenderTester from '@/pages/ConnectorDetails/components/SenderTester'; import type { ConnectorFormType } from '../../types'; import { SyncProfileMode } from '../../types'; -import ConnectorForm from '../ConnectorForm'; +import BasicForm from '../ConnectorForm/BasicForm'; +import ConfigForm from '../ConnectorForm/ConfigForm'; import { useConfigParser } from '../ConnectorForm/hooks'; import { initFormData, parseFormConfig } from '../ConnectorForm/utils'; import * as styles from './index.module.scss'; @@ -117,23 +118,31 @@ const Guide = ({ connector, onClose }: Props) => {
{readme}
-
{t('connectors.guide.connector_setting')}
- - {!isSocialConnector && ( - + +
+ )} +
+ +
+ {!isSocialConnector && ( +
+ +
)}