mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-15 19:55:02 -05:00
If provided, `<NavigateToModelManagerButton />` will render, even if `disabledTabs` includes "models". If provided, `<NavigateToModelManagerButton />` will run the callback instead of switching tabs within the studio. The button's tooltip is now just "Manage Models" and its icon is the same as the model manager tab's icon ([CUBE!](https://www.youtube.com/watch?v=4aGDCE6Nrz0)).
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import type { IconButtonProps } from '@invoke-ai/ui-library';
|
|
import { IconButton } from '@invoke-ai/ui-library';
|
|
import { useStore } from '@nanostores/react';
|
|
import { $onClickGoToModelManager } from 'app/store/nanostores/onClickGoToModelManager';
|
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
|
import { selectIsModelsTabDisabled } from 'features/system/store/configSlice';
|
|
import { setActiveTab } from 'features/ui/store/uiSlice';
|
|
import { memo, useCallback } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { PiCubeBold } from 'react-icons/pi';
|
|
|
|
export const NavigateToModelManagerButton = memo((props: Omit<IconButtonProps, 'aria-label'>) => {
|
|
const isModelsTabDisabled = useAppSelector(selectIsModelsTabDisabled);
|
|
const onClickGoToModelManager = useStore($onClickGoToModelManager);
|
|
|
|
const { t } = useTranslation();
|
|
const dispatch = useAppDispatch();
|
|
|
|
const onClick = useCallback(() => {
|
|
dispatch(setActiveTab('models'));
|
|
}, [dispatch]);
|
|
|
|
if (isModelsTabDisabled && !onClickGoToModelManager) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<IconButton
|
|
icon={<PiCubeBold />}
|
|
tooltip={`${t('modelManager.manageModels')}`}
|
|
aria-label={`${t('modelManager.manageModels')}`}
|
|
onClick={onClickGoToModelManager ?? onClick}
|
|
size="sm"
|
|
variant="ghost"
|
|
{...props}
|
|
/>
|
|
);
|
|
});
|
|
|
|
NavigateToModelManagerButton.displayName = 'NavigateToModelManagerButton';
|