diff --git a/web/app/components/plugins/install-plugin/install-from-github/index.tsx b/web/app/components/plugins/install-plugin/install-from-github/index.tsx index 71f81f0ffa..933934e9ba 100644 --- a/web/app/components/plugins/install-plugin/install-from-github/index.tsx +++ b/web/app/components/plugins/install-plugin/install-from-github/index.tsx @@ -16,6 +16,8 @@ import Loaded from './steps/loaded' import useGetIcon from '@/app/components/plugins/install-plugin/base/use-get-icon' import { useTranslation } from 'react-i18next' import useRefreshPluginList from '../hooks/use-refresh-plugin-list' +import cn from '@/utils/classnames' +import useHideLogic from '../hooks/use-hide-logic' const i18nPrefix = 'plugin.installFromGitHub' @@ -31,6 +33,13 @@ const InstallFromGitHub: React.FC = ({ updatePayload, on const { fetchReleases } = useGitHubReleases() const { refreshPluginList } = useRefreshPluginList() + const { + modalClassName, + foldAnimInto, + setIsInstalling, + handleStartToInstall, + } = useHideLogic(onClose) + const [state, setState] = useState({ step: updatePayload ? InstallStepFromGitHub.selectPackage : InstallStepFromGitHub.setUrl, repoUrl: updatePayload?.originalPackageInfo?.repo @@ -115,14 +124,16 @@ const InstallFromGitHub: React.FC = ({ updatePayload, on const handleInstalled = useCallback(() => { setState(prevState => ({ ...prevState, step: InstallStepFromGitHub.installed })) refreshPluginList(manifest) + setIsInstalling(false) onSuccess() - }, [manifest, onSuccess, refreshPluginList]) + }, [manifest, onSuccess, refreshPluginList, setIsInstalling]) const handleFailed = useCallback((errorMsg?: string) => { setState(prevState => ({ ...prevState, step: InstallStepFromGitHub.installFailed })) + setIsInstalling(false) if (errorMsg) setErrorMsg(errorMsg) - }, []) + }, [setIsInstalling]) const handleBack = () => { setState((prevState) => { @@ -140,9 +151,9 @@ const InstallFromGitHub: React.FC = ({ updatePayload, on return (
@@ -195,6 +206,7 @@ const InstallFromGitHub: React.FC = ({ updatePayload, on selectedVersion={state.selectedVersion} selectedPackage={state.selectedPackage} onBack={handleBack} + onStartToInstall={handleStartToInstall} onInstalled={handleInstalled} onFailed={handleFailed} /> diff --git a/web/app/components/plugins/install-plugin/install-from-github/steps/loaded.tsx b/web/app/components/plugins/install-plugin/install-from-github/steps/loaded.tsx index e2de988a74..b1bcf01251 100644 --- a/web/app/components/plugins/install-plugin/install-from-github/steps/loaded.tsx +++ b/web/app/components/plugins/install-plugin/install-from-github/steps/loaded.tsx @@ -23,6 +23,7 @@ type LoadedProps = { selectedVersion: string selectedPackage: string onBack: () => void + onStartToInstall?: () => void onInstalled: () => void onFailed: (message?: string) => void } @@ -37,6 +38,7 @@ const Loaded: React.FC = ({ selectedVersion, selectedPackage, onBack, + onStartToInstall, onInstalled, onFailed, }) => { @@ -59,11 +61,13 @@ const Loaded: React.FC = ({ useEffect(() => { if (hasInstalled && uniqueIdentifier === installedInfoPayload.uniqueIdentifier) onInstalled() + // eslint-disable-next-line react-hooks/exhaustive-deps }, [hasInstalled]) const handleInstall = async () => { if (isInstalling) return setIsInstalling(true) + onStartToInstall?.() try { const { owner, repo } = parseGitHubUrl(repoUrl)