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][Timeline] Notes management table #187214

Merged
merged 33 commits into from
Jul 2, 2024

Conversation

kqualters-elastic
Copy link
Contributor

@kqualters-elastic kqualters-elastic commented Jul 1, 2024

Summary

This pr adds a new notes management table, where notes from any timeline + notes not associated with a timeline can be viewed, searched, and deleted (for now). Hidden behind the securitySolutionNotesEnabled feature flag, the new page is a tab of the timelines pages, and will only appear in global search when the flag is enabled. Uses the previously added api from a table, and notes can be deleted individually or a page at a time.
notes_table
t

Checklis

Delete any items that are not applicable to this PR.

@kqualters-elastic kqualters-elastic added the Team:Threat Hunting:Investigations Security Solution Investigations Team label Jul 1, 2024
@PhilippeOberti PhilippeOberti force-pushed the notes-management-table branch 2 times, most recently from 61c0524 to 0145a48 Compare July 1, 2024 12:35
- remove ids from pendingDeleteIds on delete success
- remove no notes empty prompts and related translations
- remove unnecessary index file
- change data-test-subj to be more specific
- merged deleteNote and deleteNotes
- added unit tests
@PhilippeOberti PhilippeOberti force-pushed the notes-management-table branch from 0145a48 to 0b5e41e Compare July 1, 2024 12:39
Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

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

overall this is amazing! You will see that I took the liberty of pushing one commit to fix a few things. Feel free to revert the commit if you don't like the changes~!

  • fix an issue with the translation displayed in the delete note modal
  • remove the ids from the pendingDeleteIds when the deleteNotes action succeeds or the modal was staying open
  • made some small tweaks to the data-test-subj to make them more specific
  • merged the deleteNote and deleteNotes actions as we don't really need both (I updated all the code and tests where the old deleteNote action was used
  • added some unit tests for the notes.slice file

Here are some things that I found during review that still could/need to be fixed:

  • searching requires the full string to be written, you can't search with partial string. I find this annoying but I've seen this behavior in other pages (like the rules page)
  • should we display the document ids (eventId) and/or the saved object ids (timelineId) in the notes management table?
  • deleting a note doesn't update the total number of notes in the pagination section. It also doesn't refresh the table correctly.

@@ -122,10 +212,37 @@ const notesSlice = createSlice({
.addCase(deleteNote.fulfilled, (state, action) => {
notesAdapter.removeOne(state, action.payload);
state.status.deleteNote = ReqStatus.Succeeded;
state.pendingDeleteIds = state.pendingDeleteIds.filter((id) => id !== action.payload);
Copy link
Contributor

Choose a reason for hiding this comment

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

I added here the code to remove the id from the pendingDeleteIds property. I originally had cleared everything (state.pendingDeleteIds = []) but then decided that this action should do just what it's supposed to and nothing more...


export const selectNotesTableSort = (state: State) => state.notes.sort;

export const selectNotesTableTotalItems = (state: State) => state.notes.pagination.total;
Copy link
Contributor

@PhilippeOberti PhilippeOberti Jul 1, 2024

Choose a reason for hiding this comment

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

I wonder why this selector is necessary/useful? Why not using the selectNotesPagination right above? We already use the other one in a few places, and we even destructure the properties (like

const pagination = useSelector(selectNotesPagination);
const { perPage, page } = pagination;

for example)

Copy link
Contributor

Choose a reason for hiding this comment

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

any reason @kqualters-elastic?

@kqualters-elastic kqualters-elastic changed the title [Security Solution][Timeline] WIP/DNM Notes management table [Security Solution][Timeline] Notes management table Jul 1, 2024
@kqualters-elastic kqualters-elastic added v8.15.0 release_note:skip Skip the PR/issue when compiling release notes labels Jul 1, 2024
@kqualters-elastic kqualters-elastic marked this pull request as ready for review July 1, 2024 14:22
@kqualters-elastic kqualters-elastic requested review from a team as code owners July 1, 2024 14:22
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting-investigations (Team:Threat Hunting:Investigations)

Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

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

the code looks good, I'll do a last round of testing first thing tomorrow morning my time as it's getting late here!

Copy link
Contributor

Choose a reason for hiding this comment

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

so many tests ❤️


export const selectNotesTableSort = (state: State) => state.notes.sort;

export const selectNotesTableTotalItems = (state: State) => state.notes.pagination.total;
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason @kqualters-elastic?

@kqualters-elastic
Copy link
Contributor Author

@PhilippeOberti no, will remove

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] x-pack/test/alerting_api_integration/security_and_spaces/group1/config.ts / alerting api integration security and spaces enabled Alerts - Group 1 alerts backfill rule runs find backfill superuser at space1 should handle finding backfill requests with query string appropriately

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 5582 5587 +5

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 15.5MB 15.6MB +42.4KB
Unknown metric groups

ESLint disabled line counts

id before after diff
securitySolution 551 549 -2

Total ESLint disabled count

id before after diff
securitySolution 634 632 -2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@parkiino parkiino left a comment

Choose a reason for hiding this comment

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

Management part looks fine

Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

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

the code looks good to me, a few minor UI issues remaining (like total not updating after delete one or multiple notes) but we can fix that in a follow up PR!

Nice job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Investigations Security Solution Investigations Team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants