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

Commit9f80f9b

Browse files
committed
fix: Update routing for workspace schedule
This was broken as part of#2101. It was a silly mistake,but unfortunate our tests didn't catch it.This is a rare change so unlikely to occur again, so I won'tmake an issue adding tests.
1 parent3878e64 commit9f80f9b

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

‎site/src/pages/WorkspaceSchedulePage/WorkspaceSchedulePage.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,33 +142,39 @@ export const workspaceToInitialValues = (
142142
}
143143

144144
exportconstWorkspaceSchedulePage:React.FC=()=>{
145+
const{username:usernameQueryParam,workspace:workspaceQueryParam}=useParams()
145146
constnavigate=useNavigate()
146-
const{workspace:workspaceQueryParam}=useParams()
147-
constworkspaceId=firstOrItem(workspaceQueryParam,null)
147+
constusername=firstOrItem(usernameQueryParam,null)
148+
constworkspaceName=firstOrItem(workspaceQueryParam,null)
148149
const[scheduleState,scheduleSend]=useMachine(workspaceSchedule)
149150
const{ formErrors, getWorkspaceError, workspace}=scheduleState.context
150151

151152
// Get workspace on mount and whenever workspaceId changes.
152153
// scheduleSend should not change.
153154
useEffect(()=>{
154-
workspaceId&&scheduleSend({type:"GET_WORKSPACE",workspaceId})
155-
},[workspaceId,scheduleSend])
155+
username&&workspaceName&&scheduleSend({type:"GET_WORKSPACE",username, workspaceName})
156+
},[username,workspaceName,scheduleSend])
156157

157-
if(!workspaceId){
158+
if(!username||!workspaceName){
158159
navigate("/workspaces")
159160
returnnull
160161
}elseif(scheduleState.matches("idle")||scheduleState.matches("gettingWorkspace")||!workspace){
161162
return<FullScreenLoader/>
162163
}elseif(scheduleState.matches("error")){
163-
return<ErrorSummaryerror={getWorkspaceError}retry={()=>scheduleSend({type:"GET_WORKSPACE", workspaceId})}/>
164+
return(
165+
<ErrorSummary
166+
error={getWorkspaceError}
167+
retry={()=>scheduleSend({type:"GET_WORKSPACE", username, workspaceName})}
168+
/>
169+
)
164170
}elseif(scheduleState.matches("presentForm")||scheduleState.matches("submittingSchedule")){
165171
return(
166172
<WorkspaceScheduleForm
167173
fieldErrors={formErrors}
168174
initialValues={workspaceToInitialValues(workspace,dayjs.tz.guess())}
169175
isLoading={scheduleState.tags.has("loading")}
170176
onCancel={()=>{
171-
navigate(`/workspaces/${workspaceId}`)
177+
navigate(`/@${username}/${workspaceName}`)
172178
}}
173179
onSubmit={(values)=>{
174180
scheduleSend({
@@ -180,7 +186,7 @@ export const WorkspaceSchedulePage: React.FC = () => {
180186
/>
181187
)
182188
}elseif(scheduleState.matches("submitSuccess")){
183-
navigate(`/workspaces/${workspaceId}`)
189+
navigate(`/@${username}/${workspaceName}`)
184190
return<FullScreenLoader/>
185191
}else{
186192
// Theoretically impossible - log and bail

‎site/src/xServices/workspaceSchedule/workspaceScheduleXService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface WorkspaceScheduleContext {
2626
}
2727

2828
exporttypeWorkspaceScheduleEvent=
29-
|{type:"GET_WORKSPACE";workspaceId:string}
29+
|{type:"GET_WORKSPACE";username:string;workspaceName:string}
3030
|{
3131
type:"SUBMIT_SCHEDULE"
3232
autoStart:TypesGen.UpdateWorkspaceAutostartRequest
@@ -132,7 +132,7 @@ export const workspaceSchedule = createMachine(
132132

133133
services:{
134134
getWorkspace:async(_,event)=>{
135-
returnawaitAPI.getWorkspace(event.workspaceId)
135+
returnawaitAPI.getWorkspaceByOwnerAndName(event.username,event.workspaceName)
136136
},
137137
submitSchedule:async(context,event)=>{
138138
if(!context.workspace?.id){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp