зеркало из https://github.com/mozilla/normandy.git
Approval request actions
This commit is contained in:
Родитель
ff2b092023
Коммит
bbf69f425b
|
@ -1,6 +1,7 @@
|
|||
/* Keep this list alphabetized */
|
||||
|
||||
export const ACTION_RECEIVE = 'ACTION_RECEIVE';
|
||||
export const APPROVAL_REQUEST_DELETE = 'APPROVAL_REQUEST_DELETE';
|
||||
export const APPROVAL_REQUEST_RECEIVE = 'APPROVAL_REQUEST_RECEIVE';
|
||||
export const RECIPE_DELETE = 'RECIPE_DELETE';
|
||||
export const RECIPE_RECEIVE = 'RECIPE_RECEIVE';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {
|
||||
APPROVAL_REQUEST_DELETE,
|
||||
APPROVAL_REQUEST_RECEIVE,
|
||||
} from '../action-types';
|
||||
|
||||
|
@ -34,3 +35,51 @@ export function fetchAllApprovalRequests() {
|
|||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export function approveApprovalRequest(pk) {
|
||||
return async dispatch => {
|
||||
const requestId = `approve-approval-request-${pk}`;
|
||||
const approvalRequest = await dispatch(
|
||||
makeApiRequest(requestId, `v2/approval_request/${pk}/approve/`, {
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
dispatch({
|
||||
type: APPROVAL_REQUEST_RECEIVE,
|
||||
approvalRequest,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export function rejectApprovalRequest(pk) {
|
||||
return async dispatch => {
|
||||
const requestId = `reject-approval-request-${pk}`;
|
||||
const approvalRequest = await dispatch(
|
||||
makeApiRequest(requestId, `v2/approval_request/${pk}/reject/`, {
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
dispatch({
|
||||
type: APPROVAL_REQUEST_RECEIVE,
|
||||
approvalRequest,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export function closeApprovalRequest(pk) {
|
||||
return async dispatch => {
|
||||
const requestId = `close-approval-request-${pk}`;
|
||||
|
||||
await dispatch(makeApiRequest(requestId, `v2/approval_request/${pk}/close/`, {
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
dispatch({
|
||||
type: APPROVAL_REQUEST_DELETE,
|
||||
approvalRequestId: pk,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { fromJS, Map } from 'immutable';
|
|||
import { combineReducers } from 'redux';
|
||||
|
||||
import {
|
||||
APPROVAL_REQUEST_DELETE,
|
||||
APPROVAL_REQUEST_RECEIVE,
|
||||
} from '../action-types';
|
||||
|
||||
|
@ -11,6 +12,9 @@ function items(state = new Map(), action) {
|
|||
case APPROVAL_REQUEST_RECEIVE:
|
||||
return state.set(action.approvalRequest.id, fromJS(action.approvalRequest));
|
||||
|
||||
case APPROVAL_REQUEST_DELETE:
|
||||
return state.remove(action.approvalRequestId);
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {
|
||||
ACTION_RECEIVE,
|
||||
APPROVAL_REQUEST_RECEIVE,
|
||||
REVISION_RECEIVE,
|
||||
} from '../action-types';
|
||||
|
||||
|
@ -42,3 +43,17 @@ export function fetchAllRevisions() {
|
|||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export function requestRevisionApproval(pk) {
|
||||
return async dispatch => {
|
||||
const requestId = `request-revision-approval-${pk}`;
|
||||
const approvalRequest = await dispatch(
|
||||
makeApiRequest(requestId, `v2/recipe_revision/${pk}/request_approval/`));
|
||||
|
||||
dispatch({
|
||||
type: APPROVAL_REQUEST_RECEIVE,
|
||||
approvalRequest,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче