Skip to content

Commit be91bfc

Browse files
fix(ui): kanban, calendar, timeline and map draw the no-access state for a refused read (#36016)
Fixes #36010 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:看板、日历、时间线、地图这四种视图里,没有数据读取权限的人原来会看到一串英文服务器报错,现在看到和列表页一样的「无权访问」提示,按自己的语言显示。 - 为什么做:这是甘特图同类修复的收尾,把同一问题在其余四种视图里一次补齐。 - 出错会怎样:只影响被拒读这一种情况;服务器故障、断网仍显示原来的报错画面,改动可直接撤回。 - 要你做什么:无。 ## What changes The load-error branch of `ObjectKanban`, `ObjectCalendar`, `ObjectTimeline` and `ObjectMap` now classifies a failed data load with the shared `classifyLoadError` (`@object-ui/react`). A `forbidden` verdict (a 403, or a `PERMISSION_DENIED` / `FORBIDDEN` code) draws the shared `DataEmptyState` (`role="status"`, Lock icon) with the existing `list.loadErrorForbiddenTitle` / `list.loadErrorForbiddenMessage` keys, and none of the server's text. Every other failure keeps each view's current error screen. This copies the Gantt pattern of PR #36006 view by view. - Shared helper or copy: **copied per view**. No shared "load error to no-access" component exists, and adding one to `@object-ui/components` would be a new public export outside the claim's file surface. - English fallbacks: kanban and timeline get two rows in their existing default-translation tables (`KANBAN_DEFAULT_TRANSLATIONS`, `TIMELINE_DEFAULT_TRANSLATIONS`), with the same text as the `en` pack. Calendar and map have no such table, so their `t()` calls carry `defaultValue` with the same text. No new i18n key. - Icon: kanban and calendar already depend on `lucide-react` and use `Lock`. Timeline and map declare no icon library, so they use the shared `LazyIcon name="lock"` from `@object-ui/components` (same as `record-alert.tsx`), and no dependency is added. - The map's tile-style failure (`mapStyleError`) is not a data load and is unchanged. - The `ObjectKanban.tsx` changes are the import lines, two fallback rows and the load-error branch only (os-sales draft PR #35994 also edits that file). ## Tests New pins sit in each view's existing load-error harness as a top-level `describe`: `ObjectKanban.errorClears-10663.test.tsx`, `ObjectCalendar.errorClears-10663.test.tsx`, `ObjectTimeline.errorClears-10663.test.tsx`, plus `ObjectMap.test.tsx` (map has no load-error harness). In each one, a 403 with `httpStatus` and `code` draws `*-no-access` with `role="status"`, the en sentence, and no `Error`, `PERMISSION_DENIED` or `HTTP 403` text. CONTROL: a 500 keeps the existing error screen. ## Acceptance notes - A2 (browser reading) was not done. Setting up a showcase object with a kanban or calendar view and a refused read is not cheap here. The unit pins drive the real component through a data source that throws the adapter's 403 shape. - `useTimelineTranslation` comments say the table is the "byte-identical twin of `en.ts`". The two new rows match `en.ts` `list.loadErrorForbidden*` text exactly. ## Verification Two-minute check: `cd ui && pnpm exec vitest run packages/plugin-kanban/src/ObjectKanban.errorClears-10663.test.tsx -t 'refused read'`. You should see 2 passed. <details><summary>Green on head 37a0692: 4 files, 24 tests</summary> ``` cd ui && pnpm exec vitest run --maxWorkers=2 packages/plugin-kanban/src/ObjectKanban.errorClears-10663.test.tsx packages/plugin-calendar/src/ObjectCalendar.errorClears-10663.test.tsx packages/plugin-timeline/src/ObjectTimeline.errorClears-10663.test.tsx packages/plugin-map/src/ObjectMap.test.tsx Test Files 4 passed (4) Tests 24 passed (24) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Red on base (sources reverted to ec24363, tests kept): every 403 pin red, every CONTROL green</summary> ``` x object-timeline: a refused read draws the no-access state > a 403 read draws the no-access state, with none of the server text v object-timeline: ... > CONTROL: a 500 keeps the existing error screen x object-calendar: ... > a 403 read ... v object-calendar: ... > CONTROL: a 500 ... x ObjectMap: ... > a 403 read ... v ObjectMap: ... > CONTROL: a 500 ... x object-kanban: ... > a 403 read ... v object-kanban: ... > CONTROL: a 500 ... Tests 4 failed | 20 passed (24) restore: git diff HEAD empty; every restored blob equals its HEAD blob ``` </details> <details><summary>Ablation (kanban, one view): forbidden branch disabled, the 403 pin goes red</summary> ``` node scripts/ablation-replace.mjs --file ui/packages/plugin-kanban/src/ObjectKanban.tsx --anchor "if (error && classifyLoadError(error) === 'forbidden') {" --replacement "if (error && false) {" -- ... vitest run ... -t 'refused read' ablation-replace: ok mutation landed: anchor 1 -> 0, blob 8bd927f -> 0f5997510cd0 Tests 1 failed | 1 passed | 4 skipped (6) ablation-replace: ok restored: blob == HEAD (8bd927f) and `git diff HEAD` is empty ``` The test imports the component from `src` (relative `./index` / `./ObjectMap`), so no dist build is needed for the mutation to take effect. </details> <details><summary>Type check: the four plugins</summary> ``` pnpm --filter @object-ui/plugin-{kanban,calendar,timeline,map} run type-check (tsc --noEmit && tsc -p tsconfig.test.json) packages/plugin-calendar type-check: Done packages/plugin-kanban type-check: Done packages/plugin-map type-check: Done packages/plugin-timeline type-check: Done VERDICT command-exit 0 ``` </details> <details><summary>Derived gate families (local subset)</summary> ``` head 37a0692; dispatch-gates --commands derived 38 families; all run, each exit 0: node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0 node scripts/check-adr-0087-registration.mjs --self-test :: exit 0 node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-empty-changeset.mjs --base origin/main :: exit 0 node scripts/check-empty-changeset.mjs --self-test :: exit 0 node scripts/check-sdui-manifest.mjs :: exit 0 node scripts/check-sdui-manifest.mjs --self-test :: exit 0 node scripts/ci/snapshot-next.mjs --self-test :: exit 0 node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0 node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0 node scripts/release-pending-publish.mjs --self-test :: exit 0 pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0 pnpm check:adr-anchors :: exit 0 pnpm check:changeset-gate-self-tests :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:dispatcher-error-vocabulary :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:engine-double-contract :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:published-files :: exit 0 pnpm check:query-options-erasure :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:registry-log-declared :: exit 0 pnpm check:rest-log-spy-declared :: exit 0 pnpm check:skill-identifier-liveness :: exit 0 pnpm check:test-source-alias :: exit 0 pnpm check:tier-file-adoption :: exit 0 pnpm check:type-check-coverage :: exit 0 pnpm check:type-check-debt :: exit 0 pnpm check:undeclared-dep-imports :: exit 0 pnpm check:watch-hint-literal :: exit 0 pnpm check:where-matcher :: exit 0 pnpm --dir ui exec vitest run scripts/ :: exit 0 dispatch-gates --ran: 38 derived, 38 run, 0 NOT-MEASURED (a DERIVED zero: all 38 recorded an exit code) check:query-options-erasure and check:type-check-debt hit the 300s timeout of the first loop (exit 124); rerun with no timeout: both exit 0 ``` </details> Files to read first: `ui/packages/plugin-map/src/ObjectMap.tsx` (the new branch sits before the data error screen and must not catch `mapStyleError`), `ui/packages/plugin-timeline/src/ObjectTimeline.tsx` (`LazyIcon` instead of `lucide-react`), `ui/packages/plugin-kanban/src/ObjectKanban.tsx` (it overlaps PR #35994). --- _Generated by [Claude Code](https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9b3227f commit be91bfc

10 files changed

Lines changed: 368 additions & 4 deletions
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@object-ui/plugin-kanban': patch
3+
'@object-ui/plugin-calendar': patch
4+
'@object-ui/plugin-timeline': patch
5+
'@object-ui/plugin-map': patch
6+
---
7+
8+
fix(ui): the kanban, calendar, timeline and map views draw the no-access state for a refused read, not the raw error
9+
10+
Clause-②: no
11+
Metadata-protocol: none
12+
13+
A reader who may open a page but is not granted the records its kanban board, calendar, timeline or map reads saw the transport's own string where the view would be, untranslated (for example `Error loading kanban data: ApiDataSource: HTTP 403 Forbidden — {…}`). Each of the four views now classifies a failed load with the shared load-error verdict the list page, the related list and the Gantt chart use, and for a permission refusal (a 403, or a `PERMISSION_DENIED` / `FORBIDDEN` code) draws the calm no-access state those surfaces draw: a neutral status panel with the shared `list.loadErrorForbiddenTitle` / `list.loadErrorForbiddenMessage` sentence in the reader's language, and none of the server's text. Every other failure (a 500, a dropped connection) keeps each view's existing error screen. The map's tile-style failure is not a data load and is unchanged.

‎ui/packages/plugin-calendar/src/ObjectCalendar.errorClears-10663.test.tsx‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,29 @@ async function invalidate() {
101101
});
102102
}
103103

