Skip to content

Commit

Permalink
[App Search] Small route fixes/updates (#98556)
Browse files Browse the repository at this point in the history
* Various route URL updates

- Snake case Kibana routes
- Remove unnecessary extra subdirectory pathing

* Fix missing ability check

- There isn't currently a role that would fail the check, but since the nav link is wrapped in the role, we might as well copy it and look at our role checks in the 8.0 refactor

* fix test
  • Loading branch information
Constance authored Apr 28, 2021
1 parent 23e5685 commit 794e040
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Loading } from '../../../shared/loading';
import { AnalyticsRouter } from '../analytics';
import { ApiLogs } from '../api_logs';
import { CurationsRouter } from '../curations';
import { Documents, DocumentDetail } from '../documents';
import { EngineOverview } from '../engine_overview';
import { RelevanceTuning } from '../relevance_tuning';
import { ResultSettings } from '../result_settings';
Expand Down Expand Up @@ -103,6 +104,14 @@ describe('EngineRouter', () => {
expect(wrapper.find(AnalyticsRouter)).toHaveLength(1);
});

it('renders a documents view', () => {
setMockValues({ ...values, myRole: { canViewEngineDocuments: true } });
const wrapper = shallow(<EngineRouter />);

expect(wrapper.find(Documents)).toHaveLength(1);
expect(wrapper.find(DocumentDetail)).toHaveLength(1);
});

it('renders a synonyms view', () => {
setMockValues({ ...values, myRole: { canManageEngineSynonyms: true } });
const wrapper = shallow(<EngineRouter />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chro
import { Loading } from '../../../shared/loading';
import { AppLogic } from '../../app_logic';

// TODO: Uncomment and add more routes as we migrate them
import {
ENGINES_PATH,
ENGINE_ANALYTICS_PATH,
Expand Down Expand Up @@ -50,7 +49,7 @@ export const EngineRouter: React.FC = () => {
const {
myRole: {
canViewEngineAnalytics,
// canViewEngineDocuments,
canViewEngineDocuments,
// canViewEngineSchema,
// canViewEngineCrawler,
canViewMetaEngineSourceEngines,
Expand Down Expand Up @@ -93,12 +92,16 @@ export const EngineRouter: React.FC = () => {
<AnalyticsRouter />
</Route>
)}
<Route path={ENGINE_DOCUMENT_DETAIL_PATH}>
<DocumentDetail />
</Route>
<Route path={ENGINE_DOCUMENTS_PATH}>
<Documents />
</Route>
{canViewEngineDocuments && (
<Route path={ENGINE_DOCUMENT_DETAIL_PATH}>
<DocumentDetail />
</Route>
)}
{canViewEngineDocuments && (
<Route path={ENGINE_DOCUMENTS_PATH}>
<Documents />
</Route>
)}
{canManageEngineCurations && (
<Route path={ENGINE_CURATIONS_PATH}>
<CurationsRouter />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('AppSearchNav', () => {
setMockValues({ myRole: { canViewSettings: true } });
const wrapper = shallow(<AppSearchNav />);

expect(wrapper.find(SideNavLink).last().prop('to')).toEqual('/settings/account');
expect(wrapper.find(SideNavLink).last().prop('to')).toEqual('/settings');
});

it('renders the Credentials link', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const DOCS_PREFIX = docLinks.appSearchBase;
export const ROOT_PATH = '/';
export const SETUP_GUIDE_PATH = '/setup_guide';
export const LIBRARY_PATH = '/library';
export const SETTINGS_PATH = '/settings/account';
export const SETTINGS_PATH = '/settings';
export const CREDENTIALS_PATH = '/credentials';

export const ROLE_MAPPINGS_PATH = '/role_mappings';
Expand All @@ -21,9 +21,7 @@ export const ROLE_MAPPING_NEW_PATH = `${ROLE_MAPPINGS_PATH}/new`;

export const ENGINES_PATH = '/engines';
export const ENGINE_CREATION_PATH = '/engine_creation';

export const ENGINE_PATH = `${ENGINES_PATH}/:engineName`;
export const SAMPLE_ENGINE_PATH = `${ENGINES_PATH}/national-parks-demo`;

export const ENGINE_ANALYTICS_PATH = `${ENGINE_PATH}/analytics`;
export const ENGINE_ANALYTICS_TOP_QUERIES_PATH = `${ENGINE_ANALYTICS_PATH}/top_queries`;
Expand All @@ -48,11 +46,11 @@ export const META_ENGINE_SOURCE_ENGINES_PATH = `${ENGINE_PATH}/engines`;

export const ENGINE_RELEVANCE_TUNING_PATH = `${ENGINE_PATH}/relevance_tuning`;
export const ENGINE_SYNONYMS_PATH = `${ENGINE_PATH}/synonyms`;
export const ENGINE_RESULT_SETTINGS_PATH = `${ENGINE_PATH}/result-settings`;
export const ENGINE_RESULT_SETTINGS_PATH = `${ENGINE_PATH}/result_settings`;

export const ENGINE_CURATIONS_PATH = `${ENGINE_PATH}/curations`;
export const ENGINE_CURATIONS_NEW_PATH = `${ENGINE_CURATIONS_PATH}/new`;
export const ENGINE_CURATION_PATH = `${ENGINE_CURATIONS_PATH}/:curationId`;

export const ENGINE_SEARCH_UI_PATH = `${ENGINE_PATH}/reference_application/new`;
export const ENGINE_SEARCH_UI_PATH = `${ENGINE_PATH}/search_ui`;
export const ENGINE_API_LOGS_PATH = `${ENGINE_PATH}/api_logs`;

0 comments on commit 794e040

Please sign in to comment.