Skip to content

[Cases] Show image thumbnail#226004

Merged
cesco-f merged 12 commits intoelastic:mainfrom
cesco-f:cases-show-thumbnail
Jul 8, 2025
Merged

[Cases] Show image thumbnail#226004
cesco-f merged 12 commits intoelastic:mainfrom
cesco-f:cases-show-thumbnail

Conversation

@cesco-f
Copy link
Contributor

@cesco-f cesco-f commented Jul 1, 2025

This PR closes #222066.

Before:

Screen.Recording.2025-07-01.at.15.01.47.mov

After:

Screen.Recording.2025-07-01.at.15.01.08.mov

Acceptance criteria:

  • On the files attachment tab, show the thumbnails for attached images ✅
  • In the activity feed, show the thumbnails for attached images ✅
@cesco-f cesco-f requested review from a team as code owners July 1, 2025 13:33
@cesco-f cesco-f added release_note:enhancement backport:skip This PR does not require backporting v9.2.0 labels Jul 1, 2025
@github-actions github-actions bot added the author:obs-ux-management PRs authored by the obs ux management team label Jul 1, 2025
@benakansara
Copy link
Contributor

is it possible to show icon for file type when it't not an image (so there is always a thumbnail/icon in front of file name)?

@cesco-f
Copy link
Contributor Author

cesco-f commented Jul 2, 2025

is it possible to show icon for file type when it't not an image (so there is always a thumbnail/icon in front of file name)?

For sure it's possible, but I'm not sure how complicated that would be.
Do we already have icons in the repo for all the possible file types that can be uploaded in cases?

Maybe as first solution we can have a generic icon for all attachments that are not images.

@benakansara
Copy link
Contributor

benakansara commented Jul 2, 2025

We can use below icons based on file extension and fallback to paperClip or document icon if extension is not known or not in our list. wdyt @maciejforcone?

Except when we can show image thumbnail (so we need to exclude those file extensions)

Icons

Screenshot 2025-07-02 at 10 06 03 AM

Sample code

switch (extension.toLowerCase()) {
    case 'csv':
    case 'xls':
    case 'xlsx':
      return 'visTable';
    case 'png':
    case 'jpg':
    case 'jpeg':
    case 'gif':
    case 'svg':
      return 'image';
    case 'js':
    case 'ts':
    case 'json':
    case 'xml':
    case 'py':
    case 'html':
      return 'console';
    case 'zip':
    case 'rar':
    case '7z':
      return 'folderClosed';
    case 'pdf':
    case 'doc':
    case 'docx':
    case 'txt':
      return 'document';
    default:
      return 'paperClip'; // or 'document'
  }
@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner July 3, 2025 11:33
@cesco-f cesco-f removed the request for review from a team July 3, 2025 15:05
@cesco-f
Copy link
Contributor Author

cesco-f commented Jul 7, 2025

@benakansara I've implemented your suggestion and checked with @maciejforcone, here the result:

Screenshot 2025-07-07 at 16 14 42
import { isImage } from './utils';

// eslint-disable-next-line complexity
const getIcon = (extension: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

@cesco-f I think it's hard to list all related extensions. We should instead use parseMimeType function which is also used to display "Type" column in Files table

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The possible mime types are imageMimeTypes, textMimeTypes, compressionMimeTypes and pdfMimeTypes.

So I'm showing the document icon if the mime type is either textMimeTypes or pdfMimeTypes, the folderClosed icon if it's a compressionMimeTypes, the clickable image if it's imageMimeTypes and the paperClip icon in all the other cases.

Is this what you had in mind? Or how would you use the parseMimeType function you mentioned?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes exactly, thank you!

cesco-f added 2 commits July 8, 2025 10:35
replaced EuiAvatar with a mix of EuiImage and EuiIcon
Copy link
Contributor

@janmonschke janmonschke left a comment

Choose a reason for hiding this comment

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

kibana-cases changes lgtm

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
cases 1135 1137 +2

Async chunks

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

id before after diff
cases 1.3MB 1.3MB +2.7KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cases 135.6KB 135.8KB +220.0B
Unknown metric groups

async chunk count

id before after diff
cases 36 37 +1

History

@cesco-f cesco-f merged commit 0f57c03 into elastic:main Jul 8, 2025
12 checks passed
@cesco-f cesco-f deleted the cases-show-thumbnail branch July 8, 2025 14:59
kertal pushed a commit to kertal/kibana that referenced this pull request Jul 25, 2025
This PR closes elastic#222066.

Before:


https://github.com/user-attachments/assets/d4f82be7-59b8-44f4-bbc0-745e60bb9d62

After:


https://github.com/user-attachments/assets/527550e3-5b57-4ac7-8711-6eff0d5c515e


**Acceptance criteria**:
- On the files attachment tab, show the thumbnails for attached images ✅
- In the activity feed, show the thumbnails for attached images ✅

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:obs-ux-management PRs authored by the obs ux management team backport:skip This PR does not require backporting release_note:enhancement v9.2.0

5 participants