Skip to content

Commit ce06de3

Browse files
authored
Merge pull request #14 from tinypluginlabs/copilot/disable-download-zip-export-github-blueprint-tab
Disable download zip, export to GitHub, and blueprint tab
2 parents 2a71056 + d898480 commit ce06de3

4 files changed

Lines changed: 83 additions & 15 deletions

File tree

.github/workflows/deploy-website.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ jobs:
4848
VITE_CAN_INSTALL: no
4949
VITE_CAN_EDIT: no
5050
VITE_CAN_EDIT_DATABASE: no
51+
VITE_CAN_DOWNLOAD_ZIP: no
52+
VITE_CAN_EXPORT_GITHUB: no
53+
VITE_CAN_BLUEPRINT: no
5154
- run: tar -czf wasm-wordpress-net.tar.gz dist/packages/playground/wasm-wordpress-net
5255
# Store dist/packages/artifacts/wasm-wordpress-net as a build artifact
5356
- uses: actions/upload-artifact@v4

packages/playground/website/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
# VITE_CAN_INSTALL=no
1111
# VITE_CAN_EDIT=no
1212
# VITE_CAN_EDIT_DATABASE=no
13+
# VITE_CAN_DOWNLOAD_ZIP=no
14+
# VITE_CAN_EXPORT_GITHUB=no
15+
# VITE_CAN_BLUEPRINT=no

packages/playground/website/src/components/site-manager/site-info-panel/index.tsx

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ import { GithubExportMenuItem } from '../../toolbar-buttons/github-export-menu-i
3232
import { SiteDatabasePanel } from '../site-database-panel';
3333
import { ActiveSiteSettingsForm } from '../site-settings-form/active-site-settings-form';
3434
import { TemporarySiteNotice } from '../temporary-site-notice';
35-
import { isEditDisabledByQueryParam, isDatabaseDisabledByQueryParam } from '../../../lib/state/url/router';
35+
import {
36+
isEditDisabledByQueryParam,
37+
isDatabaseDisabledByQueryParam,
38+
isDownloadZipDisabled,
39+
isExportGithubDisabled,
40+
isBlueprintDisabled,
41+
} from '../../../lib/state/url/router';
3642
import css from './style.module.css';
3743

3844
const SiteFileBrowser = lazy(() =>
@@ -356,16 +362,20 @@ export function SiteInfoPanel({
356362
</MenuGroup>
357363
)}
358364
<MenuGroup>
359-
<GithubExportMenuItem
360-
onClose={onClose}
361-
disabled={
362-
offline || !playground
363-
}
364-
/>
365-
<DownloadAsZipMenuItem
366-
onClose={onClose}
367-
disabled={!playground}
368-
/>
365+
{!isExportGithubDisabled() && (
366+
<GithubExportMenuItem
367+
onClose={onClose}
368+
disabled={
369+
offline || !playground
370+
}
371+
/>
372+
)}
373+
{!isDownloadZipDisabled() && (
374+
<DownloadAsZipMenuItem
375+
onClose={onClose}
376+
disabled={!playground}
377+
/>
378+
)}
369379
</MenuGroup>
370380
</>
371381
)}
@@ -391,10 +401,14 @@ export function SiteInfoPanel({
391401
},
392402
]
393403
: []),
394-
{
395-
name: 'blueprint',
396-
title: 'Blueprint',
397-
},
404+
...(!isBlueprintDisabled()
405+
? [
406+
{
407+
name: 'blueprint',
408+
title: 'Blueprint',
409+
},
410+
]
411+
: []),
398412
...(!isDatabaseDisabledByQueryParam()
399413
? [
400414
{

packages/playground/website/src/lib/state/url/router.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,54 @@ export function isDatabaseDisabledByQueryParam(): boolean {
204204
return isDatabaseDisabled();
205205
}
206206

207+
/**
208+
* Checks if the download-as-zip feature is disabled.
209+
* Features can be disabled either at build time (via VITE_CAN_DOWNLOAD_ZIP env var)
210+
* or at runtime (via ?can-download-zip=no query parameter).
211+
*
212+
* @returns {boolean} True if download-as-zip is disabled, false otherwise.
213+
*/
214+
export function isDownloadZipDisabled(): boolean {
215+
if (import.meta.env.VITE_CAN_DOWNLOAD_ZIP === 'no') {
216+
return true;
217+
}
218+
return (
219+
new URL(document.location.href).searchParams.get('can-download-zip') === 'no'
220+
);
221+
}
222+
223+
/**
224+
* Checks if the export-to-GitHub feature is disabled.
225+
* Features can be disabled either at build time (via VITE_CAN_EXPORT_GITHUB env var)
226+
* or at runtime (via ?can-export-github=no query parameter).
227+
*
228+
* @returns {boolean} True if export-to-GitHub is disabled, false otherwise.
229+
*/
230+
export function isExportGithubDisabled(): boolean {
231+
if (import.meta.env.VITE_CAN_EXPORT_GITHUB === 'no') {
232+
return true;
233+
}
234+
return (
235+
new URL(document.location.href).searchParams.get('can-export-github') === 'no'
236+
);
237+
}
238+
239+
/**
240+
* Checks if the Blueprint tab is disabled.
241+
* Features can be disabled either at build time (via VITE_CAN_BLUEPRINT env var)
242+
* or at runtime (via ?can-blueprint=no query parameter).
243+
*
244+
* @returns {boolean} True if the Blueprint tab is disabled, false otherwise.
245+
*/
246+
export function isBlueprintDisabled(): boolean {
247+
if (import.meta.env.VITE_CAN_BLUEPRINT === 'no') {
248+
return true;
249+
}
250+
return (
251+
new URL(document.location.href).searchParams.get('can-blueprint') === 'no'
252+
);
253+
}
254+
207255
/**
208256
* Checks if the MCP server bridge is enabled via the `?mcp=yes` query parameter.
209257
*/

0 commit comments

Comments
 (0)