Skip to content

Commit 73cbad7

Browse files
committed
refactor workspace schedule page code
1 parent dd6ed1a commit 73cbad7

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

site/src/pages/WorkspaceSchedulePage/WorkspaceSchedulePage.tsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,23 +168,31 @@ export const WorkspaceSchedulePage: React.FC = () => {
168168
if (!username || !workspaceName) {
169169
navigate("/workspaces")
170170
return null
171-
} else if (
171+
}
172+
173+
if (
172174
scheduleState.matches("idle") ||
173175
scheduleState.matches("gettingWorkspace") ||
174176
scheduleState.matches("gettingPermissions") ||
175177
!workspace
176178
) {
177179
return <FullScreenLoader />
178-
} else if (scheduleState.matches("error")) {
180+
}
181+
182+
if (scheduleState.matches("error")) {
179183
return (
180184
<ErrorSummary
181185
error={getWorkspaceError || checkPermissionsError}
182186
retry={() => scheduleSend({ type: "GET_WORKSPACE", username, workspaceName })}
183187
/>
184188
)
185-
} else if (!permissions?.updateWorkspace) {
189+
}
190+
191+
if (!permissions?.updateWorkspace) {
186192
return <ErrorSummary error={Error(Language.forbiddenError)} />
187-
} else if (scheduleState.matches("presentForm") || scheduleState.matches("submittingSchedule")) {
193+
}
194+
195+
if (scheduleState.matches("presentForm") || scheduleState.matches("submittingSchedule")) {
188196
return (
189197
<WorkspaceScheduleForm
190198
fieldErrors={formErrors}
@@ -202,13 +210,15 @@ export const WorkspaceSchedulePage: React.FC = () => {
202210
}}
203211
/>
204212
)
205-
} else if (scheduleState.matches("submitSuccess")) {
213+
}
214+
215+
if (scheduleState.matches("submitSuccess")) {
206216
navigate(`/@${username}/${workspaceName}`)
207217
return <FullScreenLoader />
208-
} else {
209-
// Theoretically impossible - log and bail
210-
console.error("WorkspaceSchedulePage: unknown state :: ", scheduleState)
211-
navigate("/")
212-
return null
213218
}
219+
220+
// Theoretically impossible - log and bail
221+
console.error("WorkspaceSchedulePage: unknown state :: ", scheduleState)
222+
navigate("/")
223+
return null
214224
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy