mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
Show a toast when the job is already in the process of launching
This commit is contained in:
committed by
Michael Abashian
parent
480aaeace5
commit
56230ba5d1
@@ -11,6 +11,7 @@ import {
|
|||||||
WorkflowJobsAPI,
|
WorkflowJobsAPI,
|
||||||
WorkflowJobTemplatesAPI,
|
WorkflowJobTemplatesAPI,
|
||||||
} from 'api';
|
} from 'api';
|
||||||
|
import useToast, { AlertVariant } from 'hooks/useToast';
|
||||||
import AlertModal from '../AlertModal';
|
import AlertModal from '../AlertModal';
|
||||||
import ErrorDetail from '../ErrorDetail';
|
import ErrorDetail from '../ErrorDetail';
|
||||||
import LaunchPrompt from '../LaunchPrompt';
|
import LaunchPrompt from '../LaunchPrompt';
|
||||||
@@ -45,9 +46,20 @@ function LaunchButton({ resource, children }) {
|
|||||||
const [isLaunching, setIsLaunching] = useState(false);
|
const [isLaunching, setIsLaunching] = useState(false);
|
||||||
const [resourceCredentials, setResourceCredentials] = useState([]);
|
const [resourceCredentials, setResourceCredentials] = useState([]);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
|
const { addToast, Toast, toastProps } = useToast();
|
||||||
|
|
||||||
|
const showToast = () => {
|
||||||
|
addToast({
|
||||||
|
id: resource.id,
|
||||||
|
title: t`A job has already been launched`,
|
||||||
|
variant: AlertVariant.info,
|
||||||
|
hasTimeout: true,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleLaunch = async () => {
|
const handleLaunch = async () => {
|
||||||
if (isLaunching) {
|
if (isLaunching) {
|
||||||
|
showToast();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setIsLaunching(true);
|
setIsLaunching(true);
|
||||||
@@ -108,6 +120,7 @@ function LaunchButton({ resource, children }) {
|
|||||||
|
|
||||||
const launchWithParams = async (params) => {
|
const launchWithParams = async (params) => {
|
||||||
if (isLaunching) {
|
if (isLaunching) {
|
||||||
|
showToast();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setIsLaunching(true);
|
setIsLaunching(true);
|
||||||
@@ -149,6 +162,7 @@ function LaunchButton({ resource, children }) {
|
|||||||
let relaunch;
|
let relaunch;
|
||||||
|
|
||||||
if (isLaunching) {
|
if (isLaunching) {
|
||||||
|
showToast();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setIsLaunching(true);
|
setIsLaunching(true);
|
||||||
@@ -207,6 +221,7 @@ function LaunchButton({ resource, children }) {
|
|||||||
handleRelaunch,
|
handleRelaunch,
|
||||||
isLaunching,
|
isLaunching,
|
||||||
})}
|
})}
|
||||||
|
<Toast {...toastProps} />
|
||||||
{error && (
|
{error && (
|
||||||
<AlertModal
|
<AlertModal
|
||||||
isOpen={error}
|
isOpen={error}
|
||||||
|
|||||||
Reference in New Issue
Block a user