Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds public, dashboard-scoped hooks intended for custom fields/views to access the active entry, graph, user/policy, and to run graph-backed queries with Suspense-friendly caching.
Changes:
- Exposes new public hooks (
useEntry,useGraph,useUser,usePolicy,useGraphQuery) and exports them fromalinea/dashboard. - Introduces
DashboardEntryData.currentEntryto provide the selected entry version as a plainEntryrecord. - Adds tests for
useEntry/useGraphQuerybehavior and updates dev examples + the legacyuseEntryEditorcompatibility hook.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/dashboard/store/hooks.tsx | Adds public hooks and implements useGraphQuery caching logic. |
| src/dashboard/store/hooks.test.tsx | New tests covering useEntry and useGraphQuery refresh behavior. |
| src/dashboard/store/Dashboard.ts | Adds currentEntry selection atom and adjusts entry translation selection typing. |
| src/dashboard/hook/UseEntryEditor.ts | Updates deprecated compatibility hook to use the new useEntry shape. |
| src/dashboard.ts | Re-exports new public hooks/types from the package entrypoint. |
| apps/dev/src/schema/example/CustomViewExample.view.tsx | Demonstrates new hooks in a custom view example. |
| apps/dev/src/schema/example/CustomFieldExample.tsx | Enables the custom position field example in the dev schema. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+299
to
+327
| let cacheEntry: GraphQueryCacheEntry<Result> | ||
| const resource = atom(async get => { | ||
| get(dashboard.sha) | ||
| const graph = get(dashboard.db) | ||
| const config = get(dashboard.config) | ||
| const policy = get(dashboard.policy) | ||
| const user = (await get(dashboard.user)) ?? null | ||
| return cacheEntry.query({ | ||
| config, | ||
| entry: cacheEntry.entry, | ||
| graph, | ||
| policy, | ||
| user | ||
| }) | ||
| }) | ||
| const state = unwrap( | ||
| atom(async get => ({data: await get(resource)})), | ||
| previous => previous | ||
| ) | ||
| cached = { | ||
| entry, | ||
| query, | ||
| atom: atom(get => { | ||
| const current = get(state) | ||
| if (current) return current.data | ||
| return get(resource) | ||
| }) | ||
| } | ||
| cacheEntry = cached |
Comment on lines
+23
to
+28
| const nullEntryAtom = atom<EntryRecord<Record<string, unknown>> | null>(null) | ||
| const graphQueryCache = new WeakMap< | ||
| Dashboard, | ||
| Map<string, GraphQueryCacheEntry<unknown>> | ||
| >() | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.