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

Commit9ec16d4

Browse files
feat(UI): add workspace restart button (#7137)
* Refactor primary buttons* refactor(site): Always show the main actions* Remove tests that are testes on Storybook* Fix tests* Fix keys* added restart btn---------Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
1 parent7bbbb91 commit9ec16d4

File tree

7 files changed

+38
-8
lines changed

7 files changed

+38
-8
lines changed

‎site/src/components/Workspace/Workspace.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export interface WorkspaceProps {
4141
}
4242
handleStart:()=>void
4343
handleStop:()=>void
44+
handleRestart:()=>void
4445
handleDelete:()=>void
4546
handleUpdate:()=>void
4647
handleCancel:()=>void
@@ -72,6 +73,7 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
7273
scheduleProps,
7374
handleStart,
7475
handleStop,
76+
handleRestart,
7577
handleDelete,
7678
handleUpdate,
7779
handleCancel,
@@ -132,6 +134,7 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
132134
isOutdated={workspace.outdated}
133135
handleStart={handleStart}
134136
handleStop={handleStop}
137+
handleRestart={handleRestart}
135138
handleDelete={handleDelete}
136139
handleUpdate={handleUpdate}
137140
handleCancel={handleCancel}

‎site/src/components/WorkspaceActions/Buttons.tsx‎

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ import BlockIcon from "@material-ui/icons/Block"
33
importCloudQueueIconfrom"@material-ui/icons/CloudQueue"
44
importCropSquareIconfrom"@material-ui/icons/CropSquare"
55
importPlayCircleOutlineIconfrom"@material-ui/icons/PlayCircleOutline"
6+
importReplayIconfrom"@material-ui/icons/Replay"
67
import{LoadingButton}from"components/LoadingButton/LoadingButton"
7-
import{FC}from"react"
8+
import{FC,PropsWithChildren}from"react"
89
import{useTranslation}from"react-i18next"
910
import{makeStyles}from"@material-ui/core/styles"
1011

1112
interfaceWorkspaceAction{
1213
handleAction:()=>void
1314
}
1415

15-
exportconstUpdateButton:FC<React.PropsWithChildren<WorkspaceAction>>=({
16+
exportconstUpdateButton:FC<PropsWithChildren<WorkspaceAction>>=({
1617
handleAction,
1718
})=>{
1819
const{ t}=useTranslation("workspacePage")
@@ -30,7 +31,7 @@ export const UpdateButton: FC<React.PropsWithChildren<WorkspaceAction>> = ({
3031
)
3132
}
3233

33-
exportconstStartButton:FC<React.PropsWithChildren<WorkspaceAction>>=({
34+
exportconstStartButton:FC<PropsWithChildren<WorkspaceAction>>=({
3435
handleAction,
3536
})=>{
3637
const{ t}=useTranslation("workspacePage")
@@ -48,7 +49,7 @@ export const StartButton: FC<React.PropsWithChildren<WorkspaceAction>> = ({
4849
)
4950
}
5051

51-
exportconstStopButton:FC<React.PropsWithChildren<WorkspaceAction>>=({
52+
exportconstStopButton:FC<PropsWithChildren<WorkspaceAction>>=({
5253
handleAction,
5354
})=>{
5455
const{ t}=useTranslation("workspacePage")
@@ -66,7 +67,25 @@ export const StopButton: FC<React.PropsWithChildren<WorkspaceAction>> = ({
6667
)
6768
}
6869

69-
exportconstCancelButton:FC<React.PropsWithChildren<WorkspaceAction>>=({
70+
exportconstRestartButton:FC<PropsWithChildren<WorkspaceAction>>=({
71+
handleAction,
72+
})=>{
73+
const{ t}=useTranslation("workspacePage")
74+
conststyles=useStyles()
75+
76+
return(
77+
<Button
78+
variant="outlined"
79+
startIcon={<ReplayIcon/>}
80+
onClick={handleAction}
81+
className={styles.fixedWidth}
82+
>
83+
{t("actionButton.restart")}
84+
</Button>
85+
)
86+
}
87+
88+
exportconstCancelButton:FC<PropsWithChildren<WorkspaceAction>>=({
7089
handleAction,
7190
})=>{
7291
return(
@@ -80,7 +99,7 @@ interface DisabledProps {
8099
label:string
81100
}
82101

83-
exportconstDisabledButton:FC<React.PropsWithChildren<DisabledProps>>=({
102+
exportconstDisabledButton:FC<PropsWithChildren<DisabledProps>>=({
84103
label,
85104
})=>{
86105
return(
@@ -94,7 +113,7 @@ interface LoadingProps {
94113
label:string
95114
}
96115

97-
exportconstActionLoadingButton:FC<React.PropsWithChildren<LoadingProps>>=({
116+
exportconstActionLoadingButton:FC<PropsWithChildren<LoadingProps>>=({
98117
label,
99118
})=>{
100119
conststyles=useStyles()

‎site/src/components/WorkspaceActions/WorkspaceActions.stories.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const Template: Story<WorkspaceActionsProps> = (args) => (
1515
constdefaultArgs={
1616
handleStart:action("start"),
1717
handleStop:action("stop"),
18+
handleRestart:action("restart"),
1819
handleDelete:action("delete"),
1920
handleUpdate:action("update"),
2021
handleCancel:action("cancel"),

‎site/src/components/WorkspaceActions/WorkspaceActions.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
DisabledButton,
1313
StartButton,
1414
StopButton,
15+
RestartButton,
1516
UpdateButton,
1617
}from"./Buttons"
1718
import{
@@ -28,6 +29,7 @@ export interface WorkspaceActionsProps {
2829
isOutdated:boolean
2930
handleStart:()=>void
3031
handleStop:()=>void
32+
handleRestart:()=>void
3133
handleDelete:()=>void
3234
handleUpdate:()=>void
3335
handleCancel:()=>void
@@ -43,6 +45,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
4345
isOutdated,
4446
handleStart,
4547
handleStop,
48+
handleRestart,
4649
handleDelete,
4750
handleUpdate,
4851
handleCancel,
@@ -91,6 +94,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
9194
key={ButtonTypesEnum.stopping}
9295
/>
9396
),
97+
[ButtonTypesEnum.restart]:<RestartButtonhandleAction={handleRestart}/>,
9498
[ButtonTypesEnum.deleting]:(
9599
<ActionLoadingButton
96100
label={t("actionButton.deleting")}

‎site/src/components/WorkspaceActions/constants.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export enum ButtonTypesEnum {
77
starting="starting",
88
stop="stop",
99
stopping="stopping",
10+
restart="restart",
1011
deleting="deleting",
1112
update="update",
1213
updating="updating",
@@ -39,7 +40,7 @@ const statusToActions: Record<WorkspaceStatus, WorkspaceAbilities> = {
3940
canAcceptJobs:false,
4041
},
4142
running:{
42-
actions:[ButtonTypesEnum.stop],
43+
actions:[ButtonTypesEnum.stop,ButtonTypesEnum.restart],
4344
canCancel:false,
4445
canAcceptJobs:true,
4546
},

‎site/src/i18n/en/workspacePage.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"actionButton": {
2222
"start":"Start",
2323
"stop":"Stop",
24+
"restart":"Restart",
2425
"delete":"Delete",
2526
"cancel":"Cancel",
2627
"update":"Update",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export const WorkspaceReadyPage = ({
124124
workspace={workspace}
125125
handleStart={()=>workspaceSend({type:"START"})}
126126
handleStop={()=>workspaceSend({type:"STOP"})}
127+
handleRestart={()=>workspaceSend({type:"START"})}
127128
handleDelete={()=>workspaceSend({type:"ASK_DELETE"})}
128129
handleUpdate={()=>workspaceSend({type:"UPDATE"})}
129130
handleCancel={()=>workspaceSend({type:"CANCEL"})}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp