@morphemecms/cms 0.13.0 → 0.14.0-next-20261107080444

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/defaults/editor.ts +3 -14
  3. package/icons/lucide/dots-three-vertical.svg +1 -0
  4. package/icons/material-symbols/dots-three-vertical.svg +1 -0
  5. package/icons/phosphor/dots-three-vertical.svg +1 -0
  6. package/lib/appChanges.d.mts +16 -0
  7. package/lib/appChanges.mjs +20 -0
  8. package/lib/appChanges.test.mjs +30 -0
  9. package/lib/apps.d.mts +2 -2
  10. package/lib/apps.mjs +13 -7
  11. package/lib/appsFile.d.mts +20 -0
  12. package/lib/appsFile.mjs +57 -0
  13. package/lib/appsFile.test.mjs +53 -0
  14. package/lib/build-settings.mjs +1 -1
  15. package/lib/google-result.test.mjs +40 -9
  16. package/lib/menu.mjs +1 -1
  17. package/lib/menu.test.mjs +6 -5
  18. package/package.json +1 -1
  19. package/scripts/app-screenshots.mjs +4 -4
  20. package/scripts/build-settings-problems.mjs +1 -1
  21. package/scripts/built-site.mjs +1 -1
  22. package/scripts/check-content.mjs +1 -1
  23. package/scripts/check-worker.mjs +1 -1
  24. package/scripts/editor-screens.mjs +32 -16
  25. package/site/apps.ts +10 -4
  26. package/site/consent.ts +3 -3
  27. package/site/defineSite.mjs +1 -1
  28. package/site/icons.d.mts +4 -0
  29. package/site/icons.mjs +2 -0
  30. package/site/pageColors.ts +3 -3
  31. package/site/siteCsp.d.mts +1 -1
  32. package/site/siteCsp.mjs +3 -2
  33. package/src/ActionParts.tsx +1 -1
  34. package/src/Advanced.tsx +4 -4
  35. package/src/App.tsx +19 -17
  36. package/src/AppList.tsx +46 -19
  37. package/src/AppSettingsTab.tsx +15 -6
  38. package/src/BlockParts.tsx +7 -7
  39. package/src/BlockSettings.tsx +3 -3
  40. package/src/CmsPage.tsx +4 -1
  41. package/src/Colors.tsx +2 -2
  42. package/src/CommunicationParts.tsx +1 -1
  43. package/src/ContainmentParts.tsx +1 -1
  44. package/src/DataForm.tsx +1 -0
  45. package/src/EntryForm.tsx +1 -0
  46. package/src/Library.tsx +21 -10
  47. package/src/MainDrawerParts.tsx +1 -1
  48. package/src/MarkdownEditor.tsx +1 -1
  49. package/src/ModalSheetSample.tsx +1 -1
  50. package/src/MorphemeConnection.tsx +30 -0
  51. package/src/MorphemeLogo.tsx +9 -0
  52. package/src/NavigationParts.tsx +1 -1
  53. package/src/NavigationRestParts.tsx +1 -1
  54. package/src/Parts.tsx +9 -9
  55. package/src/PartsShown.tsx +1 -1
  56. package/src/PickerParts.tsx +1 -1
  57. package/src/SearchPreview.tsx +37 -14
  58. package/src/SelectionParts.tsx +1 -1
  59. package/src/SideColumn.tsx +2 -2
  60. package/src/StoreConnectNotice.tsx +1 -1
  61. package/src/StoreConnectedRow.tsx +20 -14
  62. package/src/StoreStatus.tsx +2 -10
  63. package/src/ThemeStoreScreen.tsx +1 -2
  64. package/src/Tokens.tsx +2 -2
  65. package/src/apps.ts +16 -14
  66. package/src/buildSettings.ts +1 -1
  67. package/src/editor.css +13 -2
  68. package/src/examples.ts +2 -2
  69. package/src/googleResult.d.mts +12 -1
  70. package/src/googleResult.mjs +19 -2
  71. package/src/i18n/da-DK/apps.ts +5 -1
  72. package/src/i18n/da-DK/cms.ts +1 -0
  73. package/src/i18n/da-DK/common.ts +3 -2
  74. package/src/i18n/en-US/advanced.ts +1 -1
  75. package/src/i18n/en-US/apps.ts +6 -1
  76. package/src/i18n/en-US/cms.ts +1 -0
  77. package/src/i18n/en-US/common.ts +6 -4
  78. package/src/i18n/en-US/parts.ts +3 -3
  79. package/src/menuChildren.ts +6 -14
  80. package/src/movedRoutes.mjs +12 -8
  81. package/src/movedRoutes.test.mjs +13 -10
  82. package/src/r2Caching.ts +1 -1
  83. package/src/registry.tsx +2 -2
  84. package/src/schema.ts +1 -1
  85. package/src/site.ts +2 -2
  86. package/src/store.ts +4 -8
  87. package/src/themeUi.ts +7 -7
  88. package/src/ui.tsx +2 -2
  89. package/theme/components/AppSlot.astro +4 -4
  90. package/worker/index.js +6 -3
  91. package/worker/plan-status.js +1 -1
  92. package/worker/r2-status.js +1 -1
@@ -4,7 +4,7 @@
4
4
  // packages/editor/src/icon.tsx), there or on one of the built site's pages. An icon drawn from Material Symbols instead
5
5
  // of the icon pack (data-icon-fallback) is only listed, with where it is: it does not fail.
6
6
  // The screens are found as the editor's own links: from the start screen (the drawer's links are in the page also while it is
7
- // closed) and "Dele", #appearance/parts, "Temaer", #appearance/themes, "Søgemaskineoptimering", #seo, "Appstore", #settings/appstore, and "Apps", #apps, which the menu no longer links to), and
7
+ // closed) and "Parts", #developer/parts, "Temaer", #appearance/themes, "Søgemaskineoptimering", #seo, "Appstore", #settings/appstore, and "Apps", #apps, which the menu no longer links to), and
8
8
  // from each screen it opens, two steps down. GitHub is answered from the files in this repository, so it needs no login
