Browse Source

Adding new API endpoint which provides all definitions in one.

pull/607/head
mike12345567 6 years ago
parent
commit
b1a8837c0c
  1. 10
      packages/builder/src/builderStore/store/workflow/index.js
  2. 8
      packages/server/src/api/controllers/workflow/index.js
  3. 5
      packages/server/src/api/routes/workflow.js

10
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
})

8
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 *

5
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(

Loading…
Cancel
Save