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