Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix create job form #32

Merged
merged 35 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
651c3ab
Update theme provider.
Sep 20, 2022
a8f2377
Test basic MUI components.
Sep 20, 2022
71c270d
Working theme adaptation.
Sep 20, 2022
b6b2fbb
More explorations with MUI.
Sep 20, 2022
179f584
Refactoring models.
Sep 20, 2022
6fbc0ab
fix MUI build
dlqqq Sep 20, 2022
9a06362
set builder to ^3.4.7
dlqqq Sep 21, 2022
707b38a
Fix jobName to update on change
JasonWeill Sep 21, 2022
9144579
Adds working job name, input file, output prefix
JasonWeill Sep 21, 2022
44acffd
Reinstate environment picker
JasonWeill Sep 21, 2022
986fa6a
MUI environment picker
JasonWeill Sep 21, 2022
d33dbe2
Reinstates output format picker
JasonWeill Sep 21, 2022
0ed335b
Styles dropdown
JasonWeill Sep 22, 2022
109ffee
Removes placeholder value
JasonWeill Sep 22, 2022
64e1583
Adds label
JasonWeill Sep 22, 2022
df6a373
Working checkboxes
JasonWeill Sep 22, 2022
18e66be
Cluster for checkboxes
JasonWeill Sep 22, 2022
aec2eb8
Adds parameters picker
JasonWeill Sep 22, 2022
8fd68cf
Removes create-job-form-inputs
JasonWeill Sep 22, 2022
3817091
Reorders imports
JasonWeill Sep 22, 2022
b170b4b
Removes stray junk from rebase
JasonWeill Sep 22, 2022
cded1c4
More rebase junk
JasonWeill Sep 22, 2022
06e1006
Removes log line
JasonWeill Sep 22, 2022
f17ba66
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2022
74e8d42
MUI-ifies parameters picker
JasonWeill Sep 22, 2022
e806e30
flex-start for output format boxes
JasonWeill Sep 22, 2022
d450c4e
Makes reload button work without signal
JasonWeill Sep 22, 2022
3377d33
Add label for output formats
JasonWeill Sep 22, 2022
85dc4e2
Adds header for parameters
JasonWeill Sep 22, 2022
b5edbc4
Max width for form, removes 50% widths of inputs
JasonWeill Sep 22, 2022
e0b70cf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2022
2b759f1
Removes unused css class
JasonWeill Sep 22, 2022
7eb1d43
Avoids "small" buttons, makes "Cancel" button less prominent
JasonWeill Sep 22, 2022
a302cc2
Removes "small" from text inputs, locally caches state
JasonWeill Sep 22, 2022
3645f35
Updates parameter checks
JasonWeill Sep 22, 2022
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
132 changes: 0 additions & 132 deletions src/components/create-job-form-inputs.tsx

This file was deleted.

41 changes: 22 additions & 19 deletions src/components/environment-picker.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React, { ChangeEvent, useState } from 'react';
import { InputLabel, MenuItem, Select, SelectChangeEvent } from '@mui/material';
import React, { useState } from 'react';

import { Scheduler } from '../handler';
import { useTranslator } from '../hooks';

export type EnvironmentPickerProps = {
label: string;
name: string;
id: string;
onChange: (event: ChangeEvent) => void;
onChange: (event: SelectChangeEvent<string>) => void;
environmentsPromise: Promise<Scheduler.IRuntimeEnvironment[]>;
initialValue: string;
};
Expand All @@ -25,23 +27,24 @@ export function EnvironmentPicker(props: EnvironmentPickerProps): JSX.Element {
return <em>{trans.__('Loading …')}</em>;
}

const labelId = `${props.id}-label`;

return (
<select
name={props.name}
id={props.id}
onChange={props.onChange}
value={props.initialValue}
>
<option
value=""
title={trans.__('No environment selected')}
disabled
></option>
{environmentList.map((env, idx) => (
<option value={env.label} title={env.description} key={idx}>
{env.name}
</option>
))}
</select>
<>
<InputLabel id={labelId}>{props.label}</InputLabel>
<Select
labelId={labelId}
name={props.name}
id={props.id}
onChange={props.onChange}
value={props.initialValue}
>
{environmentList.map((env, idx) => (
<MenuItem value={env.label} title={env.description} key={idx}>
{env.name}
</MenuItem>
))}
</Select>
</>
);
}
10 changes: 5 additions & 5 deletions src/components/job-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function DeleteButton(props: {

function RefillButton(props: {
job: Scheduler.IDescribeJob;
showCreateJob: () => void;
showCreateJob: (newModel: ICreateJobModel) => void;
}): JSX.Element | null {
const trans = useTranslator('jupyterlab');
const buttonTitle = props.job.name
Expand All @@ -81,7 +81,7 @@ function RefillButton(props: {
: undefined;

const clickHandler = (): void => {
const initialState: ICreateJobModel = {
const newModel: ICreateJobModel = {
inputFile: props.job.input_uri,
jobName: props.job.name ?? '',
outputPath: props.job.output_prefix,
Expand All @@ -95,13 +95,13 @@ function RefillButton(props: {
props.job.runtime_environment_name
);
if (jobOutputFormats && outputFormats) {
initialState.outputFormats = outputFormats.filter(of =>
newModel.outputFormats = outputFormats.filter(of =>
jobOutputFormats.some(jof => of.name === jof)
);
}

// Switch the view to the form.
props.showCreateJob();
props.showCreateJob(newModel);
};

return (
Expand Down Expand Up @@ -163,7 +163,7 @@ export type JobRowProps = {
rowClass: string;
cellClass: string;
app: JupyterFrontEnd;
showCreateJob: () => void;
showCreateJob: (newModel: ICreateJobModel) => void;
};

// Add a row for a job, with columns for each of its traits and a details view below.
Expand Down
40 changes: 24 additions & 16 deletions src/components/output-format-picker.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import React, { ChangeEvent, useMemo } from 'react';

import { Checkbox, FormControlLabel, InputLabel } from '@mui/material';

import { Stack } from './stack';

import { Cluster } from './cluster';
import { Scheduler } from '../handler';
import { IOutputFormat } from '../model';

export type OutputFormatPickerProps = {
label: string;
name: string;
id: string;
environment: string;
Expand Down Expand Up @@ -42,21 +49,22 @@ export function OutputFormatPicker(
}

return (
<ul className="jp-notebook-job-output-formats-options">
{outputFormats.map((of, idx) => (
<li key={idx}>
<label>
<input
type="checkbox"
id={`${props.id}-${of.name}`}
value={of.name}
onChange={props.onChange}
checked={props.value.some(sof => of.name === sof.name)}
/>{' '}
{of.label}
</label>
</li>
))}
</ul>
<Stack size={2}>
<InputLabel>{props.label}</InputLabel>
<Cluster gap={3} justifyContent="flex-start">
{outputFormats.map((of, idx) => (
<FormControlLabel
key={idx}
control={
<Checkbox
defaultChecked={props.value.some(sof => of.name === sof.name)}
id={`${props.id}-${of.name}`}
value={of.name}
onChange={props.onChange}
/>}
label={of.label} />
))}
</Cluster>
</Stack>
);
}
Loading