Skip to content

Commit

Permalink
Switch to core application service (elastic#63443)
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed May 13, 2020
1 parent e544e5c commit 0ff0dcd
Show file tree
Hide file tree
Showing 339 changed files with 2,239 additions and 1,706 deletions.
8 changes: 4 additions & 4 deletions docs/api/features.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The API returns the following:
"id": "discover",
"name": "Discover",
"icon": "discoverApp",
"navLinkId": "kibana:discover",
"navLinkId": "discover",
"app": [
"kibana"
],
Expand Down Expand Up @@ -74,7 +74,7 @@ The API returns the following:
"id": "visualize",
"name": "Visualize",
"icon": "visualizeApp",
"navLinkId": "kibana:visualize",
"navLinkId": "visualize",
"app": [
"kibana"
],
Expand Down Expand Up @@ -121,7 +121,7 @@ The API returns the following:
"id": "dashboard",
"name": "Dashboard",
"icon": "dashboardApp",
"navLinkId": "kibana:dashboard",
"navLinkId": "dashboards",
"app": [
"kibana"
],
Expand Down Expand Up @@ -173,7 +173,7 @@ The API returns the following:
"id": "dev_tools",
"name": "Dev Tools",
"icon": "devToolsApp",
"navLinkId": "kibana:dev_tools",
"navLinkId": "dev_tools",
"app": [
"kibana"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ init(server) {
defaultMessage: 'Dev Tools',
}),
icon: 'devToolsApp',
navLinkId: 'kibana:dev_tools',
navLinkId: 'dev_tools',
app: ['kibana'],
catalogue: ['console', 'searchprofiler', 'grokdebugger'],
privileges: {
Expand Down Expand Up @@ -216,7 +216,7 @@ init(server) {
}),
order: 100,
icon: 'discoverApp',
navLinkId: 'kibana:discover',
navLinkId: 'discover',
app: ['kibana'],
catalogue: ['discover'],
privileges: {
Expand Down
2 changes: 1 addition & 1 deletion docs/user/dashboard.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ to view an embedded dashboard.
* Generate a PNG report

TIP: To create a link to a dashboard by title, use: +
`${domain}/${basepath?}/app/kibana#/dashboards?title=${yourdashboardtitle}`
`${domain}/${basepath?}/app/dashboards#/list?title=${yourdashboardtitle}`

TIP: When sharing a link to a dashboard snapshot, use the *Short URL*. Snapshot
URLs are long and can be problematic for Internet Explorer and other
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class ChromeService {
forceAppSwitcherNavigation$={navLinks.getForceAppSwitcherNavigation$()}
helpExtension$={helpExtension$.pipe(takeUntil(this.stop$))}
helpSupportUrl$={helpSupportUrl$.pipe(takeUntil(this.stop$))}
homeHref={http.basePath.prepend('/app/kibana#/home')}
homeHref={http.basePath.prepend('/app/home')}
isVisible$={this.isVisible$}
kibanaVersion={injectedMetadata.getKibanaVersion()}
legacyMode={injectedMetadata.getLegacyMode()}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/core/public/chrome/ui/header/collapsible_nav.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function mockProps() {
storage: new StubBrowserStorage(),
onIsOpenUpdate: () => {},
onIsLockedUpdate: () => {},
navigateToApp: () => {},
};
}

Expand Down
16 changes: 15 additions & 1 deletion src/core/public/chrome/ui/header/collapsible_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ interface Props {
storage?: Storage;
onIsLockedUpdate: OnIsLockedUpdate;
onIsOpenUpdate: (isOpen?: boolean) => void;
navigateToApp: (appId: string) => void;
}

export function CollapsibleNav({
Expand All @@ -89,6 +90,7 @@ export function CollapsibleNav({
onIsOpenUpdate,
homeHref,
id,
navigateToApp,
storage = window.localStorage,
}: Props) {
const lockRef = useRef<HTMLButtonElement>(null);
Expand Down Expand Up @@ -124,7 +126,19 @@ export function CollapsibleNav({
label: 'Home',
iconType: 'home',
href: homeHref,
onClick: () => onIsOpenUpdate(false),
onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
onIsOpenUpdate(false);
if (
event.isDefaultPrevented() ||
event.altKey ||
event.metaKey ||
event.ctrlKey
) {
return;
}
event.preventDefault();
navigateToApp('home');
},
},
]}
maxWidth="none"
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export class Header extends Component<HeaderProps, State> {
href={this.props.homeHref}
forceNavigation={this.state.forceNavigation}
navLinks={navLinks}
navigateToApp={this.props.application.navigateToApp}
/>
</EuiHeaderSectionItem>

Expand Down Expand Up @@ -287,6 +288,7 @@ export class Header extends Component<HeaderProps, State> {
this.toggleCollapsibleNavRef.current.focus();
}
}}
navigateToApp={this.props.application.navigateToApp}
/>
) : (
// TODO #64541
Expand Down
49 changes: 25 additions & 24 deletions src/core/public/chrome/ui/header/header_logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ function findClosestAnchor(element: HTMLElement): HTMLAnchorElement | void {
function onClick(
event: React.MouseEvent<HTMLAnchorElement>,
forceNavigation: boolean,
navLinks: NavLink[]
navLinks: NavLink[],
navigateToApp: (appId: string) => void
) {
const anchor = findClosestAnchor((event as any).nativeEvent.target);
if (!anchor) {
Expand All @@ -54,47 +55,47 @@ function onClick(
return;
}

if (
!forceNavigation ||
event.isDefaultPrevented() ||
event.altKey ||
event.metaKey ||
event.ctrlKey
) {
if (event.isDefaultPrevented() || event.altKey || event.metaKey || event.ctrlKey) {
return;
}

const toParsed = Url.parse(anchor.href);
const fromParsed = Url.parse(document.location.href);
const sameProto = toParsed.protocol === fromParsed.protocol;
const sameHost = toParsed.host === fromParsed.host;
const samePath = toParsed.path === fromParsed.path;
if (forceNavigation) {
const toParsed = Url.parse(anchor.href);
const fromParsed = Url.parse(document.location.href);
const sameProto = toParsed.protocol === fromParsed.protocol;
const sameHost = toParsed.host === fromParsed.host;
const samePath = toParsed.path === fromParsed.path;

if (sameProto && sameHost && samePath) {
if (toParsed.hash) {
document.location.reload();
}
if (sameProto && sameHost && samePath) {
if (toParsed.hash) {
document.location.reload();
}

// event.preventDefault() keeps the browser from seeing the new url as an update
// and even setting window.location does not mimic that behavior, so instead
// we use stopPropagation() to prevent angular from seeing the click and
// starting a digest cycle/attempting to handle it in the router.
event.stopPropagation();
// event.preventDefault() keeps the browser from seeing the new url as an update
// and even setting window.location does not mimic that behavior, so instead
// we use stopPropagation() to prevent angular from seeing the click and
// starting a digest cycle/attempting to handle it in the router.
event.stopPropagation();
}
} else {
navigateToApp('home');
event.preventDefault();
}
}

interface Props {
href: string;
navLinks: NavLink[];
forceNavigation: boolean;
navigateToApp: (appId: string) => void;
}

export function HeaderLogo({ href, forceNavigation, navLinks }: Props) {
export function HeaderLogo({ href, forceNavigation, navLinks, navigateToApp }: Props) {
return (
<EuiHeaderLogo
data-test-subj="logo"
iconType="logoElastic"
onClick={e => onClick(e, forceNavigation, navLinks)}
onClick={e => onClick(e, forceNavigation, navLinks, navigateToApp)}
href={href}
aria-label={i18n.translate('core.ui.chrome.headerGlobalNav.goHomePageIconAriaLabel', {
defaultMessage: 'Go to home page',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('default route provider', () => {

expect(status).toEqual(302);
expect(header).toMatchObject({
location: '/hello/app/kibana',
location: '/hello/app/home',
});
});

Expand All @@ -71,7 +71,7 @@ describe('default route provider', () => {
const { status, header } = await kbnTestServer.request.get(root, '/');
expect(status).toEqual(302);
expect(header).toMatchObject({
location: '/hello/app/kibana',
location: '/hello/app/home',
});
});

Expand Down
44 changes: 0 additions & 44 deletions src/legacy/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export default function(kibana) {
},

uiExports: {
hacks: ['plugins/kibana/dev_tools'],
app: {
id: 'kibana',
title: 'Kibana',
Expand All @@ -61,49 +60,6 @@ export default function(kibana) {
},
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
links: [
{
id: 'kibana:discover',
title: i18n.translate('kbn.discoverTitle', {
defaultMessage: 'Discover',
}),
order: 2000,
url: `${kbnBaseUrl}#/discover`,
euiIconType: 'discoverApp',
disableSubUrlTracking: true,
category: DEFAULT_APP_CATEGORIES.kibana,
},
{
id: 'kibana:visualize',
title: i18n.translate('kbn.visualizeTitle', {
defaultMessage: 'Visualize',
}),
order: 7000,
url: `${kbnBaseUrl}#/visualize`,
euiIconType: 'visualizeApp',
disableSubUrlTracking: true,
category: DEFAULT_APP_CATEGORIES.kibana,
},
{
id: 'kibana:dashboard',
title: i18n.translate('kbn.dashboardTitle', {
defaultMessage: 'Dashboard',
}),
order: 1000,
url: `${kbnBaseUrl}#/dashboards`,
euiIconType: 'dashboardApp',
disableSubUrlTracking: true,
category: DEFAULT_APP_CATEGORIES.kibana,
},
{
id: 'kibana:dev_tools',
title: i18n.translate('kbn.devToolsTitle', {
defaultMessage: 'Dev Tools',
}),
order: 9001,
url: '/app/kibana#/dev_tools',
euiIconType: 'devToolsApp',
category: DEFAULT_APP_CATEGORIES.management,
},
{
id: 'kibana:stack_management',
title: i18n.translate('kbn.managementTitle', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import 'ui/private';
import { pluginInstance } from './legacy';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
import hits from 'fixtures/real_hits';
import { setScopedHistory } from '../../../../../../plugins/discover/public/kibana_services';
import { createBrowserHistory } from 'history';

let $parentScope;

Expand Down Expand Up @@ -58,6 +60,7 @@ const destroy = function() {
describe('docTable', function() {
let $elem;

before(() => setScopedHistory(createBrowserHistory()));
beforeEach(() => pluginInstance.initializeInnerAngular());
beforeEach(() => pluginInstance.initializeServices());
beforeEach(ngMock.module('app/discover'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { getFakeRow, getFakeRowVals } from 'fixtures/fake_row';
import $ from 'jquery';
import { pluginInstance } from './legacy';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
import { setScopedHistory } from '../../../../../../plugins/discover/public/kibana_services';
import { createBrowserHistory } from 'history';

describe('Doc Table', function() {
let $parentScope;
Expand All @@ -37,6 +39,7 @@ describe('Doc Table', function() {
let stubFieldFormatConverter;
beforeEach(() => pluginInstance.initializeServices());
beforeEach(() => pluginInstance.initializeInnerAngular());
before(() => setScopedHistory(createBrowserHistory()));
beforeEach(ngMock.module('app/discover'));
beforeEach(
ngMock.inject(function($rootScope, Private) {
Expand Down
3 changes: 0 additions & 3 deletions src/legacy/core_plugins/kibana/public/dev_tools/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions src/legacy/core_plugins/kibana/public/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
// bad cascading in the Editor layout
@import '../../../../plugins/maps_legacy/public/index';

// Home styles
@import '../../../../plugins/home/public/application/index';

// Management styles
@import './management/index';

Expand Down
Loading

0 comments on commit 0ff0dcd

Please sign in to comment.