tidy(ui): clearer component names for regional guidance

This commit is contained in:
psychedelicious 2024-08-07 18:06:44 +10:00
parent 4e5e7761fc
commit 52e9f43c46
13 changed files with 50 additions and 51 deletions

View File

@ -1,11 +1,10 @@
/* eslint-disable i18next/no-literal-string */
import { Flex } from '@invoke-ai/ui-library'; import { Flex } from '@invoke-ai/ui-library';
import ScrollableContent from 'common/components/OverlayScrollbars/ScrollableContent'; import ScrollableContent from 'common/components/OverlayScrollbars/ScrollableContent';
import { ControlAdapterList } from 'features/controlLayers/components/ControlAdapter/ControlAdapterList'; import { ControlAdapterList } from 'features/controlLayers/components/ControlAdapter/ControlAdapterList';
import { InpaintMask } from 'features/controlLayers/components/InpaintMask/InpaintMask'; import { InpaintMask } from 'features/controlLayers/components/InpaintMask/InpaintMask';
import { IPAdapterList } from 'features/controlLayers/components/IPAdapter/IPAdapterList'; import { IPAdapterList } from 'features/controlLayers/components/IPAdapter/IPAdapterList';
import { LayerEntityList } from 'features/controlLayers/components/Layer/LayerEntityList'; import { LayerEntityList } from 'features/controlLayers/components/Layer/LayerEntityList';
import { RGEntityList } from 'features/controlLayers/components/RegionalGuidance/RGEntityList'; import { RegionalGuidanceEntityList } from 'features/controlLayers/components/RegionalGuidance/RegionalGuidanceEntityList';
import { memo } from 'react'; import { memo } from 'react';
export const CanvasEntityList = memo(() => { export const CanvasEntityList = memo(() => {
@ -13,7 +12,7 @@ export const CanvasEntityList = memo(() => {
<ScrollableContent> <ScrollableContent>
<Flex flexDir="column" gap={2} data-testid="control-layers-layer-list"> <Flex flexDir="column" gap={2} data-testid="control-layers-layer-list">
<InpaintMask /> <InpaintMask />
<RGEntityList /> <RegionalGuidanceEntityList />
<ControlAdapterList /> <ControlAdapterList />
<IPAdapterList /> <IPAdapterList />
<LayerEntityList /> <LayerEntityList />

View File

@ -4,21 +4,21 @@ import { CanvasEntityDeleteButton } from 'features/controlLayers/components/comm
import { CanvasEntityEnabledToggle } from 'features/controlLayers/components/common/CanvasEntityEnabledToggle'; import { CanvasEntityEnabledToggle } from 'features/controlLayers/components/common/CanvasEntityEnabledToggle';
import { CanvasEntityHeader } from 'features/controlLayers/components/common/CanvasEntityHeader'; import { CanvasEntityHeader } from 'features/controlLayers/components/common/CanvasEntityHeader';
import { CanvasEntityTitle } from 'features/controlLayers/components/common/CanvasEntityTitle'; import { CanvasEntityTitle } from 'features/controlLayers/components/common/CanvasEntityTitle';
import { RGActionsMenu } from 'features/controlLayers/components/RegionalGuidance/RGActionsMenu'; import { RegionalGuidanceActionsMenu } from 'features/controlLayers/components/RegionalGuidance/RegionalGuidanceActionsMenu';
import { RGBadges } from 'features/controlLayers/components/RegionalGuidance/RGBadges'; import { RegionalGuidanceBadges } from 'features/controlLayers/components/RegionalGuidance/RegionalGuidanceBadges';
import { RGSettings } from 'features/controlLayers/components/RegionalGuidance/RGSettings'; import { RegionalGuidanceSettings } from 'features/controlLayers/components/RegionalGuidance/RegionalGuidanceSettings';
import { EntityIdentifierContext } from 'features/controlLayers/contexts/EntityIdentifierContext'; import { EntityIdentifierContext } from 'features/controlLayers/contexts/EntityIdentifierContext';
import type { CanvasEntityIdentifier } from 'features/controlLayers/store/types'; import type { CanvasEntityIdentifier } from 'features/controlLayers/store/types';
import { memo, useMemo } from 'react'; import { memo, useMemo } from 'react';
import { RGMaskFillColorPicker } from './RGMaskFillColorPicker'; import { RegionalGuidanceMaskFillColorPicker } from './RegionalGuidanceMaskFillColorPicker';
import { RGSettingsPopover } from './RGSettingsPopover'; import { RegionalGuidanceSettingsPopover } from './RegionalGuidanceSettingsPopover';
type Props = { type Props = {
id: string; id: string;
}; };
export const RG = memo(({ id }: Props) => { export const RegionalGuidance = memo(({ id }: Props) => {
const entityIdentifier = useMemo<CanvasEntityIdentifier>(() => ({ id, type: 'regional_guidance' }), [id]); const entityIdentifier = useMemo<CanvasEntityIdentifier>(() => ({ id, type: 'regional_guidance' }), [id]);
const { isOpen, onToggle } = useDisclosure({ defaultIsOpen: true }); const { isOpen, onToggle } = useDisclosure({ defaultIsOpen: true });
return ( return (
@ -28,16 +28,16 @@ export const RG = memo(({ id }: Props) => {
<CanvasEntityEnabledToggle /> <CanvasEntityEnabledToggle />
<CanvasEntityTitle /> <CanvasEntityTitle />
<Spacer /> <Spacer />
<RGBadges /> <RegionalGuidanceBadges />
<RGMaskFillColorPicker /> <RegionalGuidanceMaskFillColorPicker />
<RGSettingsPopover /> <RegionalGuidanceSettingsPopover />
<RGActionsMenu /> <RegionalGuidanceActionsMenu />
<CanvasEntityDeleteButton /> <CanvasEntityDeleteButton />
</CanvasEntityHeader> </CanvasEntityHeader>
{isOpen && <RGSettings />} {isOpen && <RegionalGuidanceSettings />}
</CanvasEntityContainer> </CanvasEntityContainer>
</EntityIdentifierContext.Provider> </EntityIdentifierContext.Provider>
); );
}); });
RG.displayName = 'RG'; RegionalGuidance.displayName = 'RegionalGuidance';

View File

@ -15,7 +15,7 @@ import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { PiPlusBold } from 'react-icons/pi'; import { PiPlusBold } from 'react-icons/pi';
export const RGActionsMenu = memo(() => { export const RegionalGuidanceActionsMenu = memo(() => {
const { id } = useEntityIdentifierContext(); const { id } = useEntityIdentifierContext();
const { t } = useTranslation(); const { t } = useTranslation();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
@ -59,4 +59,4 @@ export const RGActionsMenu = memo(() => {
); );
}); });
RGActionsMenu.displayName = 'RGActionsMenu'; RegionalGuidanceActionsMenu.displayName = 'RegionalGuidanceActionsMenu';

View File

@ -5,7 +5,7 @@ import { selectRGOrThrow } from 'features/controlLayers/store/regionsReducers';
import { memo } from 'react'; import { memo } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
export const RGBadges = memo(() => { export const RegionalGuidanceBadges = memo(() => {
const { id } = useEntityIdentifierContext(); const { id } = useEntityIdentifierContext();
const { t } = useTranslation(); const { t } = useTranslation();
const autoNegative = useAppSelector((s) => selectRGOrThrow(s.canvasV2, id).autoNegative); const autoNegative = useAppSelector((s) => selectRGOrThrow(s.canvasV2, id).autoNegative);
@ -21,4 +21,4 @@ export const RGBadges = memo(() => {
); );
}); });
RGBadges.displayName = 'RGBadges'; RegionalGuidanceBadges.displayName = 'RegionalGuidanceBadges';

View File

@ -7,7 +7,7 @@ type Props = {
onDelete: () => void; onDelete: () => void;
}; };
export const RGDeletePromptButton = memo(({ onDelete }: Props) => { export const RegionalGuidanceDeletePromptButton = memo(({ onDelete }: Props) => {
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<Tooltip label={t('controlLayers.deletePrompt')}> <Tooltip label={t('controlLayers.deletePrompt')}>
@ -21,4 +21,4 @@ export const RGDeletePromptButton = memo(({ onDelete }: Props) => {
); );
}); });
RGDeletePromptButton.displayName = 'RGDeletePromptButton'; RegionalGuidanceDeletePromptButton.displayName = 'RegionalGuidanceDeletePromptButton';

View File

@ -1,7 +1,7 @@
import { createMemoizedSelector } from 'app/store/createMemoizedSelector'; import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
import { useAppSelector } from 'app/store/storeHooks'; import { useAppSelector } from 'app/store/storeHooks';
import { CanvasEntityGroupTitle } from 'features/controlLayers/components/common/CanvasEntityGroupTitle'; import { CanvasEntityGroupTitle } from 'features/controlLayers/components/common/CanvasEntityGroupTitle';
import { RG } from 'features/controlLayers/components/RegionalGuidance/RG'; import { RegionalGuidance } from 'features/controlLayers/components/RegionalGuidance/RegionalGuidance';
import { mapId } from 'features/controlLayers/konva/util'; import { mapId } from 'features/controlLayers/konva/util';
import { selectCanvasV2Slice } from 'features/controlLayers/store/canvasV2Slice'; import { selectCanvasV2Slice } from 'features/controlLayers/store/canvasV2Slice';
import { memo } from 'react'; import { memo } from 'react';
@ -11,7 +11,7 @@ const selectEntityIds = createMemoizedSelector(selectCanvasV2Slice, (canvasV2) =
return canvasV2.regions.entities.map(mapId).reverse(); return canvasV2.regions.entities.map(mapId).reverse();
}); });
export const RGEntityList = memo(() => { export const RegionalGuidanceEntityList = memo(() => {
const { t } = useTranslation(); const { t } = useTranslation();
const isSelected = useAppSelector((s) => Boolean(s.canvasV2.selectedEntityIdentifier?.type === 'regional_guidance')); const isSelected = useAppSelector((s) => Boolean(s.canvasV2.selectedEntityIdentifier?.type === 'regional_guidance'));
const rgIds = useAppSelector(selectEntityIds); const rgIds = useAppSelector(selectEntityIds);
@ -28,11 +28,11 @@ export const RGEntityList = memo(() => {
isSelected={isSelected} isSelected={isSelected}
/> />
{rgIds.map((id) => ( {rgIds.map((id) => (
<RG key={id} id={id} /> <RegionalGuidance key={id} id={id} />
))} ))}
</> </>
); );
} }
}); });
RGEntityList.displayName = 'RGEntityList'; RegionalGuidanceEntityList.displayName = 'RegionalGuidanceEntityList';

View File

@ -28,7 +28,7 @@ type Props = {
ipAdapterNumber: number; ipAdapterNumber: number;
}; };
export const RGIPAdapterSettings = memo(({ id, ipAdapterId, ipAdapterNumber }: Props) => { export const RegionalGuidanceIPAdapterSettings = memo(({ id, ipAdapterId, ipAdapterNumber }: Props) => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const onDeleteIPAdapter = useCallback(() => { const onDeleteIPAdapter = useCallback(() => {
dispatch(rgIPAdapterDeleted({ id, ipAdapterId })); dispatch(rgIPAdapterDeleted({ id, ipAdapterId }));
@ -136,4 +136,4 @@ export const RGIPAdapterSettings = memo(({ id, ipAdapterId, ipAdapterNumber }: P
); );
}); });
RGIPAdapterSettings.displayName = 'RGIPAdapterSettings'; RegionalGuidanceIPAdapterSettings.displayName = 'RegionalGuidanceIPAdapterSettings';

View File

@ -1,6 +1,6 @@
import { Divider, Flex } from '@invoke-ai/ui-library'; import { Divider, Flex } from '@invoke-ai/ui-library';
import { useAppSelector } from 'app/store/storeHooks'; import { useAppSelector } from 'app/store/storeHooks';
import { RGIPAdapterSettings } from 'features/controlLayers/components/RegionalGuidance/RGIPAdapterSettings'; import { RegionalGuidanceIPAdapterSettings } from 'features/controlLayers/components/RegionalGuidance/RegionalGuidanceIPAdapterSettings';
import { selectRGOrThrow } from 'features/controlLayers/store/regionsReducers'; import { selectRGOrThrow } from 'features/controlLayers/store/regionsReducers';
import { memo } from 'react'; import { memo } from 'react';
@ -8,7 +8,7 @@ type Props = {
id: string; id: string;
}; };
export const RGIPAdapters = memo(({ id }: Props) => { export const RegionalGuidanceIPAdapters = memo(({ id }: Props) => {
const ipAdapterIds = useAppSelector((s) => selectRGOrThrow(s.canvasV2, id).ipAdapters.map(({ id }) => id)); const ipAdapterIds = useAppSelector((s) => selectRGOrThrow(s.canvasV2, id).ipAdapters.map(({ id }) => id));
if (ipAdapterIds.length === 0) { if (ipAdapterIds.length === 0) {
@ -24,11 +24,11 @@ export const RGIPAdapters = memo(({ id }: Props) => {
<Divider /> <Divider />
</Flex> </Flex>
)} )}
<RGIPAdapterSettings id={id} ipAdapterId={id} ipAdapterNumber={index + 1} /> <RegionalGuidanceIPAdapterSettings id={id} ipAdapterId={id} ipAdapterNumber={index + 1} />
</Flex> </Flex>
))} ))}
</> </>
); );
}); });
RGIPAdapters.displayName = 'RGLayerIPAdapterList'; RegionalGuidanceIPAdapters.displayName = 'RegionalGuidanceLayerIPAdapterList';

