UNPKG

stitch-ui

Version:

81 lines (71 loc) 2.25 kB
import { createAction } from "redux-act"; import { makeAsyncActions, asyncActionExecutor } from "../util"; export const PIPELINE_KEY = "incomingWebhooks"; const NAME = "incomingWebhooks/"; export const setEditing = createAction(`${NAME}set editing`); export const discardChanges = createAction(`${NAME}discard changes`); export const setError = createAction(`${NAME}set error`); export const createIncomingWebhookActions = makeAsyncActions( `${NAME}new incomingWebhook` ); export const loadIncomingWebhooksActions = makeAsyncActions( `${NAME}load incomingWebhooks` ); export const updateIncomingWebhookActions = makeAsyncActions( `${NAME}update incomingWebhook` ); export const removeIncomingWebhookActions = makeAsyncActions( `${NAME}remove incomingWebhook` ); export const setWebhookOptions = createAction(`${NAME}set webhook options`); export const setWebhookName = createAction(`${NAME}set webhook name`); export const setRespondResult = createAction(`${NAME}set respond result`); export const loadIncomingWebhooks = asyncActionExecutor( loadIncomingWebhooksActions, (client, groupId, appId, svcName) => () => client .apps(groupId) .app(appId) .services() .service(svcName) .incomingWebhooks() .list() ); export const createIncomingWebhook = asyncActionExecutor( createIncomingWebhookActions, (client, groupId, appId, svcName, data) => () => client .apps(groupId) .app(appId) .services() .service(svcName) .incomingWebhooks() .create(data), true ); export const updateIncomingWebhook = asyncActionExecutor( updateIncomingWebhookActions, (client, groupId, appId, svcName, incomingWebhookId, data) => () => client .apps(groupId) .app(appId) .services() .service(svcName) .incomingWebhooks() .incomingWebhook(incomingWebhookId) .update(data), true ); export const removeIncomingWebhook = asyncActionExecutor( removeIncomingWebhookActions, (client, groupId, appId, svcName, incomingWebhookId) => () => client .apps(groupId) .app(appId) .services() .service(svcName) .incomingWebhooks() .incomingWebhook(incomingWebhookId) .remove(), true );