|
|
|
|
@ -10,7 +10,6 @@ import type {
|
|
|
|
|
GitHubItemAndMarketPlaceDependency,
|
|
|
|
|
InstallPackageResponse,
|
|
|
|
|
InstalledLatestVersionResponse,
|
|
|
|
|
InstalledPluginListResponse,
|
|
|
|
|
InstalledPluginListWithTotalResponse,
|
|
|
|
|
PackageDependency,
|
|
|
|
|
Permissions,
|
|
|
|
|
@ -67,16 +66,7 @@ export const useCheckInstalled = ({
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const useInstalledPluginList = (disable?: boolean) => {
|
|
|
|
|
return useQuery<InstalledPluginListResponse>({
|
|
|
|
|
queryKey: useInstalledPluginListKey,
|
|
|
|
|
queryFn: () => get<InstalledPluginListResponse>('/workspaces/current/plugin/list'),
|
|
|
|
|
enabled: !disable,
|
|
|
|
|
initialData: !disable ? undefined : { plugins: [] },
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const useInstalledPluginListWithPagination = (pageSize = 100) => {
|
|
|
|
|
export const useInstalledPluginList = (disable?: boolean, pageSize = 100) => {
|
|
|
|
|
const fetchPlugins = async ({ pageParam = 1 }) => {
|
|
|
|
|
const response = await get<InstalledPluginListWithTotalResponse>(
|
|
|
|
|
`/workspaces/current/plugin/list?page=${pageParam}&page_size=${pageSize}`,
|
|
|
|
|
@ -91,8 +81,10 @@ export const useInstalledPluginListWithPagination = (pageSize = 100) => {
|
|
|
|
|
hasNextPage,
|
|
|
|
|
isFetchingNextPage,
|
|
|
|
|
isLoading,
|
|
|
|
|
isSuccess,
|
|
|
|
|
} = useInfiniteQuery({
|
|
|
|
|
queryKey: ['installed-plugins', pageSize],
|
|
|
|
|
enabled: !disable,
|
|
|
|
|
queryKey: useInstalledPluginListKey,
|
|
|
|
|
queryFn: fetchPlugins,
|
|
|
|
|
getNextPageParam: (lastPage, pages) => {
|
|
|
|
|
const totalItems = lastPage.total
|
|
|
|
|
@ -108,10 +100,12 @@ export const useInstalledPluginListWithPagination = (pageSize = 100) => {
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const plugins = data?.pages.flatMap(page => page.plugins) ?? []
|
|
|
|
|
const total = data?.pages[0].total ?? 0
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
data: {
|
|
|
|
|
data: disable ? undefined : {
|
|
|
|
|
plugins,
|
|
|
|
|
total,
|
|
|
|
|
},
|
|
|
|
|
isLastPage: !hasNextPage,
|
|
|
|
|
loadNextPage: () => {
|
|
|
|
|
@ -120,6 +114,7 @@ export const useInstalledPluginListWithPagination = (pageSize = 100) => {
|
|
|
|
|
isLoading,
|
|
|
|
|
isFetching: isFetchingNextPage,
|
|
|
|
|
error,
|
|
|
|
|
isSuccess,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|