Skip to content

Commit

Permalink
adds breadcrumbs to be able to navigate back to main page
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Jul 28, 2023
1 parent 7b6d14d commit dab42ee
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
10 changes: 10 additions & 0 deletions examples/response_stream/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const PLUGIN_ID = 'response-stream';
export const PLUGIN_NAME = 'response stream';
16 changes: 16 additions & 0 deletions examples/response_stream/public/mount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { CoreSetup, CoreStart, AppMountParameters } from '@kbn/core/public';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { PLUGIN_NAME } from '../common/constants';
import { ResponseStreamStartPlugins } from './plugin';
import { App } from './containers/app';

Expand All @@ -24,6 +25,21 @@ export const mount =
async ({ appBasePath, element }: AppMountParameters) => {
const [core, plugins] = await coreSetup.getStartServices();
const deps: ResponseStreamDeps = { appBasePath, core, plugins };

core.chrome.setBreadcrumbs([
{
text: 'Developer examples',
href: `/app/developerExamples`,
onClick: (e) => {
e.preventDefault();
core.application.navigateToApp('developerExamples');
},
},
{
text: PLUGIN_NAME,
},
]);

const reactElement = (
<KibanaContextProvider services={deps}>
<App />
Expand Down
9 changes: 5 additions & 4 deletions examples/response_stream/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { Plugin, CoreSetup, AppNavLinkStatus } from '@kbn/core/public';
import { DeveloperExamplesSetup } from '@kbn/developer-examples-plugin/public';
import { PLUGIN_ID, PLUGIN_NAME } from '../common/constants';
import { mount } from './mount';

export interface ResponseStreamSetupPlugins {
Expand All @@ -23,15 +24,15 @@ export class ResponseStreamPlugin implements Plugin {
{ developerExamples }: ResponseStreamSetupPlugins
) {
core.application.register({
id: 'response-stream',
title: 'response stream',
id: PLUGIN_ID,
title: PLUGIN_NAME,
navLinkStatus: AppNavLinkStatus.hidden,
mount: mount(core),
});

developerExamples.register({
appId: 'response-stream',
title: 'response stream',
appId: PLUGIN_ID,
title: PLUGIN_NAME,
description:
'This example demonstrates how to stream chunks of data to the client with just a single request.',
links: [
Expand Down
5 changes: 3 additions & 2 deletions examples/response_stream/public/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import React from 'react';
import { PLUGIN_ID, PLUGIN_NAME } from '../common/constants';
import { PageSimpleStringStream } from './containers/app/pages/page_simple_string_stream';
import { PageReducerStream } from './containers/app/pages/page_reducer_stream';

Expand All @@ -24,8 +25,8 @@ interface RouteDef {

export const routes: RouteSectionDef[] = [
{
title: 'response stream',
id: 'responseStream',
title: PLUGIN_NAME,
id: PLUGIN_ID,
items: [
{
title: 'Simple string stream',
Expand Down

0 comments on commit dab42ee

Please sign in to comment.