diff --git a/x-pack/legacy/plugins/apm/common/runtime_types/transaction_max_spans_rt/index.test.ts b/x-pack/legacy/plugins/apm/common/runtime_types/transaction_max_spans_rt/index.test.ts index b07464ce95a8d6e..b62251b6974d9b5 100644 --- a/x-pack/legacy/plugins/apm/common/runtime_types/transaction_max_spans_rt/index.test.ts +++ b/x-pack/legacy/plugins/apm/common/runtime_types/transaction_max_spans_rt/index.test.ts @@ -4,11 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ import { transactionMaxSpansRt } from './index'; import { isRight } from 'fp-ts/lib/Either'; diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/FlyoutServiceSection.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/ServiceSection.tsx similarity index 77% rename from x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/FlyoutServiceSection.tsx rename to x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/ServiceSection.tsx index 9c19cd6ab347608..eee2c5ecec5c1fa 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/FlyoutServiceSection.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/ServiceSection.tsx @@ -8,9 +8,10 @@ import { EuiTitle, EuiSpacer, EuiFormRow } from '@elastic/eui'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { SelectWithPlaceholder } from '../../../../shared/SelectWithPlaceholder'; -import { FETCH_STATUS } from '../../../../../hooks/useFetcher'; +import { useFetcher } from '../../../../../hooks/useFetcher'; import { ENVIRONMENT_NOT_DEFINED } from '../../../../../../common/environment_filter_values'; import { Config } from '../index'; +import { callApmApi } from '../../../../../services/rest/callApmApi'; const t = (id: string, defaultMessage: string) => i18n.translate(`xpack.apm.settings.agentConf.flyOut.serviceSection.${id}`, { defaultMessage @@ -24,23 +25,39 @@ interface Props { setEnvironment: (env: string) => void; serviceName?: string; setServiceName: (env: string) => void; - serviceNames: string[]; - serviceNamesStatus?: FETCH_STATUS; - environments: Array<{ name: string; alreadyExists: boolean }>; - environmentStatus?: FETCH_STATUS; } -export function FlyoutServiceSection({ +export function ServiceSection({ selectedConfig, environment, setEnvironment, serviceName, - setServiceName, - serviceNames, - serviceNamesStatus, - environments, - environmentStatus + setServiceName }: Props) { + const { data: serviceNames = [], status: serviceNamesStatus } = useFetcher( + () => { + return callApmApi({ + pathname: '/api/apm/settings/agent-configuration/services', + forceCache: true + }); + }, + [], + { preservePreviousData: false } + ); + const { data: environments = [], status: environmentStatus } = useFetcher( + () => { + if (serviceName) { + return callApmApi({ + pathname: + '/api/apm/settings/agent-configuration/services/{serviceName}/environments', + params: { path: { serviceName } } + }); + } + }, + [serviceName], + { preservePreviousData: false } + ); + const environmentOptions = environments.map(({ name, alreadyExists }) => ({ disabled: alreadyExists, text: diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/FlyoutConfigurationSection.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/SettingsSection.tsx similarity index 95% rename from x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/FlyoutConfigurationSection.tsx rename to x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/SettingsSection.tsx index 0a5b5fec744a5d4..eff90a0dfd43d0c 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/FlyoutConfigurationSection.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/SettingsSection.tsx @@ -16,10 +16,9 @@ import { i18n } from '@kbn/i18n'; import { isEmpty } from 'lodash'; import { SelectWithPlaceholder } from '../../../../shared/SelectWithPlaceholder'; const t = (id: string, defaultMessage: string) => - i18n.translate( - `xpack.apm.settings.agentConf.flyOut.ConfigurationSection.${id}`, - { defaultMessage } - ); + i18n.translate(`xpack.apm.settings.agentConf.flyOut.settingsSection.${id}`, { + defaultMessage + }); interface ConfigOption { value: string; @@ -33,7 +32,7 @@ interface Props { transactionMaxSpans: ConfigOption; } -export function FlyoutConfigurationSection({ +export function SettingsSection({ sampleRate, captureBody, transactionMaxSpans @@ -41,7 +40,7 @@ export function FlyoutConfigurationSection({ return ( <> -

{t('title', 'Configuration')}

+

{t('title', 'Settings')}

diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/index.tsx b/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/index.tsx index 119e0699de8c8a6..13d83c4a02290ce 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AddEditFlyout/index.tsx @@ -25,13 +25,12 @@ import { toastNotifications } from 'ui/notify'; import { i18n } from '@kbn/i18n'; import { isRight } from 'fp-ts/lib/Either'; import { transactionSampleRateRt } from '../../../../../../common/runtime_types/transaction_sample_rate_rt'; -import { useFetcher } from '../../../../../hooks/useFetcher'; import { ENVIRONMENT_NOT_DEFINED } from '../../../../../../common/environment_filter_values'; import { callApmApi } from '../../../../../services/rest/callApmApi'; import { trackEvent } from '../../../../../../../infra/public/hooks/use_track_metric'; import { Config } from '../index'; -import { FlyoutConfigurationSection } from './FlyoutConfigurationSection'; -import { FlyoutServiceSection } from './FlyoutServiceSection'; +import { SettingsSection } from './SettingsSection'; +import { ServiceSection } from './ServiceSection'; import { DeleteSection } from './DeleteSection'; import { transactionMaxSpansRt } from '../../../../../../common/runtime_types/transaction_max_spans_rt'; const t = (id: string, defaultMessage: string, values?: Record) => @@ -55,7 +54,7 @@ export function AddEditFlyout({ }: Props) { const [isSaving, setIsSaving] = useState(false); - // config conditions + // config conditions (servie) const [serviceName, setServiceName] = useState( selectedConfig ? selectedConfig.service.name : '' ); @@ -80,30 +79,6 @@ export function AddEditFlyout({ ).toString() ); - const { data: serviceNames = [], status: serviceNamesStatus } = useFetcher( - () => { - return callApmApi({ - pathname: '/api/apm/settings/agent-configuration/services', - forceCache: true - }); - }, - [], - { preservePreviousData: false } - ); - const { data: environments = [], status: environmentStatus } = useFetcher( - () => { - if (serviceName) { - return callApmApi({ - pathname: - '/api/apm/settings/agent-configuration/services/{serviceName}/environments', - params: { path: { serviceName } } - }); - } - }, - [serviceName], - { preservePreviousData: false } - ); - const isSampleRateValid = isRight(transactionSampleRateRt.decode(sampleRate)); const isTransactionMaxSpansValid = isRight( transactionMaxSpansRt.decode(transactionMaxSpans) @@ -170,21 +145,17 @@ export function AddEditFlyout({ } }} > - - { + setSelectedConfig(null); + setIsFlyoutOpen(false); + }; + return ( <> {isFlyoutOpen && ( { - setSelectedConfig(null); - setIsFlyoutOpen(false); - }} + onClose={onClose} onSaved={() => { - setSelectedConfig(null); - setIsFlyoutOpen(false); + onClose(); refetch(); }} onDeleted={() => { - setSelectedConfig(null); - setIsFlyoutOpen(false); + onClose(); refetch(); }} /> diff --git a/x-pack/legacy/plugins/apm/public/components/shared/StickyProperties/__snapshots__/StickyProperties.test.js.snap b/x-pack/legacy/plugins/apm/public/components/shared/StickyProperties/__snapshots__/StickyProperties.test.js.snap index 860a7a3be7ddf7f..020d5952c03e451 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/StickyProperties/__snapshots__/StickyProperties.test.js.snap +++ b/x-pack/legacy/plugins/apm/public/components/shared/StickyProperties/__snapshots__/StickyProperties.test.js.snap @@ -20,35 +20,6 @@ exports[`StickyProperties should render entire component 1`] = ` "padding": "1em 1em 1em 0", } } - > - - - @timestamp - - } - delay="regular" - position="top" - > - - Timestamp - - - - - - `; - -exports[`StickyProperties values should render timestamp when fieldName is \`@timestamp\` 1`] = ` - -`;