-
Notifications
You must be signed in to change notification settings - Fork 215
Add toggle for version upgrade notification (#815) #825
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
base: main
Are you sure you want to change the base?
Add toggle for version upgrade notification (#815) #825
Conversation
WalkthroughThis PR adds organization-level control for upgrade toast visibility. It introduces a new database column, server-side getter/setter functions, and UI components to toggle the setting. The upgrade toast display is now conditional, showing only when enabled OR when the user has owner role. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client<br/>(Browser)
participant ServerAction as Server Action<br/>(getUpgradeToastEnabled)
participant DB as Database<br/>(Org)
participant Component as UpgradeToast<br/>Component
Client->>ServerAction: layout.tsx requests setting<br/>(on page load)
ServerAction->>DB: fetch Org by domain
DB-->>ServerAction: Org record with<br/>upgradeToastEnabled flag
ServerAction-->>Client: return boolean or<br/>ServiceError
Client->>Component: render conditionally if<br/>setting enabled OR user.role=OWNER
alt Setting Enabled OR Owner Role
Component-->>Client: display UpgradeToast
else
Component-->>Client: hide UpgradeToast
end
sequenceDiagram
participant User as User<br/>(Owner)
participant UI as UpgradeToastToggle<br/>Component
participant ServerAction as Server Action<br/>(setUpgradeToastEnabled)
participant Auth as Auth Check<br/>(withAuth/withOrgMembership)
participant DB as Database<br/>(Org)
User->>UI: clicks toggle switch
UI->>UI: set isLoading=true<br/>(disable switch)
UI->>ServerAction: call setUpgradeToastEnabled<br/>(domain, enabled)
ServerAction->>Auth: verify user authenticated<br/>and is org owner
Auth-->>ServerAction: validated
ServerAction->>DB: update Org.metadata<br/>with upgradeToastEnabled
DB-->>ServerAction: update successful
ServerAction-->>UI: return true
UI->>UI: update local state<br/>show success toast
UI->>UI: set isLoading=false<br/>(enable switch)
UI-->>User: display confirmation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 🧪 Unit Test Generation v2 is now available!We have significantly improved our unit test generation capabilities. To enable: Add this to your reviews:
finishing_touches:
unit_tests:
enabled: trueTry it out by using the Have feedback? Share your thoughts on our Discord thread! 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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/db/prisma/schema.prisma`:
- Around line 277-278: The schema added a top-level Org.upgradeToastEnabled
column but actions.ts still reads/writes the value from metadata JSON; update
the implementation to use the new column directly: replace uses of
getOrgMetadata(...).upgradeToastEnabled with reading org.upgradeToastEnabled
(defaulting to true if null) and change updates that build mergedMetadata/
prisma.org.update({ data: { metadata: ... } }) to instead call
prisma.org.update({ data: { upgradeToastEnabled: enabled } }) in the functions
around lines where prisma.org.update and getOrgMetadata are used; also remove
upgradeToastEnabled from orgMetadataSchema in types.ts so the field is not
duplicated in metadata.
🧹 Nitpick comments (1)
packages/web/src/actions.ts (1)
1813-1837: Consider adding authentication togetUpgradeToastEnabled.Unlike
getAnonymousAccessStatuswhich legitimately needs to be called before authentication (to determine if anonymous access is allowed),getUpgradeToastEnabledis only called in authenticated contexts (layout.tsx after session check). Consider wrapping withwithAuthfor consistency, or document why public access is intentional.
This PR closes #815 by adding an organization-wide toggle to control who sees the upgrade toast. When the toggle is enabled, the toast is shown to all users. Otherwise, the toast is only shown to the owner. The toggle is displayed on the access control page. For backward compatibility, the toggle is enabled by default.
I have tested the feature locally by changing the version in version.ts.
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.