Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: move compliance overview to a dedicated recap page #1444

Merged
merged 5 commits into from
Jan 28, 2025

Conversation

ab-smith
Copy link
Contributor

@ab-smith ab-smith commented Jan 28, 2025

  • wip
  • wip
  • wip
  • checkpoint
  • ready for review

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new "Recap" section for compliance assessments
    • Introduced navigation link to the Recap page
  • User Interface Changes

    • Removed detailed compliance assessment display from Analytics page
    • Created a new card-style layout for the Recap page
  • Localization

    • Added new translation entries for "Recap" and "Section moved" in English and French languages
  • Performance

    • Streamlined analytics page by removing complex compliance assessment rendering

Copy link

coderabbitai bot commented Jan 28, 2025

Walkthrough

This pull request introduces a new "Recap" feature for compliance assessments. The changes involve adding a new navigation item, creating a dedicated recap page, and modifying existing analytics pages. The implementation includes updating translation files, adding a new server-side load function, and creating a Svelte component to display project compliance information. The changes represent a significant restructuring of how compliance assessment data is presented to users.

Changes

File Change Summary
frontend/messages/en.json Added entries for "recap" and "sectionMoved"
frontend/messages/fr.json Added French translations for "recap" and "sectionMoved"
frontend/src/lib/components/SideBar/navData.ts Added new navigation item for recap with icon and permissions
frontend/src/routes/(app)/(internal)/analytics/+page.server.ts Removed project compliance data fetching logic
frontend/src/routes/(app)/(internal)/analytics/+page.svelte Removed compliance assessment display components and imports
frontend/src/routes/(app)/(internal)/recap/+layout.svelte Created new layout component with card styling
frontend/src/routes/(app)/(internal)/recap/+page.server.ts Added new server-side load function for fetching project compliance data
frontend/src/routes/(app)/(internal)/recap/+page.svelte Created new Svelte component to display compliance recap

Sequence Diagram

sequenceDiagram
    participant User
    participant NavBar
    participant RecapPage
    participant API
    
    User->>NavBar: Click "Recap" navigation item
    NavBar->>RecapPage: Navigate to /recap
    RecapPage->>API: Fetch project compliance data
    API-->>RecapPage: Return project analytics
    RecapPage->>RecapPage: Process and render compliance data
    RecapPage->>User: Display project compliance overview
Loading

Possibly related PRs

Poem

🐰 A Rabbit's Recap Rhyme 🍃

Compliance data, once hidden away,
Now dances in charts, bright as day!
A new page springs forth with glee,
Metrics mapped for all to see
Hop along the compliance trail! 🏆

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 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. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@ab-smith ab-smith added the perf label Jan 28, 2025
Copy link

@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: 0

🧹 Nitpick comments (9)
frontend/src/routes/(app)/(internal)/recap/+page.server.ts (5)

6-13: Ensure consistent naming and documentation for status constants.

This array of requirement statuses is clear, but consider adding a brief comment indicating its usage or referencing it in other modules for better maintainability.


22-25: Clarify or add a JSDoc for RequirementAssessmentDonutItem interface.

To enhance readability and self-documentation, consider adding a short JSDoc comment describing the interface properties and how they're used.


34-95: Check HTTP response status before parsing JSON.

Currently, the code directly proceeds to use res.json() without confirming res.ok. Consider adding a check for res.ok to handle potential 4xx or 5xx errors more explicitly. This will improve reliability and clarity of error handling.

 const projects: ProjectAnalytics[] = await fetch(`${BASE_API_URL}/projects/`)
