Skip to content

Commit fbb7599

Browse files
fix(app-shell): draw the app no-access screen with the shared DataEmptyState (#26166)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi97Yc9Hw7zbkBCZQmMnndL2D)_ Part of #25915 Clause-②: no (one block swaps its own markup for the shared components; no exported type change. If a shared component needs a new prop, the thread reports first and the seat amends this line) Metadata-protocol: none ## What Slice 2 of #25915 (slice 1 was #26135). `ui/packages/app-shell/src/console/AppNoAccessEmptyState.tsx`, the screen an app's root shows when the app serves the caller no navigation or names only objects the caller may not read, now renders `DataEmptyState` instead of the bare `Empty` primitive. It is announced as `role="status"`. Unchanged: every i18n key and default value, the `app-no-access-empty-state` wrapper, the `app-no-access-open-setup` link (now the `action`), and `data-reason`, which moves from the description paragraph to the status node. `DataEmptyState` spreads extra props onto its root, so no prop was added to the shared component. The title takes the shared component's smaller size, which is the visual diff. ## Why this block (measured on main 601c773) Of the remaining app-shell blocks, this one hand-copied `DataEmptyState`'s icon square class string verbatim (`flex size-10 items-center justify-center rounded-lg bg-muted`) around the `Empty` primitive, and carried no role. Its only importer is `AppContent.tsx` (two call sites, not edited); `appServesNoNavigation.ts` names it in a comment only. `AppContent.tsx` already imports `DataEmptyState` through `PreviewDraftEmptyState` since #26135, so the eager graph gains no module. Not chosen for this slice: `agentEmptyState` returns title/description data, not a block; `StudioEmptyState`'s sentence is a ReactNode where `DataEmptyState.description` is a string (would need a prop); `PreviewEmptyState` has a warn tone with no shared equivalent; `InspectorEmptyState` has 7 importers. No `claude/*` branch on origin carries a different version of the file (depth-1 blob compare of 723 heads, 73 carry it, 0 differ). app-shell is outside the sdui registry closure, so `scripts/sdui-manifest.record.json` is not in the diff. ## Tests New `ui/packages/app-shell/src/console/__tests__/AppNoAccessEmptyState.sharedState-25915.test.tsx`: the screen is a `role="status"` node with `data-slot="data-empty-state"` inside the test-id wrapper; `data-reason` is on that node for both reasons; Open Setup is the action and links to the setup path. - Run at bd0b46a: the new file plus the unedited landing suites `AppContent.emptyNavigationLanding-12079` and `AppContent.noReadableObjectLanding-25338` (which reads `data-reason` through the wrapper): `Test Files 3 passed (3)`, `Tests 16 passed (16)`. - Ablation: with the fix committed and the source reverted to its main version, the new file reads `Tests 4 failed (4)`; restored with `git checkout HEAD --`, `git diff HEAD` empty and blob hash equal to HEAD. - `pnpm --filter @object-ui/app-shell type-check` after building `@object-ui/app-shell^...`: both `tsc --noEmit` and `tsc -p tsconfig.test.json`, exit 0. ## Acceptance notes - `InspectorEmptyState`, `StudioEmptyState`, `PreviewEmptyState` and `agentEmptyState` stay for later slices; #25915 remains open. --- _Generated by [Claude Code](https://claude.ai/code/session_01FdXMkfnYedDKghz7QLUkx8)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FdXMkfnYedDKghz7QLUkx8 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9993165 commit fbb7599

3 files changed

Lines changed: 128 additions & 40 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): the "nothing in this app is available to you" screen is drawn by the shared `DataEmptyState`
6+
7+
Clause-②: no (one block swaps its own markup for the shared components; no exported type change. If a shared component needs a new prop, the thread reports first and the seat amends this line)
8+
Metadata-protocol: none
9+
10+
The screen an app's root shows when the app serves the caller no navigation, or names only objects the caller may not read (`AppNoAccessEmptyState`), now uses `DataEmptyState` from `@object-ui/components` instead of the `Empty` primitive with a hand-copied icon square. It is announced to assistive technology as `role="status"`. The text, the Open Setup link, the test ids and the `data-reason` attribute (now on the status node) are unchanged; the title takes the shared component's smaller size.

