middleware icon indicating copy to clipboard operation
middleware copied to clipboard

PR Incident Filters UI Component

Open Kamlesh72 opened this issue 11 months ago • 3 comments

Linked Issue(s)

Ref #557

Further Comments

This is a stacked PR on top of https://github.com/middlewarehq/middleware/pull/656

Proposed changes (including videos or screenshots)

https://github.com/user-attachments/assets/32360116-bd48-4ce1-80dc-2bf6c06cc414

Summary by CodeRabbit

  • New Features
    • Introduced a user interface for configuring regex-based incident pull request (PR) filters at the team level, including options to add, edit, or remove filters and to include or exclude reverted PRs.
    • Added a modal in team settings to manage incident PR filters.
  • Enhancements
    • Incident PR filter settings now affect Dora metrics calculations and reporting.
    • Improved feedback with success and error notifications when updating filter settings.

Kamlesh72 avatar May 22 '25 05:05 Kamlesh72

Walkthrough

This change introduces support for configuring and managing incident pull request (PR) filters at the team level. It adds a new API endpoint, Redux state management, TypeScript types, UI components, and updates utility functions to handle incident PR filter settings, enabling teams to customize how incident PRs are identified and processed.

Changes

File(s) Change Summary
web-server/pages/api/internal/team/[team_id]/incident_prs_filter.ts Added new API route for GET/PUT of team incident PR filter settings, including Yup validation and internal endpoint integration.
web-server/src/components/DoraMetricsConfigurationSettings.tsx Enhanced settings component to support and display configuration UI for incident PR filters, including modal logic and Redux dispatches.
web-server/src/components/TeamIncidentPRsFilter.tsx Added new React component for configuring incident PR filters, with dynamic fields, validation, state management, and save logic.
web-server/src/slices/team.ts Introduced Redux state, async thunks, and reducers for fetching and updating team incident PR filter settings.
web-server/src/types/resources.ts Added new TypeScript types for incident PR filter settings and API responses.
web-server/src/utils/cockpitMetricUtils.ts Updated utility function to accept and apply incident PR filter parameters in metric API requests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DoraSettings as DoraMetricsConfigurationSettings
    participant Modal as TeamIncidentPRsFilter Modal
    participant Redux
    participant API
    participant Backend

    User->>DoraSettings: Click "Incident PR Filter" menu item
    DoraSettings->>Modal: Open TeamIncidentPRsFilter modal
    Modal->>Redux: Dispatch fetchTeamIncidentPRsFilter (team_id)
    Redux->>API: GET /internal/team/{team_id}/incident_prs_filter
    API->>Backend: Fetch incident PR filter settings
    Backend-->>API: Return settings
    API-->>Redux: Return settings
    Redux-->>Modal: Provide incident PR filter settings

    User->>Modal: Edit and save filters
    Modal->>Redux: Dispatch updateTeamIncidentPRsFilter (team_id, setting)
    Redux->>API: PUT /internal/team/{team_id}/incident_prs_filter
    API->>Backend: Update settings
    Backend-->>API: Return updated settings
    API-->>Redux: Return updated settings
    Redux-->>Modal: Confirm update
    Modal->>Redux: Dispatch fetchDoraMetrics (with updated filters)

Possibly related PRs

  • middlewarehq/middleware#650: Implements backend support for IncidentPrsSetting, including data model and filtering logic for revert PRs, directly complementing the frontend and API changes here.
  • middlewarehq/middleware#656: Adds backend logic for applying incident PR filters to analytics and metrics, which aligns with the client-side and API interface introduced in this PR.

Poem

🐇
A filter for incidents, precise and neat,
Now teams can tailor which PRs they meet.
Regex and toggles, all wrapped in a form,
With modals and metrics, it’s far from the norm!
Settings are saved, the state is refreshed—
In the garden of code, our features have meshed.

— A rabbit, hopping through PRs


📜 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 a02603aa7d585d38ac4f04fc420996bc499a618d and 2f35ad49f31ba79fd9582609b323823ec2c24cf3.

📒 Files selected for processing (2)
  • web-server/pages/api/internal/team/[team_id]/incident_prs_filter.ts (1 hunks)
  • web-server/src/components/TeamIncidentPRsFilter.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • web-server/pages/api/internal/team/[team_id]/incident_prs_filter.ts
  • web-server/src/components/TeamIncidentPRsFilter.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: All file linting
✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

coderabbitai[bot] avatar May 22 '25 05:05 coderabbitai[bot]

@coderabbitai full review

adnanhashmi09 avatar May 25 '25 23:05 adnanhashmi09

✅ Actions performed

Full review triggered.

coderabbitai[bot] avatar May 25 '25 23:05 coderabbitai[bot]