Commit 499b571c authored by Phil Hughes's avatar Phil Hughes

Allow conditions to have a replacement URL in filtered search

This allows for conditions to override the previously set URL with
a new URL. For merge requests, we will be replacing WIP with draft
which this will allow.

Part of https://gitlab.com/gitlab-org/gitlab/-/issues/227414
parent 89b27c7f
...@@ -743,7 +743,7 @@ export default class FilteredSearchManager { ...@@ -743,7 +743,7 @@ export default class FilteredSearchManager {
let tokenPath = ''; let tokenPath = '';
if (condition) { if (condition) {
tokenPath = condition.url; tokenPath = condition.replacementUrl || condition.url;
} else { } else {
let tokenValue = token.value; let tokenValue = token.value;
......
...@@ -225,6 +225,26 @@ describe('Filtered Search Manager', () => { ...@@ -225,6 +225,26 @@ describe('Filtered Search Manager', () => {
manager.search(); manager.search();
}); });
it('should use replacement URL for condition', done => {
tokensContainer.innerHTML = FilteredSearchSpecHelper.createTokensContainerHTML(
FilteredSearchSpecHelper.createFilterVisualTokenHTML('milestone', '=', '13', true),
);
visitUrl.mockImplementation(url => {
expect(url).toEqual(`${defaultParams}&milestone_title=replaced`);
done();
});
manager.filteredSearchTokenKeys.conditions.push({
url: 'milestone_title=13',
replacementUrl: 'milestone_title=replaced',
tokenKey: 'milestone',
value: '13',
operator: '=',
});
manager.search();
});
it('removes duplicated tokens', done => { it('removes duplicated tokens', done => {
tokensContainer.innerHTML = FilteredSearchSpecHelper.createTokensContainerHTML(` tokensContainer.innerHTML = FilteredSearchSpecHelper.createTokensContainerHTML(`
${FilteredSearchSpecHelper.createFilterVisualTokenHTML('label', '=', '~bug')} ${FilteredSearchSpecHelper.createFilterVisualTokenHTML('label', '=', '~bug')}
......
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