-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Upgrade Assistant] Fix filter deprecations search filter (#57541)
* Made eui search field not a controlled component Added validateRegExpString util * Update error message display. Use EuiCallOut and i18n to replicate other search filter behaviour, e.g. index management. * Remove unused variable * Update Jest snapshot * Updated layout for callout The previous callout layout looked off-center next to the controls in the table. * Update copy and remove intl Update "Filter Invalid:" to sentence case Remove inject intl wrapper from CheckupControls component Remove unnecessary grow={true} * Updated Jest component snapshot Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
84be262
commit 26fdc4a
Showing
5 changed files
with
121 additions
and
45 deletions.
There are no files selected for viewing
3 changes: 1 addition & 2 deletions
3
...blic/np_ready/application/components/tabs/checkup/__snapshots__/checkup_tab.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
x-pack/legacy/plugins/upgrade_assistant/public/np_ready/application/utils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { validateRegExpString } from './utils'; | ||
|
||
describe('validRegExpString', () => { | ||
it('correctly returns false for invalid strings', () => { | ||
expect(validateRegExpString('?asd')).toContain(`Invalid regular expression`); | ||
expect(validateRegExpString('*asd')).toContain(`Invalid regular expression`); | ||
expect(validateRegExpString('(')).toContain(`Invalid regular expression`); | ||
}); | ||
|
||
it('correctly returns true for valid strings', () => { | ||
expect(validateRegExpString('asd')).toBe(''); | ||
expect(validateRegExpString('.*asd')).toBe(''); | ||
expect(validateRegExpString('')).toBe(''); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
x-pack/legacy/plugins/upgrade_assistant/public/np_ready/application/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { pipe } from 'fp-ts/lib/pipeable'; | ||
import { tryCatch, fold } from 'fp-ts/lib/Either'; | ||
|
||
export const validateRegExpString = (s: string) => | ||
pipe( | ||
tryCatch( | ||
() => new RegExp(s), | ||
e => (e as Error).message | ||
), | ||
fold( | ||
(errorMessage: string) => errorMessage, | ||
() => '' | ||
) | ||
); |