From cf28e5fc850e2a90dccc690c9e153885f05f8f6b Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Wed, 14 Aug 2024 11:00:47 +0200 Subject: [PATCH 01/27] 10.4.0 --- package-lock.json | 142 +++++++++++++------- package.json | 335 ++++++++++++++++++++++++++-------------------- 2 files changed, 278 insertions(+), 199 deletions(-) diff --git a/package-lock.json b/package-lock.json index 29968bdf..05d5ae3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-front-matter-beta", - "version": "10.3.0", + "version": "10.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vscode-front-matter-beta", - "version": "10.3.0", + "version": "10.4.0", "license": "MIT", "dependencies": { "@radix-ui/react-dropdown-menu": "^2.0.6" @@ -2935,7 +2935,8 @@ "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.17.tgz", "integrity": "sha512-/cpVNRLSfhOtcGflT13P2794gVSgmPgTR+erw5ifnMLZb0UnSlkK4tquLmkd3BhA+nLo5tX8Cu0upUsGKvKbmg==", "dev": true, - "funding": [{ + "funding": [ + { "type": "opencollective", "url": "https://opencollective.com/postcss/" }, @@ -3115,7 +3116,8 @@ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.3.tgz", "integrity": "sha512-UAp55yfwNv0klWNapjs/ktHoguxuQNGnOzxYmfnXIS+8AsRDZkSDxg7R1AX3GKzn078SBI5dzwzj/Yx0Or0e3A==", "dev": true, - "funding": [{ + "funding": [ + { "type": "opencollective", "url": "https://opencollective.com/browserslist" }, @@ -3209,7 +3211,8 @@ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001583.tgz", "integrity": "sha512-acWTYaha8xfhA/Du/z4sNZjHUWjkiuoAi2LM+T/aL+kemKQgPT1xBb/YKjlQ0Qo8gvbHsGNplrEJ+9G3gL7i4Q==", "dev": true, - "funding": [{ + "funding": [ + { "type": "opencollective", "url": "https://opencollective.com/browserslist" }, @@ -3322,10 +3325,12 @@ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", "dev": true, - "funding": [{ - "type": "individual", - "url": "https://paulmillr.com/funding/" - }], + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -3983,10 +3988,12 @@ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", "dev": true, - "funding": [{ - "type": "github", - "url": "https://github.com/sponsors/fb55" - }] + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ] }, "node_modules/domhandler": { "version": "5.0.3", @@ -4847,10 +4854,12 @@ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "dev": true, - "funding": [{ - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - }], + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], "engines": { "node": ">=4.0" }, @@ -5453,7 +5462,8 @@ "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.4.0.tgz", "integrity": "sha512-igBTJcNNNhvZFRtm8uA6xMY6xYleeDwn3PeBCkDz7tHttv4F2hsDI2aPgNERWzvRcNYHNT3ymRaQzllmXj4YsQ==", "dev": true, - "funding": [{ + "funding": [ + { "type": "github", "url": "https://github.com/sponsors/mdevils" }, @@ -6028,7 +6038,8 @@ "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz", "integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==", "dev": true, - "funding": [{ + "funding": [ + { "type": "github", "url": "https://github.com/sponsors/feross" }, @@ -7075,7 +7086,8 @@ "resolved": "https://registry.npmjs.org/micromark/-/micromark-3.2.0.tgz", "integrity": "sha512-uD66tJj54JLYq0De10AhWycZWGQNUvDI55xPgk2sQM5kn1JYlhbCMTtEeT27+vAhW2FBQxLlOmS3pmA7/2z4aA==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7109,7 +7121,8 @@ "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-1.1.0.tgz", "integrity": "sha512-BgHO1aRbolh2hcrzL2d1La37V0Aoz73ymF8rAcKnohLy93titmv62E0gP8Hrx9PKcKrqCZ1BbLGbP3bEhoXYlw==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7263,7 +7276,8 @@ "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-1.1.0.tgz", "integrity": "sha512-XaNDROBgx9SgSChd69pjiGKbV+nfHGDPVYFs5dOoDd7ZnMAE+Cuu91BCpsY8RT2NP9vo/B8pds2VQNCLiu0zhg==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7283,7 +7297,8 @@ "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-1.1.0.tgz", "integrity": "sha512-OLtyez4vZo/1NjxGhcpDSbHQ+m0IIGnT8BoPamh+7jVlzLJBH98zzuCoUeMxvM6WsNeh8wx8cKvqLiPHEACn0w==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7304,7 +7319,8 @@ "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-1.1.0.tgz", "integrity": "sha512-cRzEj7c0OL4Mw2v6nwzttyOZe8XY/Z8G0rzmWQZTBi/jjwyw/U4uqKtUORXQrR5bAZZnbTI/feRV/R7hc4jQYQ==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7323,7 +7339,8 @@ "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-1.1.0.tgz", "integrity": "sha512-J7n9R3vMmgjDOCY8NPw55jiyaQnH5kBdV2/UXCtZIpnHH3P6nHUKaH7XXEYuWwx/xUJcawa8plLBEjMPU24HzQ==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7344,7 +7361,8 @@ "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-1.1.0.tgz", "integrity": "sha512-v2WlmiymVSp5oMg+1Q0N1Lxmt6pMhIHD457whWM7/GUlEks1hI9xj5w3zbc4uuMKXGisksZk8DzP2UyGbGqNsQ==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7365,7 +7383,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-1.2.0.tgz", "integrity": "sha512-lXraTwcX3yH/vMDaFWCQJP1uIszLVebzUa3ZHdrgxr7KEU/9mL4mVgCpGbyhvNLNlauROiNUq7WN5u7ndbY6xg==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7384,7 +7403,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-1.1.0.tgz", "integrity": "sha512-Ye01HXpkZPNcV6FiyoW2fGZDUw4Yc7vT0E9Sad83+bEDiCJ1uXu0S3mr8WLpsz3HaG3x2q0HM6CTuPdcZcluFQ==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7402,7 +7422,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-1.1.0.tgz", "integrity": "sha512-SL0wLxtKSnklKSUplok1WQFoGhUdWYKggKUiqhX+Swala+BtptGCu5iPRc+xvzJ4PXE/hwM3FNXsfEVgoZsWbw==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7422,7 +7443,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-1.1.0.tgz", "integrity": "sha512-Q20sp4mfNf9yEqDL50WwuWZHUrCO4fEyeDCnMGmG5Pr0Cz15Uo7KBs6jq+dq0EgX4DPwwrh9m0X+zPV1ypFvUA==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7441,7 +7463,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-1.1.0.tgz", "integrity": "sha512-m9V0ExGv0jB1OT21mrWcuf4QhP46pH1KkfWy9ZEezqHKAxkj4mPCy3nIH1rkbdMlChLHX531eOrymlwyZIf2iw==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7459,7 +7482,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-1.1.0.tgz", "integrity": "sha512-YphLGCK8gM1tG1bd54azwyrQRjCFcmgj2S2GoJDNnh4vYtnL38JS8M4gpxzOPNyHdNEpheyWXCTnnTDY3N+NVQ==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7480,7 +7504,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-1.1.0.tgz", "integrity": "sha512-EuEzTWSTAj9PA5GOAs992GzNh2dGQO52UvAbtSOMvXTxv3Criqb6IOzJUBCmEqrrXSblJIJBbFFv6zPxpreiJw==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7495,7 +7520,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-1.2.0.tgz", "integrity": "sha512-VTQzcuQgFUD7yYztuQFKXT49KghjtETQ+Wv/zUjGSGBioZnkA4P1XXZPT1FHeJA6RwRXSF47yvJ1tsJdoxwO+Q==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7510,7 +7536,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-1.1.0.tgz", "integrity": "sha512-N+w5vhqrBihhjdpM8+5Xsxy71QWqGn7HYNUvch71iV2PM7+E3uWGox1Qp90loa1ephtCxG2ftRV/Conitc6P2Q==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7528,7 +7555,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-1.1.0.tgz", "integrity": "sha512-b/G6BTMSg+bX+xVCshPTPyAu2tmA0E4X98NSR7eIbeC6ycCqCeE7wjfDIgzEbkzdEVJXRtOG4FbEm/uGbCRouA==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7546,7 +7574,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-1.2.0.tgz", "integrity": "sha512-QO4GXv0XZfWey4pYFndLUKEAktKkG5kZTdUNaTAkzbuJxn2tNBOr+QtxR2XpWaMhbImT2dPzyLrPXLlPhph34A==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7566,7 +7595,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-1.1.0.tgz", "integrity": "sha512-kUQHyzRoxvZO2PuLzMt2P/dwVsTiivCK8icYTeR+3WgbuPqfHgPPy7nFKbeqRivBvn/3N3GBiNC+JRTMSxEC7A==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7587,7 +7617,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-1.1.0.tgz", "integrity": "sha512-uEjpEYY6KMs1g7QfJ2eX1SQEV+ZT4rUD3UcF6l57acZvLNK7PBZL+ty82Z1qhK1/yXIY4bdx04FKMgR0g4IAag==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7602,7 +7633,8 @@ "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-1.1.0.tgz", "integrity": "sha512-ukRBgie8TIAcacscVHSiddHjO4k/q3pnedmzMQ4iwDcK0FtFCohKOlFbaOL/mPgfnPsL3C1ZyxJa4sbWrBl3jg==", "dev": true, - "funding": [{ + "funding": [ + { "type": "GitHub Sponsors", "url": "https://github.com/sponsors/unifiedjs" }, @@ -7784,10 +7816,12 @@ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", "dev": true, - "funding": [{ - "type": "github", - "url": "https://github.com/sponsors/ai" - }], + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -8665,7 +8699,8 @@ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.33.tgz", "integrity": "sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg==", "dev": true, - "funding": [{ + "funding": [ + { "type": "opencollective", "url": "https://opencollective.com/postcss/" }, @@ -8728,7 +8763,8 @@ "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-4.0.2.tgz", "integrity": "sha512-bSVhyJGL00wMVoPUzAVAnbEoWyqRxkjv64tUl427SKnPrENtq6hJwUojroMz2VB+Q1edmi4IfrAPpami5VVgMQ==", "dev": true, - "funding": [{ + "funding": [ + { "type": "opencollective", "url": "https://opencollective.com/postcss/" }, @@ -9085,7 +9121,8 @@ "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", "dev": true, - "funding": [{ + "funding": [ + { "type": "github", "url": "https://github.com/sponsors/feross" }, @@ -10548,7 +10585,8 @@ "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", "dev": true, - "funding": [{ + "funding": [ + { "type": "github", "url": "https://github.com/sponsors/feross" }, @@ -10606,7 +10644,8 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "dev": true, - "funding": [{ + "funding": [ + { "type": "github", "url": "https://github.com/sponsors/feross" }, @@ -12145,7 +12184,8 @@ "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", "dev": true, - "funding": [{ + "funding": [ + { "type": "opencollective", "url": "https://opencollective.com/browserslist" }, @@ -13012,4 +13052,4 @@ } } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index bbc0c7c7..109c4c38 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.3.0", + "version": "10.4.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" @@ -70,7 +71,8 @@ "**/.frontmatter/config/*.json": "jsonc" } }, - "keybindings": [{ + "keybindings": [ + { "command": "frontMatter.dashboard", "key": "alt+d" }, @@ -94,19 +96,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%", @@ -174,7 +180,8 @@ "frontMatter.content.defaultFileType": { "type": "string", "default": "md", - "oneOf": [{ + "oneOf": [ + { "enum": [ "md", "mdx" @@ -190,7 +197,8 @@ "frontMatter.content.defaultSorting": { "type": "string", "default": "", - "oneOf": [{ + "oneOf": [ + { "enum": [ "LastModifiedAsc", "LastModifiedDesc", @@ -542,7 +550,8 @@ "categories" ], "markdownDescription": "%setting.frontMatter.content.filters.markdownDescription%", - "items": [{ + "items": [ + { "type": "string", "enum": [ "contentFolders", @@ -616,7 +625,8 @@ "command": { "$id": "#scriptCommand", "type": "string", - "anyOf": [{ + "anyOf": [ + { "enum": [ "node", "bash", @@ -812,7 +822,8 @@ "title", "file" ], - "anyOf": [{ + "anyOf": [ + { "required": [ "schema" ] @@ -866,7 +877,8 @@ "id", "path" ], - "anyOf": [{ + "anyOf": [ + { "required": [ "schema" ] @@ -1107,26 +1119,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": { @@ -1229,7 +1244,8 @@ "fileType": { "type": "string", "default": "", - "oneOf": [{ + "oneOf": [ + { "enum": [ "md", "mdx" @@ -1368,7 +1384,8 @@ "default": "", "description": "%setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.taxonomyId.description%", "not": { - "anyOf": [{ + "anyOf": [ + { "const": "" }, { @@ -1569,7 +1586,8 @@ "type", "name" ], - "allOf": [{ + "allOf": [ + { "if": { "properties": { "type": { @@ -1781,48 +1799,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": { @@ -1835,7 +1856,8 @@ "type": "string", "description": "%setting.frontMatter.taxonomy.customTaxonomy.items.properties.id.description%", "not": { - "anyOf": [{ + "anyOf": [ + { "const": "" }, { @@ -2030,7 +2052,8 @@ } } }, - "commands": [{ + "commands": [ + { "command": "frontMatter.project.switch", "title": "%command.frontMatter.project.switch%", "category": "Front Matter", @@ -2362,16 +2385,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" @@ -2457,11 +2485,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" @@ -2477,7 +2508,8 @@ "group": "frontmatter@3" } ], - "commandPalette": [{ + "commandPalette": [ + { "command": "frontMatter.init", "when": "frontMatterCanInit" }, @@ -2654,7 +2686,8 @@ "when": "frontMatter:file:isValid == true" } ], - "view/title": [{ + "view/title": [ + { "command": "frontMatter.docs", "group": "navigation@-1", "when": "view == frontMatter.explorer" @@ -2691,13 +2724,16 @@ } ] }, - "languages": [{ - "id": "frontmatter.project.output", - "mimetypes": [ - "text/x-code-output" - ] - }], - "grammars": [{ + "languages": [ + { + "id": "frontmatter.project.output", + "mimetypes": [ + "text/x-code-output" + ] + } + ], + "grammars": [ + { "path": "./syntaxes/hugo.tmLanguage.json", "scopeName": "frontmatter.markdown.hugo", "injectTo": [ @@ -2710,45 +2746,48 @@ "path": "./syntaxes/frontmatter-output.tmLanguage.json" } ], - "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" - ] - }, - { - "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" + "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": [ - "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" + { + "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://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:*", @@ -2876,4 +2915,4 @@ "dependencies": { "@radix-ui/react-dropdown-menu": "^2.0.6" } -} \ No newline at end of file +} From f13058c59b4c1ebe26f5d055cddcac775e5abd0c Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Wed, 14 Aug 2024 11:01:35 +0200 Subject: [PATCH 02/27] Prep changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f65bcf9..44ed5c79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## [10.4.0] - 2024-xx-xx + +### ✨ New features + +### 🎨 Enhancements + +### 🐞 Fixes + ## [10.3.0] - 2024-08-13 - [Release notes](https://beta.frontmatter.codes/updates/v10.3.0) ### ✨ New features From d0b7af5c86fa78b4b9a53ed9dd7bc4b35cc3d855 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Wed, 14 Aug 2024 14:06:52 +0200 Subject: [PATCH 03/27] Enhancement: Ability to create new data files for a folder #834 --- CHANGELOG.md | 2 + l10n/bundle.l10n.json | 6 + package.json | 347 ++++++++---------- package.nls.json | 2 + src/commands/Folders.ts | 16 + src/dashboardWebView/DashboardMessage.ts | 1 + .../components/DataView/DataView.tsx | 186 +++++++--- .../components/DataView/EmptyView.tsx | 38 +- .../components/Menu/MenuButton.tsx | 15 +- src/dashboardWebView/models/Settings.ts | 2 + src/helpers/DashboardSettings.ts | 13 +- src/helpers/openFileInEditor.ts | 5 + src/listeners/dashboard/DataListener.ts | 85 ++++- src/localization/localization.enum.ts | 24 ++ src/models/DataFolder.ts | 2 + 15 files changed, 482 insertions(+), 262 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44ed5c79..766d1023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### 🎨 Enhancements +- [#834](https://github.com/estruyf/vscode-front-matter/issues/834): Added the ability to create new data files for a data folder + ### 🐞 Fixes ## [10.3.0] - 2024-08-13 - [Release notes](https://beta.frontmatter.codes/updates/v10.3.0) diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index 944f60b5..0629fb5e 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -140,6 +140,9 @@ "dashboard.dataView.dataView.noDataFiles": "No data files found", "dashboard.dataView.dataView.getStarted.link": "Read more to get started using data files", "dashboard.dataView.dataView.update.message": "Updated your data entries", + "dashboard.dataView.dataView.createNew": "Create new data file", + "dashboard.dataView.dataView.selectDataFolder": "Select data folder", + "dashboard.dataView.dataView.closeSelectedDataFile": "Close data file", "dashboard.dataView.emptyView.heading": "Select your date type first", @@ -783,6 +786,9 @@ "listeners.panel.dataListener.aiSuggestTaxonomy.noData.error": "No article data", "listeners.panel.dataListener.getDataFileEntries.noDataFiles.error": "Couldn't find data file entries", "listeners.panel.dataListener.pushMetadata.frontMatter.error": "Something went wrong while parsing your front matter. Please check the contents of your file.", + "listeners.panel.dataListener.createDataFile.inputTitle": "What is the name of the data file?", + "listeners.panel.dataListener.createDataFile.error": "No data file id or path defined.", + "listeners.panel.dataListener.createDataFile.noFileName": "No filename provided.", "listeners.panel.taxonomyListener.aiSuggestTaxonomy.noEditor.error": "No active editor", diff --git a/package.json b/package.json index 109c4c38..b1467d61 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,7 @@ "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" @@ -71,8 +70,7 @@ "**/.frontmatter/config/*.json": "jsonc" } }, - "keybindings": [ - { + "keybindings": [{ "command": "frontMatter.dashboard", "key": "alt+d" }, @@ -96,23 +94,19 @@ } ], "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%", @@ -180,8 +174,7 @@ "frontMatter.content.defaultFileType": { "type": "string", "default": "md", - "oneOf": [ - { + "oneOf": [{ "enum": [ "md", "mdx" @@ -197,8 +190,7 @@ "frontMatter.content.defaultSorting": { "type": "string", "default": "", - "oneOf": [ - { + "oneOf": [{ "enum": [ "LastModifiedAsc", "LastModifiedDesc", @@ -550,8 +542,7 @@ "categories" ], "markdownDescription": "%setting.frontMatter.content.filters.markdownDescription%", - "items": [ - { + "items": [{ "type": "string", "enum": [ "contentFolders", @@ -625,8 +616,7 @@ "command": { "$id": "#scriptCommand", "type": "string", - "anyOf": [ - { + "anyOf": [{ "enum": [ "node", "bash", @@ -822,8 +812,7 @@ "title", "file" ], - "anyOf": [ - { + "anyOf": [{ "required": [ "schema" ] @@ -870,6 +859,20 @@ "type": "boolean", "description": "%setting.frontMatter.data.folders.items.properties.singleEntry.description%", "default": false + }, + "enableFileCreation": { + "type": "boolean", + "description": "%setting.frontMatter.data.folders.items.properties.enableFileCreation.description%", + "default": false + }, + "fileType": { + "type": "string", + "default": "json", + "enum": [ + "json", + "yaml" + ], + "description": "%setting.frontMatter.data.folders.items.properties.fileType.description%" } }, "additionalProperties": false, @@ -877,8 +880,7 @@ "id", "path" ], - "anyOf": [ - { + "anyOf": [{ "required": [ "schema" ] @@ -1119,29 +1121,26 @@ } } }, - "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": { @@ -1244,8 +1243,7 @@ "fileType": { "type": "string", "default": "", - "oneOf": [ - { + "oneOf": [{ "enum": [ "md", "mdx" @@ -1384,8 +1382,7 @@ "default": "", "description": "%setting.frontMatter.taxonomy.contentTypes.items.properties.fields.items.properties.taxonomyId.description%", "not": { - "anyOf": [ - { + "anyOf": [{ "const": "" }, { @@ -1586,8 +1583,7 @@ "type", "name" ], - "allOf": [ - { + "allOf": [{ "if": { "properties": { "type": { @@ -1799,51 +1795,48 @@ "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": { @@ -1856,8 +1849,7 @@ "type": "string", "description": "%setting.frontMatter.taxonomy.customTaxonomy.items.properties.id.description%", "not": { - "anyOf": [ - { + "anyOf": [{ "const": "" }, { @@ -2052,8 +2044,7 @@ } } }, - "commands": [ - { + "commands": [{ "command": "frontMatter.project.switch", "title": "%command.frontMatter.project.switch%", "category": "Front Matter", @@ -2385,21 +2376,16 @@ } } ], - "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" @@ -2485,14 +2471,11 @@ "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" @@ -2508,8 +2491,7 @@ "group": "frontmatter@3" } ], - "commandPalette": [ - { + "commandPalette": [{ "command": "frontMatter.init", "when": "frontMatterCanInit" }, @@ -2686,8 +2668,7 @@ "when": "frontMatter:file:isValid == true" } ], - "view/title": [ - { + "view/title": [{ "command": "frontMatter.docs", "group": "navigation@-1", "when": "view == frontMatter.explorer" @@ -2724,16 +2705,13 @@ } ] }, - "languages": [ - { - "id": "frontmatter.project.output", - "mimetypes": [ - "text/x-code-output" - ] - } - ], - "grammars": [ - { + "languages": [{ + "id": "frontmatter.project.output", + "mimetypes": [ + "text/x-code-output" + ] + }], + "grammars": [{ "path": "./syntaxes/hugo.tmLanguage.json", "scopeName": "frontmatter.markdown.hugo", "injectTo": [ @@ -2746,48 +2724,45 @@ "path": "./syntaxes/frontmatter-output.tmLanguage.json" } ], - "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" - ] + "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" }, - { - "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": [ + "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.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" - ] - } - ] - } - ] + "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" + ] + } + ] + }] }, "scripts": { "dev:ext": "npm run clean && npm run localization:generate && npm-run-all --parallel watch:*", @@ -2915,4 +2890,4 @@ "dependencies": { "@radix-ui/react-dropdown-menu": "^2.0.6" } -} +} \ No newline at end of file diff --git a/package.nls.json b/package.nls.json index d7f7f44b..7fc0537f 100644 --- a/package.nls.json +++ b/package.nls.json @@ -145,6 +145,8 @@ "setting.frontMatter.data.folders.items.properties.path.description": "Path to the folder to load files.", "setting.frontMatter.data.folders.items.properties.type.description": "If you are using data types, you can specify your type ID.", "setting.frontMatter.data.folders.items.properties.singleEntry.description": "If you want to use a single entry for your data files in the folder.", + "setting.frontMatter.data.folders.items.properties.enableFileCreation.description": "Enable the creation of new data files in the folder.", + "setting.frontMatter.data.folders.items.properties.fileType.description": "Defines the file type for when the file creation is enabled. JSON is the default.", "setting.frontMatter.data.types.markdownDescription": "Specify the data types. These types can be used in for your data files. [Docs](https://frontmatter.codes/docs/settings/overview#frontmatter.data.types) - [View in VS Code](command:simpleBrowser.show?%5B%22https://frontmatter.codes/docs/settings/overview%23frontmatter.data.types%22%5D)", "setting.frontMatter.data.types.items.properties.id.description": "Your unique ID you want to use for your data type.", "setting.frontMatter.file.preserveCasing.markdownDescription": "Specify if you want to preserve the casing of your file names from the title. [Docs](https://frontmatter.codes/docs/settings/overview#frontmatter.file.preservecasing) - [View in VS Code](command:simpleBrowser.show?%5B%22https://frontmatter.codes/docs/settings/overview%23frontmatter.file.preservecasing%22%5D)", diff --git a/src/commands/Folders.ts b/src/commands/Folders.ts index 5fa5f317..82c3dca6 100644 --- a/src/commands/Folders.ts +++ b/src/commands/Folders.ts @@ -557,6 +557,22 @@ export class Folders { return parseWinPath(absPath); } + /** + * Converts a given file path to a workspace-relative path. + * + * @param path - The file path to convert. + * @returns The workspace-relative path. + */ + public static wsPath(path: string) { + const wsFolder = Folders.getWorkspaceFolder(); + let absPath = parseWinPath(path).replace( + parseWinPath(wsFolder?.fsPath || ''), + WORKSPACE_PLACEHOLDER + ); + absPath = isWindows() ? absPath.split('\\').join('/') : absPath; + return absPath; + } + /** * Generate relative folder path * @param folder diff --git a/src/dashboardWebView/DashboardMessage.ts b/src/dashboardWebView/DashboardMessage.ts index 66f35ca2..0cdce18f 100644 --- a/src/dashboardWebView/DashboardMessage.ts +++ b/src/dashboardWebView/DashboardMessage.ts @@ -50,6 +50,7 @@ export enum DashboardMessage { // Data dashboard getDataEntries = 'getDataEntries', putDataEntries = 'putDataEntries', + createDataFile = 'createDataFile', // Snippets dashboard insertSnippet = 'insertSnippet', diff --git a/src/dashboardWebView/components/DataView/DataView.tsx b/src/dashboardWebView/components/DataView/DataView.tsx index d9dd185c..bfe2ea2d 100644 --- a/src/dashboardWebView/components/DataView/DataView.tsx +++ b/src/dashboardWebView/components/DataView/DataView.tsx @@ -5,7 +5,7 @@ import { SettingsSelector } from '../../state'; import { DataForm } from './DataForm'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { DataFile } from '../../../models/DataFile'; -import { Messenger } from '@estruyf/vscode/dist/client'; +import { messageHandler, Messenger } from '@estruyf/vscode/dist/client'; import { DashboardMessage } from '../../DashboardMessage'; import { SponsorMsg } from '../Layout/SponsorMsg'; import { EventData } from '@estruyf/vscode'; @@ -15,15 +15,18 @@ import { arrayMoveImmutable } from 'array-move'; import { EmptyView } from './EmptyView'; import { Container } from './SortableContainer'; import { SortableItem } from './SortableItem'; -import { ChevronRightIcon, CircleStackIcon } from '@heroicons/react/24/outline'; +import { ChevronRightIcon, CircleStackIcon, EyeIcon, XMarkIcon } from '@heroicons/react/24/outline'; import { DataType } from '../../../models/DataType'; import { GeneralCommands, WEBSITE_LINKS } from '../../../constants'; import { NavigationItem } from '../Layout'; -import * as l10n from '@vscode/l10n'; -import { LocalizationKey } from '../../../localization'; +import { LocalizationKey, localize } from '../../../localization'; import { DropdownMenu, DropdownMenuContent } from '../../../components/shadcn/Dropdown'; import { MenuButton, MenuItem } from '../Menu'; import { Transition } from '@headlessui/react'; +import { DataFolder } from '../../../models'; +import { ActionsBarItem } from '../Header/ActionsBarItem'; +import { Spinner } from '../Common/Spinner'; +import { openFile } from '../../utils/MessageHandlers'; export interface IDataViewProps { } @@ -33,6 +36,7 @@ export const DataView: React.FunctionComponent = ( const [selectedData, setSelectedData] = useState(null); const [selectedIndex, setSelectedIndex] = useState(null); const [dataEntries, setDataEntries] = useState(null); + const [loading, setLoading] = useState(false); const settings = useRecoilValue(SettingsSelector); const setSchema = (dataFile: DataFile) => { @@ -71,6 +75,7 @@ export const DataView: React.FunctionComponent = ( return; } + debugger const dataClone: any[] = Object.assign([], dataEntries); if (selectedIndex !== null && selectedIndex !== undefined) { dataClone[selectedIndex] = data; @@ -110,11 +115,23 @@ export const DataView: React.FunctionComponent = ( entries: data }); - Messenger.send(DashboardMessage.showNotification, l10n.t(LocalizationKey.dashboardDataViewDataViewUpdateMessage)); + Messenger.send(DashboardMessage.showNotification, localize(LocalizationKey.dashboardDataViewDataViewUpdateMessage)); }, [selectedData] ); + const createDataFile = (folder: DataFolder) => { + setLoading(true); + messageHandler.request(DashboardMessage.createDataFile, folder).then(dataFile => { + if (dataFile) { + setSchema(dataFile); + } + setLoading(false); + }).catch((_: any) => { + setLoading(false); + }); + } + const dataEntry = useMemo(() => { if (selectedData?.singleEntry) { return dataEntries || {}; @@ -125,10 +142,40 @@ export const DataView: React.FunctionComponent = ( : null; }, [selectedData, , dataEntries, selectedIndex]); + // Retrieve the data files, check if they have a schema or ID, if not, they shouldn't be shown + const dataFiles = useMemo(() => { + return (settings?.dataFiles || []) + .map((dataFile: DataFile) => { + if (!dataFile.schema && !dataFile.id) { + return null; + } + + const clonedFile = Object.assign({}, dataFile); + + if (clonedFile.type) { + const dataType = settings?.dataTypes?.find( + (dataType: DataType) => dataType.id === clonedFile.type + ); + if (!dataType) { + return null; + } + clonedFile.schema = Object.assign({}, dataType.schema); + } + + return clonedFile; + }) + .filter((d) => d !== null) as DataFile[]; + }, [settings?.dataFiles]); + + const fileCreationFolders = useMemo(() => { + return (settings?.dataFolders || []) + .filter((folder) => folder.enableFileCreation); + }, [settings?.dataFolders]); + useEffect(() => { Messenger.listen(messageListener); - Messenger.send(DashboardMessage.setTitle, l10n.t(LocalizationKey.dashboardHeaderTabsData)); + Messenger.send(DashboardMessage.setTitle, localize(LocalizationKey.dashboardHeaderTabsData)); Messenger.send(GeneralCommands.toVSCode.logging.info, { message: 'Data view loaded', @@ -140,29 +187,6 @@ export const DataView: React.FunctionComponent = ( }; }, []); - // Retrieve the data files, check if they have a schema or ID, if not, they shouldn't be shown - const dataFiles = (settings?.dataFiles || []) - .map((dataFile: DataFile) => { - if (!dataFile.schema && !dataFile.id) { - return null; - } - - const clonedFile = Object.assign({}, dataFile); - - if (clonedFile.type) { - const dataType = settings?.dataTypes?.find( - (dataType: DataType) => dataType.id === clonedFile.type - ); - if (!dataType) { - return null; - } - clonedFile.schema = Object.assign({}, dataType.schema); - } - - return clonedFile; - }) - .filter((d) => d !== null) as DataFile[]; - return (
@@ -176,7 +200,7 @@ export const DataView: React.FunctionComponent = ( className={`flex flex-col flex-grow overflow-y-auto border-r py-6 px-4 overflow-auto border-[var(--frontmatter-border)]`} >

- {l10n.t(LocalizationKey.dashboardDataViewDataViewSelect)} + {localize(LocalizationKey.dashboardDataViewDataViewSelect)}

@@ -300,14 +372,14 @@ export const DataView: React.FunctionComponent = (
-

{l10n.t(LocalizationKey.dashboardDataViewDataViewNoDataFiles)}

+

{localize(LocalizationKey.dashboardDataViewDataViewNoDataFiles)}

- {l10n.t(LocalizationKey.dashboardDataViewDataViewGetStartedLink)} + {localize(LocalizationKey.dashboardDataViewDataViewGetStartedLink)}

@@ -315,6 +387,8 @@ export const DataView: React.FunctionComponent = ( ) } + {loading && } + void; +} export const EmptyView: React.FunctionComponent = ( - props: React.PropsWithChildren + { folders, onCreate }: React.PropsWithChildren ) => { return ( @@ -15,6 +21,32 @@ export const EmptyView: React.FunctionComponent = (

{l10n.t(LocalizationKey.dashboardDataViewEmptyViewHeading)}

+ + { + onCreate && folders && folders.length > 0 && ( +
+ + + + + {folders.map((folder) => ( + onCreate(folder)} + /> + ))} + + +
+ ) + }
); }; diff --git a/src/dashboardWebView/components/Menu/MenuButton.tsx b/src/dashboardWebView/components/Menu/MenuButton.tsx index 6868e438..d58e52bc 100644 --- a/src/dashboardWebView/components/Menu/MenuButton.tsx +++ b/src/dashboardWebView/components/Menu/MenuButton.tsx @@ -1,26 +1,33 @@ import { ChevronDownIcon } from '@heroicons/react/24/solid'; import * as React from 'react'; import { DropdownMenuTrigger } from '../../../components/shadcn/Dropdown'; +import { cn } from '../../../utils/cn'; export interface IMenuButtonProps { label: string | JSX.Element; title: string; disabled?: boolean; + className?: string; + labelClass?: string; + buttonClass?: string; } export const MenuButton: React.FunctionComponent = ({ label, title, - disabled + disabled, + className, + labelClass, + buttonClass, }: React.PropsWithChildren) => { return ( -
-
+
+
{label}:
{title}