-
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] Detail View Attachments Table #152941
[Cases] Detail View Attachments Table #152941
Conversation
x-pack/plugins/cases/public/containers/use_get_case_attachments.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/containers/use_get_case_attachments.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/attachments/attachments_table.test.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/attachments/attachments_table.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/attachments/attachments_table.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/attachments/attachments_table.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/attachments/attachments_table.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/attachments/attachments_table.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/case_view/components/case_view_attachments.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/case_view/components/case_view_attachments.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/case_view/components/case_view_attachments.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/case_view/components/case_view_attachments.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/attachments/attachments_table.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/containers/use_get_case_attachments.tsx
Outdated
Show resolved
Hide resolved
74290d2
to
de3165c
Compare
FilePreview is no longer a modal.
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.
Very good job! I left some comments.
x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx
Outdated
Show resolved
Hide resolved
This is looking great. So cool to see the file service getting used outside of the image embeddable already. |
Cleanup case_view_files tests. Move caseId out of filteringOptions. Add type guard for owner in cases context. Use useCasesToast in add_file component.
Add spacer for loading FilesTable. Use file name as "alt" in FilePreview. Remove HiddenButtonGroup from utility bar. Improve query keys for caseFiles. Remove owner from useGetCaseFiles.
Pass correct owner to definitions of the file kind.
…nto cases-detail-attachments-table
Change file name and mime type in files table.
Improve FilesTable tests. Add FilesUtilityBar tests. Add UseGetCaseFiles tests.
name: i18n.TYPE, | ||
'data-test-subj': 'cases-files-table-filetype', | ||
render: (attachment: FileJSON) => { | ||
return <span>{`${attachment.mimeType?.split('/')[0]}` || ''}</span>; |
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.
As the is inside the ticks anything undefined
will render to "undefined" (a string) and ||
will not work except an empty string. What about moving to a function, taking care of edge cases, and returning "Unknown" if there is no mimeType
or attachment.mimeType?.split('/')
is an empty array or attachment.mimeType?.split('/')
contains an empty string, etc. Maybe we can also capitalize the first letter. Not for this PR but about application files, I see that we show the word "application". Do we want that or it is better to say "Zip", "PDF", etc?
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 for this PR but about application files, I see that we show the word "application". Do we want that or it is better to say "Zip", "PDF", etc?
I guess that would be not much different than the file type which is what we had before and was changed due to a previous conversation with @jonathan-buttner and @mdefazio 😅
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.
It is not the same 🙂 . For the "image" is fine. It's an image. For applications/*
though the file is not an application, is a ZIP, PDF, Text, etc. Also. it does not mean that the second part of the mime type describes correctly the type. We may need our own mapping for that. I think it is fine as it is now. Let's discuss it offline if we should improve it.
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 think application
for me means an executable so I don't think we should show that. I think it'd be better to show Compressed
if we want to group zip, gzip, 7z etc into one. I think PDF, Plain Text, and JSON probably make sense for the others.
x-pack/plugins/cases/public/components/files/use_files_table_columns.test.tsx
Outdated
Show resolved
Hide resolved
@@ -20,10 +20,13 @@ const buildFileKind = (owner: Owner): FileKindBrowser => { | |||
}; | |||
}; | |||
|
|||
export const isRegisteredOwner = (ownerToCheck: string): ownerToCheck is Owner => | |||
ownerToCheck in CASES_FILE_KINDS; |
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.
For security reasons, it is better if we use Object.hasOwn(CASES_FILE_KINDS, ownerToCheck)
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.
Another option would be to compare against the OWNERS
array directly: https://github.com/elastic/kibana/blob/main/x-pack/plugins/cases/common/constants/owners.ts#L18
I also need something similar:
const isValidOwner = (ownerToValidate: string): ownerToValidate is Owner => {
const foundOwner = OWNERS.find((validOwner) => validOwner === ownerToValidate);
return foundOwner !== undefined;
};
That doesn't guarantee that it is registered though, so if you'd prefer to keep what you have that's fine 👍
Created tests for AddFile component. Added more tests for FilesTable component. Created parseMimeType util. Added a test for showDangerToast.
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.
Thank you for your patience with all of my comments. I tested and LGTM.
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.
Verified locally, looks amazing 😻 Awesome work!! 🎉
@@ -23,6 +25,7 @@ const AllCasesSelectorModalLazy: React.FC<AllCasesSelectorModalProps> = lazy( | |||
export const getAllCasesSelectorModalLazy = ({ | |||
externalReferenceAttachmentTypeRegistry, | |||
persistableStateAttachmentTypeRegistry, | |||
getFilesClient, |
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 might be missing the picture here, Why do we need getFilesClient
separately in selector modal?
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.
Even if sometimes it isn't used (like in the selector modal that doesn't show the case detail view where the files tab is)
the CasesContext
wraps its children in the FilesContextProvider
that unfortunately needs the files client.
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.
Ahh okay 👍
|
||
appMockRender.render( | ||
<> | ||
<div data-test-subj="outsideClickDummy" /> |
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 100% sure but maybe you can add onClick
event and role
to the div.
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 doesn't work 😞
color: 'danger', | ||
icon: 'trash', | ||
type: 'icon', | ||
onClick: () => {}, |
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 column be removed, if delete functionality will not be added in this PR?
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 could but I am going to work on this tomorrow so I am not sure it is worth it 😅
Also, it is not being sent to main
, it is just the feature branch.
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.
Forgot this goes to feature branch, doesn't make sense to remove it 😄
Add tests for file utils.
💔 Build FailedFailed CI Steps
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsasync chunk count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @adcoelho |
Fixes #151723 This PR adds a way for users to: View a list of all files attached to a case(with pagination). Attach files to a case. Preview image files attached to a case. Search for files attached to a case by file name. Download files attached to a case.
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 <[email protected]>
Fixes #151723
I am merging this into a feature branch.
Summary
This PR adds a way for users to:
View a list of all files attached to a case(with pagination)
Attach files to a case
Preview specific image files attached to a case
Search for files attached to a case by file name.
Download files attached to a case
TODO
I need to work on the tests, I already added some for the new components but need to write more. Off the top of my head, I still need to create tests for the new hooks and to make sure the changes to the
Cases Context
are working properly everywhere.I created new issues for missing functionality that was not described in #151595 yet. This includes the deletion action and the files total next to the tab name on the case detail page.