summaryrefslogtreecommitdiffstats
path: root/webapp/actions/job_actions.jsx
blob: 75d70faecc9c5bea2a713227331ae1f4dcf73d20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import * as JobsActions from 'mattermost-redux/actions/jobs';

import store from 'stores/redux_store.jsx';
const dispatch = store.dispatch;
const getState = store.getState;

export function createJob(job, success, error) {
    JobsActions.createJob(job)(dispatch, getState).then(
        (data) => {
            if (data && success) {
                success(data);
            } else if (data == null && error) {
                const serverError = getState().requests.jobs.createJob.error;
                error({id: serverError.server_error_id, ...serverError});
            }
        }
    );
}

export function cancelJob(jobId, success, error) {
    JobsActions.cancelJob(jobId)(dispatch, getState).then(
        (data) => {
            if (data && success) {
                success(data);
            } else if (data == null && error) {
                const serverError = getState().requests.jobs.cancelJob.error;
                error({id: serverError.server_error_id, ...serverError});
            }
        }
    );
}