Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SIEM][CASE] Configuration pages UI redesign #65355

Merged
merged 6 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ describe('Connectors', () => {
let wrapper: ReactWrapper;
const onChangeConnector = jest.fn();
const handleShowAddFlyout = jest.fn();
const handleShowEditFlyout = jest.fn();

const props: Props = {
disabled: false,
updateConnectorDisabled: false,
connectors,
selectedConnector: 'none',
isLoading: false,
onChangeConnector,
handleShowAddFlyout,
handleShowEditFlyout,
};

beforeAll(() => {
Expand Down Expand Up @@ -87,4 +91,16 @@ describe('Connectors', () => {
expect(onChangeConnector).toHaveBeenCalled();
expect(onChangeConnector).toHaveBeenCalledWith('none');
});

test('the text of the update button is shown correctly', () => {
const newWrapper = mount(<Connectors {...props} selectedConnector={'servicenow-1'} />, {
wrappingComponent: TestProviders,
});

expect(
newWrapper
.find('button[data-test-subj="case-configure-update-selected-connector-button"]')
.text()
).toBe('Update My Connector');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import React, { useMemo } from 'react';
import {
EuiDescribedFormGroup,
EuiFormRow,
EuiFlexGroup,
EuiFlexItem,
EuiLink,
EuiButton,
} from '@elastic/eui';

import styled from 'styled-components';
Expand All @@ -28,35 +29,55 @@ const EuiFormRowExtended = styled(EuiFormRow)`
}
`;

const AddConnectorEuiFormRow = styled(EuiFormRow)`
width: 100%;
max-width: 100%;
text-align: right;
`;

export interface Props {
connectors: Connector[];
disabled: boolean;
isLoading: boolean;
updateConnectorDisabled: boolean;
onChangeConnector: (id: string) => void;
selectedConnector: string;
handleShowAddFlyout: () => void;
handleShowEditFlyout: () => void;
}
const ConnectorsComponent: React.FC<Props> = ({
connectors,
disabled,
isLoading,
disabled,
updateConnectorDisabled,
onChangeConnector,
selectedConnector,
handleShowAddFlyout,
handleShowEditFlyout,
}) => {
const dropDownLabel = (
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>{i18n.INCIDENT_MANAGEMENT_SYSTEM_LABEL}</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiLink
disabled={disabled}
onClick={handleShowAddFlyout}
data-test-subj="case-configure-add-connector-button"
>
{i18n.ADD_NEW_CONNECTOR}
</EuiLink>
</EuiFlexItem>
</EuiFlexGroup>
const connectorsName = useMemo(
() => connectors.find(c => c.id === selectedConnector)?.name ?? 'none',
[connectors, selectedConnector]
);

const dropDownLabel = useMemo(
() => (
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>{i18n.INCIDENT_MANAGEMENT_SYSTEM_LABEL}</EuiFlexItem>
<EuiFlexItem grow={false}>
{connectorsName !== 'none' && (
<EuiLink
disabled={updateConnectorDisabled}
onClick={handleShowEditFlyout}
data-test-subj="case-configure-update-selected-connector-button"
>
{i18n.UPDATE_SELECTED_CONNECTOR(connectorsName)}
</EuiLink>
)}
</EuiFlexItem>
</EuiFlexGroup>
),
[connectorsName]
);

return (
Expand All @@ -81,6 +102,16 @@ const ConnectorsComponent: React.FC<Props> = ({
data-test-subj="case-connectors-dropdown"
/>
</EuiFormRowExtended>
<AddConnectorEuiFormRow>
<EuiButton
fill
disabled={disabled}
onClick={handleShowAddFlyout}
data-test-subj="case-configure-add-connector-button"
>
{i18n.ADD_NEW_CONNECTOR}
</EuiButton>
</AddConnectorEuiFormRow>
</EuiDescribedFormGroup>
</>
);
Expand Down
Loading