From 03050c68d67bc23e429e6e258d906515ad8552f1 Mon Sep 17 00:00:00 2001 From: Paul Tavares <56442535+paul-tavares@users.noreply.github.com> Date: Mon, 5 Oct 2020 08:04:46 -0400 Subject: [PATCH] [SECURITY_SOLUTION][ENDPOINT] Trusted apps create form UX mocks sync (#79155) (#79350) * Make flyout size `m` + condition entry value should be 100% wide * Condition entry and group components support for small screens * Adjust spacing below each entry in the condition group * Move `AND` button to the condition group + style it to design mock --- .../create_trusted_app_form.test.tsx | 2 +- .../components/condition_entry.tsx | 2 + .../components/condition_group.tsx | 107 ++++++++++++++---- .../logical_condition_builder.tsx | 27 +---- .../trusted_apps/view/trusted_apps_page.tsx | 2 +- 5 files changed, 92 insertions(+), 48 deletions(-) diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/create_trusted_app_form.test.tsx b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/create_trusted_app_form.test.tsx index dd4f389f04705..211fc9ec3371e 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/create_trusted_app_form.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/create_trusted_app_form.test.tsx @@ -76,7 +76,7 @@ describe('When showing the Trusted App Create Form', () => { dataTestSub: string = dataTestSubjForForm ): HTMLButtonElement => { return renderResult.getByTestId( - `${dataTestSub}-conditionsBuilder-AndButton` + `${dataTestSub}-conditionsBuilder-group1-AndButton` ) as HTMLButtonElement; }; const getConditionBuilderAndConnectorBadge = ( diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/logical_condition/components/condition_entry.tsx b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/logical_condition/components/condition_entry.tsx index 60abcc2eeeefc..55d0622c3f9a9 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/logical_condition/components/condition_entry.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/logical_condition/components/condition_entry.tsx @@ -130,6 +130,7 @@ export const ConditionEntry = memo( alignItems="center" direction="row" data-test-subj={dataTestSubj} + responsive={false} > ( { + return `calc(${theme.eui.euiButtonHeightSmall} + (${theme.eui.paddingSizes.s} * 2) + 3px);`; + }}; + } + + .group-entries { + margin-bottom: ${({ theme }) => theme.eui.paddingSizes.s}; + + & > * { + margin-bottom: ${({ theme }) => theme.eui.paddingSizes.s}; + + &:last-child { + margin-bottom: 0; + } + } + } + + .and-button { + min-width: 95px; + } `; export interface ConditionGroupProps { @@ -20,12 +45,23 @@ export interface ConditionGroupProps { entries: TrustedApp['entries']; onEntryRemove: ConditionEntryProps['onRemove']; onEntryChange: ConditionEntryProps['onChange']; + onAndClicked: () => void; + isAndDisabled?: boolean; /** called when any of the entries is visited (triggered via `onBlur` DOM event) */ onVisited?: ConditionEntryProps['onVisited']; 'data-test-subj'?: string; } export const ConditionGroup = memo( - ({ os, entries, onEntryRemove, onEntryChange, onVisited, 'data-test-subj': dataTestSubj }) => { + ({ + os, + entries, + onEntryRemove, + onEntryChange, + onAndClicked, + isAndDisabled, + onVisited, + 'data-test-subj': dataTestSubj, + }) => { const getTestId = useCallback( (suffix: string): string | undefined => { if (dataTestSubj) { @@ -35,28 +71,53 @@ export const ConditionGroup = memo( [dataTestSubj] ); return ( - + {entries.length > 1 && ( - - - + + + + + )} - - {(entries as (NewTrustedApp & { os: 'windows' })['entries']).map((entry, index) => ( - - ))} + +
+ {(entries as (NewTrustedApp & { os: 'windows' })['entries']).map((entry, index) => ( + + ))} +
+
+ + + + +
-
+ ); } ); diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/logical_condition/logical_condition_builder.tsx b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/logical_condition/logical_condition_builder.tsx index 84bfe1c1d2dc9..3ae2b13326b23 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/logical_condition/logical_condition_builder.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/components/logical_condition/logical_condition_builder.tsx @@ -5,17 +5,11 @@ */ import React, { memo, useCallback } from 'react'; -import { EuiButton, CommonProps, EuiText, EuiSpacer, EuiPanel } from '@elastic/eui'; +import { CommonProps, EuiText, EuiPanel } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { ConditionGroup, ConditionGroupProps } from './components/condition_group'; -const BUTTON_MIN_WIDTH = Object.freeze({ minWidth: '95px' }); - -export type LogicalConditionBuilderProps = CommonProps & - ConditionGroupProps & { - onAndClicked: () => void; - isAndDisabled?: boolean; - }; +export type LogicalConditionBuilderProps = CommonProps & ConditionGroupProps; export const LogicalConditionBuilder = memo( ({ entries, @@ -47,26 +41,13 @@ export const LogicalConditionBuilder = memo( entries={entries} onEntryRemove={onEntryRemove} onEntryChange={onEntryChange} + onAndClicked={onAndClicked} + isAndDisabled={isAndDisabled} onVisited={onVisited} data-test-subj={getTestId('group1')} /> )} - - - - ); } diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx index 878818d9b77fe..533ffc6487aca 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.tsx @@ -85,7 +85,7 @@ export const TrustedAppsPage = memo(() => { {showAddFlout && ( )}