Skip to content

Commit

Permalink
Add Beta label to Infrastructure tab (#136710)
Browse files Browse the repository at this point in the history
* Add Beta label to Infrastructure tab

* improve BetaBadge and reuse TechnicalPreviewBadge

* use append prop for tabs with beta or technical preview badge
  • Loading branch information
MiriamAparicio authored Jul 22, 2022
1 parent c0ad0f9 commit ad8ec92
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,44 +35,36 @@ describe('Infrastracture feature flag', () => {
cy.loginAsEditorUser();
});

describe('when infrastracture feature is disabled', () => {
it('shows the flag as disabled in kibana advanced settings', () => {
describe('when infrastracture feature is enabled', () => {
it('shows the flag as enabled in kibana advanced settings', () => {
cy.visit(settingsPath);

cy.get(infraToggle)
.should('have.attr', 'aria-checked')
.and('equal', 'false');
.and('equal', 'true');
});

it('hides infrastructure tab in service overview page', () => {
it('shows infrastructure tab in service overview page', () => {
cy.visit(serviceOverviewPath);
cy.contains('a[role="tab"]', 'Infrastructure').should('not.exist');
cy.contains('a[role="tab"]', 'Infrastructure');
});
});

describe('when infrastracture feature is enabled', () => {
after(() => {
// Reverts to default state, which is infrastructureView disabled
cy.visit(settingsPath);
cy.get(infraToggle).click();
cy.contains('Save changes').should('not.be.disabled');
cy.contains('Save changes').click();
});

it('shows the flag as enabled in kibana advanced settings', () => {
describe('when infrastracture feature is disabled', () => {
it('shows the flag as disabled in kibana advanced settings', () => {
cy.visit(settingsPath);
cy.get(infraToggle).click();
cy.contains('Save changes').should('not.be.disabled');
cy.contains('Save changes').click();

cy.get(infraToggle)
.should('have.attr', 'aria-checked')
.and('equal', 'true');
.and('equal', 'false');
});

it('shows infrastructure tab in service overview page', () => {
it('hides infrastructure tab in service overview page', () => {
cy.visit(serviceOverviewPath);
cy.contains('a[role="tab"]', 'Infrastructure');
cy.contains('a[role="tab"]', 'Infrastructure').should('not.exist');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import {
EuiBetaBadge,
EuiFlexGroup,
EuiFlexItem,
EuiPageHeaderProps,
Expand Down Expand Up @@ -36,6 +35,7 @@ import { ServiceIcons } from '../../../shared/service_icons';
import { ApmMainTemplate } from '../apm_main_template';
import { AnalyzeDataButton } from './analyze_data_button';
import { getAlertingCapabilities } from '../../../alerting/get_alerting_capabilities';
import { BetaBadge } from '../../../shared/beta_badge';
import { TechnicalPreviewBadge } from '../../../shared/technical_preview_badge';

type Tab = NonNullable<EuiPageHeaderProps['tabs']>[0] & {
Expand Down Expand Up @@ -265,9 +265,11 @@ function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) {
path: { serviceName },
query,
}),
append: <BetaBadge />,
label: i18n.translate('xpack.apm.home.infraTabLabel', {
defaultMessage: 'Infrastructure',
}),

hidden: !showInfraTab,
},
{
Expand Down Expand Up @@ -301,60 +303,31 @@ function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) {
query,
}),
hidden: !config.profilingEnabled,
label: (
<EuiFlexGroup direction="row" gutterSize="s">
<EuiFlexItem>
{i18n.translate('xpack.apm.serviceDetails.profilingTabLabel', {
defaultMessage: 'Profiling',
})}
</EuiFlexItem>
<EuiFlexItem>
<EuiBetaBadge
label={i18n.translate(
'xpack.apm.serviceDetails.profilingTabExperimentalLabel',
{
defaultMessage: 'Technical preview',
}
)}
tooltipContent={i18n.translate(
'xpack.apm.serviceDetails.profilingTabExperimentalDescription',
{
defaultMessage:
'This functionality is in technical preview and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.',
}
)}
/>
</EuiFlexItem>
</EuiFlexGroup>
),
append: <TechnicalPreviewBadge icon="beaker" />,
label: i18n.translate('xpack.apm.serviceDetails.profilingTabLabel', {
defaultMessage: 'Profiling',
}),
},
{
key: 'alerts',
href: router.link('/services/{serviceName}/alerts', {
path: { serviceName },
query,
}),
label: (
<EuiFlexGroup gutterSize="xs">
<EuiFlexItem>
{i18n.translate('xpack.apm.home.alertsTabLabel', {
defaultMessage: 'Alerts',
})}
</EuiFlexItem>
<EuiFlexItem>
<TechnicalPreviewBadge icon="beaker" />
</EuiFlexItem>
</EuiFlexGroup>
),
append: <TechnicalPreviewBadge icon="beaker" />,
label: i18n.translate('xpack.apm.home.alertsTabLabel', {
defaultMessage: 'Alerts',
}),
hidden: !(isAlertingAvailable && canReadAlerts),
},
];

return tabs
.filter((t) => !t.hidden)
.map(({ href, key, label }) => ({
.map(({ href, key, label, append }) => ({
href,
label,
append,
isSelected: key === selectedTab,
}));
}
29 changes: 29 additions & 0 deletions x-pack/plugins/apm/public/components/shared/beta_badge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { EuiBetaBadge, IconType } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';

interface Props {
icon?: IconType;
}

export function BetaBadge({ icon }: Props) {
return (
<EuiBetaBadge
label={i18n.translate('xpack.apm.betaBadgeLabel', {
defaultMessage: 'Beta',
})}
tooltipContent={i18n.translate('xpack.apm.betaBadgeDescription', {
defaultMessage:
'This feature is currently in beta. If you encounter any bugs or have feedback, please open an issue or visit our discussion forum.',
})}
iconType={icon}
/>
);
}
2 changes: 1 addition & 1 deletion x-pack/plugins/observability/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const uiSettings: Record<string, UiSettingsParams<boolean | number | stri
name: i18n.translate('xpack.observability.enableInfrastructureView', {
defaultMessage: 'Infrastructure feature',
}),
value: false,
value: true,
description: i18n.translate('xpack.observability.enableInfrastructureViewDescription', {
defaultMessage: 'Enable the Infrastructure view feature in APM app',
}),
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 @@ -7932,8 +7932,6 @@
"xpack.apm.serviceDetails.metricsTabLabel": "Indicateurs",
"xpack.apm.serviceDetails.nodesTabLabel": "JVM",
"xpack.apm.serviceDetails.overviewTabLabel": "Aperçu",
"xpack.apm.serviceDetails.profilingTabExperimentalDescription": "Cette fonctionnalité est en version d'évaluation technique et pourra être modifiée ou retirée complètement dans une future version. Elastic s'efforcera au maximum de corriger tout problème, mais les fonctionnalités en version d'évaluation technique ne sont pas soumises aux accords de niveau de service d'assistance des fonctionnalités officielles en disponibilité générale.",
"xpack.apm.serviceDetails.profilingTabExperimentalLabel": "Version d'évaluation technique",
"xpack.apm.serviceDetails.profilingTabLabel": "Profilage",
"xpack.apm.serviceDetails.transactionsTabLabel": "Transactions",
"xpack.apm.serviceGroup.allServices.title": "Tous les services",
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 @@ -7924,8 +7924,6 @@
"xpack.apm.serviceDetails.metricsTabLabel": "メトリック",
"xpack.apm.serviceDetails.nodesTabLabel": "JVM",
"xpack.apm.serviceDetails.overviewTabLabel": "概要",
"xpack.apm.serviceDetails.profilingTabExperimentalDescription": "この機能はテクニカルプレビュー中であり、将来のリリースでは変更されたり完全に削除されたりする場合があります。Elasticは最善の努力を講じてすべての問題の修正に努めますが、テクニカルプレビュー中の機能には正式なGA機能のサポートSLAが適用されません。",
"xpack.apm.serviceDetails.profilingTabExperimentalLabel": "テクニカルプレビュー",
"xpack.apm.serviceDetails.profilingTabLabel": "プロファイリング",
"xpack.apm.serviceDetails.transactionsTabLabel": "トランザクション",
"xpack.apm.serviceGroup.allServices.title": "すべてのサービス",
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 @@ -7938,8 +7938,6 @@
"xpack.apm.serviceDetails.metricsTabLabel": "指标",
"xpack.apm.serviceDetails.nodesTabLabel": "JVM",
"xpack.apm.serviceDetails.overviewTabLabel": "概览",
"xpack.apm.serviceDetails.profilingTabExperimentalDescription": "此功能处于技术预览状态,在未来版本中可能会更改或完全移除。Elastic 将尽最大努力来修复任何问题,但处于技术预览状态的功能不受正式 GA 功能支持 SLA 的约束。",
"xpack.apm.serviceDetails.profilingTabExperimentalLabel": "技术预览",
"xpack.apm.serviceDetails.profilingTabLabel": "分析",
"xpack.apm.serviceDetails.transactionsTabLabel": "事务",
"xpack.apm.serviceGroup.allServices.title": "所有服务",
Expand Down

0 comments on commit ad8ec92

Please sign in to comment.