Commit 6611fc4c authored by Adam Hegyi's avatar Adam Hegyi Committed by Filipa Lacerda

Use the project full path with namespace in PA

In productivity analytics the backend expects the full path to the
project namespace to find the DB record. This change ensures that
the full path to the project is sent via the frontend.
parent 4b7a6d82
......@@ -30,10 +30,15 @@ export default {
this.setGroupNamespace(full_path);
this.$emit('groupSelected', full_path);
},
onProjectsSelected([selectedProject]) {
const { path } = selectedProject;
this.setProjectPath(path);
this.$emit('projectSelected', { namespacePath: this.groupNamespace, project: path });
onProjectsSelected(selectedProjects) {
const pathWithNamespace = selectedProjects.length
? selectedProjects[0].path_with_namespace
: null;
this.setProjectPath(pathWithNamespace);
this.$emit('projectSelected', {
namespacePath: this.groupNamespace,
project: pathWithNamespace,
});
},
},
};
......
......@@ -7,7 +7,7 @@ import { urlParamsToObject } from '~/lib/utils/common_utils';
*
* {
* group_id: 'gitlab-org',
* project_id: 'gitlab-test',
* project_id: 'gitlab-org/gitlab-test',
* author_username: 'author',
* milestone_title: 'my milestone',
* label_name: ['my label', 'yet another label'],
......
......@@ -18,7 +18,7 @@ describe('FilterDropdowns component', () => {
};
const groupNamespace = 'gitlab-org';
const projectPath = 'gitlab-test';
const projectPath = 'gitlab-org/gitlab-test';
beforeEach(() => {
wrapper = shallowMount(localVue.extend(FilterDropdowns), {
......@@ -80,9 +80,10 @@ describe('FilterDropdowns component', () => {
});
describe('onProjectsSelected', () => {
describe('when the list of selected projects is not empty', () => {
beforeEach(() => {
store.state.filters.groupNamespace = groupNamespace;
wrapper.vm.onProjectsSelected([{ id: 1, path: `${projectPath}` }]);
wrapper.vm.onProjectsSelected([{ id: 1, path_with_namespace: `${projectPath}` }]);
});
it('invokes setProjectPath action', () => {
......@@ -96,5 +97,24 @@ describe('FilterDropdowns component', () => {
});
});
});
describe('when the list of selected projects is empty', () => {
beforeEach(() => {
store.state.filters.groupNamespace = groupNamespace;
wrapper.vm.onProjectsSelected([]);
});
it('invokes setProjectPath action with null', () => {
expect(actionSpies.setProjectPath).toHaveBeenCalledWith(null);
});
it('emits the "projectSelected" event', () => {
expect(wrapper.emitted().projectSelected[0][0]).toEqual({
namespacePath: groupNamespace,
project: null,
});
});
});
});
});
});
......@@ -16,7 +16,7 @@ describe('Productivity analytics chart actions', () => {
const chartKey = 'main';
const globalParams = {
group_id: 'gitlab-org',
project_id: 'gitlab-test',
project_id: 'gitlab-org/gitlab-test',
};
beforeEach(() => {
......
......@@ -11,7 +11,7 @@ describe('Productivity analytics chart getters', () => {
let state;
const groupNamespace = 'gitlab-org';
const projectPath = 'gitlab-test';
const projectPath = 'gitlab-org/gitlab-test';
beforeEach(() => {
state = createState();
......
......@@ -5,7 +5,7 @@ import getInitialState from 'ee/analytics/productivity_analytics/store/modules/f
describe('Productivity analytics filter actions', () => {
const groupNamespace = 'gitlab-org';
const projectPath = 'gitlab-test';
const projectPath = 'gitlab-org/gitlab-test';
describe('setGroupNamespace', () => {
it('commits the SET_GROUP_NAMESPACE mutation', done => {
......
......@@ -12,7 +12,7 @@ describe('Productivity analytics filter getters', () => {
it('returns an object with group_id, project_id and all relevant params from the filters string', () => {
state = {
groupNamespace: 'gitlab-org',
projectPath: 'gitlab-test',
projectPath: 'gitlab-org/gitlab-test',
filters: '?author_username=root&milestone_title=foo&label_name[]=labelxyz',
};
......@@ -23,7 +23,7 @@ describe('Productivity analytics filter getters', () => {
label_name: ['labelxyz'],
merged_at_after: '2019-07-16T00:00:00.00Z',
milestone_title: 'foo',
project_id: 'gitlab-test',
project_id: 'gitlab-org/gitlab-test',
};
const result = getters.getCommonFilterParams(state, mockGetters);
......
......@@ -20,7 +20,7 @@ describe('Productivity analytics filter mutations', () => {
describe(types.SET_PROJECT_PATH, () => {
it('sets the projectPath', () => {
const projectPath = 'gitlab-test';
const projectPath = 'gitlab-org/gitlab-test';
mutations[types.SET_PROJECT_PATH](state, projectPath);
expect(state.projectPath).toBe(projectPath);
......
......@@ -13,7 +13,7 @@ describe('Productivity analytics table actions', () => {
let mock;
const groupNamespace = 'gitlab-org';
const projectPath = 'gitlab-test';
const projectPath = 'gitlab-org/gitlab-test';
const filterParams = {
days_to_merge: [5],
......
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