Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitda8bd12

Browse files
committed
reduce button explosion
1 parent1c703ca commitda8bd12

File tree

3 files changed

+44
-59
lines changed

3 files changed

+44
-59
lines changed

‎site/src/modules/workspaces/actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import type { Workspace } from "api/typesGenerated";
66
constactionTypes=[
77
"start",
88
"starting",
9-
//Replaces start when an update is available.
9+
//Appears beside start when an update is available.
1010
"updateAndStart",
1111
// Replaces start when an update is required.
1212
"updateAndStartRequireActiveVersion",
1313
"stop",
1414
"stopping",
1515
"restart",
1616
"restarting",
17-
//Replaces restart when an update is available.
17+
//Appears beside restart when an update is available.
1818
"updateAndRestart",
1919
// Replaces restart when an update is required.
2020
"updateAndRestartRequireActiveVersion",

‎site/src/pages/WorkspacePage/WorkspaceActions/Buttons.tsx

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,33 @@ export interface ActionButtonProps {
1818
handleAction:(buildParameters?:WorkspaceBuildParameter[])=>void;
1919
disabled?:boolean;
2020
tooltipText?:string;
21+
isRunning?:boolean;
22+
requireActiveVersion?:boolean;
2123
}
2224

23-
exportconstUpdateAndStartButton:FC<ActionButtonProps>=({
25+
exportconstUpdateButton:FC<ActionButtonProps>=({
2426
handleAction,
2527
loading,
28+
isRunning,
29+
requireActiveVersion,
2630
})=>{
2731
return(
28-
<Tooltiptitle="Start workspace with the latest template version.">
32+
<Tooltip
33+
title={
34+
requireActiveVersion
35+
?"This template requires automatic updates on workspace startup. Contact your administrator if you want to preserve the template version."
36+
:isRunning
37+
?"Stop workspace and restart it with the latest template version."
38+
:"Start workspace with the latest template version."
39+
}
40+
>
2941
<TopbarButton
30-
disabled={loading}
3142
data-testid="workspace-update-button"
32-
onClick={()=>handleAction()}
33-
>
34-
<CirclePlayIcon/>
35-
{loading ?<>Updating&hellip;</> :<>Update&hellip;</>}
36-
</TopbarButton>
37-
</Tooltip>
38-
);
39-
};
40-
41-
exportconstUpdateAndRestartButton:FC<ActionButtonProps>=({
42-
handleAction,
43-
loading,
44-
})=>{
45-
return(
46-
<Tooltiptitle="Stop workspace, if running, and restart it with the latest template version.">
47-
<TopbarButton
4843
disabled={loading}
49-
data-testid="workspace-update-and-restart-button"
5044
onClick={()=>handleAction()}
5145
>
52-
<RotateCcwIcon/>
53-
{loading ?<>Updating&hellip;</> :<>Update and restart&hellip;</>}
46+
{isRunning ?<RotateCcwIcon/> :<CirclePlayIcon/>}
47+
{loading ?<>Updating&hellip;</> :<>Update&hellip;</>}
5448
</TopbarButton>
5549
</Tooltip>
5650
);
@@ -103,19 +97,6 @@ export const StartButton: FC<ActionButtonPropsWithWorkspace> = ({
10397
);
10498
};
10599

106-
exportconstUpdateAndStartButtonRequireActiveVersion:FC<
107-
ActionButtonProps
108-
>=({ handleAction})=>{
109-
return(
110-
<Tooltiptitle="This template requires automatic updates on workspace startup. Contact your administrator if you want to preserve the template version.">
111-
<TopbarButtononClick={()=>handleAction()}>
112-
<CirclePlayIcon/>
113-
Update and start&hellip;
114-
</TopbarButton>
115-
</Tooltip>
116-
);
117-
};
118-
119100
exportconstStopButton:FC<ActionButtonProps>=({
120101
handleAction,
121102
loading,
@@ -157,19 +138,6 @@ export const RestartButton: FC<ActionButtonPropsWithWorkspace> = ({
157138
);
158139
};
159140

160-
exportconstUpdateAndRestartButtonRequireActiveVersion:FC<
161-
ActionButtonProps
162-
>=({ handleAction})=>{
163-
return(
164-
<Tooltiptitle="This template requires automatic updates on workspace startup. Contact your administrator if you want to preserve the template version.">
165-
<TopbarButtononClick={()=>handleAction()}>
166-
<RotateCcwIcon/>
167-
Update and restart&hellip;
168-
</TopbarButton>
169-
</Tooltip>
170-
);
171-
};
172-
173141
exportconstCancelButton:FC<ActionButtonProps>=({ handleAction})=>{
174142
return(
175143
<TopbarButtononClick={()=>handleAction()}>

‎site/src/pages/WorkspacePage/WorkspaceActions/WorkspaceActions.tsx

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ import {
1818
RestartButton,
1919
StartButton,
2020
StopButton,
21-
UpdateAndRestartButton,
22-
UpdateAndRestartButtonRequireActiveVersion,
23-
UpdateAndStartButton,
24-
UpdateAndStartButtonRequireActiveVersion,
21+
UpdateButton,
2522
}from"./Buttons";
2623
import{DebugButton}from"./DebugButton";
2724
import{RetryButton}from"./RetryButton";
@@ -82,15 +79,35 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
8279

8380
// A mapping of button type to the corresponding React component
8481
constbuttonMapping:Record<ActionType,ReactNode>={
85-
updateAndStart:<UpdateAndStartButtonhandleAction={handleUpdate}/>,
82+
updateAndStart:(
83+
<UpdateButton
84+
handleAction={handleUpdate}
85+
isRunning={false}
86+
requireActiveVersion={false}
87+
/>
88+
),
8689
updateAndStartRequireActiveVersion:(
87-
<UpdateAndStartButtonRequireActiveVersionhandleAction={handleUpdate}/>
90+
<UpdateButton
91+
handleAction={handleUpdate}
92+
isRunning={false}
93+
requireActiveVersion={true}
94+
/>
95+
),
96+
updateAndRestart:(
97+
<UpdateButton
98+
handleAction={handleUpdate}
99+
isRunning={true}
100+
requireActiveVersion={false}
101+
/>
88102
),
89-
updateAndRestart:<UpdateAndRestartButtonhandleAction={handleUpdate}/>,
90103
updateAndRestartRequireActiveVersion:(
91-
<UpdateAndRestartButtonRequireActiveVersionhandleAction={handleUpdate}/>
104+
<UpdateButton
105+
handleAction={handleUpdate}
106+
isRunning={true}
107+
requireActiveVersion={true}
108+
/>
92109
),
93-
updating:<UpdateAndStartButtonloadinghandleAction={handleUpdate}/>,
110+
updating:<UpdateButtonloadinghandleAction={handleUpdate}/>,
94111
start:(
95112
<StartButton
96113
workspace={workspace}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp