-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Workplace Search] Fix Media Type field preview is unformatted bug (#…
…104684) (#104726) * Add mimeTypes util * Properly format mimeTypes Co-authored-by: Scotty Bollinger <scotty.bollinger@elastic.co>
- Loading branch information
1 parent
7482a2e
commit d8a0dc1
Showing
5 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...k/plugins/enterprise_search/public/applications/workplace_search/utils/mime_types.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { mimeType } from './'; | ||
|
||
describe('mimeType', () => { | ||
it('should return correct mimeType when present', () => { | ||
expect(mimeType('Image/gif')).toEqual('GIF'); | ||
}); | ||
|
||
it('should fall back gracefully when mimeType not present', () => { | ||
expect(mimeType('NOPE')).toEqual('NOPE'); | ||
}); | ||
}); |
54 changes: 54 additions & 0 deletions
54
x-pack/plugins/enterprise_search/public/applications/workplace_search/utils/mime_types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
const mimeTypes = { | ||
'application/iwork-keynote-sffkey': 'Keynote', | ||
'application/x-iwork-keynote-sffkey': 'Keynote', | ||
'application/iwork-numbers-sffnumbers': 'Numbers', | ||
'application/iwork-pages-sffpages': 'Pages', | ||
'application/json': 'JSON', | ||
'application/mp4': 'MP4', | ||
'application/msword': 'DOC', | ||
'application/octet-stream': 'Binary', | ||
'application/pdf': 'PDF', | ||
'application/rtf': 'RTF', | ||
'application/vnd.google-apps.audio': 'Google Audio', | ||
'application/vnd.google-apps.document': 'Google Doc', | ||
'application/vnd.google-apps.drawing': 'Google Drawing', | ||
'application/vnd.google-apps.file': 'Google Drive File', | ||
'application/vnd.google-apps.folder': 'Google Drive Folder', | ||
'application/vnd.google-apps.form': 'Google Form', | ||
'application/vnd.google-apps.fusiontable': 'Google Fusion Table', | ||
'application/vnd.google-apps.map': 'Google Map', | ||
'application/vnd.google-apps.photo': 'Google Photo', | ||
'application/vnd.google-apps.presentation': 'Google Slides', | ||
'application/vnd.google-apps.script': 'Google Script', | ||
'application/vnd.google-apps.sites': 'Google Site', | ||
'application/vnd.google-apps.spreadsheet': 'Google Sheet', | ||
'application/vnd.google-apps.unknown': 'Google Unknown', | ||
'application/vnd.google-apps.video': 'Google Video', | ||
'application/vnd.ms-excel': 'XLS', | ||
'application/vnd.ms-powerpoint': 'PPT', | ||
'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'PPTX', | ||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'XLSX', | ||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'DOCX', | ||
'application/xml': 'XML', | ||
'application/zip': 'ZIP', | ||
'image/gif': 'GIF', | ||
'image/jpeg': 'JPEG', | ||
'image/png': 'PNG', | ||
'image/svg+xml': 'SVG', | ||
'image/tiff': 'TIFF', | ||
'image/vnd.adobe.photoshop': 'PSD', | ||
'text/comma-separated-values': 'CSV', | ||
'text/css': 'CSS', | ||
'text/html': 'HTML', | ||
'text/plain': 'TXT', | ||
'video/quicktime': 'MOV', | ||
} as { [key: string]: string }; | ||
|
||
export const mimeType = (type: string) => mimeTypes[type.toLowerCase()] || type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters