Skip to content

Commit 67c8635

Browse files
fix(site): only show workspace actions if user has permission (coder#9303)
1 parent 14aa1af commit 67c8635

File tree

3 files changed

+57
-47
lines changed

3 files changed

+57
-47
lines changed

site/src/components/Resources/AgentRow.tsx

+26-20
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ export interface AgentRowProps {
4949
agent: WorkspaceAgent
5050
workspace: Workspace
5151
showApps: boolean
52-
hideSSHButton?: boolean
52+
showBuiltinApps?: boolean
5353
sshPrefix?: string
54+
hideSSHButton?: boolean
5455
hideVSCodeDesktopButton?: boolean
5556
serverVersion: string
5657
onUpdateAgent: () => void
@@ -62,6 +63,7 @@ export const AgentRow: FC<AgentRowProps> = ({
6263
agent,
6364
workspace,
6465
showApps,
66+
showBuiltinApps = true,
6567
hideSSHButton,
6668
hideVSCodeDesktopButton,
6769
serverVersion,
@@ -236,27 +238,31 @@ export const AgentRow: FC<AgentRowProps> = ({
236238
</>
237239
)}
238240

239-
<TerminalLink
240-
workspaceName={workspace.name}
241-
agentName={agent.name}
242-
userName={workspace.owner_name}
243-
/>
244-
{!hideSSHButton && (
245-
<SSHButton
246-
workspaceName={workspace.name}
247-
agentName={agent.name}
248-
sshPrefix={sshPrefix}
249-
/>
250-
)}
251-
{proxy.preferredWildcardHostname &&
252-
proxy.preferredWildcardHostname !== "" && (
253-
<PortForwardButton
254-
host={proxy.preferredWildcardHostname}
241+
{showBuiltinApps && (
242+
<>
243+
<TerminalLink
255244
workspaceName={workspace.name}
256-
agent={agent}
257-
username={workspace.owner_name}
245+
agentName={agent.name}
246+
userName={workspace.owner_name}
258247
/>
259-
)}
248+
{!hideSSHButton && (
249+
<SSHButton
250+
workspaceName={workspace.name}
251+
agentName={agent.name}
252+
sshPrefix={sshPrefix}
253+
/>
254+
)}
255+
{proxy.preferredWildcardHostname &&
256+
proxy.preferredWildcardHostname !== "" && (
257+
<PortForwardButton
258+
host={proxy.preferredWildcardHostname}
259+
workspaceName={workspace.name}
260+
agent={agent}
261+
username={workspace.owner_name}
262+
/>
263+
)}
264+
</>
265+
)}
260266
</div>
261267
)}
262268

site/src/components/Workspace/Workspace.tsx

+31-26
Original file line numberDiff line numberDiff line change
@@ -194,23 +194,25 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
194194
onDeadlinePlus={scheduleProps.onDeadlinePlus}
195195
/>
196196

197-
<PageHeaderActions>
198-
<WorkspaceActions
199-
workspace={workspace}
200-
handleStart={handleStart}
201-
handleStop={handleStop}
202-
handleRestart={handleRestart}
203-
handleDelete={handleDelete}
204-
handleUpdate={handleUpdate}
205-
handleCancel={handleCancel}
206-
handleSettings={handleSettings}
207-
handleChangeVersion={handleChangeVersion}
208-
handleDormantActivate={handleDormantActivate}
209-
canChangeVersions={canChangeVersions}
210-
isUpdating={isUpdating}
211-
isRestarting={isRestarting}
212-
/>
213-
</PageHeaderActions>
197+
{canUpdateWorkspace && (
198+
<PageHeaderActions>
199+
<WorkspaceActions
200+
workspace={workspace}
201+
handleStart={handleStart}
202+
handleStop={handleStop}
203+
handleRestart={handleRestart}
204+
handleDelete={handleDelete}
205+
handleUpdate={handleUpdate}
206+
handleCancel={handleCancel}
207+
handleSettings={handleSettings}
208+
handleChangeVersion={handleChangeVersion}
209+
handleDormantActivate={handleDormantActivate}
210+
canChangeVersions={canChangeVersions}
211+
isUpdating={isUpdating}
212+
isRestarting={isRestarting}
213+
/>
214+
</PageHeaderActions>
215+
)}
214216
</FullWidthPageHeader>
215217

216218
<Margins className={styles.content}>
@@ -226,15 +228,17 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
226228
<Alert
227229
severity="warning"
228230
actions={
229-
<Button
230-
variant="text"
231-
size="small"
232-
onClick={() => {
233-
handleRestart()
234-
}}
235-
>
236-
Restart
237-
</Button>
231+
canUpdateWorkspace && (
232+
<Button
233+
variant="text"
234+
size="small"
235+
onClick={() => {
236+
handleRestart()
237+
}}
238+
>
239+
Restart
240+
</Button>
241+
)
238242
}
239243
>
240244
<AlertTitle>Workspace is unhealthy</AlertTitle>
@@ -326,6 +330,7 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
326330
workspace={workspace}
327331
sshPrefix={sshPrefix}
328332
showApps={canUpdateWorkspace}
333+
showBuiltinApps={canUpdateWorkspace}
329334
hideSSHButton={hideSSHButton}
330335
hideVSCodeDesktopButton={hideVSCodeDesktopButton}
331336
serverVersion={serverVersion}

site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ export const WorkspaceReadyPage = ({
111111
useEffect(() => {
112112
bannerSend({ type: "REFRESH_WORKSPACE", workspace })
113113
}, [bannerSend, workspace])
114-
115114
return (
116115
<>
117116
<Helmet>

0 commit comments

Comments
 (0)