Skip to content

Commit

Permalink
addressing pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Dec 7, 2021
1 parent 524dcd7 commit 5c93cbf
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -114,12 +114,12 @@ interface Props {
title: string;
variantId: string;
createAgentInstructions: CreateAgentInstructions;
AgentRuntimeAttachment?: (props: AgentRuntimeAttachmentProps) => ReactElement;
AgentRuntimeAttachment?: ComponentType<AgentRuntimeAttachmentProps>;
}

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;
}
Expand Down Expand Up @@ -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,
},
{
Expand All @@ -233,7 +236,12 @@ export function AgentInstructionsAccordion({
alignItems="baseline"
gutterSize="s"
>
<EuiFlexItem grow={false}>Auto-Attachment</EuiFlexItem>
<EuiFlexItem grow={false}>
{i18n.translate(
'xpack.apm.fleetIntegration.apmAgent.runtimeAttachment.autoAttachment',
{ defaultMessage: 'Auto-Attachment' }
)}
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiBetaBadge
label={i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ReactElement } from 'react';
import { ComponentType } from 'react';
import {
createDotNetAgentInstructions,
createDjangoAgentInstructions,
Expand Down Expand Up @@ -48,7 +48,7 @@ export const ApmAgentInstructionsMappings: Array<{
title: string;
variantId: string;
createAgentInstructions: CreateAgentInstructions;
AgentRuntimeAttachment?: (props: AgentRuntimeAttachmentProps) => ReactElement;
AgentRuntimeAttachment?: ComponentType<AgentRuntimeAttachmentProps>;
}> = [
{
agentName: 'java',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -13,6 +13,7 @@ import {
EuiBadge,
EuiPanel,
DraggableProvidedDragHandleProps,
EuiButtonIcon,
} from '@elastic/eui';
import React, { useMemo } from 'react';
import { Operation } from '.';
Expand Down Expand Up @@ -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]: {
Expand All @@ -51,14 +57,19 @@ export function DiscoveryRule({
}, {}),
},
};
}, {} as { [operationValue: string]: { label: string; types: { [typeValue: string]: string } } });
}, {});
}, [operationTypes]);

return (
<EuiPanel paddingSize="m" hasBorder={true}>
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={false}>
<div {...providedDragHandleProps} aria-label="Drag Handle">
<div
{...providedDragHandleProps}
aria-label={i18n.translate(
'xpack.apm.fleetIntegration.apmAgent.discoveryRule.DragHandle',
{ defaultMessage: 'Drag Handle' }
)}
>
<EuiIcon type="grab" />
</div>
</EuiFlexItem>
Expand Down Expand Up @@ -87,23 +98,21 @@ export function DiscoveryRule({
<EuiFlexItem grow={false} style={{ marginLeft: 'auto' }}>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiIcon
type="pencil"
<EuiButtonIcon
iconType="pencil"
color="primary"
onClick={() => {
onEdit(id);
}}
style={{ cursor: 'pointer' }}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiIcon
type="trash"
<EuiButtonIcon
iconType="trash"
color="danger"
onClick={() => {
onDelete(id);
}}
style={{ cursor: 'pointer' }}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ export function EditDiscoveryRule({
<EuiPanel paddingSize="m" hasBorder={true}>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiFormFieldset legend={{ children: 'Operation' }}>
<EuiFormFieldset
legend={{
children: i18n.translate(
'xpack.apm.fleetIntegration.apmAgent.editDisacoveryRule.operation',
{ defaultMessage: 'Operation' }
),
}}
>
<EuiSelect
options={operationTypes.map((item) => ({
text: item.operation.label,
Expand All @@ -71,13 +78,20 @@ export function EditDiscoveryRule({
</EuiFlexGroup>
<EuiFlexGroup>
<EuiFlexItem>
<EuiFormFieldset legend={{ children: 'Type' }}>
<EuiFormFieldset
legend={{
children: i18n.translate(
'xpack.apm.fleetIntegration.apmAgent.editDisacoveryRule.type',
{ defaultMessage: 'Type' }
),
}}
>
<EuiFormRow
fullWidth
helpText={i18n.translate(
'xpack.apm.fleetIntegration.apmAgent.runtimeAttachment.editRule.helpText',
{
defaultMessage: 'Choose from allowed params',
defaultMessage: 'Choose from allowed parameters',
}
)}
>
Expand All @@ -104,9 +118,7 @@ export function EditDiscoveryRule({
})) ?? []
}
valueOfSelected={type}
onChange={(value) => {
onChangeType(value);
}}
onChange={onChangeType}
/>
</EuiFormRow>
</EuiFormFieldset>
Expand All @@ -115,7 +127,14 @@ export function EditDiscoveryRule({
{type !== DISCOVERY_RULE_TYPE_ALL && (
<EuiFlexGroup>
<EuiFlexItem>
<EuiFormFieldset legend={{ children: 'Probe' }}>
<EuiFormFieldset
legend={{
children: i18n.translate(
'xpack.apm.fleetIntegration.apmAgent.editDisacoveryRule.probe',
{ defaultMessage: 'Probe' }
),
}}
>
<EuiFormRow
fullWidth
helpText={i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const RuntimeAttachmentExample: Story = () => {
</>
);
};
RuntimeAttachmentExample.storyName = 'RuntimeAttachment';

export const JavaRuntimeAttachmentExample: Story = () => {
return (
Expand All @@ -89,7 +88,6 @@ export const JavaRuntimeAttachmentExample: Story = () => {
/>
);
};
JavaRuntimeAttachmentExample.storyName = 'JavaRuntimeAttachment';

const policy = {
id: 'cc380ec5-d84e-40e1-885a-d706edbdc968',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ export function RuntimeAttachment({
{isEnabled && versions && (
<EuiFlexItem>
<EuiFormRow
label="Version"
label={i18n.translate(
'xpack.apm.fleetIntegration.apmAgent.runtimeAttachment.version',
{ defaultMessage: 'Version' }
)}
isInvalid={!isValidVersion}
error={i18n.translate(
'xpack.apm.fleetIntegration.apmAgent.runtimeAttachment.version.invalid',
Expand Down Expand Up @@ -173,7 +176,10 @@ export function RuntimeAttachment({
disabled={editDiscoveryRuleId !== null}
onClick={onAddRule}
>
Add rule
{i18n.translate(
'xpack.apm.fleetIntegration.apmAgent.runtimeAttachment.addRule',
{ defaultMessage: 'Add rule' }
)}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
RuntimeAttachmentSettings,
IDiscoveryRule,
} from '..';
import {
import type {
NewPackagePolicy,
PackagePolicy,
PackagePolicyEditExtensionComponentProps,
Expand Down

0 comments on commit 5c93cbf

Please sign in to comment.