Skip to content

Commit 226b43f

Browse files
committed
FIX open in new tab on middle clic - #164
1 parent 4d24817 commit 226b43f

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

src/web/wizard/components/buttons/ButtonToEventDefinition.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ const ButtonToEventDefinition = ({target, disabled}) => {
2525
const intl = useIntl();
2626
const tooltip = intl.formatMessage({id: "wizard.tooltipEventDefinition", defaultMessage: "Edit event definition for this alert rule"});
2727

28-
const openEventDefinition = () => {
29-
window.open(Routes.ALERTS.DEFINITIONS.edit(target),"_self");
30-
}
28+
const computeURl = () => {
29+
let url = '';
30+
if (!disabled) {
31+
url = Routes.ALERTS.DEFINITIONS.edit(target);
32+
}
33+
return url;
34+
};
3135

3236
return (
33-
<Button bsStyle="info" title={tooltip} disabled={disabled} onClick={openEventDefinition}>
37+
<Button bsStyle="info" title={tooltip} disabled={disabled} href={computeURl()}>
3438
<FormattedMessage id="wizard.eventDefinition" defaultMessage="Event definition" />
3539
</Button>
3640
);

src/web/wizard/components/buttons/ButtonToNotification.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ const ButtonToNotification = ({target, disabled}) => {
2525
const intl = useIntl();
2626
const tooltip = intl.formatMessage({id: "wizard.tooltipNotification", defaultMessage: "Edit notification for this alert rule"});
2727

28-
const openNotification = () => {
29-
window.open(Routes.ALERTS.NOTIFICATIONS.edit(target),"_self");
30-
}
28+
const computeURl = () => {
29+
let url = '';
30+
if (!disabled) {
31+
url = Routes.ALERTS.NOTIFICATIONS.edit(target);
32+
}
33+
return url;
34+
};
3135

3236
return (
33-
<Button bsStyle="info" title={tooltip} disabled={disabled} onClick={openNotification}>
37+
<Button bsStyle="info" title={tooltip} disabled={disabled} href={computeURl()}>
3438
<FormattedMessage id="wizard.notification" defaultMessage="Notification" />
3539
</Button>
3640
);

src/web/wizard/components/buttons/ButtonToSearch.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ const ButtonToSearch = ({searchQuery1, searchQuery2, stream1, stream2, disabled}
4141

4242
const openSearchTabs = () => {
4343
const url1 = createUrl(searchQuery1, stream1);
44-
window.open(url1, '_blank', 'noopener,noreferrer')
44+
window.open(url1, '_blank', 'noopener,noreferrer');
4545

4646
if(stream2 || searchQuery2) {
4747
const url2 = createUrl(searchQuery2, stream2);
4848
window.open(url2, '_blank', 'noopener,noreferrer');
4949
}
50-
}
50+
};
5151

5252
return (
5353
<Button bsStyle="info" title={tooltip} disabled={disabled} onClick={openSearchTabs}>

src/web/wizard/components/buttons/ButtonToUpdateRule.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ const ButtonToUpdateRule = ({target, disabled}) => {
2626
const intl = useIntl();
2727
const tooltip = intl.formatMessage({id: "wizard.buttonInfoUpdate", defaultMessage: "Edit this alert rule"});
2828

29-
const openUpdateRule = () => {
30-
const url = Routes.pluginRoute('WIZARD_UPDATEALERT_ALERTRULETITLE')(target.replace(/\//g, '%2F'));
31-
window.open(url,"_self");
32-
}
29+
const computeURl = () => {
30+
let url = '';
31+
if (!disabled) {
32+
url = Routes.pluginRoute('WIZARD_UPDATEALERT_ALERTRULETITLE')(target.replace(/\//g, '%2F'));
33+
}
34+
return url;
35+
};
3336

3437
return (
3538
<IfPermitted permissions="wizard_alerts_rules:read">
36-
<Button bsStyle="info" title={tooltip} disabled={disabled} onClick={openUpdateRule}>
39+
<Button bsStyle="info" title={tooltip} disabled={disabled} href={computeURl()}>
3740
<FormattedMessage id="wizard.edit" defaultMessage="Edit"/>
3841
</Button>
3942
</IfPermitted>

0 commit comments

Comments
 (0)