Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- platform/modules/amazon_profit.py +17 -0
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
- web/src/customer-grid/CustomerGrid.tsx +11 -4
- web/src/customer-grid/apiBridge.ts +29 -9
- web/src/customer-grid/useCustomerData.ts +28 -7
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "5788700e3",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
5788700e3
|
platform/modules/amazon_profit.py
CHANGED
|
@@ -1384,6 +1384,7 @@ def ensure_table(st, username, *, table_key=None, label=None, fields=None, owned
|
|
| 1384 |
todo = [spec for spec in specs if _stale(*spec)]
|
| 1385 |
result = specs[0][0] if table_key is not None else TABLE_KEY
|
| 1386 |
if not todo:
|
|
|
|
| 1387 |
return result
|
| 1388 |
created = dt.datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
|
| 1389 |
|
|
@@ -1415,9 +1416,25 @@ def ensure_table(st, username, *, table_key=None, label=None, fields=None, owned
|
|
| 1415 |
for key, want_label, _wanted in todo:
|
| 1416 |
if ut.get_one(key, st) is None:
|
| 1417 |
raise TableRefused(f"The store did not keep {want_label}. Refresh again.")
|
|
|
|
| 1418 |
return result
|
| 1419 |
|
| 1420 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1421 |
def table_rows(st, table_key=TABLE_KEY):
|
| 1422 |
import core.user_tables as ut
|
| 1423 |
return dict((ut.get_one(table_key, st) or {}).get("rows") or {})
|
|
|
|
| 1384 |
todo = [spec for spec in specs if _stale(*spec)]
|
| 1385 |
result = specs[0][0] if table_key is not None else TABLE_KEY
|
| 1386 |
if not todo:
|
| 1387 |
+
_ensure_table_grants(st, [spec[0] for spec in specs])
|
| 1388 |
return result
|
| 1389 |
created = dt.datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
|
| 1390 |
|
|
|
|
| 1416 |
for key, want_label, _wanted in todo:
|
| 1417 |
if ut.get_one(key, st) is None:
|
| 1418 |
raise TableRefused(f"The store did not keep {want_label}. Refresh again.")
|
| 1419 |
+
_ensure_table_grants(st, [spec[0] for spec in specs])
|
| 1420 |
return result
|
| 1421 |
|
| 1422 |
|
| 1423 |
+
def _ensure_table_grants(st, keys):
|
| 1424 |
+
"""Add the everyone view grant to each stored module table that lacks it; keep other entries."""
|
| 1425 |
+
# A module table is readable by every tenant user through the may_open door; scope stays with perm_scope.
|
| 1426 |
+
import core.user_tables as ut
|
| 1427 |
+
from core import shares
|
| 1428 |
+
for key in keys:
|
| 1429 |
+
if ut.get_one(key, st) is None:
|
| 1430 |
+
continue
|
| 1431 |
+
held = shares.grants("database", key, st=st)
|
| 1432 |
+
if not any(e.get("user") == shares.EVERYONE for e in held["entries"]):
|
| 1433 |
+
shares.set_grants("database", key,
|
| 1434 |
+
held["entries"] + [{"user": shares.EVERYONE, "role": "view"}],
|
| 1435 |
+
owner=held["owner"] or WRITER, st=st)
|
| 1436 |
+
|
| 1437 |
+
|
| 1438 |
def table_rows(st, table_key=TABLE_KEY):
|
| 1439 |
import core.user_tables as ut
|
| 1440 |
return dict((ut.get_one(table_key, st) or {}).get("rows") or {})
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
b170715059ec79d07d8585c9d8b6a3583be797953ee283f05301070f39217cf1
|
web/src/customer-grid/CustomerGrid.tsx
CHANGED
|
@@ -39,7 +39,7 @@ import { acceptsQueryPreview, routeQueryViewMutation } from "./queryPreview";
|
|
| 39 |
// only its own source text could otherwise be checked.
|
| 40 |
import { PAGE_SIZES, fetchAggregates, fetchTableWindow, personalGridLayout, readPageSize, recordIdsKey,
|
| 41 |
writePageSize } from "./apiBridge";
|
| 42 |
-
import { DATABASE_TIMEOUT_MESSAGE } from "./apiBridge";
|
| 43 |
import { GridPager, pageLabel } from "./GridPager";
|
| 44 |
import { GridActivity, useNativeActivity } from "./GridActivity";
|
| 45 |
import { withoutAppliedLeaves } from "./drillLimits";
|
|
@@ -2841,6 +2841,7 @@ function CustomerGridSurface({
|
|
| 2841 |
workspaceFirstLoad,
|
| 2842 |
workspaceError,
|
| 2843 |
workspaceRefreshFailed,
|
|
|
|
| 2844 |
retryWorkspace,
|
| 2845 |
overlayEdits,
|
| 2846 |
setOverlayEdits,
|
|
@@ -11578,7 +11579,7 @@ function CustomerGridSurface({
|
|
| 11578 |
/* ⭐ W50-T11 / D-592 — the rail draws a skeleton while `/workspace` is in flight
|
| 11579 |
instead of asserting an empty list. `workspaceLoading` is the predicate this file
|
| 11580 |
already computes for the right pane, passed rather than re-derived in the rail. */
|
| 11581 |
-
loading={workspaceLoading}
|
| 11582 |
alertCounts={alertCounts}
|
| 11583 |
countNotes={countNotes}
|
| 11584 |
activeViewId={activeViewId}
|
|
@@ -11862,13 +11863,18 @@ function CustomerGridSurface({
|
|
| 11862 |
live). Both sides are prefixed so neither can be spelled by the other. */}
|
| 11863 |
<main className="cg-main" key={`cg-main:${scope}`}>
|
| 11864 |
<ProductsFrozenNotice payload={scope === "product" ? payload : null} />
|
| 11865 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11866 |
title={workspaceError.replace(/[\u2013\u2014]/g, ",")}>
|
| 11867 |
<span className="cg-more-note">{workspaceError === DATABASE_TIMEOUT_MESSAGE
|
| 11868 |
? DATABASE_TIMEOUT_MESSAGE : "Saved views unavailable."}</span>
|
| 11869 |
<button type="button" className="cg-link-btn" disabled={workspacePending}
|
| 11870 |
onClick={retryWorkspace}>Retry</button>
|
| 11871 |
</div>}
|
|
|
|
| 11872 |
{rowLoadingMessage && <div className="cg-more" role="status" aria-busy={!mirrorUnavailable}>
|
| 11873 |
<span className="cg-more-note">{rowLoadingMessage}</span>
|
| 11874 |
</div>}
|
|
@@ -13120,11 +13126,12 @@ function CustomerGridSurface({
|
|
| 13120 |
</div>
|
| 13121 |
</>
|
| 13122 |
)}
|
|
|
|
| 13123 |
{/* ⭐⭐ HOTFIX 2026-09-23 — THE PAGER. One page of a read-through table at a time, and
|
| 13124 |
every page reachable: `matched` is the server's own count, so this is a view onto the
|
| 13125 |
whole population rather than a cap on it (standing rule 1). Grouped, each open group
|
| 13126 |
pages on its own footer instead. */}
|
| 13127 |
-
{!isPagedOdooApplication && <div className="cg-grid-footer">
|
| 13128 |
{!nativeActivity && !rowsLoading && !mirrorUnavailable && <>
|
| 13129 |
{((!config.groupBy && (displayMode === "grid" || (serverWindowed && displayMode === "list")))
|
| 13130 |
|| (serverWindowed && displayMode === "gallery")) && !loading && (
|
|
|
|
| 39 |
// only its own source text could otherwise be checked.
|
| 40 |
import { PAGE_SIZES, fetchAggregates, fetchTableWindow, personalGridLayout, readPageSize, recordIdsKey,
|
| 41 |
writePageSize } from "./apiBridge";
|
| 42 |
+
import { ACCESS_REFUSED_MESSAGE, DATABASE_TIMEOUT_MESSAGE } from "./apiBridge";
|
| 43 |
import { GridPager, pageLabel } from "./GridPager";
|
| 44 |
import { GridActivity, useNativeActivity } from "./GridActivity";
|
| 45 |
import { withoutAppliedLeaves } from "./drillLimits";
|
|
|
|
| 2841 |
workspaceFirstLoad,
|
| 2842 |
workspaceError,
|
| 2843 |
workspaceRefreshFailed,
|
| 2844 |
+
accessRefused,
|
| 2845 |
retryWorkspace,
|
| 2846 |
overlayEdits,
|
| 2847 |
setOverlayEdits,
|
|
|
|
| 11579 |
/* ⭐ W50-T11 / D-592 — the rail draws a skeleton while `/workspace` is in flight
|
| 11580 |
instead of asserting an empty list. `workspaceLoading` is the predicate this file
|
| 11581 |
already computes for the right pane, passed rather than re-derived in the rail. */
|
| 11582 |
+
loading={workspaceLoading && !accessRefused}
|
| 11583 |
alertCounts={alertCounts}
|
| 11584 |
countNotes={countNotes}
|
| 11585 |
activeViewId={activeViewId}
|
|
|
|
| 11863 |
live). Both sides are prefixed so neither can be spelled by the other. */}
|
| 11864 |
<main className="cg-main" key={`cg-main:${scope}`}>
|
| 11865 |
<ProductsFrozenNotice payload={scope === "product" ? payload : null} />
|
| 11866 |
+
{/* A 403 is final: one plain line, no Retry, no skeleton, no grid. */}
|
| 11867 |
+
{accessRefused && <div className="cg-more" role="status" data-access-refused>
|
| 11868 |
+
<span className="cg-more-note">{ACCESS_REFUSED_MESSAGE}</span>
|
| 11869 |
+
</div>}
|
| 11870 |
+
{workspaceError && !accessRefused && <div className="cg-more" role="alert" data-workspace-error
|
| 11871 |
title={workspaceError.replace(/[\u2013\u2014]/g, ",")}>
|
| 11872 |
<span className="cg-more-note">{workspaceError === DATABASE_TIMEOUT_MESSAGE
|
| 11873 |
? DATABASE_TIMEOUT_MESSAGE : "Saved views unavailable."}</span>
|
| 11874 |
<button type="button" className="cg-link-btn" disabled={workspacePending}
|
| 11875 |
onClick={retryWorkspace}>Retry</button>
|
| 11876 |
</div>}
|
| 11877 |
+
{accessRefused ? null : <>
|
| 11878 |
{rowLoadingMessage && <div className="cg-more" role="status" aria-busy={!mirrorUnavailable}>
|
| 11879 |
<span className="cg-more-note">{rowLoadingMessage}</span>
|
| 11880 |
</div>}
|
|
|
|
| 13126 |
</div>
|
| 13127 |
</>
|
| 13128 |
)}
|
| 13129 |
+
</>}
|
| 13130 |
{/* ⭐⭐ HOTFIX 2026-09-23 — THE PAGER. One page of a read-through table at a time, and
|
| 13131 |
every page reachable: `matched` is the server's own count, so this is a view onto the
|
| 13132 |
whole population rather than a cap on it (standing rule 1). Grouped, each open group
|
| 13133 |
pages on its own footer instead. */}
|
| 13134 |
+
{!isPagedOdooApplication && !accessRefused && <div className="cg-grid-footer">
|
| 13135 |
{!nativeActivity && !rowsLoading && !mirrorUnavailable && <>
|
| 13136 |
{((!config.groupBy && (displayMode === "grid" || (serverWindowed && displayMode === "list")))
|
| 13137 |
|| (serverWindowed && displayMode === "gallery")) && !loading && (
|
web/src/customer-grid/apiBridge.ts
CHANGED
|
@@ -262,8 +262,10 @@ let writeSession = 0;
|
|
| 262 |
* undone on screen, which is worse than the wait it replaced.
|
| 263 |
*/
|
| 264 |
const wsCache = new Map<string, { at: number; ws: GridWorkspace; current: boolean }>();
|
| 265 |
-
type WorkspaceRead = { ws: GridWorkspace | null; failure?: string; superseded?: boolean };
|
| 266 |
-
|
|
|
|
|
|
|
| 267 |
export const WORKSPACE_ERROR_EVENT = "aios:workspace-error";
|
| 268 |
// Pending reads belong to the same memo, not a second result cache. Uncached post-write
|
| 269 |
// reads replace the joinable flight; an older completion must not remove that newer one.
|
|
@@ -548,6 +550,19 @@ function refusalCode(body: unknown): string {
|
|
| 548 |
return typeof code === "string" ? code : "";
|
| 549 |
}
|
| 550 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 551 |
/**
|
| 552 |
* ⛔ D-3495 (staging, 2026-09-29) — A `window_required` REFUSAL FROM THIS DOOR MEANS THE ROSTER
|
| 553 |
* WAS WRONG, so the memo is dropped right here, for every caller. The roster is memoised per
|
|
@@ -585,7 +600,8 @@ export async function fetchTopicRows(
|
|
| 585 |
if (offThread.ok || offThread.kind === "refused") {
|
| 586 |
if (handledSession(offThread.facts)) return null;
|
| 587 |
if (!offThread.ok) {
|
| 588 |
-
fail(refusalMessage(offThread.body, offThread.facts.status),
|
|
|
|
| 589 |
return null;
|
| 590 |
}
|
| 591 |
const carried = offThread.payload as CustomersPayload | null;
|
|
@@ -618,7 +634,7 @@ export async function fetchTopicRows(
|
|
| 618 |
// connected grid before the mirror's first sync) and the window route's own 409. Both name
|
| 619 |
// their cause and their fix; both used to render as "The server answered 503."
|
| 620 |
const refused = await readJson(res);
|
| 621 |
-
fail(refusalMessage(refused, res.status),
|
| 622 |
return null;
|
| 623 |
}
|
| 624 |
const body = (await readJson(res)) as CustomersPayload | null;
|
|
@@ -978,13 +994,15 @@ function connectedTables(abort: AbortSignal): Promise<Set<string> | null> {
|
|
| 978 |
export async function fetchTableWindow(
|
| 979 |
tableKey: string,
|
| 980 |
req: RowWindowRequest,
|
| 981 |
-
onFailure?: (reason: string) => void,
|
| 982 |
budget: WindowReadBudget = { remaining: WINDOW_REQUEST_BUDGET,
|
| 983 |
until: Date.now() + READ_DEADLINE_MS, recoveries: 0, mirrorRetries: 0 }
|
| 984 |
): Promise<WindowPayload | null> {
|
| 985 |
tableKey = tableKey === "customer" ? "customer_data" : tableKey === "product" ? "product_data" : tableKey;
|
| 986 |
// Optional record enrichment reports its failure inline without replacing the open drawer.
|
| 987 |
-
|
|
|
|
|
|
|
| 988 |
const path = windowRowsPath(tableKey, req);
|
| 989 |
const query = windowRowsPath(tableKey, { ...req, offset: 0, cursor: undefined });
|
| 990 |
const pagingKey = query;
|
|
@@ -1064,7 +1082,7 @@ export async function fetchTableWindow(
|
|
| 1064 |
await waitForMirror(delay);
|
| 1065 |
continue;
|
| 1066 |
}
|
| 1067 |
-
fail(refusalMessage(body, res.status));
|
| 1068 |
return null;
|
| 1069 |
}
|
| 1070 |
const page = windowPayload(body);
|
|
@@ -1649,13 +1667,14 @@ export async function fetchWorkspace(
|
|
| 1649 |
}
|
| 1650 |
const current = wsCache.get(scope);
|
| 1651 |
result = current && current.current && current !== fullAtStart && Date.now() - current.at < CUSTOMERS_FRESH_MS
|
| 1652 |
-
? { ws: workspaceWithoutMetricCells(current.ws) }
|
|
|
|
| 1653 |
}
|
| 1654 |
// A departed session or superseded request cannot publish even a failure into the new scope.
|
| 1655 |
if (requestEpoch !== wsCacheEpoch || result.superseded) return null;
|
| 1656 |
// Each joiner receives its own scoped status; response parsing/session handling happen once.
|
| 1657 |
const status: WorkspaceStatus = result.failure
|
| 1658 |
-
? { scope, state: "error", message: result.failure }
|
| 1659 |
: { scope, state: result.ws ? "ready" : "absent" };
|
| 1660 |
opts.onStatus?.(status);
|
| 1661 |
if (loud && result.failure) signal(WORKSPACE_ERROR_EVENT, status);
|
|
@@ -1701,6 +1720,7 @@ async function readWorkspace(scope: SurfaceScope, epoch: number, fieldsOnly: boo
|
|
| 1701 |
failure: refusalMessage(
|
| 1702 |
body, res.status,
|
| 1703 |
`The server answered ${res.status} for this table's saved views and columns.`),
|
|
|
|
| 1704 |
};
|
| 1705 |
}
|
| 1706 |
const ws = body as { workspace?: GridWorkspace } | null;
|
|
|
|
| 262 |
* undone on screen, which is worse than the wait it replaced.
|
| 263 |
*/
|
| 264 |
const wsCache = new Map<string, { at: number; ws: GridWorkspace; current: boolean }>();
|
| 265 |
+
type WorkspaceRead = { ws: GridWorkspace | null; failure?: string; forbidden?: boolean; superseded?: boolean };
|
| 266 |
+
/** `forbidden`: the server refused this person the table, so a retry cannot help. */
|
| 267 |
+
export type WorkspaceStatus = { scope: SurfaceScope; state: "ready" | "absent" | "error"; message?: string;
|
| 268 |
+
forbidden?: boolean };
|
| 269 |
export const WORKSPACE_ERROR_EVENT = "aios:workspace-error";
|
| 270 |
// Pending reads belong to the same memo, not a second result cache. Uncached post-write
|
| 271 |
// reads replace the joinable flight; an older completion must not remove that newer one.
|
|
|
|
| 550 |
return typeof code === "string" ? code : "";
|
| 551 |
}
|
| 552 |
|
| 553 |
+
/** The code a rows failure carries when the server refused this person the table. */
|
| 554 |
+
export const FORBIDDEN_CODE = "forbidden";
|
| 555 |
+
/** The one line a table shows when the server refuses this person access to it. */
|
| 556 |
+
export const ACCESS_REFUSED_MESSAGE = "You do not have access to this table. Ask an Administrator.";
|
| 557 |
+
/** A 403, or a refusal coded `forbidden`. Decided by status and code, never by the message text. */
|
| 558 |
+
export function isForbiddenRefusal(status: number, body: unknown): boolean {
|
| 559 |
+
return status === 403 || refusalCode(body) === FORBIDDEN_CODE;
|
| 560 |
+
}
|
| 561 |
+
/** A rows refusal's code, with every 403 normalised to `FORBIDDEN_CODE`. */
|
| 562 |
+
function rowsRefusalCode(status: number, body: unknown): string {
|
| 563 |
+
return isForbiddenRefusal(status, body) ? FORBIDDEN_CODE : refusalCode(body);
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
/**
|
| 567 |
* ⛔ D-3495 (staging, 2026-09-29) — A `window_required` REFUSAL FROM THIS DOOR MEANS THE ROSTER
|
| 568 |
* WAS WRONG, so the memo is dropped right here, for every caller. The roster is memoised per
|
|
|
|
| 600 |
if (offThread.ok || offThread.kind === "refused") {
|
| 601 |
if (handledSession(offThread.facts)) return null;
|
| 602 |
if (!offThread.ok) {
|
| 603 |
+
fail(refusalMessage(offThread.body, offThread.facts.status),
|
| 604 |
+
rowsRefusalCode(offThread.facts.status, offThread.body));
|
| 605 |
return null;
|
| 606 |
}
|
| 607 |
const carried = offThread.payload as CustomersPayload | null;
|
|
|
|
| 634 |
// connected grid before the mirror's first sync) and the window route's own 409. Both name
|
| 635 |
// their cause and their fix; both used to render as "The server answered 503."
|
| 636 |
const refused = await readJson(res);
|
| 637 |
+
fail(refusalMessage(refused, res.status), rowsRefusalCode(res.status, refused));
|
| 638 |
return null;
|
| 639 |
}
|
| 640 |
const body = (await readJson(res)) as CustomersPayload | null;
|
|
|
|
| 994 |
export async function fetchTableWindow(
|
| 995 |
tableKey: string,
|
| 996 |
req: RowWindowRequest,
|
| 997 |
+
onFailure?: (reason: string, code?: string) => void,
|
| 998 |
budget: WindowReadBudget = { remaining: WINDOW_REQUEST_BUDGET,
|
| 999 |
until: Date.now() + READ_DEADLINE_MS, recoveries: 0, mirrorRetries: 0 }
|
| 1000 |
): Promise<WindowPayload | null> {
|
| 1001 |
tableKey = tableKey === "customer" ? "customer_data" : tableKey === "product" ? "product_data" : tableKey;
|
| 1002 |
// Optional record enrichment reports its failure inline without replacing the open drawer.
|
| 1003 |
+
// A 403 carries `FORBIDDEN_CODE`, so the grid can paint its access line in place of an error card.
|
| 1004 |
+
const fail: (reason: string, code?: string) => void = onFailure
|
| 1005 |
+
?? ((reason) => signal(DATA_ERROR_EVENT, reason));
|
| 1006 |
const path = windowRowsPath(tableKey, req);
|
| 1007 |
const query = windowRowsPath(tableKey, { ...req, offset: 0, cursor: undefined });
|
| 1008 |
const pagingKey = query;
|
|
|
|
| 1082 |
await waitForMirror(delay);
|
| 1083 |
continue;
|
| 1084 |
}
|
| 1085 |
+
fail(refusalMessage(body, res.status), isForbiddenRefusal(res.status, body) ? FORBIDDEN_CODE : undefined);
|
| 1086 |
return null;
|
| 1087 |
}
|
| 1088 |
const page = windowPayload(body);
|
|
|
|
| 1667 |
}
|
| 1668 |
const current = wsCache.get(scope);
|
| 1669 |
result = current && current.current && current !== fullAtStart && Date.now() - current.at < CUSTOMERS_FRESH_MS
|
| 1670 |
+
? { ws: workspaceWithoutMetricCells(current.ws) }
|
| 1671 |
+
: { ws: null, failure: result.failure, ...(result.forbidden ? { forbidden: true } : {}) };
|
| 1672 |
}
|
| 1673 |
// A departed session or superseded request cannot publish even a failure into the new scope.
|
| 1674 |
if (requestEpoch !== wsCacheEpoch || result.superseded) return null;
|
| 1675 |
// Each joiner receives its own scoped status; response parsing/session handling happen once.
|
| 1676 |
const status: WorkspaceStatus = result.failure
|
| 1677 |
+
? { scope, state: "error", message: result.failure, ...(result.forbidden ? { forbidden: true } : {}) }
|
| 1678 |
: { scope, state: result.ws ? "ready" : "absent" };
|
| 1679 |
opts.onStatus?.(status);
|
| 1680 |
if (loud && result.failure) signal(WORKSPACE_ERROR_EVENT, status);
|
|
|
|
| 1720 |
failure: refusalMessage(
|
| 1721 |
body, res.status,
|
| 1722 |
`The server answered ${res.status} for this table's saved views and columns.`),
|
| 1723 |
+
...(isForbiddenRefusal(res.status, body) ? { forbidden: true } : {}),
|
| 1724 |
};
|
| 1725 |
}
|
| 1726 |
const ws = body as { workspace?: GridWorkspace } | null;
|
web/src/customer-grid/useCustomerData.ts
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
| 33 |
fetchAssignedCustomerRows,
|
| 34 |
fetchTopicRows,
|
| 35 |
fetchWorkspace,
|
|
|
|
| 36 |
peekWorkspace,
|
| 37 |
fetchPersonalGridLayout,
|
| 38 |
savePersonalGridLayout,
|
|
@@ -387,6 +388,15 @@ export function withoutRetiredChoiceEdits(
|
|
| 387 |
const EMPTY_OVERLAY_EDITS: OverlayEdits = {};
|
| 388 |
const ignoreOverlayEdits: Dispatch<SetStateAction<OverlayEdits>> = () => {};
|
| 389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
export interface CustomerData {
|
| 391 |
fields: Field[];
|
| 392 |
rawRows: Row[];
|
|
@@ -398,6 +408,8 @@ export interface CustomerData {
|
|
| 398 |
workspaceError: string | null;
|
| 399 |
/** `workspaceError` came from a refresh of an answered scope: the last workspace stays on screen. */
|
| 400 |
workspaceRefreshFailed: boolean;
|
|
|
|
|
|
|
| 401 |
retryWorkspace: () => void;
|
| 402 |
windowPending: boolean;
|
| 403 |
rowLoadingMessage: string | null;
|
|
@@ -492,8 +504,12 @@ export function useCustomerData(
|
|
| 492 |
const [data, setData] = useState<CustomersPayload | null>(() => suppliedPayload ? null : readInitialPayload());
|
| 493 |
const [windowPending, setWindowPending] = useState(false);
|
| 494 |
const [mirrorUnavailableScope, setMirrorUnavailableScope] = useState<SurfaceScope | null>(null);
|
| 495 |
-
const
|
| 496 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 497 |
else signal(DATA_ERROR_EVENT, reason);
|
| 498 |
}, [scope]);
|
| 499 |
// Item 3c: seeded SYNCHRONOUSLY from the cell journal, so a remounted grid
|
|
@@ -828,6 +844,7 @@ export function useCustomerData(
|
|
| 828 |
const error = status.state === "error" ? status.message ?? "Saved views could not be loaded." : null;
|
| 829 |
const stale = !!error && workspaceAnsweredRef.current === scope;
|
| 830 |
setWorkspaceRead({ scope, pending: false, error, stale });
|
|
|
|
| 831 |
if (!error) {
|
| 832 |
workspaceAnsweredRef.current = scope;
|
| 833 |
setWorkspaceAnswered(scope);
|
|
@@ -845,8 +862,8 @@ export function useCustomerData(
|
|
| 845 |
if (addressedView) markHostedOpen("open", scope);
|
| 846 |
setWindowPending(true);
|
| 847 |
setMirrorUnavailableScope(null);
|
| 848 |
-
const rowFailure = (reason: string) => {
|
| 849 |
-
if (!cancelled && seq === windowSeq.current) reportRowFailure(reason);
|
| 850 |
};
|
| 851 |
let workspace = includeWorkspace ? peekWorkspace(scope) : null;
|
| 852 |
// A workspace that cannot be read at first paint is not "a table with no saved
|
|
@@ -906,7 +923,7 @@ export function useCustomerData(
|
|
| 906 |
return fetchTableWindow(tableKey, { offset: 0, limit: readPageSize(), related }, rowFailure);
|
| 907 |
}
|
| 908 |
}
|
| 909 |
-
rowFailure(refusal.reason);
|
| 910 |
return null;
|
| 911 |
};
|
| 912 |
const payload = await (readThrough && tableKey !== null
|
|
@@ -924,6 +941,7 @@ export function useCustomerData(
|
|
| 924 |
if (cancelled || seq !== windowSeq.current) return;
|
| 925 |
setWindowPending(false);
|
| 926 |
if (!payload) return;
|
|
|
|
| 927 |
rowAuthorityRef.current = payload;
|
| 928 |
if (metadataSeq !== workspaceSeq.current) workspace = null;
|
| 929 |
// ⚠ `false`: this call has just fetched `payload` FROM THE SERVER, and the workspace
|
|
@@ -1153,8 +1171,8 @@ export function useCustomerData(
|
|
| 1153 |
/* ⭐⭐ W51-T06 / C6 — THE PAGE CARRIES THE PIN. `related` IS IN THE DEPENDENCY LIST BELOW FOR
|
| 1154 |
THIS ONE LINE: left out, every page after the first would be the WHOLE table under a
|
| 1155 |
`total` that still described the pinned set. */
|
| 1156 |
-
void fetchTableWindow(scope, { ...req, related, offset }, (reason) => {
|
| 1157 |
-
if (seq === windowSeq.current) reportRowFailure(reason);
|
| 1158 |
}).then((next) => {
|
| 1159 |
if (seq !== windowSeq.current) return;
|
| 1160 |
setWindowPending(false);
|
|
@@ -1214,6 +1232,9 @@ export function useCustomerData(
|
|
| 1214 |
? workspaceRead.error : null,
|
| 1215 |
workspaceRefreshFailed: includeWorkspace && !suppliedPayload && workspaceRead.scope === scope
|
| 1216 |
&& !!workspaceRead.error && !!workspaceRead.stale,
|
|
|
|
|
|
|
|
|
|
| 1217 |
retryWorkspace,
|
| 1218 |
windowPending,
|
| 1219 |
rowLoadingMessage: !suppliedPayload && mirrorUnavailableScope === scope
|
|
|
|
| 33 |
fetchAssignedCustomerRows,
|
| 34 |
fetchTopicRows,
|
| 35 |
fetchWorkspace,
|
| 36 |
+
FORBIDDEN_CODE,
|
| 37 |
peekWorkspace,
|
| 38 |
fetchPersonalGridLayout,
|
| 39 |
savePersonalGridLayout,
|
|
|
|
| 388 |
const EMPTY_OVERLAY_EDITS: OverlayEdits = {};
|
| 389 |
const ignoreOverlayEdits: Dispatch<SetStateAction<OverlayEdits>> = () => {};
|
| 390 |
|
| 391 |
+
/** Which reads of one scope the server refused this person: a 403 on either withholds the grid. */
|
| 392 |
+
type AccessRefusal = { scope: SurfaceScope; workspace: boolean; rows: boolean };
|
| 393 |
+
|
| 394 |
+
function withRefusal(previous: AccessRefusal, scope: SurfaceScope, part: "workspace" | "rows",
|
| 395 |
+
refused: boolean): AccessRefusal {
|
| 396 |
+
const base = previous.scope === scope ? previous : { scope, workspace: false, rows: false };
|
| 397 |
+
return base === previous && base[part] === refused ? previous : { ...base, [part]: refused };
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
export interface CustomerData {
|
| 401 |
fields: Field[];
|
| 402 |
rawRows: Row[];
|
|
|
|
| 408 |
workspaceError: string | null;
|
| 409 |
/** `workspaceError` came from a refresh of an answered scope: the last workspace stays on screen. */
|
| 410 |
workspaceRefreshFailed: boolean;
|
| 411 |
+
/** The server answered 403 for this table: the grid shows one access line, no Retry, no skeleton. */
|
| 412 |
+
accessRefused: boolean;
|
| 413 |
retryWorkspace: () => void;
|
| 414 |
windowPending: boolean;
|
| 415 |
rowLoadingMessage: string | null;
|
|
|
|
| 504 |
const [data, setData] = useState<CustomersPayload | null>(() => suppliedPayload ? null : readInitialPayload());
|
| 505 |
const [windowPending, setWindowPending] = useState(false);
|
| 506 |
const [mirrorUnavailableScope, setMirrorUnavailableScope] = useState<SurfaceScope | null>(null);
|
| 507 |
+
const [accessRefusal, setAccessRefusal] = useState<AccessRefusal>(
|
| 508 |
+
{ scope, workspace: false, rows: false });
|
| 509 |
+
// A 403 is not an outage: it paints the grid's access line, never the frame's error card.
|
| 510 |
+
const reportRowFailure = useCallback((reason: string, code?: string) => {
|
| 511 |
+
if (code === FORBIDDEN_CODE) setAccessRefusal((previous) => withRefusal(previous, scope, "rows", true));
|
| 512 |
+
else if (reason === AMAZON_STILL_LOADING_MESSAGE) setMirrorUnavailableScope(scope);
|
| 513 |
else signal(DATA_ERROR_EVENT, reason);
|
| 514 |
}, [scope]);
|
| 515 |
// Item 3c: seeded SYNCHRONOUSLY from the cell journal, so a remounted grid
|
|
|
|
| 844 |
const error = status.state === "error" ? status.message ?? "Saved views could not be loaded." : null;
|
| 845 |
const stale = !!error && workspaceAnsweredRef.current === scope;
|
| 846 |
setWorkspaceRead({ scope, pending: false, error, stale });
|
| 847 |
+
setAccessRefusal((previous) => withRefusal(previous, scope, "workspace", !!error && status.forbidden === true));
|
| 848 |
if (!error) {
|
| 849 |
workspaceAnsweredRef.current = scope;
|
| 850 |
setWorkspaceAnswered(scope);
|
|
|
|
| 862 |
if (addressedView) markHostedOpen("open", scope);
|
| 863 |
setWindowPending(true);
|
| 864 |
setMirrorUnavailableScope(null);
|
| 865 |
+
const rowFailure = (reason: string, code?: string) => {
|
| 866 |
+
if (!cancelled && seq === windowSeq.current) reportRowFailure(reason, code);
|
| 867 |
};
|
| 868 |
let workspace = includeWorkspace ? peekWorkspace(scope) : null;
|
| 869 |
// A workspace that cannot be read at first paint is not "a table with no saved
|
|
|
|
| 923 |
return fetchTableWindow(tableKey, { offset: 0, limit: readPageSize(), related }, rowFailure);
|
| 924 |
}
|
| 925 |
}
|
| 926 |
+
rowFailure(refusal.reason, refusal.code);
|
| 927 |
return null;
|
| 928 |
};
|
| 929 |
const payload = await (readThrough && tableKey !== null
|
|
|
|
| 941 |
if (cancelled || seq !== windowSeq.current) return;
|
| 942 |
setWindowPending(false);
|
| 943 |
if (!payload) return;
|
| 944 |
+
setAccessRefusal((previous) => withRefusal(previous, scope, "rows", false));
|
| 945 |
rowAuthorityRef.current = payload;
|
| 946 |
if (metadataSeq !== workspaceSeq.current) workspace = null;
|
| 947 |
// ⚠ `false`: this call has just fetched `payload` FROM THE SERVER, and the workspace
|
|
|
|
| 1171 |
/* ⭐⭐ W51-T06 / C6 — THE PAGE CARRIES THE PIN. `related` IS IN THE DEPENDENCY LIST BELOW FOR
|
| 1172 |
THIS ONE LINE: left out, every page after the first would be the WHOLE table under a
|
| 1173 |
`total` that still described the pinned set. */
|
| 1174 |
+
void fetchTableWindow(scope, { ...req, related, offset }, (reason, code) => {
|
| 1175 |
+
if (seq === windowSeq.current) reportRowFailure(reason, code);
|
| 1176 |
}).then((next) => {
|
| 1177 |
if (seq !== windowSeq.current) return;
|
| 1178 |
setWindowPending(false);
|
|
|
|
| 1232 |
? workspaceRead.error : null,
|
| 1233 |
workspaceRefreshFailed: includeWorkspace && !suppliedPayload && workspaceRead.scope === scope
|
| 1234 |
&& !!workspaceRead.error && !!workspaceRead.stale,
|
| 1235 |
+
// A workspace 403 holds the line only until rows arrive: readable rows keep today's Retry.
|
| 1236 |
+
accessRefused: !suppliedPayload && accessRefusal.scope === scope
|
| 1237 |
+
&& (accessRefusal.rows || (includeWorkspace && accessRefusal.workspace && visibleData === null)),
|
| 1238 |
retryWorkspace,
|
| 1239 |
windowPending,
|
| 1240 |
rowLoadingMessage: !suppliedPayload && mirrorUnavailableScope === scope
|