-
Notifications
You must be signed in to change notification settings - Fork 2
Fix console stuck on loading screen due to MSW metadata route mismatch #518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,98 +48,48 @@ export function createHandlers(baseUrl: string, kernel: ObjectKernel, driver: In | |
| return HttpResponse.json(response, { status: 200 }); | ||
| }), | ||
|
|
||
| // ── Metadata: list objects ─────────────────────────────────────────── | ||
| http.get(`${prefix}${baseUrl}/meta/objects`, async () => { | ||
| const response = await protocol.getMetaItems({ type: 'object' }); | ||
| // ── Metadata: list items by type ──────────────────────────────────── | ||
| // The client sends GET /meta/<type> where <type> is singular (e.g. app, | ||
| // object, dashboard, report, page). We also keep the legacy plural | ||
| // routes (/meta/apps, /meta/objects, …) for backward compatibility. | ||
| // A single dynamic handler covers both forms. | ||
| http.get(`${prefix}${baseUrl}/meta/:type`, async ({ params }) => { | ||
| const metadataType = params.type as string; | ||
| const response = await protocol.getMetaItems({ type: metadataType }); | ||
| return HttpResponse.json(response, { status: 200 }); | ||
| }), | ||
| http.get(`${prefix}${baseUrl}/metadata/objects`, async () => { | ||
| const response = await protocol.getMetaItems({ type: 'object' }); | ||
| http.get(`${prefix}${baseUrl}/metadata/:type`, async ({ params }) => { | ||
| const metadataType = params.type as string; | ||
| const response = await protocol.getMetaItems({ type: metadataType }); | ||
| return HttpResponse.json(response, { status: 200 }); | ||
| }), | ||
|
|
||
| // ── Metadata: single object (legacy /meta/objects/:name) ───────────── | ||
| http.get(`${prefix}${baseUrl}/meta/objects/:objectName`, async ({ params }) => { | ||
| // ── Metadata: single item by type + name ───────────────────────────── | ||
| http.get(`${prefix}${baseUrl}/meta/:type/:name`, async ({ params }) => { | ||
| try { | ||
| const response = await protocol.getMetaItem({ | ||
| type: 'object', | ||
| name: params.objectName as string | ||
| }); | ||
| return HttpResponse.json(response || { error: 'Not found' }, { status: response ? 200 : 404 }); | ||
| } catch (e) { | ||
| return HttpResponse.json({ error: String(e) }, { status: 500 }); | ||
| } | ||
| }), | ||
|
|
||
| // ── Metadata: single object (/meta/object/:name & /metadata/object/:name) | ||
| http.get(`${prefix}${baseUrl}/meta/object/:objectName`, async ({ params }) => { | ||
| try { | ||
| const response = await protocol.getMetaItem({ | ||
| type: 'object', | ||
| name: params.objectName as string | ||
| type: params.type as string, | ||
| name: params.name as string | ||
| }); | ||
| const payload = (response && response.item) ? response.item : response; | ||
| return HttpResponse.json(payload || { error: 'Not found' }, { status: payload ? 200 : 404 }); | ||
| } catch (e) { | ||
| console.error('[MSW] error getting meta item', e); | ||
| return HttpResponse.json({ error: String(e) }, { status: 500 }); | ||
| } | ||
|
Comment on lines
76
to
78
|
||
| }), | ||
|
|
||
| http.get(`${prefix}${baseUrl}/metadata/object/:objectName`, async ({ params }) => { | ||
| http.get(`${prefix}${baseUrl}/metadata/:type/:name`, async ({ params }) => { | ||
| try { | ||
| const response = await protocol.getMetaItem({ | ||
| type: 'object', | ||
| name: params.objectName as string | ||
| type: params.type as string, | ||
| name: params.name as string | ||
| }); | ||
| const payload = (response && response.item) ? response.item : response; | ||
| return HttpResponse.json(payload || { error: 'Not found' }, { status: payload ? 200 : 404 }); | ||
| } catch (e) { | ||
| console.error('[MSW] error getting meta item', e); | ||
| return HttpResponse.json({ error: String(e) }, { status: 500 }); | ||
| } | ||
| }), | ||
|
Comment on lines
+56
to
91
|
||
|
|
||
| // ── Metadata: apps ────────────────────────────────────────────────── | ||
| http.get(`${prefix}${baseUrl}/meta/apps`, async () => { | ||
| const response = await protocol.getMetaItems({ type: 'app' }); | ||
| return HttpResponse.json(response, { status: 200 }); | ||
| }), | ||
| http.get(`${prefix}${baseUrl}/metadata/apps`, async () => { | ||
| const response = await protocol.getMetaItems({ type: 'app' }); | ||
| return HttpResponse.json(response, { status: 200 }); | ||
| }), | ||
|
|
||
| // ── Metadata: dashboards ──────────────────────────────────────────── | ||
| http.get(`${prefix}${baseUrl}/meta/dashboards`, async () => { | ||
| const response = await protocol.getMetaItems({ type: 'dashboard' }); | ||
| return HttpResponse.json(response, { status: 200 }); | ||
| }), | ||
| http.get(`${prefix}${baseUrl}/metadata/dashboards`, async () => { | ||
| const response = await protocol.getMetaItems({ type: 'dashboard' }); | ||
| return HttpResponse.json(response, { status: 200 }); | ||
| }), | ||
|
|
||
| // ── Metadata: reports ─────────────────────────────────────────────── | ||
| http.get(`${prefix}${baseUrl}/meta/reports`, async () => { | ||
| const response = await protocol.getMetaItems({ type: 'report' }); | ||
| return HttpResponse.json(response, { status: 200 }); | ||
| }), | ||
| http.get(`${prefix}${baseUrl}/metadata/reports`, async () => { | ||
| const response = await protocol.getMetaItems({ type: 'report' }); | ||
| return HttpResponse.json(response, { status: 200 }); | ||
| }), | ||
|
|
||
| // ── Metadata: pages ───────────────────────────────────────────────── | ||
| http.get(`${prefix}${baseUrl}/meta/pages`, async () => { | ||
| const response = await protocol.getMetaItems({ type: 'page' }); | ||
| return HttpResponse.json(response, { status: 200 }); | ||
| }), | ||
| http.get(`${prefix}${baseUrl}/metadata/pages`, async () => { | ||
| const response = await protocol.getMetaItems({ type: 'page' }); | ||
| return HttpResponse.json(response, { status: 200 }); | ||
| }), | ||
|
|
||
| // ── Data: find all ────────────────────────────────────────────────── | ||
| http.get(`${prefix}${baseUrl}/data/:objectName`, async ({ params, request }) => { | ||
| const url = new URL(request.url); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Empty state implementation is missing a visual icon/media element that is consistently used across other Empty states in the codebase. For consistency and better UX, consider adding an icon similar to other error/empty states:
You'll need to import AlertCircle or a similar icon from lucide-react. See DashboardView.tsx:39-48, ErrorBoundary.tsx:30-38, or PageView.tsx:25-34 for examples of this pattern.