From 8d2e6ba31ec0ea57675ee5eabe8c2fd140cb73e4 Mon Sep 17 00:00:00 2001 From: Kohei Yoshino Date: Fri, 1 Nov 2024 03:38:53 -0400 Subject: [PATCH] Show repo links only when dev mode is enabled https://github.com/sveltia/sveltia-cms/discussions/243 --- .../assets/toolbar/edit-options-button.svelte | 23 ++++++++------- .../contents/details/pane-header.svelte | 29 ++++++++++--------- .../contents/details/toolbar.svelte | 18 +----------- .../toolbar/items/account-button.svelte | 14 ++++----- 4 files changed, 37 insertions(+), 47 deletions(-) diff --git a/src/lib/components/assets/toolbar/edit-options-button.svelte b/src/lib/components/assets/toolbar/edit-options-button.svelte index 8f9c47fa..86fd738c 100644 --- a/src/lib/components/assets/toolbar/edit-options-button.svelte +++ b/src/lib/components/assets/toolbar/edit-options-button.svelte @@ -10,6 +10,7 @@ } from '$lib/services/assets'; import { showUploadAssetsDialog } from '$lib/services/assets/view'; import { backend } from '$lib/services/backends'; + import { prefs } from '$lib/services/prefs'; /** * @type {Asset | undefined} @@ -84,16 +85,18 @@ window.open(publicURL); }} /> - { - window.open(`${repoBlobURL}?plain=1`); - }} - /> + {#if $prefs.devModeEnabled} + { + window.open(`${repoBlobURL}?plain=1`); + }} + /> + {/if} {/snippet} diff --git a/src/lib/components/contents/details/pane-header.svelte b/src/lib/components/contents/details/pane-header.svelte index 145b9e04..bf795b8f 100644 --- a/src/lib/components/contents/details/pane-header.svelte +++ b/src/lib/components/contents/details/pane-header.svelte @@ -22,6 +22,7 @@ import { revertChanges, toggleLocale } from '$lib/services/contents/draft/update'; import { getEntryPreviewURL, getEntryRepoBlobURL } from '$lib/services/contents/entry'; import { defaultI18nConfig, getLocaleLabel } from '$lib/services/contents/i18n'; + import { prefs } from '$lib/services/prefs'; /** * The wrapper element’s `id` attribute. @@ -156,7 +157,7 @@ }} /> {/if} - {#if originalEntry} + {#if originalEntry && (previewURL || $prefs.devModeEnabled)} {#if previewURL} {/if} - { - if (originalEntry && $thisPane) { - window.open(getEntryRepoBlobURL(originalEntry, $thisPane.locale)); - } - }} - /> + {#if $prefs.devModeEnabled} + { + if (originalEntry && $thisPane) { + window.open(getEntryRepoBlobURL(originalEntry, $thisPane.locale)); + } + }} + /> + {/if} {/if} {/snippet} diff --git a/src/lib/components/contents/details/toolbar.svelte b/src/lib/components/contents/details/toolbar.svelte index 73fbff56..cb03677a 100644 --- a/src/lib/components/contents/details/toolbar.svelte +++ b/src/lib/components/contents/details/toolbar.svelte @@ -18,7 +18,7 @@ import equal from 'fast-deep-equal'; import { _ } from 'svelte-i18n'; import { goBack, goto } from '$lib/services/app/navigation'; - import { backend, backendName } from '$lib/services/backends'; + import { backendName } from '$lib/services/backends'; import { siteConfig } from '$lib/services/config'; import { deleteEntries } from '$lib/services/contents/data'; import { entryDraft } from '$lib/services/contents/draft'; @@ -29,7 +29,6 @@ import { getAssociatedAssets, getEntryPreviewURL, - getEntryRepoBlobURL, getEntryTitle, } from '$lib/services/contents/entry'; import { defaultI18nConfig, getLocaleLabel } from '$lib/services/contents/i18n'; @@ -221,21 +220,6 @@ revertChanges(); }} /> - {#if originalEntry} - - { - if (originalEntry) { - window.open(getEntryRepoBlobURL(originalEntry, defaultLocale)); - } - }} - /> - {/if} {/snippet} diff --git a/src/lib/components/global/toolbar/items/account-button.svelte b/src/lib/components/global/toolbar/items/account-button.svelte index 331704c0..7a69c1f0 100644 --- a/src/lib/components/global/toolbar/items/account-button.svelte +++ b/src/lib/components/global/toolbar/items/account-button.svelte @@ -49,14 +49,14 @@ openProductionSite(); }} /> - { - window.open($backend?.repository?.treeBaseURL); - }} - /> {#if $prefs.devModeEnabled} + { + window.open($backend?.repository?.treeBaseURL); + }} + /> {