From 7abd8ad9271f0e98fb4b06a35ded2c84bee7ea7b Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Thu, 5 Oct 2023 11:04:04 -0500 Subject: [PATCH] Bug/WP-306: If input file target path is empty, do not send it to tapis (#871) * Adjustments to targetpath * Prettier fix --- .../Applications/AppForm/AppForm.jsx | 11 +++++---- .../Applications/AppForm/AppFormUtils.js | 23 +++++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/client/src/components/Applications/AppForm/AppForm.jsx b/client/src/components/Applications/AppForm/AppForm.jsx index b2b7ed793..787dcf255 100644 --- a/client/src/components/Applications/AppForm/AppForm.jsx +++ b/client/src/components/Applications/AppForm/AppForm.jsx @@ -19,7 +19,7 @@ import { Link } from 'react-router-dom'; import { getSystemName } from 'utils/systems'; import FormSchema from './AppFormSchema'; import { - checkAndSetDefaultTargetPath, + isTargetPathEmpty, isTargetPathField, getInputFieldFromTargetPathField, getQueueMaxMinutes, @@ -501,9 +501,12 @@ export const AppSchemaForm = ({ app }) => { .flat() .filter((fileInput) => fileInput.sourceUrl) // filter out any empty values .map((fileInput) => { - fileInput.targetPath = checkAndSetDefaultTargetPath( - fileInput.targetPath - ); + if (isTargetPathEmpty(fileInput.targetPath)) { + return { + name: fileInput.name, + sourceUrl: fileInput.sourceUrl, + }; + } return fileInput; }); diff --git a/client/src/components/Applications/AppForm/AppFormUtils.js b/client/src/components/Applications/AppForm/AppFormUtils.js index 1b5b30c7e..fcaa7910c 100644 --- a/client/src/components/Applications/AppForm/AppFormUtils.js +++ b/client/src/components/Applications/AppForm/AppFormUtils.js @@ -202,20 +202,35 @@ export const getInputFieldFromTargetPathField = (targetPathFieldName) => { }; /** - * Sets the default value if target path is not set. + * Check if targetPath is empty on input field * * @function * @param {String} targetPathFieldValue - * @returns {String} target path value + * @returns {boolean} if target path is empty */ -export const checkAndSetDefaultTargetPath = (targetPathFieldValue) => { +export const isTargetPathEmpty = (targetPathFieldValue) => { if (targetPathFieldValue === null || targetPathFieldValue === undefined) { - return '*'; + return true; } targetPathFieldValue = targetPathFieldValue.trim(); if (targetPathFieldValue.trim() === '') { + return true; + } + + return false; +}; + +/** + * Sets the default value if target path is not set. + * + * @function + * @param {String} targetPathFieldValue + * @returns {String} target path value + */ +export const checkAndSetDefaultTargetPath = (targetPathFieldValue) => { + if (isTargetPathEmpty(targetPathFieldValue)) { return '*'; }