Skip to content

Commit

Permalink
HARMONY-1978: Add insertNew param to handleSubmitClick
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnyinverso committed Jan 21, 2025
1 parent 723cb79 commit da27cb0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions services/harmony/public/js/workflow-ui/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ let labelNavItem;
* (hits relevant Harmony url, shows user the response).
* @param {Event} event - the click event
* @param {string} method - the HTTP method
* @param {boolean} insertNew - insert a list element for the new label
*/
async function handleSubmitClick(event, method) {
async function handleSubmitClick(event, method, insertNew) {
event.preventDefault();
const labelName = event.target.getAttribute('data-value');
const jobIds = jobsTable.getJobIds();
Expand All @@ -41,12 +42,12 @@ async function handleSubmitClick(event, method) {
} else if (res.status === 400) {
const responseText = await res.text();
toasts.showUpper(responseText);
if (insertNew) {
labelsModule.insertNewLabelAlphabetically(labelName);
}
} else {
toasts.showUpper('The update failed.');
}
if (res.status === 201) {
labelsModule.insertNewLabelAlphabetically(labelName);
}
}

/**
Expand Down Expand Up @@ -261,7 +262,7 @@ function bindEventListeners() {
setLabelLinksDisabled(selectedJobsCount, labelLinks);
});
document.querySelector('#create-label-link').addEventListener('click', (event) => {
handleSubmitClick(event, 'PUT');
handleSubmitClick(event, 'PUT', true);
bsDropdown.hide();
});
}
Expand Down

0 comments on commit da27cb0

Please sign in to comment.