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] Use license management locator #158278

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
yngrdyn marked this conversation as resolved.
Show resolved Hide resolved
}: 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;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @sqren,
We talk about what will happen if licenseManagement.locator is undefined, but I'm actually not sure if we want to fall back to the licensePageUrl = '/app/management/stack/license_management'
what else we can do in this case? any suggestions?

Copy link
Member

@sorenlouv sorenlouv Jun 2, 2023

Choose a reason for hiding this comment

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

In the case where license management plugin is disabled we don't want to link to the license page, because it'll display a 404. In that case I think we can just not show the link.
That being said, I don't think this will ever happen. If the license management is not enabled, the user ought to have something like an enterprise license, with access to everything.

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 @@ -28,11 +28,8 @@ export default {
],
};

export function Example({
showBetaBadge,
text,
}: ComponentProps<typeof LicensePrompt>) {
return <LicensePrompt showBetaBadge={showBetaBadge} text={text} />;
export function Example({ text }: ComponentProps<typeof LicensePrompt>) {
return <LicensePrompt text={text} />;
}
Example.args = {
showBetaBadge: false,
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(
yngrdyn marked this conversation as resolved.
Show resolved Hide resolved
'/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
2 changes: 0 additions & 2 deletions x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -8212,8 +8212,6 @@
"xpack.apm.latencyChartHistory.chartTitle": " historique des alertes de latence",
"xpack.apm.latencyChartHistory.last30days": "30 derniers jours",
"xpack.apm.latencyCorrelations.licenseCheckText": "Pour utiliser les corrélations de latence, vous devez disposer d'une licence Elastic Platinum. Elle vous permettra de découvrir quels champs sont corrélés à de faibles performances.",
"xpack.apm.license.betaBadge": "Version bêta",
"xpack.apm.license.betaTooltipMessage": "Cette fonctionnalité est actuellement en version bêta. Si vous rencontrez des bugs ou si vous souhaitez apporter des commentaires, ouvrez un ticket de problème ou visitez notre forum de discussion.",
"xpack.apm.license.button": "Commencer l'essai",
"xpack.apm.license.title": "Commencer un essai gratuit de 30 jours",
"xpack.apm.managedTable.errorMessage": "Impossible de récupérer",
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -8213,8 +8213,6 @@
"xpack.apm.latencyChartHistory.chartTitle": " レイテンシアラート履歴",
"xpack.apm.latencyChartHistory.last30days": "過去30日間",
"xpack.apm.latencyCorrelations.licenseCheckText": "遅延の相関関係を使用するには、Elastic Platinumライセンスのサブスクリプションが必要です。使用すると、パフォーマンスの低下に関連しているフィールドを検出できます。",
"xpack.apm.license.betaBadge": "ベータ",
"xpack.apm.license.betaTooltipMessage": "現在、この機能はベータです。不具合を見つけた場合やご意見がある場合、サポートに問い合わせるか、またはディスカッションフォーラムにご報告ください。",
"xpack.apm.license.button": "トライアルを開始",
"xpack.apm.license.title": "無料の 30 日トライアルを開始",
"xpack.apm.managedTable.errorMessage": "取得できませんでした",
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -8212,8 +8212,6 @@
"xpack.apm.latencyChartHistory.chartTitle": " 延迟告警历史记录",
"xpack.apm.latencyChartHistory.last30days": "过去 30 天",
"xpack.apm.latencyCorrelations.licenseCheckText": "要使用延迟相关性,必须订阅 Elastic 白金级许可证。使用相关性,将能够发现哪些字段与性能差相关。",
"xpack.apm.license.betaBadge": "公测版",
"xpack.apm.license.betaTooltipMessage": "此功能当前为公测版。如果遇到任何错误或有任何反馈,请报告问题或访问我们的论坛。",
"xpack.apm.license.button": "开始试用",
"xpack.apm.license.title": "开始为期 30 天的免费试用",
"xpack.apm.managedTable.errorMessage": "无法提取",
Expand Down