Prevent the user from launching multiple jobs by rapidly clicking on buttons

This commit is contained in:
Michael Abashian 2023-09-01 20:40:37 -04:00 committed by Michael Abashian
parent 3eaea396be
commit 480aaeace5

View File

@ -47,6 +47,9 @@ function LaunchButton({ resource, children }) {
const [error, setError] = useState(null); const [error, setError] = useState(null);
const handleLaunch = async () => { const handleLaunch = async () => {
if (isLaunching) {
return;
}
setIsLaunching(true); setIsLaunching(true);
const readLaunch = const readLaunch =
resource.type === 'workflow_job_template' resource.type === 'workflow_job_template'
@ -104,6 +107,10 @@ function LaunchButton({ resource, children }) {
}; };
const launchWithParams = async (params) => { const launchWithParams = async (params) => {
if (isLaunching) {
return;
}
setIsLaunching(true);
try { try {
let jobPromise; let jobPromise;
@ -141,6 +148,9 @@ function LaunchButton({ resource, children }) {
let readRelaunch; let readRelaunch;
let relaunch; let relaunch;
if (isLaunching) {
return;
}
setIsLaunching(true); setIsLaunching(true);
if (resource.type === 'inventory_update') { if (resource.type === 'inventory_update') {
// We'll need to handle the scenario where the src no longer exists // We'll need to handle the scenario where the src no longer exists