-
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.
[WIP] Add help menu item to header (#29664)
* Added static help menu item to header * Update default message * [chrome] add help menu extension point apis * [chrome/headerExtension] fix test file name * prettier * Insert doclink and version dynamically * Add missing i18n * Lowercase `v` for version * Smaller width for popover
- Loading branch information
Showing
21 changed files
with
406 additions
and
45 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { IRootScopeService } from 'angular'; | ||
|
||
import { ChromeStartContract, HelpExtension } from '../../../../core/public/chrome'; | ||
|
||
let newPlatformChrome: ChromeStartContract; | ||
export function __newPlatformInit__(instance: ChromeStartContract) { | ||
if (newPlatformChrome) { | ||
throw new Error('ui/chrome/api/help_extension is already initialized'); | ||
} | ||
|
||
newPlatformChrome = instance; | ||
} | ||
|
||
export type HelpExtensionApi = ReturnType<typeof createHelpExtensionApi>['helpExtension']; | ||
export { HelpExtension }; | ||
|
||
function createHelpExtensionApi() { | ||
/** | ||
* reset helpExtensionSetSinceRouteChange any time the helpExtension changes, even | ||
* if it was done directly through the new platform | ||
*/ | ||
let helpExtensionSetSinceRouteChange = false; | ||
newPlatformChrome.getHelpExtension$().subscribe({ | ||
next() { | ||
helpExtensionSetSinceRouteChange = true; | ||
}, | ||
}); | ||
|
||
return { | ||
helpExtension: { | ||
/** | ||
* Set the custom help extension, or clear it by passing undefined. This | ||
* will be rendered within the help popover in the header | ||
*/ | ||
set: (helpExtension: HelpExtension | undefined) => { | ||
newPlatformChrome.setHelpExtension(helpExtension); | ||
}, | ||
|
||
/** | ||
* Get the current help extension that should be rendered in the header | ||
*/ | ||
get$: () => newPlatformChrome.getHelpExtension$(), | ||
}, | ||
|
||
/** | ||
* internal angular run function that will be called when angular bootstraps and | ||
* lets us integrate with the angular router so that we can automatically clear | ||
* the helpExtension if we switch to a Kibana app that does not set its own | ||
* helpExtension | ||
*/ | ||
$setupHelpExtensionAutoClear: ($rootScope: IRootScopeService, $injector: any) => { | ||
const $route = $injector.has('$route') ? $injector.get('$route') : {}; | ||
|
||
$rootScope.$on('$routeChangeStart', () => { | ||
helpExtensionSetSinceRouteChange = false; | ||
}); | ||
|
||
$rootScope.$on('$routeChangeSuccess', () => { | ||
const current = $route.current || {}; | ||
|
||
if (helpExtensionSetSinceRouteChange || (current.$$route && current.$$route.redirectTo)) { | ||
return; | ||
} | ||
|
||
newPlatformChrome.setHelpExtension(current.helpExtension); | ||
}); | ||
}, | ||
}; | ||
} | ||
|
||
export function initHelpExtensionApi( | ||
chrome: { [key: string]: any }, | ||
internal: { [key: string]: any } | ||
) { | ||
const { helpExtension, $setupHelpExtensionAutoClear } = createHelpExtensionApi(); | ||
chrome.helpExtension = helpExtension; | ||
internal.$setupHelpExtensionAutoClear = $setupHelpExtensionAutoClear; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,7 @@ | |
left: 0; | ||
} | ||
} | ||
|
||
.chrHeaderHelpMenu__version { | ||
text-transform: none; | ||
} |
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
Oops, something went wrong.