@canonical/summon-application 0.44.0 → 0.46.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 (86) hide show
  1. package/README.md +57 -11
  2. package/dist/esm/application/react/index.js +165 -11
  3. package/dist/esm/application/react/index.js.map +1 -1
  4. package/dist/esm/application/react/templates/README.md.ejs +33 -1
  5. package/dist/esm/application/react/templates/package.json.ejs +25 -18
  6. package/dist/esm/application/react/templates/src/client/entry.tsx.ejs +10 -16
  7. package/dist/esm/application/react/templates/src/domains/catalog/CatalogPage.tsx.ejs +5 -5
  8. package/dist/esm/application/react/templates/src/domains/dashboard/DashboardBreadcrumbs.tsx.ejs +35 -0
  9. package/dist/esm/application/react/templates/src/domains/dashboard/DashboardLayout.tsx.ejs +39 -0
  10. package/dist/esm/application/react/templates/src/domains/dashboard/InstancesPage.test.tsx.ejs +144 -0
  11. package/dist/esm/application/react/templates/src/domains/dashboard/InstancesPage.tsx.ejs +281 -0
  12. package/dist/esm/application/react/templates/src/domains/dashboard/OverviewPage.test.tsx.ejs +76 -0
  13. package/dist/esm/application/react/templates/src/domains/dashboard/OverviewPage.tsx.ejs +224 -0
  14. package/dist/esm/application/react/templates/src/domains/dashboard/SettingsPage.test.tsx.ejs +64 -0
  15. package/dist/esm/application/react/templates/src/domains/dashboard/SettingsPage.tsx.ejs +142 -0
  16. package/dist/esm/application/react/templates/src/domains/dashboard/constants.ts.ejs +229 -0
  17. package/dist/esm/application/react/templates/src/domains/dashboard/hooks/index.ts +2 -0
  18. package/dist/esm/application/react/templates/src/domains/dashboard/hooks/types.ts +13 -0
  19. package/dist/esm/application/react/templates/src/domains/dashboard/hooks/useDashboardNavigation.ts.ejs +94 -0
  20. package/dist/esm/application/react/templates/src/domains/dashboard/projectBreadcrumbs.test.ts +78 -0
  21. package/dist/esm/application/react/templates/src/domains/dashboard/projectBreadcrumbs.ts +48 -0
  22. package/dist/esm/application/react/templates/src/domains/dashboard/routes.ts +21 -0
  23. package/dist/esm/application/react/templates/src/domains/dashboard/selectRelativeTime.test.ts +19 -0
  24. package/dist/esm/application/react/templates/src/domains/dashboard/selectRelativeTime.ts +24 -0
  25. package/dist/esm/application/react/templates/src/domains/dashboard/styles.css +98 -0
  26. package/dist/esm/application/react/templates/src/domains/dashboard/types.ts.ejs +61 -0
  27. package/dist/esm/application/react/templates/src/domains/marketing/HomePage.tsx.ejs +14 -9
  28. package/dist/esm/application/react/templates/src/i18n/ar.ts.ejs +173 -0
  29. package/dist/esm/application/react/templates/src/i18n/en.ts.ejs +172 -0
  30. package/dist/esm/application/react/templates/src/i18n/fr.ts.ejs +170 -0
  31. package/dist/esm/application/react/templates/src/lib/ApplicationShell/ApplicationShell.stories.tsx +91 -0
  32. package/dist/esm/application/react/templates/src/lib/ApplicationShell/ApplicationShell.test.tsx.ejs +139 -0
  33. package/dist/esm/application/react/templates/src/lib/ApplicationShell/ApplicationShell.tsx.ejs +78 -0
  34. package/dist/esm/application/react/templates/src/lib/ApplicationShell/index.ts +2 -0
  35. package/dist/esm/application/react/templates/src/lib/ApplicationShell/styles.css +43 -0
  36. package/dist/esm/application/react/templates/src/lib/ApplicationShell/types.ts +20 -0
  37. package/dist/esm/application/react/templates/src/lib/CanonicalLogo/CanonicalLogo.tsx.ejs +51 -0
  38. package/dist/esm/application/react/templates/src/lib/CanonicalLogo/index.ts +2 -0
  39. package/dist/esm/application/react/templates/src/lib/CanonicalLogo/styles.css +31 -0
  40. package/dist/esm/application/react/templates/src/lib/CanonicalLogo/types.ts +11 -0
  41. package/dist/esm/application/react/templates/src/lib/CodeMessage/CodeMessage.test.tsx +33 -0
  42. package/dist/esm/application/react/templates/src/lib/CodeMessage/CodeMessage.tsx +33 -0
  43. package/dist/esm/application/react/templates/src/lib/CodeMessage/index.ts +2 -0
  44. package/dist/esm/application/react/templates/src/lib/CodeMessage/types.ts +16 -0
  45. package/dist/esm/application/react/templates/src/lib/LazyComponent/{LazyComponent.tsx → LazyComponent.tsx.ejs} +26 -0
  46. package/dist/esm/application/react/templates/src/lib/LoadingMessage/LoadingMessage.test.tsx.ejs +20 -0
  47. package/dist/esm/application/react/templates/src/lib/LoadingMessage/LoadingMessage.tsx.ejs +21 -0
  48. package/dist/esm/application/react/templates/src/lib/LoadingMessage/index.ts +1 -0
  49. package/dist/esm/application/react/templates/src/lib/LocaleSelector/{LocaleSelector.tsx → LocaleSelector.tsx.ejs} +23 -0
  50. package/dist/esm/application/react/templates/src/lib/Navigation/Navigation.test.tsx.ejs +87 -0
  51. package/dist/esm/application/react/templates/src/lib/Navigation/Navigation.tsx.ejs +3 -0
  52. package/dist/esm/application/react/templates/src/lib/RouterLink/RouterLink.test.tsx +98 -0
  53. package/dist/esm/application/react/templates/src/lib/RouterLink/RouterLink.tsx +65 -0
  54. package/dist/esm/application/react/templates/src/lib/RouterLink/index.ts +1 -0
  55. package/dist/esm/application/react/templates/src/lib/ThemeSelector/ThemeSelector.tsx.ejs +29 -14
  56. package/dist/esm/application/react/templates/src/lib/TopBar/TopBar.stories.tsx.ejs +29 -0
  57. package/dist/esm/application/react/templates/src/lib/TopBar/TopBar.test.tsx.ejs +113 -0
  58. package/dist/esm/application/react/templates/src/lib/TopBar/TopBar.tsx.ejs +45 -0
  59. package/dist/esm/application/react/templates/src/lib/TopBar/index.ts +2 -0
  60. package/dist/esm/application/react/templates/src/lib/TopBar/styles.css +49 -0
  61. package/dist/esm/application/react/templates/src/lib/TopBar/types.ts +8 -0
  62. package/dist/esm/application/react/templates/src/lib/index.ts.ejs +10 -0
  63. package/dist/esm/application/react/templates/src/routes.tsx.ejs +70 -20
  64. package/dist/esm/application/react/templates/src/server/entry.tsx.ejs +6 -7
  65. package/dist/esm/application/react/templates/src/sitemap/getSitemapItems.ts.ejs +5 -0
  66. package/dist/esm/application/react/templates/src/styles/app.css +24 -11
  67. package/dist/esm/application/react/templates/src/testing/browserStubs.ts +57 -0
  68. package/dist/esm/application/react/templates/src/testing/fixtures.ts.ejs +29 -0
  69. package/dist/esm/application/react/templates/src/testing/renderWithProviders.tsx.ejs +64 -0
  70. package/dist/esm/application/react/templates/test/e2e/servers.e2e.ts.ejs +37 -1
  71. package/dist/esm/application/react/templates/vite-plugin-ds-icons.ts +7 -2
  72. package/dist/esm/application/react/templates/vitest.config.ts +4 -0
  73. package/dist/esm/application/react/textHelpers.js +9 -0
  74. package/dist/esm/application/react/textHelpers.js.map +1 -0
  75. package/dist/esm/shared/versions.js +35 -21
  76. package/dist/esm/shared/versions.js.map +1 -1
  77. package/dist/types/application/react/index.d.ts +1 -0
  78. package/dist/types/application/react/index.d.ts.map +1 -1
  79. package/dist/types/application/react/textHelpers.d.ts +18 -0
  80. package/dist/types/application/react/textHelpers.d.ts.map +1 -0
  81. package/dist/types/shared/versions.d.ts +41 -4
  82. package/dist/types/shared/versions.d.ts.map +1 -1
  83. package/package.json +8 -8
  84. package/dist/esm/application/react/templates/src/i18n/ar.ts +0 -73
  85. package/dist/esm/application/react/templates/src/i18n/en.ts +0 -72
  86. package/dist/esm/application/react/templates/src/i18n/fr.ts +0 -69
