Skip to content

Commit

Permalink
[Workplace Search] Refactor nav constants (#82646)
Browse files Browse the repository at this point in the history
* 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

* Extract remaining nav constants

* Fix links to NAV in routers

* Use constant for path

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
scottybollinger and kibanamachine committed Nov 9, 2020
1 parent 23f3857 commit e50d846
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -13,7 +12,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,
Expand All @@ -29,38 +28,26 @@ export const WorkplaceSearchNav: React.FC = () => {
return (
<SideNav product={WORKPLACE_SEARCH_PLUGIN}>
<SideNavLink to="/" isRoot>
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.overview', {
defaultMessage: 'Overview',
})}
{NAV.OVERVIEW}
</SideNavLink>
<SideNavLink isExternal to={getWorkplaceSearchUrl(ORG_SOURCES_PATH)}>
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.sources', {
defaultMessage: 'Sources',
})}
{NAV.SOURCES}
</SideNavLink>
<SideNavLink to={GROUPS_PATH} subNav={<GroupSubNav />}>
{NAV.GROUPS}
</SideNavLink>
<SideNavLink isExternal to={getWorkplaceSearchUrl(`#${ROLE_MAPPINGS_PATH}`)}>
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.roleMappings', {
defaultMessage: 'Role Mappings',
})}
{NAV.ROLE_MAPPINGS}
</SideNavLink>
<SideNavLink isExternal to={getWorkplaceSearchUrl(`#${SECURITY_PATH}`)}>
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.security', {
defaultMessage: 'Security',
})}
{NAV.SECURITY}
</SideNavLink>
<SideNavLink isExternal to={getWorkplaceSearchUrl(ORG_SETTINGS_PATH)}>
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.settings', {
defaultMessage: 'Settings',
})}
{NAV.SETTINGS}
</SideNavLink>
<EuiSpacer />
<SideNavLink isExternal to={getWorkplaceSearchUrl(`#${SOURCES_PATH}`)}>
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.personalDashboard', {
defaultMessage: 'View my personal dashboard',
})}
{NAV.PERSONAL_DASHBOARD}
</SideNavLink>
</SideNav>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,44 @@
* 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 = {
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',
}),
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' }
),
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -56,7 +56,7 @@ export const WorkplaceSearchConfigured: React.FC<IInitialAppData> = (props) => {
<ErrorState />
) : (
<Switch>
<Route path="/groups">
<Route path={GROUPS_PATH}>
<GroupsRouter />
</Route>
<Route>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -23,7 +23,7 @@ export const GroupSubNav: React.FC = () => {

return (
<>
<SideNavLink to={getGroupPath(id)}>{NAV.OVERVIEW}</SideNavLink>
<SideNavLink to={getGroupPath(id)}>{NAV.GROUP_OVERVIEW}</SideNavLink>
<SideNavLink to={getGroupSourcePrioritizationPath(id)}>
{NAV.SOURCE_PRIORITIZATION}
</SideNavLink>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit e50d846

Please sign in to comment.