mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
feat(ui): return translation keys from validation utils instead of translated strings
This commit is contained in:
@@ -33,15 +33,15 @@ const buildSelectWarnings = (entityIdentifier: CanvasEntityIdentifier, t: TFunct
|
||||
const entityType = entity.type;
|
||||
|
||||
if (entityType === 'control_layer') {
|
||||
warnings = getControlLayerWarnings(entity, model, t);
|
||||
warnings = getControlLayerWarnings(entity, model);
|
||||
} else if (entityType === 'regional_guidance') {
|
||||
warnings = getRegionalGuidanceWarnings(entity, model, t);
|
||||
warnings = getRegionalGuidanceWarnings(entity, model);
|
||||
} else if (entityType === 'inpaint_mask') {
|
||||
warnings = getInpaintMaskWarnings(entity, model, t);
|
||||
warnings = getInpaintMaskWarnings(entity, model);
|
||||
} else if (entityType === 'raster_layer') {
|
||||
warnings = getRasterLayerWarnings(entity, model, t);
|
||||
warnings = getRasterLayerWarnings(entity, model);
|
||||
} else if (entityType === 'reference_image') {
|
||||
warnings = getGlobalReferenceImageWarnings(entity, model, t);
|
||||
warnings = getGlobalReferenceImageWarnings(entity, model);
|
||||
} else {
|
||||
assert<Equals<typeof entityType, never>>(false, 'Unexpected entity type');
|
||||
}
|
||||
@@ -51,7 +51,7 @@ const buildSelectWarnings = (entityIdentifier: CanvasEntityIdentifier, t: TFunct
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
return warnings.map(upperFirst);
|
||||
return warnings.map((w) => t(w)).map(upperFirst);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -6,52 +6,50 @@ import type {
|
||||
CanvasRegionalGuidanceState,
|
||||
} from 'features/controlLayers/store/types';
|
||||
import type { ParameterModel } from 'features/parameters/types/parameterSchemas';
|
||||
import type { TFunction } from 'i18next';
|
||||
|
||||
export const getRegionalGuidanceWarnings = (
|
||||
entity: CanvasRegionalGuidanceState,
|
||||
model: ParameterModel | null,
|
||||
t: TFunction
|
||||
model: ParameterModel | null
|
||||
): string[] => {
|
||||
const warnings: string[] = [];
|
||||
|
||||
if (entity.objects.length === 0) {
|
||||
// Layer is in empty state - skip other checks
|
||||
warnings.push(t('parameters.invoke.layer.emptyLayer'));
|
||||
warnings.push('parameters.invoke.layer.emptyLayer');
|
||||
} else {
|
||||
if (entity.positivePrompt === null && entity.negativePrompt === null && entity.referenceImages.length === 0) {
|
||||
// Must have at least 1 prompt or IP Adapter
|
||||
warnings.push(t('parameters.invoke.layer.rgNoPromptsOrIPAdapters'));
|
||||
warnings.push('parameters.invoke.layer.rgNoPromptsOrIPAdapters');
|
||||
}
|
||||
|
||||
if (model) {
|
||||
if (model.base === 'sd-3' || model.base === 'sd-2') {
|
||||
// Unsupported model architecture
|
||||
warnings.push(t('controlLayers.invalidBaseModelType'));
|
||||
warnings.push('controlLayers.invalidBaseModelType');
|
||||
} else if (model.base === 'flux') {
|
||||
// Some features are not supported for flux models
|
||||
if (entity.negativePrompt !== null) {
|
||||
warnings.push(t('parameters.invoke.layer.rgNegativePromptNotSupported'));
|
||||
warnings.push('parameters.invoke.layer.rgNegativePromptNotSupported');
|
||||
}
|
||||
if (entity.referenceImages.length > 0) {
|
||||
warnings.push(t('parameters.invoke.layer.rgReferenceImagesNotSupported'));
|
||||
warnings.push('parameters.invoke.layer.rgReferenceImagesNotSupported');
|
||||
}
|
||||
if (entity.autoNegative) {
|
||||
warnings.push(t('parameters.invoke.layer.rgAutoNegativeNotSupported'));
|
||||
warnings.push('parameters.invoke.layer.rgAutoNegativeNotSupported');
|
||||
}
|
||||
} else {
|
||||
entity.referenceImages.forEach(({ ipAdapter }) => {
|
||||
if (!ipAdapter.model) {
|
||||
// No model selected
|
||||
warnings.push(t('parameters.invoke.layer.ipAdapterNoModelSelected'));
|
||||
warnings.push('parameters.invoke.layer.ipAdapterNoModelSelected');
|
||||
} else if (ipAdapter.model.base !== model.base) {
|
||||
// Supported model architecture but doesn't match
|
||||
warnings.push(t('parameters.invoke.layer.ipAdapterIncompatibleBaseModel'));
|
||||
warnings.push('parameters.invoke.layer.ipAdapterIncompatibleBaseModel');
|
||||
}
|
||||
|
||||
if (!ipAdapter.image) {
|
||||
// No image selected
|
||||
warnings.push(t('parameters.invoke.layer.ipAdapterNoImageSelected'));
|
||||
warnings.push('parameters.invoke.layer.ipAdapterNoImageSelected');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -63,53 +61,48 @@ export const getRegionalGuidanceWarnings = (
|
||||
|
||||
export const getGlobalReferenceImageWarnings = (
|
||||
entity: CanvasReferenceImageState,
|
||||
model: ParameterModel | null,
|
||||
t: TFunction
|
||||
model: ParameterModel | null
|
||||
): string[] => {
|
||||
const warnings: string[] = [];
|
||||
|
||||
if (!entity.ipAdapter.model) {
|
||||
// No model selected
|
||||
warnings.push(t('parameters.invoke.layer.ipAdapterNoModelSelected'));
|
||||
warnings.push('parameters.invoke.layer.ipAdapterNoModelSelected');
|
||||
} else if (model) {
|
||||
if (model.base === 'sd-3' || model.base === 'sd-2') {
|
||||
// Unsupported model architecture
|
||||
warnings.push(t('controlLayers.invalidBaseModelType'));
|
||||
warnings.push('controlLayers.invalidBaseModelType');
|
||||
} else if (entity.ipAdapter.model.base !== model.base) {
|
||||
// Supported model architecture but doesn't match
|
||||
warnings.push(t('parameters.invoke.layer.ipAdapterIncompatibleBaseModel'));
|
||||
warnings.push('parameters.invoke.layer.ipAdapterIncompatibleBaseModel');
|
||||
}
|
||||
}
|
||||
|
||||
if (!entity.ipAdapter.image) {
|
||||
// No image selected
|
||||
warnings.push(t('parameters.invoke.layer.ipAdapterNoImageSelected'));
|
||||
warnings.push('parameters.invoke.layer.ipAdapterNoImageSelected');
|
||||
}
|
||||
|
||||
return warnings;
|
||||
};
|
||||
|
||||
export const getControlLayerWarnings = (
|
||||
entity: CanvasControlLayerState,
|
||||
model: ParameterModel | null,
|
||||
t: TFunction
|
||||
): string[] => {
|
||||
export const getControlLayerWarnings = (entity: CanvasControlLayerState, model: ParameterModel | null): string[] => {
|
||||
const warnings: string[] = [];
|
||||
|
||||
if (entity.objects.length === 0) {
|
||||
// Layer is in empty state - skip other checks
|
||||
warnings.push(t('parameters.invoke.layer.emptyLayer'));
|
||||
warnings.push('parameters.invoke.layer.emptyLayer');
|
||||
} else {
|
||||
if (!entity.controlAdapter.model) {
|
||||
// No model selected
|
||||
warnings.push(t('parameters.invoke.layer.controlAdapterNoModelSelected'));
|
||||
warnings.push('parameters.invoke.layer.controlAdapterNoModelSelected');
|
||||
} else if (model) {
|
||||
if (model.base === 'sd-3' || model.base === 'sd-2') {
|
||||
// Unsupported model architecture
|
||||
warnings.push(t('controlLayers.invalidBaseModelType'));
|
||||
warnings.push('controlLayers.invalidBaseModelType');
|
||||
} else if (entity.controlAdapter.model.base !== model.base) {
|
||||
// Supported model architecture but doesn't match
|
||||
warnings.push(t('parameters.invoke.layer.controlAdapterIncompatibleBaseModel'));
|
||||
warnings.push('parameters.invoke.layer.controlAdapterIncompatibleBaseModel');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,31 +110,23 @@ export const getControlLayerWarnings = (
|
||||
return warnings;
|
||||
};
|
||||
|
||||
export const getRasterLayerWarnings = (
|
||||
entity: CanvasRasterLayerState,
|
||||
_model: ParameterModel | null,
|
||||
t: TFunction
|
||||
): string[] => {
|
||||
export const getRasterLayerWarnings = (entity: CanvasRasterLayerState, _model: ParameterModel | null): string[] => {
|
||||
const warnings: string[] = [];
|
||||
|
||||
if (entity.objects.length === 0) {
|
||||
// Layer is in empty state - skip other checks
|
||||
warnings.push(t('parameters.invoke.layer.emptyLayer'));
|
||||
warnings.push('parameters.invoke.layer.emptyLayer');
|
||||
}
|
||||
|
||||
return warnings;
|
||||
};
|
||||
|
||||
export const getInpaintMaskWarnings = (
|
||||
entity: CanvasInpaintMaskState,
|
||||
_model: ParameterModel | null,
|
||||
t: TFunction
|
||||
): string[] => {
|
||||
export const getInpaintMaskWarnings = (entity: CanvasInpaintMaskState, _model: ParameterModel | null): string[] => {
|
||||
const warnings: string[] = [];
|
||||
|
||||
if (entity.objects.length === 0) {
|
||||
// Layer is in empty state - skip other checks
|
||||
warnings.push(t('parameters.invoke.layer.emptyLayer'));
|
||||
warnings.push('parameters.invoke.layer.emptyLayer');
|
||||
}
|
||||
|
||||
return warnings;
|
||||
|
||||
@@ -285,10 +285,10 @@ const getReasonsWhyCannotEnqueueCanvasTab = (arg: {
|
||||
const layerNumber = i + 1;
|
||||
const layerType = i18n.t(LAYER_TYPE_TO_TKEY['control_layer']);
|
||||
const prefix = `${layerLiteral} #${layerNumber} (${layerType})`;
|
||||
const problems = getControlLayerWarnings(controlLayer, model, i18n.t);
|
||||
const problems = getControlLayerWarnings(controlLayer, model);
|
||||
|
||||
if (problems.length) {
|
||||
const content = upperFirst(problems.join(', '));
|
||||
const content = upperFirst(problems.map((p) => i18n.t(p)).join(', '));
|
||||
reasons.push({ prefix, content });
|
||||
}
|
||||
});
|
||||
@@ -300,10 +300,10 @@ const getReasonsWhyCannotEnqueueCanvasTab = (arg: {
|
||||
const layerNumber = i + 1;
|
||||
const layerType = i18n.t(LAYER_TYPE_TO_TKEY[entity.type]);
|
||||
const prefix = `${layerLiteral} #${layerNumber} (${layerType})`;
|
||||
const problems = getGlobalReferenceImageWarnings(entity, model, i18n.t);
|
||||
const problems = getGlobalReferenceImageWarnings(entity, model);
|
||||
|
||||
if (problems.length) {
|
||||
const content = upperFirst(problems.join(', '));
|
||||
const content = upperFirst(problems.map((p) => i18n.t(p)).join(', '));
|
||||
reasons.push({ prefix, content });
|
||||
}
|
||||
});
|
||||
@@ -315,10 +315,10 @@ const getReasonsWhyCannotEnqueueCanvasTab = (arg: {
|
||||
const layerNumber = i + 1;
|
||||
const layerType = i18n.t(LAYER_TYPE_TO_TKEY[entity.type]);
|
||||
const prefix = `${layerLiteral} #${layerNumber} (${layerType})`;
|
||||
const problems = getRegionalGuidanceWarnings(entity, model, i18n.t);
|
||||
const problems = getRegionalGuidanceWarnings(entity, model);
|
||||
|
||||
if (problems.length) {
|
||||
const content = upperFirst(problems.join(', '));
|
||||
const content = upperFirst(problems.map((p) => i18n.t(p)).join(', '));
|
||||
reasons.push({ prefix, content });
|
||||
}
|
||||
});
|
||||
@@ -330,10 +330,10 @@ const getReasonsWhyCannotEnqueueCanvasTab = (arg: {
|
||||
const layerNumber = i + 1;
|
||||
const layerType = i18n.t(LAYER_TYPE_TO_TKEY[entity.type]);
|
||||
const prefix = `${layerLiteral} #${layerNumber} (${layerType})`;
|
||||
const problems = getRasterLayerWarnings(entity, model, i18n.t);
|
||||
const problems = getRasterLayerWarnings(entity, model);
|
||||
|
||||
if (problems.length) {
|
||||
const content = upperFirst(problems.join(', '));
|
||||
const content = upperFirst(problems.map((p) => i18n.t(p)).join(', '));
|
||||
reasons.push({ prefix, content });
|
||||
}
|
||||
});
|
||||
@@ -345,10 +345,10 @@ const getReasonsWhyCannotEnqueueCanvasTab = (arg: {
|
||||
const layerNumber = i + 1;
|
||||
const layerType = i18n.t(LAYER_TYPE_TO_TKEY[entity.type]);
|
||||
const prefix = `${layerLiteral} #${layerNumber} (${layerType})`;
|
||||
const problems = getInpaintMaskWarnings(entity, model, i18n.t);
|
||||
const problems = getInpaintMaskWarnings(entity, model);
|
||||
|
||||
if (problems.length) {
|
||||
const content = upperFirst(problems.join(', '));
|
||||
const content = upperFirst(problems.map((p) => i18n.t(p)).join(', '));
|
||||
reasons.push({ prefix, content });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user