tidy(ui): clearer component names for control adapters

This commit is contained in:
psychedelicious 2024-08-07 17:49:02 +10:00
parent eb8eacfec6
commit 6a432f6518
11 changed files with 40 additions and 40 deletions

View File

@ -1,7 +1,7 @@
/* eslint-disable i18next/no-literal-string */ /* 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 { CAEntityList } from 'features/controlLayers/components/ControlAdapter/CAEntityList'; import { ControlAdapterList } from 'features/controlLayers/components/ControlAdapter/ControlAdapterList';
import { IM } from 'features/controlLayers/components/InpaintMask/IM'; import { IM } from 'features/controlLayers/components/InpaintMask/IM';
import { IPAEntityList } from 'features/controlLayers/components/IPAdapter/IPAEntityList'; import { IPAEntityList } from 'features/controlLayers/components/IPAdapter/IPAEntityList';
import { LayerEntityList } from 'features/controlLayers/components/Layer/LayerEntityList'; import { LayerEntityList } from 'features/controlLayers/components/Layer/LayerEntityList';
@ -14,7 +14,7 @@ export const CanvasEntityList = memo(() => {
<Flex flexDir="column" gap={2} data-testid="control-layers-layer-list"> <Flex flexDir="column" gap={2} data-testid="control-layers-layer-list">
<IM /> <IM />
<RGEntityList /> <RGEntityList />
<CAEntityList /> <ControlAdapterList />
<IPAEntityList /> <IPAEntityList />
<LayerEntityList /> <LayerEntityList />
</Flex> </Flex>

View File

@ -4,9 +4,9 @@ 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 { CAActionsMenu } from 'features/controlLayers/components/ControlAdapter/CAActionsMenu'; import { ControlAdapterActionsMenu } from 'features/controlLayers/components/ControlAdapter/ControlAdapterActionsMenu';
import { CAOpacityAndFilter } from 'features/controlLayers/components/ControlAdapter/CAOpacityAndFilter'; import { ControlAdapterOpacityAndFilter } from 'features/controlLayers/components/ControlAdapter/ControlAdapterOpacityAndFilter';
import { CASettings } from 'features/controlLayers/components/ControlAdapter/CASettings'; import { ControlAdapterSettings } from 'features/controlLayers/components/ControlAdapter/ControlAdapterSettings';
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';
@ -15,7 +15,7 @@ type Props = {
id: string; id: string;
}; };
export const CA = memo(({ id }: Props) => { export const ControlAdapter = memo(({ id }: Props) => {
const entityIdentifier = useMemo<CanvasEntityIdentifier>(() => ({ id, type: 'control_adapter' }), [id]); const entityIdentifier = useMemo<CanvasEntityIdentifier>(() => ({ id, type: 'control_adapter' }), [id]);
const { isOpen, onToggle } = useDisclosure({ defaultIsOpen: true }); const { isOpen, onToggle } = useDisclosure({ defaultIsOpen: true });
@ -26,14 +26,14 @@ export const CA = memo(({ id }: Props) => {
<CanvasEntityEnabledToggle /> <CanvasEntityEnabledToggle />
<CanvasEntityTitle /> <CanvasEntityTitle />
<Spacer /> <Spacer />
<CAOpacityAndFilter /> <ControlAdapterOpacityAndFilter />
<CAActionsMenu /> <ControlAdapterActionsMenu />
<CanvasEntityDeleteButton /> <CanvasEntityDeleteButton />
</CanvasEntityHeader> </CanvasEntityHeader>
{isOpen && <CASettings />} {isOpen && <ControlAdapterSettings />}
</CanvasEntityContainer> </CanvasEntityContainer>
</EntityIdentifierContext.Provider> </EntityIdentifierContext.Provider>
); );
}); });
CA.displayName = 'CA'; ControlAdapter.displayName = 'ControlAdapter';

View File

@ -3,7 +3,7 @@ import { CanvasEntityActionMenuItems } from 'features/controlLayers/components/c
import { CanvasEntityMenuButton } from 'features/controlLayers/components/common/CanvasEntityMenuButton'; import { CanvasEntityMenuButton } from 'features/controlLayers/components/common/CanvasEntityMenuButton';
import { memo } from 'react'; import { memo } from 'react';
export const CAActionsMenu = memo(() => { export const ControlAdapterActionsMenu = memo(() => {
return ( return (
<Menu> <Menu>
<CanvasEntityMenuButton /> <CanvasEntityMenuButton />
@ -14,4 +14,4 @@ export const CAActionsMenu = memo(() => {
); );
}); });
CAActionsMenu.displayName = 'CAActionsMenu'; ControlAdapterActionsMenu.displayName = 'ControlAdapterActionsMenu';

View File

@ -12,7 +12,7 @@ type Props = {
onChange: (controlMode: ControlModeV2) => void; onChange: (controlMode: ControlModeV2) => void;
}; };
export const CAControlModeSelect = memo(({ controlMode, onChange }: Props) => { export const ControlAdapterControlModeSelect = memo(({ controlMode, onChange }: Props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const CONTROL_MODE_DATA = useMemo( const CONTROL_MODE_DATA = useMemo(
() => [ () => [
@ -57,4 +57,4 @@ export const CAControlModeSelect = memo(({ controlMode, onChange }: Props) => {
); );
}); });
CAControlModeSelect.displayName = 'CAControlModeSelect'; ControlAdapterControlModeSelect.displayName = 'ControlAdapterControlModeSelect';

View File

@ -28,7 +28,7 @@ type Props = {
onErrorLoadingProcessedImage: () => void; onErrorLoadingProcessedImage: () => void;
}; };
export const CAImagePreview = memo( export const ControlAdapterImagePreview = memo(
({ ({
controlAdapter, controlAdapter,
onChangeImage, onChangeImage,
@ -226,4 +226,4 @@ export const CAImagePreview = memo(
} }
); );
CAImagePreview.displayName = 'CAImagePreview'; ControlAdapterImagePreview.displayName = 'ControlAdapterImagePreview';

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 { CA } from 'features/controlLayers/components/ControlAdapter/CA'; import { ControlAdapter } from 'features/controlLayers/components/ControlAdapter/ControlAdapter';
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.controlAdapters.entities.map(mapId).reverse(); return canvasV2.controlAdapters.entities.map(mapId).reverse();
}); });
export const CAEntityList = memo(() => { export const ControlAdapterList = memo(() => {
const { t } = useTranslation(); const { t } = useTranslation();
const isSelected = useAppSelector((s) => Boolean(s.canvasV2.selectedEntityIdentifier?.type === 'control_adapter')); const isSelected = useAppSelector((s) => Boolean(s.canvasV2.selectedEntityIdentifier?.type === 'control_adapter'));
const caIds = useAppSelector(selectEntityIds); const caIds = useAppSelector(selectEntityIds);
@ -28,11 +28,11 @@ export const CAEntityList = memo(() => {
isSelected={isSelected} isSelected={isSelected}
/> />
{caIds.map((id) => ( {caIds.map((id) => (
<CA key={id} id={id} /> <ControlAdapter key={id} id={id} />
))} ))}
</> </>
); );
} }
}); });
CAEntityList.displayName = 'CAEntityList'; ControlAdapterList.displayName = 'ControlAdapterList';

View File

@ -11,7 +11,7 @@ type Props = {
onChange: (modelConfig: ControlNetModelConfig | T2IAdapterModelConfig) => void; onChange: (modelConfig: ControlNetModelConfig | T2IAdapterModelConfig) => void;
}; };
export const CAModelCombobox = memo(({ modelKey, onChange: onChangeModel }: Props) => { export const ControlAdapterModel = memo(({ modelKey, onChange: onChangeModel }: Props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const currentBaseModel = useAppSelector((s) => s.canvasV2.params.model?.base); const currentBaseModel = useAppSelector((s) => s.canvasV2.params.model?.base);
const [modelConfigs, { isLoading }] = useControlNetAndT2IAdapterModels(); const [modelConfigs, { isLoading }] = useControlNetAndT2IAdapterModels();
@ -60,4 +60,4 @@ export const CAModelCombobox = memo(({ modelKey, onChange: onChangeModel }: Prop
); );
}); });
CAModelCombobox.displayName = 'CAModelCombobox'; ControlAdapterModel.displayName = 'ControlAdapterModel';

View File

@ -25,7 +25,7 @@ import { PiDropHalfFill } from 'react-icons/pi';
const marks = [0, 25, 50, 75, 100]; const marks = [0, 25, 50, 75, 100];
const formatPct = (v: number | string) => `${v} %`; const formatPct = (v: number | string) => `${v} %`;
export const CAOpacityAndFilter = memo(() => { export const ControlAdapterOpacityAndFilter = memo(() => {
const { id } = useEntityIdentifierContext(); const { id } = useEntityIdentifierContext();
const { t } = useTranslation(); const { t } = useTranslation();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
@ -96,4 +96,4 @@ export const CAOpacityAndFilter = memo(() => {
); );
}); });
CAOpacityAndFilter.displayName = 'CAOpacityAndFilter'; ControlAdapterOpacityAndFilter.displayName = 'ControlAdapterOpacityAndFilter';

View File

@ -17,7 +17,7 @@ type Props = {
onChange: (config: ProcessorConfig | null) => void; onChange: (config: ProcessorConfig | null) => void;
}; };
export const CAProcessorConfig = memo(({ config, onChange }: Props) => { export const ControlAdapterProcessorConfig = memo(({ config, onChange }: Props) => {
if (!config) { if (!config) {
return null; return null;
} }
@ -81,4 +81,4 @@ export const CAProcessorConfig = memo(({ config, onChange }: Props) => {
} }
}); });
CAProcessorConfig.displayName = 'CAProcessorConfig'; ControlAdapterProcessorConfig.displayName = 'ControlAdapterProcessorConfig';

View File

@ -22,7 +22,7 @@ const selectDisabledProcessors = createMemoizedSelector(
(config) => config.sd.disabledControlNetProcessors (config) => config.sd.disabledControlNetProcessors
); );
export const CAProcessorTypeSelect = memo(({ config, onChange }: Props) => { export const ControlAdapterProcessorTypeSelect = memo(({ config, onChange }: Props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const disabledProcessors = useAppSelector(selectDisabledProcessors); const disabledProcessors = useAppSelector(selectDisabledProcessors);
const options = useMemo(() => { const options = useMemo(() => {
@ -67,4 +67,4 @@ export const CAProcessorTypeSelect = memo(({ config, onChange }: Props) => {
); );
}); });
CAProcessorTypeSelect.displayName = 'CAProcessorTypeSelect'; ControlAdapterProcessorTypeSelect.displayName = 'ControlAdapterProcessorTypeSelect';

View File

@ -3,11 +3,11 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { BeginEndStepPct } from 'features/controlLayers/components/common/BeginEndStepPct'; import { BeginEndStepPct } from 'features/controlLayers/components/common/BeginEndStepPct';
import { CanvasEntitySettings } from 'features/controlLayers/components/common/CanvasEntitySettings'; import { CanvasEntitySettings } from 'features/controlLayers/components/common/CanvasEntitySettings';
import { Weight } from 'features/controlLayers/components/common/Weight'; import { Weight } from 'features/controlLayers/components/common/Weight';
import { CAControlModeSelect } from 'features/controlLayers/components/ControlAdapter/CAControlModeSelect'; import { ControlAdapterControlModeSelect } from 'features/controlLayers/components/ControlAdapter/ControlAdapterControlModeSelect';
import { CAImagePreview } from 'features/controlLayers/components/ControlAdapter/CAImagePreview'; import { ControlAdapterImagePreview } from 'features/controlLayers/components/ControlAdapter/ControlAdapterImagePreview';
import { CAModelCombobox } from 'features/controlLayers/components/ControlAdapter/CAModelCombobox'; import { ControlAdapterModel } from 'features/controlLayers/components/ControlAdapter/ControlAdapterModel';
import { CAProcessorConfig } from 'features/controlLayers/components/ControlAdapter/CAProcessorConfig'; import { ControlAdapterProcessorConfig } from 'features/controlLayers/components/ControlAdapter/ControlAdapterProcessorConfig';
import { CAProcessorTypeSelect } from 'features/controlLayers/components/ControlAdapter/CAProcessorTypeSelect'; import { ControlAdapterProcessorTypeSelect } from 'features/controlLayers/components/ControlAdapter/ControlAdapterProcessorTypeSelect';
import { useEntityIdentifierContext } from 'features/controlLayers/contexts/EntityIdentifierContext'; import { useEntityIdentifierContext } from 'features/controlLayers/contexts/EntityIdentifierContext';
import { import {
caBeginEndStepPctChanged, caBeginEndStepPctChanged,
@ -32,7 +32,7 @@ import type {
T2IAdapterModelConfig, T2IAdapterModelConfig,
} from 'services/api/types'; } from 'services/api/types';
export const CASettings = memo(() => { export const ControlAdapterSettings = memo(() => {
const { id } = useEntityIdentifierContext(); const { id } = useEntityIdentifierContext();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { t } = useTranslation(); const { t } = useTranslation();
@ -98,7 +98,7 @@ export const CASettings = memo(() => {
<Flex flexDir="column" gap={3} position="relative" w="full"> <Flex flexDir="column" gap={3} position="relative" w="full">
<Flex gap={3} alignItems="center" w="full"> <Flex gap={3} alignItems="center" w="full">
<Box minW={0} w="full" transitionProperty="common" transitionDuration="0.1s"> <Box minW={0} w="full" transitionProperty="common" transitionDuration="0.1s">
<CAModelCombobox modelKey={controlAdapter.model?.key ?? null} onChange={onChangeModel} /> <ControlAdapterModel modelKey={controlAdapter.model?.key ?? null} onChange={onChangeModel} />
</Box> </Box>
<IconButton <IconButton
@ -121,13 +121,13 @@ export const CASettings = memo(() => {
<Flex gap={3} w="full"> <Flex gap={3} w="full">
<Flex flexDir="column" gap={3} w="full" h="full"> <Flex flexDir="column" gap={3} w="full" h="full">
{controlAdapter.adapterType === 'controlnet' && ( {controlAdapter.adapterType === 'controlnet' && (
<CAControlModeSelect controlMode={controlAdapter.controlMode} onChange={onChangeControlMode} /> <ControlAdapterControlModeSelect controlMode={controlAdapter.controlMode} onChange={onChangeControlMode} />
)} )}
<Weight weight={controlAdapter.weight} onChange={onChangeWeight} /> <Weight weight={controlAdapter.weight} onChange={onChangeWeight} />
<BeginEndStepPct beginEndStepPct={controlAdapter.beginEndStepPct} onChange={onChangeBeginEndStepPct} /> <BeginEndStepPct beginEndStepPct={controlAdapter.beginEndStepPct} onChange={onChangeBeginEndStepPct} />
</Flex> </Flex>
<Flex alignItems="center" justifyContent="center" h={36} w={36} aspectRatio="1/1"> <Flex alignItems="center" justifyContent="center" h={36} w={36} aspectRatio="1/1">
<CAImagePreview <ControlAdapterImagePreview
controlAdapter={controlAdapter} controlAdapter={controlAdapter}
onChangeImage={onChangeImage} onChangeImage={onChangeImage}
droppableData={droppableData} droppableData={droppableData}
@ -141,8 +141,8 @@ export const CASettings = memo(() => {
<> <>
<Divider /> <Divider />
<Flex flexDir="column" gap={3} w="full"> <Flex flexDir="column" gap={3} w="full">
<CAProcessorTypeSelect config={controlAdapter.processorConfig} onChange={onChangeProcessorConfig} /> <ControlAdapterProcessorTypeSelect config={controlAdapter.processorConfig} onChange={onChangeProcessorConfig} />
<CAProcessorConfig config={controlAdapter.processorConfig} onChange={onChangeProcessorConfig} /> <ControlAdapterProcessorConfig config={controlAdapter.processorConfig} onChange={onChangeProcessorConfig} />
</Flex> </Flex>
</> </>
)} )}
@ -151,4 +151,4 @@ export const CASettings = memo(() => {
); );
}); });
CASettings.displayName = 'CASettings'; ControlAdapterSettings.displayName = 'ControlAdapterSettings';