Skip to content

Commit

Permalink
feat: Pre-select ws when launching notebook (#9109)
Browse files Browse the repository at this point in the history
  • Loading branch information
gt2345 authored Apr 4, 2024
1 parent f03a8a8 commit 91d7e08
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions webui/react/src/components/JupyterLabModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ const JupyterLabFullConfig: React.FC<FullConfigProps> = ({
const usableConfig = useMemo(() => (Loadable.isLoaded(config) ? config.data : ''), [config]);
const [field, setField] = useState([
{ name: 'config', value: usableConfig },
{ name: 'workspaceId', value: currentWorkspace?.id },
{ name: 'workspaceId', value: currentWorkspace ? currentWorkspace.id : workspaces.at(0)?.id },
]);

const handleConfigChange = useCallback(
Expand All @@ -274,8 +274,11 @@ const JupyterLabFullConfig: React.FC<FullConfigProps> = ({
}, [usableConfig]);

useEffect(() => {
form.setFieldValue('workspaceId', currentWorkspace?.id);
}, [currentWorkspace, form]);
form.setFieldValue(
'workspaceId',
currentWorkspace ? currentWorkspace.id : workspaces.at(0)?.id,
);
}, [currentWorkspace, form, workspaces]);
useEffect(() => {
form.setFieldValue('config', usableConfig);
}, [usableConfig, form]);
Expand Down Expand Up @@ -417,8 +420,11 @@ const JupyterLabForm: React.FC<{
}, [boundResourcePools, form]);

useEffect(() => {
form.setFieldValue('workspaceId', currentWorkspace?.id);
}, [currentWorkspace, form]);
form.setFieldValue(
'workspaceId',
currentWorkspace ? currentWorkspace.id : workspaces.at(0)?.id,
);
}, [currentWorkspace, form, workspaces]);

const onSelectWorkspace = (workspaceId?: SelectValue) => {
const selected = workspaces.find((w) => workspaceId && w.id === workspaceId);
Expand Down

0 comments on commit 91d7e08

Please sign in to comment.