mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(site): only show workspace actions if user has permission (#9303)
This commit is contained in:
@@ -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
|
||||
@@ -62,6 +63,7 @@ export const AgentRow: FC<AgentRowProps> = ({
|
||||
agent,
|
||||
workspace,
|
||||
showApps,
|
||||
showBuiltinApps = true,
|
||||
hideSSHButton,
|
||||
hideVSCodeDesktopButton,
|
||||
serverVersion,
|
||||
@@ -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>
|
||||
)}
|
||||
|
||||
|
||||
@@ -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}>
|
||||
@@ -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>
|
||||
@@ -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}
|
||||
|
||||
@@ -111,7 +111,6 @@ export const WorkspaceReadyPage = ({
|
||||
useEffect(() => {
|
||||
bannerSend({ type: "REFRESH_WORKSPACE", workspace })
|
||||
}, [bannerSend, workspace])
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
|
||||
Reference in New Issue
Block a user