Skip to content

Commit

Permalink
Adjustments to targetpath
Browse files Browse the repository at this point in the history
  • Loading branch information
chandra-tacc committed Oct 3, 2023
1 parent 67f4e75 commit d324e4a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
11 changes: 7 additions & 4 deletions client/src/components/Applications/AppForm/AppForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
});

Expand Down
23 changes: 19 additions & 4 deletions client/src/components/Applications/AppForm/AppFormUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 '*';
}

Expand Down

0 comments on commit d324e4a

Please sign in to comment.