From 4028bb4f58cf6b0717e2e6e5e9960ef80612aa9e Mon Sep 17 00:00:00 2001 From: Yi Date: Tue, 5 Nov 2024 11:40:52 +0800 Subject: [PATCH] chore: update installPluginFromGitHub component --- .../install-plugin/install-from-github/index.tsx | 14 ++++++++------ web/app/components/plugins/types.ts | 6 ++++++ 2 files changed, 14 insertions(+), 6 deletions(-) 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 890424bfed..22c25ab1ab 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 @@ -6,7 +6,7 @@ import type { Item } from '@/app/components/base/select' import type { InstallState } from '@/app/components/plugins/types' import { useGitHubReleases, useGitHubUpload } from '../hooks' import { parseGitHubUrl } from '../utils' -import type { PluginDeclaration } from '../../types' +import type { PluginDeclaration, UpdatePluginPayload } from '../../types' import { InstallStepFromGitHub } from '../../types' import Toast from '@/app/components/base/toast' import SetURL from './steps/setURL' @@ -16,16 +16,17 @@ import Loaded from './steps/loaded' import { useTranslation } from 'react-i18next' type InstallFromGitHubProps = { + updatePayload?: UpdatePluginPayload onClose: () => void } -const InstallFromGitHub: React.FC = ({ onClose }) => { +const InstallFromGitHub: React.FC = ({ updatePayload, onClose }) => { const { t } = useTranslation() const [state, setState] = useState({ - step: InstallStepFromGitHub.setUrl, - repoUrl: '', - selectedVersion: '', - selectedPackage: '', + step: updatePayload ? InstallStepFromGitHub.selectPackage : InstallStepFromGitHub.setUrl, + repoUrl: updatePayload?.url || '', + selectedVersion: updatePayload?.currVersion || '', + selectedPackage: updatePayload?.currPackage || '', releases: [], }) const [uniqueIdentifier, setUniqueIdentifier] = useState(null) @@ -140,6 +141,7 @@ const InstallFromGitHub: React.FC = ({ onClose }) => { )} {state.step === InstallStepFromGitHub.selectPackage && ( setState(prevState => ({ ...prevState, selectedVersion: item.value as string }))} diff --git a/web/app/components/plugins/types.ts b/web/app/components/plugins/types.ts index e0ed3bf862..3b2ce1fb8c 100644 --- a/web/app/components/plugins/types.ts +++ b/web/app/components/plugins/types.ts @@ -70,6 +70,12 @@ export type PluginDeclaration = { model: any // TODO } +export type UpdatePluginPayload = { + url: string + currVersion: string + currPackage: string +} + export type PluginManifestInMarket = { name: string org: string