@umituz/web-dashboard 7.2.0 → 7.3.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-dashboard",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "Installable app skeleton for the fleet — layouts, analytics (dependency-free SVG charts), calendar, onboarding flow permissions/module registry; udb-* stylesheet on design-system tokens",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { render, screen, fireEvent } from "@testing-library/react";
|
|
3
|
+
import { lazy } from "react";
|
|
3
4
|
import { MemoryRouter, Routes, Route } from "react-router";
|
|
4
5
|
import { Home } from "lucide-react";
|
|
5
6
|
import { DashboardLayout } from "./DashboardLayout";
|
|
@@ -176,3 +177,24 @@ describe("DashboardSidebar (secondaryLabel)", () => {
|
|
|
176
177
|
window.localStorage.removeItem("udb-collapsed-test");
|
|
177
178
|
});
|
|
178
179
|
});
|
|
180
|
+
|
|
181
|
+
describe("DashboardLayout (contentFallback)", () => {
|
|
182
|
+
const NeverResolves = lazy(() => new Promise<{ default: React.ComponentType }>(() => {}));
|
|
183
|
+
|
|
184
|
+
it("shows the fallback while a lazy route is suspending", () => {
|
|
185
|
+
render(
|
|
186
|
+
<MemoryRouter initialEntries={["/"]}>
|
|
187
|
+
<Routes>
|
|
188
|
+
<Route
|
|
189
|
+
path="*"
|
|
190
|
+
element={<DashboardLayout config={config} labels={labels} contentFallback={<div>loading-page</div>} />}
|
|
191
|
+
>
|
|
192
|
+
<Route path="*" element={<NeverResolves />} />
|
|
193
|
+
</Route>
|
|
194
|
+
</Routes>
|
|
195
|
+
</MemoryRouter>
|
|
196
|
+
);
|
|
197
|
+
const main = document.getElementById("udb-main");
|
|
198
|
+
expect(main?.textContent).toContain("loading-page");
|
|
199
|
+
});
|
|
200
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useEffect, useRef, type ReactNode } from "react";
|
|
1
|
+
import { Suspense, useState, useEffect, useRef, type ReactNode } from "react";
|
|
2
2
|
import { useLocation, useNavigate, Outlet, Navigate } from "react-router";
|
|
3
3
|
import { Skeleton } from "@umituz/web-design-system/atoms";
|
|
4
4
|
import { CommandPalette, type CommandGroup, type CommandItem } from "@umituz/web-design-system/organisms";
|
|
@@ -26,6 +26,7 @@ interface DashboardLayoutProps {
|
|
|
26
26
|
collapsedStorageKey?: string;
|
|
27
27
|
footer?: ReactNode;
|
|
28
28
|
mainId?: string;
|
|
29
|
+
contentFallback?: ReactNode;
|
|
29
30
|
formatNotificationTime?: (createdAt: Date | string | number) => string;
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -55,6 +56,7 @@ export const DashboardLayout = ({
|
|
|
55
56
|
collapsedStorageKey,
|
|
56
57
|
footer,
|
|
57
58
|
mainId = "udb-main",
|
|
59
|
+
contentFallback,
|
|
58
60
|
formatNotificationTime,
|
|
59
61
|
}: DashboardLayoutProps) => {
|
|
60
62
|
const location = useLocation();
|
|
@@ -261,7 +263,9 @@ export const DashboardLayout = ({
|
|
|
261
263
|
</div>
|
|
262
264
|
|
|
263
265
|
) : (
|
|
264
|
-
<
|
|
266
|
+
<Suspense fallback={contentFallback ?? null}>
|
|
267
|
+
<Outlet />
|
|
268
|
+
</Suspense>
|
|
265
269
|
)}
|
|
266
270
|
</main>
|
|
267
271
|
|