Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] License prompt for service map #52668

Merged
merged 1 commit into from
Dec 17, 2019
Merged

Conversation

smith
Copy link
Contributor

@smith smith commented Dec 10, 2019

Display a link to platinum license upgrade on the service map.

Also add useKibanaUrl and useLicense hooks.

Make the LicenseContext (which is used in a couple class components and on page load) use the license observable from the NP plugin.

Add missing export of useObservable to kibana_react.

Closes #52375.

@smith smith added release_note:skip Skip the PR/issue when compiling release notes v7.6.0 labels Dec 12, 2019
@smith smith marked this pull request as ready for review December 12, 2019 22:01
@smith smith requested a review from a team as a code owner December 12, 2019 22:01
setLicense(nextLicense);
});
return () => subscription.unsubscribe();
}, [license$]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the subscription happen inside the context and not the other way around? If several components call useLicense we'll have several subscriptions. If we add it to the context we'll only have one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b7e5f18.

@@ -148,7 +148,9 @@ export class ServiceIntegrations extends React.Component<Props, State> {
panels={[
{
id: 0,
items: this.getPanelItems(license.features.ml?.is_available)
items: this.getPanelItems(
license.getFeature('ml').isAvailable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will getFeature always return an object regardless if the plugin is disabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. getFeature always returns a LicenseFeature:

export interface LicenseFeature {
isAvailable: boolean;
isEnabled: boolean;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're using ILicense | undefined now so a ? has been added to license, but the above still holds.

import React from 'react';
import { FETCH_STATUS, useFetcher } from '../../hooks/useFetcher';
import { loadLicense, LicenseApiResponse } from '../../services/rest/xpack';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also remove the loadLicense method (and the entire rest/xpack.ts file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That file is deleted.

@mbondyra mbondyra requested a review from a team December 13, 2019 16:56
@mbondyra mbondyra requested review from a team as code owners December 13, 2019 16:56
@smith smith force-pushed the nls/map-plat branch 2 times, most recently from 921e593 to 25cb6f7 Compare December 13, 2019 18:06
@smith smith requested a review from joshdover December 13, 2019 18:08
Copy link
Contributor

@joshdover joshdover left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small suggestions

Comment on lines 59 to 62
const isValidPlatinumLicense =
license !== undefined &&
license.status === 'active' &&
license.type === 'platinum';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  const isValidPlatinumLicense = license?.isActive && license?.type === 'platinum'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 44d9568.

[http]
);
const hasValidLicense = data.license.is_active;
const hasInValidLicense = license !== undefined && !license.isActive;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const hasInValidLicense = license !== undefined && !license.isActive;
const hasInValidLicense = !license?.isActive;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 44d9568.

import { i18n } from '@kbn/i18n';
import { useKibanaUrl } from '../../../hooks/useKibanaUrl';

export function LicensePrompt() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps call it "PlatinumLicensePrompt" Since we already have another prompt that ensures the user has a license at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 44d9568.


// if license is invalid show an error message
if (status === FETCH_STATUS.SUCCESS && !hasValidLicense) {
if (hasInValidLicense) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (hasInValidLicense) {
if (hasInvalidLicense) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 44d9568.


export function useKibanaUrl(
/** The path to the plugin */ path: string,
/** The hash path */ hash: string
Copy link
Member

@sorenlouv sorenlouv Dec 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting looks odd. Shouldn't the comments either be after the argument:

path: string // The path to the plugin

Or on the line above:

// The path to the plugin
path: string

Either way I don't think they are terribly helpful. So perhaps just remove them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks odd (to you) but it's valid JSDoc comments that show up when using autocomplete:
image

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits

@sorenlouv
Copy link
Member

sorenlouv commented Dec 16, 2019

@smith can you add a "Closes #issue" to tie the PR and issue together? I think the issue is currently unassigned in the backlog so someone could pick it.

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kibana_react export LGTM

Display a link to platinum license upgrade on the service map.

Also add `useKibanaUrl` and `useLicense` hooks.

Make the `LicenseContext` (which is used in a couple class components and on page load) use the license observable from the NP plugin.

Add missing export of `useObservable` to kibana_react.
@legrego legrego removed the request for review from a team December 17, 2019 16:28
@legrego
Copy link
Member

legrego commented Dec 17, 2019

Removing review request for @elastic/kibana-security since this doesn't touch anything we own. Let me know if you'd still like a review!

@smith
Copy link
Contributor Author

smith commented Dec 17, 2019

@elasticmachine test this please

@smith
Copy link
Contributor Author

smith commented Dec 17, 2019

@elasticmachine test this please

@jbudz jbudz removed request for a team December 17, 2019 16:46
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@smith smith merged commit d391764 into elastic:master Dec 17, 2019
@smith smith deleted the nls/map-plat branch December 17, 2019 18:01
smith added a commit to smith/kibana that referenced this pull request Jan 10, 2020
Display a link to platinum license upgrade on the service map.

Also add `useKibanaUrl` and `useLicense` hooks.

Make the `LicenseContext` (which is used in a couple class components and on page load) use the license observable from the NP plugin.

Add missing export of `useObservable` to kibana_react.
smith added a commit to smith/kibana that referenced this pull request Jan 10, 2020
Display a link to platinum license upgrade on the service map.

Also add `useKibanaUrl` and `useLicense` hooks.

Make the `LicenseContext` (which is used in a couple class components and on page load) use the license observable from the NP plugin.

Add missing export of `useObservable` to kibana_react.
smith added a commit to smith/kibana that referenced this pull request Jan 13, 2020
Display a link to platinum license upgrade on the service map.

Also add `useKibanaUrl` and `useLicense` hooks.

Make the `LicenseContext` (which is used in a couple class components and on page load) use the license observable from the NP plugin.

Add missing export of `useObservable` to kibana_react.
smith added a commit that referenced this pull request Jan 13, 2020
Display a link to platinum license upgrade on the service map.

Also add `useKibanaUrl` and `useLicense` hooks.

Make the `LicenseContext` (which is used in a couple class components and on page load) use the license observable from the NP plugin.

Add missing export of `useObservable` to kibana_react.
@dgieselaar dgieselaar self-assigned this Jan 16, 2020
@dgieselaar dgieselaar added the apm:test-plan-done Pull request that was successfully tested during the test plan label Jan 16, 2020
@dgieselaar
Copy link
Member

Tested in Chrome, FF, IE11, Safari.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:test-plan-done Pull request that was successfully tested during the test plan release_note:skip Skip the PR/issue when compiling release notes v7.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Service maps: Show license subscription trial CTA
8 participants