feat(ui): no JSX in metadata handlers

This commit is contained in:
psychedelicious 2024-02-26 10:23:37 +11:00 committed by Brandon Rising
parent caa05864f8
commit c6a95eb9ac
4 changed files with 10 additions and 9 deletions

View File

@ -1,3 +1,4 @@
import { Text } from '@invoke-ai/ui-library';
import type { ControlNetConfig } from 'features/controlAdapters/store/types';
import { MetadataItemView } from 'features/metadata/components/MetadataItemView';
import type { MetadataHandlers } from 'features/metadata/types';
@ -59,7 +60,7 @@ const MetadataViewControlNet = ({
if (!handlers.renderItemValue) {
return null;
}
return handlers.renderItemValue(controlNet);
return <Text>{handlers.renderItemValue(controlNet)}</Text>;
}, [handlers, controlNet]);
return <MetadataItemView label={label} isDisabled={false} onRecall={onRecall} renderedValue={renderedValue} />;

View File

@ -1,3 +1,4 @@
import { Text } from '@invoke-ai/ui-library';
import type { IPAdapterConfig } from 'features/controlAdapters/store/types';
import { MetadataItemView } from 'features/metadata/components/MetadataItemView';
import type { MetadataHandlers } from 'features/metadata/types';
@ -59,7 +60,7 @@ const MetadataViewIPAdapter = ({
if (!handlers.renderItemValue) {
return null;
}
return handlers.renderItemValue(ipAdapter);
return <Text>{handlers.renderItemValue(ipAdapter)}</Text>;
}, [handlers, ipAdapter]);
return <MetadataItemView label={label} isDisabled={false} onRecall={onRecall} renderedValue={renderedValue} />;

View File

@ -1,3 +1,4 @@
import { Text } from '@invoke-ai/ui-library';
import type { T2IAdapterConfig } from 'features/controlAdapters/store/types';
import { MetadataItemView } from 'features/metadata/components/MetadataItemView';
import type { MetadataHandlers } from 'features/metadata/types';
@ -59,7 +60,7 @@ const MetadataViewT2IAdapter = ({
if (!handlers.renderItemValue) {
return null;
}
return handlers.renderItemValue(t2iAdapter);
return <Text>{handlers.renderItemValue(t2iAdapter)}</Text>;
}, [handlers, t2iAdapter]);
return <MetadataItemView label={label} isDisabled={false} onRecall={onRecall} renderedValue={renderedValue} />;

View File

@ -1,6 +1,5 @@
import { Text } from '@invoke-ai/ui-library';
import { toast } from 'common/util/toast';
import type { ControlNetConfig, IPAdapterConfig, T2IAdapterConfig } from 'features/controlAdapters/store/types';
import type { ControlAdapterConfig } from 'features/controlAdapters/store/types';
import type { LoRA } from 'features/lora/store/loraSlice';
import type {
BuildMetadataHandlers,
@ -20,10 +19,9 @@ import { recallers } from './recallers';
const renderModelConfigValue: MetadataRenderValueFunc<AnyModelConfig> = (value) =>
`${value.name} (${value.base.toUpperCase()}, ${value.key})`;
const renderLoRAValue: MetadataRenderValueFunc<LoRA> = (value) => <Text>{`${value.model.key} (${value.weight})`}</Text>;
const renderControlAdapterValue: MetadataRenderValueFunc<ControlNetConfig | T2IAdapterConfig | IPAdapterConfig> = (
value
) => <Text>{`${value.model?.key} (${value.weight})`}</Text>;
const renderLoRAValue: MetadataRenderValueFunc<LoRA> = (value) => `${value.model.key} (${value.weight})`;
const renderControlAdapterValue: MetadataRenderValueFunc<ControlAdapterConfig> = (value) =>
`${value.model?.key} (${value.weight})`;
const parameterSetToast = (parameter: string, description?: string) => {
toast({