-
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
[Cases] Deleting file attachments from a case #154432
[Cases] Deleting file attachments from a case #154432
Conversation
Created FileDeleteButtonIcon. Created deleteFileAttachments public api. Created useDeleteFileAttachment hook.
Added FileDeleteButtonIcon tests. Added useDeleteFileAttachment tests.
Pinging @elastic/response-ops (Team:ResponseOps) |
Pinging @elastic/response-ops-cases (Feature:Cases) |
2f7a7b4
to
483ffce
Compare
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.
fileIds: string[]; | ||
signal: AbortSignal; | ||
}): Promise<void> => { | ||
await KibanaServices.get().http.fetch<CaseResponse>( |
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: I think we should remove the type (CaseResponse
) as the endpoint does not return a case response.
{ | ||
mutationKey: casesMutationsKeys.deleteFileAttachment, | ||
onSuccess: (_, { successToasterTitle }) => { | ||
showSuccessToast(successToasterTitle); |
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: As this hook is only for file deletions maybe we can hardcoded the success toaster title.
refreshAttachmentsTable(); | ||
}, | ||
onError: (error: ServerError) => { | ||
showErrorToast(error, { title: i18n.ERROR_TITLE }); |
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 ERROR_TITLE
equals to Error fetching data.
We should change it to ERROR_DELETING
(Error deleting data
) or have a custom one only for files, "Error deleting file (s)" for example.
jest.clearAllMocks(); | ||
}); | ||
|
||
it('init', async () => { |
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 don't think we need this test.
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.
Can you add a test where we delete a file from the files table?
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.
Can you add a test where we delete a file from the user activity?
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.
Addressed PR comments.
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.
LGMT! Don't forget to add the tests.
Added delete button tests for files_table.
I'm not sure @js-jankisalvi check out on mine. They look different, right? Yours looks worse 😅 |
yeah, yours look better. Not sure why it looked weird on mine 😄 |
💔 Build FailedFailed CI StepsMetrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @adcoelho |
Fixes #151595 ## Summary In this PR we will be merging a feature branch into `main`. This feature branch is a collection of several different PRs with file functionality for cases. - #152941 - #153957 - #154432 - #153853 Most of the code was already reviewed so this will mainly be used for testing. - Files tab in the case detail view. - Attach files to a case. - View a list of all files attached to a case (with pagination). - Preview image files attached to a case. - Search for files attached to a case by file name. - Download files attached to a case. - Users are now able to see file activity in the case detail view. - Image files have a different icon and a clickable file name to preview. - Other files have a standard "document" icon and the name is not clickable. - The file can be downloaded by clicking the download icon. ## Release notes Support file attachments in Cases. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Summary
In this PR we add the ability to delete files attached to a case.
This can be done in the Case detail view either in the
Files tab
or the
Activity tab
When a file is deleted the file activity item is replaced by a removed attachment activity item.