Skip to content

Commit

Permalink
Merge pull request #447 from PagerDuty/new-tab-button
Browse files Browse the repository at this point in the history
add new tab arg to button= param
  • Loading branch information
gsreynolds authored Jun 14, 2024
2 parents ba7c9fb + 4949650 commit b4b6a73
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
20 changes: 13 additions & 7 deletions src/components/IncidentActions/IncidentActionsComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@ const IncidentActionsComponent = () => (
<AddNoteButton />
<RunActionMenu />
{EXTRA_BUTTONS
&& EXTRA_BUTTONS.map(({
label, url, width, height,
}) => (
<>
<ExtraButton key={url} label={label} url={url} width={width} height={height} />
</>
))}
&& EXTRA_BUTTONS.map(({
label, url, width, height, tab,
}) => (
<>
{tab
? (
<ExtraButton key={url} label={label} url={url} tab />
)
: (
<ExtraButton key={url} label={label} url={url} width={width} height={height} />
)}
</>
))}
</Box>
</Flex>
);
Expand Down
18 changes: 17 additions & 1 deletion src/components/IncidentActions/subcomponents/ExtraButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const isInt = (value) => {
};

const ExtraButton = ({
label, url, width, height,
label, url, width, height, tab,
}) => {
// State to control the open state of the popover
const [isOpen, setIsOpen] = useState(false);
Expand All @@ -30,6 +30,22 @@ const ExtraButton = ({
// Function to close the popover
const closePopover = () => setIsOpen(false);

if (tab) {
return (
<Button
as="a"
id={`incident-action-extra-button-${url}`}
size="sm"
mr={2}
mb={2}
href={url}
target="_blank"
>
{label}
</Button>
);
}

return (
<Popover isOpen={isOpen} onClose={closePopover} closeOnBlur={false}>
<PopoverTrigger>
Expand Down
11 changes: 9 additions & 2 deletions src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,21 @@ export const DEBUG_UNTIL_DATE = debugParams.get('until') || null;
export const EXTRA_BUTTONS = debugParams
.getAll('button')
.map((button) => {
const [label, url, width, height] = button.split(',');
const [label, url, widthOrTab, height] = button.split(',');
if (!label || !url) {
return null;
}
if (widthOrTab === 'tab') {
return {
label,
url,
tab: true,
};
}
return {
label,
url,
width,
width: widthOrTab,
height,
};
})
Expand Down

0 comments on commit b4b6a73

Please sign in to comment.