Commit 2b9484ef authored by Scott Stern's avatar Scott Stern Committed by Kushal Pandya

Fix iteration token value on load

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