From 3c37739107794466a30c44163743915d489bb3ae Mon Sep 17 00:00:00 2001 From: Wang Sijie Date: Tue, 31 May 2022 12:59:08 +0800 Subject: [PATCH] fix(console): connector guide (#990) --- .../Connectors/components/GuideModal/index.tsx | 18 +++++++++++++----- .../console/src/pages/Connectors/index.tsx | 3 +++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/console/src/pages/Connectors/components/GuideModal/index.tsx b/packages/console/src/pages/Connectors/components/GuideModal/index.tsx index 589f5a352..abecd1577 100644 --- a/packages/console/src/pages/Connectors/components/GuideModal/index.tsx +++ b/packages/console/src/pages/Connectors/components/GuideModal/index.tsx @@ -8,12 +8,10 @@ import { useTranslation } from 'react-i18next'; import ReactMarkdown from 'react-markdown'; import Modal from 'react-modal'; -import Button from '@/components/Button'; import CardTitle from '@/components/CardTitle'; import CodeEditor from '@/components/CodeEditor'; import DangerousRaw from '@/components/DangerousRaw'; import IconButton from '@/components/IconButton'; -import Spacer from '@/components/Spacer'; import useApi from '@/hooks/use-api'; import useAdminConsoleConfigs from '@/hooks/use-configs'; import Close from '@/icons/Close'; @@ -44,6 +42,7 @@ const GuideModal = ({ connector, isOpen, onClose }: Props) => { const isSocialConnector = connectorType !== ConnectorType.SMS && connectorType !== ConnectorType.Email; const [activeStepIndex, setActiveStepIndex] = useState(0); + const steps = isSocialConnector ? 1 : 2; const methods = useForm({ reValidateMode: 'onBlur' }); const { control, @@ -63,12 +62,22 @@ const GuideModal = ({ connector, isOpen, onClose }: Props) => { json: { config }, }) .json(); + await api + .patch(`/api/connectors/${connectorId}/enabled`, { + json: { enabled: true }, + }) + .json(); await updateConfigs({ ...conditional(!isSocialConnector && { configurePasswordless: true }), ...conditional(isSocialConnector && { configureSocialSignIn: true }), }); - setActiveStepIndex(activeStepIndex + 1); + + if (activeStepIndex === steps - 1) { + onClose(); + } else { + setActiveStepIndex(activeStepIndex + 1); + } toast.success(t('connector_details.save_success')); } catch (error: unknown) { if (error instanceof SyntaxError) { @@ -90,8 +99,6 @@ const GuideModal = ({ connector, isOpen, onClose }: Props) => { title={{connectorName}} subtitle="connectors.guide.subtitle" /> - -