Remove isDeleting state property

This removes the isDeleting 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 8e1fbdf4
...@@ -25,9 +25,6 @@ export const resetLicenseInModal = ({ commit }) => { ...@@ -25,9 +25,6 @@ export const resetLicenseInModal = ({ commit }) => {
commit(types.RESET_LICENSE_IN_MODAL); commit(types.RESET_LICENSE_IN_MODAL);
}; };
export const requestDeleteLicense = ({ commit }) => {
commit(types.REQUEST_DELETE_LICENSE);
};
export const receiveDeleteLicense = ({ commit, dispatch }, id) => { export const receiveDeleteLicense = ({ commit, dispatch }, id) => {
commit(types.RECEIVE_DELETE_LICENSE); commit(types.RECEIVE_DELETE_LICENSE);
return dispatch('fetchManagedLicenses').then(() => { return dispatch('fetchManagedLicenses').then(() => {
...@@ -39,7 +36,6 @@ export const receiveDeleteLicenseError = ({ commit }, error) => { ...@@ -39,7 +36,6 @@ export const receiveDeleteLicenseError = ({ commit }, error) => {
}; };
export const deleteLicense = ({ dispatch, state }) => { export const deleteLicense = ({ dispatch, state }) => {
const licenseId = state.currentLicenseInModal.id; const licenseId = state.currentLicenseInModal.id;
dispatch('requestDeleteLicense');
dispatch('addPendingLicense', licenseId); dispatch('addPendingLicense', licenseId);
const endpoint = `${state.apiUrlManageLicenses}/${licenseId}`; const endpoint = `${state.apiUrlManageLicenses}/${licenseId}`;
return axios return axios
......
...@@ -6,7 +6,6 @@ export const RECEIVE_PARSED_LICENSE_REPORT_SUCCESS = 'RECEIVE_PARSED_LICENSE_REP ...@@ -6,7 +6,6 @@ export const RECEIVE_PARSED_LICENSE_REPORT_SUCCESS = 'RECEIVE_PARSED_LICENSE_REP
export const RECEIVE_PARSED_LICENSE_REPORT_ERROR = 'RECEIVE_PARSED_LICENSE_REPORT_ERROR'; export const RECEIVE_PARSED_LICENSE_REPORT_ERROR = 'RECEIVE_PARSED_LICENSE_REPORT_ERROR';
export const RECEIVE_SET_LICENSE_APPROVAL = 'RECEIVE_SET_LICENSE_APPROVAL'; export const RECEIVE_SET_LICENSE_APPROVAL = 'RECEIVE_SET_LICENSE_APPROVAL';
export const RECEIVE_SET_LICENSE_APPROVAL_ERROR = 'RECEIVE_SET_LICENSE_APPROVAL_ERROR'; export const RECEIVE_SET_LICENSE_APPROVAL_ERROR = 'RECEIVE_SET_LICENSE_APPROVAL_ERROR';
export const REQUEST_DELETE_LICENSE = 'REQUEST_DELETE_LICENSE';
export const REQUEST_MANAGED_LICENSES = 'REQUEST_MANAGED_LICENSES'; export const REQUEST_MANAGED_LICENSES = 'REQUEST_MANAGED_LICENSES';
export const REQUEST_PARSED_LICENSE_REPORT = 'REQUEST_PARSED_LICENSE_REPORT'; export const REQUEST_PARSED_LICENSE_REPORT = 'REQUEST_PARSED_LICENSE_REPORT';
export const REQUEST_SET_LICENSE_APPROVAL = 'REQUEST_SET_LICENSE_APPROVAL'; export const REQUEST_SET_LICENSE_APPROVAL = 'REQUEST_SET_LICENSE_APPROVAL';
......
...@@ -69,21 +69,14 @@ export default { ...@@ -69,21 +69,14 @@ export default {
[types.RECEIVE_DELETE_LICENSE](state) { [types.RECEIVE_DELETE_LICENSE](state) {
Object.assign(state, { Object.assign(state, {
isDeleting: false,
currentLicenseInModal: null, currentLicenseInModal: null,
}); });
}, },
[types.RECEIVE_DELETE_LICENSE_ERROR](state) { [types.RECEIVE_DELETE_LICENSE_ERROR](state) {
Object.assign(state, { Object.assign(state, {
isDeleting: false,
currentLicenseInModal: null, currentLicenseInModal: null,
}); });
}, },
[types.REQUEST_DELETE_LICENSE](state) {
Object.assign(state, {
isDeleting: true,
});
},
[types.REQUEST_SET_LICENSE_APPROVAL](state) { [types.REQUEST_SET_LICENSE_APPROVAL](state) {
Object.assign(state, { Object.assign(state, {
isSaving: true, isSaving: true,
......
...@@ -5,7 +5,6 @@ export default () => ({ ...@@ -5,7 +5,6 @@ export default () => ({
canManageLicenses: false, canManageLicenses: false,
currentLicenseInModal: null, currentLicenseInModal: null,
isAdmin: false, isAdmin: false,
isDeleting: false,
isLoadingLicenseReport: false, isLoadingLicenseReport: false,
isLoadingManagedLicenses: false, isLoadingManagedLicenses: false,
pendingLicenses: [], pendingLicenses: [],
......
...@@ -117,20 +117,6 @@ describe('License store actions', () => { ...@@ -117,20 +117,6 @@ describe('License store actions', () => {
}); });
}); });
describe('requestDeleteLicense', () => {
it('commits REQUEST_DELETE_LICENSE', (done) => {
testAction(
actions.requestDeleteLicense,
null,
state,
[{ type: mutationTypes.REQUEST_DELETE_LICENSE }],
[],
)
.then(done)
.catch(done.fail);
});
});
describe('receiveDeleteLicense', () => { describe('receiveDeleteLicense', () => {
it('commits RECEIVE_DELETE_LICENSE and dispatches fetchManagedLicenses and removePendingLicense', () => { it('commits RECEIVE_DELETE_LICENSE and dispatches fetchManagedLicenses and removePendingLicense', () => {
return actions.receiveDeleteLicense(store, licenseId).then(() => { return actions.receiveDeleteLicense(store, licenseId).then(() => {
...@@ -165,27 +151,25 @@ describe('License store actions', () => { ...@@ -165,27 +151,25 @@ describe('License store actions', () => {
endpointMock = axiosMock.onDelete(deleteUrl); endpointMock = axiosMock.onDelete(deleteUrl);
}); });
it('dispatches requestDeleteLicense, addPendingLicense and receiveDeleteLicense for successful response', () => { it('dispatches addPendingLicense and receiveDeleteLicense for successful response', () => {
endpointMock.replyOnce((req) => { endpointMock.replyOnce((req) => {
expect(req.url).toBe(deleteUrl); expect(req.url).toBe(deleteUrl);
return [200, '']; return [200, ''];
}); });
return actions.deleteLicense(store).then(() => { return actions.deleteLicense(store).then(() => {
expectDispatched('requestDeleteLicense');
expectDispatched('addPendingLicense', licenseId); expectDispatched('addPendingLicense', licenseId);
expectDispatched('receiveDeleteLicense', licenseId); expectDispatched('receiveDeleteLicense', licenseId);
}); });
}); });
it('dispatches requestDeleteLicense, addPendingLicense, receiveDeleteLicenseError and removePendingLicense for error response', () => { it('dispatches addPendingLicense, receiveDeleteLicenseError and removePendingLicense for error response', () => {
endpointMock.replyOnce((req) => { endpointMock.replyOnce((req) => {
expect(req.url).toBe(deleteUrl); expect(req.url).toBe(deleteUrl);
return [500, '']; return [500, ''];
}); });
return actions.deleteLicense(store).then(() => { return actions.deleteLicense(store).then(() => {
expectDispatched('requestDeleteLicense');
expectDispatched('addPendingLicense', licenseId); expectDispatched('addPendingLicense', licenseId);
expectDispatched('receiveDeleteLicenseError', expect.any(Error)); expectDispatched('receiveDeleteLicenseError', expect.any(Error));
expectDispatched('removePendingLicense', licenseId); expectDispatched('removePendingLicense', licenseId);
......
...@@ -69,52 +69,35 @@ describe('License store mutations', () => { ...@@ -69,52 +69,35 @@ describe('License store mutations', () => {
}); });
describe('RECEIVE_DELETE_LICENSE', () => { describe('RECEIVE_DELETE_LICENSE', () => {
it('sets isDeleting to false and closes the modal', () => { it('closes the modal', () => {
store.replaceState({ store.replaceState({
...store.state, ...store.state,
licenseManagement: { licenseManagement: {
isDeleting: true, currentLicenseInModal: approvedLicense,
}, },
}); });
store.commit(`licenseManagement/${types.RECEIVE_DELETE_LICENSE}`); store.commit(`licenseManagement/${types.RECEIVE_DELETE_LICENSE}`);
expect(store.state.licenseManagement.isDeleting).toBe(false); expect(store.state.licenseManagement.currentLicenseInModal).toBeNull();
}); });
}); });
describe('RECEIVE_DELETE_LICENSE_ERROR', () => { describe('RECEIVE_DELETE_LICENSE_ERROR', () => {
it('sets isDeleting to false and closes the modal', () => { it('closes the modal', () => {
store.replaceState({ store.replaceState({
...store.state, ...store.state,
licenseManagement: { licenseManagement: {
isDeleting: true,
currentLicenseInModal: approvedLicense, currentLicenseInModal: approvedLicense,
}, },
}); });
store.commit(`licenseManagement/${types.RECEIVE_DELETE_LICENSE_ERROR}`); store.commit(`licenseManagement/${types.RECEIVE_DELETE_LICENSE_ERROR}`);
expect(store.state.licenseManagement.isDeleting).toBe(false);
expect(store.state.licenseManagement.currentLicenseInModal).toBeNull(); expect(store.state.licenseManagement.currentLicenseInModal).toBeNull();
}); });
}); });
describe('REQUEST_DELETE_LICENSE', () => {
it('sets isDeleting to true', () => {
store.replaceState({
...store.state,
licenseManagement: {
isDeleting: false,
},
});
store.commit(`licenseManagement/${types.REQUEST_DELETE_LICENSE}`);
expect(store.state.licenseManagement.isDeleting).toBe(true);
});
});
describe('RECEIVE_SET_LICENSE_APPROVAL', () => { describe('RECEIVE_SET_LICENSE_APPROVAL', () => {
it('sets isSaving to false and closes the modal', () => { it('sets isSaving to false and closes the modal', () => {
store.replaceState({ 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