aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/ducks/flows.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/js/ducks/flows.js')
-rw-r--r--web/src/js/ducks/flows.js37
1 files changed, 19 insertions, 18 deletions
diff --git a/web/src/js/ducks/flows.js b/web/src/js/ducks/flows.js
index dfcd5ba9..f18e48e6 100644
--- a/web/src/js/ducks/flows.js
+++ b/web/src/js/ducks/flows.js
@@ -16,6 +16,7 @@ export const UNKNOWN_CMD = 'FLOWS_UNKNOWN_CMD'
export const FETCH_ERROR = 'FLOWS_FETCH_ERROR'
export const SELECT = 'FLOWS_SELECT'
+
const defaultState = {
selected: [],
...reduceList(undefined, {}),
@@ -66,64 +67,65 @@ export default function reduce(state = defaultState, action) {
* @public
*/
export function accept(flow) {
- fetchApi(`/flows/${flow.id}/accept`, { method: 'POST' })
- return { type: REQUEST_ACTION }
+ return dispatch => fetchApi(`/flows/${flow.id}/accept`, { method: 'POST' })
}
/**
* @public
*/
export function acceptAll() {
- fetchApi('/flows/accept', { method: 'POST' })
- return { type: REQUEST_ACTION }
+ return dispatch => fetchApi('/flows/accept', { method: 'POST' })
}
/**
* @public
*/
export function remove(flow) {
- fetchApi(`/flows/${flow.id}`, { method: 'DELETE' })
- return { type: REQUEST_ACTION }
+ return dispatch => fetchApi(`/flows/${flow.id}`, { method: 'DELETE' })
}
/**
* @public
*/
export function duplicate(flow) {
- fetchApi(`/flows/${flow.id}/duplicate`, { method: 'POST' })
- return { type: REQUEST_ACTION }
+ return dispatch => fetchApi(`/flows/${flow.id}/duplicate`, { method: 'POST' })
}
/**
* @public
*/
export function replay(flow) {
- fetchApi(`/flows/${flow.id}/replay`, { method: 'POST' })
- return { type: REQUEST_ACTION }
+ return dispatch => fetchApi(`/flows/${flow.id}/replay`, { method: 'POST' })
}
/**
* @public
*/
export function revert(flow) {
- fetchApi(`/flows/${flow.id}/revert`, { method: 'POST' })
- return { type: REQUEST_ACTION }
+ return dispatch => fetchApi(`/flows/${flow.id}/revert`, { method: 'POST' })
}
/**
* @public
*/
export function update(flow, data) {
- fetchApi.put(`/flows/${flow.id}`, data)
- return { type: REQUEST_ACTION }
+ return dispatch => fetchApi.put(`/flows/${flow.id}`, data)
}
+export function updateContent(flow, file, type) {
+ const body = new FormData()
+ if (typeof file !== File)
+ file = new Blob([file], {type: 'plain/text'})
+ body.append('file', file)
+ return dispatch => fetchApi(`/flows/${flow.id}/${type}/content`, {method: 'post', body} )
+}
+
+
/**
* @public
*/
export function clear() {
- fetchApi('/clear', { method: 'POST' })
- return { type: REQUEST_ACTION }
+ return dispatch => fetchApi('/clear', { method: 'POST' })
}
/**
@@ -140,8 +142,7 @@ export function download() {
export function upload(file) {
const body = new FormData()
body.append('file', file)
- fetchApi('/flows/dump', { method: 'post', body })
- return { type: REQUEST_ACTION }
+ return dispatch => fetchApi('/flows/dump', { method: 'post', body })
}