[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 (Inactive) |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | frontend, link, menu, trigger, url | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | 2.25h | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Team: | |||||||||
| Sprint: | S25-W2/3, S25-W4/5 | ||||||||
| Story Points: | 0.25 | ||||||||
| Description |
|
Broke after 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: 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. <?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. {
"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. |
| 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 (Inactive) [ 2024 Dec 18 ] |
|
Fixed in development branch feature/ZBX-25730-7.0 |
| Comment by Eliza Sekace (Inactive) [ 2025 Jan 30 ] |
|
Available in:
|