diff --git a/src/components/ButtonOpenMenu.tsx b/src/components/ButtonOpenMenu.tsx index 3f92bfb..9cb5e11 100644 --- a/src/components/ButtonOpenMenu.tsx +++ b/src/components/ButtonOpenMenu.tsx @@ -24,11 +24,12 @@ import { DrawerSnips } from "./DrawerSnips"; import { getId, idEditButtonOpen, idEditButtonOpenSnip } from "./id"; import { DrawerSamples } from "./DrawerSamples"; import { DrawerEmbed } from "./DrawerEmbed"; -import { enableEmbed } from "../core/enableEmbed"; +import { enableEmbed } from "../core/settings/enableEmbed"; import { newDefaultSnip } from "../core/newDefaultSnip"; import { LogTag, log } from "../core/log"; import { DrawerGists } from "./DrawerGists"; -import { enableGists } from "../core/enableGists"; +import { enableGists } from "../core/settings/enableGists"; +import { enableSamples } from "../core/settings/enableSamples"; export function ButtonOpenMenu({ openSnip, @@ -89,9 +90,14 @@ export function ButtonOpenMenu({ ) : ( <> )} - } onClick={() => setIsOpenDrawerSamples(true)}> - Sample - + + {enableSamples() ? ( + } onClick={() => setIsOpenDrawerSamples(true)}> + Sample + + ) : ( + <> + )} diff --git a/src/components/PageEdit.tsx b/src/components/PageEdit.tsx index bc39666..1a24032 100644 --- a/src/components/PageEdit.tsx +++ b/src/components/PageEdit.tsx @@ -25,10 +25,10 @@ import { copyTextToClipboard } from "../core/copyTextToClipboard"; import { LogTag, log } from "../core/log"; import { ButtonEmbedCopy } from "./ButtonEmbedCopy"; import { ButtonOpenMenu } from "./ButtonOpenMenu"; -import { enableEmbed } from "../core/enableEmbed"; +import { enableEmbed } from "../core/settings/enableEmbed"; import { idEditButtonCopyToClipboard } from "./id"; import { getSetting } from "../core/setting"; -import { enableEditImport } from "../core/enableEditImport"; +import { enableEditImport } from "../core/settings/enableEditImport"; function buttonRun() { window.location.href = "./run.html#back"; @@ -145,7 +145,7 @@ export function PageEdit({ initialSnip }: { initialSnip: SnipWithSource }) { } onClick={buttonDeleteSnip} /> {/** Label */} - {getSourceBadge(snip)} + {enableEmbed() ? getSourceBadge(snip) : <>} {/** Settings */} } onClick={buttonSettings} /> diff --git a/src/core/setting.ts b/src/core/setting.ts index 8492fc1..4de434d 100644 --- a/src/core/setting.ts +++ b/src/core/setting.ts @@ -17,13 +17,22 @@ export const settingsMetadata = { defaultValue: "", } as SettingString, + /** + * Show the samples in the open menu. + */ + enableSamples: { + name: "Enable Samples", + type: "boolean", + defaultValue: false, + } as SettingBoolean, + /** * Show the embed button on the edit page and in the open menu. */ enableEmbed: { name: "Enable Embed", type: "boolean", - defaultValue: true, + defaultValue: false, } as SettingBoolean, /** diff --git a/src/core/enableEditImport.ts b/src/core/settings/enableEditImport.ts similarity index 80% rename from src/core/enableEditImport.ts rename to src/core/settings/enableEditImport.ts index 8959769..bf37db7 100644 --- a/src/core/enableEditImport.ts +++ b/src/core/settings/enableEditImport.ts @@ -1,4 +1,4 @@ -import { getSetting } from "./setting"; +import { getSetting } from "../setting"; /** * Enable the import button on the edit page diff --git a/src/core/enableEmbed.ts b/src/core/settings/enableEmbed.ts similarity index 78% rename from src/core/enableEmbed.ts rename to src/core/settings/enableEmbed.ts index 8695708..6df604e 100644 --- a/src/core/enableEmbed.ts +++ b/src/core/settings/enableEmbed.ts @@ -1,5 +1,5 @@ -import { getHost } from "./globals"; -import { getSetting } from "./setting"; +import { getHost } from "../globals"; +import { getSetting } from "../setting"; export function enableEmbed(): boolean { const host = getHost(); diff --git a/src/core/enableGists.ts b/src/core/settings/enableGists.ts similarity index 83% rename from src/core/enableGists.ts rename to src/core/settings/enableGists.ts index a78cccd..251e684 100644 --- a/src/core/enableGists.ts +++ b/src/core/settings/enableGists.ts @@ -1,4 +1,4 @@ -import { getSetting } from "./setting"; +import { getSetting } from "../setting"; /** * Enable creating a local copy of a gist. diff --git a/src/core/settings/enableSamples.ts b/src/core/settings/enableSamples.ts new file mode 100644 index 0000000..fa5d736 --- /dev/null +++ b/src/core/settings/enableSamples.ts @@ -0,0 +1,9 @@ +import { getSetting } from "../setting"; + +/** + * Enable open menu samples button. + */ +export function enableSamples(): boolean { + const enable = getSetting("enableSamples"); + return enable; +}