-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[App Search] Implement initial Engine routing/navigation #82549
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
64f2cde
[Setup] Update routes + role privileges
cee-chen 2f3f574
Add new EngineNav and EngineRouter components
cee-chen 150a95a
Update existing components to use new EngineRouter/EngineNav
cee-chen de4752e
Add App Search engine label & new SideNavItem component
cee-chen 1bed338
Add EngineRouter breadcrumbs
cee-chen 5086128
[Refactor] DRY out i18n constants
cee-chen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...k/plugins/enterprise_search/public/applications/app_search/components/engine/constants.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,58 @@ | ||
/* | ||
* 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'; | ||
|
||
// TODO: It's very likely that we'll move these i18n constants to their respective component | ||
// folders once those are migrated over. This is a temporary way of DRYing them out for now. | ||
|
||
export const ENGINES_TITLE = i18n.translate('xpack.enterpriseSearch.appSearch.engines.title', { | ||
defaultMessage: 'Engines', | ||
}); | ||
|
||
export const OVERVIEW_TITLE = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.overview.title', | ||
{ defaultMessage: 'Overview' } | ||
); | ||
export const ANALYTICS_TITLE = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.analytics.title', | ||
{ defaultMessage: 'Analytics' } | ||
); | ||
export const DOCUMENTS_TITLE = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.documents.title', | ||
{ defaultMessage: 'Documents' } | ||
); | ||
export const SCHEMA_TITLE = i18n.translate('xpack.enterpriseSearch.appSearch.engine.schema.title', { | ||
defaultMessage: 'Schema', | ||
}); | ||
export const CRAWLER_TITLE = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.crawler.title', | ||
{ defaultMessage: 'Crawler' } | ||
); | ||
export const RELEVANCE_TUNING_TITLE = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.relevanceTuning.title', | ||
{ defaultMessage: 'Relevance Tuning' } | ||
); | ||
export const SYNONYMS_TITLE = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.synonyms.title', | ||
{ defaultMessage: 'Synonyms' } | ||
); | ||
export const CURATIONS_TITLE = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.curations.title', | ||
{ defaultMessage: 'Curations' } | ||
); | ||
export const RESULT_SETTINGS_TITLE = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.resultSettings.title', | ||
{ defaultMessage: 'Result Settings' } | ||
); | ||
export const SEARCH_UI_TITLE = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.searchUI.title', | ||
{ defaultMessage: 'Search UI' } | ||
); | ||
export const API_LOGS_TITLE = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.apiLogs.title', | ||
{ defaultMessage: 'API Logs' } | ||
); |
17 changes: 17 additions & 0 deletions
17
...lugins/enterprise_search/public/applications/app_search/components/engine/engine_nav.scss
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,17 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
.appSearchNavEngineLabel { | ||
padding-top: $euiSizeS; | ||
padding-bottom: $euiSizeS; | ||
|
||
.euiText { | ||
font-weight: $euiFontWeightMedium; | ||
} | ||
.euiBadge { | ||
margin-top: $euiSizeXS; | ||
} | ||
} |
138 changes: 138 additions & 0 deletions
138
...ns/enterprise_search/public/applications/app_search/components/engine/engine_nav.test.tsx
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,138 @@ | ||
/* | ||
* 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 '../../../__mocks__/react_router_history.mock'; | ||
import { setMockValues } from '../../../__mocks__/kea.mock'; | ||
|
||
import React from 'react'; | ||
import { shallow, mount } from 'enzyme'; | ||
import { Switch, useParams } from 'react-router-dom'; | ||
import { EuiBadge } from '@elastic/eui'; | ||
|
||
import { EngineRouter, EngineNav } from './'; | ||
|
||
describe('EngineRouter', () => { | ||
it('renders a default engine overview', () => { | ||
setMockValues({ myRole: {} }); | ||
const wrapper = shallow(<EngineRouter />); | ||
|
||
expect(wrapper.find(Switch)).toHaveLength(1); | ||
expect(wrapper.find('[data-test-subj="EngineOverviewTODO"]')).toHaveLength(1); | ||
}); | ||
|
||
it('renders an analytics view', () => { | ||
setMockValues({ myRole: { canViewEngineAnalytics: true } }); | ||
const wrapper = shallow(<EngineRouter />); | ||
|
||
expect(wrapper.find('[data-test-subj="AnalyticsTODO"]')).toHaveLength(1); | ||
}); | ||
}); | ||
|
||
describe('EngineNav', () => { | ||
beforeEach(() => { | ||
(useParams as jest.Mock).mockReturnValue({ engineName: 'some-engine' }); | ||
}); | ||
|
||
it('does not render without an engine name', () => { | ||
setMockValues({ myRole: {} }); | ||
(useParams as jest.Mock).mockReturnValue({ engineName: '' }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.isEmptyRender()).toBe(true); | ||
}); | ||
|
||
it('renders an engine label', () => { | ||
setMockValues({ myRole: {} }); | ||
const wrapper = mount(<EngineNav />); | ||
|
||
const label = wrapper.find('[data-test-subj="EngineLabel"]').last(); | ||
expect(label.text()).toEqual(expect.stringContaining('SOME-ENGINE')); | ||
|
||
// TODO: Test sample & meta engine conditional rendering | ||
expect(label.find(EuiBadge).text()).toEqual('SAMPLE ENGINE'); | ||
}); | ||
|
||
it('renders a default engine overview link', () => { | ||
setMockValues({ myRole: {} }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.find('[data-test-subj="EngineOverviewLink"]')).toHaveLength(1); | ||
}); | ||
|
||
it('renders an analytics link', () => { | ||
setMockValues({ myRole: { canViewEngineAnalytics: true } }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.find('[data-test-subj="EngineAnalyticsLink"]')).toHaveLength(1); | ||
}); | ||
|
||
it('renders a documents link', () => { | ||
setMockValues({ myRole: { canViewEngineDocuments: true } }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.find('[data-test-subj="EngineDocumentsLink"]')).toHaveLength(1); | ||
}); | ||
|
||
it('renders a schema link', () => { | ||
setMockValues({ myRole: { canViewEngineSchema: true } }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.find('[data-test-subj="EngineSchemaLink"]')).toHaveLength(1); | ||
|
||
// TODO: Schema warning icon | ||
}); | ||
|
||
// TODO: Unskip when EngineLogic is migrated | ||
it.skip('renders a crawler link', () => { | ||
setMockValues({ myRole: { canViewEngineCrawler: true } }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.find('[data-test-subj="EngineCrawlerLink"]')).toHaveLength(1); | ||
|
||
// TODO: Test that the crawler link does NOT show up for meta/sample engines | ||
}); | ||
|
||
// TODO: Unskip when EngineLogic is migrated | ||
it.skip('renders a meta engine source engines link', () => { | ||
setMockValues({ myRole: { canViewMetaEngineSourceEngines: true } }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.find('[data-test-subj="MetaEngineEnginesLink"]')).toHaveLength(1); | ||
|
||
// TODO: Test that the crawler link does NOT show up for non-meta engines | ||
}); | ||
|
||
it('renders a relevance tuning link', () => { | ||
setMockValues({ myRole: { canManageEngineRelevanceTuning: true } }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.find('[data-test-subj="EngineRelevanceTuningLink"]')).toHaveLength(1); | ||
|
||
// TODO: Boost error icon | ||
}); | ||
|
||
it('renders a synonyms link', () => { | ||
setMockValues({ myRole: { canManageEngineSynonyms: true } }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.find('[data-test-subj="EngineSynonymsLink"]')).toHaveLength(1); | ||
}); | ||
|
||
it('renders a curations link', () => { | ||
setMockValues({ myRole: { canManageEngineCurations: true } }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.find('[data-test-subj="EngineCurationsLink"]')).toHaveLength(1); | ||
}); | ||
|
||
it('renders a results settings link', () => { | ||
setMockValues({ myRole: { canManageEngineResultSettings: true } }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.find('[data-test-subj="EngineResultSettingsLink"]')).toHaveLength(1); | ||
}); | ||
|
||
it('renders a Search UI link', () => { | ||
setMockValues({ myRole: { canManageEngineSearchUi: true } }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.find('[data-test-subj="EngineSearchUILink"]')).toHaveLength(1); | ||
}); | ||
|
||
it('renders an API logs link', () => { | ||
setMockValues({ myRole: { canViewEngineApiLogs: true } }); | ||
const wrapper = shallow(<EngineNav />); | ||
expect(wrapper.find('[data-test-subj="EngineAPILogsLink"]')).toHaveLength(1); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely probably doesn't belong in this file but I plan on moving it/DRYing out more i18n const's in a follow up PR here shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow up cleanup PR after this: cee-chen/kibana@engine-nav...consts-refactor