Skip to content

Commit

Permalink
showing callout with space name
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Feb 23, 2022
1 parent 56cd059 commit ea6597a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import {
EuiButton,
EuiButtonEmpty,
EuiCallOut,
EuiFieldText,
EuiFlexGroup,
EuiFlexItem,
Expand All @@ -19,9 +20,12 @@ import {
EuiToolTip,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import React, { useEffect, useState } from 'react';
import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public';
import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
import { useFetcher } from '../../../../hooks/use_fetcher';
import { ApmPluginStartDeps } from '../../../../plugin';
import { clearCache } from '../../../../services/rest/call_api';
import {
APIReturnType,
Expand Down Expand Up @@ -93,6 +97,8 @@ const INITIAL_STATE: ApiResponse = { apmIndexSettings: [] };

export function ApmIndices() {
const { core } = useApmPluginContext();
const { services } = useKibana<ApmPluginStartDeps>();

const { notifications, application } = core;
const canSave = application.capabilities.apm.save;

Expand All @@ -108,6 +114,10 @@ export function ApmIndices() {
[canSave]
);

const { data: space } = useFetcher(() => {
return services.spaces?.getActiveSpace();
}, [services.spaces]);

useEffect(() => {
setApmIndices(
data.apmIndexSettings.reduce(
Expand Down Expand Up @@ -191,6 +201,31 @@ export function ApmIndices() {

<EuiSpacer size="m" />

{space?.name && (
<>
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={false}>
<EuiCallOut
color="primary"
iconType="spacesApp"
title={
<EuiText size="s">
<FormattedMessage
id="xpack.apm.settings.apmIndices.spaceDescription"
defaultMessage="The index settings apply to the {spaceName} space."
values={{
spaceName: <strong>{space?.name}</strong>,
}}
/>
</EuiText>
}
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="m" />
</>
)}

<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={false}>
<EuiForm>
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 @@ -53,6 +53,7 @@ import { getLazyAPMPolicyCreateExtension } from './components/fleet_integration/
import { getLazyAPMPolicyEditExtension } from './components/fleet_integration/lazy_apm_policy_edit_extension';
import { featureCatalogueEntry } from './feature_catalogue_entry';
import type { SecurityPluginStart } from '../../security/public';
import { SpacesPluginStart } from '../../spaces/public';

export type ApmPluginSetup = ReturnType<ApmPlugin['setup']>;

Expand Down Expand Up @@ -82,6 +83,7 @@ export interface ApmPluginStartDeps {
observability: ObservabilityPublicStart;
fleet?: FleetStart;
security?: SecurityPluginStart;
spaces?: SpacesPluginStart;
}

const servicesTitle = i18n.translate('xpack.apm.navigation.servicesTitle', {
Expand Down

0 comments on commit ea6597a

Please sign in to comment.