9
9
  // and changes nothing. It runs on the built site: npm run build && npm run check:screens (or on another
10
10
  // folder with a built site, its path after the command: packages/editor/scripts/check-themes.mjs).
@@ -68,10 +68,10 @@ for (const [width, height] of [
68
68
  });
69
69
  await openEditor(page, site);
70
70
 
71
- // From the start screen (the drawer's links), and from "Dele", "Temaer", "Søgemaskineoptimering" and "Appstore"
71
+ // From the start screen (the drawer's links), and from "Parts", "Temaer", "Søgemaskineoptimering" and "Appstore"
72
72
  // (the apps' pages and their developers'), whose screens are a step further down than the others. "Apps" (the list of
73
73
  // the apps installed) has no row in the menu, so it is a start of its own.
74
- const starts = ['', 'appearance/parts', 'appearance/themes', 'seo', 'settings/appstore', 'apps'];
74
+ const starts = ['', 'developer/parts', 'appearance/themes', 'seo', 'settings/appstore', 'apps'];
75
75
  const seen = new Set(starts);
76
76
  let next = starts;
77
77
  for (let depth = 0; depth <= 2 && next.length; depth++) {
@@ -104,27 +104,43 @@ for (const [width, height] of [
104
104
  await page.close();
105
105
  }
106
106
 
107
- // "Appstore" in the three states of the site's key to the store (STORE_STATES): what each shows, and a picture of it in
107
+ // "Appstore" and "Morpheme" in the three states of the site's key to the store (STORE_STATES): what each shows, and a picture of it in
108
108
  // SCREENS_DIR (the temporary folder's morpheme-screens by default).
109
109
  const shots = process.env.SCREENS_DIR || join(tmpdir(), 'morpheme-screens');
110
110
  mkdirSync(shots, { recursive: true });
111
111
  const keyStates = {
112
- open: { shows: ['Hjemmesiden er ikke forbundet til Morpheme', 'Forbind til Morpheme'], hides: ['Afbryd forbindelsen til Morpheme'] },
113
- readOnly: { shows: ['Hjemmesiden har ingen Appstore'], hides: ['Forbind til Morpheme', 'Afbryd forbindelsen til Morpheme'] },
114
- button: { shows: ['Forbundet til Morpheme', 'site_sample', 'Afbryd forbindelsen til Morpheme'], hides: ['Forbind til Morpheme'] },
112
+ open: {
113
+ appstore: {
114
+ shows: ['Hjemmesiden er ikke forbundet til Morpheme', 'Forbind til Morpheme'],
115
+ hides: ['Afbryd forbindelsen til Morpheme'],
116
+ },
117
+ morpheme: { shows: ['Forbind til Morpheme'], hides: ['Afbryd forbindelsen til Morpheme'] },
118
+ },
119
+ readOnly: {
120
+ appstore: { shows: ['Hjemmesiden har ingen Appstore'], hides: ['Forbind til Morpheme', 'Afbryd forbindelsen til Morpheme'] },
121
+ morpheme: { shows: ['Hjemmesiden har ingen Appstore'], hides: ['Forbind til Morpheme', 'Afbryd forbindelsen til Morpheme'] },
122
+ },
123
+ button: {
124
+ appstore: { shows: [], hides: ['Forbundet til Morpheme', 'Afbryd forbindelsen til Morpheme'] },
125
+ morpheme: { shows: ['Forbundet til Morpheme', 'site_sample', 'Afbryd forbindelsen til Morpheme'], hides: ['Forbind til Morpheme'] },
126
+ },
115
127
  };
116
- for (const [state, { shows, hides }] of Object.entries(keyStates)) {
128
+ // The screens that show the key: where each is (its address after the "#", CMS_ROUTE in CmsPage.tsx for "Morpheme").
129
+ const keyScreens = { appstore: 'settings/appstore', morpheme: 'morpheme' };
130
+ for (const [state, checks] of Object.entries(keyStates)) {
117
131
  const page = await browser.newPage({ viewport: { width: 390, height: 844 }, locale: 'da-DK' });
118
132
  page.on('pageerror', (e) => problems.push(`Appstore (${state}): ${e.message}`));
119
133
  await openEditor(page, site, {}, state);
120
- await page.evaluate(() => (location.hash = 'settings/appstore'));
121
- await page.waitForTimeout(500);
122
- const text = await page.evaluate(() => document.body.innerText);
123
- for (const x of shows) if (!text.includes(x)) problems.push(`Appstore (${state}): "${x}" mangler`);
124
- for (const x of hides) if (text.includes(x)) problems.push(`Appstore (${state}): "${x}" skal ikke vises`);
125
- const file = join(shots, `appstore-${state}.png`);
126
- await page.screenshot({ path: file });
127
- console.log(`Appstore (${state}): ${file}`);
134
+ for (const [screen, { shows, hides }] of Object.entries(checks)) {
135
+ await page.evaluate((hash) => (location.hash = hash), keyScreens[screen]);
136
+ await page.waitForTimeout(500);
137
+ const text = await page.evaluate(() => document.body.innerText);
138
+ for (const x of shows) if (!text.includes(x)) problems.push(`${screen} (${state}): "${x}" mangler`);
139
+ for (const x of hides) if (text.includes(x)) problems.push(`${screen} (${state}): "${x}" skal ikke vises`);
140
+ const file = join(shots, `${screen}-${state}.png`);
141
+ await page.screenshot({ path: file });
142
+ console.log(`${screen} (${state}): ${file}`);
143
+ }
128
144
  await page.close();
129
145
  }
130
146
 
package/site/apps.ts CHANGED
@@ -1,11 +1,17 @@
1
- // The apps on the site (src/apps/<app>/, packages/editor/src/apps.ts): which are installed under
2
- // "Indstillinger" › "Apps" in the editor (apps.json), and each app's settings (apps/<app>.json), as the
1
+ // The apps on the site (src/apps/<app>/, packages/editor/src/apps.ts): which are installed (and which of them are
2
+ // turned off) under "Indstillinger" › "Apps" in the editor (apps.json), and each app's settings (apps/<app>.json), as the
3
3
  // site's build reads them. What an app puts on every page (AppSlot.astro) is there only while it is
4
4
  // installed; what was made with it (a pop-up, a block on a page) stays when it is uninstalled.
5
5
  import data from '@data/apps.json';
6
+ import { activeOf, readAppsFile } from '../lib/appsFile.mjs';
6
7
 
7
- /** The ids of the apps installed. */
8
- export const installed: string[] = Array.isArray(data.installed) ? data.installed.map(String) : [];
8
+ const state = readAppsFile(JSON.stringify(data));
9
+
10
+ /** The ids of the apps installed, also those turned off. */
11
+ export const installed: string[] = state.installed;
12
+
13
+ /** The ids of the apps installed and not turned off: what runs, and puts something on the site. */
14
+ export const active: string[] = activeOf(state);
9
15
 
10
16
  // Each app's saved settings, by its id (the file's name).
11
17
  const saved = Object.fromEntries(
package/site/consent.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // What the cookie banner asks about: the categories of cookies (@morphemecms/cms/lib/cookieCategories.mjs) of what the
2
- // installed apps load with their settings (`cookies` in their index.ts: Google Analytics statistics, Google Ads
2
+ // active apps (installed, not turned off) load with their settings (`cookies` in their index.ts: Google Analytics statistics, Google Ads
3
3
  // marketing, Google Tag Manager both), each a yes or no of its own; and whether the site has the banner (and
4
4
  // "Cookieindstillinger" in the footer) at all: when it is switched on ("Privatliv" › "Cookiebanner",
5
5
  // src/data/cookies.json) and there is something to ask about. For the theme (Base.astro, Footer.astro,
@@ -8,7 +8,7 @@ import type { AppDefinition } from '../src/apps';
8
8
  import { appIdOf } from '../src/apps';
9
9
  import { CONSENT_CATEGORIES, type ConsentCategory } from '../lib/cookieCategories.mjs';
10
10
  import cookies from '@data/cookies.json';
11
- import { installed, settingsOf } from './apps';
11
+ import { active, settingsOf } from './apps';
12
12
 
13
13
  // Only the apps' index.ts, without their blocks (as opens.ts).
14
14
  const appFiles = import.meta.glob<{ default: AppDefinition }>('/src/apps/*/index.ts', { eager: true });
@@ -16,7 +16,7 @@ const appFiles = import.meta.glob<{ default: AppDefinition }>('/src/apps/*/index
16
16
  const asked = new Set(
17
17
  Object.entries(appFiles).flatMap(([path, { default: app }]) => {
18
18
  const id = appIdOf(path);
19
- return installed.includes(id) ? (app.cookies?.(settingsOf(id, app.settings?.values)) ?? []) : [];
19
+ return active.includes(id) ? (app.cookies?.(settingsOf(id, app.settings?.values)) ?? []) : [];
20
20
  }),
21
21
  );
22
22
 
@@ -54,7 +54,7 @@ const CHOICES = {
54
54
 
55
55
  /** The same on every site. */
56
56
  const STANDARD = {
57
- /** The Worker's settings: the editor turns R2 caching on and off in them ("Indstillinger" › "Avanceret", src/r2Caching.ts). */
57
+ /** The Worker's settings: the editor turns R2 caching on and off in them (Settings › Developer › Caching and builds, src/r2Caching.ts). */
58
58
  wrangler: 'wrangler.jsonc',
59
59
  /** The folders the editor loads: the blog posts, the pages, the data files, the pictures and the PDFs, videos and zip
60
60
  * files (shown with the pictures in "Filer", at /filer/<name> on the site). */
package/site/icons.d.mts CHANGED
@@ -154,6 +154,7 @@ export const MATERIAL_SYMBOLS: {
154
154
  desktop: string;
155
155
  'device-mobile': string;
156
156
  'door-open': string;
157
+ 'dots-three-vertical': string;
157
158
  'download-simple': string;
158
159
  'envelope-simple': string;
159
160
  'envelope-simple-fill': string;
@@ -345,6 +346,7 @@ export const LUCIDE: {
345
346
  desktop: string;
346
347
  'device-mobile': string;
347
348
  'door-open': string;
349
+ 'dots-three-vertical': string;
348
350
  'download-simple': string;
349
351
  'envelope-simple': string;
350
352
  'envelope-simple-fill': string;
@@ -536,6 +538,7 @@ export const PACK_MAPS: {
536
538
  desktop: string;
537
539
  'device-mobile': string;
538
540
  'door-open': string;
541
+ 'dots-three-vertical': string;
539
542
  'download-simple': string;
540
543
  'envelope-simple': string;
541
544
  'envelope-simple-fill': string;
@@ -725,6 +728,7 @@ export const PACK_MAPS: {
725
728
  desktop: string;
726
729
  'device-mobile': string;
727
730
  'door-open': string;
731
+ 'dots-three-vertical': string;
728
732
  'download-simple': string;
729
733
  'envelope-simple': string;
730
734
  'envelope-simple-fill': string;
package/site/icons.mjs CHANGED
@@ -168,6 +168,7 @@ export const MATERIAL_SYMBOLS = {
168
168
  desktop: 'desktop_windows',
169
169
  'device-mobile': 'mobile',
170
170
  'door-open': 'door_open',
171
+ 'dots-three-vertical': 'more_vert',
171
172
  'download-simple': 'download',
172
173
  'envelope-simple': 'mail',
173
174
  'envelope-simple-fill': 'mail-fill',
@@ -360,6 +361,7 @@ export const LUCIDE = {
360
361
  desktop: 'monitor',
361
362
  'device-mobile': 'smartphone',
362
363
  'door-open': 'door-open',
364
+ 'dots-three-vertical': 'ellipsis-vertical',
363
365
  'download-simple': 'download',
364
366
  'envelope-simple': 'mail',
365
367
  'envelope-simple-fill': 'mail-fill',
@@ -1,5 +1,5 @@
1
1
  // The colours of one page, for the theme (Base.astro, which knows no app by name): the site's own (src/data/colors.json,
2
- // "Farver"), changed by the apps installed that change a page's colours (hooks/page-colors.ts, PageColorsHook in
2
+ // "Farver"), changed by the active apps (installed, not turned off) that change a page's colours (hooks/page-colors.ts, PageColorsHook in
3
3
  // @morphemecms/cms/lib/hooks.ts), in the order of their ids, each given the colours the one before left. An app gets the
4
4
  // page's address, its pictures, its own settings, the colours' roles, and the pixels of a picture read small, so it
5
5
  // never reads the site's files itself; what it gives is kept only when it is the site's colours, by their names, and
@@ -12,7 +12,7 @@ import path from 'node:path';
12
12
  import sharp from 'sharp';
13
13
  import colors from '@data/colors.json';
14
14
  import { colorFields, colorPairs, colorRoles } from '@site/colors';
15
- import { installed, settingsOf } from './apps';
15
+ import { active, settingsOf } from './apps';
16
16
  import { appIdOf, type AppDefinition } from '@morphemecms/cms/src/apps';
17
17
  import { colorProblems, lowContrast, MODES, type Colors } from '@morphemecms/cms/lib/colors';
18
18
  import { completeColors } from '@morphemecms/cms/lib/dynamic-colors';
@@ -31,7 +31,7 @@ const appFiles = import.meta.glob<{ default: AppDefinition }>('/src/apps/*/index
31
31
  const hookFiles = import.meta.glob<{ default: PageColorsHook }>('/src/apps/*/hooks/page-colors.ts', { eager: true });
32
32
  const hooks = Object.entries(hookFiles)
33
33
  .map(([file, { default: hook }]) => ({ id: appIdOf(file), hook }))
34
- .filter(({ id }) => installed.includes(id))
34
+ .filter(({ id }) => active.includes(id))
35
35
  .sort((a, b) => a.id.localeCompare(b.id))
36
36
  .map(({ id, hook }) => ({
37
37
  id,
@@ -1,4 +1,4 @@
1
- /** What the site's installed apps load from elsewhere, and the addresses allowed in the editor.
1
+ /** What the site's active apps (installed, not turned off) load from elsewhere, and the addresses allowed in the editor.
2
2
  * @returns {import('../lib/csp.mjs').Sources[]} */
3
3
  export function siteSources(): import("../lib/csp.mjs").Sources[];
4
4
  /** What is wrong with the addresses allowed in the editor (src/data/csp.json): not JSON, or not written as an app's
package/site/siteCsp.mjs CHANGED
@@ -6,6 +6,7 @@
6
6
  // Read by the build (packages/editor/astro.mjs) and by npm run check:content (appCspProblems), so no TypeScript here.
7
7
  import { existsSync, readdirSync, readFileSync } from 'node:fs';
8
8
  import { pathToFileURL } from 'node:url';
9
+ import { activeOf, readAppsFile } from '../lib/appsFile.mjs';
9
10
  import { allows, sourcesProblems } from '../lib/csp.mjs';
10
11
 
11
12
  // The site's src/, from its root (the working directory).
@@ -22,10 +23,10 @@ const appSources = (app) => {
22
23
  const ALLOWED = new URL('data/csp.json', SRC);
23
24
  const allowedSources = () => (existsSync(ALLOWED) ? JSON.parse(readFileSync(ALLOWED, 'utf8')) : {});
24
25
 
25
- /** What the site's installed apps load from elsewhere, and the addresses allowed in the editor.
26
+ /** What the site's active apps (installed, not turned off) load from elsewhere, and the addresses allowed in the editor.
26
27
  * @returns {import('../lib/csp.mjs').Sources[]} */
27
28
  export function siteSources() {
28
- return [...(json('data/apps.json').installed ?? []).map(appSources), allowedSources()];
29
+ return [...activeOf(readAppsFile(readFileSync(new URL('data/apps.json', SRC), 'utf8'))).map(appSources), allowedSources()];
29
30
  }
30
31
 
31
32
  /** What is wrong with the addresses allowed in the editor (src/data/csp.json): not JSON, or not written as an app's
@@ -1,4 +1,4 @@
1
- // "Dele" › "UI-komponenter" (BlockParts.tsx), the group "Handlinger": the theme's buttons that do more than one thing
1
+ // "Parts" › "UI-komponenter" (BlockParts.tsx), the group "Handlinger": the theme's buttons that do more than one thing
2
2
  // (packages/editor/theme/ui/, through @site/editor) as the site draws them: button groups in both kinds with toggles on
3
3
  // and off, in every size and in both shapes, segmented buttons with one and with several chosen, split buttons in their
4
4
  // kinds and sizes, closed and with the menu open, and FAB menus in their colour sets, from FABs of each size, closed
package/src/Advanced.tsx CHANGED
@@ -1,4 +1,4 @@
1
- // "Avanceret" (#advanced), under "Indstillinger": R2 caching, the copy of the site's files in Cloudflare R2 the Worker
1
+ // "Caching and builds" (#developer/caching), under "Developer" (Library.tsx Developer): R2 caching, the copy of the site's files in Cloudflare R2 the Worker
2
2
  // answers the editor from (packages/editor/worker/files.js), turned on and off with "Aktiveret" in the Worker's settings (r2Caching.ts),
3
3
  // saved at once in its own commit. Off, the Worker asks GitHub for everything. It can only be turned on when Cloudflare
4
4
  // has the bucket (the Worker asks, /api/r2), else a deploy would fail; under the switch, why not, and, until the site is
@@ -13,7 +13,7 @@ import { EmptyNote, GroupTitle, LinkButton, MenuRow, ProblemNote, SupportingText
13
13
  import { ConflictError, type RepoFile } from './github';
14
14
  import type { Env } from './App';
15
15
  import { savedText } from './deploy';
16
- import { backFrom } from './site';
16
+ import { backToDeveloper } from './Library';
17
17
  import {
18
18
  bucketOf,
19
19
  JURISDICTIONS,
@@ -32,7 +32,7 @@ import { buildSettingsOf, withBuildSetting, type BuildSetting } from './buildSet
32
32
  import { BUILD_SETTINGS_PATH } from '../lib/build-settings.mjs';
33
33
  import { siteT, t } from './i18n';
34
34
 
35
- export const ADVANCED_ROUTE = 'advanced';
35
+ export const CACHING_ROUTE = 'developer/caching';
36
36
 
37
37
  // "Placering" when Cloudflare places the bucket (no jurisdiction).
38
38
  const AUTO = 'auto';
@@ -170,7 +170,7 @@ export default function Advanced({ env }: { env: Env }) {
170
170
  }
171
171
 
172
172
  return (
173
- <Screen title={t.common.parts.advanced} wide back={backFrom(ADVANCED_ROUTE)}>
173
+ <Screen title={t.common.parts.caching} wide back={backToDeveloper}>
174
174
  <section className="mb-8">
175
175
  <GroupTitle>{t.advanced.r2Caching}</GroupTitle>
176
176
  <div className="px-4">
package/src/App.tsx CHANGED
@@ -26,13 +26,13 @@
26
26
  // appearance/footer the footer's texts and links with its preview (FooterSettings.tsx; once at src/data/footer.json),
27
27
  // appearance/colors the colours (Colors.tsx;
28
28
  // appearance/colors/fallback-colors the site's own while an app changes the pages'),
29
- // appearance/parts the parts (Library.tsx PartsHome): appearance/parts/editor the editor's, every
30
- // one in every state (Parts.tsx), appearance/parts/ui the theme's UI components, appearance/parts/blocks the
31
- // blocks, the standard ones and the apps', and appearance/parts/list/<list> each kind of a list of kinds
32
- // ("Promovering"), its own and the apps' (BlockParts.tsx), and appearance/parts/values the
29
+ // developer the developer screens (Library.tsx Developer), under "Settings": developer/caching the copy of the site's files in R2 and the build settings (Advanced.tsx), and
30
+ // developer/parts the parts (Library.tsx PartsHome): developer/parts/editor the editor's, every
31
+ // one in every state (Parts.tsx), developer/parts/ui the theme's UI components, developer/parts/blocks the
32
+ // blocks, the standard ones and the apps', and developer/parts/list/<list> each kind of a list of kinds
33
+ // ("Promovering"), its own and the apps' (BlockParts.tsx), and developer/parts/values the
33
34
  // theme's design tokens, "Værdier" (Tokens.tsx)
34
35
  // block-settings the blocks that can be put in, "Blokindstillinger" (BlockSettings.tsx)
35
- // advanced "Avanceret", under "Indstillinger": the copy of the site's files in R2 (Advanced.tsx)
36
36
  // morpheme "Morpheme", under "Indstillinger": the CMS's version, a newer one and its notes, an update's progress (CmsPage.tsx)
37
37
  // licenses "Licenser", under "Indstillinger": the licences of what the site and the editor are made with, and
38
38
  // licenses/<id> one with its text (Licenses.tsx)
@@ -97,7 +97,7 @@ import { BlocksParts, ComponentParts, KindParts } from './BlockParts';
97
97
  import Tokens from './Tokens';
98
98
  import BrandForm from './BrandForm';
99
99
  import BlockSettings from './BlockSettings';
100
- import Advanced, { ADVANCED_ROUTE } from './Advanced';
100
+ import Advanced, { CACHING_ROUTE } from './Advanced';
101
101
  import CmsPage, { CMS_ROUTE } from './CmsPage';
102
102
  import Licenses, { LICENSES_ROUTE, LicensePage } from './Licenses';
103
103
  import { StoreThemePage } from './ThemeStore';
@@ -114,7 +114,7 @@ import {
114
114
  StoreAppPage,
115
115
  StorePage,
116
116
  } from './AppList';
117
- import { installedApps } from './apps';
117
+ import { activeApps, installedApps } from './apps';
118
118
  import {
119
119
  DEVELOPER_ROUTE,
120
120
  readApp,
@@ -142,6 +142,8 @@ import {
142
142
  Account,
143
143
  Blocks,
144
144
  Company,
145
+ DEV_MENU_ROUTE,
146
+ Developer,
145
147
  List,
146
148
  Lists,
147
149
  PartsHome,
@@ -624,7 +626,7 @@ function Editor() {
624
626
 
625
627
  // What the installed apps have to say (AppNotifications in apps.ts): asked when the editor opens and every 15 minutes
626
628
  // while it is open; each comes once, at the bottom and under "Notifikationer", while its type is on (notificationData.ts).
627
- const notifying = installedApps(files ?? [])
629
+ const notifying = activeApps(files ?? [])
628
630
  .filter((id) => apps.some((a) => a.id === id && a.notifications))
629
631
  .join();
630
632
  useEffect(() => {
@@ -784,7 +786,8 @@ function Page({ route, files, env, user, builtAt, onLogout }: PageProps) {
784
786
  return <Colors env={env} files={files} fallback={route === FALLBACK_ROUTE} />;
785
787
  if (route === 'company/logo') return <BrandForm env={env} />;
786
788
  if (route === 'block-settings') return <BlockSettings env={env} files={files} />;
787
- if (route === ADVANCED_ROUTE) return <Advanced env={env} />;
789
+ if (route === DEV_MENU_ROUTE) return <Developer />;
790
+ if (route === CACHING_ROUTE) return <Advanced env={env} />;
788
791
  if (route === CMS_ROUTE) return <CmsPage />;
789
792
  if (route === LICENSES_ROUTE) return <Licenses />;
790
793
  if (route.startsWith(`${LICENSES_ROUTE}/`)) return <LicensePage key={route} id={route.slice(LICENSES_ROUTE.length + 1)} />;
@@ -807,14 +810,13 @@ function Page({ route, files, env, user, builtAt, onLogout }: PageProps) {
807
810
  const [, screenApp, screenId, ...deeper] = route.split('/');
808
811
  const ownScreen =
809
812
  route.startsWith('apps/') && !deeper.length && apps.find((a) => a.id === screenApp && screenId && a.screens?.[screenId]);
810
- if (ownScreen && installedApps(files).includes(ownScreen.id))
811
- return <AppScreenPage key={route} app={ownScreen} id={screenId} env={env} />;
812
- if (route === 'appearance/parts') return <PartsHome />;
813
- if (route === 'appearance/parts/editor') return <Parts env={env} />;
814
- if (route === 'appearance/parts/ui') return <ComponentParts />;
815
- if (route === 'appearance/parts/blocks') return <BlocksParts />;
816
- if (route.startsWith('appearance/parts/list/')) return <KindParts key={route} id={route.slice('appearance/parts/list/'.length)} />;
817
- if (route === 'appearance/parts/values') return <Tokens />;
813
+ if (ownScreen && activeApps(files).includes(ownScreen.id)) return <AppScreenPage key={route} app={ownScreen} id={screenId} env={env} />;
814
+ if (route === 'developer/parts') return <PartsHome />;
815
+ if (route === 'developer/parts/editor') return <Parts env={env} />;
816
+ if (route === 'developer/parts/ui') return <ComponentParts />;
817
+ if (route === 'developer/parts/blocks') return <BlocksParts />;
818
+ if (route.startsWith('developer/parts/list/')) return <KindParts key={route} id={route.slice('developer/parts/list/'.length)} />;
819
+ if (route === 'developer/parts/values') return <Tokens />;
818
820
  if (route.startsWith('deleted/')) return <Deleted id={route.slice('deleted/'.length)} files={files} env={env} />;
819
821
  // company/<part>, or company/<part>/<its part> (Part.parts).
820
822
  const [, companyId, ownId, ...more] = route.split('/');
package/src/AppList.tsx CHANGED
@@ -1,11 +1,12 @@
1
1
  // "Indstillinger" › "Apps" (#apps): the apps installed (src/apps/, apps.ts: the site's own and those from the app store,
2
2
  // with one from the store not yet built as "Installeres…"), each with who made it under its name and, from the store,
3
- // that it has a newer version, with search (by name, who made it and what it does), the order (A–Å, Å–A, kept in this
3
+ // that it has a newer version or is turned off (liveStatus, also in "Appstore"), with search (by name, who made it and what it does), the order (A–Å, Å–A, kept in this
4
4
  // browser) and headings by the first letter, as the lists under "Indhold" have. "Indstillinger" › "Appstore"
5
5
  // (#settings/appstore): all apps, those in the app store (store.ts) and the site's own, installed or not, with search (by name, what they
6
6
  // do, who made them and the words they are found by), the same order and a funnel by category (only apps: the themes are in "Theme store", ThemeStoreScreen.tsx; the search row and the
7
7
  // store notices both screens share are StoreSearchRow.tsx, StoreStatus.tsx and storeSort.tsx). An app's page
8
- // (#apps/<app>) is the same for every app and without examples: its name, who made it, whether it is installed, its
8
+ // (#apps/<app>) is the same for every app and without examples: its name, who made it, whether it is installed (or turned
9
+ // off, with the switch "Aktiveret" first on the Settings tab), its
9
10
  // version (from the store) and what it does, "Installer" (or "Opdater til …"); installed, it has two tabs: "Indstillinger"
10
11
  // (#apps/<app>: its settings form, saved with "Gem ændringer" in their file, config.apps.settings, also on the screen
11
12
  // under "Indstillinger" with its kind, "Analytics" or "Promovering"; AppFormPage.tsx; then what it shows itself, what it
@@ -32,7 +33,8 @@ import { ConflictError, type Change, type RepoFile } from './github';
32
33
  import { cookieChanges, inCookieList } from './cookieList';
33
34
  import type { Env } from './App';
34
35
  import { ask, choose } from './ask';
35
- import { installedApps, settingsFile, type SiteApp } from './apps';
36
+ import { appsState, installedApps, settingsFile, type SiteApp } from './apps';
37
+ import { appsFileText, withInstalled, withOff } from '../lib/appsFile.mjs';
36
38
  import { AnyIcon } from './icon';
37
39
  import {
38
40
  appCategories,
@@ -59,7 +61,7 @@ import { config } from '@site/editor';
59
61
  import { allThemes, ThemeRow, useThemeCatalog } from './ThemeStore';
60
62
  import { siteT, siteText, t } from './i18n';
61
63
  import { OwnerLicenses, StoreLicenseRows } from './Licenses';
62
- import { StoreFooter, StoreNotice, StoreRound, useStoreConnected, useStoreKey } from './StoreStatus';
64
+ import { StoreNotice, StoreRound, useStoreConnected, useStoreKey } from './StoreStatus';
63
65
  import { StoreSearchRow, useStateFilter } from './StoreSearchRow';
64
66
  import { sortChoice, useSort } from './storeSort';
65
67
  import { told } from './notificationData';
@@ -185,6 +187,10 @@ export function kindsOf(app: SiteApp) {
185
187
 
186
188
  const statusOf = (installed: boolean) => (installed ? t.apps.installed : t.apps.notInstalled);
187
189
 
190
+ /** What an installed app's row and page head say instead of "Installed": "Deaktiveret" while it is turned off, else "Opdatering
191
+ * findes" when it has a newer version; undefined when neither. */
192
+ const liveStatus = (off: boolean, update: boolean) => (off ? t.apps.deactivated : update ? t.apps.updateFound : undefined);
193
+
188
194
  /** The store's catalog (store.ts) for a screen: null while it is read, 'failed' when it could not be; `skip`: not read
189
195
  * (the page of one of the site's own apps). */
190
196
  function useCatalog(env: Env, skip = false): ShownApp[] | null | 'failed' {
@@ -219,6 +225,7 @@ const storeIcon = (name?: string) => <LeadingIcon>{name && <AnyIcon name={name}
219
225
 
220
226
  export function Apps({ env, files }: { env: Env; files: RepoFile[] }) {
221
227
  const installed = installedApps(files);
228
+ const { off } = appsState(files);
222
229
  const catalog = useCatalog(env);
223
230
  const store = Array.isArray(catalog) ? catalog : [];
224
231
  const [query, setQuery] = useKept('apps-search', '');
@@ -236,7 +243,7 @@ export function Apps({ env, files }: { env: Env; files: RepoFile[] }) {
236
243
  publisher: a.publisher,
237
244
  hint: a.hint,
238
245
  icon: <LeadingIcon icon={a.icon} />,
239
- status: updateOf(a, catalog) ? t.apps.updateFound : '',
246
+ status: liveStatus(off.includes(a.id), !!updateOf(a, catalog)) ?? '',
240
247
  })),
241
248
  ...installed
242
249
  .filter((id) => !apps.some((a) => a.id === id))
@@ -320,14 +327,14 @@ const developerHref = (name: string) => `#${DEVELOPER_ROUTE}/${slugify(name)}`;
320
327
 
321
328
  /** An app's row in "Appstore" and on a developer's page: its icon, its name, what it does, and whether it is installed,
322
329
  * opening its page. */
323
- function AppRow({ app, installed }: { app: ReturnType<typeof allApps>[number]; installed: boolean }) {
330
+ function AppRow({ app, installed, off }: { app: ReturnType<typeof allApps>[number]; installed: boolean; off: boolean }) {
324
331
  return (
325
332
  <ListItem
326
333
  href={`#apps/${app.id}`}
327
334
  leading={app.glyph}
328
335
  headline={app.label}
329
336
  supporting={app.hint}
330
- count={installed && t.apps.installed}
337
+ count={installed && (liveStatus(off, false) ?? t.apps.installed)}
331
338
  arrow
332
339
  />
333
340
  );
@@ -337,6 +344,7 @@ function AppRow({ app, installed }: { app: ReturnType<typeof allApps>[number]; i
337
344
  * own), each opening its page. */
338
345
  export function DeveloperPage({ slug, env, files }: { slug: string; env: Env; files: RepoFile[] }) {
339
346
  const installed = installedApps(files);
347
+ const { off } = appsState(files);
340
348
  const catalog = useCatalog(env);
341
349
  const themeCatalog = useThemeCatalog(env);
342
350
  const theirs = allApps(catalog)
@@ -364,7 +372,7 @@ export function DeveloperPage({ slug, env, files }: { slug: string; env: Env; fi
364
372
  {theirs.length > 0 && (
365
373
  <Group title={t.apps.developerApps}>
366
374
  {theirs.map((a) => (
367
- <AppRow key={a.id} app={a} installed={installed.includes(a.id)} />
375
+ <AppRow key={a.id} app={a} installed={installed.includes(a.id)} off={off.includes(a.id)} />
368
376
  ))}
369
377
  </Group>
370
378
  )}
@@ -404,6 +412,7 @@ export function StorePage({ env, files }: { env: Env; files: RepoFile[] }) {
404
412
 
405
413
  function StoreScreen({ env, files, again }: { env: Env; files: RepoFile[]; again: () => void }) {
406
414
  const installed = installedApps(files);
415
+ const { off } = appsState(files);
407
416
  const key = useStoreKey();
408
417
  const catalog = useCatalog(env);
409
418
  const connected = useStoreConnected(env);
@@ -449,12 +458,11 @@ function StoreScreen({ env, files, again }: { env: Env; files: RepoFile[]; again
449
458
  appGroups.map((g) => (
450
459
  <Group key={g.key ?? 'all'} title={g.key ?? undefined}>
451
460
  {g.items.map((a) => (
452
- <AppRow key={a.id} app={a} installed={installed.includes(a.id)} />
461
+ <AppRow key={a.id} app={a} installed={installed.includes(a.id)} off={off.includes(a.id)} />
453
462
  ))}
454
463
  </Group>
455
464
  ))
456
465
  )}
457
- <StoreFooter keyInfo={key} again={again} />
458
466
  </Screen>
459
467
  );
460
468
  }
@@ -517,7 +525,7 @@ export async function autoUpdate(env: Env, files: RepoFile[]) {
517
525
  }
518
526
  if (changedFiles(app.id, record, current).length) continue;
519
527
  const wanted = { files: await env.store.files(next), record: recordOf(next) };
520
- const changes = [...appChanges(app.id, current, wanted, installed, file), ...cookieChanges(app.id, cookiesIn(wanted.files), files)];
528
+ const changes = [...appChanges(app.id, current, wanted, file), ...cookieChanges(app.id, cookiesIn(wanted.files), files)];
521
529
  const change = t.app.changes.updated(kindAndName(t.app.changes.app, next.label), next.version);
522
530
  await saveApp(env, siteT.apps.commit.update(next.written, next.version), change, changes, file);
523
531
  updated.set(app.id, next.version);
@@ -542,7 +550,6 @@ function useStoreActions(env: Env, files: RepoFile[]) {
542
550
  // Which action runs, on which app; `asking` while a dialog waits for the user (busyAction.mjs shows only the pressed button).
543
551
  const [running, setRunning] = useState<{ id: string; action: StoreAction; asking: boolean } | null>(null);
544
552
  const saving = !!running;
545
- const installed = installedApps(files);
546
553
  const file = files.find((f) => f.path === config.apps.installed);
547
554
 
548
555
  async function change(
@@ -566,7 +573,7 @@ function useStoreActions(env: Env, files: RepoFile[]) {
566
573
  setRunning({ id, action, asking: false });
567
574
  env.notify({ text: text.busy });
568
575
  const cookies = cookieChanges(id, wanted ? cookiesIn(wanted.files) : null, files);
569
- await saveApp(env, text.commit, text.change, [...appChanges(id, current, wanted, installed, file), ...cookies], file);
576
+ await saveApp(env, text.commit, text.change, [...appChanges(id, current, wanted, file), ...cookies], file);
570
577
  env.notify({ text: text.done, kind: text.kind ?? 'saved' });
571
578
  return true;
572
579
  } catch (e) {
@@ -854,7 +861,7 @@ export function AppScreenPage({ app, id, env }: { app: SiteApp; id: string; env:
854
861
  * not installed, with the pictures, what it needs, its cookies, who made it and where it is used). */
855
862
  function AppContent({ app, env, files, tab, fields }: AppProps & { tab: AppTab; fields?: ReactNode }) {
856
863
  const notify = env.notify;
857
- const [toggling, setToggling] = useState<'install' | 'uninstall' | null>(null);
864
+ const [toggling, setToggling] = useState<'install' | 'uninstall' | 'switch' | null>(null);
858
865
  const store = useStoreActions(env, files);
859
866
  const saving = !!toggling || store.saving;
860
867
  const catalog = useCatalog(env);
@@ -863,6 +870,7 @@ function AppContent({ app, env, files, tab, fields }: AppProps & { tab: AppTab;
863
870
  const inStore = Array.isArray(catalog) ? catalog.find((a) => a.id === app.id) : undefined;
864
871
  const installed = installedApps(files);
865
872
  const on = installed.includes(app.id);
873
+ const off = on && appsState(files).off.includes(app.id);
866
874
  // Where it is used: while it is, it cannot be uninstalled.
867
875
  const uses = on ? usesOf(app, files) : [];
868
876
  const stuck = uses.length > 0;
@@ -874,8 +882,7 @@ function AppContent({ app, env, files, tab, fields }: AppProps & { tab: AppTab;
874
882
  if (!yes && !(await ask(t.apps.askUninstall(app.label), t.apps.uninstall))) return;
875
883
  if (!yes && app.store) return store.uninstall(app.id, app.label, asWritten(app).label);
876
884
  const file = files.find((f) => f.path === config.apps.installed);
877
- const next = installed.filter((id) => id !== app.id).concat(yes ? [app.id] : []);
878
- const text = `${JSON.stringify({ installed: [...new Set(next)].sort() }, null, 2)}\n`;
885
+ const text = appsFileText(withInstalled(appsState(files), app.id, yes));
879
886
  if (text === file?.text) return;
880
887
  setToggling(yes ? 'install' : 'uninstall');
881
888
  notify({ text: yes ? t.apps.installing : t.apps.uninstalling });
@@ -895,14 +902,32 @@ function AppContent({ app, env, files, tab, fields }: AppProps & { tab: AppTab;
895
902
  }
896
903
  }
897
904
 
905
+ // Turned on or off, saved at once in its own commit: the app stays installed with its folder, settings and version.
906
+ async function turn(enabled: boolean) {
907
+ const file = files.find((f) => f.path === config.apps.installed);
908
+ const text = appsFileText(withOff(appsState(files), app.id, !enabled));
909
+ if (text === file?.text) return;
910
+ setToggling('switch');
911
+ try {
912
+ const change = t.app.changes[enabled ? 'turnedOn' : 'turnedOff'](kindAndName(t.app.changes.app, app.label));
913
+ const content = { path: config.apps.installed, content: text, oid: file?.oid || null };
914
+ await saveApp(env, siteT.apps.commit[enabled ? 'turnOn' : 'turnOff'](asWritten(app).label), change, [content], file);
915
+ notify({ text: change, kind: 'saved' });
916
+ } catch (e) {
917
+ notify({ text: e instanceof ConflictError ? e.message : t.common.notSaved((e as Error).message), error: true, kind: 'failed' });
918
+ } finally {
919
+ setToggling(null);
920
+ }
921
+ }
922
+
898
923
  return (
899
924
  <div>
900
925
  <AppHead
901
926
  icon={<LeadingIcon icon={app.icon} selected={on} />}
902
927
  label={app.label}
903
928
  publisher={app.publisher}
904
- status={on && update ? t.apps.updateFound : statusOf(on)}
905
- version={app.store && versionOf(app)}
929
+ status={(on && liveStatus(off, !!update)) || statusOf(on)}
930
+ version={versionOf(app) || app.version}
906
931
  hint={app.hint}
907
932
  />
908
933
  {(!on || (update && app.store)) && (
@@ -926,6 +951,8 @@ function AppContent({ app, env, files, tab, fields }: AppProps & { tab: AppTab;
926
951
  env={env}
927
952
  files={files}
928
953
  busy={saving}
954
+ enabled={!off}
955
+ onEnabled={turn}
929
956
  uninstalling={toggling === 'uninstall' || store.busy(app.id, 'uninstall')}
930
957
  stuck={stuck}
931
958
  onUninstall={() => install(false)}
@@ -946,7 +973,7 @@ function AppContent({ app, env, files, tab, fields }: AppProps & { tab: AppTab;
946
973
  id={`app/${app.id}`}
947
974
  name={app.label}
948
975
  author={app.publisher}
949
- version={app.store && versionOf(app)}
976
+ version={versionOf(app) || app.version}
950
977
  declared={app}
951
978
  />
952
979
  }