diff --git a/web/app/components/base/upgrade-modal/index.tsx b/web/app/components/base/upgrade-modal/index.tsx new file mode 100644 index 0000000000..90d29cea78 --- /dev/null +++ b/web/app/components/base/upgrade-modal/index.tsx @@ -0,0 +1,66 @@ +'use client' + +import type { ComponentType, FC, ReactNode, SVGProps } from 'react' +import Modal from '@/app/components/base/modal' +import styles from './style.module.css' + +type Props = { + Icon?: ComponentType> + title: string + description: string + extraInfo?: ReactNode + footer?: ReactNode + show: boolean + onClose: () => void +} + +const UpgradeModalBase: FC = ({ + Icon, + title, + description, + extraInfo, + footer, + show, + onClose, +}) => { + return ( + +
+
+
+ {Icon && ( +
+ +
+ )} +
+
+ {title} +
+
+ {description} +
+
+ {extraInfo} +
+
+ + {footer && ( +
+ {footer} +
+ )} + + ) +} + +export default UpgradeModalBase diff --git a/web/app/components/billing/plan-upgrade-modal/style.module.css b/web/app/components/base/upgrade-modal/style.module.css similarity index 100% rename from web/app/components/billing/plan-upgrade-modal/style.module.css rename to web/app/components/base/upgrade-modal/style.module.css diff --git a/web/app/components/billing/plan-upgrade-modal/index.tsx b/web/app/components/billing/plan-upgrade-modal/index.tsx index 17a50e89ad..8a382a25ad 100644 --- a/web/app/components/billing/plan-upgrade-modal/index.tsx +++ b/web/app/components/billing/plan-upgrade-modal/index.tsx @@ -4,11 +4,10 @@ import * as React from 'react' import { useCallback } from 'react' import { useTranslation } from 'react-i18next' import Button from '@/app/components/base/button' -import Modal from '@/app/components/base/modal' +import UpgradeModalBase from '@/app/components/base/upgrade-modal' import UpgradeBtn from '@/app/components/billing/upgrade-btn' import { useModalContext } from '@/context/modal-context' import { SquareChecklist } from '../../base/icons/src/vender/other' -import styles from './style.module.css' type Props = { Icon?: React.ComponentType> @@ -41,50 +40,30 @@ const PlanUpgradeModal: FC = ({ }, [onClose, onUpgrade, setShowPricingModal]) return ( - -
-
-
-
- -
-
-
- {title} -
-
- {description} -
-
- {extraInfo} -
-
- -
- - -
- + // eslint-disable-next-line ts/no-explicit-any + Icon={Icon as any} + title={title} + description={description} + extraInfo={extraInfo} + footer={( + <> + + + + )} + /> ) } diff --git a/web/app/components/workflow-app/components/sandbox-migration-modal.tsx b/web/app/components/workflow-app/components/sandbox-migration-modal.tsx new file mode 100644 index 0000000000..edeef09ee0 --- /dev/null +++ b/web/app/components/workflow-app/components/sandbox-migration-modal.tsx @@ -0,0 +1,54 @@ +'use client' + +import type { FC } from 'react' +import { forwardRef, useCallback } from 'react' +import { useTranslation } from 'react-i18next' +import Button from '@/app/components/base/button' +import { Thinking as ThinkingIcon } from '@/app/components/base/icons/src/vender/workflow' +import UpgradeModalBase from '@/app/components/base/upgrade-modal' + +const Thinking = forwardRef>((props, ref) => ( + // eslint-disable-next-line ts/no-explicit-any + +)) + +type Props = { + show: boolean + onClose: () => void + onUpgrade?: () => void +} + +const SandboxMigrationModal: FC = ({ + show, + onClose, + onUpgrade, +}) => { + const { t } = useTranslation() + + const handleUpgrade = useCallback(() => { + onClose() + onUpgrade?.() + }, [onClose, onUpgrade]) + + return ( + + + + + )} + /> + ) +} + +export default SandboxMigrationModal diff --git a/web/app/components/workflow-app/index.tsx b/web/app/components/workflow-app/index.tsx index 4beeed4238..a805019d07 100644 --- a/web/app/components/workflow-app/index.tsx +++ b/web/app/components/workflow-app/index.tsx @@ -13,12 +13,10 @@ import { useRef, useState, } from 'react' -import { useTranslation } from 'react-i18next' import { useStore as useAppStore } from '@/app/components/app/store' import { FeaturesProvider } from '@/app/components/base/features' import Loading from '@/app/components/base/loading' import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants' -import PlanUpgradeModal from '@/app/components/billing/plan-upgrade-modal' import WorkflowWithDefaultContext from '@/app/components/workflow' import { useCollaboration } from '@/app/components/workflow/collaboration' import { collaborationManager } from '@/app/components/workflow/collaboration/core/collaboration-manager' @@ -42,6 +40,7 @@ import { useAppTriggers } from '@/service/use-tools' import { AppModeEnum } from '@/types/app' import { useFeatures } from '../base/features/hooks' import ViewPicker from '../workflow/view-picker' +import SandboxMigrationModal from './components/sandbox-migration-modal' import WorkflowAppMain from './components/workflow-main' import { useGetRunAndTraceUrl } from './hooks/use-get-run-and-trace-url' import { useNodesSyncDraft } from './hooks/use-nodes-sync-draft' @@ -173,7 +172,6 @@ const WorkflowAppWithAdditionalContext = () => { } = useWorkflowInit() const workflowStore = useWorkflowStore() const { isLoadingCurrentWorkspace, currentWorkspace } = useAppContext() - const { t } = useTranslation() const [showMigrationModal, setShowMigrationModal] = useState(false) const lastCheckedAppIdRef = useRef(null) @@ -366,11 +364,9 @@ const WorkflowAppWithAdditionalContext = () => { return ( <> -