Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ow "Record not found" in DetailView - RecordDetailView: compute pureRecordId once and use for resourceId, presence, and comment queries - DetailView: show "Record not found" message with Go back button when data is null after loading - Update tests to verify findOne called with stripped ID and test Record not found state Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 仔细评估是否已经完成了任务中要求的所有开发? |
All issue requirements have been completed. Here's the full audit: 1. RecordDetailView prefix stripping (✅ all 6 query points):
2. DetailView "Record not found" state (✅):
3. Tests (✅ 28 passing):
The only remaining raw |
There was a problem hiding this comment.
Pull request overview
Fixes console record detail pages when navigating via URL by normalizing recordId (stripping the objectName- prefix) so backend lookups succeed, and adds a clear empty state when a record loads as null.
Changes:
- Strip
objectName-prefix from URLrecordIdonce inRecordDetailViewand reusepureRecordIdacross DetailView, presence, comments, and edit callbacks. - Add a “Record not found” empty state to
DetailViewwhen loaded data isnull. - Update/add tests covering recordId stripping and the new not-found state.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/plugin-detail/src/DetailView.tsx | Adds a “Record not found” empty state after loading when data is missing. |
| packages/plugin-detail/src/tests/DetailView.test.tsx | Adds tests validating the not-found empty state and optional back behavior. |
| apps/console/src/components/RecordDetailView.tsx | Introduces pureRecordId and threads it through detail schema, presence, comments, and onEdit. |
| apps/console/src/tests/RecordDetailEdit.test.tsx | Fixes selectors and asserts findOne is called with stripped/non-stripped IDs. |
Comments suppressed due to low confidence (3)
packages/plugin-detail/src/DetailView.tsx:240
- The "Record not found" branch is triggered by a broad falsy check (
!data). This will also render the not-found state whendatais stillundefined(e.g., misconfigured schema with noresourceId/dataSource), not just whenfindOneexplicitly returnsnull. Consider checkingdata === null(and optionallyschema.resourceIdpresent) so only a true not-found result shows this state.
if (!data && !schema.data) {
return (
<div className={cn('flex flex-col items-center justify-center py-16 text-center', className)}>
<p className="text-lg font-semibold">Record not found</p>
<p className="text-sm text-muted-foreground mt-1">
The record you are looking for does not exist or may have been deleted.
apps/console/src/components/RecordDetailView.tsx:58
dataSource.findis being called with$filteras an interpolated string. In@object-ui/types,QueryParams.$filteris defined as an object/AST, and the ObjectStack adapter converts object filters to an AST; passing a string can be mis-parsed (e.g., treated as a list of characters). Use an object filter like{ recordId: pureRecordId }/{ threadId }instead of a string expression.
// Fetch record viewers
dataSource.find('sys_presence', { $filter: `recordId eq '${pureRecordId}'` })
.then((res: any) => { if (res.data?.length) setRecordViewers(res.data); })
.catch(() => {});
// Fetch persisted comments and map to FeedItem[]
dataSource.find('sys_comment', { $filter: `threadId eq '${threadId}'`, $orderby: 'createdAt asc' })
.then((res: any) => {
apps/console/src/components/RecordDetailView.tsx:80
- The
useEffectdependency list includescurrentUser, butcurrentUseris a new object literal each render, which will cause this effect to refetch presence/comments unnecessarily. Prefer depending on stable primitives (e.g.,currentUser.id) or memoizecurrentUserwithuseMemo.
})
.catch(() => {});
}, [dataSource, objectName, pureRecordId, currentUser]);
Detail pages render blank when navigating via URL (e.g.
/contact/record/contact-1772355903654-1) because the URLrecordIdincludes anobjectName-prefix that the backend doesn't store.findOne("contact", "contact-1772355903654-1")returns null silently.Changes
pureRecordIdonce at component top, use it for all downstream queries —detailSchema.resourceId, presence filter, comment thread IDs, andonEditcallbackDetailView: Add "Record not found" empty state when
datais null post-load, with optional back navigation — prevents silent blank pageTests: Fix broken
waitForselectors inRecordDetailEdit.test.tsx, add assertions thatfindOnereceives the stripped ID, add two tests for the record-not-found stateOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.