Skip to content

Commit be194d3

Browse files
committed
fix(platform): hide controls a viewer cannot use instead of disabling them unexplained
New documents shows only to an editor, as New connector beside it does; Create fork only to someone who can fork; and the sidebar's Add workspace only when the organization lets this viewer create one, since an icon button cannot explain why it is off.
1 parent b8391be commit be194d3

4 files changed

Lines changed: 26 additions & 26 deletions

File tree

‎apps/sim/app/(product)/_components/sidebar/workspaces-section.tsx‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ export function WorkspacesSection({
8282
]
8383
}
8484

85-
const addLabel = canCreate ? 'Add workspace' : (policy?.reason ?? CREATE_UNAVAILABLE)
86-
8785
return (
8886
<>
8987
<Disclosure
@@ -98,13 +96,12 @@ export function WorkspacesSection({
9896
order={workspaceOrder}
9997
onChange={setWorkspaceOrder}
10098
/>
101-
{create && (
99+
{create && canCreate && (
102100
<IconButton
103101
tooltip
104102
size='compact'
105-
label={addLabel}
103+
label='Add workspace'
106104
icon='I074'
107-
disabled={!canCreate}
108105
onClick={() => actions.requestLeave(() => setCreating(true))}
109106
/>
110107
)}

‎apps/sim/app/(product)/_components/workspace/knowledge/knowledge-base/knowledge-base.tsx‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -619,15 +619,17 @@ export function KnowledgeBase({ workspaceId, knowledgeBaseId }: KnowledgeBasePro
619619
New connector
620620
</Button>
621621
)}
622-
<Button
623-
variant='secondary'
624-
size='compact'
625-
icon='I117'
626-
disabled={!canEdit}
627-
onClick={() => setUploading(true)}
628-
>
629-
New documents
630-
</Button>
622+
{(canEdit || access.isLoading) && (
623+
<Button
624+
variant='secondary'
625+
size='compact'
626+
icon='I117'
627+
disabled={!canEdit}
628+
onClick={() => setUploading(true)}
629+
>
630+
New documents
631+
</Button>
632+
)}
631633
</ControlBar>
632634
)
633635

‎apps/sim/app/(product)/workspace/[workspaceId]/settings/_components/sections/forks/forks-section.tsx‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,18 @@ export default function ForksSection({ workspaceId }: WorkspaceSettingsSectionPr
239239
description={query ? undefined : 'Create a fork to get started.'}
240240
/>
241241
)}
242-
<SettingsRow label='New fork'>
243-
<Button
244-
variant='primary'
245-
size='compact'
246-
icon='I074'
247-
disabled={!canMutate}
248-
onClick={() => setForking(true)}
249-
>
250-
Create fork
251-
</Button>
252-
</SettingsRow>
242+
{canMutate && (
243+
<SettingsRow label='New fork'>
244+
<Button
245+
variant='primary'
246+
size='compact'
247+
icon='I074'
248+
onClick={() => setForking(true)}
249+
>
250+
Create fork
251+
</Button>
252+
</SettingsRow>
253+
)}
253254
</SettingsSection>
254255
<SettingsSection title='Synced workflows'>
255256
{/* Only this workspace's own value: a previous workspace's placeholder would write another lineage's policy. */}

‎apps/sim/platform/checks/live/shell.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ test('creating a workspace opens it in the zone, on its Workflows tab', async ({
117117
.getByRole('button', { name: 'Add workspace' })
118118
.click()
119119
await page.getByRole('textbox', { name: 'Workspace name' }).fill(name)
120-
await page.getByRole('button', { name: 'Create', exact: true }).click()
120+
await page.getByRole('button', { name: 'Create workspace', exact: true }).click()
121121
await expect(page).toHaveURL(/\/workspace\/[^/]+\/workflows/)
122122
} finally {
123123
// Every later check reads the seeded organization's workspaces, and a rerun would list two.

0 commit comments

Comments
 (0)