@canonical/summon-application 0.44.0 → 0.47.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.
- package/README.md +57 -11
- package/dist/esm/application/react/index.js +165 -11
- package/dist/esm/application/react/index.js.map +1 -1
- package/dist/esm/application/react/templates/README.md.ejs +33 -1
- package/dist/esm/application/react/templates/package.json.ejs +25 -18
- package/dist/esm/application/react/templates/src/client/entry.tsx.ejs +10 -16
- package/dist/esm/application/react/templates/src/domains/catalog/CatalogPage.tsx.ejs +5 -5
- package/dist/esm/application/react/templates/src/domains/dashboard/DashboardBreadcrumbs.tsx.ejs +35 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/DashboardLayout.tsx.ejs +39 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/InstancesPage.test.tsx.ejs +144 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/InstancesPage.tsx.ejs +281 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/OverviewPage.test.tsx.ejs +76 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/OverviewPage.tsx.ejs +224 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/SettingsPage.test.tsx.ejs +64 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/SettingsPage.tsx.ejs +142 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/constants.ts.ejs +229 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/hooks/index.ts +2 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/hooks/types.ts +13 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/hooks/useDashboardNavigation.ts.ejs +94 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/projectBreadcrumbs.test.ts +78 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/projectBreadcrumbs.ts +48 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/routes.ts +21 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/selectRelativeTime.test.ts +19 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/selectRelativeTime.ts +24 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/styles.css +98 -0
- package/dist/esm/application/react/templates/src/domains/dashboard/types.ts.ejs +61 -0
- package/dist/esm/application/react/templates/src/domains/marketing/HomePage.tsx.ejs +14 -9
- package/dist/esm/application/react/templates/src/i18n/ar.ts.ejs +173 -0
- package/dist/esm/application/react/templates/src/i18n/en.ts.ejs +172 -0
- package/dist/esm/application/react/templates/src/i18n/fr.ts.ejs +170 -0
- package/dist/esm/application/react/templates/src/lib/ApplicationShell/ApplicationShell.stories.tsx +91 -0
- package/dist/esm/application/react/templates/src/lib/ApplicationShell/ApplicationShell.test.tsx.ejs +139 -0
- package/dist/esm/application/react/templates/src/lib/ApplicationShell/ApplicationShell.tsx.ejs +78 -0
- package/dist/esm/application/react/templates/src/lib/ApplicationShell/index.ts +2 -0
- package/dist/esm/application/react/templates/src/lib/ApplicationShell/styles.css +43 -0
- package/dist/esm/application/react/templates/src/lib/ApplicationShell/types.ts +20 -0
- package/dist/esm/application/react/templates/src/lib/CanonicalLogo/CanonicalLogo.tsx.ejs +51 -0
- package/dist/esm/application/react/templates/src/lib/CanonicalLogo/index.ts +2 -0
- package/dist/esm/application/react/templates/src/lib/CanonicalLogo/styles.css +31 -0
- package/dist/esm/application/react/templates/src/lib/CanonicalLogo/types.ts +11 -0
- package/dist/esm/application/react/templates/src/lib/CodeMessage/CodeMessage.test.tsx +33 -0
- package/dist/esm/application/react/templates/src/lib/CodeMessage/CodeMessage.tsx +33 -0
- package/dist/esm/application/react/templates/src/lib/CodeMessage/index.ts +2 -0
- package/dist/esm/application/react/templates/src/lib/CodeMessage/types.ts +16 -0
- package/dist/esm/application/react/templates/src/lib/LazyComponent/{LazyComponent.tsx → LazyComponent.tsx.ejs} +26 -0
- package/dist/esm/application/react/templates/src/lib/LoadingMessage/LoadingMessage.test.tsx.ejs +20 -0
- package/dist/esm/application/react/templates/src/lib/LoadingMessage/LoadingMessage.tsx.ejs +21 -0
- package/dist/esm/application/react/templates/src/lib/LoadingMessage/index.ts +1 -0
- package/dist/esm/application/react/templates/src/lib/LocaleSelector/{LocaleSelector.tsx → LocaleSelector.tsx.ejs} +23 -0
- package/dist/esm/application/react/templates/src/lib/Navigation/Navigation.test.tsx.ejs +87 -0
- package/dist/esm/application/react/templates/src/lib/Navigation/Navigation.tsx.ejs +3 -0
- package/dist/esm/application/react/templates/src/lib/RouterLink/RouterLink.test.tsx +98 -0
- package/dist/esm/application/react/templates/src/lib/RouterLink/RouterLink.tsx +65 -0
- package/dist/esm/application/react/templates/src/lib/RouterLink/index.ts +1 -0
- package/dist/esm/application/react/templates/src/lib/ThemeSelector/ThemeSelector.tsx.ejs +29 -14
- package/dist/esm/application/react/templates/src/lib/TopBar/TopBar.stories.tsx.ejs +29 -0
- package/dist/esm/application/react/templates/src/lib/TopBar/TopBar.test.tsx.ejs +113 -0
- package/dist/esm/application/react/templates/src/lib/TopBar/TopBar.tsx.ejs +45 -0
- package/dist/esm/application/react/templates/src/lib/TopBar/index.ts +2 -0
- package/dist/esm/application/react/templates/src/lib/TopBar/styles.css +49 -0
- package/dist/esm/application/react/templates/src/lib/TopBar/types.ts +8 -0
- package/dist/esm/application/react/templates/src/lib/index.ts.ejs +10 -0
- package/dist/esm/application/react/templates/src/routes.tsx.ejs +70 -20
- package/dist/esm/application/react/templates/src/server/entry.tsx.ejs +6 -7
- package/dist/esm/application/react/templates/src/sitemap/getSitemapItems.ts.ejs +5 -0
- package/dist/esm/application/react/templates/src/styles/app.css +24 -11
- package/dist/esm/application/react/templates/src/testing/browserStubs.ts +57 -0
- package/dist/esm/application/react/templates/src/testing/fixtures.ts.ejs +29 -0
- package/dist/esm/application/react/templates/src/testing/renderWithProviders.tsx.ejs +64 -0
- package/dist/esm/application/react/templates/test/e2e/servers.e2e.ts.ejs +37 -1
- package/dist/esm/application/react/templates/vite-plugin-ds-icons.ts +23 -4
- package/dist/esm/application/react/templates/vitest.config.ts +4 -0
- package/dist/esm/application/react/textHelpers.js +9 -0
- package/dist/esm/application/react/textHelpers.js.map +1 -0
- package/dist/esm/shared/versions.js +35 -21
- package/dist/esm/shared/versions.js.map +1 -1
- package/dist/types/application/react/index.d.ts +1 -0
- package/dist/types/application/react/index.d.ts.map +1 -1
- package/dist/types/application/react/textHelpers.d.ts +18 -0
- package/dist/types/application/react/textHelpers.d.ts.map +1 -0
- package/dist/types/shared/versions.d.ts +41 -4
- package/dist/types/shared/versions.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/esm/application/react/templates/src/i18n/ar.ts +0 -73
- package/dist/esm/application/react/templates/src/i18n/en.ts +0 -72
- package/dist/esm/application/react/templates/src/i18n/fr.ts +0 -69
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<% if (intl) { -%>
|
|
2
|
+
import { useTranslation } from "@canonical/i18n-react";
|
|
3
|
+
<% } -%>
|
|
4
|
+
import { createHelpItem } from "@canonical/react-ds-app";
|
|
5
|
+
import type {
|
|
6
|
+
UseDashboardNavigationProps,
|
|
7
|
+
UseDashboardNavigationResult,
|
|
8
|
+
} from "./types.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Builds the dashboard's side navigation<% if (intl) { %>, labelled in the active locale<% } %>.
|
|
12
|
+
*
|
|
13
|
+
* The first group holds the dashboard's three pages. The second shows how an
|
|
14
|
+
* area without pages yet appears: its items are disabled, so they render
|
|
15
|
+
* without a link and nothing leads to a missing page. The last group is the
|
|
16
|
+
* Help item every application's side navigation carries. The footer links to
|
|
17
|
+
* the router guide, a public page outside the dashboard.
|
|
18
|
+
*/
|
|
19
|
+
export default function useDashboardNavigation({
|
|
20
|
+
legalUrl,
|
|
21
|
+
}: UseDashboardNavigationProps): UseDashboardNavigationResult {
|
|
22
|
+
<% if (intl) { -%>
|
|
23
|
+
const { t } = useTranslation();
|
|
24
|
+
|
|
25
|
+
<% } -%>
|
|
26
|
+
return {
|
|
27
|
+
root: {
|
|
28
|
+
key: "dashboard",
|
|
29
|
+
items: [
|
|
30
|
+
{
|
|
31
|
+
key: "pages",
|
|
32
|
+
items: [
|
|
33
|
+
{
|
|
34
|
+
url: "/dashboard",
|
|
35
|
+
label: <%- str("dashboard.nav.overview", "Overview") %>,
|
|
36
|
+
icon: "switcher-dashboard",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
url: "/dashboard/instances",
|
|
40
|
+
label: <%- str("dashboard.nav.instances", "Instances") %>,
|
|
41
|
+
icon: "containers",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
url: "/dashboard/settings",
|
|
45
|
+
label: <%- str("dashboard.nav.settings", "Settings") %>,
|
|
46
|
+
icon: "settings",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: "networking",
|
|
52
|
+
label: <%- str("dashboard.nav.networking", "Networking") %>,
|
|
53
|
+
items: [
|
|
54
|
+
{
|
|
55
|
+
key: "networks",
|
|
56
|
+
label: <%- str("dashboard.nav.networks", "Networks") %>,
|
|
57
|
+
icon: "connected",
|
|
58
|
+
disabled: true,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: "storage",
|
|
62
|
+
label: <%- str("dashboard.nav.storage", "Storage pools") %>,
|
|
63
|
+
icon: "pods",
|
|
64
|
+
disabled: true,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: "help-group",
|
|
70
|
+
<% if (intl) { -%>
|
|
71
|
+
items: [
|
|
72
|
+
createHelpItem(legalUrl, {
|
|
73
|
+
label: t("dashboard.nav.help"),
|
|
74
|
+
legalLabel: t("dashboard.nav.legal"),
|
|
75
|
+
}),
|
|
76
|
+
],
|
|
77
|
+
<% } else { -%>
|
|
78
|
+
items: [createHelpItem(legalUrl)],
|
|
79
|
+
<% } -%>
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
footerRoot: {
|
|
84
|
+
key: "dashboard-footer",
|
|
85
|
+
items: [
|
|
86
|
+
{
|
|
87
|
+
url: "/guides/router-core",
|
|
88
|
+
label: <%- str("dashboard.nav.guide", "Router guide") %>,
|
|
89
|
+
icon: "book",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { NavRoot } from "@canonical/react-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,48 @@
|
|
|
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/react-ds-app";
|
|
8
|
+
import type { BreadcrumbItem } from "@canonical/react-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, as SideNavigation itself assumes
|
|
27
|
+
// when it indexes the same tree.
|
|
28
|
+
const index = prepareIndex(annotateTree(root as Item));
|
|
29
|
+
const current = index[currentUrl];
|
|
30
|
+
|
|
31
|
+
if (current === undefined) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return findAncestorPath(index, current).flatMap((item): BreadcrumbItem[] => {
|
|
36
|
+
if (item.url === undefined) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const label = item.label ?? "";
|
|
41
|
+
|
|
42
|
+
return item === current
|
|
43
|
+
? // The current crumb renders without a link, so it is identified by a
|
|
44
|
+
// key; a trail has exactly one, so the key is fixed.
|
|
45
|
+
[{ key: "current", label, current: true }]
|
|
46
|
+
: [{ url: item.url, label }];
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { route } from "@canonical/router-core";
|
|
2
|
+
import InstancesPage from "./InstancesPage.js";
|
|
3
|
+
import OverviewPage from "./OverviewPage.js";
|
|
4
|
+
import SettingsPage from "./SettingsPage.js";
|
|
5
|
+
|
|
6
|
+
const routes = {
|
|
7
|
+
dashboard: route({
|
|
8
|
+
url: "/dashboard",
|
|
9
|
+
content: OverviewPage,
|
|
10
|
+
}),
|
|
11
|
+
dashboardInstances: route({
|
|
12
|
+
url: "/dashboard/instances",
|
|
13
|
+
content: InstancesPage,
|
|
14
|
+
}),
|
|
15
|
+
dashboardSettings: route({
|
|
16
|
+
url: "/dashboard/settings",
|
|
17
|
+
content: SettingsPage,
|
|
18
|
+
}),
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
export default routes;
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/* The dashboard pages. Each page renders a ViewLayout carrying the
|
|
2
|
+
* `dashboard-view` class, and every rule here is scoped to it. The content
|
|
3
|
+
* column is a ContentLayout grid; each section spans its full width and lays
|
|
4
|
+
* out its own children, because the grid's breakpoints follow the viewport,
|
|
5
|
+
* not the narrower column beside the side navigation. */
|
|
6
|
+
|
|
7
|
+
@layer app {
|
|
8
|
+
.dashboard-view {
|
|
9
|
+
& .titlebar {
|
|
10
|
+
grid-column: 1 / -1;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-wrap: wrap;
|
|
13
|
+
align-items: flex-end;
|
|
14
|
+
justify-content: space-between;
|
|
15
|
+
gap: var(--container-gap-default);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
& .titlebar h1 {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: var(--space-100);
|
|
22
|
+
margin: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
& .section {
|
|
26
|
+
grid-column: 1 / -1;
|
|
27
|
+
display: grid;
|
|
28
|
+
gap: var(--container-gap-default);
|
|
29
|
+
align-content: start;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
& .section.narrow {
|
|
33
|
+
max-inline-size: 48rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
& .tiles,
|
|
37
|
+
& .cards {
|
|
38
|
+
display: grid;
|
|
39
|
+
gap: var(--container-gap-default);
|
|
40
|
+
margin: 0;
|
|
41
|
+
padding: 0;
|
|
42
|
+
list-style: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
& .tiles {
|
|
46
|
+
grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
& .cards {
|
|
50
|
+
grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
& .figure {
|
|
54
|
+
margin: 0;
|
|
55
|
+
font-size: var(--typography-heading-2-font-size);
|
|
56
|
+
line-height: var(--typography-heading-2-line-height);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
& .muted {
|
|
60
|
+
color: var(--color-text-muted);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
& .actions {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-wrap: wrap;
|
|
66
|
+
align-items: center;
|
|
67
|
+
gap: var(--space-100);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
& .panel {
|
|
71
|
+
inline-size: 20rem;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
& .details {
|
|
75
|
+
display: grid;
|
|
76
|
+
grid-template-columns: max-content 1fr;
|
|
77
|
+
gap: var(--space-100) var(--container-gap-default);
|
|
78
|
+
margin: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
& .details dd {
|
|
82
|
+
margin: 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Below this width the aside moves under the content. */
|
|
87
|
+
@media (width < 62rem) {
|
|
88
|
+
.dashboard-view {
|
|
89
|
+
grid-template-columns: 1fr;
|
|
90
|
+
/* Stacked, the view grows with its content and the page scrolls. */
|
|
91
|
+
block-size: auto;
|
|
92
|
+
|
|
93
|
+
& .panel {
|
|
94
|
+
inline-size: auto;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<% if (intl) { -%>
|
|
2
|
+
import type { MessageKey } from "#i18n/en.js";
|
|
3
|
+
|
|
4
|
+
<% } -%>
|
|
5
|
+
/** An instance's lifecycle state; its label comes from <%= intl ? "the catalogs" : "STATUS_LABELS" %>. */
|
|
6
|
+
export type InstanceStatus = "running" | "stopped" | "starting";
|
|
7
|
+
|
|
8
|
+
/** A virtual machine or container, as the dashboard lists it. */
|
|
9
|
+
export interface Instance {
|
|
10
|
+
/** Unique name, which also identifies the instance in the list. */
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly status: InstanceStatus;
|
|
13
|
+
/** The Ubuntu release the instance was launched from, by its product name. */
|
|
14
|
+
readonly release: string;
|
|
15
|
+
/** Address on the default bridge; empty while the instance is stopped. */
|
|
16
|
+
readonly ipv4: string;
|
|
17
|
+
/** Memory limit, in gibibytes. */
|
|
18
|
+
readonly memoryGib: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** An Ubuntu release offered on the overview. */
|
|
22
|
+
export interface Release {
|
|
23
|
+
/** The product name, which is not translated. */
|
|
24
|
+
readonly name: string;
|
|
25
|
+
<% if (intl) { -%>
|
|
26
|
+
/** The catalog key of the release's one-line description. */
|
|
27
|
+
readonly summaryKey: MessageKey;
|
|
28
|
+
<% } else { -%>
|
|
29
|
+
/** The release's one-line description. */
|
|
30
|
+
readonly summary: string;
|
|
31
|
+
<% } -%>
|
|
32
|
+
readonly channel: "stable" | "beta";
|
|
33
|
+
readonly kernel: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** One entry of the activity feed. */
|
|
37
|
+
export interface ActivityEvent {
|
|
38
|
+
readonly key: string;
|
|
39
|
+
<% if (intl) { -%>
|
|
40
|
+
/**
|
|
41
|
+
* Who acted: a person's name, shown as is, or the catalog key of a system
|
|
42
|
+
* actor such as the scheduler.
|
|
43
|
+
*/
|
|
44
|
+
readonly actor: { readonly name: string } | { readonly key: MessageKey };
|
|
45
|
+
<% } else { -%>
|
|
46
|
+
/** Who acted: a person, or a system actor such as the scheduler. */
|
|
47
|
+
readonly actor: string;
|
|
48
|
+
<% } -%>
|
|
49
|
+
/** How long ago it happened, in minutes; shown as a relative time. */
|
|
50
|
+
readonly minutesAgo: number;
|
|
51
|
+
<% if (intl) { -%>
|
|
52
|
+
/** The catalog key of the event's text, and the values it interpolates. */
|
|
53
|
+
readonly messageKey: MessageKey;
|
|
54
|
+
readonly values: Readonly<Record<string, string>>;
|
|
55
|
+
<% } else { -%>
|
|
56
|
+
/** The event's text. */
|
|
57
|
+
readonly message: string;
|
|
58
|
+
<% } -%>
|
|
59
|
+
/** Status of the event, mapped onto the timeline's criticality. */
|
|
60
|
+
readonly criticality?: "success" | "warning" | "error";
|
|
61
|
+
}
|
|
@@ -3,7 +3,11 @@ import { useTranslation } from "@canonical/i18n-react";
|
|
|
3
3
|
<% } -%>
|
|
4
4
|
import { Head } from "@canonical/react-head";
|
|
5
5
|
import { type ReactElement, Suspense } from "react";
|
|
6
|
+
<% if (intl) { -%>
|
|
7
|
+
import { CodeMessage, ExampleComponent, LazyComponent } from "#lib/index.js";
|
|
8
|
+
<% } else { -%>
|
|
6
9
|
import { ExampleComponent, LazyComponent } from "#lib/index.js";
|
|
10
|
+
<% } -%>
|
|
7
11
|
|
|
8
12
|
export default function HomePage(): ReactElement {
|
|
9
13
|
<% if (intl) { -%>
|
|
@@ -25,13 +29,17 @@ export default function HomePage(): ReactElement {
|
|
|
25
29
|
<% if (intl) { -%>
|
|
26
30
|
<h2>{t("home.exampleHeading")}</h2>
|
|
27
31
|
{/*
|
|
28
|
-
The explanatory paragraphs
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
The explanatory paragraphs name files and APIs. They are translated
|
|
33
|
+
like the rest of the page; the names themselves sit between backticks
|
|
34
|
+
in every catalog, and CodeMessage renders them as code.
|
|
31
35
|
*/}
|
|
36
|
+
<CodeMessage message={t("home.exampleBody")} />
|
|
37
|
+
<ExampleComponent>{t("home.exampleGreeting")}</ExampleComponent>
|
|
38
|
+
|
|
39
|
+
<h2>{t("home.streamingHeading")}</h2>
|
|
40
|
+
<CodeMessage message={t("home.streamingBody")} />
|
|
32
41
|
<% } else { -%>
|
|
33
42
|
<h2>Example component</h2>
|
|
34
|
-
<% } -%>
|
|
35
43
|
<p>
|
|
36
44
|
A plain component scaffolded alongside the app. It ships with a
|
|
37
45
|
Storybook story (<code>ExampleComponent.stories.tsx</code>) and a test —
|
|
@@ -39,19 +47,16 @@ export default function HomePage(): ReactElement {
|
|
|
39
47
|
</p>
|
|
40
48
|
<ExampleComponent>Hello from ExampleComponent</ExampleComponent>
|
|
41
49
|
|
|
42
|
-
<% if (intl) { -%>
|
|
43
|
-
<h2>{t("home.streamingHeading")}</h2>
|
|
44
|
-
<% } else { -%>
|
|
45
50
|
<h2>Streaming with Suspense</h2>
|
|
46
51
|
<% } -%>
|
|
47
|
-
<% if (spa) { -%>
|
|
52
|
+
<% if (spa && !intl) { -%>
|
|
48
53
|
<p>
|
|
49
54
|
<code>LazyComponent</code> reads a synthetic delayed fetch with React 19{" "}
|
|
50
55
|
<code>use()</code>, so it suspends. Inside this <code>Suspense</code>{" "}
|
|
51
56
|
boundary the rest of the page renders immediately and the fallback
|
|
52
57
|
stands in until the resolved content swaps itself back in.
|
|
53
58
|
</p>
|
|
54
|
-
<% } else { -%>
|
|
59
|
+
<% } else if (!intl) { -%>
|
|
55
60
|
<p>
|
|
56
61
|
<code>LazyComponent</code> reads a synthetic delayed fetch with React 19{" "}
|
|
57
62
|
<code>use()</code>, so it suspends. Inside this <code>Suspense</code>{" "}
|