Commit 45309f7c authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '326270-scoping-an-issue-board-by-label-does-not-load-filter' into 'master'

Resolve "Scoping an Issue Board by label does not load filter" [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!57779
parents dfe9aca1 62fd0fd0
...@@ -5,7 +5,6 @@ import BoardAddNewColumnForm from '~/boards/components/board_add_new_column_form ...@@ -5,7 +5,6 @@ import BoardAddNewColumnForm from '~/boards/components/board_add_new_column_form
import { ListType } from '~/boards/constants'; import { ListType } from '~/boards/constants';
import boardsStore from '~/boards/stores/boards_store'; import boardsStore from '~/boards/stores/boards_store';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { isScopedLabel } from '~/lib/utils/common_utils';
export default { export default {
components: { components: {
...@@ -20,17 +19,12 @@ export default { ...@@ -20,17 +19,12 @@ export default {
data() { data() {
return { return {
selectedId: null, selectedId: null,
selectedLabel: null,
}; };
}, },
computed: { computed: {
...mapState(['labels', 'labelsLoading']), ...mapState(['labels', 'labelsLoading']),
...mapGetters(['getListByLabelId', 'shouldUseGraphQL']), ...mapGetters(['getListByLabelId', 'shouldUseGraphQL']),
selectedLabel() {
if (!this.selectedId) {
return null;
}
return this.labels.find(({ id }) => id === this.selectedId);
},
columnForSelected() { columnForSelected() {
return this.getListByLabelId(this.selectedId); return this.getListByLabelId(this.selectedId);
}, },
...@@ -83,8 +77,13 @@ export default { ...@@ -83,8 +77,13 @@ export default {
this.fetchLabels(searchTerm); this.fetchLabels(searchTerm);
}, },
showScopedLabels(label) { setSelectedItem(selectedId) {
return this.scopedLabelsAvailable && isScopedLabel(label); const label = this.labels.find(({ id }) => id === selectedId);
if (!selectedId || !label) {
this.selectedLabel = null;
} else {
this.selectedLabel = { ...label };
}
}, },
}, },
}; };
...@@ -116,6 +115,7 @@ export default { ...@@ -116,6 +115,7 @@ export default {
v-if="labels.length > 0" v-if="labels.length > 0"
v-model="selectedId" v-model="selectedId"
class="gl-overflow-y-auto gl-px-5 gl-pt-3" class="gl-overflow-y-auto gl-px-5 gl-pt-3"
@change="setSelectedItem"
> >
<label <label
v-for="label in labels" v-for="label in labels"
......
...@@ -72,6 +72,7 @@ export default { ...@@ -72,6 +72,7 @@ export default {
data() { data() {
return { return {
selectedId: null, selectedId: null,
selectedItem: null,
columnType: ListType.label, columnType: ListType.label,
}; };
}, },
...@@ -113,10 +114,6 @@ export default { ...@@ -113,10 +114,6 @@ export default {
return this.columnType === ListType.iteration; return this.columnType === ListType.iteration;
}, },
selectedItem() {
return this.items.find(({ id }) => id === this.selectedId);
},
hasLabelSelection() { hasLabelSelection() {
return this.labelTypeSelected && this.selectedItem; return this.labelTypeSelected && this.selectedItem;
}, },
...@@ -262,11 +259,17 @@ export default { ...@@ -262,11 +259,17 @@ export default {
setColumnType(type) { setColumnType(type) {
this.columnType = type; this.columnType = type;
this.selectedId = null; this.selectedId = null;
this.setSelectedItem(null);
this.filterItems(); this.filterItems();
}, },
hideDropdown() { setSelectedItem(selectedId) {
this.$root.$emit('bv::dropdown::hide'); const item = this.items.find(({ id }) => id === selectedId);
if (!selectedId || !item) {
this.selectedItem = null;
} else {
this.selectedItem = { ...item };
}
}, },
}, },
}; };
...@@ -337,7 +340,8 @@ export default { ...@@ -337,7 +340,8 @@ export default {
<gl-form-radio-group <gl-form-radio-group
v-model="selectedId" v-model="selectedId"
class="gl-overflow-y-auto gl-px-5" class="gl-overflow-y-auto gl-px-5"
@change="hideDropdown" data-testid="selectItem"
@change="setSelectedItem"
> >
<label <label
v-for="item in items" v-for="item in items"
......
...@@ -17,6 +17,10 @@ describe('BoardAddNewColumn', () => { ...@@ -17,6 +17,10 @@ describe('BoardAddNewColumn', () => {
let wrapper; let wrapper;
let shouldUseGraphQL; let shouldUseGraphQL;
const selectItem = (id) => {
wrapper.findByTestId('selectItem').vm.$emit('change', id);
};
const createStore = ({ actions = {}, getters = {}, state = {} } = {}) => { const createStore = ({ actions = {}, getters = {}, state = {} } = {}) => {
return new Vuex.Store({ return new Vuex.Store({
state: { state: {
...@@ -76,6 +80,11 @@ describe('BoardAddNewColumn', () => { ...@@ -76,6 +80,11 @@ describe('BoardAddNewColumn', () => {
}, },
}), }),
); );
// trigger change event
if (selectedId) {
selectItem(selectedId);
}
}; };
afterEach(() => { afterEach(() => {
......
import { GlFormRadioGroup } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
...@@ -12,6 +13,10 @@ Vue.use(Vuex); ...@@ -12,6 +13,10 @@ Vue.use(Vuex);
describe('Board card layout', () => { describe('Board card layout', () => {
let wrapper; let wrapper;
const selectLabel = (id) => {
wrapper.findComponent(GlFormRadioGroup).vm.$emit('change', id);
};
const createStore = ({ actions = {}, getters = {}, state = {} } = {}) => { const createStore = ({ actions = {}, getters = {}, state = {} } = {}) => {
return new Vuex.Store({ return new Vuex.Store({
state: { state: {
...@@ -57,6 +62,11 @@ describe('Board card layout', () => { ...@@ -57,6 +62,11 @@ describe('Board card layout', () => {
}, },
}), }),
); );
// trigger change event
if (selectedId) {
selectLabel(selectedId);
}
}; };
afterEach(() => { afterEach(() => {
......
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