From d324e4ae710e89e34e68724a25ce6db730677fbd Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Tue, 3 Oct 2023 17:39:15 -0500 Subject: [PATCH] Adjustments to targetpath --- .../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..f59a41027 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 '*'; }