[Workplace Search] Move Personal Dashboard link to header (#87244)

* Remove comment

We aren’t going to use icons like we have in ent-search

* Add new constant

* Use constant instead of inline i18n

* Add link to top bar

The external href to sources will be changed once that component is built

* Remove link from sidebar

* Update i18n translation key names

CI was failing and this should fix it

* Alphabetize items
This commit is contained in:
Scotty Bollinger 2021-01-05 10:12:03 -06:00 committed by GitHub
parent 81887b7400
commit c69eaf872a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 62 additions and 46 deletions

View file

@ -19,11 +19,23 @@ describe('WorkplaceSearchHeaderActions', () => {
expect(wrapper.isEmptyRender()).toBe(true);
});
it('renders a link to the personal dashboard', () => {
externalUrl.enterpriseSearchUrl = 'http://localhost:3002';
const wrapper = shallow(<WorkplaceSearchHeaderActions />);
expect(wrapper.find(EuiButtonEmpty).first().prop('href')).toEqual(
'http://localhost:3002/ws/sources'
);
});
it('renders a link to the search application', () => {
externalUrl.enterpriseSearchUrl = 'http://localhost:3002';
const wrapper = shallow(<WorkplaceSearchHeaderActions />);
expect(wrapper.find(EuiButtonEmpty).prop('href')).toEqual('http://localhost:3002/ws/search');
expect(wrapper.find(EuiButtonEmpty).last().prop('href')).toEqual(
'http://localhost:3002/ws/search'
);
});
});

View file

@ -5,26 +5,33 @@
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiButtonEmpty, EuiText } from '@elastic/eui';
import { externalUrl, getWorkplaceSearchUrl } from '../../../shared/enterprise_search_url';
import { NAV } from '../../constants';
export const WorkplaceSearchHeaderActions: React.FC = () => {
if (!externalUrl.enterpriseSearchUrl) return null;
return (
<EuiButtonEmpty
href={getWorkplaceSearchUrl('/search')}
target="_blank"
iconType="search"
style={{ marginRight: 5 }}
>
<EuiText size="s">
{i18n.translate('xpack.enterpriseSearch.workplaceSearch.headerActions.searchApplication', {
defaultMessage: 'Go to search application',
})}
</EuiText>
</EuiButtonEmpty>
<>
<EuiButtonEmpty
href={getWorkplaceSearchUrl('/sources')}
target="_blank"
iconType="user"
style={{ marginRight: 5 }}
>
<EuiText size="s">{NAV.PERSONAL_DASHBOARD}</EuiText>
</EuiButtonEmpty>
<EuiButtonEmpty
href={getWorkplaceSearchUrl('/search')}
target="_blank"
iconType="search"
style={{ marginRight: 5 }}
>
<EuiText size="s">{NAV.SEARCH}</EuiText>
</EuiButtonEmpty>
</>
);
};

View file

@ -18,6 +18,6 @@ describe('WorkplaceSearchNav', () => {
expect(wrapper.find(SideNav)).toHaveLength(1);
expect(wrapper.find(SideNavLink).first().prop('to')).toEqual('/');
expect(wrapper.find(SideNavLink)).toHaveLength(7);
expect(wrapper.find(SideNavLink)).toHaveLength(6);
});
});

View file

@ -26,32 +26,26 @@ interface Props {
groupsSubNav?: React.ReactNode;
}
export const WorkplaceSearchNav: React.FC<Props> = ({ sourcesSubNav, groupsSubNav }) => {
// TODO: icons
return (
<SideNav product={WORKPLACE_SEARCH_PLUGIN}>
<SideNavLink to="/" isRoot>
{NAV.OVERVIEW}
</SideNavLink>
<SideNavLink to={SOURCES_PATH} subNav={sourcesSubNav}>
{NAV.SOURCES}
</SideNavLink>
<SideNavLink to={GROUPS_PATH} subNav={groupsSubNav}>
{NAV.GROUPS}
</SideNavLink>
<SideNavLink isExternal to={getWorkplaceSearchUrl(`#${ROLE_MAPPINGS_PATH}`)}>
{NAV.ROLE_MAPPINGS}
</SideNavLink>
<SideNavLink isExternal to={getWorkplaceSearchUrl(`#${SECURITY_PATH}`)}>
{NAV.SECURITY}
</SideNavLink>
<SideNavLink isExternal to={getWorkplaceSearchUrl(ORG_SETTINGS_PATH)}>
{NAV.SETTINGS}
</SideNavLink>
<EuiSpacer />
<SideNavLink isExternal to={getWorkplaceSearchUrl(`#${SOURCES_PATH}`)}>
{NAV.PERSONAL_DASHBOARD}
</SideNavLink>
</SideNav>
);
};
export const WorkplaceSearchNav: React.FC<Props> = ({ sourcesSubNav, groupsSubNav }) => (
<SideNav product={WORKPLACE_SEARCH_PLUGIN}>
<SideNavLink to="/" isRoot>
{NAV.OVERVIEW}
</SideNavLink>
<SideNavLink to={SOURCES_PATH} subNav={sourcesSubNav}>
{NAV.SOURCES}
</SideNavLink>
<SideNavLink to={GROUPS_PATH} subNav={groupsSubNav}>
{NAV.GROUPS}
</SideNavLink>
<SideNavLink isExternal to={getWorkplaceSearchUrl(`#${ROLE_MAPPINGS_PATH}`)}>
{NAV.ROLE_MAPPINGS}
</SideNavLink>
<SideNavLink isExternal to={getWorkplaceSearchUrl(`#${SECURITY_PATH}`)}>
{NAV.SECURITY}
</SideNavLink>
<SideNavLink isExternal to={getWorkplaceSearchUrl(ORG_SETTINGS_PATH)}>
{NAV.SETTINGS}
</SideNavLink>
<EuiSpacer />
</SideNav>
);

