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

feat: always show alerts tab and lock email alerts when keys are missing #1478

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

ghostdevv
Copy link
Contributor

@ghostdevv ghostdevv commented Nov 17, 2024

When I was testing my self hosted installation, I noticed that the alerts tab was missing. It was still accessible if I manually changed the url, and the webhook alerts were fully functional. This PR removes the feature flag alertsEnabled and makes the alerts page always visible. Similarly to the Slack alert, it'll now show a notice to the user if they don't have their resend configured for alerts.

image

It has the same behaviour as before for checking whether email alerts are enabled. It uses the two environment variables. I've never used Remix before so let me know if it's not safe to check those there. I think it is as I did see there is other server code in that file, and the remix docs say that loaders run on the server.

If there is interest, I could also update the self hosting docs with how to configure email alerts in a follow up pr?

✅ Checklist

  • I have followed every step in the contributing guide
  • The PR title follows the convention.
  • I ran and tested the code works

Summary by CodeRabbit

  • New Features

    • The "Alerts" menu item is now always visible in the side menu, enhancing accessibility.
    • The alert creation page now provides immediate feedback on email alert availability with a new input field or warning message.
  • Bug Fixes

    • Simplified the control flow related to alert settings by removing unnecessary conditions.
  • Documentation

    • Updated return values and properties in relevant functions to reflect the removal of the alertsEnabled feature.

Copy link
Contributor

coderabbitai bot commented Nov 17, 2024

Walkthrough

The changes in this pull request involve modifications to several components in the web application related to alert features. The "Alerts" menu item in the SideMenu is now always rendered, removing the conditional logic based on a feature flag. The TriggerFeatures type and featuresForHost function have been updated to eliminate the alertsEnabled property. The useFeatures hook has been adjusted to return a simplified object without the alertsEnabled property. Lastly, the alert creation page has been enhanced to include a new property indicating if email alerts are enabled, improving user feedback.

Changes

File Change Summary
apps/webapp/app/components/navigation/SideMenu.tsx Removed conditional rendering for "Alerts" menu item; it is now always displayed.
apps/webapp/app/features.server.ts Updated TriggerFeatures type by removing alertsEnabled; modified featuresForHost function to eliminate related logic.
apps/webapp/app/hooks/useFeatures.ts Changed return value of useFeatures() to exclude alertsEnabled, now returning only { isManagedCloud, v3Enabled }.
apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.alerts.new/route.tsx Added emailAlertsEnabled to the loader's return value; modified rendering logic in the Page component to conditionally display email input based on this state.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SideMenu
    participant Features
    participant AlertsPage

    User->>SideMenu: Open Menu
    SideMenu->>User: Display "Alerts" Item
    User->>AlertsPage: Navigate to Alerts
    AlertsPage->>Features: Check emailAlertsEnabled
    Features-->>AlertsPage: Return emailAlertsEnabled
    AlertsPage->>User: Show Email Input or Warning
Loading

🐰 "In the menu, the Alerts now shine,
Always there, a change so fine.
No more flags to hide away,
Just clear paths for a brighter day.
With emails set to guide our flight,
We hop along, all feels just right!" 🌟

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/webapp/app/components/navigation/SideMenu.tsx

(node:42229) ESLintIgnoreWarning: The ".eslintignore" file is no longer supported. Switch to using the "ignores" property in "eslint.config.js": https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files
(Use node --trace-warnings ... to show where the warning was created)

Oops! Something went wrong! :(

ESLint: 9.15.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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 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.

Copy link
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: 0

🧹 Outside diff range and nitpick comments (1)
apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.alerts.new/route.tsx (1)

291-294: Enhance the warning message with specific configuration details.

The warning message could be more helpful by specifying which configuration is missing (FROM email and Resend API key).

Consider updating the warning message to be more specific:

-                  Email integration is not available. Please contact your organization
-                  administrator.
+                  Email integration is not available because the FROM email or Resend API key
+                  is not configured. Please contact your organization administrator to set up
+                  the email configuration.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 332854b and 0cd501a.

📒 Files selected for processing (4)
  • apps/webapp/app/components/navigation/SideMenu.tsx (1 hunks)
  • apps/webapp/app/features.server.ts (0 hunks)
  • apps/webapp/app/hooks/useFeatures.ts (1 hunks)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.alerts.new/route.tsx (4 hunks)
💤 Files with no reviewable changes (1)
  • apps/webapp/app/features.server.ts
🔇 Additional comments (4)
apps/webapp/app/hooks/useFeatures.ts (2)

8-8: LGTM! Change aligns with PR objectives.

The removal of alertsEnabled from the default return value is consistent with the PR's goal of removing this feature flag and making alerts always visible.


Line range hint 1-9: Verify dependent components and type updates.

Let's ensure this change is consistent across the codebase.

✅ Verification successful

Based on the shell script results, I can generate the final response as we have sufficient information:

Changes are consistent with feature flag usage across the codebase

The verification shows:

  • TriggerFeatures type in features.server.ts only includes isManagedCloud and v3Enabled
  • No remaining references to alertsEnabled were found
  • All components using useFeatures() hook only access isManagedCloud and v3Enabled flags
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the removal of alertsEnabled across the codebase

# Check if TriggerFeatures type has been updated
echo "Checking TriggerFeatures type definition:"
rg -A 5 "type TriggerFeatures" apps/webapp/app/features.server.ts

# Find any remaining references to alertsEnabled that might need updating
echo "\nChecking for any remaining references to alertsEnabled:"
rg "alertsEnabled" apps/webapp/

# Find components using useFeatures hook to verify they handle the new return type
echo "\nFinding components using useFeatures hook:"
rg "useFeatures\(\)" apps/webapp/

Length of output: 1689

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.v3.$projectParam.alerts.new/route.tsx (1)

26-26: LGTM! Server-side environment variable check is implemented correctly.

The implementation securely checks for required email configuration variables (ALERT_FROM_EMAIL and ALERT_RESEND_API_KEY) in the server-side loader function, following Remix's best practices.

Also applies to: 154-156, 160-160

apps/webapp/app/components/navigation/SideMenu.tsx (1)

686-692: LGTM! Implementation follows established patterns.

The Alerts menu item is well-implemented, following the consistent pattern of other menu items in the V3ProjectSideMenu component.

Let's verify that the alerts route is properly configured:

✅ Verification successful

Route is properly configured and actively used

The verification shows that v3ProjectAlertsPath is:

  • Correctly defined in pathBuilder.ts with proper organization and project parameters
  • Used in multiple route handlers:
    • alerts/route.tsx for the main alerts view
    • alerts.new/route.tsx for creating new alerts
  • Actively used for navigation and redirects in the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the v3ProjectAlertsPath route exists and is properly configured

# Check for the route definition
rg -A 5 "v3ProjectAlertsPath"

# Check for any route handlers or components related to alerts
ast-grep --pattern 'export function $_(organization, project) {
  $$$
  return $$$alerts$$$;
}'

Length of output: 8381

@ghostdevv
Copy link
Contributor Author

I was worried there might be conflicts with #1474, but it looks like we're changing very different parts of the same file. So we should be ok!

Copy link
Member

@matt-aitken matt-aitken left a comment

Choose a reason for hiding this comment

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

@ghostdevv thanks, this looks great

@matt-aitken matt-aitken merged commit 54017cb into triggerdotdev:main Nov 28, 2024
1 check passed
@ghostdevv ghostdevv deleted the always-show-alerts branch December 18, 2024 07:08
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.

2 participants