Skip to content

Commit

Permalink
[7.x] [Cloud] move cloud plugin to np (#51789) (#52289)
Browse files Browse the repository at this point in the history
* merge conflicts with 7.x

* resolve conflict

* resolve eslint conflict
  • Loading branch information
Bamieh authored Dec 5, 2019
1 parent 15a4256 commit 240dd1c
Show file tree
Hide file tree
Showing 55 changed files with 471 additions and 294 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface ChromeStart
| [setBrand(brand)](./kibana-plugin-public.chromestart.setbrand.md) | Set the brand configuration. |
| [setBreadcrumbs(newBreadcrumbs)](./kibana-plugin-public.chromestart.setbreadcrumbs.md) | Override the current set of breadcrumbs |
| [setHelpExtension(helpExtension)](./kibana-plugin-public.chromestart.sethelpextension.md) | Override the current set of custom help content |
| [setHelpSupportUrl(url)](./kibana-plugin-public.chromestart.sethelpsupporturl.md) | Override the default support URL shown in the help menu |
| [setIsCollapsed(isCollapsed)](./kibana-plugin-public.chromestart.setiscollapsed.md) | Set the collapsed state of the chrome navigation. |
| [setIsVisible(isVisible)](./kibana-plugin-public.chromestart.setisvisible.md) | Set the temporary visibility for the chrome. This does nothing if the chrome is hidden by default and should be used to hide the chrome for things like full-screen modes with an exit button. |

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [ChromeStart](./kibana-plugin-public.chromestart.md) &gt; [setHelpSupportUrl](./kibana-plugin-public.chromestart.sethelpsupporturl.md)

## ChromeStart.setHelpSupportUrl() method

Override the default support URL shown in the help menu

<b>Signature:</b>

```typescript
setHelpSupportUrl(url: string): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| url | <code>string</code> | |

<b>Returns:</b>

`void`

1 change: 1 addition & 0 deletions src/core/public/chrome/chrome_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const createStartContractMock = () => {
setBreadcrumbs: jest.fn(),
getHelpExtension$: jest.fn(),
setHelpExtension: jest.fn(),
setHelpSupportUrl: jest.fn(),
};
startContract.navLinks.getAll.mockReturnValue([]);
startContract.getBrand$.mockReturnValue(new BehaviorSubject({} as ChromeBrand));
Expand Down
12 changes: 11 additions & 1 deletion src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { DocTitleService, ChromeDocTitle } from './doc_title';
import { LoadingIndicator, HeaderWrapper as Header } from './ui';
import { DocLinksStart } from '../doc_links';
import { ChromeHelpExtensionMenuLink } from './ui/header/header_help_menu';
import { KIBANA_ASK_ELASTIC_LINK } from './constants';

export { ChromeNavControls, ChromeRecentlyAccessed, ChromeDocTitle };

Expand Down Expand Up @@ -147,6 +148,7 @@ export class ChromeService {
const helpExtension$ = new BehaviorSubject<ChromeHelpExtension | undefined>(undefined);
const breadcrumbs$ = new BehaviorSubject<ChromeBreadcrumb[]>([]);
const badge$ = new BehaviorSubject<ChromeBadge | undefined>(undefined);
const helpSupportUrl$ = new BehaviorSubject<string>(KIBANA_ASK_ELASTIC_LINK);

const navControls = this.navControls.start();
const navLinks = this.navLinks.start({ application, http });
Expand All @@ -172,7 +174,6 @@ export class ChromeService {
<LoadingIndicator loadingCount$={http.getLoadingCount$()} />

<Header
isCloudEnabled={injectedMetadata.getInjectedVar('isCloudEnabled') as boolean}
application={application}
appTitle$={appTitle$.pipe(takeUntil(this.stop$))}
badge$={badge$.pipe(takeUntil(this.stop$))}
Expand All @@ -181,6 +182,7 @@ export class ChromeService {
kibanaDocLink={docLinks.links.kibana}
forceAppSwitcherNavigation$={navLinks.getForceAppSwitcherNavigation$()}
helpExtension$={helpExtension$.pipe(takeUntil(this.stop$))}
helpSupportUrl$={helpSupportUrl$.pipe(takeUntil(this.stop$))}
homeHref={http.basePath.prepend('/app/kibana#/home')}
isVisible$={this.isVisible$}
kibanaVersion={injectedMetadata.getKibanaVersion()}
Expand Down Expand Up @@ -256,6 +258,8 @@ export class ChromeService {
setHelpExtension: (helpExtension?: ChromeHelpExtension) => {
helpExtension$.next(helpExtension);
},

setHelpSupportUrl: (url: string) => helpSupportUrl$.next(url),
};
}

Expand Down Expand Up @@ -401,6 +405,12 @@ export interface ChromeStart {
* Override the current set of custom help content
*/
setHelpExtension(helpExtension?: ChromeHelpExtension): void;

/**
* Override the default support URL shown in the help menu
* @param url The updated support URL
*/
setHelpSupportUrl(url: string): void;
}

/** @internal */
Expand Down
1 change: 0 additions & 1 deletion src/core/public/chrome/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

export const ELASTIC_SUPPORT_LINK = 'https://support.elastic.co/';
export const KIBANA_FEEDBACK_LINK = 'https://www.elastic.co/products/kibana/feedback';
export const KIBANA_ASK_ELASTIC_LINK = 'https://www.elastic.co/products/kibana/ask-elastic';
export const GITHUB_CREATE_ISSUE_LINK = 'https://github.com/elastic/kibana/issues/new/choose';
11 changes: 8 additions & 3 deletions src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ interface Props {
recentlyAccessed$: Rx.Observable<ChromeRecentlyAccessedHistoryItem[]>;
forceAppSwitcherNavigation$: Rx.Observable<boolean>;
helpExtension$: Rx.Observable<ChromeHelpExtension | undefined>;
helpSupportUrl$: Rx.Observable<string>;
legacyMode: boolean;
navControlsLeft$: Rx.Observable<readonly ChromeNavControl[]>;
navControlsRight$: Rx.Observable<readonly ChromeNavControl[]>;
intl: InjectedIntl;
basePath: HttpStart['basePath'];
isLocked?: boolean;
onIsLockedUpdate?: (isLocked: boolean) => void;
isCloudEnabled: boolean;
}

interface State {
Expand Down Expand Up @@ -283,13 +283,13 @@ class HeaderUI extends Component<Props, State> {
basePath,
breadcrumbs$,
helpExtension$,
helpSupportUrl$,
intl,
isLocked,
kibanaDocLink,
kibanaVersion,
onIsLockedUpdate,
legacyMode,
isCloudEnabled,
} = this.props;
const {
appTitle,
Expand Down Expand Up @@ -389,7 +389,12 @@ class HeaderUI extends Component<Props, State> {
<EuiHeaderSection side="right">
<EuiHeaderSectionItem>
<HeaderHelpMenu
{...{ isCloudEnabled, helpExtension$, kibanaDocLink, kibanaVersion }}
{...{
helpExtension$,
helpSupportUrl$,
kibanaDocLink,
kibanaVersion,
}}
/>
</EuiHeaderSectionItem>

Expand Down
35 changes: 15 additions & 20 deletions src/core/public/chrome/ui/header/header_help_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,10 @@ import {
} from '@elastic/eui';

import { ExclusiveUnion } from '@elastic/eui';
import { combineLatest } from 'rxjs';
import { HeaderExtension } from './header_extension';
import { ChromeHelpExtension } from '../../chrome_service';
import {
ELASTIC_SUPPORT_LINK,
GITHUB_CREATE_ISSUE_LINK,
KIBANA_ASK_ELASTIC_LINK,
KIBANA_FEEDBACK_LINK,
} from '../../constants';
import { GITHUB_CREATE_ISSUE_LINK, KIBANA_FEEDBACK_LINK } from '../../constants';

/** @public */
export type ChromeHelpExtensionMenuGitHubLink = EuiButtonEmptyProps & {
Expand Down Expand Up @@ -110,16 +106,17 @@ export type ChromeHelpExtensionMenuLink = ExclusiveUnion<

interface Props {
helpExtension$: Rx.Observable<ChromeHelpExtension | undefined>;
helpSupportUrl$: Rx.Observable<string>;
intl: InjectedIntl;
kibanaVersion: string;
useDefaultContent?: boolean;
kibanaDocLink: string;
isCloudEnabled: boolean;
}

interface State {
isOpen: boolean;
helpExtension?: ChromeHelpExtension;
helpSupportUrl: string;
}

class HeaderHelpMenuUI extends Component<Props, State> {
Expand All @@ -131,16 +128,19 @@ class HeaderHelpMenuUI extends Component<Props, State> {
this.state = {
isOpen: false,
helpExtension: undefined,
helpSupportUrl: '',
};
}

public componentDidMount() {
this.subscription = this.props.helpExtension$.subscribe({
next: helpExtension => {
this.setState({
helpExtension,
});
},
this.subscription = combineLatest(
this.props.helpExtension$,
this.props.helpSupportUrl$
).subscribe(([helpExtension, helpSupportUrl]) => {
this.setState({
helpExtension,
helpSupportUrl,
});
});
}

Expand Down Expand Up @@ -183,7 +183,7 @@ class HeaderHelpMenuUI extends Component<Props, State> {

public render() {
const { intl, kibanaVersion, useDefaultContent, kibanaDocLink } = this.props;
const { helpExtension } = this.state;
const { helpExtension, helpSupportUrl } = this.state;

const defaultContent = useDefaultContent ? (
<Fragment>
Expand All @@ -196,12 +196,7 @@ class HeaderHelpMenuUI extends Component<Props, State> {

<EuiSpacer size="xs" />

<EuiButtonEmpty
href={this.props.isCloudEnabled ? ELASTIC_SUPPORT_LINK : KIBANA_ASK_ELASTIC_LINK}
target="_blank"
size="xs"
flush="left"
>
<EuiButtonEmpty href={helpSupportUrl} target="_blank" size="xs" flush="left">
<FormattedMessage
id="core.ui.chrome.headerGlobalNav.helpMenuAskElasticTitle"
defaultMessage="Ask Elastic"
Expand Down
1 change: 1 addition & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export interface ChromeStart {
setBrand(brand: ChromeBrand): void;
setBreadcrumbs(newBreadcrumbs: ChromeBreadcrumb[]): void;
setHelpExtension(helpExtension?: ChromeHelpExtension): void;
setHelpSupportUrl(url: string): void;
setIsCollapsed(isCollapsed: boolean): void;
setIsVisible(isVisible: boolean): void;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { HashRouter as Router, Switch, Route, Redirect } from 'react-router-dom'
import { getTutorial } from '../load_tutorials';
import { replaceTemplateStrings } from './tutorial/replace_template_strings';
import { getServices } from '../kibana_services';
import { npSetup } from 'ui/new_platform';

export function HomeApp({ directories }) {
const {
Expand All @@ -39,8 +40,9 @@ export function HomeApp({ directories }) {
setOptInNoticeSeen,
},
} = getServices();
const { cloud } = npSetup.plugins;
const isCloudEnabled = !!(cloud && cloud.isCloudEnabled);

const isCloudEnabled = getInjected('isCloudEnabled', false);
const apmUiEnabled = getInjected('apmUiEnabled', true);
const mlEnabled = getInjected('mlEnabled', false);
const defaultAppId = getInjected('kbnDefaultAppId', 'discover');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import { get, has } from 'lodash';
import { i18n } from '@kbn/i18n';
import { INSTRUCTION_VARIANT } from '../../../../common/tutorials/instruction_variant';

Expand All @@ -32,27 +33,27 @@ import {
createDotNetAgentInstructions,
} from '../instructions/apm_agent_instructions';

function getIfExists(config, key) {
return config.has(key) && config.get(key);
function getIfExists(obj, key) {
return has(obj, key) && get(obj, key);
}

export function createElasticCloudInstructions(config) {
const apmServerUrl = getIfExists(config, 'xpack.cloud.apm.url');
export function createElasticCloudInstructions(cloudSetup) {
const apmServerUrl = getIfExists(cloudSetup, 'apm.url');
const instructionSets = [];

if (!apmServerUrl) {
instructionSets.push(getApmServerInstructionSet(config));
instructionSets.push(getApmServerInstructionSet(cloudSetup));
}

instructionSets.push(getApmAgentInstructionSet(config));
instructionSets.push(getApmAgentInstructionSet(cloudSetup));

return {
instructionSets,
};
}

function getApmServerInstructionSet(config) {
const cloudId = getIfExists(config, 'xpack.cloud.id');
function getApmServerInstructionSet(cloudSetup) {
const cloudId = getIfExists(cloudSetup, 'cloudId');
return {
title: i18n.translate('kbn.server.tutorials.apm.apmServer.title', {
defaultMessage: 'APM Server',
Expand All @@ -75,9 +76,9 @@ function getApmServerInstructionSet(config) {
};
}

function getApmAgentInstructionSet(config) {
const apmServerUrl = getIfExists(config, 'xpack.cloud.apm.url');
const secretToken = getIfExists(config, 'xpack.cloud.apm.secret_token');
function getApmAgentInstructionSet(cloudSetup) {
const apmServerUrl = getIfExists(cloudSetup, 'apm.url');
const secretToken = getIfExists(cloudSetup, 'apm.secretToken');

return {
title: i18n.translate('kbn.server.tutorials.apm.elasticCloudInstructions.title', {
Expand Down
3 changes: 2 additions & 1 deletion src/legacy/core_plugins/kibana/server/tutorials/apm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function isEnabled(config) {
export function apmSpecProvider(server) {
const config = server.config();
const apmIndexPatternTitle = config.get('apm_oss.indexPattern');
const { cloud } = server.newPlatform.setup;

const savedObjects = [
{
Expand Down Expand Up @@ -95,7 +96,7 @@ It allows you to monitor the performance of thousands of applications in real ti
euiIconType: 'logoAPM',
artifacts,
onPrem: onPremInstructions(apmIndexPatternTitle),
elasticCloud: createElasticCloudInstructions(config),
elasticCloud: createElasticCloudInstructions(cloud),
previewImagePath: '/plugins/kibana/home/tutorial_resources/apm/apm.png',
savedObjects,
savedObjectsInstallMsg: i18n.translate(
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface Datatable {
rows: DatatableRow[];
}

interface SerializedDatatable extends Datatable {
export interface SerializedDatatable extends Datatable {
rows: string[][];
}

Expand Down
Loading

0 comments on commit 240dd1c

Please sign in to comment.