Commit d2ec61e4 authored by pburdette's avatar pburdette

Show warning for raw text

Show createFlash Warning for
raw text search when filtering
pipelines. And ensure console error
doesn't happen when using raw text.
parent a563eba7
...@@ -10,7 +10,7 @@ import NavigationControls from './nav_controls.vue'; ...@@ -10,7 +10,7 @@ import NavigationControls from './nav_controls.vue';
import { getParameterByName } from '../../lib/utils/common_utils'; import { getParameterByName } from '../../lib/utils/common_utils';
import CIPaginationMixin from '../../vue_shared/mixins/ci_pagination_api_mixin'; import CIPaginationMixin from '../../vue_shared/mixins/ci_pagination_api_mixin';
import PipelinesFilteredSearch from './pipelines_filtered_search.vue'; import PipelinesFilteredSearch from './pipelines_filtered_search.vue';
import { ANY_TRIGGER_AUTHOR } from '../constants'; import { ANY_TRIGGER_AUTHOR, RAW_TEXT_WARNING } from '../constants';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
export default { export default {
...@@ -258,9 +258,13 @@ export default { ...@@ -258,9 +258,13 @@ export default {
filters.forEach(filter => { filters.forEach(filter => {
// do not add Any for username query param, so we // do not add Any for username query param, so we
// can fetch all trigger authors // can fetch all trigger authors
if (filter.value.data !== ANY_TRIGGER_AUTHOR) { if (filter.type && filter.value.data !== ANY_TRIGGER_AUTHOR) {
this.requestData[filter.type] = filter.value.data; this.requestData[filter.type] = filter.value.data;
} }
if (!filter.type) {
createFlash(RAW_TEXT_WARNING, 'warning');
}
}); });
if (filters.length === 0) { if (filters.length === 0) {
......
import { __ } from '~/locale'; import { s__, __ } from '~/locale';
export const CANCEL_REQUEST = 'CANCEL_REQUEST'; export const CANCEL_REQUEST = 'CANCEL_REQUEST';
export const PIPELINES_TABLE = 'PIPELINES_TABLE'; export const PIPELINES_TABLE = 'PIPELINES_TABLE';
...@@ -14,3 +14,6 @@ export const TestStatus = { ...@@ -14,3 +14,6 @@ export const TestStatus = {
export const FETCH_AUTHOR_ERROR_MESSAGE = __('There was a problem fetching project users.'); export const FETCH_AUTHOR_ERROR_MESSAGE = __('There was a problem fetching project users.');
export const FETCH_BRANCH_ERROR_MESSAGE = __('There was a problem fetching project branches.'); export const FETCH_BRANCH_ERROR_MESSAGE = __('There was a problem fetching project branches.');
export const RAW_TEXT_WARNING = s__(
'Pipeline|Raw text search is not currently supported. Please use the available search tokens.',
);
---
title: Show warning message to user if raw text search is used when filtering pipelines
merge_request: 31942
author:
type: changed
...@@ -15280,6 +15280,9 @@ msgstr "" ...@@ -15280,6 +15280,9 @@ msgstr ""
msgid "Pipeline|Pipelines" msgid "Pipeline|Pipelines"
msgstr "" msgstr ""
msgid "Pipeline|Raw text search is not currently supported. Please use the available search tokens."
msgstr ""
msgid "Pipeline|Run Pipeline" msgid "Pipeline|Run Pipeline"
msgstr "" msgstr ""
......
...@@ -6,7 +6,11 @@ import waitForPromises from 'helpers/wait_for_promises'; ...@@ -6,7 +6,11 @@ import waitForPromises from 'helpers/wait_for_promises';
import PipelinesComponent from '~/pipelines/components/pipelines.vue'; import PipelinesComponent from '~/pipelines/components/pipelines.vue';
import Store from '~/pipelines/stores/pipelines_store'; import Store from '~/pipelines/stores/pipelines_store';
import { pipelineWithStages, stageReply, users, mockSearch, branches } from './mock_data'; import { pipelineWithStages, stageReply, users, mockSearch, branches } from './mock_data';
import { RAW_TEXT_WARNING } from '~/pipelines/constants';
import { GlFilteredSearch } from '@gitlab/ui'; import { GlFilteredSearch } from '@gitlab/ui';
import createFlash from '~/flash';
jest.mock('~/flash', () => jest.fn());
describe('Pipelines', () => { describe('Pipelines', () => {
const jsonFixtureName = 'pipelines/pipelines.json'; const jsonFixtureName = 'pipelines/pipelines.json';
...@@ -667,15 +671,18 @@ describe('Pipelines', () => { ...@@ -667,15 +671,18 @@ describe('Pipelines', () => {
}); });
describe('Pipeline filters', () => { describe('Pipeline filters', () => {
let updateContentMock;
beforeEach(() => { beforeEach(() => {
mock.onGet(paths.endpoint).reply(200, pipelines); mock.onGet(paths.endpoint).reply(200, pipelines);
createComponent(); createComponent();
updateContentMock = jest.spyOn(wrapper.vm, 'updateContent');
return waitForPromises(); return waitForPromises();
}); });
it('updates request data and query params on filter submit', () => { it('updates request data and query params on filter submit', () => {
const updateContentMock = jest.spyOn(wrapper.vm, 'updateContent');
const expectedQueryParams = { page: '1', scope: 'all', username: 'root', ref: 'master' }; const expectedQueryParams = { page: '1', scope: 'all', username: 'root', ref: 'master' };
findFilteredSearch().vm.$emit('submit', mockSearch); findFilteredSearch().vm.$emit('submit', mockSearch);
...@@ -683,5 +690,21 @@ describe('Pipelines', () => { ...@@ -683,5 +690,21 @@ describe('Pipelines', () => {
expect(wrapper.vm.requestData).toEqual(expectedQueryParams); expect(wrapper.vm.requestData).toEqual(expectedQueryParams);
expect(updateContentMock).toHaveBeenCalledWith(expectedQueryParams); expect(updateContentMock).toHaveBeenCalledWith(expectedQueryParams);
}); });
it('does not add query params if raw text search is used', () => {
const expectedQueryParams = { page: '1', scope: 'all' };
findFilteredSearch().vm.$emit('submit', ['rawText']);
expect(wrapper.vm.requestData).toEqual(expectedQueryParams);
expect(updateContentMock).toHaveBeenCalledWith(expectedQueryParams);
});
it('displays a warning message if raw text search is used', () => {
findFilteredSearch().vm.$emit('submit', ['rawText']);
expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith(RAW_TEXT_WARNING, 'warning');
});
}); });
}); });
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