Skip to content

Commit

Permalink
Fix routing and breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed May 10, 2020
1 parent 2b0e90b commit 5f540a3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export { INDEX_NAMES } from './index_names';
export { PLUGIN } from './plugin';
export { LICENSES, REQUIRED_LICENSES, REQUIRED_ROLES } from './security';
export { TABLE_CONFIG } from './table';
export const BASE_PATH = '/management/beats_management';
export const BASE_PATH = '/management/beats/beats_management';
2 changes: 1 addition & 1 deletion x-pack/plugins/beats_management/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const renderApp = (
ReactDOM.render(
<ThemeProvider theme={{ eui: euiVars }}>
<services.I18nContext>
<HashRouter basename="/management/beats/beats">
<HashRouter basename="/management/beats/beats_management">
<UnstatedProvider inject={[new BeatsContainer(libs), new TagsContainer(libs)]}>
<BreadcrumbProvider useGlobalBreadcrumbs={libs.framework.versionGreaterThen('6.7.0')}>
<Subscribe to={[BeatsContainer, TagsContainer]}>
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/beats_management/public/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { BeatsManagementConfigType } from '../common';
async function startApp(libs: FrontendLibs, core: CoreSetup<StartDeps>) {
await libs.framework.waitUntilFrameworkReady();

if (true || libs.framework.licenseIsAtLeast('standard')) {
if (libs.framework.licenseIsAtLeast('standard')) {
libs.framework.registerManagementSection({
id: 'beats',
name: i18n.translate('xpack.beatsManagement.centralManagementSectionLabel', {
Expand All @@ -31,6 +31,7 @@ async function startApp(libs: FrontendLibs, core: CoreSetup<StartDeps>) {

libs.framework.registerManagementUI({
sectionId: 'beats',
appId: 'beats_management',
name: i18n.translate('xpack.beatsManagement.centralManagementLinkLabel', {
defaultMessage: 'Central Management',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const Breadcrumb: React.FC<BreadcrumbProps> = ({ title, path, parentBread
{context => (
<BreadcrumbManager
text={title}
href={`#${BASE_PATH}${path}`}
href={path ? `#${BASE_PATH}${path}` : `#${BASE_PATH}`}
parents={parentBreadcrumbs}
context={context}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ export interface FrameworkAdapter {
// Methods
waitUntilFrameworkReady(): Promise<void>;
registerManagementSection(settings: {
id?: string;
id: string;
name: string;
iconName: string;
order?: number;
}): void;
registerManagementUI(settings: {
sectionId?: string;
sectionId: string;
appId: string;
name: string;
basePath: string;
visable?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export class KibanaFrameworkAdapter implements FrameworkAdapter {
enabled: license.getFeature('security').isEnabled,
available: license.getFeature('security').isAvailable,
},
// TODO: this really has nothing to do with licensing, but should be server config
settings: this.config,
};
} catch (e) {
Expand Down Expand Up @@ -104,41 +103,38 @@ export class KibanaFrameworkAdapter implements FrameworkAdapter {
}

public registerManagementSection(settings: {
id?: string;
id: string;
name: string;
iconName: string;
order?: number;
}) {
const sectionId = settings.id || this.PLUGIN_ID;

this.management.sections.register({
id: sectionId,
id: settings.id,
title: settings.name,
euiIconType: settings.iconName,
order: settings.order || 30,
});
}

public registerManagementUI(settings: {
sectionId?: string;
sectionId: string;
appId: string;
name: string;
basePath: string;
visable?: boolean;
order?: number;
mount: RegisterManagementAppArgs['mount'];
}) {
const sectionId = settings.sectionId || this.PLUGIN_ID;

const section = this.management.sections.getSection(sectionId);
const section = this.management.sections.getSection(settings.sectionId);

if (!section) {
throw new Error(
`registerManagementUI was called with a sectionId of ${sectionId}, and that is is not yet regestered as a section`
`registerManagementUI was called with a sectionId of ${settings.sectionId}, and that is is not yet regestered as a section`
);
}

section.registerApp({
id: sectionId,
id: settings.appId,
title: settings.name,
order: settings.order || 30,
mount: settings.mount,
Expand Down

0 comments on commit 5f540a3

Please sign in to comment.