104+
/** The shape the ObjectStack adapter throws: status + code decorated on the Error. */
105+
function refusal(): Error {
106+
const err = new Error(
107+
'ApiDataSource: HTTP 403 Forbidden — {"error":"PERMISSION_DENIED: no read access to event"}',
108+
) as Error & { httpStatus?: number; code?: string };
109+
err.httpStatus = 403;
110+
err.code = 'PERMISSION_DENIED';
111+
return err;
112+
}
113+
114+
function serverError(): Error {
115+
const err = new Error('ApiDataSource: HTTP 500 Internal Server Error') as Error & { httpStatus?: number };
116+
err.httpStatus = 500;
117+
return err;
118+
}
119+
120+
async function failWith(d: Deferred<any>, err: Error) {
121+
await act(async () => {
122+
d.reject(err);
123+
await Promise.resolve();
124+
});
125+
}
126+
104127
const CALENDAR = { startDateField: 'due', titleField: 'name' };
105128
const BLOCK = { type: 'object-calendar', objectName: 'event', calendar: CALENDAR };
106129

@@ -211,3 +234,41 @@ describe('object-calendar clears its error when a later load commits rows (objec
211234
expect(screen.getByText('Handed over')).toBeTruthy();
212235
});
213236
});
237+
238+
/**
239+
* A refused read draws the calm no-access state, not the raw error.
240+
*
241+
* A reader who may open the page but not read the calendar's object used to see
242+
* the transport's own string ("ApiDataSource: HTTP 403 Forbidden — ..."). The
243+
* calendar now classifies a failed load with the shared `classifyLoadError` and,
244+
* for a `forbidden` read, draws the shared `list.loadErrorForbidden*` sentence
245+
* as a neutral `role="status"` panel. Every other failure keeps the existing
246+
* error screen (CONTROL).
247+
*/
248+
describe('object-calendar: a refused read draws the no-access state', () => {
249+
it('a 403 read draws the no-access state, with none of the server text', async () => {
250+
const { dataSource, finds } = makeDeferredDataSource();
251+
const { container } = mount(dataSource);
252+
await waitFor(() => expect(finds).toHaveLength(1));
253+
await failWith(finds[0], refusal());
254+
255+
const panel = await screen.findByTestId('calendar-no-access');
256+
expect(panel.getAttribute('role')).toBe('status');
257+
expect(panel.textContent).toContain('You don\u2019t have access');
258+
expect(panel.textContent).toContain('You don\u2019t have permission to view these records.');
259+
const text = container.textContent ?? '';
260+
expect(text).not.toContain('Error');
261+
expect(text).not.toContain('PERMISSION_DENIED');
262+
expect(text).not.toContain('HTTP 403');
263+
});
264+
265+
it('CONTROL: a 500 keeps the existing error screen', async () => {
266+
const { dataSource, finds } = makeDeferredDataSource();
267+
mount(dataSource);
268+
await waitFor(() => expect(finds).toHaveLength(1));
269+
await failWith(finds[0], serverError());
270+
271+
expect(errorShown('ApiDataSource: HTTP 500 Internal Server Error')).toBe(true);
272+
expect(screen.queryByTestId('calendar-no-access')).toBeNull();
273+
});
274+
});

‎ui/packages/plugin-calendar/src/ObjectCalendar.tsx‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ import {
4949
useDataInvalidation,
5050
useFilterScope,
5151
useResolvedFilter,
52+
classifyLoadError,
5253
} from '@object-ui/react';
5354
import {
5455
RECORD_OVERLAY_DEFAULT_WIDTH,
5556
RecordDetailPanel,
5657
deriveRecordPageHref,
5758
} from '@object-ui/plugin-detail';
5859
import { usePermissions } from '@object-ui/permissions';
59-
import { ChevronRight } from 'lucide-react';
60+
import { ChevronRight, Lock } from 'lucide-react';
6061
import {
6162
cn,
6263
useIsMobile,
@@ -70,6 +71,7 @@ import {
7071
Input,
7172
Label,
7273
NavigationOverlay,
74+
DataEmptyState,
7375
legacyRecordDrawerWidthKey,
7476
recordOverlayWidthStorageKey,
7577
toast,
@@ -1508,6 +1510,31 @@ export const ObjectCalendar: React.FC<ObjectCalendarComponentProps> = ({
15081510
);
15091511
}
15101512

1513+
// A refused read (403 / PERMISSION_DENIED, by the shared `classifyLoadError`
1514+
// verdict the list page, the related list and the gantt use) is not a
1515+
// failure of anything the reader did: they may open the page without being
1516+
// granted the records this calendar reads. It is drawn as the calm no-access
1517+
// state (`role="status"`, the shared `list.loadErrorForbidden*` sentence in
1518+
// the reader's language), never the server's text. Every other failure
1519+
// keeps the error screen below.
1520+
// This package has no default-translation table: the `defaultValue`s are the
1521+
// provider-less fallback and say exactly what the `en` pack says.
1522+
if (error && classifyLoadError(error) === 'forbidden') {
1523+
return (
1524+
<div className={className}>
1525+
<DataEmptyState
1526+
data-testid="calendar-no-access"
1527+
className="h-96"
1528+
icon={<Lock className="size-5 text-muted-foreground" aria-hidden />}
1529+
title={t('list.loadErrorForbiddenTitle', { defaultValue: 'You don’t have access' })}
1530+
description={t('list.loadErrorForbiddenMessage', {
1531+
defaultValue: 'You don’t have permission to view these records. Contact your administrator if you think you should have access.',
1532+
})}
1533+
/>
1534+
</div>
1535+
);
1536+
}
1537+
15111538
if (error) {
15121539
return (
15131540
<div className={className}>

‎ui/packages/plugin-kanban/src/ObjectKanban.errorClears-10663.test.tsx‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,29 @@ async function invalidate() {
9898
});
9999
}
100100

101+
/** The shape the ObjectStack adapter throws: status + code decorated on the Error. */
102+
function refusal(): Error {
103+
const err = new Error(
104+
'ApiDataSource: HTTP 403 Forbidden — {"error":"PERMISSION_DENIED: no read access to deal"}',
105+
) as Error & { httpStatus?: number; code?: string };
106+
err.httpStatus = 403;
107+
err.code = 'PERMISSION_DENIED';
108+
return err;
109+
}
110+
111+
function serverError(): Error {
112+
const err = new Error('ApiDataSource: HTTP 500 Internal Server Error') as Error & { httpStatus?: number };
113+
err.httpStatus = 500;
114+
return err;
115+
}
116+
117+
async function failWith(d: Deferred<any>, err: Error) {
118+
await act(async () => {
119+
d.reject(err);
120+
await Promise.resolve();
121+
});
122+
}
123+
101124
const BLOCK = { type: 'object-kanban', objectName: 'deal', groupBy: 'status', columns: [{ id: 'open', title: 'Open' }] };
102125

103126
function mount(dataSource: ReturnType<typeof makeDeferredDataSource>['dataSource']) {
@@ -191,3 +214,41 @@ describe('object-kanban clears its error when a later load commits cards (object
191214
expect(errorShown('current run failed'), 'a superseded answer cleared the current error').toBe(true);
192215
});
193216
});
217+
218+
/**
219+
* A refused read draws the calm no-access state, not the raw error.
220+
*
221+
* A reader who may open the page but not read the kanban's object used to see
222+
* the transport's own string ("ApiDataSource: HTTP 403 Forbidden — ..."). The
223+
* kanban now classifies a failed load with the shared `classifyLoadError` and,
224+
* for a `forbidden` read, draws the shared `list.loadErrorForbidden*` sentence
225+
* as a neutral `role="status"` panel. Every other failure keeps the existing
226+
* error screen (CONTROL).
227+
*/
228+
describe('object-kanban: a refused read draws the no-access state', () => {
229+
it('a 403 read draws the no-access state, with none of the server text', async () => {
230+
const { dataSource, finds } = makeDeferredDataSource();
231+
const { container } = mount(dataSource);
232+
await waitFor(() => expect(finds).toHaveLength(1));
233+
await failWith(finds[0], refusal());
234+
235+
const panel = await screen.findByTestId('kanban-no-access');
236+
expect(panel.getAttribute('role')).toBe('status');
237+
expect(panel.textContent).toContain('You don\u2019t have access');
238+
expect(panel.textContent).toContain('You don\u2019t have permission to view these records.');
239+
const text = container.textContent ?? '';
240+
expect(text).not.toContain('Error');
241+
expect(text).not.toContain('PERMISSION_DENIED');
242+
expect(text).not.toContain('HTTP 403');
243+
});
244+
245+
it('CONTROL: a 500 keeps the existing error screen', async () => {
246+
const { dataSource, finds } = makeDeferredDataSource();
247+
mount(dataSource);
248+
await waitFor(() => expect(finds).toHaveLength(1));
249+
await failWith(finds[0], serverError());
250+
251+
expect(errorShown('ApiDataSource: HTTP 500 Internal Server Error')).toBe(true);
252+
expect(screen.queryByTestId('kanban-no-access')).toBeNull();
253+
});
254+
});

