mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-13 02:45:17 -05:00
Update the frontend to incorporate the previous changes to how image selection and general image identification is handled in the frontend.
53 lines
2.0 KiB
TypeScript
53 lines
2.0 KiB
TypeScript
import { IconButton } from '@invoke-ai/ui-library';
|
|
import { useStore } from '@nanostores/react';
|
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
|
import { selectLastSelectedImage } from 'features/gallery/store/gallerySelectors';
|
|
import { useRegisteredHotkeys } from 'features/system/components/HotkeysModal/useHotkeyData';
|
|
import { selectShouldShowImageDetails, selectShouldShowProgressInViewer } from 'features/ui/store/uiSelectors';
|
|
import { setShouldShowImageDetails } from 'features/ui/store/uiSlice';
|
|
import { memo, useCallback } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { PiInfoBold } from 'react-icons/pi';
|
|
|
|
import { useImageViewerContext } from './ImageViewerPanel';
|
|
|
|
export const ToggleMetadataViewerButton = memo(() => {
|
|
const dispatch = useAppDispatch();
|
|
const ctx = useImageViewerContext();
|
|
const hasProgressImage = useStore(ctx.$hasProgressImage);
|
|
const shouldShowProgressInViewer = useAppSelector(selectShouldShowProgressInViewer);
|
|
|
|
const isDisabledOverride = hasProgressImage && shouldShowProgressInViewer;
|
|
|
|
const shouldShowImageDetails = useAppSelector(selectShouldShowImageDetails);
|
|
const imageDTO = useAppSelector(selectLastSelectedImage);
|
|
const { t } = useTranslation();
|
|
|
|
const toggleMetadataViewer = useCallback(() => {
|
|
dispatch(setShouldShowImageDetails(!shouldShowImageDetails));
|
|
}, [dispatch, shouldShowImageDetails]);
|
|
|
|
useRegisteredHotkeys({
|
|
id: 'toggleMetadata',
|
|
category: 'viewer',
|
|
callback: toggleMetadataViewer,
|
|
dependencies: [imageDTO, shouldShowImageDetails],
|
|
});
|
|
|
|
return (
|
|
<IconButton
|
|
icon={<PiInfoBold />}
|
|
tooltip={`${t('parameters.info')} (I)`}
|
|
aria-label={`${t('parameters.info')} (I)`}
|
|
onClick={toggleMetadataViewer}
|
|
variant="link"
|
|
alignSelf="stretch"
|
|
colorScheme={shouldShowImageDetails ? 'invokeBlue' : 'base'}
|
|
data-testid="toggle-show-metadata-button"
|
|
isDisabled={isDisabledOverride}
|
|
/>
|
|
);
|
|
});
|
|
|
|
ToggleMetadataViewerButton.displayName = 'ToggleMetadataViewerButton';
|