From 5047e946e15a9a6d1ee6f7ccbc3c8c284e902a9c Mon Sep 17 00:00:00 2001 From: scottybollinger Date: Wed, 4 Nov 2020 12:08:38 -0600 Subject: [PATCH 1/4] Move NAV constants to top level This was only needed locally in Groups but we can to store all nav constants in the global constants file --- .../components/layout/nav.tsx | 2 +- .../workplace_search/constants.ts | 17 ++++++++++++++++ .../views/groups/components/group_sub_nav.tsx | 4 ++-- .../views/groups/constants.ts | 20 ------------------- 4 files changed, 20 insertions(+), 23 deletions(-) delete mode 100644 x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/constants.ts diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/nav.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/nav.tsx index a454e3146f4d9..374905e65b860 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/nav.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/nav.tsx @@ -13,7 +13,7 @@ import { getWorkplaceSearchUrl } from '../../../shared/enterprise_search_url'; import { SideNav, SideNavLink } from '../../../shared/layout'; import { GroupSubNav } from '../../views/groups/components/group_sub_nav'; -import { NAV } from '../../views/groups/constants'; +import { NAV } from '../../constants'; import { ORG_SOURCES_PATH, diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/constants.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/constants.ts index 9f313a6995ad5..5ade3b26ac9d7 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/constants.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/constants.ts @@ -3,6 +3,23 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; + +export const NAV = { + GROUPS: i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.groups', { + defaultMessage: 'Groups', + }), + GROUP_OVERVIEW: i18n.translate( + 'xpack.enterpriseSearch.workplaceSearch.nav.groups.groupOverview', + { + defaultMessage: 'Overview', + } + ), + SOURCE_PRIORITIZATION: i18n.translate( + 'xpack.enterpriseSearch.workplaceSearch.nav.groups.sourcePrioritization', + { defaultMessage: 'Source Prioritization' } + ), +}; export const MAX_TABLE_ROW_ICONS = 3; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_sub_nav.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_sub_nav.tsx index a41cf6191eb64..ad19ad059fb40 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_sub_nav.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_sub_nav.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { useValues } from 'kea'; import { GroupLogic } from '../group_logic'; -import { NAV } from '../constants'; +import { NAV } from '../../../constants'; import { SideNavLink } from '../../../../shared/layout'; @@ -23,7 +23,7 @@ export const GroupSubNav: React.FC = () => { return ( <> - {NAV.OVERVIEW} + {NAV.GROUP_OVERVIEW} {NAV.SOURCE_PRIORITIZATION} diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/constants.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/constants.ts deleted file mode 100644 index 7c3d160017138..0000000000000 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/constants.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 { i18n } from '@kbn/i18n'; - -export const NAV = { - GROUPS: i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.groups', { - defaultMessage: 'Groups', - }), - OVERVIEW: i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.groups.groupOverview', { - defaultMessage: 'Overview', - }), - SOURCE_PRIORITIZATION: i18n.translate( - 'xpack.enterpriseSearch.workplaceSearch.nav.groups.sourcePrioritization', - { defaultMessage: 'Source Prioritization' } - ), -}; From 389706acb382be4eafd51c8f296a78b36afc316f Mon Sep 17 00:00:00 2001 From: scottybollinger Date: Wed, 4 Nov 2020 12:12:13 -0600 Subject: [PATCH 2/4] Extract remaining nav constants --- .../components/layout/nav.tsx | 25 +++++-------------- .../workplace_search/constants.ts | 21 ++++++++++++++++ 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/nav.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/nav.tsx index 374905e65b860..6fa6698e6b6ba 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/nav.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/layout/nav.tsx @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { i18n } from '@kbn/i18n'; import { EuiSpacer } from '@elastic/eui'; @@ -29,38 +28,26 @@ export const WorkplaceSearchNav: React.FC = () => { return ( - {i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.overview', { - defaultMessage: 'Overview', - })} + {NAV.OVERVIEW} - {i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.sources', { - defaultMessage: 'Sources', - })} + {NAV.SOURCES} }> {NAV.GROUPS} - {i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.roleMappings', { - defaultMessage: 'Role Mappings', - })} + {NAV.ROLE_MAPPINGS} - {i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.security', { - defaultMessage: 'Security', - })} + {NAV.SECURITY} - {i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.settings', { - defaultMessage: 'Settings', - })} + {NAV.SETTINGS} - {i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.personalDashboard', { - defaultMessage: 'View my personal dashboard', - })} + {NAV.PERSONAL_DASHBOARD} ); diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/constants.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/constants.ts index 5ade3b26ac9d7..3b911b87dea12 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/constants.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/constants.ts @@ -6,6 +6,12 @@ import { i18n } from '@kbn/i18n'; export const NAV = { + OVERVIEW: i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.overview', { + defaultMessage: 'Overview', + }), + SOURCES: i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.sources', { + defaultMessage: 'Sources', + }), GROUPS: i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.groups', { defaultMessage: 'Groups', }), @@ -19,6 +25,21 @@ export const NAV = { 'xpack.enterpriseSearch.workplaceSearch.nav.groups.sourcePrioritization', { defaultMessage: 'Source Prioritization' } ), + ROLE_MAPPINGS: i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.roleMappings', { + defaultMessage: 'Role Mappings', + }), + SECURITY: i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.security', { + defaultMessage: 'Security', + }), + SETTINGS: i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.settings', { + defaultMessage: 'Settings', + }), + PERSONAL_DASHBOARD: i18n.translate( + 'xpack.enterpriseSearch.workplaceSearch.nav.personalDashboard', + { + defaultMessage: 'View my personal dashboard', + } + ), }; export const MAX_TABLE_ROW_ICONS = 3; From df29c8fff8f40f15a58d131788c581ff58bfc55f Mon Sep 17 00:00:00 2001 From: scottybollinger Date: Wed, 4 Nov 2020 12:19:09 -0600 Subject: [PATCH 3/4] Fix links to NAV in routers --- .../applications/workplace_search/views/groups/group_router.tsx | 2 +- .../workplace_search/views/groups/groups_router.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_router.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_router.tsx index 1b6f0c4c49a05..822d966bfb8d2 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_router.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_router.tsx @@ -14,7 +14,7 @@ import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kiban import { SendWorkplaceSearchTelemetry as SendTelemetry } from '../../../shared/telemetry'; import { GROUP_SOURCE_PRIORITIZATION_PATH, GROUP_PATH } from '../../routes'; -import { NAV } from './constants'; +import { NAV } from '../../constants'; import { GroupLogic } from './group_logic'; import { ManageUsersModal } from './components/manage_users_modal'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_router.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_router.tsx index a4fe472065d90..326362a0ddfbc 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_router.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_router.tsx @@ -14,7 +14,7 @@ import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kiban import { SendWorkplaceSearchTelemetry as SendTelemetry } from '../../../shared/telemetry'; import { GROUP_PATH, GROUPS_PATH } from '../../routes'; -import { NAV } from './constants'; +import { NAV } from '../../constants'; import { GroupsLogic } from './groups_logic'; From a0fde7b6ade96ef40cfddf1b58a005e036c134d3 Mon Sep 17 00:00:00 2001 From: scottybollinger Date: Wed, 4 Nov 2020 12:21:17 -0600 Subject: [PATCH 4/4] Use constant for path --- .../public/applications/workplace_search/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.tsx index e22b9c6282f95..9875af7889447 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.tsx @@ -16,7 +16,7 @@ import { AppLogic } from './app_logic'; import { Layout } from '../shared/layout'; import { WorkplaceSearchNav, WorkplaceSearchHeaderActions } from './components/layout'; -import { SETUP_GUIDE_PATH } from './routes'; +import { GROUPS_PATH, SETUP_GUIDE_PATH } from './routes'; import { SetupGuide } from './views/setup_guide'; import { ErrorState } from './views/error_state'; @@ -56,7 +56,7 @@ export const WorkplaceSearchConfigured: React.FC = (props) => { ) : ( - +