Skip to content

Commit a00876a

Browse files
authored
Publisher pages lazy import, pt6 (#5477)
* feature: lazy load more brand store pages * fix: ignore AbortError when using AbourController.abort()
1 parent 42a2f65 commit a00876a

4 files changed

Lines changed: 20 additions & 16 deletions

File tree

static/js/publisher/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import PublisherLayout from "./layouts/PublisherLayout";
1010
import SnapsManagementLayout from "./layouts/SnapsManagementLayout";
1111
import ModelDetailsPageLayout from "./layouts/ModelDetailsPageLayout/ModelPageLayout";
1212

13-
import BrandStoreSettings from "./pages/BrandStoreSettings";
14-
import Members from "./pages/Members";
15-
import SigningKeys from "./pages/SigningKeys";
16-
import Snaps from "./pages/Snaps";
1713
import ValidationSet from "./pages/ValidationSet";
1814
import ValidationSets from "./pages/ValidationSets";
1915
import AccountKeys from "./pages/AccountKeys";
@@ -39,6 +35,12 @@ const RequestReservedName = importComponent(
3935
const Models = importComponent(() => import("./pages/Models"));
4036
const Model = importComponent(() => import("./pages/Model"));
4137
const Policies = importComponent(() => import("./pages/Model/Policies"));
38+
const BrandStoreSettings = importComponent(
39+
() => import("./pages/BrandStoreSettings"),
40+
);
41+
const Members = importComponent(() => import("./pages/Members"));
42+
const SigningKeys = importComponent(() => import("./pages/SigningKeys"));
43+
const Snaps = importComponent(() => import("./pages/Snaps"));
4244

4345
Sentry.init({
4446
dsn: window.SENTRY_DSN,

static/js/publisher/pages/BrandStoreSettings/BrandStoreSettings.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { useQuery } from "react-query";
44
import {
55
Row,
66
Col,
7-
Spinner,
87
Form,
98
Input,
109
PasswordToggle,
1110
Button,
1211
} from "@canonical/react-components";
12+
import Loader from "../../components/Loader";
1313

1414
function BrandStoreSettings() {
1515
const { id } = useParams();
@@ -60,11 +60,7 @@ function BrandStoreSettings() {
6060

6161
return (
6262
<>
63-
{isLoading && (
64-
<div className="u-fixed-width">
65-
<Spinner text="Loading..." />
66-
</div>
67-
)}
63+
{isLoading && <Loader />}
6864

6965
{!isLoading && status === "success" && data && (
7066
<>

static/js/publisher/pages/Snaps/Snaps.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useState, useEffect } from "react";
22
import { useParams, Link } from "react-router-dom";
33
import { useAtomValue } from "jotai";
44
import {
5-
Spinner,
65
Row,
76
Col,
87
Button,
@@ -26,6 +25,7 @@ import IncludedSnapsTable from "./IncludedSnapsTable";
2625
import { setPageTitle } from "../../utils";
2726
import type { Store, Snap, SnapsList, Member } from "../../types/shared";
2827
import { PortalEntrance } from "../Portals/Portals";
28+
import Loader from "../../components/Loader";
2929

3030
function Snaps() {
3131
const { id } = useParams();
@@ -326,9 +326,7 @@ function Snaps() {
326326
return (
327327
<>
328328
{snapsLoading && membersLoading ? (
329-
<div className="u-fixed-width">
330-
<Spinner text="Loading&hellip;" />
331-
</div>
329+
<Loader />
332330
) : currentStore && isReviewerAndPublisherOnly ? (
333331
<ReviewerAndPublisher />
334332
) : currentStore && isReviewerOnly ? (
@@ -362,7 +360,7 @@ function Snaps() {
362360
</>
363361
)}
364362
<div className="u-fixed-width">
365-
{isReloading && <Spinner text="Loading&hellip;" />}
363+
{isReloading && <Loader />}
366364

367365
{!isReloading && currentStore && (
368366
<>

static/js/publisher/utils/getPolicies.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ const getPolicies = async ({
2323
signal,
2424
});
2525
}),
26-
);
26+
).catch((e: Error) => {
27+
if (e instanceof DOMException && e.name == "AbortError") {
28+
// swallow the error because it's actually deliberate
29+
} else {
30+
console.error(e);
31+
}
32+
});
33+
34+
if (!data) return;
2735

2836
const allPolicies = await Promise.all(
2937
data.map(async (res) => {

0 commit comments

Comments
 (0)