@@ -0,0 +1,224 @@
1
+ <% if (intl) { -%>
2
+ import { useFormatters, useTranslation } from "@canonical/i18n-react";
3
+ <% } -%>
4
+ import { ContentLayout, ViewLayout } from "@canonical/react-ds-app";
5
+ import { Button, Card, Tile, Timeline } from "@canonical/react-ds-global";
6
+ import { Head } from "@canonical/react-head";
7
+ import { useRouter } from "@canonical/router-react";
8
+ import type { ReactElement } from "react";
9
+ import {
10
+ ACTIVITY,
11
+ <% if (intl) { -%>
12
+ CHANNEL_KEYS,
13
+ <% } else { -%>
14
+ CHANNEL_LABELS,
15
+ <% } -%>
16
+ OVERVIEW_FIGURES,
17
+ RELEASES,
18
+ TERABYTES,
19
+ } from "./constants.js";
20
+ import DashboardBreadcrumbs from "./DashboardBreadcrumbs.js";
21
+ import selectRelativeTime from "./selectRelativeTime.js";
22
+ import "./styles.css";
23
+ <% if (!intl) { -%>
24
+
25
+ // The app has one language, so the formatters are fixed to it.
26
+ const number = new Intl.NumberFormat("en");
27
+ const terabytes = new Intl.NumberFormat("en", TERABYTES);
28
+ const relativeTime = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
29
+
30
+ function formatRelative(minutesAgo: number): string {
31
+ const { value, unit } = selectRelativeTime(minutesAgo);
32
+ return relativeTime.format(value, unit);
33
+ }
34
+ <% } -%>
35
+
36
+ export default function OverviewPage(): ReactElement {
37
+ <% if (intl) { -%>
38
+ const { t } = useTranslation();
39
+ const formatters = useFormatters();
40
+
41
+ function formatRelative(minutesAgo: number): string {
42
+ const { value, unit } = selectRelativeTime(minutesAgo);
43
+ return formatters.relativeTime(value, unit, { numeric: "auto" });
44
+ }
45
+ <% } -%>
46
+ const router = useRouter();
47
+
48
+ const activity = (
49
+ <section aria-labelledby="activity-title" className="panel">
50
+ <h2 id="activity-title"><%- msg("dashboard.activity.heading", "Activity") %></h2>
51
+ <Timeline>
52
+ <Timeline.Content>
53
+ {ACTIVITY.map((event) => (
54
+ <Timeline.Event
55
+ <% if (intl) { -%>
56
+ actor={
57
+ "name" in event.actor ? event.actor.name : t(event.actor.key)
58
+ }
59
+ <% } else { -%>
60
+ actor={event.actor}
61
+ <% } -%>
62
+ criticality={event.criticality}
63
+ datetime={formatRelative(event.minutesAgo)}
64
+ key={event.key}
65
+ >
66
+ <% if (intl) { -%>
67
+ {t(event.messageKey, event.values)}
68
+ <% } else { -%>
69
+ {event.message}
70
+ <% } -%>
71
+ </Timeline.Event>
72
+ ))}
73
+ </Timeline.Content>
74
+ </Timeline>
75
+ </section>
76
+ );
77
+
78
+ return (
79
+ <ViewLayout aside={activity} className="dashboard-view">
80
+ <ContentLayout>
81
+ <Head title=<%- attr("dashboard.overview.title", "Dashboard") %> />
82
+ <header className="titlebar">
83
+ <div>
84
+ <DashboardBreadcrumbs />
85
+ <h1><%- msg("dashboard.overview.heading", "Overview") %></h1>
86
+ </div>
87
+ <div className="actions">
88
+ <Button
89
+ icon="plus"
90
+ importance="primary"
91
+ onClick={() => router.navigate("dashboardInstances")}
92
+ >
93
+ <%- msg("dashboard.instances.create", "Create instance") %>
94
+ </Button>
95
+ </div>
96
+ </header>
97
+
98
+ <section aria-labelledby="status-title" className="section">
99
+ <h2 id="status-title"><%- msg("dashboard.overview.status", "Status") %></h2>
100
+ <ul className="tiles">
101
+ <li>
102
+ <Tile>
103
+ <Tile.Header><%- msg("dashboard.overview.running", "Running") %></Tile.Header>
104
+ <Tile.Content>
105
+ <p className="figure">
106
+ <% if (intl) { -%>
107
+ {formatters.number(OVERVIEW_FIGURES.running)}
108
+ <% } else { -%>
109
+ {number.format(OVERVIEW_FIGURES.running)}
110
+ <% } -%>
111
+ </p>
112
+ </Tile.Content>
113
+ </Tile>
114
+ </li>
115
+ <li>
116
+ <Tile>
117
+ <Tile.Header><%- msg("dashboard.overview.stopped", "Stopped") %></Tile.Header>
118
+ <Tile.Content>
119
+ <p className="figure">
120
+ <% if (intl) { -%>
121
+ {formatters.number(OVERVIEW_FIGURES.stopped)}
122
+ <% } else { -%>
123
+ {number.format(OVERVIEW_FIGURES.stopped)}
124
+ <% } -%>
125
+ </p>
126
+ </Tile.Content>
127
+ </Tile>
128
+ </li>
129
+ <li>
130
+ <Tile>
131
+ <Tile.Header><%- msg("dashboard.overview.storage", "Storage") %></Tile.Header>
132
+ <Tile.Content>
133
+ <% if (intl) { -%>
134
+ <p className="figure">
135
+ {formatters.number(
136
+ OVERVIEW_FIGURES.storageUsedTb,
137
+ TERABYTES,
138
+ )}
139
+ </p>
140
+ <p className="muted">
141
+ {t("dashboard.overview.storageOf", {
142
+ total: formatters.number(
143
+ OVERVIEW_FIGURES.storageTotalTb,
144
+ TERABYTES,
145
+ ),
146
+ })}
147
+ </p>
148
+ <% } else { -%>
149
+ <p className="figure">
150
+ {terabytes.format(OVERVIEW_FIGURES.storageUsedTb)}
151
+ </p>
152
+ <p className="muted">
153
+ of {terabytes.format(OVERVIEW_FIGURES.storageTotalTb)} used
154
+ </p>
155
+ <% } -%>
156
+ </Tile.Content>
157
+ </Tile>
158
+ </li>
159
+ <li>
160
+ <Tile>
161
+ <Tile.Header><%- msg("dashboard.overview.alerts", "Alerts") %></Tile.Header>
162
+ <Tile.Content>
163
+ <p className="figure">
164
+ <% if (intl) { -%>
165
+ {formatters.number(OVERVIEW_FIGURES.alerts)}
166
+ <% } else { -%>
167
+ {number.format(OVERVIEW_FIGURES.alerts)}
168
+ <% } -%>
169
+ </p>
170
+ </Tile.Content>
171
+ </Tile>
172
+ </li>
173
+ </ul>
174
+ </section>
175
+
176
+ <section aria-labelledby="releases-title" className="section">
177
+ <h2 id="releases-title"><%- msg("dashboard.overview.releases", "Releases") %></h2>
178
+ <ul className="cards">
179
+ {RELEASES.map((release) => (
180
+ <li key={release.name}>
181
+ <Card>
182
+ <Card.Header>{release.name}</Card.Header>
183
+ <Card.Content>
184
+ <% if (intl) { -%>
185
+ <p>{t(release.summaryKey)}</p>
186
+ <p className="muted">
187
+ {t("dashboard.releases.detail", {
188
+ channel: t(CHANNEL_KEYS[release.channel]),
189
+ kernel: release.kernel,
190
+ })}
191
+ </p>
192
+ <% } else { -%>
193
+ <p>{release.summary}</p>
194
+ <p className="muted">
195
+ {CHANNEL_LABELS[release.channel]} · kernel{" "}
196
+ {release.kernel}
197
+ </p>
198
+ <% } -%>
199
+ </Card.Content>
200
+ <Card.Footer>
201
+ <% if (intl) { -%>
202
+ <Button importance="secondary">
203
+ {t("dashboard.overview.releaseNotes")}
204
+ </Button>
205
+ <% } else { -%>
206
+ <Button importance="secondary">Release notes</Button>
207
+ <% } -%>
208
+ <Button
209
+ icon="plus"
210
+ importance="primary"
211
+ onClick={() => router.navigate("dashboardInstances")}
212
+ >
213
+ <%- msg("dashboard.overview.launch", "Launch") %>
214
+ </Button>
215
+ </Card.Footer>
216
+ </Card>
217
+ </li>
218
+ ))}
219
+ </ul>
220
+ </section>
221
+ </ContentLayout>
222
+ </ViewLayout>
223
+ );
224
+ }
@@ -0,0 +1,64 @@
1
+ import { fireEvent, screen } from "@testing-library/react";
2
+ import { beforeAll, describe, expect, it } from "vitest";
3
+ import {
4
+ installDialogStubs,
5
+ installMatchMedia,
6
+ installResizeObserver,
7
+ } from "../../testing/browserStubs.js";
8
+ import renderWithProviders from "../../testing/renderWithProviders.js";
9
+ import SettingsPage from "./SettingsPage.js";
10
+
11
+ beforeAll(() => {
12
+ installMatchMedia();
13
+ installResizeObserver();
14
+ installDialogStubs();
15
+ });
16
+
17
+ function renderPage() {
18
+ return renderWithProviders(<SettingsPage />, "/dashboard/settings");
19
+ }
20
+
21
+ describe("SettingsPage", () => {
22
+ <% if (forms) { -%>
23
+ it("prefills the project settings", () => {
24
+ renderPage();
25
+
26
+ expect(screen.getByLabelText(/Default bridge/)).toHaveValue("lxdbr0");
27
+ expect(screen.getByLabelText(/Maximum instances/)).toHaveValue(50);
28
+ });
29
+ <% } else { -%>
30
+ it("heads the page and marks Settings as the current crumb", () => {
31
+ renderPage();
32
+
33
+ expect(
34
+ screen.getByRole("heading", { level: 1, name: "Settings" }),
35
+ ).toBeInTheDocument();
36
+ expect(
37
+ screen.getByText("Settings", { selector: "[aria-current]" }),
38
+ ).toBeInTheDocument();
39
+ });
40
+ <% } -%>
41
+
42
+ describe("the delete confirmation", () => {
43
+ it("opens from Delete project in the danger zone", () => {
44
+ const { container } = renderPage();
45
+ const modal = container.querySelector("dialog.ds.modal");
46
+
47
+ expect(modal).not.toHaveAttribute("open");
48
+
49
+ fireEvent.click(screen.getByRole("button", { name: "Delete project" }));
50
+
51
+ expect(modal).toHaveAttribute("open");
52
+ });
53
+
54
+ it("closes from Cancel", () => {
55
+ const { container } = renderPage();
56
+ const modal = container.querySelector("dialog.ds.modal");
57
+
58
+ fireEvent.click(screen.getByRole("button", { name: "Delete project" }));
59
+ fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
60
+
61
+ expect(modal).not.toHaveAttribute("open");
62
+ });
63
+ });
64
+ });
@@ -0,0 +1,142 @@
1
+ <% if (intl) { -%>
2
+ import { useTranslation } from "@canonical/i18n-react";
3
+ <% } -%>
4
+ import { ContentLayout, ViewLayout } from "@canonical/react-ds-app";
5
+ import { Button, Modal } from "@canonical/react-ds-global";
6
+ <% if (forms) { -%>
7
+ import { Field, Form } from "@canonical/react-ds-global-form";
8
+ <% } -%>
9
+ import { Head } from "@canonical/react-head";
10
+ import { type ReactElement, useRef } from "react";
11
+ import { PROJECT_NAME } from "./constants.js";
12
+ import DashboardBreadcrumbs from "./DashboardBreadcrumbs.js";
13
+ import "./styles.css";
14
+ <% if (forms) { -%>
15
+
16
+ /** The project's current settings, prefilled into the form. */
17
+ const SETTINGS_DEFAULTS = {
18
+ bridge: "lxdbr0",
19
+ ipv6: true,
20
+ max_instances: 50,
21
+ snapshots: true,
22
+ };
23
+
24
+ const BRIDGE_OPTIONS = [
25
+ { value: "lxdbr0", label: "lxdbr0" },
26
+ { value: "ovn-1", label: "ovn-1" },
27
+ ];
28
+
29
+ function handleSave(data: Record<string, unknown>) {
30
+ console.log("Settings saved:", data);
31
+ }
32
+ <% } -%>
33
+
34
+ export default function SettingsPage(): ReactElement {
35
+ <% if (intl) { -%>
36
+ const { t } = useTranslation();
37
+ <% } -%>
38
+ const modalRef = useRef<HTMLDialogElement>(null);
39
+
40
+ function closeModal() {
41
+ modalRef.current?.close();
42
+ }
43
+
44
+ return (
45
+ <ViewLayout className="dashboard-view">
46
+ <ContentLayout>
47
+ <Head title=<%- attr("dashboard.settings.title", "Settings") %> />
48
+ <header className="titlebar">
49
+ <div>
50
+ <DashboardBreadcrumbs />
51
+ <h1><%- msg("dashboard.settings.heading", "Settings") %></h1>
52
+ </div>
53
+ </header>
54
+ <% if (forms) { -%>
55
+
56
+ <section aria-labelledby="project-title" className="section narrow">
57
+ <h2 id="project-title"><%- msg("dashboard.settings.project", "Project") %></h2>
58
+ <Form defaultValues={SETTINGS_DEFAULTS} onSubmit={handleSave}>
59
+ <Field
60
+ inputType="select"
61
+ label=<%- attr("dashboard.settings.bridge", "Default bridge") %>
62
+ name="bridge"
63
+ options={BRIDGE_OPTIONS}
64
+ />
65
+ <Field
66
+ controlLabel=<%- attr("dashboard.settings.ipv6Control", "Enable IPv6 NAT") %>
67
+ inputType="switch"
68
+ isOptional
69
+ label=<%- attr("dashboard.settings.ipv6", "IPv6") %>
70
+ name="ipv6"
71
+ />
72
+ <Field
73
+ inputType="number"
74
+ label=<%- attr("dashboard.settings.maxInstances", "Maximum instances") %>
75
+ name="max_instances"
76
+ />
77
+ <Field
78
+ controlLabel=<%- attr("dashboard.settings.snapshotsControl", "Enabled") %>
79
+ inputType="switch"
80
+ isOptional
81
+ label=<%- attr("dashboard.settings.snapshots", "Nightly snapshots") %>
82
+ name="snapshots"
83
+ />
84
+ <div className="actions">
85
+ <Button importance="primary" type="submit">
86
+ <%- msg("dashboard.settings.save", "Save changes") %>
87
+ </Button>
88
+ </div>
89
+ </Form>
90
+ </section>
91
+ <% } -%>
92
+
93
+ <section aria-labelledby="danger-title" className="section narrow">
94
+ <h2 id="danger-title"><%- msg("dashboard.settings.danger", "Danger zone") %></h2>
95
+ <p className="muted"><%- msg("dashboard.settings.dangerBody", "These actions cannot be undone.") %></p>
96
+ <div className="actions">
97
+ <Button
98
+ anticipation="destructive"
99
+ icon="delete"
100
+ importance="primary"
101
+ onClick={() => modalRef.current?.showModal()}
102
+ >
103
+ <%- msg("dashboard.settings.delete", "Delete project") %>
104
+ </Button>
105
+ </div>
106
+ </section>
107
+ </ContentLayout>
108
+
109
+ <Modal closeOnBackdropClick ref={modalRef}>
110
+ <% if (intl) { -%>
111
+ <Modal.Header dismissLabel={t("dashboard.close")}>
112
+ {t("dashboard.settings.confirmTitle")}
113
+ </Modal.Header>
114
+ <% } else { -%>
115
+ <Modal.Header dismissLabel="Close">Delete project?</Modal.Header>
116
+ <% } -%>
117
+ <Modal.Content>
118
+ <p>
119
+ <% if (intl) { -%>
120
+ {t("dashboard.settings.confirmBody", { project: PROJECT_NAME })}
121
+ <% } else { -%>
122
+ {`This permanently deletes the ${PROJECT_NAME} project, its instances and their storage. This cannot be undone.`}
123
+ <% } -%>
124
+ </p>
125
+ </Modal.Content>
126
+ <Modal.Footer>
127
+ <Button importance="tertiary" onClick={closeModal}>
128
+ <%- msg("dashboard.cancel", "Cancel") %>
129
+ </Button>
130
+ <Button
131
+ anticipation="destructive"
132
+ icon="delete"
133
+ importance="primary"
134
+ onClick={closeModal}
135
+ >
136
+ <%- msg("dashboard.settings.delete", "Delete project") %>
137
+ </Button>
138
+ </Modal.Footer>
139
+ </Modal>
140
+ </ViewLayout>
141
+ );
142
+ }
@@ -0,0 +1,229 @@
1
+ <% if (intl) { -%>
2
+ import type { MessageKey } from "#i18n/en.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
+ <% } -%>
@@ -0,0 +1,2 @@
1
+ export type * from "./types.js";
2
+ export { default as useDashboardNavigation } from "./useDashboardNavigation.js";
@@ -0,0 +1,13 @@
1
+ import type { FooterRoot, NavRoot } from "@canonical/react-ds-app";
2
+
3
+ export interface UseDashboardNavigationProps {
4
+ /** Target of the Help › Legal information item. */
5
+ readonly legalUrl: string;
6
+ }
7
+
8
+ export interface UseDashboardNavigationResult {
9
+ /** The side navigation's tree, labelled in the active locale. */
10
+ readonly root: NavRoot;
11
+ /** The side navigation's footer rows, labelled in the active locale. */
12
+ readonly footerRoot: FooterRoot;
13
+ }