-  .then((res) => res.json())
+  .then(async (res) => {
+    if (!res.ok) {
+      throw new Error(`Failed to fetch projects: ${res.status} ${res.statusText}`);
+    }
+    return res.json();
+  })
   .then(async (projects) => {
     ...

130-133: Standardize the displayed percentage format.

Currently, percentages display as a string with a single decimal or 0. Consider always showing a single decimal place (e.g., "0.0") for consistency.

- percentage: totalValue > 0 ? ((item.value / totalValue) * 100).toFixed(1) : '0'
+ percentage: totalValue > 0 ? ((item.value / totalValue) * 100).toFixed(1) : '0.0'

140-145: Consider returning additional metadata.

If further analytics or metrics may be needed downstream (e.g., per-framework compliance levels), extend the return object to include more fields. This can help avoid repeated fetches.

frontend/src/routes/(app)/(internal)/recap/+page.svelte (3)

11-18: Reuse the requirement statuses across the client and server.

The REQUIREMENT_ASSESSMENT_STATUS array is defined in both client and server code. Consider centralizing it for consistency across layers if possible.


66-81: Handle potential negative or undefined scores gracefully.

While the condition checks >= 0, any future code changes or data anomalies could lead to unexpected values. Consider how to handle negative or null scores more explicitly.


88-108: Consider a dedicated component for compliance assessment cards.

This section includes repeated logic for displaying compliance data, edit/export links, etc. Extracting it into a smaller component can improve maintainability and readability.

frontend/src/routes/(app)/(internal)/analytics/+page.svelte (1)

507-510: Enhance accessibility and clean up the implementation.

The link to the recap section could be improved:

  1. Remove the empty div as it serves no purpose
  2. Add aria-label for better accessibility
  3. Use CSS variables for hover color to maintain consistency
-				<span class="text-xl font-extrabold"
-					><a href="/recap" class="hover:text-purple-500">{m.sectionMoved()}</a></span
-				>
-				<div class="flex flex-col space-y-2"></div>
+				<span class="text-xl font-extrabold">
+					<a
+						href="/recap"
+						class="hover:text-primary-500"
+						aria-label={m.sectionMoved()}
+					>
+						{m.sectionMoved()}
+					</a>
+				</span>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 625e07b and 88f1aa7.

📒 Files selected for processing (8)
  • frontend/messages/en.json (1 hunks)
  • frontend/messages/fr.json (1 hunks)
  • frontend/src/lib/components/SideBar/navData.ts (1 hunks)
  • frontend/src/routes/(app)/(internal)/analytics/+page.server.ts (0 hunks)
  • frontend/src/routes/(app)/(internal)/analytics/+page.svelte (2 hunks)
  • frontend/src/routes/(app)/(internal)/recap/+layout.svelte (1 hunks)
  • frontend/src/routes/(app)/(internal)/recap/+page.server.ts (1 hunks)
  • frontend/src/routes/(app)/(internal)/recap/+page.svelte (1 hunks)
💤 Files with no reviewable changes (1)
  • frontend/src/routes/(app)/(internal)/analytics/+page.server.ts
✅ Files skipped from review due to trivial changes (3)
  • frontend/src/routes/(app)/(internal)/recap/+layout.svelte
  • frontend/messages/fr.json
  • frontend/messages/en.json
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: startup-functional-test (3.12)
  • GitHub Check: startup-docker-compose-test
  • GitHub Check: enterprise-functional-tests (3.12, chromium)
  • GitHub Check: enterprise-startup-functional-test (3.12)
  • GitHub Check: enterprise-startup-docker-compose-test
  • GitHub Check: migrations-check (3.12)
  • GitHub Check: functional-tests (3.12, chromium)
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
frontend/src/routes/(app)/(internal)/recap/+page.server.ts (1)

96-137: Guard against missing or undefined compliance_assessments.

While the fetch logic initializes project.compliance_assessments, there’s a remote risk that the property could be missing or corrupted. If you intend to handle partial or empty project data gracefully, you may want to verify existence before iterating.

frontend/src/routes/(app)/(internal)/recap/+page.svelte (1)

37-45: Double-check sorting logic for statuses.

Sorting by array index is fine, but ensure that the order of statuses in the UI aligns with user expectations or business logic (e.g., grouping “compliant” vs. “non_compliant” side by side).

frontend/src/lib/components/SideBar/navData.ts (1)

198-203: Ensure permission alignment with your compliance recap.

You’ve added 'view_complianceassessment' as the required permission for “recap.” Verify that this permission is the correct scope for reading or summarizing compliance data. Consider introducing a more specific permission if you plan to restrict certain recap details.

frontend/src/routes/(app)/(internal)/analytics/+page.svelte (1)

15-15: LGTM! Import changes align with the compliance overview move.

The addition of tableSourceMapper and removal of unused imports keeps the code clean.

@ab-smith ab-smith changed the title move compliance overview refactor!: move compliance overview to a dedicated recap page Jan 28, 2025
@ab-smith ab-smith merged commit bb7c019 into main Jan 28, 2025
18 checks passed
@ab-smith ab-smith deleted the move_compliance_overview branch January 28, 2025 19:24
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant