forked from giranm/pd-live-react
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add button= URL param to have extra buttons in the UI
- Loading branch information
1 parent
8efb8dc
commit 1557f95
Showing
4 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/components/IncidentActions/subcomponents/ExtraButton.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, { | ||
useState, | ||
} from 'react'; | ||
import { | ||
Box, | ||
Button, | ||
Popover, | ||
PopoverTrigger, | ||
PopoverContent, | ||
PopoverArrow, | ||
PopoverCloseButton, | ||
PopoverBody, | ||
PopoverHeader, | ||
} from '@chakra-ui/react'; | ||
|
||
const isInt = (value) => { | ||
const x = parseInt(value, 10); | ||
return !Number.isNaN(x) && x.toString() === value; | ||
}; | ||
|
||
const ExtraButton = ({ | ||
label, url, width, height, | ||
}) => { | ||
// State to control the open state of the popover | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
// Function to open the popover | ||
const openPopover = () => setIsOpen(true); | ||
|
||
// Function to close the popover | ||
const closePopover = () => setIsOpen(false); | ||
|
||
return ( | ||
<Popover isOpen={isOpen} onClose={closePopover} closeOnBlur={false}> | ||
<PopoverTrigger> | ||
<Button | ||
onClick={openPopover} | ||
id={`incident-action-extra-button-${url}`} | ||
size="sm" | ||
mr={2} | ||
mb={2} | ||
> | ||
{label} | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverContent | ||
zIndex="999" | ||
w={isInt(width) ? `${width}vw` : '80vw'} | ||
h={isInt(height) ? `${height}vh` : '80vh'} | ||
> | ||
<PopoverHeader><b>{label}</b></PopoverHeader> | ||
<PopoverArrow /> | ||
<PopoverCloseButton /> | ||
<PopoverBody height="calc(100% - 60px)"> | ||
<Box flex="1" overflow="hidden" height="100%"> | ||
<iframe | ||
src={url} | ||
title={label} | ||
style={{ | ||
width: '100%', | ||
height: '100%', | ||
border: 'none', | ||
}} | ||
/> | ||
</Box> | ||
</PopoverBody> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
}; | ||
|
||
export default ExtraButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters