fix(ui): remove sync models functionality

The backend functionality was removed in the previous couple commits. Removing the frontend endpoints and components.
This commit is contained in:
psychedelicious 2024-03-27 15:46:20 +11:00
parent ce2923533a
commit 48e1a0c217
10 changed files with 1 additions and 130 deletions

View File

@ -1,33 +0,0 @@
import type { ButtonProps } from '@invoke-ai/ui-library';
import { Button } from '@invoke-ai/ui-library';
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { PiArrowsClockwiseBold } from 'react-icons/pi';
import { useSyncModels } from './useSyncModels';
export const SyncModelsButton = memo((props: Omit<ButtonProps, 'aria-label'>) => {
const { t } = useTranslation();
const { syncModels, isLoading } = useSyncModels();
const isSyncModelEnabled = useFeatureStatus('syncModels').isFeatureEnabled;
if (!isSyncModelEnabled) {
return null;
}
return (
<Button
leftIcon={<PiArrowsClockwiseBold />}
isLoading={isLoading}
onClick={syncModels}
size="sm"
variant="ghost"
{...props}
>
{t('modelManager.syncModels')}
</Button>
);
});
SyncModelsButton.displayName = 'SyncModelsButton';

View File

@ -1,33 +0,0 @@
import type { IconButtonProps } from '@invoke-ai/ui-library';
import { IconButton } from '@invoke-ai/ui-library';
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { PiArrowsClockwiseBold } from 'react-icons/pi';
import { useSyncModels } from './useSyncModels';
export const SyncModelsIconButton = memo((props: Omit<IconButtonProps, 'aria-label'>) => {
const { t } = useTranslation();
const { syncModels, isLoading } = useSyncModels();
const isSyncModelEnabled = useFeatureStatus('syncModels').isFeatureEnabled;
if (!isSyncModelEnabled) {
return null;
}
return (
<IconButton
icon={<PiArrowsClockwiseBold />}
tooltip={t('modelManager.syncModels')}
aria-label={t('modelManager.syncModels')}
isLoading={isLoading}
onClick={syncModels}
size="sm"
variant="ghost"
{...props}
/>
);
});
SyncModelsIconButton.displayName = 'SyncModelsIconButton';

View File

@ -1,40 +0,0 @@
import { useAppDispatch } from 'app/store/storeHooks';
import { addToast } from 'features/system/store/systemSlice';
import { makeToast } from 'features/system/util/makeToast';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { useSyncModelsMutation } from 'services/api/endpoints/models';
export const useSyncModels = () => {
const dispatch = useAppDispatch();
const { t } = useTranslation();
const [_syncModels, { isLoading }] = useSyncModelsMutation();
const syncModels = useCallback(() => {
_syncModels()
.unwrap()
.then((_) => {
dispatch(
addToast(
makeToast({
title: `${t('modelManager.modelsSynced')}`,
status: 'success',
})
)
);
})
.catch((error) => {
if (error) {
dispatch(
addToast(
makeToast({
title: `${t('modelManager.modelSyncFailed')}`,
status: 'error',
})
)
);
}
});
}, [dispatch, _syncModels, t]);
return { syncModels, isLoading };
};

View File