‎ui/packages/app-shell/src/console/AppNoAccessEmptyState.tsx‎

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727

2828
import { Link } from 'react-router-dom';
2929
import { Lock } from 'lucide-react';
30-
// The three primitives `RouteNotFound` and the app-verdict screens in
31-
// `AppContent.tsx` already compose, so this screen looks like its siblings and
32-
// adds nothing to the eager `ui-components` chunk.
33-
import { Button, Empty, EmptyDescription, EmptyTitle } from '@object-ui/components';
30+
// The shared empty state (objectstack#25915): it draws the muted icon square
31+
// this screen used to hand-copy, and it is `role="status"`, so "nothing here
32+
// for you" is announced instead of being an unlabelled block. `AppContent.tsx`
33+
// already reaches it through `PreviewDraftEmptyState`, so the eager graph
34+
// gains no new module.
35+
import { Button, DataEmptyState } from '@object-ui/components';
3436
import { useObjectLabel, useObjectTranslation } from '@object-ui/i18n';
3537
import { resolveKeyedI18nLabel } from '../utils/index.js';
3638

@@ -56,44 +58,44 @@ export function AppNoAccessEmptyState({ app, setupPath, reason = 'no-navigation'
5658
// The same label the header's app switcher shows for this app.
5759
const label = appLabel({ name: app.name, label: resolveKeyedI18nLabel(app.label, t) });
5860

61+
const description =
62+
reason === 'no-readable-object'
63+
? setupPath
64+
? t('empty.appNoReadableObjectGrantDescription', {
65+
defaultValue: 'Your account cannot read any of the records in this app yet. You can grant access in Setup.',
66+
})
67+
: t('empty.appNoReadableObjectDescription', {
68+
defaultValue:
69+
'Your account cannot read any of the records in this app yet. Ask an administrator to assign you a permission set.',
70+
})
71+
: setupPath
72+
? t('empty.appNothingAvailableGrantDescription', {
73+
defaultValue: 'This app has no pages your account can open. You can grant access in Setup.',
74+
})
75+
: t('empty.appNothingAvailableDescription', {
76+
defaultValue: 'This app has no pages your account can open. Ask an administrator to grant you access.',
77+
});
78+
5979
return (
6080
<div className="flex h-full w-full items-center justify-center p-8" data-testid="app-no-access-empty-state">
61-
<Empty>
62-
<div className="flex size-10 items-center justify-center rounded-lg bg-muted text-muted-foreground" aria-hidden="true">
63-
<Lock className="size-5" />
64-
</div>
65-
<EmptyTitle>
66-
{t('empty.appNothingAvailable', {
67-
app: label,
68-
defaultValue: 'Nothing in {{app}} is available to you yet',
69-
})}
70-
</EmptyTitle>
71-
<EmptyDescription data-reason={reason}>
72-
{reason === 'no-readable-object'
73-
? setupPath
74-
? t('empty.appNoReadableObjectGrantDescription', {
75-
defaultValue: 'Your account cannot read any of the records in this app yet. You can grant access in Setup.',
76-
})
77-
: t('empty.appNoReadableObjectDescription', {
78-
defaultValue:
79-
'Your account cannot read any of the records in this app yet. Ask an administrator to assign you a permission set.',
80-
})
81-
: setupPath
82-
? t('empty.appNothingAvailableGrantDescription', {
83-
defaultValue: 'This app has no pages your account can open. You can grant access in Setup.',
84-
})
85-
: t('empty.appNothingAvailableDescription', {
86-
defaultValue: 'This app has no pages your account can open. Ask an administrator to grant you access.',
87-
})}
88-
</EmptyDescription>
89-
{setupPath && (
90-
<Button asChild variant="outline">
91-
<Link to={setupPath} data-testid="app-no-access-open-setup">
92-
{t('empty.openSetup', { defaultValue: 'Open Setup' })}
93-
</Link>
94-
</Button>
95-
)}
96-
</Empty>
81+
<DataEmptyState
82+
data-reason={reason}
83+
icon={<Lock className="size-5 text-muted-foreground" aria-hidden="true" />}
84+
title={t('empty.appNothingAvailable', {
85+
app: label,
86+
defaultValue: 'Nothing in {{app}} is available to you yet',
87+
})}
88+
description={description}
89+
action={
90+
setupPath ? (
91+
<Button asChild variant="outline">
92+
<Link to={setupPath} data-testid="app-no-access-open-setup">
93+
{t('empty.openSetup', { defaultValue: 'Open Setup' })}
94+
</Link>
95+
</Button>
96+
) : undefined
97+
}
98+
/>
9799
</div>
98100
);
99101
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* The app root's "nothing here for you" screen is drawn by the shared
11+
* `DataEmptyState` (objectstack#25915), so it is announced as
12+
* `role="status"`. Before, it composed the bare `Empty` primitive around a
13+
* hand-copied icon square, an unlabelled block to assistive technology.
14+
*
15+
* The routing that decides WHEN this screen shows is pinned by the
16+
* AppContent landing suites; this file pins only what the screen is.
17+
*
18+
* The `t` mock returns each call site's `defaultValue`, which the i18n
19+
* call-site gate holds byte-equal to the `en` pack value.
20+
*/
21+
22+
import '@testing-library/jest-dom/vitest';
23+
import { describe, expect, it, vi } from 'vitest';
24+
import { render, screen } from '@testing-library/react';
25+
import type { ComponentProps } from 'react';
26+
import { MemoryRouter } from 'react-router-dom';
27+
28+
vi.mock('@object-ui/i18n', async (importOriginal) => ({
29+
...(await importOriginal<typeof import('@object-ui/i18n')>()),
30+
useObjectTranslation: () => ({
31+
t: (_k: string, o?: { defaultValue?: string }) => o?.defaultValue ?? _k,
32+
}),
33+
useObjectLabel: () => ({
34+
appLabel: (app: { name: string; label?: string }) => app.label ?? app.name,
35+
}),
36+
}));
37+
38+
import { AppNoAccessEmptyState } from '../AppNoAccessEmptyState';
39+
40+
function renderState(props: Partial<ComponentProps<typeof AppNoAccessEmptyState>> = {}) {
41+
return render(
42+
<MemoryRouter>
43+
<AppNoAccessEmptyState app={{ name: 'crm', label: 'CRM' }} setupPath={null} {...props} />
44+
</MemoryRouter>,
45+
);
46+
}
47+
48+
describe('AppNoAccessEmptyState draws the shared empty state (objectstack#25915)', () => {
49+
it('is a role="status" DataEmptyState inside the test-id wrapper', () => {
50+
renderState();
51+
52+
const wrapper = screen.getByTestId('app-no-access-empty-state');
53+
const status = screen.getByRole('status');
54+
expect(wrapper).toContainElement(status);
55+
expect(status).toHaveAttribute('data-slot', 'data-empty-state');
56+
expect(status).toHaveTextContent('Nothing in {{app}} is available to you yet');
57+
expect(status).toHaveTextContent('Ask an administrator to grant you access.');
58+
});
59+
60+
it.each([
61+
['no-navigation', undefined],
62+
['no-readable-object', 'no-readable-object' as const],
63+
])('carries data-reason=%s on the status node', (expected, reason) => {
64+
renderState(reason ? { reason } : {});
65+
66+
expect(screen.getByRole('status')).toHaveAttribute('data-reason', expected);
67+
});
68+
69+
it('offers Open Setup as the action only when a setup path is given', () => {
70+
renderState({ setupPath: '/setup/permissions' });
71+
72+
const link = screen.getByTestId('app-no-access-open-setup');
73+
expect(screen.getByRole('status')).toContainElement(link);
74+
expect(link).toHaveAttribute('href', '/setup/permissions');
75+
});
76+
});

0 commit comments

Comments
 (0)