Skip to content

fix(site): only show workspace actions if user has permission #9303

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

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 26 additions & 20 deletions site/src/components/Resources/AgentRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ export interface AgentRowProps {
agent: WorkspaceAgent
workspace: Workspace
showApps: boolean
hideSSHButton?: boolean
showBuiltinApps?: boolean
sshPrefix?: string
hideSSHButton?: boolean
hideVSCodeDesktopButton?: boolean
serverVersion: string
onUpdateAgent: () => void
Expand All @@ -62,6 +63,7 @@ export const AgentRow: FC<AgentRowProps> = ({
agent,
workspace,
showApps,
showBuiltinApps = true,
hideSSHButton,
hideVSCodeDesktopButton,
serverVersion,
Expand Down Expand Up @@ -236,27 +238,31 @@ export const AgentRow: FC<AgentRowProps> = ({
</>
)}

<TerminalLink
workspaceName={workspace.name}
agentName={agent.name}
userName={workspace.owner_name}
/>
{!hideSSHButton && (
<SSHButton
workspaceName={workspace.name}
agentName={agent.name}
sshPrefix={sshPrefix}
/>
)}
{proxy.preferredWildcardHostname &&
proxy.preferredWildcardHostname !== "" && (
<PortForwardButton
host={proxy.preferredWildcardHostname}
{showBuiltinApps && (
<>
<TerminalLink
workspaceName={workspace.name}
agent={agent}
username={workspace.owner_name}
agentName={agent.name}
userName={workspace.owner_name}
/>
)}
{!hideSSHButton && (
<SSHButton
workspaceName={workspace.name}
agentName={agent.name}
sshPrefix={sshPrefix}
/>
)}
{proxy.preferredWildcardHostname &&
proxy.preferredWildcardHostname !== "" && (
<PortForwardButton
host={proxy.preferredWildcardHostname}
workspaceName={workspace.name}
agent={agent}
username={workspace.owner_name}
/>
)}
</>
)}
</div>
)}

Expand Down
57 changes: 31 additions & 26 deletions site/src/components/Workspace/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,23 +194,25 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
onDeadlinePlus={scheduleProps.onDeadlinePlus}
/>

<PageHeaderActions>
<WorkspaceActions
workspace={workspace}
handleStart={handleStart}
handleStop={handleStop}
handleRestart={handleRestart}
handleDelete={handleDelete}
handleUpdate={handleUpdate}
handleCancel={handleCancel}
handleSettings={handleSettings}
handleChangeVersion={handleChangeVersion}
handleDormantActivate={handleDormantActivate}
canChangeVersions={canChangeVersions}
isUpdating={isUpdating}
isRestarting={isRestarting}
/>
</PageHeaderActions>
{canUpdateWorkspace && (
<PageHeaderActions>
<WorkspaceActions
workspace={workspace}
handleStart={handleStart}
handleStop={handleStop}
handleRestart={handleRestart}
handleDelete={handleDelete}
handleUpdate={handleUpdate}
handleCancel={handleCancel}
handleSettings={handleSettings}
handleChangeVersion={handleChangeVersion}
handleDormantActivate={handleDormantActivate}
canChangeVersions={canChangeVersions}
isUpdating={isUpdating}
isRestarting={isRestarting}
/>
</PageHeaderActions>
)}
</FullWidthPageHeader>

<Margins className={styles.content}>
Expand All @@ -226,15 +228,17 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
<Alert
severity="warning"
actions={
<Button
variant="text"
size="small"
onClick={() => {
handleRestart()
}}
>
Restart
</Button>
canUpdateWorkspace && (
<Button
variant="text"
size="small"
onClick={() => {
handleRestart()
}}
>
Restart
</Button>
)
}
>
<AlertTitle>Workspace is unhealthy</AlertTitle>
Expand Down Expand Up @@ -326,6 +330,7 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
workspace={workspace}
sshPrefix={sshPrefix}
showApps={canUpdateWorkspace}
showBuiltinApps={canUpdateWorkspace}
hideSSHButton={hideSSHButton}
hideVSCodeDesktopButton={hideVSCodeDesktopButton}
serverVersion={serverVersion}
Expand Down
1 change: 0 additions & 1 deletion site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export const WorkspaceReadyPage = ({
useEffect(() => {
bannerSend({ type: "REFRESH_WORKSPACE", workspace })
}, [bannerSend, workspace])

return (
<>
<Helmet>
Expand Down