‎ui/packages/plugin-kanban/src/ObjectKanban.tsx‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ import {
2222
useFilterScope,
2323
useResolvedFilter,
2424
usePredicateScope,
25+
classifyLoadError,
2526
} from '@object-ui/react';
2627
import {
2728
NavigationOverlay,
29+
DataEmptyState,
2830
legacyRecordDrawerWidthKey,
2931
recordOverlayWidthStorageKey,
3032
toast,
3133
} from '@object-ui/components';
3234
import { createSafeTranslation } from '@object-ui/i18n';
35+
import { Lock } from 'lucide-react';
3336
import {
3437
RECORD_OVERLAY_DEFAULT_WIDTH,
3538
RecordDetailPanel,
@@ -91,6 +94,12 @@ import { lanesFromOptions, type LaneLifecycleKind } from './kanbanLaneLifecycle'
9194
const KANBAN_DEFAULT_TRANSLATIONS: Record<string, string> = {
9295
'detail.recordDetail': 'Record Detail',
9396
'detail.recordDetailWithLabel': '{{label}} Detail',
97+
// The refused-read state reuses the shared no-access sentence the list page
98+
// and the related list draw, so a host pack that translates them translates
99+
// this board too; these rows are the provider-less fallback and say exactly
100+
// what the `en` pack says.
101+
'list.loadErrorForbiddenTitle': 'You don’t have access',
102+
'list.loadErrorForbiddenMessage': 'You don’t have permission to view these records. Contact your administrator if you think you should have access.',
94103
};
95104

96105
/**
@@ -1953,6 +1962,25 @@ export const ObjectKanban: React.FC<ObjectKanbanComponentProps> = ({
19531962

19541963
// Error branch renders only after every hook above has run, so hook order
19551964
// stays stable across renders (no early return before the hooks).
1965+
// A refused read (403 / PERMISSION_DENIED, by the shared `classifyLoadError`
1966+
// verdict the list page, the related list and the gantt use) is not a
1967+
// failure of anything the reader did: they may open the page without being
1968+
// granted the records this board reads. It is drawn as the calm no-access
1969+
// state (`role="status"`, the shared `list.loadErrorForbidden*` sentence in
1970+
// the reader's language), never the server's text. Every other failure
1971+
// keeps the error screen below.
1972+
if (error && classifyLoadError(error) === 'forbidden') {
1973+
return (
1974+
<DataEmptyState
1975+
data-testid="kanban-no-access"
1976+
className="h-96"
1977+
icon={<Lock className="size-5 text-muted-foreground" aria-hidden />}
1978+
title={t('list.loadErrorForbiddenTitle')}
1979+
description={t('list.loadErrorForbiddenMessage')}
1980+
/>
1981+
);
1982+
}
1983+
19561984
if (error) {
19571985
return (
19581986
<div className="p-4 border border-destructive/50 rounded bg-destructive/10 text-destructive">

‎ui/packages/plugin-map/src/ObjectMap.test.tsx‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,60 @@ describe('ObjectMap', () => {
109109
});
110110
});
111111
});
112+
113+
/**
114+
* A refused read draws the calm no-access state, not the raw error.
115+
*
116+
* A reader who may open the page but not read the map's object used to see
117+
* the transport's own string ("Error: ApiDataSource: HTTP 403 Forbidden — ...").
118+
* The map now classifies a failed load with the shared `classifyLoadError` and,
119+
* for a `forbidden` read, draws the shared `list.loadErrorForbidden*` sentence
120+
* as a neutral `role="status"` panel. Every other failure keeps the existing
121+
* error screen (CONTROL).
122+
*/
123+
describe('ObjectMap: a refused read draws the no-access state', () => {
124+
const schema: any = {
125+
type: 'map',
126+
map: { latitudeField: 'latitude', longitudeField: 'longitude', titleField: 'name' },
127+
data: { provider: 'object', object: 'locations' },
128+
};
129+
130+
function failingSource(err: Error): DataSource {
131+
return {
132+
find: vi.fn(async () => { throw err; }),
133+
findOne: vi.fn(),
134+
create: vi.fn(),
135+
update: vi.fn(),
136+
delete: vi.fn(),
137+
getObjectSchema: vi.fn(),
138+
} as unknown as DataSource;
139+
}
140+
141+
it('a 403 read draws the no-access state, with none of the server text', async () => {
142+
const err = new Error(
143+
'ApiDataSource: HTTP 403 Forbidden — {"error":"PERMISSION_DENIED: no read access to locations"}',
144+
) as Error & { httpStatus?: number; code?: string };
145+
err.httpStatus = 403;
146+
err.code = 'PERMISSION_DENIED';
147+
const { container } = render(<ObjectMap schema={schema} dataSource={failingSource(err)} />);
148+
149+
const panel = await screen.findByTestId('map-no-access');
150+
expect(panel.getAttribute('role')).toBe('status');
151+
expect(panel.textContent).toContain('You don’t have access');
152+
expect(panel.textContent).toContain('You don’t have permission to view these records.');
153+
const text = container.textContent ?? '';
154+
expect(text).not.toContain('Error');
155+
expect(text).not.toContain('PERMISSION_DENIED');
156+
expect(text).not.toContain('HTTP 403');
157+
expect(screen.queryByLabelText('Map')).toBeNull();
158+
});
159+
160+
it('CONTROL: a 500 keeps the existing error screen', async () => {
161+
const err = new Error('ApiDataSource: HTTP 500 Internal Server Error') as Error & { httpStatus?: number };
162+
err.httpStatus = 500;
163+
render(<ObjectMap schema={schema} dataSource={failingSource(err)} />);
164+
165+
expect(await screen.findByText('Error: ApiDataSource: HTTP 500 Internal Server Error')).toBeTruthy();
166+
expect(screen.queryByTestId('map-no-access')).toBeNull();
167+
});
168+
});

‎ui/packages/plugin-map/src/ObjectMap.tsx‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ import {
3232
useResolvedFilter,
3333
useObjectTranslation,
3434
useHostMapStyle,
35+
classifyLoadError,
3536
} from '@object-ui/react';
36-
import { NavigationOverlay, cn, useIsMobile } from '@object-ui/components';
37+
import { NavigationOverlay, DataEmptyState, LazyIcon, cn, useIsMobile } from '@object-ui/components';
3738
import { usePermissions } from '@object-ui/permissions';
3839
import { RecordDetailPanel } from '@object-ui/plugin-detail';
3940
import {
@@ -1386,6 +1387,34 @@ export const ObjectMap: React.FC<ObjectMapProps> = ({
13861387
);
13871388
}
13881389

1390+
// A refused read (403 / PERMISSION_DENIED, by the shared `classifyLoadError`
1391+
// verdict the list page, the related list and the gantt use) is not a
1392+
// failure of anything the reader did: they may open the page without being
1393+
// granted the records this map reads. It is drawn as the calm no-access
1394+
// state (`role="status"`, the shared `list.loadErrorForbidden*` sentence in
1395+
// the reader's language), never the server's text. Every other failure
1396+
// keeps the error screen below.
1397+
// This package has no default-translation table, so the `defaultValue`s are
1398+
// the provider-less fallback (they say exactly what the `en` pack says), and
1399+
// the Lock glyph comes through the shared `LazyIcon`: it declares no icon
1400+
// library of its own. The style/tile failure (`mapStyleError`) is not a data
1401+
// load and is not routed here.
1402+
if (error && classifyLoadError(error) === 'forbidden') {
1403+
return (
1404+
<div className={cn("min-w-0 overflow-hidden", className)}>
1405+
<DataEmptyState
1406+
data-testid="map-no-access"
1407+
className="h-96"
1408+
icon={<LazyIcon name="lock" className="size-5 text-muted-foreground" aria-hidden />}
1409+
title={t('list.loadErrorForbiddenTitle', { defaultValue: 'You don’t have access' })}
1410+
description={t('list.loadErrorForbiddenMessage', {
1411+
defaultValue: 'You don’t have permission to view these records. Contact your administrator if you think you should have access.',
1412+
})}
1413+
/>
1414+
</div>
1415+
);
1416+
}
1417+
13891418
if (error) {
13901419
return (
13911420
<div className={cn("min-w-0 overflow-hidden", className)}>

0 commit comments

Comments
 (0)