From 2911a7ba350867594853c3380c4231eadada1308 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 17 Sep 2020 12:44:59 +0100 Subject: [PATCH] Changing how default inputs for workflow definitions are handled and providing pretty print options for enums. --- packages/server/src/utilities/accessLevels.js | 6 ++++++ .../server/src/workflows/steps/createUser.js | 6 ++++-- packages/server/src/workflows/steps/filter.js | 21 +++++++++++++------ .../server/src/workflows/steps/saveRecord.js | 1 - 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/packages/server/src/utilities/accessLevels.js b/packages/server/src/utilities/accessLevels.js index 8e318d03d3..3170afc461 100644 --- a/packages/server/src/utilities/accessLevels.js +++ b/packages/server/src/utilities/accessLevels.js @@ -17,6 +17,12 @@ module.exports.ACCESS_LEVELS = [ module.exports.BUILDER_LEVEL_ID, module.exports.ANON_LEVEL_ID, ] +module.exports.PRETTY_ACCESS_LEVELS = { + [module.exports.ADMIN_LEVEL_ID]: "Admin", + [module.exports.POWERUSER_LEVEL_ID]: "Power user", + [module.exports.BUILDER_LEVEL_ID]: "Builder", + [module.exports.ANON_LEVEL_ID]: "Anonymous", +} module.exports.adminPermissions = [ { name: module.exports.USER_MANAGEMENT, diff --git a/packages/server/src/workflows/steps/createUser.js b/packages/server/src/workflows/steps/createUser.js index 454e1ae2bb..fe5267c963 100644 --- a/packages/server/src/workflows/steps/createUser.js +++ b/packages/server/src/workflows/steps/createUser.js @@ -8,7 +8,9 @@ module.exports.definition = { name: "Create User", type: "ACTION", stepId: "CREATE_USER", - inputs: {}, + inputs: { + accessLevelId: accessLevels.POWERUSER_LEVEL_ID, + }, schema: { inputs: { properties: { @@ -24,8 +26,8 @@ module.exports.definition = { accessLevelId: { type: "string", title: "Access Level", - default: accessLevels.POWERUSER_LEVEL_ID, enum: accessLevels.ACCESS_LEVELS, + pretty: Object.values(accessLevels.PRETTY_ACCESS_LEVELS), }, }, required: ["username", "password", "accessLevelId"], diff --git a/packages/server/src/workflows/steps/filter.js b/packages/server/src/workflows/steps/filter.js index b5c353a5ad..8fb1603b99 100644 --- a/packages/server/src/workflows/steps/filter.js +++ b/packages/server/src/workflows/steps/filter.js @@ -1,8 +1,15 @@ const LogicConditions = { - EQUALS: "Equals", - NOT_EQUALS: "Not equals", - GREATER_THAN: "Greater than", - LESS_THAN: "Less than", + EQUAL: "EQUAL", + NOT_EQUAL: "NOT_EQUAL", + GREATER_THAN: "GREATER_THAN", + LESS_THAN: "LESS_THAN", +} + +const PrettyLogicConditions = { + [LogicConditions.EQUAL]: "Equals", + [LogicConditions.NOT_EQUAL]: "Not equals", + [LogicConditions.GREATER_THAN]: "Greater than", + [LogicConditions.LESS_THAN]: "Less than", } module.exports.definition = { @@ -12,7 +19,9 @@ module.exports.definition = { description: "Filter any workflows which do not meet certain conditions", type: "LOGIC", stepId: "FILTER", - inputs: {}, + inputs: { + condition: LogicConditions.EQUALS, + }, schema: { inputs: { properties: { @@ -24,7 +33,7 @@ module.exports.definition = { type: "string", title: "Condition", enum: Object.values(LogicConditions), - default: "equals", + pretty: Object.values(PrettyLogicConditions), }, value: { type: "string", diff --git a/packages/server/src/workflows/steps/saveRecord.js b/packages/server/src/workflows/steps/saveRecord.js index 1befe182f9..4c955a5923 100644 --- a/packages/server/src/workflows/steps/saveRecord.js +++ b/packages/server/src/workflows/steps/saveRecord.js @@ -22,7 +22,6 @@ module.exports.definition = { }, customType: "record", title: "The record to be written", - default: {}, required: ["modelId"], }, },