Commit 4f8e5530 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo Committed by Kushal Pandya

Fix filter bar member request for subgroups

For subgroups, we should fetch the group
members of the parent group.
parent 0f68786a
......@@ -9,6 +9,9 @@ export const hasNoAccessError = state => state.errorCode === httpStatus.FORBIDDE
export const currentGroupPath = ({ selectedGroup }) =>
selectedGroup && selectedGroup.fullPath ? selectedGroup.fullPath : null;
export const currentGroupParentPath = ({ selectedGroup }, getters) =>
selectedGroup?.parentId || getters.currentGroupPath;
export const selectedProjectIds = ({ selectedProjects }) =>
selectedProjects.length ? selectedProjects.map(({ id }) => id) : [];
......
......@@ -55,22 +55,22 @@ const fetchUser = ({ commit, endpoint, query, action, errorMessage }) => {
};
export const fetchAuthors = ({ commit, rootGetters }, query = '') => {
const { currentGroupPath } = rootGetters;
const { currentGroupParentPath } = rootGetters;
return fetchUser({
commit,
query,
endpoint: currentGroupPath,
endpoint: currentGroupParentPath,
action: 'AUTHORS',
errorMessage: __('Failed to load authors. Please try again.'),
});
};
export const fetchAssignees = ({ commit, rootGetters }, query = '') => {
const { currentGroupPath } = rootGetters;
const { currentGroupParentPath } = rootGetters;
return fetchUser({
commit,
query,
endpoint: currentGroupPath,
endpoint: currentGroupParentPath,
action: 'ASSIGNEES',
errorMessage: __('Failed to load assignees. Please try again.'),
});
......
......@@ -63,13 +63,49 @@ describe('Cycle analytics getters', () => {
});
describe('without a selectedGroup set', () => {
it.each([[''], [{}], [null]])('given %s will return null', value => {
it.each([[''], [{}], [null]])('given "%s" will return null', value => {
state = { selectedGroup: value };
expect(getters.currentGroupPath(state)).toEqual(null);
});
});
});
describe('currentGroupParentPath', () => {
const fullPath = 'cool-beans';
const parentId = 'subgroup/parent/id';
describe('with a subgroup', () => {
it('returns the parentId value of the sub group', () => {
state = {
selectedGroup: {
fullPath,
parentId,
},
};
expect(getters.currentGroupParentPath(state)).toEqual(parentId);
});
});
describe('with a parent group', () => {
it('returns the fullPath value of the group', () => {
const res = getters.currentGroupParentPath(
{
selectedGroup: {
fullPath,
},
},
{
...getters,
currentGroupPath: fullPath,
},
);
expect(res).toEqual(fullPath);
});
});
});
describe('cycleAnalyticsRequestParams', () => {
const selectedAuthor = 'Gohan';
const selectedMilestone = 'SSJ4';
......
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