Skip to content

Commit bf78626

Browse files
committed
fix(sidebar): simplify organization profile controls
1 parent ac48105 commit bf78626

3 files changed

Lines changed: 8 additions & 67 deletions

File tree

apps/sim/app/o/[organizationId]/components/organization-sidebar/components/organization-footer/organization-footer.test.tsx

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ const { mockNavigate, mockPush, context } = vi.hoisted(() => ({
1010
mockPush: vi.fn(),
1111
context: {
1212
organization: { id: 'org-1' },
13-
viewer: { isAdmin: true },
14-
settingsFeatures: {
15-
billingEnabled: true,
16-
hasEnterprisePlan: false,
17-
hosted: true,
18-
selfHosted: {},
19-
},
20-
connectedAccountsAvailable: true,
21-
searchAccess: { memberScoped: true },
2213
},
2314
}))
2415

@@ -52,9 +43,6 @@ vi.mock('next/link', () => ({
5243
),
5344
}))
5445
vi.mock('@/lib/auth/sign-out', () => ({ signOutAndRedirect: vi.fn() }))
55-
vi.mock('@/lib/auth/auth-client', () => ({
56-
useSession: () => ({ data: { user: { id: 'user-1' } } }),
57-
}))
5846
vi.mock('@/lib/desktop', () => ({ getDesktopUpdates: () => null }))
5947
vi.mock('@/hooks/use-desktop-update-state', () => ({
6048
useDesktopUpdateState: () => ({ status: 'idle' }),
@@ -69,8 +57,6 @@ vi.mock('@/app/workspace/[workspaceId]/w/components/sidebar/components', () => (
6957
SidebarTooltip: ({ children }: { children: React.ReactNode }) => children,
7058
}))
7159
vi.mock('@/components/icons', () => ({
72-
CodeIcon: () => <svg />,
73-
McpIcon: () => <svg />,
7460
SlackIcon: () => <svg />,
7561
}))
7662

@@ -83,8 +69,6 @@ let root: Root
8369
beforeEach(() => {
8470
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
8571
vi.clearAllMocks()
86-
context.viewer.isAdmin = true
87-
context.settingsFeatures.billingEnabled = true
8872
useSettingsDirtyStore.getState().reset()
8973
container = document.createElement('div')
9074
document.body.appendChild(container)
@@ -126,46 +110,14 @@ async function selectSettings() {
126110
}
127111

128112
describe('OrganizationFooter settings navigation', () => {
129-
it('preserves unsaved settings when opening a shortcut', async () => {
130-
useSettingsDirtyStore.getState().setDirty(true)
113+
it('keeps only Settings and Sign out in the organization profile menu', async () => {
131114
await openProfileMenu()
132-
const members = document.querySelector<HTMLAnchorElement>('a[href="/o/org-1/settings/members"]')
133-
if (!members) throw new Error('Members shortcut is missing')
134-
await act(async () => members.click())
135-
expect(mockPush).not.toHaveBeenCalled()
136-
act(() => useSettingsDirtyStore.getState().confirmLeave())
137-
expect(mockPush).toHaveBeenCalledWith('/o/org-1/settings/members')
115+
expect(
116+
[...document.querySelectorAll('[role="menuitem"]')].map((item) => item.textContent)
117+
).toEqual(['Settings', 'Sign out'])
118+
expect(document.querySelector('[role="separator"]')).toBeNull()
138119
})
139120

140-
it.each([
141-
{ isAdmin: true, billingEnabled: true, showBilling: true },
142-
{ isAdmin: false, billingEnabled: true, showBilling: false },
143-
{ isAdmin: true, billingEnabled: false, showBilling: false },
144-
])(
145-
'matches settings visibility for $isAdmin admin, $billingEnabled billing',
146-
async ({ isAdmin, billingEnabled, showBilling }) => {
147-
context.viewer.isAdmin = isAdmin
148-
context.settingsFeatures.billingEnabled = billingEnabled
149-
await openProfileMenu()
150-
expect(
151-
[...document.querySelectorAll('[role="menuitem"]')].map((item) => item.textContent)
152-
).toEqual([
153-
'Settings',
154-
...(showBilling ? ['Subscription'] : []),
155-
'Members',
156-
'Recently deleted',
157-
'Sign out',
158-
])
159-
expect(document.querySelector('[role="separator"]')).toBeNull()
160-
const members = document.querySelector<HTMLAnchorElement>(
161-
'a[href="/o/org-1/settings/members"]'
162-
)
163-
if (!members) throw new Error('Members shortcut is missing')
164-
await act(async () => members.click())
165-
expect(mockPush).toHaveBeenCalledWith('/o/org-1/settings/members')
166-
}
167-
)
168-
169121
it('navigates immediately when settings are clean', async () => {
170122
await selectSettings()
171123
expect(mockPush).toHaveBeenCalledWith('/o/org-1/settings/general')

apps/sim/app/o/[organizationId]/components/organization-sidebar/components/organization-footer/organization-footer.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { ComponentProps } from 'react'
44
import { useRouter } from 'next/navigation'
55
import { organizationRoutes } from '@/lib/navigation/paths'
66
import { useOrganizationContext } from '@/app/o/[organizationId]/providers/organization-provider'
7-
import { organizationSettingsNavigation } from '@/app/o/[organizationId]/settings/navigation'
87
import { SidebarFooter } from '@/app/workspace/[workspaceId]/w/components/sidebar/components/sidebar-footer/sidebar-footer'
98

109
interface OrganizationFooterProps
@@ -14,26 +13,16 @@ interface OrganizationFooterProps
1413
> {}
1514

1615
export function OrganizationFooter(props: OrganizationFooterProps) {
17-
const { organization, viewer, settingsFeatures, connectedAccountsAvailable, searchAccess } =
18-
useOrganizationContext()
16+
const { organization } = useOrganizationContext()
1917
const router = useRouter()
2018
const accountSettingsHref = organizationRoutes(organization.id).settingsSection('general')
21-
const navigationLinks = organizationSettingsNavigation(viewer.isAdmin, settingsFeatures, {
22-
connectedAccounts: connectedAccountsAvailable,
23-
search: searchAccess.memberScoped,
24-
})
25-
.filter(({ id }) => id === 'billing' || id === 'members' || id === 'recently-deleted')
26-
.map(({ id, label, icon }) => {
27-
const href = organizationRoutes(organization.id).settingsSection(id)
28-
return { label, icon, href, onNavigate: () => router.push(href) }
29-
})
3019

3120
return (
3221
<SidebarFooter
3322
{...props}
3423
accountSettingsHref={accountSettingsHref}
3524
onOpenAccountSettings={() => router.push(accountSettingsHref)}
36-
navigationLinks={navigationLinks}
25+
navigationLinks={[]}
3726
/>
3827
)
3928
}

apps/sim/app/o/[organizationId]/components/organization-sidebar/components/organization-header/organization-header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export function OrganizationHeader({
135135
aria-label='Change organization logo'
136136
aria-busy={isUploadingLogo}
137137
textValue='Change organization logo'
138-
className='h-auto shrink-0 p-1'
138+
className='h-auto shrink-0 p-0 hover-hover:opacity-70 focus-visible:opacity-70'
139139
disabled={isUploadingLogo}
140140
onSelect={(event) => {
141141
event.preventDefault()

0 commit comments

Comments
 (0)