From d7658852b0fc590e2862b0db6f5c0358ac28c43b Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Mon, 24 Jan 2022 22:27:55 +0100 Subject: [PATCH] Reveal media file --- CHANGELOG.md | 1 + src/dashboardWebView/DashboardMessage.ts | 1 + .../components/Media/Item.tsx | 33 ++++++++++++------- src/listeners/MediaListener.ts | 16 ++++++++- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de070b24..afee4c46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Added default field value for content type fields - HMR support for panel webview development +- Added reveal media file action - [#187](https://github.com/estruyf/vscode-front-matter/issues/187): Svelte support with the [#227](https://github.com/estruyf/vscode-front-matter/issues/227) features has been added. - [#198](https://github.com/estruyf/vscode-front-matter/issues/198): Additional media sort options (alt, caption, and size). - [#230](https://github.com/estruyf/vscode-front-matter/issues/230): JSON front matter support added. diff --git a/src/dashboardWebView/DashboardMessage.ts b/src/dashboardWebView/DashboardMessage.ts index bc064e91..f7e4cab3 100644 --- a/src/dashboardWebView/DashboardMessage.ts +++ b/src/dashboardWebView/DashboardMessage.ts @@ -15,6 +15,7 @@ export enum DashboardMessage { refreshMedia = 'refreshMedia', uploadMedia = 'uploadMedia', deleteMedia = 'deleteMedia', + revealMedia = 'revealMedia', insertPreviewImage = 'insertPreviewImage', updateMediaMetadata = 'updateMediaMetadata', createMediaFolder = 'createMediaFolder', diff --git a/src/dashboardWebView/components/Media/Item.tsx b/src/dashboardWebView/components/Media/Item.tsx index 22dc9d76..35d5c6e8 100644 --- a/src/dashboardWebView/components/Media/Item.tsx +++ b/src/dashboardWebView/components/Media/Item.tsx @@ -1,6 +1,6 @@ import { Messenger } from '@estruyf/vscode/dist/client'; import { Menu } from '@headlessui/react'; -import { ClipboardIcon, CodeIcon, PencilIcon, PhotographIcon, PlusIcon, TrashIcon } from '@heroicons/react/outline'; +import { ClipboardIcon, CodeIcon, EyeIcon, PencilIcon, PhotographIcon, PlusIcon, TrashIcon } from '@heroicons/react/outline'; import { basename, dirname } from 'path'; import * as React from 'react'; import { useEffect } from 'react'; @@ -108,6 +108,13 @@ export const Item: React.FunctionComponent = ({media}: React.PropsWi setShowAlert(true); }; + const revealMedia = () => { + Messenger.send(DashboardMessage.revealMedia, { + file: media.fsPath, + folder: selectedFolder + }); + }; + const confirmDeletion = () => { Messenger.send(DashboardMessage.deleteMedia, { file: media.fsPath, @@ -243,15 +250,15 @@ export const Item: React.FunctionComponent = ({media}: React.PropsWi onClick={copyToClipboard}>