mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
chore: update installPluginFromGitHub component
This commit is contained in:
parent
691dbf9d17
commit
4028bb4f58
|
@ -6,7 +6,7 @@ import type { Item } from '@/app/components/base/select'
|
||||||
import type { InstallState } from '@/app/components/plugins/types'
|
import type { InstallState } from '@/app/components/plugins/types'
|
||||||
import { useGitHubReleases, useGitHubUpload } from '../hooks'
|
import { useGitHubReleases, useGitHubUpload } from '../hooks'
|
||||||
import { parseGitHubUrl } from '../utils'
|
import { parseGitHubUrl } from '../utils'
|
||||||
import type { PluginDeclaration } from '../../types'
|
import type { PluginDeclaration, UpdatePluginPayload } from '../../types'
|
||||||
import { InstallStepFromGitHub } from '../../types'
|
import { InstallStepFromGitHub } from '../../types'
|
||||||
import Toast from '@/app/components/base/toast'
|
import Toast from '@/app/components/base/toast'
|
||||||
import SetURL from './steps/setURL'
|
import SetURL from './steps/setURL'
|
||||||
|
@ -16,16 +16,17 @@ import Loaded from './steps/loaded'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
type InstallFromGitHubProps = {
|
type InstallFromGitHubProps = {
|
||||||
|
updatePayload?: UpdatePluginPayload
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const InstallFromGitHub: React.FC<InstallFromGitHubProps> = ({ onClose }) => {
|
const InstallFromGitHub: React.FC<InstallFromGitHubProps> = ({ updatePayload, onClose }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [state, setState] = useState<InstallState>({
|
const [state, setState] = useState<InstallState>({
|
||||||
step: InstallStepFromGitHub.setUrl,
|
step: updatePayload ? InstallStepFromGitHub.selectPackage : InstallStepFromGitHub.setUrl,
|
||||||
repoUrl: '',
|
repoUrl: updatePayload?.url || '',
|
||||||
selectedVersion: '',
|
selectedVersion: updatePayload?.currVersion || '',
|
||||||
selectedPackage: '',
|
selectedPackage: updatePayload?.currPackage || '',
|
||||||
releases: [],
|
releases: [],
|
||||||
})
|
})
|
||||||
const [uniqueIdentifier, setUniqueIdentifier] = useState<string | null>(null)
|
const [uniqueIdentifier, setUniqueIdentifier] = useState<string | null>(null)
|
||||||
|
@ -140,6 +141,7 @@ const InstallFromGitHub: React.FC<InstallFromGitHubProps> = ({ onClose }) => {
|
||||||
)}
|
)}
|
||||||
{state.step === InstallStepFromGitHub.selectPackage && (
|
{state.step === InstallStepFromGitHub.selectPackage && (
|
||||||
<SelectPackage
|
<SelectPackage
|
||||||
|
isEdit={Boolean(updatePayload)}
|
||||||
selectedVersion={state.selectedVersion}
|
selectedVersion={state.selectedVersion}
|
||||||
versions={versions}
|
versions={versions}
|
||||||
onSelectVersion={item => setState(prevState => ({ ...prevState, selectedVersion: item.value as string }))}
|
onSelectVersion={item => setState(prevState => ({ ...prevState, selectedVersion: item.value as string }))}
|
||||||
|
|
|
@ -70,6 +70,12 @@ export type PluginDeclaration = {
|
||||||
model: any // TODO
|
model: any // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type UpdatePluginPayload = {
|
||||||
|
url: string
|
||||||
|
currVersion: string
|
||||||
|
currPackage: string
|
||||||
|
}
|
||||||
|
|
||||||
export type PluginManifestInMarket = {
|
export type PluginManifestInMarket = {
|
||||||
name: string
|
name: string
|
||||||
org: string
|
org: string
|
||||||
|
|
Loading…
Reference in New Issue
Block a user