Skip to content

Rb nov 11 policy templates library#2716

Merged
MuhammadKhalilzadeh merged 16 commits intodevelopfrom
rb-nov-11-policy-templates-library
Nov 22, 2025
Merged

Rb nov 11 policy templates library#2716
MuhammadKhalilzadeh merged 16 commits intodevelopfrom
rb-nov-11-policy-templates-library

Conversation

@rachanabasnet
Copy link
Copy Markdown
Contributor

@rachanabasnet rachanabasnet commented Nov 19, 2025

Describe your changes

Created a Tab named "Policy Templates" under the policy page to display a list of policy templates. Upon clicking the template, the "Create new Policy" drawer opens with the template data filled in the form. The user can create a new policy based on those templates.

Write your issue number after "Fixes "

Fixes #2652

Screenshots

image image

Please ensure all items are checked off before requesting a review:

  • I deployed the code locally.
  • I have performed a self-review of my code.
  • I have included the issue # in the PR.
  • I have labelled the PR correctly.
  • The issue I am working on is assigned to me.
  • I have avoided using hardcoded values to ensure scalability and maintain consistency across the application.
  • I have ensured that font sizes, color choices, and other UI elements are referenced from the theme.
  • My pull request is focused and addresses a single, specific feature.
  • If there are UI changes, I have attached a screenshot or video to this PR.

rachanabasnet and others added 14 commits November 11, 2025 19:08
- Update all policy template tags to use official predefined tags from backend
- Create reusable TagChip component with color-coded badge styling
- Change default pagination to 10 items per page with localStorage persistence
- Convert category labels from title case to sentence case
- Update Policy Manager descriptions to highlight template library features
- Add tag color mappings for all 15 official tags (Fairness, Privacy, Security, etc.)
- Improve helper drawer content with template browsing guidance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ble styling

- Implement three-state column sorting (asc/desc/none) with localStorage persistence
- Add sort icons and visual indicators matching incident management table UX
- Highlight sorted columns with background color for better visibility
- Fix policy table header styling bug (style to sx) to enable hover effects
- Add click handlers to all table headers for intuitive sorting interaction
- Persist sort preferences across sessions using localStorage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…orting

- Remove sorting functionality from TAGS column as requested
- Fix header text visibility issue by adding whiteSpace nowrap
- Prevent header text and icons from shrinking with flexShrink 0
- Remove background highlighting from TAGS column cells
- Clean up sorting logic to exclude TAGS handling

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove sorting state, handlers, and localStorage persistence
- Remove sort icons and click handlers from table headers
- Revert table body to use filteredPolicyTemplates instead of sortedPolicyTemplates
- Remove column highlighting for sorted columns
- Revert PolicyTable component sx fix back to style

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@rachanabasnet rachanabasnet added this to the 2.0 milestone Nov 19, 2025
@rachanabasnet rachanabasnet self-assigned this Nov 19, 2025
@rachanabasnet rachanabasnet added enhancement New feature or request frontend Frontend related tasks/issues labels Nov 19, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 19, 2025

Walkthrough

Refactors policies routing to nested /policies routes and introduces a tabbed PolicyDashboard. Adds a PolicyTemplates feature backed by a JSON library, a PolicyManager component for org policies, a TagChip component, new enums/interfaces for templates, and template-aware PolicyDetailModal behavior.

Changes

