diff --git a/web/app/components/plugins/plugin-mutation-model/index.tsx b/web/app/components/plugins/plugin-mutation-model/index.tsx new file mode 100644 index 0000000000..fadfd9a957 --- /dev/null +++ b/web/app/components/plugins/plugin-mutation-model/index.tsx @@ -0,0 +1,71 @@ +import type { FC, ReactNode } from 'react' +import React, { memo } from 'react' +import Card from '@/app/components/plugins/card' +import Modal from '@/app/components/base/modal' +import Button from '@/app/components/base/button' +import type { Plugin } from '../types' +import type { UseMutationResult } from '@tanstack/react-query' + +type Props = { + plugin: Plugin + onSave: () => void + onCancel: () => void + mutation: UseMutationResult + confirmButtonText: ReactNode + cancelButtonText: ReactNode + modelTitle: ReactNode + description: ReactNode + cardTitleLeft: ReactNode +} + +const PluginMutationModal: FC = ({ + plugin, + onCancel, + mutation, + confirmButtonText, + cancelButtonText, + modelTitle, + description, + cardTitleLeft, +}: Props) => { + return ( + +
+ {description} +
+
+ +
+
+ {mutation.isPending && ( + + )} + +
+
+ ) +} + +PluginMutationModal.displayName = 'PluginMutationModal' + +export default memo(PluginMutationModal) diff --git a/web/service/use-plugins.ts b/web/service/use-plugins.ts index f9c8f0a2c2..f885efd761 100644 --- a/web/service/use-plugins.ts +++ b/web/service/use-plugins.ts @@ -41,7 +41,7 @@ export const useCheckInstalled = ({ enabled: boolean }) => { return useQuery<{ plugins: PluginDetail[] }>({ - queryKey: [NAME_SPACE, 'checkInstalled'], + queryKey: [NAME_SPACE, 'checkInstalled', pluginIds], queryFn: () => post<{ plugins: PluginDetail[] }>('/workspaces/current/plugin/list/installations/ids', { body: { plugin_ids: pluginIds, @@ -82,8 +82,9 @@ export const useInstallPackageFromMarketPlace = (options?: MutateOptions { +export const useUpdatePackageFromMarketPlace = (options?: MutateOptions) => { return useMutation({ + ...options, mutationFn: (body: object) => { return post('/workspaces/current/plugin/upgrade/marketplace', { body,