Skip to content

Commit

Permalink
use license managment locator
Browse files Browse the repository at this point in the history
  • Loading branch information
MiriamAparicio committed May 25, 2023
1 parent 3e88052 commit c2472bc
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 217 deletions.
3 changes: 2 additions & 1 deletion x-pack/plugins/apm/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"security",
"spaces",
"taskManager",
"usageCollection"
"usageCollection",
"licenseManagement"
],
"requiredBundles": [
"fleet",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,29 @@
import { EuiButton, EuiCard, EuiTextColor } from '@elastic/eui';
import React from 'react';
import { i18n } from '@kbn/i18n';
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context';
import { useKibanaUrl } from '../../../hooks/use_kibana_url';

export interface LicensePromptProps {
text: string;
showBetaBadge?: boolean;
}

export function LicensePrompt({
text,
showBetaBadge = false,
}: LicensePromptProps) {
export function LicensePrompt({ text }: LicensePromptProps) {
const {
plugins: { licenseManagement },
} = useApmPluginContext();
const licensePageUrl = useKibanaUrl(
'/app/management/stack/license_management'
);

const manageLicenseURL = licenseManagement?.locator
? licenseManagement?.locator?.useUrl({
page: 'dashboard',
})
: licensePageUrl;
return (
<EuiCard
display={showBetaBadge ? undefined : 'plain'}
display="plain"
paddingSize="l"
betaBadgeProps={
showBetaBadge
? {
label: i18n.translate('xpack.apm.license.betaBadge', {
defaultMessage: 'Beta',
}),
tooltipContent: i18n.translate(
'xpack.apm.license.betaTooltipMessage',
{
defaultMessage:
'This feature is currently in beta. If you encounter any bugs or have feedback, please open an issue or visit our discussion forum.',
}
),
}
: undefined
}
title={i18n.translate('xpack.apm.license.title', {
defaultMessage: 'Start free 30-day trial',
})}
Expand All @@ -52,7 +40,7 @@ export function LicensePrompt({
<EuiButton
data-test-subj="apmLicensePromptStartTrialButton"
fill={true}
href={licensePageUrl}
href={manageLicenseURL}
>
{i18n.translate('xpack.apm.license.button', {
defaultMessage: 'Start trial',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@ import { EuiButton, EuiEmptyPrompt } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { useKibanaUrl } from '../../hooks/use_kibana_url';
import { useApmPluginContext } from '../apm_plugin/use_apm_plugin_context';

export function InvalidLicenseNotification() {
const manageLicenseURL = useKibanaUrl(
const {
plugins: { licenseManagement },
} = useApmPluginContext();
const licensePageUrl = useKibanaUrl(
'/app/management/stack/license_management'
);
const manageLicenseURL = licenseManagement?.locator
? licenseManagement?.locator?.useUrl({
page: 'dashboard',
})
: licensePageUrl;

return (
<EuiEmptyPrompt
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugins/apm/public/context/license/license_context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export const LicenseContext = React.createContext<ILicense | undefined>(
);

export function LicenseProvider({ children }: { children: React.ReactChild }) {
const { license$ } = useApmPluginContext().plugins.licensing;
const license = useObservable(license$);
const { plugins } = useApmPluginContext();
const { licensing } = plugins;
const license = useObservable(licensing.license$);
// if license is not loaded yet, consider it valid
const hasInvalidLicense = license?.isActive === false;

Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/apm/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { ChartsPluginStart } from '@kbn/charts-plugin/public';
import { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import { UiActionsStart, UiActionsSetup } from '@kbn/ui-actions-plugin/public';
import { ObservabilityTriggerId } from '@kbn/observability-shared-plugin/common';
import { LicenseManagementUIPluginSetup } from '@kbn/license-management-plugin/public';
import { registerApmRuleTypes } from './components/alerting/rule_types/register_apm_rule_types';
import {
getApmEnrollmentFlyoutData,
Expand All @@ -84,6 +85,7 @@ export interface ApmPluginSetupDeps {
features: FeaturesPluginSetup;
home?: HomePublicPluginSetup;
licensing: LicensingPluginSetup;
licenseManagement?: LicenseManagementUIPluginSetup;
ml?: MlPluginSetup;
observability: ObservabilityPublicSetup;
observabilityShared: ObservabilitySharedPluginSetup;
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/apm/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@kbn/features-plugin",
"@kbn/infra-plugin",
"@kbn/licensing-plugin",
"@kbn/license-management-plugin",
"@kbn/maps-plugin",
"@kbn/ml-plugin",
"@kbn/observability-plugin",
Expand Down
124 changes: 61 additions & 63 deletions x-pack/plugins/translations/translations/fr-FR.json

Large diffs are not rendered by default.

124 changes: 61 additions & 63 deletions x-pack/plugins/translations/translations/ja-JP.json

Large diffs are not rendered by default.

Loading

0 comments on commit c2472bc

Please sign in to comment.