Commit ae5d83de authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '195992-fix-license-compliance-ee' into 'master'

Fix reloading of licenses in project settings

Closes #195992

See merge request gitlab-org/gitlab!24361
parents 84bf6584 cead5255
...@@ -93,9 +93,18 @@ export const receiveLoadLicenseReportError = ({ commit }, error) => { ...@@ -93,9 +93,18 @@ export const receiveLoadLicenseReportError = ({ commit }, error) => {
export const requestSetLicenseApproval = ({ commit }) => { export const requestSetLicenseApproval = ({ commit }) => {
commit(types.REQUEST_SET_LICENSE_APPROVAL); commit(types.REQUEST_SET_LICENSE_APPROVAL);
}; };
export const receiveSetLicenseApproval = ({ commit, dispatch }) => { export const receiveSetLicenseApproval = ({ commit, dispatch, state }) => {
commit(types.RECEIVE_SET_LICENSE_APPROVAL); commit(types.RECEIVE_SET_LICENSE_APPROVAL);
dispatch('loadParsedLicenseReport'); // If we have the licenses API endpoint, fetch from there. This corresponds
// to the cases that we're viewing the merge request or pipeline pages.
// Otherwise, fetch from the managed licenses endpoint, which corresponds to
// the project settings page.
// https://gitlab.com/gitlab-org/gitlab/issues/201867
if (state.licensesApiPath) {
dispatch('loadParsedLicenseReport');
} else {
dispatch('loadManagedLicenses');
}
}; };
export const receiveSetLicenseApprovalError = ({ commit }, error) => { export const receiveSetLicenseApprovalError = ({ commit }, error) => {
commit(types.RECEIVE_SET_LICENSE_APPROVAL_ERROR, error); commit(types.RECEIVE_SET_LICENSE_APPROVAL_ERROR, error);
......
...@@ -10,6 +10,7 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -10,6 +10,7 @@ import axios from '~/lib/utils/axios_utils';
describe('License store actions', () => { describe('License store actions', () => {
const apiUrlManageLicenses = `${TEST_HOST}/licenses/management`; const apiUrlManageLicenses = `${TEST_HOST}/licenses/management`;
const licensesApiPath = `${TEST_HOST}/licensesApiPath`;
let axiosMock; let axiosMock;
let licenseId; let licenseId;
...@@ -177,16 +178,32 @@ describe('License store actions', () => { ...@@ -177,16 +178,32 @@ describe('License store actions', () => {
}); });
describe('receiveSetLicenseApproval', () => { describe('receiveSetLicenseApproval', () => {
it('commits RECEIVE_SET_LICENSE_APPROVAL and dispatches loadParsedLicenseReport', done => { describe('given the licensesApiPath is provided', () => {
testAction( it('commits RECEIVE_SET_LICENSE_APPROVAL and dispatches loadParsedLicenseReport', done => {
actions.receiveSetLicenseApproval, testAction(
null, actions.receiveSetLicenseApproval,
state, null,
[{ type: mutationTypes.RECEIVE_SET_LICENSE_APPROVAL }], { ...state, licensesApiPath },
[{ type: 'loadParsedLicenseReport' }], [{ type: mutationTypes.RECEIVE_SET_LICENSE_APPROVAL }],
) [{ type: 'loadParsedLicenseReport' }],
.then(done) )
.catch(done.fail); .then(done)
.catch(done.fail);
});
});
describe('given the licensesApiPath is not provided', () => {
it('commits RECEIVE_SET_LICENSE_APPROVAL and dispatches loadManagedLicenses', done => {
testAction(
actions.receiveSetLicenseApproval,
null,
state,
[{ type: mutationTypes.RECEIVE_SET_LICENSE_APPROVAL }],
[{ type: 'loadManagedLicenses' }],
)
.then(done)
.catch(done.fail);
});
}); });
}); });
...@@ -533,7 +550,6 @@ describe('License store actions', () => { ...@@ -533,7 +550,6 @@ describe('License store actions', () => {
}); });
describe('loadParsedLicenseReport', () => { describe('loadParsedLicenseReport', () => {
const licensesApiPath = `${TEST_HOST}/licensesApiPath`;
let licensesApiMock; let licensesApiMock;
let rawLicenseReport; let rawLicenseReport;
......
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