Skip to content

Split Annotation Dashbord into sub components#9424

Open
hotzenklotz wants to merge 1 commit intomasterfrom
split-annotation-dashboard
Open

Split Annotation Dashbord into sub components#9424
hotzenklotz wants to merge 1 commit intomasterfrom
split-annotation-dashboard

Conversation

@hotzenklotz
Copy link
Copy Markdown
Member

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • abc

TODOs:

  • ...

Issues:


(Please delete unneeded items, merge only when none are left open)

  • Added changelog entry (create a $PR_NUMBER.md file in unreleased_changes or use ./tools/create-changelog-entry.py)
  • Added migration guide entry if applicable (edit the same file as for the changelog)
  • Updated documentation if applicable
  • Adapted wk-libs python client if relevant API parts change
  • Removed dev-only changes like prints and application.conf edits
  • Considered common edge cases
  • Needs datastore update after deployment

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

This PR introduces two new dashboard components: DashboardEmptyAnnotationsPlaceholder (empty state UI) and DashboardTopBar (search and action controls). It refactors explorative_annotations_view.tsx to use these new components, removing inline implementations, and updates Ant Design imports. Minor formatting adjustments to categorization_label.tsx.

Changes

Cohort / File(s) Summary
New Dashboard Components
frontend/javascripts/dashboard/dashboard_empty_annotations_placeholder.tsx, frontend/javascripts/dashboard/dashboard_top_bar.tsx
Added two new exported React components for dashboard UI: one for empty-state messaging with a link to datasets, another for conditional top-bar rendering with search, upload, and archive controls.
Dashboard View Refactoring
frontend/javascripts/dashboard/explorative_annotations_view.tsx
Removed inline TopBar implementation and replaced with imported DashboardTopBar and DashboardEmptyAnnotationsPlaceholder. Consolidated search tag rendering into JSX, updated Ant Design imports (e.g., SearchProps source), and reduced component imports.
Minor Formatting
frontend/javascripts/viewer/view/components/categorization_label.tsx
Added blank lines around exported components and constants for improved readability.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Antd v6 Follow-ups #9152: Modifies the same explorative_annotations_view.tsx file for read-only/locked rendering and LinkButton updates, directly impacted by these component refactorings.

Suggested labels

frontend

Suggested reviewers

  • philippotto
  • fm3

Poem

🐰 Two shiny components hop to life,
Dashboard rid of tangled strife,
TopBar and Placeholder align,
Refactored code now clean and fine! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: splitting the annotation dashboard into subcomponents, which matches the refactoring work shown in the summary (extracting DashboardTopBar and DashboardEmptyAnnotationsPlaceholder).
Description check ✅ Passed The description is related to the changeset as it references issue #9423 and provides context for testing, though it is incomplete with placeholder values and unchecked items.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch split-annotation-dashboard

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
frontend/javascripts/dashboard/dashboard_top_bar.tsx (2)

12-28: Consider extracting the props type for better reusability.

The inline props type definition works, but extracting it as a named type would improve readability and enable reuse if needed elsewhere.

