Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions components/dashboard/src/workspaces/CreateWorkspacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ export function CreateWorkspacePage() {
});
const defaultIde = computedDefaultEditor;
const [selectedIde, setSelectedIde, selectedIdeIsDirty] = useDirtyState<string | undefined>(defaultIde);
const { computedDefaultClass, data: allowedWorkspaceClasses } = useAllowedWorkspaceClassesMemo(selectedProjectID);
const {
computedDefaultClass,
data: allowedWorkspaceClasses,
isLoading: isLoadingWorkspaceClasses,
} = useAllowedWorkspaceClassesMemo(selectedProjectID);
const defaultWorkspaceClass = props.workspaceClass ?? computedDefaultClass;
const { data: orgSettings } = useOrgSettingsQuery();
const [selectedWsClass, setSelectedWsClass, selectedWsClassIsDirty] = useDirtyState(defaultWorkspaceClass);
Expand Down Expand Up @@ -316,7 +320,7 @@ export function CreateWorkspacePage() {

// when workspaceContext is available, we look up if options are remembered
useEffect(() => {
if (!workspaceContext.data || !user || !currentOrg) {
if (!workspaceContext.data || !user?.workspaceAutostartOptions || !currentOrg) {
return;
}
const cloneURL = workspaceContext.data.cloneUrl;
Expand All @@ -326,7 +330,10 @@ export function CreateWorkspacePage() {
if (nextLoadOption !== "autoStart") {
return;
}
const rememberedOptions = (user?.workspaceAutostartOptions || []).find(
if (isLoadingWorkspaceClasses || allowedWorkspaceClasses.length === 0) {
return;
}
const rememberedOptions = user.workspaceAutostartOptions.find(
(e) => e.cloneUrl === cloneURL && e.organizationId === currentOrg?.id,
);
if (rememberedOptions) {
Expand Down Expand Up @@ -362,7 +369,7 @@ export function CreateWorkspacePage() {
setNextLoadOption("allDone");
// we only update the remembered options when the workspaceContext changes
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [workspaceContext.data, nextLoadOption, setNextLoadOption, project]);
}, [workspaceContext.data, nextLoadOption, project, isLoadingWorkspaceClasses, allowedWorkspaceClasses]);

// Need a wrapper here so we call createWorkspace w/o any arguments
const onClickCreate = useCallback(() => createWorkspace(), [createWorkspace]);
Expand Down