Commit ac02e8df authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch...

Merge branch '273130-remove-getx-prefix-from-vuex-getter-name-in-boards-sidebar-store' into 'master'

Remove get- prefix from swimlanes boards vuex getters

See merge request gitlab-org/gitlab!46939
parents 0c623f32 90e3ea30
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
data() { data() {
return { return {
participants: [], participants: [],
selected: this.$store.getters.getActiveIssue.assignees, selected: this.$store.getters.activeIssue.assignees,
}; };
}, },
apollo: { apollo: {
...@@ -34,7 +34,7 @@ export default { ...@@ -34,7 +34,7 @@ export default {
query: getIssueParticipants, query: getIssueParticipants,
variables() { variables() {
return { return {
id: `gid://gitlab/Issue/${this.getActiveIssue.iid}`, id: `gid://gitlab/Issue/${this.activeIssue.iid}`,
}; };
}, },
update(data) { update(data) {
...@@ -43,7 +43,7 @@ export default { ...@@ -43,7 +43,7 @@ export default {
}, },
}, },
computed: { computed: {
...mapGetters(['getActiveIssue']), ...mapGetters(['activeIssue']),
assigneeText() { assigneeText() {
return n__('Assignee', '%d Assignees', this.selected.length); return n__('Assignee', '%d Assignees', this.selected.length);
}, },
...@@ -88,7 +88,7 @@ export default { ...@@ -88,7 +88,7 @@ export default {
<template> <template>
<board-editable-item :title="assigneeText" @close="saveAssignees"> <board-editable-item :title="assigneeText" @close="saveAssignees">
<template #collapsed> <template #collapsed>
<issuable-assignees :users="getActiveIssue.assignees" /> <issuable-assignees :users="activeIssue.assignees" />
</template> </template>
<template #default> <template #default>
......
...@@ -46,7 +46,7 @@ export default { ...@@ -46,7 +46,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapGetters(['getIssues']), ...mapGetters(['getIssuesByList']),
showBoardListAndBoardInfo() { showBoardListAndBoardInfo() {
return this.list.type !== ListType.promotion; return this.list.type !== ListType.promotion;
}, },
...@@ -58,7 +58,7 @@ export default { ...@@ -58,7 +58,7 @@ export default {
if (!this.glFeatures.graphqlBoardLists) { if (!this.glFeatures.graphqlBoardLists) {
return this.list.issues; return this.list.issues;
} }
return this.getIssues(this.list.id); return this.getIssuesByList(this.list.id);
}, },
shouldFetchIssues() { shouldFetchIssues() {
return this.glFeatures.graphqlBoardLists && this.list.type !== ListType.blank; return this.glFeatures.graphqlBoardLists && this.list.type !== ListType.blank;
......
...@@ -18,7 +18,7 @@ export default { ...@@ -18,7 +18,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapGetters({ issue: 'getActiveIssue' }), ...mapGetters({ issue: 'activeIssue' }),
hasDueDate() { hasDueDate() {
return this.issue.dueDate != null; return this.issue.dueDate != null;
}, },
......
...@@ -21,7 +21,7 @@ export default { ...@@ -21,7 +21,7 @@ export default {
}, },
inject: ['labelsFetchPath', 'labelsManagePath', 'labelsFilterBasePath'], inject: ['labelsFetchPath', 'labelsManagePath', 'labelsFilterBasePath'],
computed: { computed: {
...mapGetters({ issue: 'getActiveIssue' }), ...mapGetters({ issue: 'activeIssue' }),
selectedLabels() { selectedLabels() {
const { labels = [] } = this.issue; const { labels = [] } = this.issue;
......
...@@ -324,7 +324,7 @@ export default { ...@@ -324,7 +324,7 @@ export default {
}, },
setActiveIssueLabels: async ({ commit, getters }, input) => { setActiveIssueLabels: async ({ commit, getters }, input) => {
const activeIssue = getters.getActiveIssue; const { activeIssue } = getters;
const { data } = await gqlClient.mutate({ const { data } = await gqlClient.mutate({
mutation: issueSetLabels, mutation: issueSetLabels,
variables: { variables: {
...@@ -349,7 +349,7 @@ export default { ...@@ -349,7 +349,7 @@ export default {
}, },
setActiveIssueDueDate: async ({ commit, getters }, input) => { setActiveIssueDueDate: async ({ commit, getters }, input) => {
const activeIssue = getters.getActiveIssue; const { activeIssue } = getters;
const { data } = await gqlClient.mutate({ const { data } = await gqlClient.mutate({
mutation: issueSetDueDate, mutation: issueSetDueDate,
variables: { variables: {
......
...@@ -2,7 +2,7 @@ import { find } from 'lodash'; ...@@ -2,7 +2,7 @@ import { find } from 'lodash';
import { inactiveId } from '../constants'; import { inactiveId } from '../constants';
export default { export default {
getLabelToggleState: state => (state.isShowingLabels ? 'on' : 'off'), labelToggleState: state => (state.isShowingLabels ? 'on' : 'off'),
isSidebarOpen: state => state.activeId !== inactiveId, isSidebarOpen: state => state.activeId !== inactiveId,
isSwimlanesOn: state => { isSwimlanesOn: state => {
if (!gon?.features?.boardsWithSwimlanes && !gon?.features?.swimlanes) { if (!gon?.features?.boardsWithSwimlanes && !gon?.features?.swimlanes) {
...@@ -15,12 +15,12 @@ export default { ...@@ -15,12 +15,12 @@ export default {
return state.issues[id] || {}; return state.issues[id] || {};
}, },
getIssues: (state, getters) => listId => { getIssuesByList: (state, getters) => listId => {
const listIssueIds = state.issuesByListId[listId] || []; const listIssueIds = state.issuesByListId[listId] || [];
return listIssueIds.map(id => getters.getIssueById(id)); return listIssueIds.map(id => getters.getIssueById(id));
}, },
getActiveIssue: state => { activeIssue: state => {
return state.issues[state.activeId] || {}; return state.issues[state.activeId] || {};
}, },
......
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
}, },
mixins: [glFeatureFlagsMixin()], mixins: [glFeatureFlagsMixin()],
computed: { computed: {
...mapGetters(['isSidebarOpen', 'getActiveIssue']), ...mapGetters(['isSidebarOpen', 'activeIssue']),
...mapState(['sidebarType']), ...mapState(['sidebarType']),
showSidebar() { showSidebar() {
return this.sidebarType === ISSUABLE; return this.sidebarType === ISSUABLE;
...@@ -46,7 +46,7 @@ export default { ...@@ -46,7 +46,7 @@ export default {
@close="unsetActiveId" @close="unsetActiveId"
> >
<template #header> <template #header>
<issuable-title :ref-path="getActiveIssue.referencePath" :title="getActiveIssue.title" /> <issuable-title :ref-path="activeIssue.referencePath" :title="activeIssue.title" />
</template> </template>
<template> <template>
......
...@@ -20,7 +20,7 @@ export default { ...@@ -20,7 +20,7 @@ export default {
inject: ['groupId'], inject: ['groupId'],
computed: { computed: {
...mapState(['epics']), ...mapState(['epics']),
...mapGetters({ getEpicById: 'getEpicById', issue: 'getActiveIssue' }), ...mapGetters({ getEpicById: 'getEpicById', issue: 'activeIssue' }),
storedEpic() { storedEpic() {
const storedEpic = this.getEpicById(this.issue.epic?.id); const storedEpic = this.getEpicById(this.issue.epic?.id);
const epicId = getIdFromGraphQLId(storedEpic?.id); const epicId = getIdFromGraphQLId(storedEpic?.id);
......
...@@ -8,17 +8,17 @@ export default { ...@@ -8,17 +8,17 @@ export default {
IssuableTimeTracker, IssuableTimeTracker,
}, },
computed: { computed: {
...mapGetters(['getActiveIssue']), ...mapGetters(['activeIssue']),
}, },
}; };
</script> </script>
<template> <template>
<issuable-time-tracker <issuable-time-tracker
:time-estimate="getActiveIssue.timeEstimate" :time-estimate="activeIssue.timeEstimate"
:time-spent="getActiveIssue.totalTimeSpent" :time-spent="activeIssue.totalTimeSpent"
:human-time-estimate="getActiveIssue.humanTimeEstimate" :human-time-estimate="activeIssue.humanTimeEstimate"
:human-time-spent="getActiveIssue.humanTotalTimeSpent" :human-time-spent="activeIssue.humanTotalTimeSpent"
:limit-to-hours="timeTrackingLimitToHours" :limit-to-hours="timeTrackingLimitToHours"
:show-collapsed="false" :show-collapsed="false"
/> />
......
...@@ -23,7 +23,7 @@ export default { ...@@ -23,7 +23,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapGetters({ issue: 'getActiveIssue' }), ...mapGetters({ issue: 'activeIssue' }),
hasWeight() { hasWeight() {
return this.issue.weight > 0; return this.issue.weight > 0;
}, },
......
...@@ -333,7 +333,7 @@ export default { ...@@ -333,7 +333,7 @@ export default {
mutation: issueSetEpic, mutation: issueSetEpic,
variables: { variables: {
input: { input: {
iid: String(getters.getActiveIssue.iid), iid: String(getters.activeIssue.iid),
epicId: input.epicId, epicId: input.epicId,
projectPath: input.projectPath, projectPath: input.projectPath,
}, },
...@@ -352,7 +352,7 @@ export default { ...@@ -352,7 +352,7 @@ export default {
mutation: issueSetWeight, mutation: issueSetWeight,
variables: { variables: {
input: { input: {
iid: String(getters.getActiveIssue.iid), iid: String(getters.activeIssue.iid),
weight: input.weight, weight: input.weight,
projectPath: input.projectPath, projectPath: input.projectPath,
}, },
...@@ -364,7 +364,7 @@ export default { ...@@ -364,7 +364,7 @@ export default {
} }
commit(typesCE.UPDATE_ISSUE_BY_ID, { commit(typesCE.UPDATE_ISSUE_BY_ID, {
issueId: getters.getActiveIssue.id, issueId: getters.activeIssue.id,
prop: 'weight', prop: 'weight',
value: data.issueSetWeight.issue.weight, value: data.issueSetWeight.issue.weight,
}); });
......
...@@ -4,11 +4,11 @@ export default { ...@@ -4,11 +4,11 @@ export default {
...gettersCE, ...gettersCE,
getIssuesByEpic: (state, getters) => (listId, epicId) => { getIssuesByEpic: (state, getters) => (listId, epicId) => {
return getters.getIssues(listId).filter(issue => issue.epic && issue.epic.id === epicId); return getters.getIssuesByList(listId).filter(issue => issue.epic && issue.epic.id === epicId);
}, },
getUnassignedIssues: (state, getters) => listId => { getUnassignedIssues: (state, getters) => listId => {
return getters.getIssues(listId).filter(i => Boolean(i.epic) === false); return getters.getIssuesByList(listId).filter(i => Boolean(i.epic) === false);
}, },
getEpicById: state => epicId => { getEpicById: state => epicId => {
......
...@@ -15,7 +15,7 @@ export default () => ...@@ -15,7 +15,7 @@ export default () =>
store, store,
computed: { computed: {
...mapState(['isShowingLabels']), ...mapState(['isShowingLabels']),
...mapGetters(['getLabelToggleState']), ...mapGetters(['labelToggleState']),
}, },
methods: { methods: {
...mapActions(['setShowLabels']), ...mapActions(['setShowLabels']),
...@@ -25,7 +25,7 @@ export default () => ...@@ -25,7 +25,7 @@ export default () =>
Tracking.event(document.body.dataset.page, 'toggle', { Tracking.event(document.body.dataset.page, 'toggle', {
label: 'show_labels', label: 'show_labels',
property: this.getLabelToggleState, property: this.labelToggleState,
}); });
}, },
......
...@@ -528,7 +528,7 @@ describe('resetEpics', () => { ...@@ -528,7 +528,7 @@ describe('resetEpics', () => {
}); });
describe('setActiveIssueEpic', () => { describe('setActiveIssueEpic', () => {
const getters = { getActiveIssue: mockIssue }; const getters = { activeIssue: mockIssue };
const epicWithData = { const epicWithData = {
id: 'gid://gitlab/Epic/42', id: 'gid://gitlab/Epic/42',
iid: 1, iid: 1,
...@@ -560,7 +560,7 @@ describe('setActiveIssueEpic', () => { ...@@ -560,7 +560,7 @@ describe('setActiveIssueEpic', () => {
describe('setActiveIssueWeight', () => { describe('setActiveIssueWeight', () => {
const state = { issues: { [mockIssue.id]: mockIssue } }; const state = { issues: { [mockIssue.id]: mockIssue } };
const getters = { getActiveIssue: mockIssue }; const getters = { activeIssue: mockIssue };
const testWeight = mockIssue.weight + 1; const testWeight = mockIssue.weight + 1;
const input = { const input = {
weight: testWeight, weight: testWeight,
...@@ -580,7 +580,7 @@ describe('setActiveIssueWeight', () => { ...@@ -580,7 +580,7 @@ describe('setActiveIssueWeight', () => {
}); });
const payload = { const payload = {
issueId: getters.getActiveIssue.id, issueId: getters.activeIssue.id,
prop: 'weight', prop: 'weight',
value: testWeight, value: testWeight,
}; };
......
...@@ -18,9 +18,9 @@ describe('EE Boards Store Getters', () => { ...@@ -18,9 +18,9 @@ describe('EE Boards Store Getters', () => {
describe('getIssuesByEpic', () => { describe('getIssuesByEpic', () => {
it('returns issues for a given listId and epicId', () => { it('returns issues for a given listId and epicId', () => {
const getIssues = () => mockIssues; const getIssuesByList = () => mockIssues;
expect( expect(
getters.getIssuesByEpic(boardsState, { getIssues })( getters.getIssuesByEpic(boardsState, { getIssuesByList })(
'gid://gitlab/List/2', 'gid://gitlab/List/2',
'gid://gitlab/Epic/41', 'gid://gitlab/Epic/41',
), ),
...@@ -30,9 +30,9 @@ describe('EE Boards Store Getters', () => { ...@@ -30,9 +30,9 @@ describe('EE Boards Store Getters', () => {
describe('getUnassignedIssues', () => { describe('getUnassignedIssues', () => {
it('returns issues not assigned to an epic for a given listId', () => { it('returns issues not assigned to an epic for a given listId', () => {
const getIssues = () => [mockIssue, mockIssue3, mockIssue4]; const getIssuesByList = () => [mockIssue, mockIssue3, mockIssue4];
expect( expect(
getters.getUnassignedIssues(boardsState, { getIssues })('gid://gitlab/List/1'), getters.getUnassignedIssues(boardsState, { getIssuesByList })('gid://gitlab/List/1'),
).toEqual([mockIssue3, mockIssue4]); ).toEqual([mockIssue3, mockIssue4]);
}); });
}); });
......
...@@ -18,7 +18,7 @@ describe('BoardCardAssigneeDropdown', () => { ...@@ -18,7 +18,7 @@ describe('BoardCardAssigneeDropdown', () => {
wrapper = mount(BoardAssigneeDropdown, { wrapper = mount(BoardAssigneeDropdown, {
data() { data() {
return { return {
selected: store.getters.getActiveIssue.assignees, selected: store.getters.activeIssue.assignees,
participants, participants,
}; };
}, },
......
...@@ -640,7 +640,7 @@ describe('addListIssueFailure', () => { ...@@ -640,7 +640,7 @@ describe('addListIssueFailure', () => {
describe('setActiveIssueLabels', () => { describe('setActiveIssueLabels', () => {
const state = { issues: { [mockIssue.id]: mockIssue } }; const state = { issues: { [mockIssue.id]: mockIssue } };
const getters = { getActiveIssue: mockIssue }; const getters = { activeIssue: mockIssue };
const testLabelIds = labels.map(label => label.id); const testLabelIds = labels.map(label => label.id);
const input = { const input = {
addLabelIds: testLabelIds, addLabelIds: testLabelIds,
...@@ -654,7 +654,7 @@ describe('setActiveIssueLabels', () => { ...@@ -654,7 +654,7 @@ describe('setActiveIssueLabels', () => {
.mockResolvedValue({ data: { updateIssue: { issue: { labels: { nodes: labels } } } } }); .mockResolvedValue({ data: { updateIssue: { issue: { labels: { nodes: labels } } } } });
const payload = { const payload = {
issueId: getters.getActiveIssue.id, issueId: getters.activeIssue.id,
prop: 'labels', prop: 'labels',
value: labels, value: labels,
}; };
...@@ -685,7 +685,7 @@ describe('setActiveIssueLabels', () => { ...@@ -685,7 +685,7 @@ describe('setActiveIssueLabels', () => {
describe('setActiveIssueDueDate', () => { describe('setActiveIssueDueDate', () => {
const state = { issues: { [mockIssue.id]: mockIssue } }; const state = { issues: { [mockIssue.id]: mockIssue } };
const getters = { getActiveIssue: mockIssue }; const getters = { activeIssue: mockIssue };
const testDueDate = '2020-02-20'; const testDueDate = '2020-02-20';
const input = { const input = {
dueDate: testDueDate, dueDate: testDueDate,
...@@ -705,7 +705,7 @@ describe('setActiveIssueDueDate', () => { ...@@ -705,7 +705,7 @@ describe('setActiveIssueDueDate', () => {
}); });
const payload = { const payload = {
issueId: getters.getActiveIssue.id, issueId: getters.activeIssue.id,
prop: 'dueDate', prop: 'dueDate',
value: testDueDate, value: testDueDate,
}; };
......
...@@ -10,13 +10,13 @@ import { ...@@ -10,13 +10,13 @@ import {
} from '../mock_data'; } from '../mock_data';
describe('Boards - Getters', () => { describe('Boards - Getters', () => {
describe('getLabelToggleState', () => { describe('labelToggleState', () => {
it('should return "on" when isShowingLabels is true', () => { it('should return "on" when isShowingLabels is true', () => {
const state = { const state = {
isShowingLabels: true, isShowingLabels: true,
}; };
expect(getters.getLabelToggleState(state)).toBe('on'); expect(getters.labelToggleState(state)).toBe('on');
}); });
it('should return "off" when isShowingLabels is false', () => { it('should return "off" when isShowingLabels is false', () => {
...@@ -24,7 +24,7 @@ describe('Boards - Getters', () => { ...@@ -24,7 +24,7 @@ describe('Boards - Getters', () => {
isShowingLabels: false, isShowingLabels: false,
}; };
expect(getters.getLabelToggleState(state)).toBe('off'); expect(getters.labelToggleState(state)).toBe('off');
}); });
}); });
...@@ -112,7 +112,7 @@ describe('Boards - Getters', () => { ...@@ -112,7 +112,7 @@ describe('Boards - Getters', () => {
}); });
}); });
describe('getActiveIssue', () => { describe('activeIssue', () => {
it.each` it.each`
id | expected id | expected
${'1'} | ${'issue'} ${'1'} | ${'issue'}
...@@ -120,11 +120,11 @@ describe('Boards - Getters', () => { ...@@ -120,11 +120,11 @@ describe('Boards - Getters', () => {
`('returns $expected when $id is passed to state', ({ id, expected }) => { `('returns $expected when $id is passed to state', ({ id, expected }) => {
const state = { issues: { '1': 'issue' }, activeId: id }; const state = { issues: { '1': 'issue' }, activeId: id };
expect(getters.getActiveIssue(state)).toEqual(expected); expect(getters.activeIssue(state)).toEqual(expected);
}); });
}); });
describe('getIssues', () => { describe('getIssuesByList', () => {
const boardsState = { const boardsState = {
issuesByListId: mockIssuesByListId, issuesByListId: mockIssuesByListId,
issues, issues,
...@@ -132,7 +132,7 @@ describe('Boards - Getters', () => { ...@@ -132,7 +132,7 @@ describe('Boards - Getters', () => {
it('returns issues for a given listId', () => { it('returns issues for a given listId', () => {
const getIssueById = issueId => [mockIssue, mockIssue2].find(({ id }) => id === issueId); const getIssueById = issueId => [mockIssue, mockIssue2].find(({ id }) => id === issueId);
expect(getters.getIssues(boardsState, { getIssueById })('gid://gitlab/List/2')).toEqual( expect(getters.getIssuesByList(boardsState, { getIssueById })('gid://gitlab/List/2')).toEqual(
mockIssues, mockIssues,
); );
}); });
......
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