-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Asset Criticality UI #173011
Asset Criticality UI #173011
Conversation
<EuiSpacer size="m" /> | ||
<AssetCriticalitySelector entity={{ type: 'host', name: hostName }} /> |
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.
Still not sure if this is the correct placement? @SourinPaul
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.
After discussing with Pablo, we were wondering if it also needs to show up in the user flyout in the timeline?
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.
Still not sure if this is the correct placement? @SourinPaul
Can we move the assignment component before displaying host metadata? The accordion can stay collapsed.
After discussing with Pablo, we were wondering if it also needs to show up in the user flyout in the timeline?
In short, yes. The users should be able to assign from every instance of the user flyout, including the timeline. Afaik, this user flyout component is reused everywhere in our app for consistency. I may be incorrect, so worth double checking that.
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.
Afaik, this user flyout component is reused everywhere in our app for consistency. I may be incorrect, so worth double checking that.
Not a direct answer, but regarding consistency, today the timeline view does not support the new expanded flyouts. This means that, today, even when we have the new users flyout enabled, the timeline view still shows the old flyout.
I'm working to find an answer for when the timeline view will support expanded flyouts, so that this discrepancy will be fixed.
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.
@jaredburgettelastic The key here is that the timeline does not use flyouts, hence the discrepancy. Perhaps it should?
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.
The key here is that the timeline does not use flyouts
Apologies for the lack of clarity, to make this more clear:
This means that, today, even when we have the new users flyout enabled, the timeline view still shows
the old flyouta panel containing many of the same components used by the old host/user flyout, but embedded directly into the timeline view.
); | ||
}; | ||
|
||
const useAssetCriticality = (entity: Entity): State => { |
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.
Not sure if this is the correct place for this hook?
This is under the components
folder, maybe we want the hook logic somewhere else?
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.
Maybe security_solution/public/entity_analytics/hooks/use_asset_criticality.ts
?
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.
use_asset_criticality
looks like a single usage hook. You could create a folder for the component for asset_criticality
inside components
and encapsulate everything related to the component inside the 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.
done.
As discussed I separated the hook into one dealing with data fetching and another for the modal and placed them in a file under the new asset criticality directory
const QC = useQueryClient(); | ||
|
||
const privileges = useQuery({ | ||
queryKey: ['ASSET_CRITICALITY', 'PRIVILEGES', entity.name], |
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.
Do we have common place for react-query
keys?
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.
Moved this to a new file in the new asset criticality folder
type: 'host' | 'user'; | ||
} | ||
|
||
const criticalityDisplayText: Record<AssetCriticalityRecord['criticality_level'], string> = { |
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.
Should this also be moved to a different file? It seems like this mapping might apply anywhere we deal with asset criticality levels?
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.
This looks like a translation map, shouldn't we use i18n
for the texts?
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.
Done.
export const ASSET_CRITICALITY_INDEX_PATTERN = '.asset-criticality.asset-criticality-*'; | ||
|
||
type AssetCriticalityIndexPrivilege = 'read' | 'write'; | ||
export const ASSET_CRITICALITY_REQUIRED_ES_INDEX_PRIVILEGES = { | ||
[ASSET_CRITICALITY_INDEX_PATTERN]: ['read', 'write'] as AssetCriticalityIndexPrivilege[], | ||
}; | ||
|
||
export const PICK_ASSET_CRITICALITY = i18n.translate( |
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.
I wonder if this is also the correct place to place this common stuff?
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.
Not the best place, as a general rule of thumb:
security_solution/common/*
-> shared betweenpublic
andserver
directories (URLs, indexPatterns, privileges..)security_solution/public/common/*
-> shared betweenpublic
"sub-plugin" directories (reusable components, reusable hooks, paths, constants...)
These translations, however, do not seem to be common stuff, they are only used in the security_solution/public/entity_analytics/components/asset_criticality_selector.tsx
component.
So, it would be better to put them in a new translations file inside the same directory, like: security_solution/public/entity_analytics/components/translations.ts
.
However, how things are organized inside the security_solution/public/entity_analytics
directory is up to your team.
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.
security_solution/public/entity_analytics/components/translations.ts
is a good option. The docs recommend inlining the copy into the react component using <FormattedMessage>
.
You can read more here: https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/GUIDELINE.md
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.
Yeah, I think @hop-dev just had a PR that moved stuff around quite a bit within EA?
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.
I moved stuff around, most of this stuff now lives along side the component in a new asset criticality folder within EA
c448f27
to
65e5d20
Compare
x-pack/plugins/security_solution/public/entity_analytics/api/api.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/entity_analytics/api/api.ts
Outdated
Show resolved
Hide resolved
.../plugins/security_solution/public/entity_analytics/components/asset_criticality_selector.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/common/asset_criticality/constants.ts
Outdated
Show resolved
Hide resolved
fill | ||
data-test-subj="asset-criticality-modal-save-btn" | ||
> | ||
{'Save'} |
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.
Please use i18n
to allow translation.
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.
Done.
export const ASSET_CRITICALITY_INDEX_PATTERN = '.asset-criticality.asset-criticality-*'; | ||
|
||
type AssetCriticalityIndexPrivilege = 'read' | 'write'; | ||
export const ASSET_CRITICALITY_REQUIRED_ES_INDEX_PRIVILEGES = { | ||
[ASSET_CRITICALITY_INDEX_PATTERN]: ['read', 'write'] as AssetCriticalityIndexPrivilege[], | ||
}; | ||
|
||
export const PICK_ASSET_CRITICALITY = i18n.translate( |
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.
security_solution/public/entity_analytics/components/translations.ts
is a good option. The docs recommend inlining the copy into the react component using <FormattedMessage>
.
You can read more here: https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/GUIDELINE.md
.../plugins/security_solution/public/entity_analytics/components/asset_criticality_selector.tsx
Outdated
Show resolved
Hide resolved
<> | ||
<EuiAccordion | ||
id="asset-criticality-selector" | ||
buttonContent="Asset Criticality" |
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.
i18n
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.
Done
|
||
const useAssetCriticality = (entity: Entity): State => { | ||
const [visible, toggleModal] = useToggle(false); | ||
const modal = { visible, toggle: (next: boolean) => () => toggleModal(next) }; |
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.
This object will update on every hook execution.
I would rather move the toggle state to the component itself so we don't have to create this object.
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.
Moved to a different hook
); | ||
}; | ||
|
||
const useAssetCriticality = (entity: Entity): State => { |
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.
use_asset_criticality
looks like a single usage hook. You could create a folder for the component for asset_criticality
inside components
and encapsulate everything related to the component inside the folder.
65e5d20
to
dbb1a5a
Compare
import type { CriticalityLevel } from './common'; | ||
|
||
export const PICK_ASSET_CRITICALITY = i18n.translate( | ||
'xpack.securitySolution.timeline.sidePanel.hostDetails.assetCriticality.pick', |
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.
nit: The id xpack.securitySolution.timeline.sidePanel.hostDetails.assetCriticality.pick
looks outdated
/** | ||
* Find the first alert row in the alerts table then click on the host name to open the flyout | ||
*/ | ||
export const expandFirstAlertHostExpandableFlyout = () => { |
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.
I noticed that you created files and functions inside the cypress folder containing HostExpandableFlyout
, but there isn't a host expandable flyout yet. We are going to create it soon, but for now, we only have a HostFlyout
.
ex: expandable_flyout/host_details_right_panel.ts
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.
Yeah, that whole thing is weird.
I was pairing with @jaredburgettelastic and we figured that was the best place to add the test. Do you have a better option?
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.
A recently merged PR created this folder x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics
. I believe that we should put all entity_analytics
tests there.
Please don't name it "expandable" if it is testing the old flyout.
adding footer btns to the modal improving tests
using react-query
daf8e91
to
f95165c
Compare
fca815b
to
b02c9c4
Compare
b02c9c4
to
a27f094
Compare
Summary
This PR adds the UI to assign asset criticality in the old host flyout. #8086
asset-criticality.demo.mov
Checklist
Delete any items that are not applicable to this PR.