Remove isSaving state property

This removes the isSaving property from the license management store.
This property isn't used anywhere, so it does not make sense to keep
maintaining it and the associated actions and mutations.
parent 4f3534f2
......@@ -96,9 +96,6 @@ export const fetchParsedLicenseReport = ({ dispatch, state }) => {
});
};
export const requestSetLicenseApproval = ({ commit }) => {
commit(types.REQUEST_SET_LICENSE_APPROVAL);
};
export const receiveSetLicenseApproval = ({ commit, dispatch, state }, id) => {
commit(types.RECEIVE_SET_LICENSE_APPROVAL);
// If we have the licenses API endpoint, fetch from there. This corresponds
......@@ -173,7 +170,6 @@ export const setLicenseApproval = ({ dispatch, state }, payload) => {
const { license, newStatus } = payload;
const { id, name } = license;
dispatch('requestSetLicenseApproval');
dispatch('addPendingLicense', id);
let request;
......
......@@ -8,7 +8,6 @@ export const RECEIVE_SET_LICENSE_APPROVAL = 'RECEIVE_SET_LICENSE_APPROVAL';
export const RECEIVE_SET_LICENSE_APPROVAL_ERROR = 'RECEIVE_SET_LICENSE_APPROVAL_ERROR';
export const REQUEST_MANAGED_LICENSES = 'REQUEST_MANAGED_LICENSES';
export const REQUEST_PARSED_LICENSE_REPORT = 'REQUEST_PARSED_LICENSE_REPORT';
export const REQUEST_SET_LICENSE_APPROVAL = 'REQUEST_SET_LICENSE_APPROVAL';
export const RESET_LICENSE_IN_MODAL = 'RESET_LICENSE_IN_MODAL';
export const SET_API_SETTINGS = 'SET_API_SETTINGS';
export const SET_LICENSE_IN_MODAL = 'SET_LICENSE_IN_MODAL';
......
......@@ -77,20 +77,13 @@ export default {
currentLicenseInModal: null,
});
},
[types.REQUEST_SET_LICENSE_APPROVAL](state) {
Object.assign(state, {
isSaving: true,
});
},
[types.RECEIVE_SET_LICENSE_APPROVAL](state) {
Object.assign(state, {
isSaving: false,
currentLicenseInModal: null,
});
},
[types.RECEIVE_SET_LICENSE_APPROVAL_ERROR](state) {
Object.assign(state, {
isSaving: false,
currentLicenseInModal: null,
});
},
......
......@@ -8,7 +8,6 @@ export default () => ({
isLoadingLicenseReport: false,
isLoadingManagedLicenses: false,
pendingLicenses: [],
isSaving: false,
loadLicenseReportError: false,
loadManagedLicensesError: false,
managedLicenses: [],
......
......@@ -177,20 +177,6 @@ describe('License store actions', () => {
});
});
describe('requestSetLicenseApproval', () => {
it('commits REQUEST_SET_LICENSE_APPROVAL', (done) => {
testAction(
actions.requestSetLicenseApproval,
null,
state,
[{ type: mutationTypes.REQUEST_SET_LICENSE_APPROVAL }],
[],
)
.then(done)
.catch(done.fail);
});
});
describe('receiveSetLicenseApproval', () => {
describe('given the licensesApiPath is provided', () => {
it('commits RECEIVE_SET_LICENSE_APPROVAL and dispatches fetchParsedLicenseReport', (done) => {
......@@ -244,7 +230,7 @@ describe('License store actions', () => {
putEndpointMock = axiosMock.onPost(apiUrlManageLicenses);
});
it('dispatches requestSetLicenseApproval, addPendingLicense and receiveSetLicenseApproval for successful response', () => {
it('dispatches addPendingLicense and receiveSetLicenseApproval for successful response', () => {
putEndpointMock.replyOnce((req) => {
const { approval_status, name } = JSON.parse(req.data);
......@@ -255,20 +241,18 @@ describe('License store actions', () => {
});
return actions.setLicenseApproval(store, { license: newLicense, newStatus }).then(() => {
expectDispatched('requestSetLicenseApproval');
expectDispatched('addPendingLicense', undefined);
expectDispatched('receiveSetLicenseApproval', undefined);
});
});
it('dispatches requestSetLicenseApproval, addPendingLicense, receiveSetLicenseApprovalError and removePendingLicense for error response', () => {
it('dispatches addPendingLicense, receiveSetLicenseApprovalError and removePendingLicense for error response', () => {
putEndpointMock.replyOnce((req) => {
expect(req.url).toBe(apiUrlManageLicenses);
return [500, ''];
});
return actions.setLicenseApproval(store, { license: newLicense, newStatus }).then(() => {
expectDispatched('requestSetLicenseApproval');
expectDispatched('addPendingLicense', undefined);
expectDispatched('receiveSetLicenseApprovalError', expect.any(Error));
expectDispatched('removePendingLicense', undefined);
......@@ -285,7 +269,7 @@ describe('License store actions', () => {
patchEndpointMock = axiosMock.onPatch(licenseUrl);
});
it('dispatches requestSetLicenseApproval, addPendingLicense and receiveSetLicenseApproval for successful response', () => {
it('dispatches addPendingLicense and receiveSetLicenseApproval for successful response', () => {
patchEndpointMock.replyOnce((req) => {
expect(req.url).toBe(licenseUrl);
const { approval_status, name } = JSON.parse(req.data);
......@@ -298,13 +282,12 @@ describe('License store actions', () => {
return actions
.setLicenseApproval(store, { license: approvedLicense, newStatus })
.then(() => {
expectDispatched('requestSetLicenseApproval');
expectDispatched('addPendingLicense', approvedLicense.id);
expectDispatched('receiveSetLicenseApproval', approvedLicense.id);
});
});
it('dispatches requestSetLicenseApproval, addPendingLicense, receiveSetLicenseApprovalError and removePendingLicense for error response', () => {
it('dispatches addPendingLicense, receiveSetLicenseApprovalError and removePendingLicense for error response', () => {
patchEndpointMock.replyOnce((req) => {
expect(req.url).toBe(licenseUrl);
return [500, ''];
......@@ -313,7 +296,6 @@ describe('License store actions', () => {
return actions
.setLicenseApproval(store, { license: approvedLicense, newStatus })
.then(() => {
expectDispatched('requestSetLicenseApproval');
expectDispatched('addPendingLicense', approvedLicense.id);
expectDispatched('receiveSetLicenseApprovalError', expect.any(Error));
expectDispatched('removePendingLicense', approvedLicense.id);
......
......@@ -99,52 +99,35 @@ describe('License store mutations', () => {
});
describe('RECEIVE_SET_LICENSE_APPROVAL', () => {
it('sets isSaving to false and closes the modal', () => {
it('closes the modal', () => {
store.replaceState({
...store.state,
licenseManagement: {
isSaving: true,
currentLicenseInModal: approvedLicense,
},
});
store.commit(`licenseManagement/${types.RECEIVE_SET_LICENSE_APPROVAL}`);
expect(store.state.licenseManagement.isSaving).toBe(false);
expect(store.state.licenseManagement.currentLicenseInModal).toBeNull();
});
});
describe('RECEIVE_SET_LICENSE_APPROVAL_ERROR', () => {
it('sets isSaving to false and closes the modal', () => {
it('closes the modal', () => {
store.replaceState({
...store.state,
licenseManagement: {
isSaving: true,
currentLicenseInModal: approvedLicense,
},
});
store.commit(`licenseManagement/${types.RECEIVE_SET_LICENSE_APPROVAL_ERROR}`);
expect(store.state.licenseManagement.isSaving).toBe(false);
expect(store.state.licenseManagement.currentLicenseInModal).toBeNull();
});
});
describe('REQUEST_SET_LICENSE_APPROVAL', () => {
it('sets isSaving to true', () => {
store.replaceState({
...store.state,
licenseManagement: {
isSaving: false,
},
});
store.commit(`licenseManagement/${types.REQUEST_SET_LICENSE_APPROVAL}`);
expect(store.state.licenseManagement.isSaving).toBe(true);
});
});
describe('REQUEST_LICENSE_CHECK_APPROVAL_RULE', () => {
it('sets isLoadingLicenseCheckApprovalRule to true', () => {
store.replaceState({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment