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