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