-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Endpoint] Policy Details integration with Ingest APIs #61827
Changes from all commits
0b2b40d
3a8883a
df16b26
4e220d3
bb5167d
9436893
9f3369c
08aaae0
6a48297
78e35ed
c251cc6
cfaa957
c4d53b2
da31cba
c96c8d2
0cbf623
81f3a9b
2ed3a07
553b9e2
0530e9f
864776e
be5f4a3
25a8222
e57e18d
a18b91a
8e534c1
f6a6268
a6c55ee
3b45458
bdccd82
3f5e3d9
4be1e2b
a63b191
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,24 +20,65 @@ import React, { memo, ReactNode } from 'react'; | |
import styled from 'styled-components'; | ||
|
||
const StyledEuiPage = styled(EuiPage)` | ||
padding: 0; | ||
&.endpoint--isListView { | ||
padding: 0; | ||
|
||
.endpoint-header { | ||
padding: ${props => props.theme.eui.euiSizeL}; | ||
.endpoint-header { | ||
padding: ${props => props.theme.eui.euiSizeL}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GOOOD EYE 👏 FYI: The extra white space here is noticeable because a |
||
} | ||
.endpoint-page-content { | ||
border-left: none; | ||
border-right: none; | ||
} | ||
} | ||
.endpoint-page-content { | ||
border-left: none; | ||
border-right: none; | ||
&.endpoint--isDetailsView { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i see this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :) (there are a few other patterns out there - google |
||
.endpoint-page-content { | ||
padding: 0; | ||
border: none; | ||
background: none; | ||
} | ||
} | ||
`; | ||
|
||
const isStringOrNumber = /(string|number)/; | ||
|
||
/** | ||
* The `PageView` component used to render `headerLeft` when it is set as a `string` | ||
* Can be used when wanting to customize the `headerLeft` value but still use the standard | ||
* title component | ||
*/ | ||
export const PageViewHeaderTitle = memo<{ children: ReactNode }>(({ children }) => { | ||
return ( | ||
<EuiTitle size="l"> | ||
<h1 data-test-subj="pageViewHeaderLeftTitle">{children}</h1> | ||
</EuiTitle> | ||
); | ||
}); | ||
|
||
/** | ||
* The `PageView` component used to render `bodyHeader` when it is set as a `string` | ||
* Can be used when wanting to customize the `bodyHeader` value but still use the standard | ||
* title component | ||
*/ | ||
export const PageViewBodyHeaderTitle = memo<{ children: ReactNode }>( | ||
({ children, ...otherProps }) => { | ||
return ( | ||
<EuiTitle {...otherProps}> | ||
<h2 data-test-subj="pageViewBodyTitle">{children}</h2> | ||
</EuiTitle> | ||
); | ||
} | ||
); | ||
|
||
/** | ||
* Page View layout for use in Endpoint | ||
*/ | ||
export const PageView = memo< | ||
EuiPageProps & { | ||
/** | ||
* The type of view | ||
*/ | ||
viewType: 'list' | 'details'; | ||
/** | ||
* content to be placed on the left side of the header. If a `string` is used, then it will | ||
* be wrapped with `<EuiTitle><h1></h1></EuiTitle>`, else it will just be used as is. | ||
|
@@ -52,17 +93,18 @@ export const PageView = memo< | |
bodyHeader?: ReactNode; | ||
children?: ReactNode; | ||
} | ||
>(({ children, headerLeft, headerRight, bodyHeader, ...otherProps }) => { | ||
>(({ viewType, children, headerLeft, headerRight, bodyHeader, ...otherProps }) => { | ||
return ( | ||
<StyledEuiPage {...otherProps}> | ||
<StyledEuiPage | ||
className={(viewType === 'list' && 'endpoint--isListView') || 'endpoint--isDetailsView'} | ||
{...otherProps} | ||
> | ||
<EuiPageBody> | ||
{(headerLeft || headerRight) && ( | ||
<EuiPageHeader className="endpoint-header"> | ||
<EuiPageHeaderSection data-test-subj="pageViewHeaderLeft"> | ||
{isStringOrNumber.test(typeof headerLeft) ? ( | ||
<EuiTitle size="l"> | ||
<h1>{headerLeft}</h1> | ||
</EuiTitle> | ||
<PageViewHeaderTitle>{headerLeft}</PageViewHeaderTitle> | ||
) : ( | ||
headerLeft | ||
)} | ||
|
@@ -77,11 +119,9 @@ export const PageView = memo< | |
<EuiPageContent className="endpoint-page-content"> | ||
{bodyHeader && ( | ||
<EuiPageContentHeader> | ||
<EuiPageContentHeaderSection data-test-subj="pageViewBodyTitle"> | ||
<EuiPageContentHeaderSection data-test-subj="pageViewBodyTitleArea"> | ||
{isStringOrNumber.test(typeof bodyHeader) ? ( | ||
<EuiTitle> | ||
<h2>{bodyHeader}</h2> | ||
</EuiTitle> | ||
<PageViewBodyHeaderTitle>{bodyHeader}</PageViewBodyHeaderTitle> | ||
) : ( | ||
bodyHeader | ||
)} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { PolicyConfig } from '../types'; | ||
|
||
/** | ||
* Generate a new Policy model. | ||
* NOTE: in the near future, this will likely be removed and an API call to EPM will be used to retrieve | ||
* the latest from the Endpoint package | ||
*/ | ||
export const generatePolicy = (): PolicyConfig => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is essentially our defaults for now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kevinlog Yes, but this will move to the package registry (as part of the Endpoint package) (here: https://github.com/elastic/package-registry/blob/master/dev/packages/example/endpoint-1.0.0/manifest.yml). Once there, it should not be necessary for us to have this generator here (ok - maybe for UT), and if needed, we can use EPM APIs to retrieve it from the package. |
||
return { | ||
windows: { | ||
events: { | ||
process: true, | ||
network: true, | ||
}, | ||
malware: { | ||
mode: 'prevent', | ||
}, | ||
logging: { | ||
stdout: 'debug', | ||
file: 'info', | ||
}, | ||
advanced: { | ||
elasticsearch: { | ||
indices: { | ||
control: 'control-index', | ||
event: 'event-index', | ||
logging: 'logging-index', | ||
}, | ||
kernel: { | ||
connect: true, | ||
process: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
mac: { | ||
events: { | ||
process: true, | ||
}, | ||
malware: { | ||
mode: 'detect', | ||
}, | ||
logging: { | ||
stdout: 'debug', | ||
file: 'info', | ||
}, | ||
advanced: { | ||
elasticsearch: { | ||
indices: { | ||
control: 'control-index', | ||
event: 'event-index', | ||
logging: 'logging-index', | ||
}, | ||
kernel: { | ||
connect: true, | ||
process: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
linux: { | ||
events: { | ||
process: true, | ||
}, | ||
logging: { | ||
stdout: 'debug', | ||
file: 'info', | ||
}, | ||
advanced: { | ||
elasticsearch: { | ||
indices: { | ||
control: 'control-index', | ||
event: 'event-index', | ||
logging: 'logging-index', | ||
}, | ||
kernel: { | ||
connect: true, | ||
process: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { PolicyConfig } from '../types'; | ||
import { UIPolicyConfig } from '../types'; | ||
|
||
/** | ||
* A typed Object.entries() function where the keys and values are typed based on the given object | ||
|
@@ -14,10 +14,10 @@ const entries = <T extends object>(o: T): Array<[keyof T, T[keyof T]]> => | |
type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> }; | ||
|
||
/** | ||
* Returns a deep copy of PolicyDetailsConfig | ||
* Returns a deep copy of `UIPolicyConfig` object | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wew did it werk? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - just needed to get the types right |
||
*/ | ||
export function clone(policyDetailsConfig: PolicyConfig): PolicyConfig { | ||
const clonedConfig: DeepPartial<PolicyConfig> = {}; | ||
export function clone(policyDetailsConfig: UIPolicyConfig): UIPolicyConfig { | ||
const clonedConfig: DeepPartial<UIPolicyConfig> = {}; | ||
for (const [key, val] of entries(policyDetailsConfig)) { | ||
if (typeof val === 'object') { | ||
const valClone: Partial<typeof val> = {}; | ||
|
@@ -41,5 +41,5 @@ export function clone(policyDetailsConfig: PolicyConfig): PolicyConfig { | |
/** | ||
* clonedConfig is typed as DeepPartial so we can construct the copy from an empty object | ||
*/ | ||
return clonedConfig as PolicyConfig; | ||
return clonedConfig as UIPolicyConfig; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also just general question on our code organization: do we need to have a separate components folder? or does it make sense to just have all view related stuff just in the view folder? maybe common components can just be top level in the view folder? 🤷♀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats what I was thinking - top level
components
folder was reusable across all views.my approach also was that if a component from one view needs to be re-used in another View, we would elevate that component here for reuse - so that we're not importing from a sibling, only from a parent or a child of the given view/component.