@canonical/summon-application 0.47.0 → 0.49.0-experimental.0

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 (217) hide show
  1. package/README.md +35 -4
  2. package/dist/esm/application/react/index.js +28 -1
  3. package/dist/esm/application/react/index.js.map +1 -1
  4. package/dist/esm/application/react/templates/README.md.ejs +5 -0
  5. package/dist/esm/application/react/templates/src/domains/catalog/ProductCard.tsx.ejs +2 -2
  6. package/dist/esm/application/react/templates/src/domains/dashboard/InstancesPage.tsx.ejs +1 -1
  7. package/dist/esm/application/react/templates/src/domains/dashboard/OverviewPage.tsx.ejs +6 -6
  8. package/dist/esm/application/react/templates/src/i18n/ar.ts.ejs +1 -0
  9. package/dist/esm/application/react/templates/src/i18n/config.ts +2 -2
  10. package/dist/esm/application/react/templates/src/i18n/en.ts.ejs +1 -0
  11. package/dist/esm/application/react/templates/src/i18n/fr.ts.ejs +1 -0
  12. package/dist/esm/application/react/templates/src/i18n/negotiation.test.ts +5 -5
  13. package/dist/esm/application/react/templates/src/lib/LocaleSelector/LocaleSelector.test.tsx +10 -0
  14. package/dist/esm/application/react/templates/src/lib/LocaleSelector/LocaleSelector.tsx.ejs +35 -21
  15. package/dist/esm/application/react/templates/src/lib/ThemeSelector/ServerThemeContext.ts +13 -0
  16. package/dist/esm/application/react/templates/src/lib/ThemeSelector/ThemeSelector.ssr.test.tsx.ejs +45 -0
  17. package/dist/esm/application/react/templates/src/lib/ThemeSelector/ThemeSelector.test.tsx.ejs +67 -0
  18. package/dist/esm/application/react/templates/src/lib/ThemeSelector/ThemeSelector.tsx.ejs +60 -26
  19. package/dist/esm/application/react/templates/src/lib/ThemeSelector/index.ts.ejs +4 -0
  20. package/dist/esm/application/react/templates/src/lib/TopBar/TopBar.test.tsx.ejs +7 -10
  21. package/dist/esm/application/react/templates/src/lib/TopBar/styles.css +8 -3
  22. package/dist/esm/application/react/templates/src/server/entry.tsx.ejs +23 -14
  23. package/dist/esm/application/react/templates/src/server/handlePreferenceForm.test.ts.ejs +63 -0
  24. package/dist/esm/application/react/templates/src/server/handlePreferenceForm.ts.ejs +158 -0
  25. package/dist/esm/application/react/templates/src/server/preferenceFormMiddleware.ts +42 -0
  26. package/dist/esm/application/react/templates/src/server/preview.bun.ts +5 -0
  27. package/dist/esm/application/react/templates/src/server/preview.express.ts +4 -0
  28. package/dist/esm/application/react/templates/src/server/resolveReturnTo.ts +18 -0
  29. package/dist/esm/application/react/templates/src/server/server.bun.ts.ejs +5 -0
  30. package/dist/esm/application/react/templates/src/server/server.express.ts.ejs +4 -0
  31. package/dist/esm/application/react/templates/test/e2e/servers.e2e.ts.ejs +56 -0
  32. package/dist/esm/application/react/templates/vitest.config.ts +4 -0
  33. package/dist/esm/application/svelte/index.js +337 -0
  34. package/dist/esm/application/svelte/index.js.map +1 -0
  35. package/dist/esm/application/svelte/templates/.storybook/main.ts +3 -0
  36. package/dist/esm/application/svelte/templates/.storybook/preview.ts.ejs +21 -0
  37. package/dist/esm/application/svelte/templates/README.md.ejs +168 -0
  38. package/dist/esm/application/svelte/templates/biome.json.ejs +12 -0
  39. package/dist/esm/application/svelte/templates/gitignore.ejs +7 -0
  40. package/dist/esm/application/svelte/templates/package.json.ejs +76 -0
  41. package/dist/esm/application/svelte/templates/scripts/copy-icons.js +10 -0
  42. package/dist/esm/application/svelte/templates/src/app.d.ts.ejs +14 -0
  43. package/dist/esm/application/svelte/templates/src/app.html.ejs +19 -0
  44. package/dist/esm/application/svelte/templates/src/domains/account/AccountPage.svelte.ejs +18 -0
  45. package/dist/esm/application/svelte/templates/src/domains/account/LoginPage.svelte.ejs +32 -0
  46. package/dist/esm/application/svelte/templates/src/domains/account/getAuthRedirect.test.ts +18 -0
  47. package/dist/esm/application/svelte/templates/src/domains/account/getAuthRedirect.ts +18 -0
  48. package/dist/esm/application/svelte/templates/src/domains/account/guardAccount.ts +15 -0
  49. package/dist/esm/application/svelte/templates/src/domains/catalog/CatalogPage.svelte.ejs +35 -0
  50. package/dist/esm/application/svelte/templates/src/domains/catalog/ProductCard.svelte.ejs +51 -0
  51. package/dist/esm/application/svelte/templates/src/domains/catalog/ProductList.stories.svelte.ejs +110 -0
  52. package/dist/esm/application/svelte/templates/src/domains/catalog/ProductList.svelte.ejs +41 -0
  53. package/dist/esm/application/svelte/templates/src/domains/catalog/constants.ts +2 -0
  54. package/dist/esm/application/svelte/templates/src/domains/catalog/data.test.ts +19 -0
  55. package/dist/esm/application/svelte/templates/src/domains/catalog/data.ts +75 -0
  56. package/dist/esm/application/svelte/templates/src/domains/catalog/loadCatalog.ts +7 -0
  57. package/dist/esm/application/svelte/templates/src/domains/catalog/types.ts +25 -0
  58. package/dist/esm/application/svelte/templates/src/domains/contact/ContactPage.svelte.ejs +86 -0
  59. package/dist/esm/application/svelte/templates/src/domains/contact/types.ts.ejs +19 -0
  60. package/dist/esm/application/svelte/templates/src/domains/contact/validateContact.test.ts.ejs +31 -0
  61. package/dist/esm/application/svelte/templates/src/domains/contact/validateContact.ts.ejs +28 -0
  62. package/dist/esm/application/svelte/templates/src/domains/dashboard/DashboardBreadcrumbs.svelte.ejs +29 -0
  63. package/dist/esm/application/svelte/templates/src/domains/dashboard/DashboardLayout.svelte.ejs +35 -0
  64. package/dist/esm/application/svelte/templates/src/domains/dashboard/InstancesPage.svelte.ejs +245 -0
  65. package/dist/esm/application/svelte/templates/src/domains/dashboard/OverviewPage.svelte.ejs +180 -0
  66. package/dist/esm/application/svelte/templates/src/domains/dashboard/SettingsPage.svelte.ejs +103 -0
  67. package/dist/esm/application/svelte/templates/src/domains/dashboard/constants.ts.ejs +253 -0
  68. package/dist/esm/application/svelte/templates/src/domains/dashboard/createDashboardNavigation.ts.ejs +103 -0
  69. package/dist/esm/application/svelte/templates/src/domains/dashboard/createInstance.test.ts +22 -0
  70. package/dist/esm/application/svelte/templates/src/domains/dashboard/createInstance.ts +28 -0
  71. package/dist/esm/application/svelte/templates/src/domains/dashboard/projectBreadcrumbs.test.ts +78 -0
  72. package/dist/esm/application/svelte/templates/src/domains/dashboard/projectBreadcrumbs.ts +47 -0
  73. package/dist/esm/application/svelte/templates/src/domains/dashboard/selectRelativeTime.test.ts +19 -0
  74. package/dist/esm/application/svelte/templates/src/domains/dashboard/selectRelativeTime.ts +24 -0
  75. package/dist/esm/application/svelte/templates/src/domains/dashboard/styles.css +98 -0
  76. package/dist/esm/application/svelte/templates/src/domains/dashboard/types.ts.ejs +61 -0
  77. package/dist/esm/application/svelte/templates/src/domains/marketing/GuidePage.svelte.ejs +29 -0
  78. package/dist/esm/application/svelte/templates/src/domains/marketing/HomePage.svelte.ejs +47 -0
  79. package/dist/esm/application/svelte/templates/src/domains/marketing/isGuideSlug.ts +8 -0
  80. package/dist/esm/application/svelte/templates/src/formatDocumentTitle.ts.ejs +9 -0
  81. package/dist/esm/application/svelte/templates/src/hooks.server.ts.ejs +51 -0
  82. package/dist/esm/application/svelte/templates/src/i18n/ar.ts.ejs +174 -0
  83. package/dist/esm/application/svelte/templates/src/i18n/catalogs.ts +14 -0
  84. package/dist/esm/application/svelte/templates/src/i18n/config.ts +19 -0
  85. package/dist/esm/application/svelte/templates/src/i18n/en.ts.ejs +173 -0
  86. package/dist/esm/application/svelte/templates/src/i18n/fr.ts.ejs +171 -0
  87. package/dist/esm/application/svelte/templates/src/i18n/index.ts +45 -0
  88. package/dist/esm/application/svelte/templates/src/i18n/negotiation.test.ts +92 -0
  89. package/dist/esm/application/svelte/templates/src/layouts/ErrorPage.svelte.ejs +40 -0
  90. package/dist/esm/application/svelte/templates/src/layouts/PublicLayout.svelte +18 -0
  91. package/dist/esm/application/svelte/templates/src/layouts/RootLayout.svelte.ejs +43 -0
  92. package/dist/esm/application/svelte/templates/src/layouts/TopBarLayout.svelte +28 -0
  93. package/dist/esm/application/svelte/templates/src/lib/ApplicationShell/ApplicationShell.stories.svelte +87 -0
  94. package/dist/esm/application/svelte/templates/src/lib/ApplicationShell/ApplicationShell.svelte.ejs +60 -0
  95. package/dist/esm/application/svelte/templates/src/lib/ApplicationShell/index.ts +2 -0
  96. package/dist/esm/application/svelte/templates/src/lib/ApplicationShell/styles.css +43 -0
  97. package/dist/esm/application/svelte/templates/src/lib/ApplicationShell/types.ts +23 -0
  98. package/dist/esm/application/svelte/templates/src/lib/CanonicalLogo/CanonicalLogo.svelte.ejs +27 -0
  99. package/dist/esm/application/svelte/templates/src/lib/CanonicalLogo/index.ts +2 -0
  100. package/dist/esm/application/svelte/templates/src/lib/CanonicalLogo/styles.css +31 -0
  101. package/dist/esm/application/svelte/templates/src/lib/CanonicalLogo/types.ts +15 -0
  102. package/dist/esm/application/svelte/templates/src/lib/CodeMessage/CodeMessage.svelte +18 -0
  103. package/dist/esm/application/svelte/templates/src/lib/CodeMessage/index.ts +2 -0
  104. package/dist/esm/application/svelte/templates/src/lib/CodeMessage/types.ts +14 -0
  105. package/dist/esm/application/svelte/templates/src/lib/ExampleComponent/ExampleComponent.stories.svelte +15 -0
  106. package/dist/esm/application/svelte/templates/src/lib/ExampleComponent/ExampleComponent.svelte +17 -0
  107. package/dist/esm/application/svelte/templates/src/lib/ExampleComponent/index.ts +2 -0
  108. package/dist/esm/application/svelte/templates/src/lib/ExampleComponent/styles.css +17 -0
  109. package/dist/esm/application/svelte/templates/src/lib/ExampleComponent/types.ts +10 -0
  110. package/dist/esm/application/svelte/templates/src/lib/Icon/Icon.svelte +16 -0
  111. package/dist/esm/application/svelte/templates/src/lib/Icon/index.ts +2 -0
  112. package/dist/esm/application/svelte/templates/src/lib/Icon/types.ts +10 -0
  113. package/dist/esm/application/svelte/templates/src/lib/LazyComponent/LazyComponent.stories.svelte +19 -0
  114. package/dist/esm/application/svelte/templates/src/lib/LazyComponent/LazyComponent.svelte.ejs +29 -0
  115. package/dist/esm/application/svelte/templates/src/lib/LazyComponent/createDelayedData.ts.ejs +24 -0
  116. package/dist/esm/application/svelte/templates/src/lib/LazyComponent/index.ts +2 -0
  117. package/dist/esm/application/svelte/templates/src/lib/LazyComponent/types.ts.ejs +19 -0
  118. package/dist/esm/application/svelte/templates/src/lib/LocaleSelector/LocaleSelector.svelte.ejs +50 -0
  119. package/dist/esm/application/svelte/templates/src/lib/LocaleSelector/index.ts +2 -0
  120. package/dist/esm/application/svelte/templates/src/lib/LocaleSelector/types.ts +7 -0
  121. package/dist/esm/application/svelte/templates/src/lib/Navigation/Navigation.svelte.ejs +42 -0
  122. package/dist/esm/application/svelte/templates/src/lib/Navigation/index.ts +2 -0
  123. package/dist/esm/application/svelte/templates/src/lib/Navigation/types.ts +14 -0
  124. package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/ThemeSelector.svelte.ejs +38 -0
  125. package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/constants.ts +8 -0
  126. package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/index.ts +5 -0
  127. package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/readTheme.test.ts +13 -0
  128. package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/readTheme.ts +15 -0
  129. package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/setTheme.ts +27 -0
  130. package/dist/esm/application/svelte/templates/src/lib/ThemeSelector/types.ts +18 -0
  131. package/dist/esm/application/svelte/templates/src/lib/TopBar/TopBar.stories.svelte.ejs +24 -0
  132. package/dist/esm/application/svelte/templates/src/lib/TopBar/TopBar.svelte.ejs +32 -0
  133. package/dist/esm/application/svelte/templates/src/lib/TopBar/index.ts +2 -0
  134. package/dist/esm/application/svelte/templates/src/lib/TopBar/styles.css +54 -0
  135. package/dist/esm/application/svelte/templates/src/lib/TopBar/types.ts +15 -0
  136. package/dist/esm/application/svelte/templates/src/lib/index.ts.ejs +16 -0
  137. package/dist/esm/application/svelte/templates/src/params/guide.ts +5 -0
  138. package/dist/esm/application/svelte/templates/src/resolveReturnTo.test.ts +27 -0
  139. package/dist/esm/application/svelte/templates/src/resolveReturnTo.ts +13 -0
  140. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/+layout.svelte +8 -0
  141. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/+page.server.ts +6 -0
  142. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/+page.svelte +8 -0
  143. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/+page.ts +6 -0
  144. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/account/+page.svelte +5 -0
  145. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/account/+page.ts +4 -0
  146. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/catalog/+page.svelte +8 -0
  147. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/catalog/+page.ts +4 -0
  148. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/contact/+page.server.ts +25 -0
  149. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/contact/+page.svelte.ejs +30 -0
  150. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/guides/[slug=guide]/+page.svelte +6 -0
  151. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/(public)/login/+page.svelte +6 -0
  152. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/+layout.svelte +9 -0
  153. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/dashboard/+layout.svelte +9 -0
  154. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/dashboard/+page.svelte +5 -0
  155. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/dashboard/instances/+page.server.ts.ejs +28 -0
  156. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/dashboard/instances/+page.svelte.ejs +19 -0
  157. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/dashboard/settings/+page.server.ts +9 -0
  158. package/dist/esm/application/svelte/templates/src/routes/(top-bar)/dashboard/settings/+page.svelte +5 -0
  159. package/dist/esm/application/svelte/templates/src/routes/+error.svelte +6 -0
  160. package/dist/esm/application/svelte/templates/src/routes/+layout.server.ts.ejs +8 -0
  161. package/dist/esm/application/svelte/templates/src/routes/+layout.svelte.ejs +21 -0
  162. package/dist/esm/application/svelte/templates/src/routes/+layout.ts.ejs +30 -0
  163. package/dist/esm/application/svelte/templates/src/routes/home/+page.ts +4 -0
  164. package/dist/esm/application/svelte/templates/src/routes/home/+server.ts +3 -0
  165. package/dist/esm/application/svelte/templates/src/routes/icons/[icon]/+server.ts +37 -0
  166. package/dist/esm/application/svelte/templates/src/routes/language/+server.ts +30 -0
  167. package/dist/esm/application/svelte/templates/src/routes/preferences/+server.ts +32 -0
  168. package/dist/esm/application/svelte/templates/src/routes/sitemap.xml/+server.ts.ejs +47 -0
  169. package/dist/esm/application/svelte/templates/src/storybook/I18nDecorator.svelte +28 -0
  170. package/dist/esm/application/svelte/templates/src/storybook/decorators.ts +12 -0
  171. package/dist/esm/application/svelte/templates/src/styles/app.css +38 -0
  172. package/dist/esm/application/svelte/templates/src/styles/index.css.ejs +25 -0
  173. package/dist/esm/application/svelte/templates/src/styles/standins/Card.css +198 -0
  174. package/dist/esm/application/svelte/templates/src/styles/standins/Icon.css +32 -0
  175. package/dist/esm/application/svelte/templates/src/styles/standins/InlineCode.css +30 -0
  176. package/dist/esm/application/svelte/templates/src/styles/standins/SidePanel.css +462 -0
  177. package/dist/esm/application/svelte/templates/src/styles/standins/Tile.css +108 -0
  178. package/dist/esm/application/svelte/templates/src/styles/standins/Timeline.css +171 -0
  179. package/dist/esm/application/svelte/templates/src/styles/standins.css.ejs +17 -0
  180. package/dist/esm/application/svelte/templates/svelte.config.js.ejs +17 -0
  181. package/dist/esm/application/svelte/templates/test/app.test.js.ejs +758 -0
  182. package/dist/esm/application/svelte/templates/test/spa.test.js.ejs +224 -0
  183. package/dist/esm/application/svelte/templates/tsconfig.json +15 -0
  184. package/dist/esm/application/svelte/templates/vite.config.ts +4 -0
  185. package/dist/esm/application/svelte/templates/vitest.config.ts +10 -0
  186. package/dist/esm/application/svelte/textHelpers.js +20 -0
  187. package/dist/esm/application/svelte/textHelpers.js.map +1 -0
  188. package/dist/esm/domain/index.js +39 -5
  189. package/dist/esm/domain/index.js.map +1 -1
  190. package/dist/esm/domain/templates/Page.svelte.ejs +2 -0
  191. package/dist/esm/index.js +2 -0
  192. package/dist/esm/index.js.map +1 -1
  193. package/dist/esm/page/index.js +44 -7
  194. package/dist/esm/page/index.js.map +1 -1
  195. package/dist/esm/page/templates/Page.svelte.ejs +2 -0
  196. package/dist/esm/shared/versions.js +10 -8
  197. package/dist/esm/shared/versions.js.map +1 -1
  198. package/dist/esm/wrapper/index.js +38 -5
  199. package/dist/esm/wrapper/index.js.map +1 -1
  200. package/dist/esm/wrapper/templates/Layout.svelte.ejs +5 -0
  201. package/dist/types/application/react/index.d.ts.map +1 -1
  202. package/dist/types/application/svelte/index.d.ts +12 -0
  203. package/dist/types/application/svelte/index.d.ts.map +1 -0
  204. package/dist/types/application/svelte/textHelpers.d.ts +21 -0
  205. package/dist/types/application/svelte/textHelpers.d.ts.map +1 -0
  206. package/dist/types/domain/index.d.ts +2 -1
  207. package/dist/types/domain/index.d.ts.map +1 -1
  208. package/dist/types/index.d.ts +1 -0
  209. package/dist/types/index.d.ts.map +1 -1
  210. package/dist/types/page/index.d.ts +1 -0
  211. package/dist/types/page/index.d.ts.map +1 -1
  212. package/dist/types/shared/versions.d.ts +11 -9
  213. package/dist/types/shared/versions.d.ts.map +1 -1
  214. package/dist/types/wrapper/index.d.ts +2 -1
  215. package/dist/types/wrapper/index.d.ts.map +1 -1
  216. package/package.json +8 -8
  217. package/dist/esm/application/react/templates/src/lib/ThemeSelector/index.ts +0 -1
