From 09565e41d039197620f83c2a3828b4dcc526ab54 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 14 Sep 2020 15:34:09 +0100 Subject: [PATCH] Adding new API endpoint which provides all definitions in one. --- .../builder/src/builderStore/store/workflow/index.js | 10 ++++------ packages/server/src/api/controllers/workflow/index.js | 8 ++++++++ packages/server/src/api/routes/workflow.js | 5 +++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/builderStore/store/workflow/index.js b/packages/builder/src/builderStore/store/workflow/index.js index de312e507b..054170bfce 100644 --- a/packages/builder/src/builderStore/store/workflow/index.js +++ b/packages/builder/src/builderStore/store/workflow/index.js @@ -7,17 +7,15 @@ const workflowActions = store => ({ fetch: async () => { const responses = await Promise.all([ api.get(`/api/workflows`), - api.get(`/api/workflows/trigger/list`), - api.get(`/api/workflows/action/list`), - api.get(`/api/workflows/logic/list`), + api.get(`/api/workflows/definition/list`), ]) const jsonResponses = await Promise.all(responses.map(x => x.json())) store.update(state => { state.workflows = jsonResponses[0] state.blockDefinitions = { - TRIGGER: jsonResponses[1], - ACTION: jsonResponses[2], - LOGIC: jsonResponses[3], + TRIGGER: jsonResponses[1].trigger, + ACTION: jsonResponses[1].action, + LOGIC: jsonResponses[1].logic, } return state }) diff --git a/packages/server/src/api/controllers/workflow/index.js b/packages/server/src/api/controllers/workflow/index.js index 5a3020879a..efb93ad1c1 100644 --- a/packages/server/src/api/controllers/workflow/index.js +++ b/packages/server/src/api/controllers/workflow/index.js @@ -78,6 +78,14 @@ exports.getLogicList = async function(ctx) { ctx.body = blockDefinitions.LOGIC } +module.exports.getDefinitionList = async function(ctx) { + ctx.body = { + logic: blockDefinitions.LOGIC, + trigger: blockDefinitions.TRIGGER, + action: blockDefinitions.ACTION, + } +} + /********************* * * * API FUNCTIONS * diff --git a/packages/server/src/api/routes/workflow.js b/packages/server/src/api/routes/workflow.js index cc4a7610e3..e6a61ae5f5 100644 --- a/packages/server/src/api/routes/workflow.js +++ b/packages/server/src/api/routes/workflow.js @@ -52,6 +52,11 @@ router authorized(BUILDER), controller.getLogicList ) + .get( + "/api/workflows/definitions/list", + authorized(BUILDER), + controller.getDefinitionList + ) .get("/api/workflows", authorized(BUILDER), controller.fetch) .get("/api/workflows/:id", authorized(BUILDER), controller.find) .put(