From 3948f61ef2b70e6d81178e63b20ece99958de2ec Mon Sep 17 00:00:00 2001 From: Sloane Perrault Date: Mon, 3 Apr 2023 12:58:11 -0400 Subject: [PATCH] [Enterprise Search] Search Applications - Switch to only show conflicts on schema page (#154149) ## Summary https://user-images.githubusercontent.com/1699281/229123456-922093c2-3218-4fb5-b26e-548bfd670f45.mov ### Checklist Delete any items that are not applicable to this PR. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [x] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) --- .../components/engine/engine_schema.tsx | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/engine/engine_schema.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/engine/engine_schema.tsx index 8a5bae680e34e..76bae7ec6ee1f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/engine/engine_schema.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/engine/engine_schema.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState, useCallback, useMemo } from 'react'; import { useActions, useValues } from 'kea'; @@ -19,6 +19,7 @@ import { EuiIcon, EuiLink, EuiPanel, + EuiSwitch, EuiText, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; @@ -143,12 +144,23 @@ const SchemaFieldDetails: React.FC<{ schemaField: SchemaField }> = ({ schemaFiel export const EngineSchema: React.FC = () => { const { engineName } = useValues(EngineIndicesLogic); + const [onlyShowConflicts, setOnlyShowConflicts] = useState(false); const { isLoadingEngineSchema, schemaFields } = useValues(EngineViewLogic); const { fetchEngineSchema } = useActions(EngineViewLogic); const [itemIdToExpandedRowMap, setItemIdToExpandedRowMap] = useState>( {} ); + const toggleOnlyShowConflicts = useCallback(() => { + setOnlyShowConflicts(!onlyShowConflicts); + setItemIdToExpandedRowMap({}); + }, [onlyShowConflicts]); + + const filteredSchemaFields = useMemo(() => { + if (onlyShowConflicts) return schemaFields.filter((field) => field.type === 'conflict'); + return schemaFields; + }, [onlyShowConflicts, schemaFields]); + useEffect(() => { fetchEngineSchema({ engineName }); }, [engineName]); @@ -288,16 +300,28 @@ export const EngineSchema: React.FC = () => { }} engineName={engineName} > - <> + + + + - + ); };