View File

@ -10,7 +10,7 @@ import { memo, useCallback } from 'react';
import type { RgbColor } from 'react-colorful'; import type { RgbColor } from 'react-colorful';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
export const RGMaskFillColorPicker = memo(() => { export const RegionalGuidanceMaskFillColorPicker = memo(() => {
const entityIdentifier = useEntityIdentifierContext(); const entityIdentifier = useEntityIdentifierContext();
const { t } = useTranslation(); const { t } = useTranslation();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
@ -46,4 +46,4 @@ export const RGMaskFillColorPicker = memo(() => {
); );
}); });
RGMaskFillColorPicker.displayName = 'RGMaskFillColorPicker'; RegionalGuidanceMaskFillColorPicker.displayName = 'RegionalGuidanceMaskFillColorPicker';

View File

@ -1,6 +1,6 @@
import { Box, Textarea } from '@invoke-ai/ui-library'; import { Box, Textarea } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { RGDeletePromptButton } from 'features/controlLayers/components/RegionalGuidance/RGDeletePromptButton'; import { RegionalGuidanceDeletePromptButton } from 'features/controlLayers/components/RegionalGuidance/RegionalGuidanceDeletePromptButton';
import { rgNegativePromptChanged } from 'features/controlLayers/store/canvasV2Slice'; import { rgNegativePromptChanged } from 'features/controlLayers/store/canvasV2Slice';
import { selectRGOrThrow } from 'features/controlLayers/store/regionsReducers'; import { selectRGOrThrow } from 'features/controlLayers/store/regionsReducers';
import { PromptOverlayButtonWrapper } from 'features/parameters/components/Prompts/PromptOverlayButtonWrapper'; import { PromptOverlayButtonWrapper } from 'features/parameters/components/Prompts/PromptOverlayButtonWrapper';
@ -14,7 +14,7 @@ type Props = {
id: string; id: string;
}; };
export const RGNegativePrompt = memo(({ id }: Props) => { export const RegionalGuidanceNegativePrompt = memo(({ id }: Props) => {
const prompt = useAppSelector((s) => selectRGOrThrow(s.canvasV2, id).negativePrompt ?? ''); const prompt = useAppSelector((s) => selectRGOrThrow(s.canvasV2, id).negativePrompt ?? '');
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const textareaRef = useRef<HTMLTextAreaElement>(null); const textareaRef = useRef<HTMLTextAreaElement>(null);
@ -50,7 +50,7 @@ export const RGNegativePrompt = memo(({ id }: Props) => {
fontSize="sm" fontSize="sm"
/> />
<PromptOverlayButtonWrapper> <PromptOverlayButtonWrapper>
<RGDeletePromptButton onDelete={onDeletePrompt} /> <RegionalGuidanceDeletePromptButton onDelete={onDeletePrompt} />
<AddPromptTriggerButton isOpen={isOpen} onOpen={onOpen} /> <AddPromptTriggerButton isOpen={isOpen} onOpen={onOpen} />
</PromptOverlayButtonWrapper> </PromptOverlayButtonWrapper>
</Box> </Box>
@ -58,4 +58,4 @@ export const RGNegativePrompt = memo(({ id }: Props) => {
); );
}); });
RGNegativePrompt.displayName = 'RGNegativePrompt'; RegionalGuidanceNegativePrompt.displayName = 'RegionalGuidanceNegativePrompt';

View File

@ -1,6 +1,6 @@
import { Box, Textarea } from '@invoke-ai/ui-library'; import { Box, Textarea } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { RGDeletePromptButton } from 'features/controlLayers/components/RegionalGuidance/RGDeletePromptButton'; import { RegionalGuidanceDeletePromptButton } from 'features/controlLayers/components/RegionalGuidance/RegionalGuidanceDeletePromptButton';
import { rgPositivePromptChanged } from 'features/controlLayers/store/canvasV2Slice'; import { rgPositivePromptChanged } from 'features/controlLayers/store/canvasV2Slice';
import { selectRGOrThrow } from 'features/controlLayers/store/regionsReducers'; import { selectRGOrThrow } from 'features/controlLayers/store/regionsReducers';
import { PromptOverlayButtonWrapper } from 'features/parameters/components/Prompts/PromptOverlayButtonWrapper'; import { PromptOverlayButtonWrapper } from 'features/parameters/components/Prompts/PromptOverlayButtonWrapper';
@ -14,7 +14,7 @@ type Props = {
id: string; id: string;
}; };
export const RGPositivePrompt = memo(({ id }: Props) => { export const RegionalGuidancePositivePrompt = memo(({ id }: Props) => {
const prompt = useAppSelector((s) => selectRGOrThrow(s.canvasV2, id).positivePrompt ?? ''); const prompt = useAppSelector((s) => selectRGOrThrow(s.canvasV2, id).positivePrompt ?? '');
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const textareaRef = useRef<HTMLTextAreaElement>(null); const textareaRef = useRef<HTMLTextAreaElement>(null);
@ -50,7 +50,7 @@ export const RGPositivePrompt = memo(({ id }: Props) => {
minH={28} minH={28}
/> />
<PromptOverlayButtonWrapper> <PromptOverlayButtonWrapper>
<RGDeletePromptButton onDelete={onDeletePrompt} /> <RegionalGuidanceDeletePromptButton onDelete={onDeletePrompt} />
<AddPromptTriggerButton isOpen={isOpen} onOpen={onOpen} /> <AddPromptTriggerButton isOpen={isOpen} onOpen={onOpen} />
</PromptOverlayButtonWrapper> </PromptOverlayButtonWrapper>
</Box> </Box>
@ -58,4 +58,4 @@ export const RGPositivePrompt = memo(({ id }: Props) => {
); );
}); });
RGPositivePrompt.displayName = 'RGPositivePrompt'; RegionalGuidancePositivePrompt.displayName = 'RegionalGuidancePositivePrompt';

View File

@ -5,11 +5,11 @@ import { useEntityIdentifierContext } from 'features/controlLayers/contexts/Enti
import { selectRGOrThrow } from 'features/controlLayers/store/regionsReducers'; import { selectRGOrThrow } from 'features/controlLayers/store/regionsReducers';
import { memo } from 'react'; import { memo } from 'react';
import { RGIPAdapters } from './RGIPAdapters'; import { RegionalGuidanceIPAdapters } from './RegionalGuidanceIPAdapters';
import { RGNegativePrompt } from './RGNegativePrompt'; import { RegionalGuidanceNegativePrompt } from './RegionalGuidanceNegativePrompt';
import { RGPositivePrompt } from './RGPositivePrompt'; import { RegionalGuidancePositivePrompt } from './RegionalGuidancePositivePrompt';
export const RGSettings = memo(() => { export const RegionalGuidanceSettings = memo(() => {
const { id } = useEntityIdentifierContext(); const { id } = useEntityIdentifierContext();
const hasPositivePrompt = useAppSelector((s) => selectRGOrThrow(s.canvasV2, id).positivePrompt !== null); const hasPositivePrompt = useAppSelector((s) => selectRGOrThrow(s.canvasV2, id).positivePrompt !== null);
const hasNegativePrompt = useAppSelector((s) => selectRGOrThrow(s.canvasV2, id).negativePrompt !== null); const hasNegativePrompt = useAppSelector((s) => selectRGOrThrow(s.canvasV2, id).negativePrompt !== null);
@ -18,11 +18,11 @@ export const RGSettings = memo(() => {
return ( return (
<CanvasEntitySettings> <CanvasEntitySettings>
{!hasPositivePrompt && !hasNegativePrompt && !hasIPAdapters && <AddPromptButtons id={id} />} {!hasPositivePrompt && !hasNegativePrompt && !hasIPAdapters && <AddPromptButtons id={id} />}
{hasPositivePrompt && <RGPositivePrompt id={id} />} {hasPositivePrompt && <RegionalGuidancePositivePrompt id={id} />}
{hasNegativePrompt && <RGNegativePrompt id={id} />} {hasNegativePrompt && <RegionalGuidanceNegativePrompt id={id} />}
{hasIPAdapters && <RGIPAdapters id={id} />} {hasIPAdapters && <RegionalGuidanceIPAdapters id={id} />}
</CanvasEntitySettings> </CanvasEntitySettings>
); );
}); });
RGSettings.displayName = 'RGSettings'; RegionalGuidanceSettings.displayName = 'RegionalGuidanceSettings';

View File

@ -20,7 +20,7 @@ import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { PiGearSixBold } from 'react-icons/pi'; import { PiGearSixBold } from 'react-icons/pi';
export const RGSettingsPopover = memo(() => { export const RegionalGuidanceSettingsPopover = memo(() => {
const entityIdentifier = useEntityIdentifierContext(); const entityIdentifier = useEntityIdentifierContext();
const { t } = useTranslation(); const { t } = useTranslation();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
@ -60,4 +60,4 @@ export const RGSettingsPopover = memo(() => {
); );
}); });
RGSettingsPopover.displayName = 'RGSettingsPopover'; RegionalGuidanceSettingsPopover.displayName = 'RegionalGuidanceSettingsPopover';