View file

@ -52,6 +52,9 @@ export const NAV = {
defaultMessage: 'View my personal dashboard',
}
),
SEARCH: i18n.translate('xpack.enterpriseSearch.workplaceSearch.nav.searchApplication', {
defaultMessage: 'Go to search application',
}),
};
export const MAX_TABLE_ROW_ICONS = 3;

View file

@ -6964,13 +6964,13 @@
"xpack.enterpriseSearch.workplaceSearch.groups.sourcesModalTitle": "{groupName}と共有するコンテンツソースを選択",
"xpack.enterpriseSearch.workplaceSearch.groups.userListCount": "{maxVisibleUsers}/{numUsers}ユーザーを表示しています。",
"xpack.enterpriseSearch.workplaceSearch.groups.usersModalLabel": "ユーザー",
"xpack.enterpriseSearch.workplaceSearch.headerActions.searchApplication": "検索アプリケーションに移動",
"xpack.enterpriseSearch.workplaceSearch.nav.groups": "グループ",
"xpack.enterpriseSearch.workplaceSearch.nav.groups.groupOverview": "概要",
"xpack.enterpriseSearch.workplaceSearch.nav.groups.sourcePrioritization": "ソースの優先度",
"xpack.enterpriseSearch.workplaceSearch.nav.overview": "概要",
"xpack.enterpriseSearch.workplaceSearch.nav.personalDashboard": "個人のダッシュボードを表示",
"xpack.enterpriseSearch.workplaceSearch.nav.roleMappings": "ロールマッピング",
"xpack.enterpriseSearch.workplaceSearch.nav.searchApplication": "検索アプリケーションに移動",
"xpack.enterpriseSearch.workplaceSearch.nav.security": "セキュリティ",
"xpack.enterpriseSearch.workplaceSearch.nav.settings": "設定",
"xpack.enterpriseSearch.workplaceSearch.nav.sources": "ソース",

View file

@ -6970,13 +6970,13 @@
"xpack.enterpriseSearch.workplaceSearch.groups.sourcesModalTitle": "选择要与 {groupName} 共享的内容源",
"xpack.enterpriseSearch.workplaceSearch.groups.userListCount": "正在显示 {numUsers} 个用户中的 {maxVisibleUsers} 个。",
"xpack.enterpriseSearch.workplaceSearch.groups.usersModalLabel": "用户",
"xpack.enterpriseSearch.workplaceSearch.headerActions.searchApplication": "前往搜索应用程序",
"xpack.enterpriseSearch.workplaceSearch.nav.groups": "组",
"xpack.enterpriseSearch.workplaceSearch.nav.groups.groupOverview": "概览",
"xpack.enterpriseSearch.workplaceSearch.nav.groups.sourcePrioritization": "源的优先级排序",
"xpack.enterpriseSearch.workplaceSearch.nav.overview": "概览",
"xpack.enterpriseSearch.workplaceSearch.nav.personalDashboard": "查看我的个人仪表板",
"xpack.enterpriseSearch.workplaceSearch.nav.roleMappings": "角色映射",
"xpack.enterpriseSearch.workplaceSearch.nav.searchApplication": "前往搜索应用程序",
"xpack.enterpriseSearch.workplaceSearch.nav.security": "安全",
"xpack.enterpriseSearch.workplaceSearch.nav.settings": "设置",
"xpack.enterpriseSearch.workplaceSearch.nav.sources": "源",