-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added breadcrumb service and call on ILM pages * add notices to legacy pattern services * fix jest tests and create mock
- Loading branch information
1 parent
7558fe1
commit db8f98c
Showing
12 changed files
with
151 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
13 changes: 13 additions & 0 deletions
13
x-pack/plugins/index_lifecycle_management/public/application/services/breadcrumbs.mock.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,13 @@ | ||
/* | ||
* 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 { BreadcrumbService } from './breadcrumbs'; | ||
|
||
export const createBreadcrumbsMock = () => { | ||
const breadcrumbService = new BreadcrumbService(); | ||
breadcrumbService.setup(jest.fn()); | ||
return breadcrumbService; | ||
}; |
67 changes: 67 additions & 0 deletions
67
x-pack/plugins/index_lifecycle_management/public/application/services/breadcrumbs.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,67 @@ | ||
/* | ||
* 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'; | ||
import { ChromeBreadcrumb } from 'kibana/public'; | ||
import { ManagementAppMountParams } from '../../../../../../src/plugins/management/public'; | ||
|
||
type SetBreadcrumbs = ManagementAppMountParams['setBreadcrumbs']; | ||
|
||
// Build the breadcrumbs for this app | ||
const breadcrumbs = (function () { | ||
const policies: ChromeBreadcrumb[] = [ | ||
{ | ||
text: i18n.translate('xpack.indexLifecycleMgmt.breadcrumb.homeLabel', { | ||
defaultMessage: 'Index Lifecycle Management', | ||
}), | ||
href: `/policies`, | ||
}, | ||
]; | ||
|
||
const editPolicy: ChromeBreadcrumb[] = [ | ||
...policies, | ||
{ | ||
text: i18n.translate('xpack.indexLifecycleMgmt.breadcrumb.editPolicyLabel', { | ||
defaultMessage: 'Edit policy', | ||
}), | ||
href: undefined, | ||
}, | ||
]; | ||
|
||
return { | ||
policies, | ||
editPolicy, | ||
}; | ||
})(); | ||
|
||
export class BreadcrumbService { | ||
private setBreadcrumbsHandler?: SetBreadcrumbs; | ||
|
||
public setup(setBreadcrumbsHandler: SetBreadcrumbs): void { | ||
this.setBreadcrumbsHandler = setBreadcrumbsHandler; | ||
} | ||
|
||
public setBreadcrumbs(type: keyof typeof breadcrumbs): void { | ||
if (!this.setBreadcrumbsHandler) { | ||
throw new Error(`BreadcrumbService#setup() must be called first!`); | ||
} | ||
|
||
const newBreadcrumbs = breadcrumbs[type] ? [...breadcrumbs[type]] : [...breadcrumbs.policies]; | ||
|
||
// Pop off last breadcrumb | ||
const lastBreadcrumb = newBreadcrumbs.pop() as { | ||
text: string; | ||
href?: string; | ||
}; | ||
|
||
// Put last breadcrumb back without href | ||
newBreadcrumbs.push({ | ||
...lastBreadcrumb, | ||
href: undefined, | ||
}); | ||
|
||
this.setBreadcrumbsHandler(newBreadcrumbs); | ||
} | ||
} |
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
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
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
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
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
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