-
Notifications
You must be signed in to change notification settings - Fork 20
feat(sidebar): hide unauthorized settings buttons in the sidebar for non-admins #596
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?
Changes from all commits
4e38e04
97dd83a
87d7117
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -464,8 +464,13 @@ export const WorkspaceSettingsRoute = () => { | |
| // a second time with the role-correct default if the URL is bare. | ||
| const callerCanManage = | ||
| settings?.my_policies?.includes("member:manage") ?? false; | ||
| const defaultTab: TabValue = | ||
| settings?.my_role === "billing" && !callerCanManage ? "billing" : "general"; | ||
| const canEditSettings = | ||
| settings?.my_policies?.includes("settings:manage") ?? false; | ||
| const defaultTab: TabValue = canEditSettings | ||
| ? "general" | ||
| : settings?.my_role === "billing" | ||
| ? "billing" | ||
| : "members"; | ||
|
Comment on lines
+467
to
+473
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Defer default-tab redirect until settings are loaded. Line 469 computes a fallback before Suggested fix- const defaultTab: TabValue = canEditSettings
- ? "general"
- : settings?.my_role === "billing"
- ? "billing"
- : "members";
+ const defaultTab: TabValue | null = settings
+ ? canEditSettings
+ ? "general"
+ : settings.my_role === "billing"
+ ? "billing"
+ : "members"
+ : null;
const activeTab: TabValue = segmentIsValid
? (segment as TabValue)
- : defaultTab;
+ : (defaultTab ?? "members");
@@
useEffect(() => {
if (!workspaceId) return;
- if (segment !== activeTab) {
- navigate(`/w/${workspaceId}/settings/${activeTab}${urlSearch}`, {
+ if (!segmentIsValid) {
+ if (!defaultTab) return;
+ navigate(`/w/${workspaceId}/settings/${defaultTab}${urlSearch}`, {
replace: true,
});
}
- }, [workspaceId, segment, activeTab, navigate, urlSearch]);
+ }, [workspaceId, segmentIsValid, defaultTab, navigate, urlSearch]);Also applies to: 483-490 🤖 Prompt for AI Agents |
||
| const activeTab: TabValue = segmentIsValid | ||
| ? (segment as TabValue) | ||
| : defaultTab; | ||
|
|
@@ -599,8 +604,6 @@ export const WorkspaceSettingsRoute = () => { | |
|
|
||
| const canManage = callerCanManage; | ||
| const myAppUserId = meV2?.id ?? null; | ||
| const canEditSettings = | ||
| settings.my_policies?.includes("settings:manage") ?? false; | ||
| const seesFinancials = | ||
| settings.my_policies?.includes("workspace:view_invoices") ?? false; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.