@ -1,6 +1,5 @@
import { Button, Flex, Heading, Spacer } from '@invoke-ai/ui-library'; import { Button, Flex, Heading } from '@invoke-ai/ui-library';
import { useAppDispatch } from 'app/store/storeHooks'; import { useAppDispatch } from 'app/store/storeHooks';
import { SyncModelsButton } from 'features/modelManagerV2/components/SyncModels/SyncModelsButton';
import { setSelectedModelKey } from 'features/modelManagerV2/store/modelManagerV2Slice'; import { setSelectedModelKey } from 'features/modelManagerV2/store/modelManagerV2Slice';
import { useCallback } from 'react'; import { useCallback } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -20,8 +19,6 @@ export const ModelManager = () => {
<Flex flexDir="column" layerStyle="first" p={4} gap={4} borderRadius="base" w="50%" h="full"> <Flex flexDir="column" layerStyle="first" p={4} gap={4} borderRadius="base" w="50%" h="full">
<Flex w="full" gap={4} justifyContent="space-between" alignItems="center"> <Flex w="full" gap={4} justifyContent="space-between" alignItems="center">
<Heading fontSize="xl">{t('common.modelManager')}</Heading> <Heading fontSize="xl">{t('common.modelManager')}</Heading>
<Spacer />
<SyncModelsButton size="sm" />
<Button size="sm" colorScheme="invokeYellow" leftIcon={<PiPlusBold />} onClick={handleClickAddModel}> <Button size="sm" colorScheme="invokeYellow" leftIcon={<PiPlusBold />} onClick={handleClickAddModel}>
{t('modelManager.addModels')} {t('modelManager.addModels')}
</Button> </Button>

View File

@ -1,7 +1,6 @@
import { Combobox, Flex, FormControl } from '@invoke-ai/ui-library'; import { Combobox, Flex, FormControl } from '@invoke-ai/ui-library';
import { useAppDispatch } from 'app/store/storeHooks'; import { useAppDispatch } from 'app/store/storeHooks';
import { useGroupedModelCombobox } from 'common/hooks/useGroupedModelCombobox'; import { useGroupedModelCombobox } from 'common/hooks/useGroupedModelCombobox';
import { SyncModelsIconButton } from 'features/modelManagerV2/components/SyncModels/SyncModelsIconButton';
import { fieldMainModelValueChanged } from 'features/nodes/store/nodesSlice'; import { fieldMainModelValueChanged } from 'features/nodes/store/nodesSlice';
import type { MainModelFieldInputInstance, MainModelFieldInputTemplate } from 'features/nodes/types/field'; import type { MainModelFieldInputInstance, MainModelFieldInputTemplate } from 'features/nodes/types/field';
import { memo, useCallback } from 'react'; import { memo, useCallback } from 'react';
@ -49,7 +48,6 @@ const MainModelFieldInputComponent = (props: Props) => {
noOptionsMessage={noOptionsMessage} noOptionsMessage={noOptionsMessage}
/> />
</FormControl> </FormControl>
<SyncModelsIconButton className="nodrag" />
</Flex> </Flex>
); );
}; };

View File

@ -1,7 +1,6 @@
import { Combobox, Flex, FormControl } from '@invoke-ai/ui-library'; import { Combobox, Flex, FormControl } from '@invoke-ai/ui-library';
import { useAppDispatch } from 'app/store/storeHooks'; import { useAppDispatch } from 'app/store/storeHooks';
import { useGroupedModelCombobox } from 'common/hooks/useGroupedModelCombobox'; import { useGroupedModelCombobox } from 'common/hooks/useGroupedModelCombobox';
import { SyncModelsIconButton } from 'features/modelManagerV2/components/SyncModels/SyncModelsIconButton';
import { fieldRefinerModelValueChanged } from 'features/nodes/store/nodesSlice'; import { fieldRefinerModelValueChanged } from 'features/nodes/store/nodesSlice';
import type { import type {
SDXLRefinerModelFieldInputInstance, SDXLRefinerModelFieldInputInstance,
@ -52,7 +51,6 @@ const RefinerModelFieldInputComponent = (props: Props) => {
noOptionsMessage={noOptionsMessage} noOptionsMessage={noOptionsMessage}
/> />
</FormControl> </FormControl>
<SyncModelsIconButton className="nodrag" />
</Flex> </Flex>
); );
}; };

View File

@ -1,7 +1,6 @@
import { Combobox, Flex, FormControl } from '@invoke-ai/ui-library'; import { Combobox, Flex, FormControl } from '@invoke-ai/ui-library';
import { useAppDispatch } from 'app/store/storeHooks'; import { useAppDispatch } from 'app/store/storeHooks';
import { useGroupedModelCombobox } from 'common/hooks/useGroupedModelCombobox'; import { useGroupedModelCombobox } from 'common/hooks/useGroupedModelCombobox';
import { SyncModelsIconButton } from 'features/modelManagerV2/components/SyncModels/SyncModelsIconButton';
import { fieldMainModelValueChanged } from 'features/nodes/store/nodesSlice'; import { fieldMainModelValueChanged } from 'features/nodes/store/nodesSlice';
import type { SDXLMainModelFieldInputInstance, SDXLMainModelFieldInputTemplate } from 'features/nodes/types/field'; import type { SDXLMainModelFieldInputInstance, SDXLMainModelFieldInputTemplate } from 'features/nodes/types/field';
import { memo, useCallback } from 'react'; import { memo, useCallback } from 'react';
@ -49,7 +48,6 @@ const SDXLMainModelFieldInputComponent = (props: Props) => {
noOptionsMessage={noOptionsMessage} noOptionsMessage={noOptionsMessage}
/> />
</FormControl> </FormControl>
<SyncModelsIconButton className="nodrag" />
</Flex> </Flex>
); );
}; };

View File

@ -1,7 +1,6 @@
import { Combobox, Flex, FormControl } from '@invoke-ai/ui-library'; import { Combobox, Flex, FormControl } from '@invoke-ai/ui-library';
import { useAppDispatch } from 'app/store/storeHooks'; import { useAppDispatch } from 'app/store/storeHooks';
import { useGroupedModelCombobox } from 'common/hooks/useGroupedModelCombobox'; import { useGroupedModelCombobox } from 'common/hooks/useGroupedModelCombobox';
import { SyncModelsIconButton } from 'features/modelManagerV2/components/SyncModels/SyncModelsIconButton';
import { fieldVaeModelValueChanged } from 'features/nodes/store/nodesSlice'; import { fieldVaeModelValueChanged } from 'features/nodes/store/nodesSlice';
import type { VAEModelFieldInputInstance, VAEModelFieldInputTemplate } from 'features/nodes/types/field'; import type { VAEModelFieldInputInstance, VAEModelFieldInputTemplate } from 'features/nodes/types/field';
import { memo, useCallback } from 'react'; import { memo, useCallback } from 'react';
@ -49,7 +48,6 @@ const VAEModelFieldInputComponent = (props: Props) => {
noOptionsMessage={noOptionsMessage} noOptionsMessage={noOptionsMessage}
/> />
</FormControl> </FormControl>
<SyncModelsIconButton className="nodrag" />
</Flex> </Flex>
); );
}; };

View File

@ -6,7 +6,6 @@ import { useAppSelector } from 'app/store/storeHooks';
import { LoRAList } from 'features/lora/components/LoRAList'; import { LoRAList } from 'features/lora/components/LoRAList';
import LoRASelect from 'features/lora/components/LoRASelect'; import LoRASelect from 'features/lora/components/LoRASelect';
import { selectLoraSlice } from 'features/lora/store/loraSlice'; import { selectLoraSlice } from 'features/lora/store/loraSlice';
import { SyncModelsIconButton } from 'features/modelManagerV2/components/SyncModels/SyncModelsIconButton';
import ParamCFGScale from 'features/parameters/components/Core/ParamCFGScale'; import ParamCFGScale from 'features/parameters/components/Core/ParamCFGScale';
import ParamScheduler from 'features/parameters/components/Core/ParamScheduler'; import ParamScheduler from 'features/parameters/components/Core/ParamScheduler';
import ParamSteps from 'features/parameters/components/Core/ParamSteps'; import ParamSteps from 'features/parameters/components/Core/ParamSteps';
@ -60,7 +59,6 @@ export const GenerationSettingsAccordion = memo(() => {
<ParamMainModelSelect /> <ParamMainModelSelect />
<Flex> <Flex>
<UseDefaultSettingsButton /> <UseDefaultSettingsButton />
<SyncModelsIconButton />
<NavigateToModelManagerButton /> <NavigateToModelManagerButton />
</Flex> </Flex>
</Flex> </Flex>

View File

@ -188,15 +188,6 @@ export const modelsApi = api.injectEndpoints({
}, },
serializeQueryArgs: ({ queryArgs }) => `${queryArgs.name}.${queryArgs.base}.${queryArgs.type}`, serializeQueryArgs: ({ queryArgs }) => `${queryArgs.name}.${queryArgs.base}.${queryArgs.type}`,
}), }),
syncModels: build.mutation<void, void>({
query: () => {
return {
url: buildModelsUrl('sync'),
method: 'PATCH',
};
},
invalidatesTags: [{ type: 'ModelConfig', id: LIST_TAG }],
}),
scanFolder: build.query<ScanFolderResponse, ScanFolderArg>({ scanFolder: build.query<ScanFolderResponse, ScanFolderArg>({
query: (arg) => { query: (arg) => {
const folderQueryStr = arg ? queryString.stringify(arg, {}) : ''; const folderQueryStr = arg ? queryString.stringify(arg, {}) : '';
@ -278,7 +269,6 @@ export const {
useUpdateModelImageMutation, useUpdateModelImageMutation,
useInstallModelMutation, useInstallModelMutation,
useConvertModelMutation, useConvertModelMutation,
useSyncModelsMutation,
useLazyScanFolderQuery, useLazyScanFolderQuery,
useLazyGetHuggingFaceModelsQuery, useLazyGetHuggingFaceModelsQuery,
useListModelInstallsQuery, useListModelInstallsQuery,