mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): add UI-level nodes denylist
This simply hides nodes from the workflow editor. The nodes will still work if an API request is made with them. For example, you could hide `iterate` nodes from the workflow editor, but if the Linear UI makes use of those nodes, they will still function. - Update `AppConfig` with optional property `nodesDenylist: string[]` - If provided, nodes are filtered out by `type` in the workflow editor
This commit is contained in:
parent
dc771d9645
commit
7254a6a517
@ -9,13 +9,16 @@ import { startAppListening } from '..';
|
||||
export const addReceivedOpenAPISchemaListener = () => {
|
||||
startAppListening({
|
||||
actionCreator: receivedOpenAPISchema.fulfilled,
|
||||
effect: (action, { dispatch }) => {
|
||||
effect: (action, { dispatch, getState }) => {
|
||||
const log = logger('system');
|
||||
const schemaJSON = action.payload;
|
||||
|
||||
log.debug({ schemaJSON }, 'Received OpenAPI schema');
|
||||
|
||||
const nodeTemplates = parseSchema(schemaJSON);
|
||||
const nodeTemplates = parseSchema(
|
||||
schemaJSON,
|
||||
getState().config.nodesDenylist
|
||||
);
|
||||
|
||||
log.debug(
|
||||
{ nodeTemplates: parseify(nodeTemplates) },
|
||||
|
@ -50,6 +50,7 @@ export type AppConfig = {
|
||||
disabledFeatures: AppFeature[];
|
||||
disabledSDFeatures: SDFeature[];
|
||||
canRestoreDeletedImagesFromBin: boolean;
|
||||
nodesDenylist: string[];
|
||||
sd: {
|
||||
defaultModel?: string;
|
||||
disabledControlNetModels: string[];
|
||||
|
@ -60,11 +60,15 @@ const isNotInDenylist = (schema: InvocationSchemaObject) =>
|
||||
!invocationDenylist.includes(schema.properties.type.default);
|
||||
|
||||
export const parseSchema = (
|
||||
openAPI: OpenAPIV3.Document
|
||||
openAPI: OpenAPIV3.Document,
|
||||
nodesDenylistExtra: string[] = []
|
||||
): Record<string, InvocationTemplate> => {
|
||||
const filteredSchemas = Object.values(openAPI.components?.schemas ?? {})
|
||||
.filter(isInvocationSchemaObject)
|
||||
.filter(isNotInDenylist);
|
||||
.filter(isNotInDenylist)
|
||||
.filter(
|
||||
(schema) => !nodesDenylistExtra.includes(schema.properties.type.default)
|
||||
);
|
||||
|
||||
const invocations = filteredSchemas.reduce<
|
||||
Record<string, InvocationTemplate>
|
||||
|
@ -15,6 +15,7 @@ export const initialConfigState: AppConfig = {
|
||||
'perlinNoise',
|
||||
'noiseThreshold',
|
||||
],
|
||||
nodesDenylist: [],
|
||||
canRestoreDeletedImagesFromBin: true,
|
||||
sd: {
|
||||
disabledControlNetModels: [],
|
||||
|
Loading…
Reference in New Issue
Block a user