| Server IP : 193.146.211.90 / Your IP : 10.85.6.55 Web Server : Apache System : Linux wordpress-gti-69dcdb54f7-n4wdq 6.11.8-arch1-2 #1 SMP PREEMPT_DYNAMIC Fri, 15 Nov 2024 15:35:07 +0000 x86_64 User : 1001 ( 1001) PHP Version : 8.2.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/presto-player/src/admin/settings/components/ |
Upload File : |
const { __ } = wp.i18n;
const {
Button,
Panel,
PanelBody,
Flex,
Modal,
FlexBlock,
FlexItem,
PanelRow,
} = wp.components;
const { useState } = wp.element;
export default ({
connected,
title,
children,
onConnect,
isBusy,
connectButtonText,
disconnectButtonText,
onDisconnect,
}) => {
const [confirm, setConfirm] = useState(false);
return (
<Panel>
<PanelBody
title={
<Flex>
<FlexBlock>{title}</FlexBlock>
<FlexItem>
{connected ? (
<Button isSmall isPrimary style={{ marginRight: "30px" }}>
{__("Connected", "presto-player")}
</Button>
) : (
<Button isSmall isSecondary style={{ marginRight: "30px" }}>
{__("Not Connected", "presto-player")}
</Button>
)}
</FlexItem>
</Flex>
}
initialOpen={false}
>
<form
onSubmit={(e) => {
e.preventDefault();
onConnect();
}}
disabled={isBusy}
>
{children}
<PanelRow>
<div>
{!connected ? (
<Button
isPrimary
isBusy={isBusy}
disabled={isBusy}
type="submit"
>
{connectButtonText
? connectButtonText
: __("Connect", "presto-player")}
</Button>
) : (
<div>
{" "}
<Button
isSecondary
isBusy={isBusy}
disabled={isBusy}
onClick={(e) => {
e.preventDefault();
setConfirm(true);
}}
>
{disconnectButtonText
? disconnectButtonText
: __("Disconnect", "presto-player")}
</Button>
</div>
)}
</div>
</PanelRow>
</form>
</PanelBody>
{confirm && (
<Modal
className="presto-player__modal-confirm"
title={__("Are you sure?", "presto-player")}
style={{ "max-width": "350px" }}
onRequestClose={() => setConfirm(false)}
>
<p>
{__(
"Are you sure you want to disconnect this integration?",
"presto-player"
)}
</p>
<Button
className="presto-player__modal-confirm-button"
isDestructive
onClick={() => {
onDisconnect && onDisconnect();
setConfirm(false);
}}
>
{__("Disconnect", "presto-player")}
</Button>
<Button onClick={() => setConfirm(false)}>
{__("Cancel", "presto-player")}
</Button>
</Modal>
)}
</Panel>
);
};