[ZBX-25730] Can't open URL in a new tab from Event Links menu Created: 2024 Dec 11  Updated: 2025 Jan 30  Resolved: 2025 Jan 30

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 7.0.6
Fix Version/s: 7.0.10rc1, 7.2.4rc1, 7.4.0alpha1

Type: Problem report Priority: Trivial
Reporter: Yurii Polenok Assignee: Eliza Sekace
Resolution: Fixed Votes: 1
Labels: frontend, link, menu, trigger, url
Remaining Estimate: Not Specified
Time Spent: 2.25h
Original Estimate: Not Specified

Attachments: PNG File image-2024-12-12-14-06-07-828.png    
Issue Links:
Causes
caused by ZBX-24972 Map URLs cannot be openned in a new w... Closed
Team: Team B
Sprint: S25-W2/3, S25-W4/5
Story Points: 0.25

 Description   

Broke after ZBX-24972.

Steps to reproduce:

Add URL into event menu using frontend module.

$main_block['data']['urls'][] = [
    'label' => $grafana_dashboard_name,
    'menu_path' => '',
    'url' => $grafana_dashboard_url,
    'target' => '_blank',
    'confirmation' => '',
    'rel' => 'noopener noreferrer'
];

 

Result:
'target' => '_blank' is ignored and the URL is opened in the same browser tab.
Expected:
The ability to open links in the same or a new browser tab depending on the needs and tasks of the user.

Temporarily fixed by adding

item.target = data.params.target;

to the /usr/share/zabbix/js/menupopup.js



 Comments   
Comment by Alexander Vladishev [ 2024 Dec 11 ]

Could you please provide the exact steps to reproduce this issue? Where do you define the URL? At the trigger level or global scripts?

Comment by Yurii Polenok [ 2024 Dec 11 ]

As I said in the request, the url is added using a frontend module.
/usr/share/zabbix/modules/add_links_to_menu/actions/MenuPopupExtendedAction.php

<?php

namespace Modules\Monitoring\Actions;

use API;
use CControllerMenuPopup;
use CControllerResponseData;
use CWebUser;

class MenuPopupExtendedAction extends CControllerMenuPopup {
        private function getTagValue($event_tags, $tag_name) {
            $tag_index = array_search($tag_name, array_column($event_tags, 'tag'));
            $tag_value = $tag_index ? $event_tags[$tag_index]['value'] : '';
            return $tag_value;
        }

        public function getResponse() {
                /** @var CControllerResponseData $response */
                $response = parent::getResponse();
                $input = $this->getInput('data', []);
                $output = $response->getData();
                $main_block = json_decode($output['main_block'] ?? '[]', true);
                if (!isset($input['triggerid']) || !isset($main_block['data']) || !isset($main_block['data']['eventid'])) {
                        return $response;
                }
                $eventid = $main_block['data']['eventid'];
                $event = API::Event()->get([
                    'eventids' => [$eventid],
                    'output' => ['name', 'opdata', 'clock'],
                    'selectHosts' => ['host'],
                    'selectTags' => 'extend'
                ])[0];
                $trigger = API::Trigger()->get([
                    'triggerids' => [$input['triggerid']],
                    'output' => 'extend',
                    'expandComment' => true
                ])[0];
                $event_tags = $event['tags'];

                // Confluence URL
                if ($this->getTagValue($event_tags, 'confluence_url') !== '') {
                    $confluence_url = $this->getTagValue($event_tags, 'confluence_url');
                }
                else {
                    $confluence_url = $trigger['url'];
                }

                $main_block['data']['urls'][] = [
                    'label' => 'Confluence URL',
                    'menu_path' => '',
                    'url' => $confluence_url,
                    'target' => '_blank',
                    'confirmation' => '',
                    'rel' => 'noopener noreferrer'
                ];
                // END Confluence URL

                return new CControllerResponseData(['main_block' => json_encode($main_block)]);
        }
}

 

 

Comment by Andrejs Verza [ 2024 Dec 12 ]

Hi, yuriip,

The target parameter is ignored in URLs because it's not used in Zabbix unless it is a script. As a workaround for your module, you can add the following line to your current code:

$main_block['data']['urls'][] = [
    ...,
    'scriptid' => 0
];
Comment by Yurii Polenok [ 2024 Dec 12 ]

Thanks for the workaround, it works for URLs added by frontend module.
But URLs added by mediatype scripts are still affected.            

{
"label": "ServiceNow: IN12345",
"menu_path": "",
"confirmation": "",
"url": "https://p**.service-now.com/nav_to.do?uri=incident.do?sys_id=***",
"target": "_blank"
}

As you can see, even "target": "_blank" is added by Zabbix itself using mediatype, but further it is ignored and the URL is opened in the same tab.
Please fix this behaviour and/or even add the ability to configure it at different levels/places (trigger, mediatype, script...). It is convenient for someone to open in the same tab, for someone it is necessary in a new one.
Opening everything in a new tab is important to us, and that's how it worked up until version 7.0.6.

Comment by Andrejs Verza [ 2024 Dec 12 ]

yuriip, thank you for your report. The support for "target" parameter will be brought back.

Comment by Eliza Sekace [ 2024 Dec 18 ]

Fixed in development branch feature/ZBX-25730-7.0

Comment by Eliza Sekace [ 2025 Jan 30 ]

Available in:

Generated at Thu Apr 03 19:11:10 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.