Cohort / File(s) Summary
Routing
Clients/src/application/config/routes.tsx
Replaced single /policies route with nested /policies (index default) and /policies/templates, both rendering PolicyDashboard to enable path-driven tab selection.
Enums & Types
Clients/src/domain/enums/policy.enum.ts, Clients/src/domain/interfaces/IPolicy.ts
Added PolicyTemplateCategory enum. Added PolicyTemplate, PolicyManagerProps, PolicyTemplatesProps interfaces and extended PolicyDetailModalProps with optional template.
Tag UI
Clients/src/presentation/components/Tags/TagChip.tsx, Clients/src/presentation/components/Tags/index.ts
New TagChip component with tag-to-style mapping and barrel exports for TagChip and TagChipProps.
Policy dashboard — manager
Clients/src/presentation/pages/PolicyDashboard/PolicyManager.tsx
New PolicyManager component: manages policies list, filtering (status/search), modals for create/edit, save/delete flows, and alerts; accepts policies, tags, fetchAll.
Policy dashboard — templates
Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx
New PolicyTemplates component: loads templates from JSON, provides category filter, search, pagination, tag rendering, modal-open-on-row-click, and onSaved refresh handling.
Dashboard refactor
Clients/src/presentation/pages/PolicyDashboard/PoliciesDashboard.tsx
Reworked PolicyDashboard to tab-driven layout using TabBar/TabContext, routing between Organizational Policies and Policy Templates; delegates to PolicyManager / PolicyTemplates.
Modal enhancements
Clients/src/presentation/components/Policies/PolicyDetailsModal.tsx
PolicyDetailModal now accepts template prop, prefills form/editor from template when present, adds handleClose to reset state, and updates effect dependencies to include template.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Router as App Router
    participant Dashboard as PolicyDashboard
    participant Manager as PolicyManager
    participant Templates as PolicyTemplates
    participant Modal as PolicyDetailModal
    participant API

    User->>Router: Navigate to /policies or /policies/templates
    Router->>Dashboard: Render with path-based tab

    alt /policies
        Dashboard->>Manager: render PolicyManager(policies,tags,fetchAll)
        Manager->>API: fetchAll()
        Manager->>Manager: filter/search, open PolicyDetailModal (create/edit)
        Manager->>API: save/delete actions
    else /policies/templates
        Dashboard->>Templates: render PolicyTemplates(tags,fetchAll)
        Templates->>Templates: load PolicyTemplates.json
        User->>Templates: Filter / Search / Paginate
        User->>Templates: Click template -> Templates->>Modal: open(template)
        Modal->>Modal: prefill editor from template or policy
        User->>Modal: Save -> Modal->>API: create policy
        API-->>Modal: success -> Modal->>Templates: onSaved() -> Templates refresh
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas to focus:
    • PolicyTemplates.tsx — filtering, pagination, template→modal data flow.
    • PolicyManager.tsx — CRUD flows, side effects and sync with incoming props.
    • PolicyDetailsModal.tsx — editor initialization, template vs policy content branching, effect dependencies.
    • routes.tsx and PoliciesDashboard.tsx — path-driven tab selection and nested routing behavior.

Poem

🐇 I hopped through routes and split the field in two,
Tabs for the meadow and templates to view.
Tags like tiny carrots, colors bright and neat,
Templates to nibble when crafting a new seat.
A hop, a save, a tiny rabbit cheer — success is sweet!

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Rb nov 11 policy templates library' is vague and lacks clarity, using a branch name prefix instead of describing the actual feature change. Rename the title to clearly describe the feature, such as 'Add Policy Templates tab to enable creating policies from templates'.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code changes comprehensively implement all requirements from issue #2652: tab-based navigation between 'Organizational Policies' and 'Policy Templates', template library display with search/filter, and template-prefilled policy creation.
Out of Scope Changes check ✅ Passed All changes directly support the policy templates feature; new components, interfaces, enums, and routing modifications align with the stated objectives and issue requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed PR description is comprehensive with clear change summary, issue reference, screenshots, and all checklist items marked complete.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rb-nov-11-policy-templates-library

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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Clients/src/presentation/components/Policies/PolicyDetailsModal.tsx (1)

227-235: The review comment is accurate and identifies a real major issue. Data loss is confirmed possible when editing policies.

The code at lines 287–320 confirms the vulnerability:

  1. Policy editing scenario: When a user is editing an existing policy and the users hook refreshes (or any re-render causes users to be a new reference), the useEffect re-runs because users is in the dependency array [policy, template, users]. This executes the if (policy) branch and calls setFormData() with the original policy data, discarding any unsaved form edits (title, tags, content, reviewers).

  2. Template initialization: While the template branch uses spread (...formData), the effect still unnecessarily re-runs on every users change, which is inefficient and adds risk.

  3. Root cause: The users dependency is necessary for the reviewer mapping (policy.assigned_reviewer_ids.map((i) => users.find(...))), but including it in the dependency array causes full form resets instead of just updating reviewers.

The suggested refactoring—separating into two effects with tighter dependency scopes—correctly resolves this:

  • Policy effect: [policy, users] only
  • Template effect: [template, policy] only

This prevents user edits from being lost when users refreshes during editing or template creation.

🧹 Nitpick comments (12)
Clients/src/domain/enums/policy.enum.ts (1)

1-8: Enum definition looks good; just ensure backend/category alignment.

The PolicyTemplateCategory enum is well-typed and readable. Please double-check that these string values exactly match whatever the backend or template JSON expects (if any mapping is done there), so you don’t end up with subtle mismatches at integration time.

Clients/src/presentation/components/Tags/TagChip.tsx (1)

8-53: Tag-to-style mapping is solid; consider hoisting and simplifying lookup.

Logic and defaults look good, and the case-insensitive behavior matches the comment about official tags.

As optional cleanup:

  • Move tagStyles outside getTagStyle so it isn’t reallocated on every call.
  • Since you normalize to tagLower, you can avoid the loop and just do a direct lookup:
const TAG_STYLES: Record<string, { bg: string; color: string }> = { /* ... */ };

const getTagStyle = (tag: string) => TAG_STYLES[tag.toLowerCase()] ?? {
  bg: "#F5F5F5",
  color: "#616161",
};
Clients/src/application/config/routes.tsx (1)

82-85: Nested /policies routes are redundant without an <Outlet />; consider simplifying.

Right now you have:

<Route path="/policies" element={<PolicyDashboard />}>
  <Route index element={<PolicyDashboard />} />
  <Route path="templates" element={<PolicyDashboard />} />
</Route>

Since PolicyDashboard doesn’t render an <Outlet />, the child route elements are effectively unused; navigation to /policies and /policies/templates is already handled by the parent element and your location.pathname logic inside PolicyDashboard.

You can simplify and avoid confusion by flattening this to:

<Route path="/policies" element={<PolicyDashboard />} />
<Route path="/policies/templates" element={<PolicyDashboard />} />

This preserves behavior while making the routing intent clearer.

Clients/src/domain/interfaces/IPolicy.ts (1)

66-75: Props for PolicyManager/PolicyTemplates are reasonable; refine fetchAll typing.

PolicyManagerProps and PolicyTemplatesProps are clear and map well onto how PoliciesDashboard passes data down.

Since fetchAll is implemented as an async function in PoliciesDashboard, it would be slightly more accurate to type it as returning a promise:

export interface PolicyManagerProps {
  policies: PolicyManagerModel[];
  tags: string[];
  fetchAll: () => Promise<void>;
}

export interface PolicyTemplatesProps {
  tags: string[];
  fetchAll: () => Promise<void>;
}

This keeps call sites unchanged but better documents the async nature of the reload.

Clients/src/presentation/pages/PolicyDashboard/PoliciesDashboard.tsx (1)

21-30: Prefer useLocation over the global location for tab state.

Using location.pathname directly works in the browser, but relying on the global location can be brittle (e.g., SSR, tests, or if react-router location ever diverges from window.location).

You can make this more idiomatic and robust by switching to useLocation:

import { useNavigate, useLocation } from "react-router-dom";

const PolicyDashboard: React.FC = () => {
  const navigate = useNavigate();
  const { pathname } = useLocation();

  const isPolicyTemplateTab = pathname.includes("/policies/templates");
  const activeTab = isPolicyTemplateTab ? "templates" : "policies";
  // ...
};

This keeps tab selection in lockstep with the router state.

Clients/src/presentation/components/Policies/PolicyDetailsModal.tsx (1)

111-117: Template-aware close handling is consistent; minor scope consideration.

Wiring handleClose through useModalKeyHandling, the Drawer onClose, and the close icon ensures that all close paths reset formData and then delegate to the parent via onClose. That’s a good centralization of close logic.

One thing to be aware of: handleClose currently only resets formData. If the parent ever chooses to keep this component mounted and just toggle visibility (vs unmounting it), you may also want to reset errors and other local state there to avoid leaking old validation errors into a fresh open.

Also applies to: 167-182, 600-605, 632-636

Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx (5)

46-48: Avoid any for SelectorVertical props; use a typed alias

SelectorVertical currently uses props: any, which drops type safety for the pagination select icon.

You can keep it typed while staying simple:

-const SelectorVertical = (props: any) => (
-  <ChevronsUpDown size={16} {...props} />
-);
+const SelectorVertical = (props: React.ComponentProps<typeof ChevronsUpDown>) => (
+  <ChevronsUpDown size={16} {...props} />
+);

Based on learnings.


72-86: Remove debug console.log from template selection

console.log(selectedPolicy); in handleSelectPolicyTemplate is a debug artifact and will spam the console every row click in production.

Consider removing it:

-      const selectedPolicy = policyTemplates.find((policy) => policy.id === id);
-      console.log(selectedPolicy);
+      const selectedPolicy = policyTemplates.find((policy) => policy.id === id);

203-215: Tune empty-state copy for templates context

The empty state message says "No policies found in database", but this view is for policy templates loaded from static JSON and/or filters.

Consider a more specific message such as:

-                      <EmptyState message="No policies found in database" />
+                      <EmptyState message="No policy templates match your filters" />

This better reflects what the user is seeing.


220-234: Add keyboard activation for clickable table rows

Rows are focusable (tabIndex={0}) and have role="button", but there is no keyboard handler, so pressing Enter/Space does nothing.

Example:

-                    <TableRow
+                    <TableRow
                       key={policy.id}
                       onClick={() => handleSelectPolicyTemplate(policy.id)}
+                      onKeyDown={(e) => {
+                        if (e.key === "Enter" || e.key === " ") {
+                          e.preventDefault();
+                          handleSelectPolicyTemplate(policy.id);
+                        }
+                      }}
                       sx={{
                         cursor: "pointer",

This improves accessibility for keyboard-only users.


140-169: Hardcoded white background may not match theme (optional)

Both the filter Select and search container use bgcolor: "#fff". This can clash with non-light themes and bypass theming.

Consider using theme values instead, e.g.:

-            sx={{
-              minWidth: "225px",
-              height: "34px",
-              bgcolor: "#fff",
-            }}
+            sx={{
+              minWidth: "225px",
+              height: "34px",
+              bgcolor: theme.palette.background.paper,
+            }}

Same idea for other "#fff" usages in this file.

Clients/src/presentation/pages/PolicyDashboard/PolicyManager.tsx (1)

19-236: PolicyManager behavior and structure look correct; consider deduplicating shared patterns

The component cleanly handles syncing incoming policies, auto-opening the create modal from navigation state, filter + search, delete flow with alerts, and conditional modal rendering based on tags. No functional issues stand out.

You might later factor shared pieces (e.g., handleSaved alert pattern and filter/search logic) into small helpers or hooks shared with PolicyTemplates, but that’s optional.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f429108 and bb9b617.

📒 Files selected for processing (9)
  • Clients/src/application/config/routes.tsx (1 hunks)
  • Clients/src/domain/enums/policy.enum.ts (1 hunks)
  • Clients/src/domain/interfaces/IPolicy.ts (2 hunks)
  • Clients/src/presentation/components/Policies/PolicyDetailsModal.tsx (8 hunks)
  • Clients/src/presentation/components/Tags/TagChip.tsx (1 hunks)
  • Clients/src/presentation/components/Tags/index.ts (1 hunks)
  • Clients/src/presentation/pages/PolicyDashboard/PoliciesDashboard.tsx (2 hunks)
  • Clients/src/presentation/pages/PolicyDashboard/PolicyManager.tsx (1 hunks)
  • Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-11-18T05:28:01.115Z
Learnt from: MuhammadKhalilzadeh
Repo: bluewave-labs/verifywise PR: 254
File: Clients/src/presentation/components/Modals/Controlpane/index.tsx:22-24
Timestamp: 2024-11-18T05:28:01.115Z
Learning: In `Clients/src/presentation/components/Modals/Controlpane/index.tsx` (TypeScript React component), avoid changing prop types from specific types like `string` to `any` when the exact type is known. Maintaining explicit types ensures better type safety and code reliability.

Applied to files:

  • Clients/src/presentation/pages/PolicyDashboard/PoliciesDashboard.tsx
  • Clients/src/presentation/components/Policies/PolicyDetailsModal.tsx
  • Clients/src/presentation/pages/PolicyDashboard/PolicyManager.tsx
  • Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx
🧬 Code graph analysis (5)
Clients/src/domain/interfaces/IPolicy.ts (1)
Clients/src/domain/models/Common/policy/policyManager.model.ts (1)
  • PolicyManagerModel (25-55)
Clients/src/presentation/components/Tags/TagChip.tsx (1)
Clients/src/presentation/components/Tags/index.ts (1)
  • TagChipProps (2-2)
Clients/src/presentation/pages/PolicyDashboard/PoliciesDashboard.tsx (1)
Clients/src/domain/models/Common/policy/policyManager.model.ts (1)
  • PolicyManagerModel (25-55)
Clients/src/presentation/pages/PolicyDashboard/PolicyManager.tsx (5)
Clients/src/domain/interfaces/IPolicy.ts (1)
  • PolicyManagerProps (66-70)
Clients/src/domain/models/Common/policy/policyManager.model.ts (1)
  • PolicyManagerModel (25-55)
Clients/src/domain/interfaces/iAlert.ts (1)
  • AlertProps (22-31)
Clients/src/application/tools/alertUtils.ts (1)
  • handleAlert (32-32)
Clients/src/application/repository/policy.repository.ts (1)
  • deletePolicy (58-64)
Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx (2)
Clients/src/domain/interfaces/IPolicy.ts (2)
  • PolicyTemplatesProps (72-75)
  • PolicyTemplate (35-39)
Clients/src/domain/interfaces/iAlert.ts (1)
  • AlertProps (22-31)
🪛 GitHub Actions: Frontend Checks
Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx

[error] 14-14: TypeScript error TS6133: 'Typography' is declared but its value is never read.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (7)
Clients/src/presentation/components/Tags/TagChip.tsx (1)

55-75: Chip rendering is straightforward and consistent with MUI patterns.

The TagChip component is appropriately typed, keeps styling encapsulated via sx, and uppercases the visible text while preserving the original tag value. No issues from a UI/props perspective.

Clients/src/presentation/components/Tags/index.ts (1)

1-2: Barrel export is clean and ergonomic.

Re-exporting both TagChip and TagChipProps from the index keeps imports tidy for consumers (import { TagChip } from "…/Tags"). No issues here.

Clients/src/domain/interfaces/IPolicy.ts (2)

35-39: PolicyTemplate shape matches the modal/template flow.

PolicyTemplate having title, tags, and content is consistent with how PolicyDetailsModal uses templates to prefill the form and editor. No structural issues from a typing standpoint.


41-47: Template support on the detail modal props is well-scoped.

Adding template?: PolicyTemplate to PolicyDetailModalProps keeps the existing API intact while enabling template-based prefills. This is a good, minimal surface-area change.

Clients/src/presentation/pages/PolicyDashboard/PoliciesDashboard.tsx (1)

52-140: Tabbed composition and helper UX wiring look coherent.

The TabContext + TabBar setup, conditional rendering of PolicyManager vs PolicyTemplates, and PageTour driven by isInitialLoadComplete form a clear, maintainable structure. Passing fetchAll and tags down gives both tabs a single source of truth for data.

No blocking issues in this section.

Clients/src/presentation/components/Policies/PolicyDetailsModal.tsx (1)

426-501: Content initialization from policy/template is correct and reasonably safe.

Using policy?.content_html || template?.content with DOMPurify sanitization before deserializing into the Plate editor is a good approach. The allowed tags/attrs list looks strict enough to avoid obvious XSS vectors while still supporting rich text, links, and images.

Behaviorally, this means:

  • Editing an existing policy loads its saved HTML.
  • Creating from a template loads the template’s content.

No functional issues here given the current sanitize configuration.

Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx (1)

140-379: Overall PolicyTemplates implementation looks solid

Search + category filter, pagination (with persisted rowsPerPage), tag chips, and template-driven modal opening are wired cleanly. Aside from the minor issues above, the component is cohesive and matches the described UX.

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: 3

♻️ Duplicate comments (1)
Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx (1)

282-288: Fix pagination summary for zero items case.

This issue was previously flagged: when there are no filtered results, the summary incorrectly displays "Showing 1 - 0 of 0 items" because the start index always computes as page * rowsPerPage + 1. The start should be 0 when the list is empty.

Apply this diff:

-                   Showing {page * rowsPerPage + 1} -{" "}
+                   Showing{" "}
+                   {filteredPolicyTemplates.length === 0
+                     ? 0
+                     : page * rowsPerPage + 1}{" "}
+                   -{" "}
                    {Math.min(
                      page * rowsPerPage + rowsPerPage,
                      filteredPolicyTemplates.length,
                    )}{" "}
                    of {filteredPolicyTemplates.length} items
🧹 Nitpick comments (1)
Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx (1)

45-47: Consider typing the props parameter.

The any type reduces type safety. For better type inference, consider using React.ComponentProps<typeof ChevronsUpDown> or React.SVGProps<SVGSVGElement>.

Apply this diff:

-const SelectorVertical = (props: any) => (
+const SelectorVertical = (props: React.ComponentProps<typeof ChevronsUpDown>) => (
   <ChevronsUpDown size={16} {...props} />
 );
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb9b617 and b1b56fb.

📒 Files selected for processing (1)
  • Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-11-18T05:28:01.115Z
Learnt from: MuhammadKhalilzadeh
Repo: bluewave-labs/verifywise PR: 254
File: Clients/src/presentation/components/Modals/Controlpane/index.tsx:22-24
Timestamp: 2024-11-18T05:28:01.115Z
Learning: In `Clients/src/presentation/components/Modals/Controlpane/index.tsx` (TypeScript React component), avoid changing prop types from specific types like `string` to `any` when the exact type is known. Maintaining explicit types ensures better type safety and code reliability.

Applied to files:

  • Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx
🧬 Code graph analysis (1)
Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx (3)
Clients/src/domain/interfaces/IPolicy.ts (2)
  • PolicyTemplatesProps (72-75)
  • PolicyTemplate (35-39)
Clients/src/domain/interfaces/iAlert.ts (1)
  • AlertProps (22-31)
Clients/src/application/tools/alertUtils.ts (1)
  • handleAlert (32-32)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Frontend Checks / build-check
🔇 Additional comments (10)
Clients/src/presentation/pages/PolicyDashboard/PolicyTemplates.tsx (10)

1-35: LGTM - Imports are clean and well-organized.

All imports are used appropriately in the component. The previous Typography import issue has been resolved.


49-64: LGTM - State management is well-structured.

The component properly initializes state with appropriate types and retrieves pagination preferences from storage.


87-122: LGTM - Filtering and callback logic is correct.

The filtering logic efficiently handles both category and search filters with appropriate memoization. The page reset on filter change prevents showing empty pages.


124-137: LGTM - Pagination handlers are well-implemented.

The handlers correctly manage pagination state and persist user preferences to storage.


170-201: LGTM - Table structure and sticky header are well-implemented.

The scrollable container with sticky header provides good UX. The styling appropriately uses theme values for colors and spacing.


215-263: LGTM - Table rows are well-implemented with good accessibility.

The row implementation includes proper hover states, keyboard navigation support, and semantic ARIA labels. The ellipsis handling for long text is appropriate.


289-349: LGTM - Pagination controls are properly styled with theme values.

The custom pagination dropdown configuration is thorough and correctly uses theme values for consistent styling.


367-375: LGTM - Alert implementation is correct.

The alert component properly displays success messages with toast behavior and clears on click.


380-380: LGTM - Proper default export.


357-365: Modal won't render if user clicks template row before tags finish loading.

The guard tags.length > 0 is intentional—the modal needs available tags to populate a selector. However, this creates a UX issue: if the API fetching tags is slow or fails, clicking a template row will silently fail (setShowModal(true) executes but the modal never renders because the condition fails). Users get no feedback.

Recommend one of:

  1. Disable template rows until tags are loaded
  2. Show a loading indicator while tags are fetching
  3. Handle the empty tags case gracefully in the modal instead of blocking it

@gorkem-bwl
Copy link
Copy Markdown
Contributor

LGTM.

@swaleha456
Copy link
Copy Markdown
Contributor

@MuhammadKhalilzadeh LGTM!

Copy link
Copy Markdown
Member

@Br0wnHammer Br0wnHammer left a comment

Choose a reason for hiding this comment

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

LGTM!
One nit: please break large PRs into smaller chunks so as to make it easier to review them.

@MuhammadKhalilzadeh MuhammadKhalilzadeh merged commit 692028c into develop Nov 22, 2025
6 checks passed
@MuhammadKhalilzadeh MuhammadKhalilzadeh deleted the rb-nov-11-policy-templates-library branch November 22, 2025 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request frontend Frontend related tasks/issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Policy templates library

5 participants