mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): move field output template builder to own file
This commit is contained in:
parent
a703e1b3d3
commit
ad9c954a58
@ -0,0 +1,24 @@
|
|||||||
|
import { startCase } from 'lodash-es';
|
||||||
|
import { FieldOutputTemplate, FieldType } from '../types/field';
|
||||||
|
import { InvocationFieldSchema } from '../types/openapi';
|
||||||
|
|
||||||
|
export const buildFieldOutputTemplate = (
|
||||||
|
fieldSchema: InvocationFieldSchema,
|
||||||
|
fieldName: string,
|
||||||
|
fieldType: FieldType
|
||||||
|
): FieldOutputTemplate => {
|
||||||
|
const { title, description, ui_hidden, ui_type, ui_order } = fieldSchema;
|
||||||
|
|
||||||
|
const fieldOutputTemplate: FieldOutputTemplate = {
|
||||||
|
fieldKind: 'output',
|
||||||
|
name: fieldName,
|
||||||
|
title: title ?? (fieldName ? startCase(fieldName) : ''),
|
||||||
|
description: description ?? '',
|
||||||
|
type: fieldType,
|
||||||
|
ui_hidden,
|
||||||
|
ui_type,
|
||||||
|
ui_order,
|
||||||
|
};
|
||||||
|
|
||||||
|
return fieldOutputTemplate;
|
||||||
|
};
|
@ -1,7 +1,9 @@
|
|||||||
import { logger } from 'app/logging/logger';
|
import { logger } from 'app/logging/logger';
|
||||||
import { parseify } from 'common/util/serialize';
|
import { parseify } from 'common/util/serialize';
|
||||||
import { reduce, startCase } from 'lodash-es';
|
import { t } from 'i18next';
|
||||||
|
import { reduce } from 'lodash-es';
|
||||||
import { OpenAPIV3_1 } from 'openapi-types';
|
import { OpenAPIV3_1 } from 'openapi-types';
|
||||||
|
import { FieldTypeParseError, UnsupportedFieldTypeError } from '../types/error';
|
||||||
import { FieldInputTemplate, FieldOutputTemplate } from '../types/field';
|
import { FieldInputTemplate, FieldOutputTemplate } from '../types/field';
|
||||||
import { InvocationTemplate } from '../types/invocation';
|
import { InvocationTemplate } from '../types/invocation';
|
||||||
import {
|
import {
|
||||||
@ -11,9 +13,8 @@ import {
|
|||||||
isInvocationSchemaObject,
|
isInvocationSchemaObject,
|
||||||
} from '../types/openapi';
|
} from '../types/openapi';
|
||||||
import { buildFieldInputTemplate } from './buildFieldInputTemplate';
|
import { buildFieldInputTemplate } from './buildFieldInputTemplate';
|
||||||
|
import { buildFieldOutputTemplate } from './buildFieldOutputTemplate';
|
||||||
import { parseFieldType } from './parseFieldType';
|
import { parseFieldType } from './parseFieldType';
|
||||||
import { FieldTypeParseError, UnsupportedFieldTypeError } from '../types/error';
|
|
||||||
import { t } from 'i18next';
|
|
||||||
|
|
||||||
const RESERVED_INPUT_FIELD_NAMES = ['id', 'type', 'use_cache'];
|
const RESERVED_INPUT_FIELD_NAMES = ['id', 'type', 'use_cache'];
|
||||||
const RESERVED_OUTPUT_FIELD_NAMES = ['type'];
|
const RESERVED_OUTPUT_FIELD_NAMES = ['type'];
|
||||||
@ -209,17 +210,11 @@ export const parseSchema = (
|
|||||||
return outputsAccumulator;
|
return outputsAccumulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fieldOutputTemplate: FieldOutputTemplate = {
|
const fieldOutputTemplate = buildFieldOutputTemplate(
|
||||||
fieldKind: 'output',
|
property,
|
||||||
name: propertyName,
|
propertyName,
|
||||||
title:
|
fieldType
|
||||||
property.title ?? (propertyName ? startCase(propertyName) : ''),
|
);
|
||||||
description: property.description ?? '',
|
|
||||||
type: fieldType,
|
|
||||||
ui_hidden: property.ui_hidden ?? false,
|
|
||||||
ui_type: property.ui_type,
|
|
||||||
ui_order: property.ui_order,
|
|
||||||
};
|
|
||||||
|
|
||||||
outputsAccumulator[propertyName] = fieldOutputTemplate;
|
outputsAccumulator[propertyName] = fieldOutputTemplate;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user