fix(app): creation page waits for own grants; e2e never prints setup keys
Delta verifier: two remaining setup-key assertions now booleans. Its observation: the editor rule read grants before they loaded; authStore.catalogGrantsStatus (loading, ready, failed): the page waits, and a failed read leaves the decision to the server. App 654, e2e:ui 227, admin shell spec 14 + 6 skipped.
This commit is contained in:
1 parent
02625a76b6
commit
f04bfdd040
6 files changed
+37
-11
No files matched your search
@@ -33,6 +33,7 @@ import { coreFailureMessage } from '@/core/failure'
|
||||
import { coreRuntime } from '@/core/runtime'
|
||||
import { emptySheetDocument } from '@/core/sheetDocumentOps'
|
||||
import { getSupabaseClient } from '@/lib/supabase'
|
||||
import { useAuthStore } from '@/state/authStore'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
@@ -95,6 +96,7 @@ export default function AdminSheetCreateRoute() {
|
||||
const navigate = useNavigate()
|
||||
const locale = useLocaleStore((s) => s.locale)
|
||||
const { editor } = useAdminPermissions()
|
||||
const grantsStatus = useAuthStore((s) => s.catalogGrantsStatus)
|
||||
const species = useAdminQuery('species', listCatalogSpecies)
|
||||
const [values, setValues] = useState<SheetFormValues>(EMPTY)
|
||||
const [slugEdited, setSlugEdited] = useState(false)
|
||||
@@ -110,11 +112,19 @@ export default function AdminSheetCreateRoute() {
|
||||
if (first) document.getElementById(fieldId(first))?.focus()
|
||||
}, [errorRound, errors])
|
||||
|
||||
// A display rule like the « Nouvelle fiche » button: a reviewer or a
|
||||
// publisher reaching the address is not offered the form. The server still
|
||||
// refuses the creation to anyone without the editor capability.
|
||||
// A display rule like the « Nouvelle fiche » button: once the caller's own
|
||||
// grants are read, a reviewer or a publisher reaching the address is not
|
||||
// offered the form. While they load nothing is decided; if the read failed
|
||||
// the form shows and the server, which refuses creation to anyone without
|
||||
// the editor capability, decides.
|
||||
if (grantsStatus === 'loading')
|
||||
return (
|
||||
<p role="status" className="text-sm text-[var(--color-ink-muted)]">
|
||||
{t('shell.loading_session')}
|
||||
</p>
|
||||
)
|
||||
if (
|
||||
!editor ||
|
||||
(grantsStatus === 'ready' && !editor) ||
|
||||
(species.state.status === 'error' &&
|
||||
isRightsRefusal(species.state.failure))
|
||||
)
|
||||
|
||||
@@ -6,8 +6,10 @@ import { useT } from '@/i18n/useT'
|
||||
/**
|
||||
* « Accès non autorisé » (contract §5.3, BDR-094): what a catalogue or
|
||||
* administration page shows when the server refuses (`rights.*`, and
|
||||
* `not_found` under /app/anatomy), the same whether the sheet exists or not.
|
||||
* Nothing from the address is echoed.
|
||||
* `not_found` under /app/anatomy), the same whether the sheet exists or not;
|
||||
* also the sheet creation page for an account whose own grants hold no editor
|
||||
* capability (a display rule, the server still decides). Nothing from the
|
||||
* address is echoed.
|
||||
*/
|
||||
export default function AccessDenied() {
|
||||
const t = useT()
|
||||
|
||||
@@ -68,6 +68,8 @@ export interface AuthState {
|
||||
* Empty until loaded and when the read fails.
|
||||
*/
|
||||
catalogGrants: OwnCatalogGrant[]
|
||||
/** Whether `catalogGrants` is read yet: a display rule waits for `ready`, and a `failed` read leaves the decision to the server. */
|
||||
catalogGrantsStatus: 'loading' | 'ready' | 'failed'
|
||||
/** Subscribes to the client; returns the unsubscribe. Safe to call twice. */
|
||||
start: () => () => void
|
||||
refreshAccount: () => Promise<void>
|
||||
@@ -150,8 +152,8 @@ async function loadAccount(client: FaunosteoClient, user: User, set: Set, get: G
|
||||
loadWorkspace(client, user, profile, setOwn, get),
|
||||
syncAvatar(client, user, setOwn, get).catch(() => setOwn({ avatar: null })),
|
||||
listOwnCatalogGrants(client, user.id)
|
||||
.then((catalogGrants) => setOwn({ catalogGrants }))
|
||||
.catch(() => setOwn({ catalogGrants: [] })),
|
||||
.then((catalogGrants) => setOwn({ catalogGrants, catalogGrantsStatus: 'ready' }))
|
||||
.catch(() => setOwn({ catalogGrants: [], catalogGrantsStatus: 'failed' })),
|
||||
])
|
||||
}
|
||||
|
||||
@@ -165,6 +167,7 @@ function accountReset(get: Get): Partial<AuthState> {
|
||||
avatarUrl: null,
|
||||
workspace: { status: 'idle' },
|
||||
catalogGrants: [],
|
||||
catalogGrantsStatus: 'loading',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +239,7 @@ export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
avatarUrl: null,
|
||||
workspace: { status: 'idle' },
|
||||
catalogGrants: [],
|
||||
catalogGrantsStatus: 'loading',
|
||||
|
||||
start: () => {
|
||||
const client = getSupabaseClient()
|
||||
|
||||
Reference in new issue
Block a user