Dashboard search, display most recent dashboards first, display who created dashboard#259
Dashboard search, display most recent dashboards first, display who created dashboard#259vkarpov15 wants to merge 1 commit into
Conversation
…reated dashboard Fix #253
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5acddb8729
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await authorize('Dashboard.getDashboards', roles); | ||
|
|
||
| const dashboards = await Dashboard.find(); | ||
| const dashboards = await Dashboard.find().sort({ createdAt: -1, _id: -1 }).lean(); |
There was a problem hiding this comment.
Sort legacy dashboards after deriving createdAt
For legacy dashboards that do not have createdAt, the schema derives and persists createdAt only in the post-find hook, but this MongoDB sort has already happened by then. In a mixed collection, a recently created legacy dashboard with no createdAt sorts below every dashboard that has any createdAt value, so the dashboard list is not actually newest-first until after that document has been backfilled by a prior request.
Useful? React with 👍 / 👎.
| await authorize('Dashboard.createDashboard', roles); | ||
|
|
||
| const dashboard = await Dashboard.create({ title, code }); | ||
| console.log('Test', params) |
There was a problem hiding this comment.
Remove creation parameter logging
Every dashboard creation now logs the full params object, which includes the dashboard code and the authenticated user's details when running with an API key. In production this can leak proprietary dashboard scripts or user PII into server logs, and the log line appears unrelated to the returned result.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR enhances the Dashboards UX and metadata by adding client-side search, ordering dashboards with the most recently created first, and persisting/displaying additional dashboard metadata (creator info and last evaluation time). It also adds/updates tests to validate the new sorting and persistence behavior.
Changes:
- Add dashboard list search UI with match highlighting and empty-state messaging.
- Sort dashboards newest-first and persist
lastEvaluatedAton evaluation completion. - Store creator metadata (
createdById+createdBy) when dashboards are created, with new test coverage.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Dashboard.getDashboards.test.js | Adds tests for newest-first ordering, legacy createdAt derivation, and creator persistence. |
| test/Dashboard.getDashboard.results.test.js | Verifies lastEvaluatedAt is persisted to the dashboard when evaluations complete. |
| frontend/src/dashboards/dashboards.js | Adds search state, filtering, highlighting helpers, date/user formatting, and inserts new dashboards at the top. |
| frontend/src/dashboards/dashboards.html | Adds the search input, “no matches” state, switches list rendering to filtered dashboards, and displays metadata fields. |
| express.js | Propagates initiating user info into request internals for downstream actions. |
| backend/next.js | Propagates initiating user info into action params for Next.js deployments. |
| backend/netlify.js | Propagates initiating user info into action params for Netlify deployments. |
| backend/db/dashboardSchema.js | Adds creator + evaluation fields and attempts legacy createdAt backfill via a query post-hook. |
| backend/actions/Dashboard/getDashboards.js | Sorts dashboards by newest first and returns lean objects. |
| backend/actions/Dashboard/getDashboard.js | Updates dashboard lastEvaluatedAt when an evaluation finishes. |
| backend/actions/Dashboard/createDashboard.js | Persists creator fields when creating a new dashboard. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await this.model.db.model('__Studio_Dashboard').updateOne( | ||
| { _id: dashboard._id }, | ||
| { createdAt: dashboard._id.getTimestamp() }, | ||
| { overwriteImmutable: true } | ||
| ); |
| console.log('Test', params) | ||
|
|
||
| const dashboard = await Dashboard.create({ | ||
| title, | ||
| code, | ||
| createdById: initiatedById, | ||
| createdBy: params.initiatedBy | ||
| }); |
| filteredDashboards() { | ||
| const searchText = this.searchText.trim().toLowerCase(); | ||
| if (!searchText) { | ||
| return this.dashboards; | ||
| } | ||
|
|
||
| return this.dashboards.filter(dashboard => { | ||
| return (dashboard.title || '').toLowerCase().includes(searchText) || | ||
| (dashboard.description || '').toLowerCase().includes(searchText); | ||
| }); | ||
| } |
| <div v-show="dashboard.createdBy"> | ||
| <dt class="font-medium text-content-secondary">Created By</dt> | ||
| <dd class="truncate">{{ dashboard.createdBy?.name }}</dd> | ||
| </div> |
| req._internals.initiatedById = user._id; | ||
| req._internals.roles = roles; | ||
| req._internals.$workspaceId = workspace._id; | ||
| req._internals.initiatedBy = user; |
| params.roles = roles; | ||
| params.userId = user._id; | ||
| params.initiatedById = user._id; | ||
| params.initiatedBy = user; |
| params.roles = roles; | ||
| params.userId = user._id; | ||
| params.initiatedById = user._id; | ||
| params.initiatedBy = user; |
Fix #253