@@ -0,0 +1,103 @@
1
+ <script lang="ts">
2
+ import { ContentLayout, ViewLayout } from "@canonical/svelte-ds-app";
3
+ import { Button, Modal } from "@canonical/svelte-ds-global";
4
+ <% if (forms) { -%>
5
+ import { Field, Form } from "@canonical/svelte-ds-global-form";
6
+ <% } -%>
7
+ import formatDocumentTitle from "../../formatDocumentTitle.js";
8
+ <% if (intl) { -%>
9
+ import { createAppTranslator, getLocaleSource } from "../../i18n/index.js";
10
+ <% } -%>
11
+ import { Icon } from "../../lib/index.js";
12
+ <% if (forms) { -%>
13
+ import {
14
+ BRIDGE_OPTIONS,
15
+ PROJECT_NAME,
16
+ SETTINGS_DEFAULTS,
17
+ } from "./constants.js";
18
+ <% } else { -%>
19
+ import { PROJECT_NAME } from "./constants.js";
20
+ <% } -%>
21
+ import DashboardBreadcrumbs from "./DashboardBreadcrumbs.svelte";
22
+ import "./styles.css";
23
+ <% if (intl) { -%>
24
+
25
+ const locale = getLocaleSource();
26
+ const t = $derived(createAppTranslator($locale));
27
+ <% } -%>
28
+ <% if (forms) { -%>
29
+
30
+ /** Saving logs the settings; nothing is stored. */
31
+ function handleSave(event: SubmitEvent) {
32
+ event.preventDefault();
33
+ const form = event.currentTarget as HTMLFormElement;
34
+ console.log("Settings saved:", Object.fromEntries(new FormData(form)));
35
+ }
36
+ <% } -%>
37
+ </script>
38
+
39
+ <svelte:head><title>{formatDocumentTitle(<%- str("dashboard.settings.title", "Settings") %>)}</title></svelte:head>
40
+
41
+ {#snippet deleteIcon()}<Icon name="delete" />{/snippet}
42
+
43
+ <ViewLayout class="dashboard-view">
44
+ <ContentLayout>
45
+ <header class="titlebar">
46
+ <div>
47
+ <DashboardBreadcrumbs />
48
+ <h1><%- msg("dashboard.settings.heading", "Settings") %></h1>
49
+ </div>
50
+ </header>
51
+
52
+ <% if (forms) { -%>
53
+ <section aria-labelledby="project-title" class="section narrow">
54
+ <h2 id="project-title"><%- msg("dashboard.settings.project", "Project") %></h2>
55
+ <Form action="?/save" method="post" onsubmit={handleSave}>
56
+ <Field inputType="select" label=<%- attr("dashboard.settings.bridge", "Default bridge") %> name="bridge" options={BRIDGE_OPTIONS} value={SETTINGS_DEFAULTS.bridge} />
57
+ <Field controlLabel=<%- attr("dashboard.settings.ipv6Control", "Enable IPv6 NAT") %> inputType="switch" isOptional label=<%- attr("dashboard.settings.ipv6", "IPv6") %> name="ipv6" value={SETTINGS_DEFAULTS.ipv6} />
58
+ <Field inputType="number" label=<%- attr("dashboard.settings.maxInstances", "Maximum instances") %> name="max_instances" value={SETTINGS_DEFAULTS.max_instances} />
59
+ <Field controlLabel=<%- attr("dashboard.settings.snapshotsControl", "Enabled") %> inputType="switch" isOptional label=<%- attr("dashboard.settings.snapshots", "Nightly snapshots") %> name="snapshots" value={SETTINGS_DEFAULTS.snapshots} />
60
+ <div class="actions">
61
+ <Button importance="primary" type="submit"><%- msg("dashboard.settings.save", "Save changes") %></Button>
62
+ </div>
63
+ </Form>
64
+ </section>
65
+ <% } -%>
66
+
67
+ <section aria-labelledby="danger-title" class="section narrow">
68
+ <h2 id="danger-title"><%- msg("dashboard.settings.danger", "Danger zone") %></h2>
69
+ <p class="muted"><%- msg("dashboard.settings.dangerBody", "These actions cannot be undone.") %></p>
70
+ <Modal closedby="any">
71
+ {#snippet trigger(triggerProps)}
72
+ <div class="actions">
73
+ <Button {...triggerProps} anticipation="destructive" icon={deleteIcon} importance="primary" type="button"><%- msg("dashboard.settings.delete", "Delete project") %></Button>
74
+ </div>
75
+ {/snippet}
76
+ {#snippet children(closeProps)}
77
+ <Modal.Header>
78
+ <%- msg("dashboard.settings.confirmTitle", "Delete project?") %>
79
+ {#snippet closeButton()}<Modal.Header.CloseButton aria-label=<%- attr("dashboard.close", "Close") %> />{/snippet}
80
+ </Modal.Header>
81
+ <Modal.Content>
82
+ <% if (intl) { -%>
83
+ <p>{t("dashboard.settings.confirmBody", { project: PROJECT_NAME })}</p>
84
+ <% } else { -%>
85
+ <p>{`This permanently deletes the ${PROJECT_NAME} project, its instances and their storage. This cannot be undone.`}</p>
86
+ <% } -%>
87
+ </Modal.Content>
88
+ <Modal.Footer>
89
+ <Button {...closeProps} importance="tertiary" type="button"><%- msg("dashboard.cancel", "Cancel") %></Button>
90
+ <Button {...closeProps} anticipation="destructive" icon={deleteIcon} importance="primary" type="button"><%- msg("dashboard.settings.delete", "Delete project") %></Button>
91
+ </Modal.Footer>
92
+ {/snippet}
93
+ </Modal>
94
+ </section>
95
+ </ContentLayout>
96
+ </ViewLayout>
97
+
98
+ <!-- @component
99
+ The project settings: a form prefilled with the current settings, and a danger
100
+ zone whose delete action asks for confirmation in a Modal. Saving logs the
101
+ values; without JavaScript the form posts to the page's action, and the Modal
102
+ opens and closes through invoker commands.
103
+ -->
@@ -0,0 +1,253 @@
1
+ <% if (intl) { -%>
2
+ import type { MessageKey } from "../../i18n/index.js";
3
+ <% } -%>
4
+ import type {
5
+ ActivityEvent,
6
+ Instance,
7
+ InstanceStatus,
8
+ Release,
9
+ } from "./types.js";
10
+
11
+ /*
12
+ <% if (intl) { -%>
13
+ * Sample data for the dashboard, modelled on LXD. Every word a reader sees is
14
+ * a catalog key, so the dashboard reads fully in each locale; what stays as is
15
+ * are names — instance and project names, people, product names, addresses —
16
+ * which are the same in every language.
17
+ <% } else { -%>
18
+ * Sample data for the dashboard, modelled on LXD.
19
+ <% } -%>
20
+ */
21
+
22
+ /** Where the side navigation's Help › Legal information item points. */
23
+ export const LEGAL_URL = "https://ubuntu.com/legal";
24
+
25
+ /** The project the dashboard shows, the first crumb of every page. */
26
+ export const PROJECT_NAME = "default";
27
+
28
+ /** The figures of the overview's status tiles; storage is in terabytes. */
29
+ export const OVERVIEW_FIGURES = {
30
+ running: 128,
31
+ stopped: 4,
32
+ storageUsedTb: 2.4,
33
+ storageTotalTb: 4,
34
+ alerts: 2,
35
+ } as const;
36
+
37
+ /** How the overview formats a size in terabytes: "2.4 TB"<% if (intl) { %>, "2,4 To"<% } %>. */
38
+ export const TERABYTES: Intl.NumberFormatOptions = {
39
+ style: "unit",
40
+ unit: "terabyte",
41
+ maximumFractionDigits: 1,
42
+ };
43
+
44
+ <% if (intl) { -%>
45
+ /** The catalog key of each instance status's label. */
46
+ export const STATUS_KEYS: Readonly<Record<InstanceStatus, MessageKey>> = {
47
+ running: "dashboard.status.running",
48
+ stopped: "dashboard.status.stopped",
49
+ starting: "dashboard.status.starting",
50
+ };
51
+ <% } else { -%>
52
+ /** Each instance status's label. */
53
+ export const STATUS_LABELS: Readonly<Record<InstanceStatus, string>> = {
54
+ running: "Running",
55
+ stopped: "Stopped",
56
+ starting: "Starting",
57
+ };
58
+ <% } -%>
59
+
60
+ export const INSTANCES: readonly Instance[] = [
61
+ {
62
+ name: "web-01",
63
+ status: "running",
64
+ release: "Ubuntu 24.04 LTS",
65
+ ipv4: "10.42.0.11",
66
+ memoryGib: 4,
67
+ },
68
+ {
69
+ name: "web-02",
70
+ status: "running",
71
+ release: "Ubuntu 24.04 LTS",
72
+ ipv4: "10.42.0.12",
73
+ memoryGib: 4,
74
+ },
75
+ {
76
+ name: "db-01",
77
+ status: "running",
78
+ release: "Ubuntu 22.04 LTS",
79
+ ipv4: "10.42.0.21",
80
+ memoryGib: 16,
81
+ },
82
+ {
83
+ name: "db-02",
84
+ status: "running",
85
+ release: "Ubuntu 22.04 LTS",
86
+ ipv4: "10.42.0.22",
87
+ memoryGib: 16,
88
+ },
89
+ {
90
+ name: "cache-01",
91
+ status: "stopped",
92
+ release: "Ubuntu 24.04 LTS",
93
+ ipv4: "",
94
+ memoryGib: 2,
95
+ },
96
+ {
97
+ name: "worker-01",
98
+ status: "running",
99
+ release: "Ubuntu 24.04 LTS",
100
+ ipv4: "10.42.0.41",
101
+ memoryGib: 8,
102
+ },
103
+ ];
104
+ <% if (forms) { -%>
105
+
106
+ /** The releases the create form offers, by value; labels are product names. */
107
+ export const RELEASE_OPTIONS = [
108
+ { value: "noble", label: "Ubuntu 24.04 LTS" },
109
+ { value: "jammy", label: "Ubuntu 22.04 LTS" },
110
+ { value: "focal", label: "Ubuntu 20.04 LTS" },
111
+ ];
112
+ <% } -%>
113
+
114
+ export const RELEASES: readonly Release[] = [
115
+ {
116
+ name: "Ubuntu 24.04 LTS",
117
+ <% if (intl) { -%>
118
+ summaryKey: "dashboard.releases.noble",
119
+ <% } else { -%>
120
+ summary:
121
+ "Noble Numbat. Five years of security updates, ten with Ubuntu Pro.",
122
+ <% } -%>
123
+ channel: "stable",
124
+ kernel: "6.8",
125
+ },
126
+ {
127
+ name: "Ubuntu 25.10",
128
+ <% if (intl) { -%>
129
+ summaryKey: "dashboard.releases.questing",
130
+ <% } else { -%>
131
+ summary: "Questing Quokka. Interim release with nine months of support.",
132
+ <% } -%>
133
+ channel: "beta",
134
+ kernel: "6.17",
135
+ },
136
+ ];
137
+
138
+ <% if (intl) { -%>
139
+ /** The catalog key of each release channel's label. */
140
+ export const CHANNEL_KEYS: Readonly<Record<Release["channel"], MessageKey>> = {
141
+ stable: "dashboard.releases.stable",
142
+ beta: "dashboard.releases.beta",
143
+ };
144
+ <% } else { -%>
145
+ /** Each release channel's label. */
146
+ export const CHANNEL_LABELS: Readonly<Record<Release["channel"], string>> = {
147
+ stable: "Stable",
148
+ beta: "Beta",
149
+ };
150
+ <% } -%>
151
+
152
+ <% if (intl) { -%>
153
+ export const ACTIVITY: readonly ActivityEvent[] = [
154
+ {
155
+ key: "start",
156
+ actor: { name: "Alice" },
157
+ minutesAgo: 2,
158
+ messageKey: "dashboard.activity.started",
159
+ values: { instance: "web-01" },
160
+ criticality: "success",
161
+ },
162
+ {
163
+ key: "snapshot",
164
+ actor: { key: "dashboard.activity.scheduler" },
165
+ minutesAgo: 14,
166
+ messageKey: "dashboard.activity.snapshot",
167
+ values: { snapshot: "nightly-2026-10-21" },
168
+ },
169
+ {
170
+ key: "disk",
171
+ actor: { key: "dashboard.activity.monitor" },
172
+ minutesAgo: 60,
173
+ messageKey: "dashboard.activity.disk",
174
+ values: { instance: "db-02", percent: "85" },
175
+ criticality: "warning",
176
+ },
177
+ {
178
+ key: "profile",
179
+ actor: { name: "Bob" },
180
+ minutesAgo: 24 * 60,
181
+ messageKey: "dashboard.activity.profile",
182
+ values: { profile: "gpu" },
183
+ },
184
+ {
185
+ key: "failed",
186
+ actor: { key: "dashboard.activity.monitor" },
187
+ minutesAgo: 2 * 24 * 60,
188
+ messageKey: "dashboard.activity.failed",
189
+ values: { instance: "cache-01" },
190
+ criticality: "error",
191
+ },
192
+ ];
193
+ <% } else { -%>
194
+ export const ACTIVITY: readonly ActivityEvent[] = [
195
+ {
196
+ key: "start",
197
+ actor: "Alice",
198
+ minutesAgo: 2,
199
+ message: "Started web-01",
200
+ criticality: "success",
201
+ },
202
+ {
203
+ key: "snapshot",
204
+ actor: "Scheduler",
205
+ minutesAgo: 14,
206
+ message: "Snapshot nightly-2026-10-21 taken",
207
+ },
208
+ {
209
+ key: "disk",
210
+ actor: "Monitor",
211
+ minutesAgo: 60,
212
+ message: "Disk on db-02 at 85%",
213
+ criticality: "warning",
214
+ },
215
+ {
216
+ key: "profile",
217
+ actor: "Bob",
218
+ minutesAgo: 24 * 60,
219
+ message: "Profile gpu updated",
220
+ },
221
+ {
222
+ key: "failed",
223
+ actor: "Monitor",
224
+ minutesAgo: 2 * 24 * 60,
225
+ message: "cache-01 failed to start",
226
+ criticality: "error",
227
+ },
228
+ ];
229
+ <% } -%>
230
+ <% if (forms) { -%>
231
+
232
+ /** The create form's prefilled values: a second web server on 24.04. */
233
+ export const CREATE_DEFAULTS = {
234
+ instance_name: "web-03",
235
+ release: "noble",
236
+ enable_pro: true,
237
+ cloud_init: "#cloud-config\npackages:\n - nginx",
238
+ } as const;
239
+
240
+ /** The project's current settings, prefilled into the settings form. */
241
+ export const SETTINGS_DEFAULTS = {
242
+ bridge: "lxdbr0",
243
+ ipv6: true,
244
+ max_instances: 50,
245
+ snapshots: true,
246
+ } as const;
247
+
248
+ /** The bridges the settings form offers. */
249
+ export const BRIDGE_OPTIONS = [
250
+ { value: "lxdbr0", label: "lxdbr0" },
251
+ { value: "ovn-1", label: "ovn-1" },
252
+ ];
253
+ <% } -%>
@@ -0,0 +1,103 @@
1
+ import {
2
+ createHelpItem,
3
+ type FooterRoot,
4
+ type NavRoot,
5
+ } from "@canonical/svelte-ds-app";
6
+ <% if (intl) { -%>
7
+ import type { MessageKey } from "../../i18n/index.js";
8
+ <% } -%>
9
+
10
+ export interface DashboardNavigation {
11
+ /** The side navigation's tree<%= intl ? ", labelled in the active locale" : "" %>. */
12
+ readonly root: NavRoot;
13
+ /** The side navigation's footer rows<%= intl ? ", labelled in the active locale" : "" %>. */
14
+ readonly footerRoot: FooterRoot;
15
+ }
16
+
17
+ /**
18
+ * Builds the dashboard's side navigation<%= intl ? ", labelled by `t`" : "" %>.
19
+ *
20
+ * The first group holds the dashboard's three pages. The second shows how an
21
+ * area without pages yet appears: its items are disabled, so they render
22
+ * without a link and nothing leads to a missing page. The last group is the
23
+ * Help item every application's side navigation carries. The footer links to
24
+ * the router guide, a public page outside the dashboard.
25
+ */
26
+ export default function createDashboardNavigation({
27
+ legalUrl,
28
+ <% if (intl) { -%>
29
+ t,
30
+ <% } -%>
31
+ }: {
32
+ /** Target of the Help › Legal information item. */
33
+ readonly legalUrl: string;
34
+ <% if (intl) { -%>
35
+ /** The active locale's translator. */
36
+ readonly t: (key: MessageKey) => string;
37
+ <% } -%>
38
+ }): DashboardNavigation {
39
+ return {
40
+ root: {
41
+ key: "dashboard",
42
+ items: [
43
+ {
44
+ key: "pages",
45
+ items: [
46
+ {
47
+ url: "/dashboard",
48
+ label: <%- str("dashboard.nav.overview", "Overview") %>,
49
+ icon: "switcher-dashboard",
50
+ },
51
+ {
52
+ url: "/dashboard/instances",
53
+ label: <%- str("dashboard.nav.instances", "Instances") %>,
54
+ icon: "containers",
55
+ },
56
+ {
57
+ url: "/dashboard/settings",
58
+ label: <%- str("dashboard.nav.settings", "Settings") %>,
59
+ icon: "settings",
60
+ },
61
+ ],
62
+ },
63
+ {
64
+ key: "networking",
65
+ label: <%- str("dashboard.nav.networking", "Networking") %>,
66
+ items: [
67
+ {
68
+ key: "networks",
69
+ label: <%- str("dashboard.nav.networks", "Networks") %>,
70
+ icon: "connected",
71
+ disabled: true,
72
+ },
73
+ {
74
+ key: "storage",
75
+ label: <%- str("dashboard.nav.storage", "Storage pools") %>,
76
+ icon: "pods",
77
+ disabled: true,
78
+ },
79
+ ],
80
+ },
81
+ {
82
+ key: "help-group",
83
+ items: [
84
+ createHelpItem(legalUrl, {
85
+ label: <%- str("dashboard.nav.help", "Help") %>,
86
+ legalLabel: <%- str("dashboard.nav.legal", "Legal information") %>,
87
+ }),
88
+ ],
89
+ },
90
+ ],
91
+ },
92
+ footerRoot: {
93
+ key: "dashboard-footer",
94
+ items: [
95
+ {
96
+ url: "/guides/router-core",
97
+ label: <%- str("dashboard.nav.guide", "Router guide") %>,
98
+ icon: "book",
99
+ },
100
+ ],
101
+ },
102
+ };
103
+ }
@@ -0,0 +1,22 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import createInstance from "./createInstance.js";
3
+
4
+ describe("createInstance", () => {
5
+ it("builds a starting instance with the release's product name", () => {
6
+ expect(
7
+ createInstance({ instance_name: "web-03", release: "jammy" }),
8
+ ).toEqual({
9
+ name: "web-03",
10
+ status: "starting",
11
+ release: "Ubuntu 22.04 LTS",
12
+ ipv4: "",
13
+ memoryGib: 4,
14
+ });
15
+ });
16
+
17
+ it("returns nothing without a name", () => {
18
+ expect(createInstance({ instance_name: " ", release: "noble" })).toBe(
19
+ undefined,
20
+ );
21
+ });
22
+ });
@@ -0,0 +1,28 @@
1
+ import { RELEASE_OPTIONS } from "./constants.js";
2
+ import type { Instance } from "./types.js";
3
+
4
+ /**
5
+ * Builds the instance a submitted create form describes, or `undefined` when
6
+ * the form has no name. A new instance is starting and has no address yet.
7
+ */
8
+ export default function createInstance(
9
+ data: Readonly<Record<string, unknown>>,
10
+ ): Instance | undefined {
11
+ const name = typeof data.instance_name === "string" ? data.instance_name : "";
12
+
13
+ if (!name.trim()) {
14
+ return undefined;
15
+ }
16
+
17
+ const release = RELEASE_OPTIONS.find(
18
+ (option) => option.value === data.release,
19
+ );
20
+
21
+ return {
22
+ name,
23
+ status: "starting",
24
+ release: release?.label ?? String(data.release ?? ""),
25
+ ipv4: "",
26
+ memoryGib: 4,
27
+ };
28
+ }
@@ -0,0 +1,78 @@
1
+ import type { NavRoot } from "@canonical/svelte-ds-app";
2
+ import { describe, expect, it } from "vitest";
3
+ import projectBreadcrumbs from "./projectBreadcrumbs.js";
4
+
5
+ const root: NavRoot = {
6
+ key: "root",
7
+ items: [
8
+ {
9
+ key: "pages",
10
+ items: [
11
+ { url: "/overview", label: "Overview" },
12
+ {
13
+ key: "images",
14
+ label: "Images",
15
+ items: [{ url: "/images/local", label: "Local" }],
16
+ },
17
+ ],
18
+ },
19
+ {
20
+ key: "networking",
21
+ label: "Networking",
22
+ items: [{ key: "networks", label: "Networks", disabled: true }],
23
+ },
24
+ ],
25
+ };
26
+
27
+ describe("projectBreadcrumbs", () => {
28
+ it("projects a top-level item onto a trail of itself, marked current", () => {
29
+ expect(projectBreadcrumbs(root, "/overview")).toEqual([
30
+ { key: "current", label: "Overview", current: true },
31
+ ]);
32
+ });
33
+
34
+ it("keeps navigable ancestors and drops the groups, which carry no URL", () => {
35
+ const withParent: NavRoot = {
36
+ key: "root",
37
+ items: [
38
+ {
39
+ key: "pages",
40
+ items: [
41
+ { url: "/instances", label: "Instances" },
42
+ { url: "/instances/web-01", label: "web-01" },
43
+ ],
44
+ },
45
+ ],
46
+ };
47
+ const nested = {
48
+ ...withParent,
49
+ items: [
50
+ {
51
+ key: "pages",
52
+ items: [
53
+ {
54
+ url: "/instances",
55
+ label: "Instances",
56
+ items: [{ url: "/instances/web-01", label: "web-01" }],
57
+ },
58
+ ],
59
+ },
60
+ ],
61
+ } as NavRoot;
62
+
63
+ expect(projectBreadcrumbs(nested, "/instances/web-01")).toEqual([
64
+ { url: "/instances", label: "Instances" },
65
+ { key: "current", label: "web-01", current: true },
66
+ ]);
67
+ });
68
+
69
+ it("drops an expandable parent that has no URL of its own", () => {
70
+ expect(projectBreadcrumbs(root, "/images/local")).toEqual([
71
+ { key: "current", label: "Local", current: true },
72
+ ]);
73
+ });
74
+
75
+ it("returns no trail for a URL that is not in the tree", () => {
76
+ expect(projectBreadcrumbs(root, "/elsewhere")).toEqual([]);
77
+ });
78
+ });
@@ -0,0 +1,47 @@
1
+ import type { Item } from "@canonical/ds-types";
2
+ import {
3
+ annotateTree,
4
+ findAncestorPath,
5
+ prepareIndex,
6
+ } from "@canonical/ds-utils";
7
+ import type { NavRoot } from "@canonical/svelte-ds-app";
8
+ import type { BreadcrumbItem } from "@canonical/svelte-ds-global";
9
+
10
+ /**
11
+ * Projects a navigation tree onto the breadcrumb trail of one of its items.
12
+ *
13
+ * The side navigation and the breadcrumbs are two views of the same tree of
14
+ * navigation items: the trail is the path from the root to the item whose URL
15
+ * is `currentUrl`, keeping the navigable ancestors (groups carry no URL) and
16
+ * marking the item itself as current. A URL that is not in the tree has no
17
+ * trail.
18
+ */
19
+ export default function projectBreadcrumbs(
20
+ root: NavRoot,
21
+ currentUrl: string,
22
+ ): BreadcrumbItem[] {
23
+ // The side navigation's item type keeps `key` and `url` both optional, which
24
+ // is looser than the navigation item's identity rule (one of them is
25
+ // required) that the tree utilities are typed against. Every item of a side
26
+ // navigation tree carries one by contract.
27
+ const index = prepareIndex(annotateTree(root as unknown as Item));
28
+ const current = index[currentUrl];
29
+
30
+ if (current === undefined) {
31
+ return [];
32
+ }
33
+
34
+ return findAncestorPath(index, current).flatMap((item): BreadcrumbItem[] => {
35
+ if (item.url === undefined) {
36
+ return [];
37
+ }
38
+
39
+ const label = item.label ?? "";
40
+
41
+ return item === current
42
+ ? // The current crumb renders without a link, so it is identified by a
43
+ // key; a trail has exactly one, so the key is fixed.
44
+ [{ key: "current", label, current: true }]
45
+ : [{ url: item.url, label }];
46
+ });
47
+ }
@@ -0,0 +1,19 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import selectRelativeTime from "./selectRelativeTime.js";
3
+
4
+ describe("selectRelativeTime", () => {
5
+ it("uses minutes under an hour", () => {
6
+ expect(selectRelativeTime(2)).toEqual({ value: -2, unit: "minute" });
7
+ expect(selectRelativeTime(59)).toEqual({ value: -59, unit: "minute" });
8
+ });
9
+
10
+ it("uses whole hours under a day", () => {
11
+ expect(selectRelativeTime(60)).toEqual({ value: -1, unit: "hour" });
12
+ expect(selectRelativeTime(150)).toEqual({ value: -3, unit: "hour" });
13
+ });
14
+
15
+ it("uses whole days beyond", () => {
16
+ expect(selectRelativeTime(24 * 60)).toEqual({ value: -1, unit: "day" });
17
+ expect(selectRelativeTime(3 * 24 * 60)).toEqual({ value: -3, unit: "day" });
18
+ });
19
+ });
@@ -0,0 +1,24 @@
1
+ const MINUTES_PER_HOUR = 60;
2
+ const MINUTES_PER_DAY = 24 * MINUTES_PER_HOUR;
3
+
4
+ /** A relative time, ready for `Intl.RelativeTimeFormat`: negative is past. */
5
+ export interface RelativeTime {
6
+ readonly value: number;
7
+ readonly unit: "minute" | "hour" | "day";
8
+ }
9
+
10
+ /**
11
+ * Expresses how long ago something happened in the largest whole unit that
12
+ * fits: minutes under an hour, hours under a day, days beyond. The result is
13
+ * formatted by the locale's relative-time formatter, which reads neighbouring
14
+ * days as words where the locale has them ("yesterday", "hier").
15
+ */
16
+ export default function selectRelativeTime(minutesAgo: number): RelativeTime {
17
+ if (minutesAgo < MINUTES_PER_HOUR) {
18
+ return { value: -minutesAgo, unit: "minute" };
19
+ }
20
+ if (minutesAgo < MINUTES_PER_DAY) {
21
+ return { value: -Math.round(minutesAgo / MINUTES_PER_HOUR), unit: "hour" };
22
+ }
23
+ return { value: -Math.round(minutesAgo / MINUTES_PER_DAY), unit: "day" };
24
+ }