From 5c93cbfb1c9ea9e649d724335b43c2a09176433e Mon Sep 17 00:00:00 2001 From: cauemarcondes Date: Tue, 7 Dec 2021 15:30:35 -0500 Subject: [PATCH] addressing pr comments --- .../agent_instructions_accordion.tsx | 22 +++++++++---- .../apm_agents/agent_instructions_mappings.ts | 4 +-- .../runtime_attachment/discovery_rule.tsx | 31 ++++++++++------- .../edit_discovery_rule.tsx | 33 +++++++++++++++---- .../runtime_attachment.stories.tsx | 2 -- .../runtime_attachment/runtime_attachment.tsx | 10 ++++-- .../java_runtime_attachment.tsx | 2 +- 7 files changed, 72 insertions(+), 32 deletions(-) diff --git a/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/agent_instructions_accordion.tsx b/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/agent_instructions_accordion.tsx index 6757db1fe3580..a82fa3121bb3b 100644 --- a/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/agent_instructions_accordion.tsx +++ b/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/agent_instructions_accordion.tsx @@ -16,7 +16,7 @@ import { EuiBetaBadge, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import React, { ReactElement } from 'react'; +import React, { ComponentType } from 'react'; import styled from 'styled-components'; import { AgentRuntimeAttachmentProps, @@ -28,7 +28,7 @@ import { } from '../../../../../../../src/plugins/kibana_react/public'; import { AgentName } from '../../../../typings/es_schemas/ui/fields/agent'; import { AgentIcon } from '../../shared/agent_icon'; -import { +import type { NewPackagePolicy, PackagePolicy, PackagePolicyEditExtensionComponentProps, @@ -114,12 +114,12 @@ interface Props { title: string; variantId: string; createAgentInstructions: CreateAgentInstructions; - AgentRuntimeAttachment?: (props: AgentRuntimeAttachmentProps) => ReactElement; + AgentRuntimeAttachment?: ComponentType; } const StyledEuiAccordion = styled(EuiAccordion)` - //This is an alternative fix suggested by the EUI team to fix drag elements inside EuiAccordion - //This Issue tracks the fix on the Eui side https://github.com/elastic/eui/issues/3548#issuecomment-639041283 + // This is an alternative fix suggested by the EUI team to fix drag elements inside EuiAccordion + // This Issue tracks the fix on the Eui side https://github.com/elastic/eui/issues/3548#issuecomment-639041283 .euiAccordion__childWrapper { transform: none; } @@ -222,7 +222,10 @@ export function AgentInstructionsAccordion({ tabs={[ { id: 'manual-instrumentation', - name: 'Manual instrumentation', + name: i18n.translate( + 'xpack.apm.fleetIntegration.apmAgent.runtimeAttachment.manualInstrumentation', + { defaultMessage: 'Manual instrumentation' } + ), content: manualInstrumentationContent, }, { @@ -233,7 +236,12 @@ export function AgentInstructionsAccordion({ alignItems="baseline" gutterSize="s" > - Auto-Attachment + + {i18n.translate( + 'xpack.apm.fleetIntegration.apmAgent.runtimeAttachment.autoAttachment', + { defaultMessage: 'Auto-Attachment' } + )} + ReactElement; + AgentRuntimeAttachment?: ComponentType; }> = [ { agentName: 'java', diff --git a/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/discovery_rule.tsx b/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/discovery_rule.tsx index 7473044ed5449..f7b1b3db3a4c4 100644 --- a/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/discovery_rule.tsx +++ b/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/discovery_rule.tsx @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import { i18n } from '@kbn/i18n'; import { EuiText, EuiFlexGroup, @@ -13,6 +13,7 @@ import { EuiBadge, EuiPanel, DraggableProvidedDragHandleProps, + EuiButtonIcon, } from '@elastic/eui'; import React, { useMemo } from 'react'; import { Operation } from '.'; @@ -41,7 +42,12 @@ export function DiscoveryRule({ operationTypes, }: Props) { const operationTypesLabels = useMemo(() => { - return operationTypes.reduce((acc, current) => { + return operationTypes.reduce<{ + [operationValue: string]: { + label: string; + types: { [typeValue: string]: string }; + }; + }>((acc, current) => { return { ...acc, [current.operation.value]: { @@ -51,14 +57,19 @@ export function DiscoveryRule({ }, {}), }, }; - }, {} as { [operationValue: string]: { label: string; types: { [typeValue: string]: string } } }); + }, {}); }, [operationTypes]); - return ( -
+
@@ -87,23 +98,21 @@ export function DiscoveryRule({ - { onEdit(id); }} - style={{ cursor: 'pointer' }} /> - { onDelete(id); }} - style={{ cursor: 'pointer' }} /> diff --git a/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/edit_discovery_rule.tsx b/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/edit_discovery_rule.tsx index 4d07ce5f4e2fd..5059bbabfce91 100644 --- a/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/edit_discovery_rule.tsx +++ b/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/edit_discovery_rule.tsx @@ -55,7 +55,14 @@ export function EditDiscoveryRule({ - + ({ text: item.operation.label, @@ -71,13 +78,20 @@ export function EditDiscoveryRule({ - + @@ -104,9 +118,7 @@ export function EditDiscoveryRule({ })) ?? [] } valueOfSelected={type} - onChange={(value) => { - onChangeType(value); - }} + onChange={onChangeType} /> @@ -115,7 +127,14 @@ export function EditDiscoveryRule({ {type !== DISCOVERY_RULE_TYPE_ALL && ( - + { ); }; -RuntimeAttachmentExample.storyName = 'RuntimeAttachment'; export const JavaRuntimeAttachmentExample: Story = () => { return ( @@ -89,7 +88,6 @@ export const JavaRuntimeAttachmentExample: Story = () => { /> ); }; -JavaRuntimeAttachmentExample.storyName = 'JavaRuntimeAttachment'; const policy = { id: 'cc380ec5-d84e-40e1-885a-d706edbdc968', diff --git a/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/runtime_attachment.tsx b/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/runtime_attachment.tsx index 01b4750780410..3592eb4f04745 100644 --- a/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/runtime_attachment.tsx +++ b/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/runtime_attachment.tsx @@ -123,7 +123,10 @@ export function RuntimeAttachment({ {isEnabled && versions && ( - Add rule + {i18n.translate( + 'xpack.apm.fleetIntegration.apmAgent.runtimeAttachment.addRule', + { defaultMessage: 'Add rule' } + )} diff --git a/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/supported_agents/java_runtime_attachment.tsx b/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/supported_agents/java_runtime_attachment.tsx index beb2db14ee902..2284315d4a6ba 100644 --- a/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/supported_agents/java_runtime_attachment.tsx +++ b/x-pack/plugins/apm/public/components/fleet_integration/apm_agents/runtime_attachment/supported_agents/java_runtime_attachment.tsx @@ -14,7 +14,7 @@ import { RuntimeAttachmentSettings, IDiscoveryRule, } from '..'; -import { +import type { NewPackagePolicy, PackagePolicy, PackagePolicyEditExtensionComponentProps,