Skip to content

Mariano/risk improvements - #267

Merged
Marfuen merged 8 commits into
mainfrom
mariano/risk-improvements
Apr 3, 2025
Merged

Marfuen merged 8 commits into
mainfrom
mariano/risk-improvements

Conversation

@Marfuen

@Marfuen Marfuen commented Apr 3, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Introduced new risk matrix visualizations for vendor inherent and residual risk, offering a dynamic 5x5 grid that clearly displays risk levels.
    • Added detailed assignee analytics and filtering in tables, registers, and dashboards for enhanced vendor and task management.
  • Refactor & Style

    • Standardized terminology across the application by replacing “owner” with “assignee” in forms, charts, and UI labels.
    • Updated form labels and visual cues (e.g., “Vertical Axis,” “Horizontal Axis”) for clearer risk assessment and improved user experience.

Marfuen added 8 commits April 3, 2025 18:03
…mas, actions, and components for improved clarity and consistency
…rity

- Removed redundant risk level translation logic from InherentRiskVendorChart and ResidualRiskVendorChart components.
- Updated layout for better responsiveness in risk chart headers.
- Enhanced visual representation of risk levels by adjusting styles in risk chart cells.
- Cleaned up form submission logic in InherentRiskForm and ResidualRiskForm by removing console logs and ensuring router refresh after successful submissions.
…dates

- Integrated useSearchParams in InherentRiskForm and ResidualRiskForm for better state management.
- Updated form submission logic to force page refresh instead of router manipulation.
- Added descriptive labels to select fields for clarity on risk levels.
- Cleaned up unnecessary comments and improved toast notifications for user feedback.
- Changed assigneeId in createRiskSchema, updateRiskSchema, createTaskSchema, updateTaskSchema, and updatePolicyFormSchema to be optional and nullable for improved flexibility in form submissions.
… and UI

- Added visual order for likelihood rendering in InherentRiskVendorChart and ResidualRiskVendorChart for better clarity.
- Streamlined grid cell rendering logic to improve performance and maintainability.
- Updated form submission logic in InherentRiskForm and ResidualRiskForm to ensure proper page refresh and state management after successful updates.
- Removed unnecessary console logs and improved user feedback through toast notifications.
@vercel

vercel Bot commented Apr 3, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app 🔄 Building (Inspect) Visit Preview 💬 Add feedback Apr 3, 2025 10:47pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
comp-portal ⬜️ Skipped (Inspect) Apr 3, 2025 10:47pm

@coderabbitai

coderabbitai Bot commented Apr 3, 2025 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request refactors a large portion of the codebase to transition from using “owner” terminology to “assignee” terminology. Changes span multiple layers including action files, form components, UI elements, API endpoints, Prisma schema definitions, and SQL migration scripts. Most modifications involve renaming variables (e.g. ownerId to assigneeId), updating props and types, and adjusting query logic and UI components with minor formatting improvements. The overall functionality remains intact while adopting a consistent assignee-centered structure across tasks, vendors, risks, and related API responses.

Changes

