From 60952a05ac533c975c0b56fa2a9dd686de838d80 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Tue, 23 Apr 2024 19:50:27 +0200 Subject: [PATCH 01/56] #796 - Return error in output --- src/commands/Folders.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/commands/Folders.ts b/src/commands/Folders.ts index 108ecde9..b43e030c 100644 --- a/src/commands/Folders.ts +++ b/src/commands/Folders.ts @@ -744,7 +744,12 @@ export class Folders { private static async findFiles(pattern: string): Promise { return new Promise((resolve) => { glob(pattern, { ignore: '**/node_modules/**' }, (err, files) => { - const allFiles = files.map((file) => Uri.file(file)); + if (err) { + Logger.error(`Folders:findFiles: ${err}`); + resolve([]); + } + + const allFiles = (files || []).map((file) => Uri.file(file)); resolve(allFiles); }); }); From 82b894c35b3afca74ce75185c32ab6147f66a598 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Wed, 24 Apr 2024 15:23:55 +0200 Subject: [PATCH 02/56] #797 - Adding common actions at the bottom of the snippet cards --- CHANGELOG.md | 12 ++ .../components/SnippetsView/FooterActions.tsx | 84 +++++++++++++ .../components/SnippetsView/Item.tsx | 114 +++++------------- 3 files changed, 124 insertions(+), 86 deletions(-) create mode 100644 src/dashboardWebView/components/SnippetsView/FooterActions.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index d01d1bba..58a7922a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log +## [10.2.0] - 2024-xx-xx + +### ✨ New features + +- [#797](https://github.com/estruyf/vscode-front-matter/issues/797): Adding common actions at the bottom of the snippet cards + +### 🎨 Enhancements + +### ⚡️ Optimizations + +### 🐞 Fixes + ## [10.1.0] - 2024-04-11 - [Release notes](https://beta.frontmatter.codes/updates/v10.1.0) ### ✨ New features diff --git a/src/dashboardWebView/components/SnippetsView/FooterActions.tsx b/src/dashboardWebView/components/SnippetsView/FooterActions.tsx new file mode 100644 index 00000000..68d44e3b --- /dev/null +++ b/src/dashboardWebView/components/SnippetsView/FooterActions.tsx @@ -0,0 +1,84 @@ +import * as React from 'react'; +import * as l10n from '@vscode/l10n'; +import { LocalizationKey } from '../../../localization'; +import { QuickAction } from '../Menu'; +import { EyeIcon, PencilIcon, PlusIcon, TrashIcon } from '@heroicons/react/24/solid'; +import { useCallback } from 'react'; +import { openFile } from '../../utils/MessageHandlers'; + +export interface IFooterActionsProps { + insertEnabled: boolean; + sourcePath?: string; + onEdit?: () => void; + onInsert: () => void; + onDelete?: () => void; +} + +export const FooterActions: React.FunctionComponent = ({ + insertEnabled, + sourcePath, + onEdit, + onInsert, + onDelete, +}: React.PropsWithChildren) => { + + const showFile = useCallback(() => { + openFile(sourcePath); + }, [sourcePath]); + + if (!onEdit && !onDelete && !sourcePath && !insertEnabled) { + return null; + } + + return ( +
+ {insertEnabled && ( + + + )} + + { + !sourcePath ? ( + <> + { + onEdit && ( + + + ) + } + + { + onDelete && ( + + + ) + } + + ) : ( + + + ) + } +
+ ); +}; \ No newline at end of file diff --git a/src/dashboardWebView/components/SnippetsView/Item.tsx b/src/dashboardWebView/components/SnippetsView/Item.tsx index 1ef5ae50..762dbbed 100644 --- a/src/dashboardWebView/components/SnippetsView/Item.tsx +++ b/src/dashboardWebView/components/SnippetsView/Item.tsx @@ -2,13 +2,8 @@ import { Messenger } from '@estruyf/vscode/dist/client'; import { CodeBracketIcon, DocumentTextIcon, - EllipsisHorizontalIcon, - EyeIcon, - PencilIcon, PhotoIcon, - PlusIcon, - TrashIcon -} from '@heroicons/react/24/outline'; +} from '@heroicons/react/24/solid'; import * as React from 'react'; import { useCallback, useMemo, useRef, useState } from 'react'; import { useRecoilValue } from 'recoil'; @@ -18,14 +13,13 @@ import { SnippetParser } from '../../../helpers/SnippetParser'; import { Snippet, Snippets } from '../../../models'; import { DashboardMessage } from '../../DashboardMessage'; import { ModeAtom, SettingsSelector, ViewDataSelector } from '../../state'; -import { QuickAction } from '../Menu'; import { Alert } from '../Modals/Alert'; import { FormDialog } from '../Modals/FormDialog'; import { NewForm } from './NewForm'; import SnippetForm, { SnippetFormHandle } from './SnippetForm'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../../../localization'; -import { openFile } from '../../utils'; +import { FooterActions } from './FooterActions'; export interface IItemProps { snippetKey: string; @@ -65,10 +59,6 @@ export const Item: React.FunctionComponent = ({ setMediaSnippet(false); }; - const showFile = useCallback(() => { - openFile(snippet.sourcePath); - }, [snippet]); - const onOpenEdit = useCallback(() => { setSnippetTitle(snippet.title || snippetKey); setSnippetDescription(snippet.description); @@ -162,89 +152,41 @@ export const Item: React.FunctionComponent = ({ return ( <> -
  • -
    - +
  • +
    +

    + {snippet.isMediaSnippet ? ( + + ) : ( + + )} + + {snippet.title || snippetKey} +

    + +

    {snippet.description}

    -

    - {snippet.isMediaSnippet ? ( - - ) : ( - - )} - - {snippet.title || snippetKey} -

    - -
    -
    - -
    - -
    - setShowInsertDialog(true)}> - -
    -
    - - ) : undefined + setShowInsertDialog(true)} /> } > -
    -
    -
    - -
    - -
    - {insertToContent && !snippet.isMediaSnippet && ( - <> - setShowInsertDialog(true)}> - - - )} - - {!snippet.sourcePath ? ( - <> - - - - setShowAlert(true)}> - - - ) : ( - - - )} -
    -
    -
    + setShowInsertDialog(true)} + onDelete={() => setShowAlert(true)} />
    - -

    {snippet.description}

  • {showInsertDialog && ( From 75a3fc21a3464bbd0e8433973ff443c155101149 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Wed, 24 Apr 2024 15:24:05 +0200 Subject: [PATCH 03/56] 10.2.0 --- package-lock.json | 4 +- package.json | 334 ++++++++++++++++++++++++++-------------------- 2 files changed, 188 insertions(+), 150 deletions(-) diff --git a/package-lock.json b/package-lock.json index de7ee19e..f4e8cf96 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-front-matter-beta", - "version": "10.1.0", + "version": "10.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vscode-front-matter-beta", - "version": "10.1.0", + "version": "10.2.0", "license": "MIT", "dependencies": { "@radix-ui/react-dropdown-menu": "^2.0.6" diff --git a/package.json b/package.json index 509933d6..6d4da81c 100644 --- a/package.json +++ b/package.json @@ -3,14 +3,15 @@ "displayName": "Front Matter CMS", "description": "Front Matter is a CMS that runs within Visual Studio Code. It gives you the power and control of a full-blown CMS while also providing you the flexibility and speed of the static site generator of your choice like: Hugo, Jekyll, Docusaurus, NextJs, Gatsby, and many more...", "icon": "assets/frontmatter-teal-128x128.png", - "version": "10.1.0", + "version": "10.2.0", "preview": false, "publisher": "eliostruyf", "galleryBanner": { "color": "#0e131f", "theme": "dark" }, - "badges": [{ + "badges": [ + { "description": "version", "url": "https://img.shields.io/github/package-json/v/estruyf/vscode-front-matter?color=green&label=vscode-front-matter&style=flat-square", "href": "https://github.com/estruyf/vscode-front-matter" @@ -69,7 +70,8 @@ "**/.frontmatter/config/*.json": "jsonc" } }, - "keybindings": [{ + "keybindings": [ + { "command": "frontMatter.dashboard", "key": "alt+d" }, @@ -78,7 +80,8 @@ "key": "ctrl+r", "mac": "cmd+r", "when": "activeWebviewPanelId == frontMatterDashboard" - }, { + }, + { "command": "frontMatter.insertMedia", "key": "ctrl+shift+i", "mac": "cmd+shift+i", @@ -92,19 +95,23 @@ } ], "viewsContainers": { - "activitybar": [{ - "id": "frontmatter-explorer", - "title": "FM", - "icon": "$(fm-logo)" - }] + "activitybar": [ + { + "id": "frontmatter-explorer", + "title": "FM", + "icon": "$(fm-logo)" + } + ] }, "views": { - "frontmatter-explorer": [{ - "id": "frontMatter.explorer", - "name": "Front Matter", - "icon": "$(fm-logo)", - "type": "webview" - }] + "frontmatter-explorer": [ + { + "id": "frontMatter.explorer", + "name": "Front Matter", + "icon": "$(fm-logo)", + "type": "webview" + } + ] }, "configuration": { "title": "%settings.configuration.title%", @@ -172,7 +179,8 @@ "frontMatter.content.defaultFileType": { "type": "string", "default": "md", - "oneOf": [{ + "oneOf": [ + { "enum": [ "md", "mdx" @@ -188,7 +196,8 @@ "frontMatter.content.defaultSorting": { "type": "string", "default": "", - "oneOf": [{ + "oneOf": [ + { "enum": [ "LastModifiedAsc", "LastModifiedDesc", @@ -536,7 +545,8 @@ "categories" ], "markdownDescription": "%setting.frontMatter.content.filters.markdownDescription%", - "items": [{ + "items": [ + { "type": "string", "enum": [ "contentFolders", @@ -609,7 +619,8 @@ "command": { "$id": "#scriptCommand", "type": "string", - "anyOf": [{ + "anyOf": [ + { "enum": [ "node", "bash", @@ -805,7 +816,8 @@ "title", "file" ], - "anyOf": [{ + "anyOf": [ + { "required": [ "schema" ] @@ -859,7 +871,8 @@ "id", "path" ], - "anyOf": [{ + "anyOf": [ + { "required": [ "schema" ] @@ -1100,26 +1113,29 @@ } } }, - "default": [{ - "name": "default", - "fileTypes": null, - "fields": [{ - "title": "Title", - "name": "title", - "type": "string" - }, - { - "title": "Caption", - "name": "caption", - "type": "string" - }, - { - "title": "Alt text", - "name": "alt", - "type": "string" - } - ] - }], + "default": [ + { + "name": "default", + "fileTypes": null, + "fields": [ + { + "title": "Title", + "name": "title", + "type": "string" + }, + { + "title": "Caption", + "name": "caption", + "type": "string" + }, + { + "title": "Alt text", + "name": "alt", + "type": "string" + } + ] + } + ], "scope": "Media" }, "frontMatter.media.supportedMimeTypes": { @@ -1349,7 +1365,8 @@ "default": "", "description": "%setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.taxonomyId.description%", "not": { - "anyOf": [{ + "anyOf": [ + { "const": "" }, { @@ -1543,7 +1560,8 @@ "type", "name" ], - "allOf": [{ + "allOf": [ + { "if": { "properties": { "type": { @@ -1751,48 +1769,51 @@ "fields" ] }, - "default": [{ - "name": "default", - "pageBundle": false, - "fields": [{ - "title": "Title", - "name": "title", - "type": "string" - }, - { - "title": "Description", - "name": "description", - "type": "string" - }, - { - "title": "Publishing date", - "name": "date", - "type": "datetime", - "default": "{{now}}", - "isPublishDate": true - }, - { - "title": "Content preview", - "name": "preview", - "type": "image" - }, - { - "title": "Is in draft", - "name": "draft", - "type": "boolean" - }, - { - "title": "Tags", - "name": "tags", - "type": "tags" - }, - { - "title": "Categories", - "name": "categories", - "type": "categories" - } - ] - }], + "default": [ + { + "name": "default", + "pageBundle": false, + "fields": [ + { + "title": "Title", + "name": "title", + "type": "string" + }, + { + "title": "Description", + "name": "description", + "type": "string" + }, + { + "title": "Publishing date", + "name": "date", + "type": "datetime", + "default": "{{now}}", + "isPublishDate": true + }, + { + "title": "Content preview", + "name": "preview", + "type": "image" + }, + { + "title": "Is in draft", + "name": "draft", + "type": "boolean" + }, + { + "title": "Tags", + "name": "tags", + "type": "tags" + }, + { + "title": "Categories", + "name": "categories", + "type": "categories" + } + ] + } + ], "scope": "Taxonomy" }, "frontMatter.taxonomy.customTaxonomy": { @@ -1805,7 +1826,8 @@ "type": "string", "description": "%setting.frontMatter.taxonomy.customTaxonomy.items.properties.id.description%", "not": { - "anyOf": [{ + "anyOf": [ + { "const": "" }, { @@ -1990,7 +2012,8 @@ } } }, - "commands": [{ + "commands": [ + { "command": "frontMatter.project.switch", "title": "%command.frontMatter.project.switch%", "category": "Front Matter", @@ -2316,16 +2339,21 @@ } } ], - "submenus": [{ - "id": "frontmatter.submenu", - "label": "Front Matter" - }], + "submenus": [ + { + "id": "frontmatter.submenu", + "label": "Front Matter" + } + ], "menus": { - "webview/context": [{ - "command": "workbench.action.webview.openDeveloperTools", - "when": "frontMatter:isDevelopment" - }], - "editor/title": [{ + "webview/context": [ + { + "command": "workbench.action.webview.openDeveloperTools", + "when": "frontMatter:isDevelopment" + } + ], + "editor/title": [ + { "command": "frontMatter.markup.heading", "group": "navigation@-133", "when": "frontMatter:file:isValid == true && frontMatter:markdown:wysiwyg" @@ -2411,11 +2439,14 @@ "when": "resourceFilename == 'frontmatter.json'" } ], - "explorer/context": [{ - "submenu": "frontmatter.submenu", - "group": "frontmatter@1" - }], - "frontmatter.submenu": [{ + "explorer/context": [ + { + "submenu": "frontmatter.submenu", + "group": "frontmatter@1" + } + ], + "frontmatter.submenu": [ + { "command": "frontMatter.createFromTemplate", "when": "explorerResourceIsFolder", "group": "frontmatter@1" @@ -2431,7 +2462,8 @@ "group": "frontmatter@3" } ], - "commandPalette": [{ + "commandPalette": [ + { "command": "frontMatter.init", "when": "frontMatterCanInit" }, @@ -2608,7 +2640,8 @@ "when": "frontMatter:file:isValid == true" } ], - "view/title": [{ + "view/title": [ + { "command": "frontMatter.chatbot", "group": "navigation@0", "when": "view == frontMatter.explorer" @@ -2640,52 +2673,57 @@ } ] }, - "grammars": [{ - "path": "./syntaxes/hugo.tmLanguage.json", - "scopeName": "frontmatter.markdown.hugo", - "injectTo": [ - "text.html.markdown" - ] - }], - "walkthroughs": [{ - "id": "frontmatter.welcome", - "title": "Get started with Front Matter", - "description": "Discover the features of Front Matter and learn how to use the CMS for your SSG or static site.", - "steps": [{ - "id": "frontmatter.welcome.init", - "title": "Get started", - "description": "Initial steps to get started.\n[Open dashboard](command:frontMatter.dashboard)", - "media": { - "markdown": "assets/walkthrough/get-started.md" + "grammars": [ + { + "path": "./syntaxes/hugo.tmLanguage.json", + "scopeName": "frontmatter.markdown.hugo", + "injectTo": [ + "text.html.markdown" + ] + } + ], + "walkthroughs": [ + { + "id": "frontmatter.welcome", + "title": "Get started with Front Matter", + "description": "Discover the features of Front Matter and learn how to use the CMS for your SSG or static site.", + "steps": [ + { + "id": "frontmatter.welcome.init", + "title": "Get started", + "description": "Initial steps to get started.\n[Open dashboard](command:frontMatter.dashboard)", + "media": { + "markdown": "assets/walkthrough/get-started.md" + }, + "completionEvents": [ + "onContext:frontMatterInitialized" + ] }, - "completionEvents": [ - "onContext:frontMatterInitialized" - ] - }, - { - "id": "frontmatter.welcome.documentation", - "title": "Documentation", - "description": "Check out the documentation for Front Matter.\n[View our documentation](https://frontmatter.codes/docs)", - "media": { - "markdown": "assets/walkthrough/documentation.md" + { + "id": "frontmatter.welcome.documentation", + "title": "Documentation", + "description": "Check out the documentation for Front Matter.\n[View our documentation](https://frontmatter.codes/docs)", + "media": { + "markdown": "assets/walkthrough/documentation.md" + }, + "completionEvents": [ + "onLink:https://frontmatter.codes/docs" + ] }, - "completionEvents": [ - "onLink:https://frontmatter.codes/docs" - ] - }, - { - "id": "frontmatter.welcome.supporter", - "title": "Support the project", - "description": "Become a supporter.\n[Support the project](https://github.com/sponsors/estruyf)", - "media": { - "markdown": "assets/walkthrough/support-the-project.md" - }, - "completionEvents": [ - "onLink:https://github.com/sponsors/estruyf" - ] - } - ] - }] + { + "id": "frontmatter.welcome.supporter", + "title": "Support the project", + "description": "Become a supporter.\n[Support the project](https://github.com/sponsors/estruyf)", + "media": { + "markdown": "assets/walkthrough/support-the-project.md" + }, + "completionEvents": [ + "onLink:https://github.com/sponsors/estruyf" + ] + } + ] + } + ] }, "scripts": { "dev:ext": "npm run clean && npm run localization:generate && npm-run-all --parallel watch:*", @@ -2814,4 +2852,4 @@ "dependencies": { "@radix-ui/react-dropdown-menu": "^2.0.6" } -} \ No newline at end of file +} From 3fedaf7d5f10013460034fa8dff9977578ee357d Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Wed, 24 Apr 2024 15:38:25 +0200 Subject: [PATCH 04/56] Update snippets list --- src/dashboardWebView/components/Layout/SponsorMsg.tsx | 2 +- src/dashboardWebView/components/SnippetsView/Snippets.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dashboardWebView/components/Layout/SponsorMsg.tsx b/src/dashboardWebView/components/Layout/SponsorMsg.tsx index 6e592c88..b5c7616e 100644 --- a/src/dashboardWebView/components/Layout/SponsorMsg.tsx +++ b/src/dashboardWebView/components/Layout/SponsorMsg.tsx @@ -36,7 +36,7 @@ export const SponsorMsg: React.FunctionComponent = ({ return (