Skip to content

Commit

Permalink
Show repo links only when dev mode is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoshino committed Nov 1, 2024
1 parent a7b5a20 commit 8d2e6ba
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 47 deletions.
23 changes: 13 additions & 10 deletions src/lib/components/assets/toolbar/edit-options-button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -84,16 +85,18 @@
window.open(publicURL);
}}
/>
<MenuItem
disabled={!$backend?.repository || !repoBlobURL}
label={$_('view_on_x', {
values: { service: $backend?.repository?.label },
default: $_('view_in_repository'),
})}
onclick={() => {
window.open(`${repoBlobURL}?plain=1`);
}}
/>
{#if $prefs.devModeEnabled}
<MenuItem
disabled={!$backend?.repository || !repoBlobURL}
label={$_('view_on_x', {
values: { service: $backend?.repository?.label },
default: $_('view_in_repository'),
})}
onclick={() => {
window.open(`${repoBlobURL}?plain=1`);
}}
/>
{/if}
</Menu>
{/snippet}
</MenuButton>
29 changes: 16 additions & 13 deletions src/lib/components/contents/details/pane-header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -156,7 +157,7 @@
}}
/>
{/if}
{#if originalEntry}
{#if originalEntry && (previewURL || $prefs.devModeEnabled)}
<Divider />
{#if previewURL}
<MenuItem
Expand All @@ -166,18 +167,20 @@
}}
/>
{/if}
<MenuItem
disabled={!$backend?.repository?.blobBaseURL}
label={$_('view_on_x', {
values: { service: $backend?.repository?.label },
default: $_('view_in_repository'),
})}
onclick={() => {
if (originalEntry && $thisPane) {
window.open(getEntryRepoBlobURL(originalEntry, $thisPane.locale));
}
}}
/>
{#if $prefs.devModeEnabled}
<MenuItem
disabled={!$backend?.repository?.blobBaseURL}
label={$_('view_on_x', {
values: { service: $backend?.repository?.label },
default: $_('view_in_repository'),
})}
onclick={() => {
if (originalEntry && $thisPane) {
window.open(getEntryRepoBlobURL(originalEntry, $thisPane.locale));
}
}}
/>
{/if}
{/if}
</Menu>
{/snippet}
Expand Down
18 changes: 1 addition & 17 deletions src/lib/components/contents/details/toolbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -29,7 +29,6 @@
import {
getAssociatedAssets,
getEntryPreviewURL,
getEntryRepoBlobURL,
getEntryTitle,
} from '$lib/services/contents/entry';
import { defaultI18nConfig, getLocaleLabel } from '$lib/services/contents/i18n';
Expand Down Expand Up @@ -221,21 +220,6 @@
revertChanges();
}}
/>
{#if originalEntry}
<Divider />
<MenuItem
disabled={!$backend?.repository?.blobBaseURL}
label={$_('view_on_x', {
values: { service: $backend?.repository?.label },
default: $_('view_in_repository'),
})}
onclick={() => {
if (originalEntry) {
window.open(getEntryRepoBlobURL(originalEntry, defaultLocale));
}
}}
/>
{/if}
</Menu>
{/snippet}
</MenuButton>
Expand Down
14 changes: 7 additions & 7 deletions src/lib/components/global/toolbar/items/account-button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
openProductionSite();
}}
/>
<MenuItem
label={$_('git_repository')}
disabled={!$backend?.repository?.treeBaseURL}
onclick={() => {
window.open($backend?.repository?.treeBaseURL);
}}
/>
{#if $prefs.devModeEnabled}
<MenuItem
label={$_('git_repository')}
disabled={!$backend?.repository?.treeBaseURL}
onclick={() => {
window.open($backend?.repository?.treeBaseURL);
}}
/>
<MenuItem
label={$_('site_config')}
onclick={() => {
Expand Down

0 comments on commit 8d2e6ba

Please sign in to comment.