Skip to content
Snippets Groups Projects

Remember user preference for showing labels on work item widgets

All threads resolved!
Files
7
@@ -14,6 +14,8 @@ import { TYPENAME_ISSUE, TYPENAME_WORK_ITEM } from '~/graphql_shared/constants';
import getIssueDetailsQuery from 'ee_else_ce/work_items/graphql/get_issue_details.query.graphql';
import { getParameterByName, setUrlParams, updateHistory } from '~/lib/utils/url_utility';
import AccessorUtilities from '~/lib/utils/accessor';
import { parseBoolean } from '~/lib/utils/common_utils';
import {
FORM_TYPES,
WIDGET_ICONS,
@@ -21,6 +23,7 @@ import {
TASKS_ANCHOR,
DEFAULT_PAGE_SIZE_CHILD_ITEMS,
DETAIL_VIEW_QUERY_PARAM_NAME,
WORKITEM_LINKS_SHOWLABELS_LOCALSTORAGEKEY,
} from '../../constants';
import { findHierarchyWidgets } from '../../utils';
import { removeHierarchyChild } from '../../graphql/cache_utils';
@@ -117,9 +120,11 @@ export default {
reportedUserId: 0,
reportedUrl: '',
widgetName: TASKS_ANCHOR,
defaultShowLabels: true,
showLabels: true,
fetchNextPageInProgress: false,
disableContent: false,
showLabelsLocalStorageKey: WORKITEM_LINKS_SHOWLABELS_LOCALSTORAGEKEY,
};
},
computed: {
@@ -179,6 +184,9 @@ export default {
return this.workItem?.workItemType?.name || '';
},
},
mounted() {
this.setShowLabelsFromLocalStorage();
},
methods: {
showAddForm(formType) {
this.$refs.wrapper.show();
@@ -224,6 +232,19 @@ export default {
openReportAbuseModal(reply) {
this.toggleReportAbuseModal(true, reply);
},
toggleShowLabels() {
this.showLabels = !this.showLabels;
if (AccessorUtilities.canUseLocalStorage()) {
localStorage.setItem(this.showLabelsLocalStorageKey, this.showLabels);
}
},
setShowLabelsFromLocalStorage() {
if (AccessorUtilities.canUseLocalStorage()) {
this.showLabels = parseBoolean(
localStorage.getItem(this.showLabelsLocalStorageKey) ?? this.defaultShowLabels,
);
}
},
async fetchNextPage() {
if (this.hasNextPage && !this.fetchNextPageInProgress) {
this.fetchNextPageInProgress = true;
@@ -310,7 +331,7 @@ export default {
:work-item-type="workItemType"
:show-labels="showLabels"
:show-view-roadmap-action="false"
@toggle-show-labels="showLabels = !showLabels"
@toggle-show-labels="toggleShowLabels"
/>
</template>
<template #body>
Loading