chore: install from marketplace
This commit is contained in:
parent
33349191e9
commit
c77b38b97d
@ -9,7 +9,7 @@ import Button from '@/app/components/base/button'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { RiLoader2Line } from '@remixicon/react'
|
import { RiLoader2Line } from '@remixicon/react'
|
||||||
import Badge, { BadgeState } from '@/app/components/base/badge/index'
|
import Badge, { BadgeState } from '@/app/components/base/badge/index'
|
||||||
import { installPackageFromMarketPlace } from '@/service/plugins'
|
import { useInstallPackageFromMarketPlace } from '@/service/use-plugins'
|
||||||
import checkTaskStatus from '../../base/check-task-status'
|
import checkTaskStatus from '../../base/check-task-status'
|
||||||
|
|
||||||
const i18nPrefix = 'plugin.installModal'
|
const i18nPrefix = 'plugin.installModal'
|
||||||
@ -32,6 +32,7 @@ const Installed: FC<Props> = ({
|
|||||||
onFailed,
|
onFailed,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const { mutateAsync: installPackageFromMarketPlace } = useInstallPackageFromMarketPlace()
|
||||||
const [isInstalling, setIsInstalling] = React.useState(false)
|
const [isInstalling, setIsInstalling] = React.useState(false)
|
||||||
const {
|
const {
|
||||||
check,
|
check,
|
||||||
|
@ -104,12 +104,6 @@ export const fetchManifestFromMarketPlace = async (uniqueIdentifier: string) =>
|
|||||||
return getMarketplace<{ data: { plugin: PluginManifestInMarket } }>(`/plugins/identifier?unique_identifier=${uniqueIdentifier}`)
|
return getMarketplace<{ data: { plugin: PluginManifestInMarket } }>(`/plugins/identifier?unique_identifier=${uniqueIdentifier}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const installPackageFromMarketPlace = async (uniqueIdentifier: string) => {
|
|
||||||
return post<InstallPackageResponse>('/workspaces/current/plugin/install/marketplace', {
|
|
||||||
body: { plugin_unique_identifiers: [uniqueIdentifier] },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const fetchMarketplaceCollections: Fetcher<MarketplaceCollectionsResponse, { url: string; }> = ({ url }) => {
|
export const fetchMarketplaceCollections: Fetcher<MarketplaceCollectionsResponse, { url: string; }> = ({ url }) => {
|
||||||
return get<MarketplaceCollectionsResponse>(url)
|
return get<MarketplaceCollectionsResponse>(url)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import type {
|
import type {
|
||||||
DebugInfo as DebugInfoTypes,
|
DebugInfo as DebugInfoTypes,
|
||||||
|
InstallPackageResponse,
|
||||||
InstalledPluginListResponse,
|
InstalledPluginListResponse,
|
||||||
Permissions,
|
Permissions,
|
||||||
PluginsFromMarketplaceResponse,
|
PluginsFromMarketplaceResponse,
|
||||||
@ -34,6 +35,14 @@ export const useInvalidateInstalledPluginList = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const useInstallPackageFromMarketPlace = () => {
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (uniqueIdentifier: string) => {
|
||||||
|
return post<InstallPackageResponse>('/workspaces/current/plugin/install/marketplace', { body: { plugin_unique_identifiers: [uniqueIdentifier] } })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const useDebugKey = () => {
|
export const useDebugKey = () => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: [NAME_SPACE, 'debugKey'],
|
queryKey: [NAME_SPACE, 'debugKey'],
|
||||||
|
Loading…
Reference in New Issue
Block a user