Suggested refactor
+type DashboardTopBarProps = {
+  isAdminView: boolean;
+  handleOnSearch: SearchProps["onSearch"];
+  handleSearchChanged: (event: React.ChangeEvent<HTMLInputElement>) => void;
+  searchQuery: string;
+  toggleShowArchived: () => void;
+  shouldShowArchivedAnnotations: boolean;
+  archiveAll: () => void;
+};
+
-export function DashboardTopBar({
-  isAdminView,
-  handleOnSearch,
-  handleSearchChanged,
-  searchQuery,
-  toggleShowArchived,
-  shouldShowArchivedAnnotations,
-  archiveAll,
-}: {
-  isAdminView: boolean;
-  handleOnSearch: SearchProps["onSearch"];
-  handleSearchChanged: (event: React.ChangeEvent<HTMLInputElement>) => void;
-  searchQuery: string;
-  toggleShowArchived: () => void;
-  shouldShowArchivedAnnotations: boolean;
-  archiveAll: () => void;
-}) {
+export function DashboardTopBar({
+  isAdminView,
+  handleOnSearch,
+  handleSearchChanged,
+  searchQuery,
+  toggleShowArchived,
+  shouldShowArchivedAnnotations,
+  archiveAll,
+}: DashboardTopBarProps) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/javascripts/dashboard/dashboard_top_bar.tsx` around lines 12 - 28,
Extract the inline props annotation for DashboardTopBar into a named
type/interface (e.g., DashboardTopBarProps) and use it as the function's
parameter type; include all current prop names and their types (isAdminView,
handleOnSearch, handleSearchChanged, searchQuery, toggleShowArchived,
shouldShowArchivedAnnotations, archiveAll) in that new type to improve
readability and enable reuse across the codebase. Update the function signature
to accept props: DashboardTopBarProps and export the new type if it may be
reused elsewhere.

33-42: Consider adding a placeholder for better UX.

The Search input would benefit from a placeholder to guide users on what they can search for (e.g., annotation names, tags, IDs).

Suggested improvement
   const search = (
     <Search
       style={{
         width: 200,
       }}
       onSearch={handleOnSearch}
       onChange={handleSearchChanged}
       value={searchQuery}
+      placeholder="Search annotations"
     />
   );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/javascripts/dashboard/dashboard_top_bar.tsx` around lines 33 - 42,
Add a user-facing placeholder to the Search component to improve
discoverability; update the JSX for Search (the Search element using props
onSearch={handleOnSearch}, onChange={handleSearchChanged}, value={searchQuery})
to include a placeholder prop (e.g., placeholder="Search annotations, tags or
IDs") so users know what to search for.
frontend/javascripts/dashboard/dashboard_empty_annotations_placeholder.tsx (1)

7-7: Use numeric value for span prop.

The Col span prop is typed as number | string, but using a number is the standard convention and ensures type consistency.

Suggested fix
-      <Col span="6">
+      <Col span={6}>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/javascripts/dashboard/dashboard_empty_annotations_placeholder.tsx`
at line 7, The Col component is passing span as a string; change the prop to a
numeric value to match the typed convention (number | string) and ensure type
consistency: update the JSX usage of Col (the span prop) from a quoted string to
a numeric expression (e.g., replace span="6" with span={6}) in
dashboard_empty_annotations_placeholder.tsx.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/javascripts/dashboard/explorative_annotations_view.tsx`:
- Around line 574-576: The current check shows
DashboardEmptyAnnotationsPlaceholder whenever filteredAndSortedAnnotations is
empty and this.state.isLoading is false, which can mislead users if
filters/search are active; update the conditional around
filteredAndSortedAnnotations to first detect whether any filters/search/tags are
active (e.g. check this.state.query, this.state.selectedTags or the component's
filter props) and only render DashboardEmptyAnnotationsPlaceholder when there
are truly no annotations and no active filters; if filters are active and the
filtered list is empty, render a distinct "no results for current filters"
message or nothing instead of the Create-an-Annotation placeholder so users
aren't confused.

---

Nitpick comments:
In `@frontend/javascripts/dashboard/dashboard_empty_annotations_placeholder.tsx`:
- Line 7: The Col component is passing span as a string; change the prop to a
numeric value to match the typed convention (number | string) and ensure type
consistency: update the JSX usage of Col (the span prop) from a quoted string to
a numeric expression (e.g., replace span="6" with span={6}) in
dashboard_empty_annotations_placeholder.tsx.

In `@frontend/javascripts/dashboard/dashboard_top_bar.tsx`:
- Around line 12-28: Extract the inline props annotation for DashboardTopBar
into a named type/interface (e.g., DashboardTopBarProps) and use it as the
function's parameter type; include all current prop names and their types
(isAdminView, handleOnSearch, handleSearchChanged, searchQuery,
toggleShowArchived, shouldShowArchivedAnnotations, archiveAll) in that new type
to improve readability and enable reuse across the codebase. Update the function
signature to accept props: DashboardTopBarProps and export the new type if it
may be reused elsewhere.
- Around line 33-42: Add a user-facing placeholder to the Search component to
improve discoverability; update the JSX for Search (the Search element using
props onSearch={handleOnSearch}, onChange={handleSearchChanged},
value={searchQuery}) to include a placeholder prop (e.g., placeholder="Search
annotations, tags or IDs") so users know what to search for.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cab5d838-228e-44b3-8968-7ca7d2875192

📥 Commits

Reviewing files that changed from the base of the PR and between d4a2f84 and ddb16b9.

📒 Files selected for processing (4)
  • frontend/javascripts/dashboard/dashboard_empty_annotations_placeholder.tsx
  • frontend/javascripts/dashboard/dashboard_top_bar.tsx
  • frontend/javascripts/dashboard/explorative_annotations_view.tsx
  • frontend/javascripts/viewer/view/components/categorization_label.tsx

Comment on lines +574 to 576
if (filteredAndSortedAnnotations.length === 0 && !this.state.isLoading) {
return <DashboardEmptyAnnotationsPlaceholder />;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Empty placeholder may be misleading when filters are active.

When filteredAndSortedAnnotations is empty due to active search query or tags (not because the user has no annotations), the placeholder displays "Create an Annotation" with a link to the datasets page. This could confuse users who have annotations but are seeing empty results due to their filters.

Consider checking if filters/tags are active and either showing a different message or not showing this placeholder when the empty state is filter-induced.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/javascripts/dashboard/explorative_annotations_view.tsx` around lines
574 - 576, The current check shows DashboardEmptyAnnotationsPlaceholder whenever
filteredAndSortedAnnotations is empty and this.state.isLoading is false, which
can mislead users if filters/search are active; update the conditional around
filteredAndSortedAnnotations to first detect whether any filters/search/tags are
active (e.g. check this.state.query, this.state.selectedTags or the component's
filter props) and only render DashboardEmptyAnnotationsPlaceholder when there
are truly no annotations and no active filters; if filters are active and the
filtered list is empty, render a distinct "no results for current filters"
message or nothing instead of the Create-an-Annotation placeholder so users
aren't confused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant