Commit 5732b016 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ss/fix-load-iteration-token' into 'master'

Fix iteration token value on load

See merge request gitlab-org/gitlab!75582
parents 9ca47a93 2b9484ef
...@@ -232,20 +232,24 @@ export const FiltersInfo = { ...@@ -232,20 +232,24 @@ export const FiltersInfo = {
}, },
iterationId: { iterationId: {
negatedSupport: true, negatedSupport: true,
remap: (k, v) => remap: (k, v) => {
// iteration_id should be renamed to iterationWildcardId when CURRENT is the value return v.endsWith(IterationFilterType.any) ||
v === IterationFilterType.any || v.endsWith(IterationFilterType.none) ||
v === IterationFilterType.none || v.endsWith(IterationFilterType.current)
v === IterationFilterType.current
? 'iterationWildcardId' ? 'iterationWildcardId'
: k, : k;
},
}, },
iterationTitle: { iterationTitle: {
negatedSupport: true, negatedSupport: true,
}, },
iterationWildcardId: { iterationWildcardId: {
negatedSupport: true, negatedSupport: true,
transform: (val) => val.toUpperCase(), transform: (val) => {
// Gets the wildcard value out of the gid.
const valList = val.split('/');
return valList[valList.length - 1].toUpperCase();
},
}, },
weight: { weight: {
negatedSupport: true, negatedSupport: true,
......
#import "../../sidebar/queries/iteration.fragment.graphql"
query GroupBoardIterations($fullPath: ID!, $title: String) {
group(fullPath: $fullPath) {
id
iterations(includeAncestors: true, title: $title) {
nodes {
...IterationFragment
}
}
}
}
#import "../../sidebar/queries/iteration.fragment.graphql"
query ProjectBoardIterations($fullPath: ID!, $title: String) {
project(fullPath: $fullPath) {
id
iterations(includeAncestors: true, title: $title) {
nodes {
...IterationFragment
}
}
}
}
...@@ -12,12 +12,11 @@ import listsIssuesQuery from '~/boards/graphql/lists_issues.query.graphql'; ...@@ -12,12 +12,11 @@ import listsIssuesQuery from '~/boards/graphql/lists_issues.query.graphql';
import projectBoardMembersQuery from '~/boards/graphql/project_board_members.query.graphql'; import projectBoardMembersQuery from '~/boards/graphql/project_board_members.query.graphql';
import actionsCE from '~/boards/stores/actions'; import actionsCE from '~/boards/stores/actions';
import * as typesCE from '~/boards/stores/mutation_types'; import * as typesCE from '~/boards/stores/mutation_types';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId, convertToGraphQLId } from '~/graphql_shared/utils';
import { historyPushState, convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { historyPushState, convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import { mergeUrlParams, removeParams, queryToObject } from '~/lib/utils/url_utility'; import { mergeUrlParams, removeParams, queryToObject } from '~/lib/utils/url_utility';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import groupBoardIterationsQuery from 'ee/boards/graphql/group_board_iterations.query.graphql'; import searchIterationQuery from 'ee/issues_list/queries/search_iterations.query.graphql';
import projectBoardIterationsQuery from 'ee/boards/graphql/project_board_iterations.query.graphql';
import { import {
fullEpicBoardId, fullEpicBoardId,
formatEpic, formatEpic,
...@@ -137,14 +136,21 @@ export default { ...@@ -137,14 +136,21 @@ export default {
}, },
setFilters: ({ commit, dispatch, state: { issuableType } }, filters) => { setFilters: ({ commit, dispatch, state: { issuableType } }, filters) => {
const filtersCopy = { ...filters };
if (filters.groupBy === GroupByParamType.epic) { if (filters.groupBy === GroupByParamType.epic) {
dispatch('setEpicSwimlanes'); dispatch('setEpicSwimlanes');
} }
if (filters?.iterationId) {
// eslint-disable-next-line @gitlab/require-i18n-strings
filtersCopy.iterationId = convertToGraphQLId('Iteration', filters.iterationId);
}
commit( commit(
types.SET_FILTERS, types.SET_FILTERS,
filterVariables({ filterVariables({
filters, filters: filtersCopy,
issuableType, issuableType,
filterInfo: FiltersInfo, filterInfo: FiltersInfo,
filterFields: FilterFields, filterFields: FilterFields,
...@@ -157,27 +163,16 @@ export default { ...@@ -157,27 +163,16 @@ export default {
const { fullPath, boardType } = state; const { fullPath, boardType } = state;
const variables = { const id = Number(title);
fullPath, let variables = { fullPath, search: title, isProject: boardType === BoardType.project };
title,
};
let query; if (!Number.isNaN(id) && title !== '') {
if (boardType === BoardType.project) { variables = { fullPath, id, isProject: boardType === BoardType.project };
query = projectBoardIterationsQuery;
}
if (boardType === BoardType.group) {
query = groupBoardIterationsQuery;
}
if (!query) {
// eslint-disable-next-line @gitlab/require-i18n-strings
throw new Error('Unknown board type');
} }
return gqlClient return gqlClient
.query({ .query({
query, query: searchIterationQuery,
variables, variables,
}) })
.then(({ data }) => { .then(({ data }) => {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { GlDropdownDivider, GlDropdownSectionHeader, GlFilteredSearchSuggestion } from '@gitlab/ui'; import { GlDropdownDivider, GlDropdownSectionHeader, GlFilteredSearchSuggestion } from '@gitlab/ui';
import { groupByIterationCadences } from 'ee/iterations/utils'; import { groupByIterationCadences } from 'ee/iterations/utils';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue'; import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
...@@ -42,7 +43,7 @@ export default { ...@@ -42,7 +43,7 @@ export default {
}, },
methods: { methods: {
getActiveIteration(iterations, data) { getActiveIteration(iterations, data) {
return iterations.find((iteration) => iteration.id === data); return iterations.find((iteration) => this.getId(iteration) === data);
}, },
groupIterationsByCadence(iterations) { groupIterationsByCadence(iterations) {
return groupByIterationCadences(iterations); return groupByIterationCadences(iterations);
...@@ -61,6 +62,9 @@ export default { ...@@ -61,6 +62,9 @@ export default {
this.loading = false; this.loading = false;
}); });
}, },
getId(iteration) {
return getIdFromGraphQLId(iteration.id).toString();
},
}, },
}; };
</script> </script>
...@@ -93,7 +97,7 @@ export default { ...@@ -93,7 +97,7 @@ export default {
<gl-filtered-search-suggestion <gl-filtered-search-suggestion
v-for="iteration in cadence.iterations" v-for="iteration in cadence.iterations"
:key="iteration.id" :key="iteration.id"
:value="iteration.id" :value="getId(iteration)"
> >
{{ iteration.title }} {{ iteration.title }}
<div v-if="glFeatures.iterationCadences" class="gl-text-gray-400"> <div v-if="glFeatures.iterationCadences" class="gl-text-gray-400">
......
...@@ -66,11 +66,11 @@ describe('setFilters', () => { ...@@ -66,11 +66,11 @@ describe('setFilters', () => {
[ [
'with correct EE filters as payload', 'with correct EE filters as payload',
{ {
filters: { weight: 3, 'not[iterationId]': 1 }, filters: { weight: 3, 'not[iterationId]': '1' },
filterVariables: { filterVariables: {
weight: 3, weight: 3,
not: { not: {
iterationId: 1, iterationId: '1',
}, },
}, },
}, },
......
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