File(s) Change Summary
apps/app/src/actions/risk/task/update-task-action.ts, .../employees/all/types/search-params.ts, .../risk/[riskId]/tasks/search-params.ts Simplified assigneeId assignment in action calls and renamed search parameters from ownerId to assigneeId.
apps/app/src/actions/schema.ts, apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/page.tsx, .../update-title-and-description-form.tsx, .../update-task-overview-form.tsx General code formatting and indentation improvements; removal of debugging console logs.
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/risk/(overview)/layout.tsx, .../vendors/[vendorId]/components/inherent-risk-vendor-chart.tsx, .../vendors/[vendorId]/components/residual-risk-vendor-chart.tsx UI component updates including a new risk matrix visualization and refined filtering in assignee queries (excluding “employee” roles).
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/actions/{create-task-action.ts, update-vendor-action.ts, update-vendor-residual-risk.ts} Vendor actions updated to replace ownerId with assigneeId; adjustments include removal of some checks and addition of revalidation calls.
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/{components,forms}/** (e.g. TitleAndDescription.tsx, UpdateSecondaryFieldsForm.tsx, CreateVendorTaskForm.tsx, CreateVendorForm.tsx, CreateVendorSheet.tsx) Component and form updates to accept new assignee props instead of owner data; types and the selection component changed to use SelectAssignee.
apps/app/src/app/api/v1/risks/{[id]/route.ts, route.ts}, packages/docs/api-reference/v1/risks.mdx API endpoints and documentation adjusted to include assigneeId with a nested assignee.user structure and an added email field in responses.
packages/db/prisma/migrations/*, packages/db/prisma/schema/{auth.prisma, task.prisma, vendor.prisma} Prisma schema and migration scripts updated: removed ownerId/owner fields and introduced assigneeId/assignee, with changes to relationships, constraints, and indexes.
apps/app/src/locales/core/common.ts, apps/app/src/components/tables/{policies/filter-toolbar.tsx, risk-register/*, risk-tasks/*} Localization and filter toolbar components updated: renamed keys and variables from owner/ownerId to assignee/assigneeId along with updated UI labels.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant RF as RiskForm Component
    participant QS as QueryState Hook
    participant API as Risk API
    U->>RF: Fill out risk form & submit
    RF->>API: POST risk data with assigneeId
    API-->>RF: Return success/error response
    RF->>QS: Update query state (set open to null) & update URL
    QS-->>RF: URL updated, form closed
Loading
sequenceDiagram
    participant U as User
    participant VS as VendorSheet Component
    participant VF as VendorForm Component
    participant API as Vendor API
    U->>VS: Open vendor creation sheet
    VS->>VF: Render form with available assignees
    U->>VF: Fill out form, select an assignee
    VF->>API: Submit vendor creation with assigneeId
    API-->>VF: Return vendor creation confirmation
    VF->>VS: Close sheet and update vendor list
Loading

Possibly related PRs

Poem

I'm a clever rabbit with code in my paws,
Hopping from owners to assignees without a pause.
Fields and schemas now sing in a fresh, new light,
Risk matrices and forms dancing through the night.
In our code burrow, every fix feels just right!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1be1074 and 3755f69.

📒 Files selected for processing (56)
  • apps/app/src/actions/risk/task/update-task-action.ts (1 hunks)
  • apps/app/src/actions/schema.ts (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/components/SelectAssignee.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/employees/all/types/search-params.ts (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/page.tsx (0 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/risk/(overview)/layout.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/risk/[riskId]/page.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/risk/[riskId]/tasks/search-params.ts (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/(overview)/layout.tsx (3 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/actions/task/create-task-action.ts (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/actions/update-vendor-action.ts (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/actions/update-vendor-residual-risk.ts (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/components/inherent-risk-vendor-chart.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/components/inherent-risk.tsx (3 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/components/residual-risk-vendor-chart.tsx (2 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/components/residual-risk.tsx (3 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/components/secondary-fields/secondary-fields.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/components/secondary-fields/update-secondary-fields-form.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/components/tasks/create-vendor-task-form.tsx (2 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/components/title-and-description/title-and-description.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/components/title-and-description/update-title-and-description-form.tsx (2 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/forms/risks/inherent-risk-form.tsx (9 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/forms/risks/residual-risk-form.tsx (9 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/page.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/[vendorId]/tasks/[taskId]/page.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/actions/create-vendor-action.ts (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/components/create-vendor-form.tsx (4 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/components/create-vendor-sheet.tsx (3 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/register/components/VendorRegisterColumns.tsx (2 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/register/components/VendorRegisterTable.tsx (3 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/vendors/register/page.tsx (3 hunks)
  • apps/app/src/app/api/v1/risks/[id]/route.ts (3 hunks)
  • apps/app/src/app/api/v1/risks/route.ts (5 hunks)
  • apps/app/src/components/forms/risks/task/update-task-form.tsx (2 hunks)
  • apps/app/src/components/forms/risks/task/update-task-overview-form.tsx (2 hunks)
  • apps/app/src/components/forms/risks/update-risk-form.tsx (2 hunks)
  • apps/app/src/components/policies/charts/policies-by-assignee.tsx (1 hunks)
  • apps/app/src/components/tables/policies/filter-toolbar.tsx (3 hunks)
  • apps/app/src/components/tables/risk-register/columns.tsx (3 hunks)
  • apps/app/src/components/tables/risk-register/data-table-header.tsx (1 hunks)
  • apps/app/src/components/tables/risk-register/data-table.tsx (2 hunks)
  • apps/app/src/components/tables/risk-register/filter-toolbar.tsx (2 hunks)
  • apps/app/src/components/tables/risk-register/server-columns.tsx (1 hunks)
  • apps/app/src/components/tables/risk-tasks/data-table-header.tsx (1 hunks)
  • apps/app/src/components/tables/risk-tasks/data-table.tsx (2 hunks)
  • apps/app/src/components/tables/risk-tasks/filter-toolbar.tsx (1 hunks)
  • apps/app/src/components/tables/risk-tasks/server-columns.tsx (1 hunks)
  • apps/app/src/data/tools/risks.ts (1 hunks)
  • apps/app/src/locales/core/common.ts (1 hunks)
  • packages/db/prisma/migrations/20250403205655_vendor_assignee/migration.sql (1 hunks)
  • packages/db/prisma/migrations/20250403205840_oops_optional/migration.sql (1 hunks)
  • packages/db/prisma/migrations/20250403210049_task_assignee_optional_too/migration.sql (1 hunks)
  • packages/db/prisma/schema/auth.prisma (1 hunks)
  • packages/db/prisma/schema/task.prisma (1 hunks)
  • packages/db/prisma/schema/vendor.prisma (1 hunks)
  • packages/docs/api-reference/v1/risks.mdx (6 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

This branch had an error being deployed

1 failed and 1 inactive deployments
Preview – app — 3755f693 Deployed Apr 3, 2025 by vercel[bot]
Preview – comp-portal — 3755f693 Deployed Apr 3, 2025 by vercel[bot]
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