Skip to content

Commit 0fd9232

Browse files
author
Francesco Pagnamenta
committed
JobSubmitForm changes
1 parent 4812bce commit 0fd9232

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
lines changed

app/modules/compute/components/forms/JobSubmitForm.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import BaseSlideOver from '~/components/overlays/BaseSliderOver'
3434
interface FormData {
3535
systems: [System]
3636
username: string
37+
accountName: string
38+
systemName: string
3739
}
3840

3941
interface JobSubmitFormData {
@@ -50,10 +52,10 @@ const JobSubmitForm: React.FC<any> = ({ formData, formError }: JobSubmitFormData
5052
const [file, setFile] = useState<any>(null)
5153
const [isOpenTargetBrowse, setIsOpenTargetBrowse] = useState(false)
5254
const [loading, setLoading] = useState(false)
53-
const { systems, username } = formData
55+
const { systems, username, systemName, accountName } = formData
5456
const formErrorFields = getFormErrorFieldsFromError(formError)
5557
const [formValues, setFormValues] = useState({
56-
system: '',
58+
system: systemName,
5759
workingDirectory: '',
5860
// advanced options
5961
standardInput: '',
@@ -68,6 +70,8 @@ const JobSubmitForm: React.FC<any> = ({ formData, formError }: JobSubmitFormData
6870
if (healthySystems && healthySystems.length > 0) {
6971
handleSystemChanged(healthySystems[0].name)
7072
}
73+
} else {
74+
handleSystemChanged(systemName)
7175
}
7276
}, [])
7377

@@ -151,14 +155,10 @@ const JobSubmitForm: React.FC<any> = ({ formData, formError }: JobSubmitFormData
151155
</BaseSlideOver>
152156
<div className='sm:overflow-hidden'>
153157
<div>
154-
{/* <div className='mb-6'>
155-
<h2 className='text-lg font-medium leading-6 text-gray-900'>Project details</h2>
156-
<p className='mt-1 text-sm text-gray-500'>Fill the form to proceed with ...</p>
157-
</div> */}
158158
<div className='grid grid-cols-6 gap-6'>
159159
<div className='col-span-6 sm:col-span-2'>
160160
<label htmlFor='system' className='block text-sm font-medium text-gray-700'>
161-
System <span className='italic text-red-400'>*</span>
161+
System <span className='italic text-red-400'>:</span>
162162
</label>
163163
<select
164164
name='system'
@@ -200,6 +200,7 @@ const JobSubmitForm: React.FC<any> = ({ formData, formError }: JobSubmitFormData
200200
<input
201201
type='text'
202202
name='account'
203+
value={formData.accountName}
203204
className='border-gray-300 focus:border-blue-300 focus:ring-blue-300 mt-1 block w-full rounded-md border py-2 px-3 shadow-sm sm:text-sm focus:outline-none'
204205
/>
205206
{showInputValidation({

app/modules/compute/components/views/JobListView.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,22 @@ import SimpleView, { SimpleViewSize } from '~/components/views/SimpleView'
1919
import SimplePanel from '~/components/panels/SimplePanel'
2020
// lists
2121
import JobList from '~/modules/compute/components/lists/JobList'
22+
// contexts
23+
import { useSystem } from '~/contexts/SystemContext'
24+
import { useGroup } from '~/contexts/GroupContext'
2225

2326
const JobListView: React.FC<any> = ({ jobs }) => {
27+
const { selectedSystem } = useSystem()
28+
const { selectedGroup } = useGroup()
29+
2430
const handleClickReload = () => {
2531
window.location.reload()
2632
}
2733

2834
const actionsButtons = (
2935
<>
3036
<Link
31-
to='/compute/jobs/submit'
37+
to={`/compute/systems/${selectedSystem?.name}/accounts/${selectedGroup?.name}/submit`}
3238
className='inline-flex items-center ml-1 px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500'
3339
>
3440
<PlusIcon className='-ml-1 mr-2 h-5 w-5 text-gray-500' aria-hidden='true' />
@@ -41,7 +47,7 @@ const JobListView: React.FC<any> = ({ jobs }) => {
4147
<SimpleView title={LABEL_COMPUTE_TITLE} size={SimpleViewSize.FULL}>
4248
<SimplePanel title={'List of jobs'} className='mb-4' actionsButtons={actionsButtons}>
4349
<AlertError error={jobs.error} />
44-
<JobList jobs={jobs} />
50+
<JobList jobs={jobs} />
4551
</SimplePanel>
4652
</SimpleView>
4753
)

app/modules/filesystem/components/views/FileListView.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -601,22 +601,6 @@ const FileSystemSelection: React.FC<FileSystemSelectionData> = ({
601601
</option>
602602
))}
603603
</optgroup>
604-
{/* {systems &&
605-
systems.length > 0 &&
606-
systems.map((itemSystem: System) => (
607-
<optgroup key={itemSystem.name} label={itemSystem.name}>
608-
{itemSystem.fileSystems.map((itemFileSystem: FileSystem) => (
609-
<option
610-
key={buildFileSystemSelection(itemSystem, itemFileSystem, username)}
611-
value={buildFileSystemSelection(itemSystem, itemFileSystem, username)}
612-
disabled={!isFileSystemHealthy(itemSystem, itemFileSystem)}
613-
>
614-
{`${itemSystem.name} - ${buildFileSystemSelectionPath(itemFileSystem, username)}`}{' '}
615-
{`${isFileSystemHealthy(itemSystem, itemFileSystem) ? '' : ' - unhealthy'}`}
616-
</option>
617-
))}
618-
</optgroup>
619-
))} */}
620604
</select>
621605
</div>
622606
)

app/routes/_app.compute.jobs.submit.tsx renamed to app/routes/_app.compute.systems.$systemName.accounts.$accountName.submit.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { validateJob } from '~/validations/computeValidation'
3131
import ErrorView from '~/components/views/ErrorView'
3232
import JobSubmitView from '~/modules/compute/components/views/JobSubmitView'
3333

34-
export const loader: LoaderFunction = async ({ request }: LoaderFunctionArgs) => {
34+
export const loader: LoaderFunction = async ({ request, params }: LoaderFunctionArgs) => {
3535
// Check authentication
3636
const auth = await authenticator.isAuthenticated(request, {
3737
failureRedirect: '/login',
@@ -43,24 +43,32 @@ export const loader: LoaderFunction = async ({ request }: LoaderFunctionArgs) =>
4343
})
4444
// Get auth access token
4545
const accessToken = await getAuthAccessToken(request)
46+
// Get params
47+
const systemName = params.systemName!
48+
const accountName = params.accountName!
4649
// Call api/s and fetch data
4750
const { systems } = await getSystems(accessToken)
4851
// Return response (deferred response)
4952
return {
5053
formData: {
5154
systems: systems,
5255
username: auth.user.username,
56+
systemName: systemName,
57+
accountName: accountName,
5358
},
5459
}
5560
}
5661

57-
export const action = async ({ request }: ActionFunctionArgs) => {
62+
export const action = async ({ request, params }: ActionFunctionArgs) => {
5863
// Create a headers object
5964
const headers = new Headers()
6065
// Authenticate the request and get the accessToken back, this will be the
6166
// already saved token or the refreshed one, in that case the headers above
6267
// will have the Set-Cookie header appended
6368
const accessToken = await getAuthAccessToken(request, headers)
69+
// Get params
70+
const systemName = params.systemName!
71+
const accountName = params.accountName!
6472
try {
6573
// Instance handler
6674
const uploadHandler = unstable_composeUploadHandlers(
@@ -87,7 +95,7 @@ export const action = async ({ request }: ActionFunctionArgs) => {
8795
headers,
8896
)
8997
// Redirect with headers
90-
return redirect(`/compute`, {
98+
return redirect(`/compute/systems/${systemName}/accounts/${accountName}`, {
9199
headers: headers,
92100
})
93101
} catch (error) {

0 commit comments

Comments
 (0)