diff --git a/packages/console/src/pages/Connectors/Guide/Steps.tsx b/packages/console/src/pages/Connectors/Guide/Steps.tsx new file mode 100644 index 000000000..580493454 --- /dev/null +++ b/packages/console/src/pages/Connectors/Guide/Steps.tsx @@ -0,0 +1,46 @@ +import { type LocalePhrase } from '@logto/phrases'; +import React, { type ReactNode, type ReactElement } from 'react'; +import { useTranslation } from 'react-i18next'; + +import * as styles from './index.module.scss'; + +type CanBeArray = T | T[]; + +type StepProps = { + readonly children: ReactNode; + readonly index?: number; + readonly tKey: keyof LocalePhrase['translation']['admin_console']['connectors']['guide']; +}; + +export function Step({ children, index, tKey }: StepProps) { + const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.connectors.guide' }); + + return ( +
+
+
{index}
+
{t(tKey)}
+
+ {children} +
+ ); +} + +type Props = { + readonly children: CanBeArray | boolean>; +}; + +function Steps({ children }: Props) { + return ( + <> + {React.Children.map(children, (child, index) => { + return ( + typeof child !== 'boolean' && + React.cloneElement(child, { key: child.key, index: index + 1 }) + ); + })} + + ); +} + +export default Steps; diff --git a/packages/console/src/pages/Connectors/Guide/index.tsx b/packages/console/src/pages/Connectors/Guide/index.tsx index 68ce4d20c..0b03293b3 100644 --- a/packages/console/src/pages/Connectors/Guide/index.tsx +++ b/packages/console/src/pages/Connectors/Guide/index.tsx @@ -33,6 +33,7 @@ import { trySubmitSafe } from '@/utils/form'; import { splitMarkdownByTitle } from '../utils'; +import Steps, { Step } from './Steps'; import * as styles from './index.module.scss'; const targetErrorCode = 'connector.multiple_target_with_same_platform'; @@ -187,44 +188,34 @@ function Guide({ connector, onClose }: Props) {
- {isSocialConnector && ( -
-
-
1
-
{t('connectors.guide.general_setting')}
-
- -
- )} -
-
-
{isSocialConnector ? 2 : 1}
-
{t('connectors.guide.parameter_configuration')}
-
- -
- {!isSocialConnector && ( -
-
-
2
-
{t('connectors.guide.test_connection')}
-
- + {isSocialConnector && ( + + + + )} + + configParser(watch(), formItems)} + formItems={formItems} /> -
- )} + + {!isSocialConnector && ( + + configParser(watch(), formItems)} + /> + + )} +