Skip to content

Commit

Permalink
Add target path for every file input
Browse files Browse the repository at this point in the history
Rebase
  • Loading branch information
chandra-tacc committed Sep 13, 2023
1 parent 0eeec05 commit e1b4700
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
55 changes: 43 additions & 12 deletions client/src/components/Applications/AppForm/AppForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ import { Link } from 'react-router-dom';
import { getSystemName } from 'utils/systems';
import FormSchema from './AppFormSchema';
import {
<<<<<<< HEAD
checkAndSetDefaultTargetPath,
=======
>>>>>>> 47de92d3 (Add target path for every file input)
isTargetPathField,
getInputFieldFromTargetPathField,
getQueueMaxMinutes,
getMaxMinutesValidation,
getNodeCountValidation,
getCoresPerNodeValidation,
getTargetPathFieldName,
updateValuesForQueue,
} from './AppFormUtils';
import DataFilesSelectModal from '../../DataFiles/DataFilesModals/DataFilesSelectModal';
Expand Down Expand Up @@ -462,27 +466,35 @@ export const AppSchemaForm = ({ app }) => {
onSubmit={(values, { setSubmitting, resetForm }) => {
const job = cloneDeep(values);

// Tranform input field values into format that jobs service wants
job.fileInputs = Object.entries(job.fileInputs)
.map(([k, v]) => {
// filter out read only inputs. 'FIXED' inputs are tracked as readOnly
if (
Object.hasOwn(appFields.fileInputs, k) &&
appFields.fileInputs[k].readOnly
)
return;
return {
name: k,
sourceUrl: v,
targetPath: app.definition.jobAttributes.fileInputs.find(
(file) => file.name === k
).targetPath,
};
})
.filter((fileInput) => fileInput && fileInput.sourceUrl); // filter out any empty values
// Transform input field values into format that jobs service wants
job.fileInputs = Object.values(
Object.entries(job.fileInputs)
.map(([k, v]) => {
// filter out read only inputs. 'FIXED' inputs are tracked as readOnly
if (
Object.hasOwn(appFields.fileInputs, k) &&
appFields.fileInputs[k].readOnly
)
return;
return {
name: k,
sourceUrl: !isTargetPathField(k) ? v : null,
targetDir: isTargetPathField(k)
? checkAndSetDefaultTargetPath(v)
: null,
targetDir: isTargetPathField(k) ? v : null,
};
})
.filter((fileInput) => fileInput.sourceUrl || fileInput.targetDir) // filter out any empty values
.reduce((acc, entry) => {
// merge input field and targetPath fields into one.
.reduce((acc, entry) => { // merge input field and targetPath fields into one.
const key = getInputFieldFromTargetPathField(entry.name);
if (!acc[key]) {
acc[key] = {};
Expand Down Expand Up @@ -585,6 +597,7 @@ export const AppSchemaForm = ({ app }) => {
{Object.entries(appFields.fileInputs).map(
([name, field]) => {
// TODOv3 handle fileInputArrays https://jira.tacc.utexas.edu/browse/WP-81
<<<<<<< HEAD
return isTargetPathField(name) ? (
<FormField
{...field}
Expand All @@ -601,6 +614,24 @@ export const AppSchemaForm = ({ app }) => {
placeholder="Browse Data Files"
key={`fileInputs.${name}`}
/>
=======
return (
isTargetPathField(name)?
<FormField
{...field}
name={`fileInputs.${name}`}
placeholder="Target Path Name"
key={`fileInputs.${name}`}
/>:
<FormField
{...field}
name={`fileInputs.${name}`}
tapisFile
SelectModal={DataFilesSelectModal}
placeholder="Browse Data Files"
key={`fileInputs.${name}`}
/>
>>>>>>> 47de92d3 (Add target path for every file input)
);
}
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const FormSchema = (app) => {
input.sourceUrl === null || typeof input.sourceUrl === 'undefined'
? ''
: input.sourceUrl;

// Add targetDir for all sourceUrl
const targetPathName = getTargetPathFieldName(input.name);
appFields.schema.fileInputs[targetPathName] = Yup.string();
Expand Down

0 comments on commit e1b4700

Please sign in to comment.