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

[Security Solution][Endpoint][Guided onboarding] New extension point with the endpoint UI #142395

Merged
Show file tree
Hide file tree
Changes from 11 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
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
es_connection: '',
},
responseActions: `${SECURITY_SOLUTION_DOCS}response-actions.html`,
configureEndpointIntegrationPolicy: `${SECURITY_SOLUTION_DOCS}configure-endpoint-integration-policy.html`,
},
query: {
eql: `${ELASTICSEARCH_DOCS}eql.html`,
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export interface DocLinks {
};
readonly threatIntelInt: string;
readonly responseActions: string;
readonly configureEndpointIntegrationPolicy: string;
};
readonly query: {
readonly eql: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ export const AddIntegrationPageStep: React.FC<MultiPageStepLayoutProps> = (props
return (
extensionView && (
<ExtensionWrapper>
<extensionView.Component newPolicy={packagePolicy} />
<extensionView.Component />
</ExtensionWrapper>
)
);
}, [packagePolicy, extensionView]);
}, [extensionView]);

const content = useMemo(() => {
if (packageInfo.name !== 'endpoint') {
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/fleet/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export type {
PackagePolicyCreateExtensionComponentProps,
PackagePolicyCreateMultiStepExtension,
PackagePolicyCreateMultiStepExtensionComponent,
PackagePolicyCreateMultiStepExtensionComponentProps,
PackagePolicyEditExtension,
PackagePolicyEditExtensionComponent,
PackagePolicyEditExtensionComponentProps,
Expand Down
8 changes: 1 addition & 7 deletions x-pack/plugins/fleet/public/types/ui_extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,7 @@ export interface PackagePolicyCreateExtension {
* UI Component Extension is used on the pages displaying the ability to Create a multi step
* Integration Policy
*/
export type PackagePolicyCreateMultiStepExtensionComponent =
ComponentType<PackagePolicyCreateMultiStepExtensionComponentProps>;

export interface PackagePolicyCreateMultiStepExtensionComponentProps {
/** The integration policy being created */
newPolicy: NewPackagePolicy;
}
export type PackagePolicyCreateMultiStepExtensionComponent = ComponentType<{}>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not remove these props as could be used in the future (or might be used for other integrations) when we add any kind of integration modification action.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, I'd leave them removed to avoid unneeded complexity, and put them back when they are really needed.


/** Extension point registration contract for Integration Policy Create views in multi-step onboarding */
export interface PackagePolicyCreateMultiStepExtension {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,124 @@
*/

import React, { memo } from 'react';
import type { PackagePolicyCreateMultiStepExtensionComponentProps } from '@kbn/fleet-plugin/public';
import {
EuiText,
EuiIcon,
EuiFlexGroup,
EuiFlexItem,
EuiLink,
EuiPanel,
EuiSpacer,
useEuiTheme,
} from '@elastic/eui';
import styled from 'styled-components';
import { css } from '@emotion/css';
import { FormattedMessage } from '@kbn/i18n-react';
import { useKibana } from '../../../../../common/lib/kibana';

const CenteredEuiFlexItem = styled(EuiFlexItem)`
align-items: center;
`;

/**
* TBD: A component to be displayed in multi step onboarding process.
* A component to be displayed in multi step onboarding process.
*/
export const EndpointPolicyCreateMultiStepExtension =
memo<PackagePolicyCreateMultiStepExtensionComponentProps>(({ newPolicy }) => {
return <></>;
});
export const EndpointPolicyCreateMultiStepExtension = memo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move the final component at the end so we see first all the defined consts and finally the component that uses those?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, for functions that returns a component or JSX code I think it would be better to define those inside the component so all are rendered on component render and not on module import level. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move the final component at the end so we see first all the defined consts and finally the component that uses those?

Personally I like it better when the higher level components/functions are on the top of the file, so when one opens it, they can see the high level logic first, and if they want to see the details, they can go down in the file. But I see that your suggestion is the general style in our codebase, so of course! It's better to have an aligned code style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, for functions that returns a component or JSX code I think it would be better to define those inside the component so all are rendered on component render and not on module import level. What do you think?

Great idea! Usually I'd keep small components out of the main component, so the functional components are not re-created on every re-render, but in this case with a static component, I agree that favouring a faster module load is probably better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const { docLinks } = useKibana().services;
const { size } = useEuiTheme().euiTheme;

const title = (
<EuiText>
<h3>
<FormattedMessage
id="xpack.securitySolution.endpoint.policy.multiStepOnboarding.title"
defaultMessage="We'll save your integration with our recommended defaults."
/>
</h3>
</EuiText>
);

const logoSize = `calc(2 * ${size.xxxxl})`;
const securityLogo = (
<EuiIcon
type="logoSecurity"
css={css`
width: ${logoSize};
height: ${logoSize};
`}
/>
);

const features = (
<EuiFlexGroup alignItems="center" gutterSize="s" responsive={false}>
<EuiFlexItem grow={false}>
<EuiIcon type="check" />
</EuiFlexItem>

<EuiFlexItem>
<EuiText size="m">
<p>
<FormattedMessage
id="xpack.securitySolution.endpoint.policy.multiStepOnboarding.feature"
defaultMessage="Windows, Mac, and Linux event collection"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "macOS" (capitalized as such) is the proper name of the operating system, and Apple usually uses "Mac" to refer to a piece of hardware

Suggested change
defaultMessage="Windows, Mac, and Linux event collection"
defaultMessage="Windows, macOS, and Linux event collection"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

/>
</p>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
);

const details = (
<EuiText size="m" color="subdued">
<p>
<FormattedMessage
id="xpack.securitySolution.endpoint.policy.multiStepOnboarding.details"
defaultMessage="You can change this later by editing the Endpoint Security integration agent policy.
Copy link
Contributor

@kellyemurphy kellyemurphy Oct 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Janeen. Edit to @kellyemurphy 's suggestion because we updated the name to Elastic Defend in 8.5.

Suggested change
defaultMessage="You can change this later by editing the Endpoint Security integration agent policy.
defaultMessage="You can edit these settings later in the Elastic Defend integration policy.

Read more about Endpoint security configuration in our {docsPage}."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can shorten this entire sentence to just "Learn more" that links to that doc page and a jumpout icon.

values={{
docsPage: (
<EuiLink
href={docLinks.links.securitySolution.configureEndpointIntegrationPolicy}
target="_blank"
external
>
<FormattedMessage
id="xpack.securitySolution.endpoint.policy.multiStepOnboarding.docsPage"
defaultMessage="documentation"
/>
</EuiLink>
),
}}
/>
</p>
</EuiText>
);

const marginSize = `calc(${size.m} + ${size.l})`;

return (
<EuiPanel hasShadow={false} paddingSize="l">
<EuiSpacer size="xl" />

{title}

<EuiFlexGroup
css={css`
margin-bottom: ${marginSize};
margin-top: ${marginSize};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be padding and not margin. Conceptually, you're padding out the content so that there's spacing around it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks! It also makes things easier, that's for sure.
50d0017

`}
>
<CenteredEuiFlexItem grow={false}>{securityLogo}</CenteredEuiFlexItem>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this additional center alignment. You can just use the EuiFlexItem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the given design, you are right! The center alignment helps with the mobile view.


<EuiFlexItem>
<div>{features}</div>
</EuiFlexItem>
</EuiFlexGroup>

{details}

<EuiSpacer size="xl" />
</EuiPanel>
);
});
EndpointPolicyCreateMultiStepExtension.displayName = 'EndpointPolicyCreateMultiStepExtension';