removed anonymous function
This commit is contained in:
parent
189d749c89
commit
9ad2e74c2a
@ -53,31 +53,36 @@ export const WebhookDialog = ({
|
|||||||
webhook,
|
webhook,
|
||||||
passwordSettings,
|
passwordSettings,
|
||||||
}) => {
|
}) => {
|
||||||
|
const [isResetVisible, setIsResetVisible] = useState(isSettingsModal);
|
||||||
|
const [isPasswordValid, setIsPasswordValid] = useState(false);
|
||||||
|
const [webhookInfo, setWebhookInfo] = useState({
|
||||||
|
id: 0,
|
||||||
|
title: webhook ? webhook.title : "",
|
||||||
|
url: webhook ? webhook.url : "",
|
||||||
|
secretKey: webhook ? webhook.secretKey : "",
|
||||||
|
isEnabled: webhook ? webhook.isEnabled : true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const submitButtonRef = useRef();
|
||||||
|
|
||||||
const onModalClose = () => {
|
const onModalClose = () => {
|
||||||
onClose();
|
onClose();
|
||||||
isSettingsModal && setIsResetVisible(true);
|
isSettingsModal && setIsResetVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onKeyPress = (e) => (e.key === "Esc" || e.key === "Escape") && onModalClose();
|
const hideReset = () => setIsResetVisible(false);
|
||||||
const [isResetVisible, setIsResetVisible] = useState(isSettingsModal);
|
|
||||||
|
|
||||||
const submitButtonRef = useRef();
|
|
||||||
|
|
||||||
const [isPasswordValid, setIsPasswordValid] = useState(false);
|
|
||||||
|
|
||||||
const [webhookInfo, setWebhookInfo] = useState({
|
|
||||||
id: 0,
|
|
||||||
title: webhook ? webhook.title : "",
|
|
||||||
url: webhook ? webhook.url : "",
|
|
||||||
secretKey: "",
|
|
||||||
isEnabled: webhook ? webhook.isEnabled : true,
|
|
||||||
});
|
|
||||||
const onInputChange = (e) =>
|
const onInputChange = (e) =>
|
||||||
setWebhookInfo((prevWebhookInfo) => {
|
setWebhookInfo((prevWebhookInfo) => {
|
||||||
prevWebhookInfo[e.target.name] = e.target.value;
|
prevWebhookInfo[e.target.name] = e.target.value;
|
||||||
return prevWebhookInfo;
|
return prevWebhookInfo;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleSubmitClick = () => {
|
||||||
|
isPasswordValid && submitButtonRef.current.click();
|
||||||
|
isResetVisible && submitButtonRef.current.click();
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.addEventListener("keyup", onKeyPress);
|
window.addEventListener("keyup", onKeyPress);
|
||||||
//delete, when api will be connected
|
//delete, when api will be connected
|
||||||
@ -88,6 +93,8 @@ export const WebhookDialog = ({
|
|||||||
return () => window.removeEventListener("keyup", onKeyPress);
|
return () => window.removeEventListener("keyup", onKeyPress);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const onKeyPress = (e) => (e.key === "Esc" || e.key === "Escape") && onModalClose();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalDialog withFooterBorder visible={visible} onClose={onModalClose} displayType="aside">
|
<ModalDialog withFooterBorder visible={visible} onClose={onModalClose} displayType="aside">
|
||||||
<ModalDialog.Header>{header}</ModalDialog.Header>
|
<ModalDialog.Header>{header}</ModalDialog.Header>
|
||||||
@ -130,7 +137,7 @@ export const WebhookDialog = ({
|
|||||||
You cannot retrieve your secret key again once it has been saved. If you've lost or
|
You cannot retrieve your secret key again once it has been saved. If you've lost or
|
||||||
forgotten this secret key, you can reset it, but all integrations using this secret
|
forgotten this secret key, you can reset it, but all integrations using this secret
|
||||||
will need to be updated.
|
will need to be updated.
|
||||||
<DashedButton onClick={() => setIsResetVisible(false)}>Reset key</DashedButton>
|
<DashedButton onClick={hideReset}>Reset key</DashedButton>
|
||||||
</InfoHint>
|
</InfoHint>
|
||||||
) : (
|
) : (
|
||||||
<DashedButton>Generate</DashedButton>
|
<DashedButton>Generate</DashedButton>
|
||||||
@ -146,9 +153,7 @@ export const WebhookDialog = ({
|
|||||||
label={isSettingsModal ? "Save" : "Create"}
|
label={isSettingsModal ? "Save" : "Create"}
|
||||||
size="normal"
|
size="normal"
|
||||||
primary={true}
|
primary={true}
|
||||||
onClick={() => {
|
onClick={handleSubmitClick}
|
||||||
isPasswordValid && submitButtonRef.current.click();
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<Button label="Cancel" size="normal" onClick={onModalClose} />
|
<Button label="Cancel" size="normal" onClick={onModalClose} />
|
||||||
</Footer>
|
</Footer>
|
||||||
|
Loading…
Reference in New Issue
Block a user