Skip to content

Commit

Permalink
MyToDoTasksWidget: fix broken link (demisto#34768)
Browse files Browse the repository at this point in the history
* fix broken link

* Bump pack from version CommonWidgets to 1.2.51.

* Update Packs/CommonWidgets/ReleaseNotes/1_2_51.md

Co-authored-by: Dean Arbel <[email protected]>

---------

Co-authored-by: Content Bot <[email protected]>
Co-authored-by: Dean Arbel <[email protected]>
  • Loading branch information
3 people authored Jun 10, 2024
1 parent 4406202 commit ae8e6f7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
7 changes: 7 additions & 0 deletions Packs/CommonWidgets/ReleaseNotes/1_2_51.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

#### Scripts

##### MyToDoTasksWidget

- Fixed an issue where the incident link was broken in SaaS platforms.
- Updated the Docker image to: *demisto/python3:3.10.14.97100*.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
MAX_ENTRIES = 30


def get_clickable_incident_id(incident_id):
incident_id_url = os.path.join("Custom/caseinfoid", incident_id)
if not is_xsiam_or_xsoar_saas():
incident_id_url = f'#/{incident_id_url}'
return f'[{incident_id}]({incident_id_url})'


def get_open_to_do_tasks_of_current_user() -> List[Dict]:
body = {
"dataType": "todos",
Expand All @@ -28,8 +35,6 @@ def get_open_to_do_tasks_of_current_user() -> List[Dict]:
title = task.get('title', '')
description = task.get('description', '')
task_id = task.get('id', '')
incident_id = task.get('incidentId', '')
clickable_incident_id = f'[{incident_id}]({os.path.join("#/Custom/caseinfoid", incident_id)})'
if sla := task.get('dueDate', ''):
sla_dt = parse(sla)
assert sla_dt is not None, f'could not parse {sla}'
Expand All @@ -41,7 +46,7 @@ def get_open_to_do_tasks_of_current_user() -> List[Dict]:
'Task ID': task_id,
'SLA': sla,
'Opened By': opened_by,
'Incident ID': clickable_incident_id
'Incident ID': get_clickable_incident_id(incident_id=task.get('incidentId', ''))
})
else:
demisto.error(f'Failed running POST query to /v2/statistics/widgets/query.\n{str(todo_tasks_query_res)}')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tags:
timeout: '0'
type: python
subtype: python3
dockerimage: demisto/python3:3.10.13.83255
dockerimage: demisto/python3:3.10.14.97100
fromversion: 6.1.0
tests:
- No test
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json

import demistomock as demisto
from MyToDoTasksWidget import get_open_to_do_tasks_of_current_user
from MyToDoTasksWidget import get_open_to_do_tasks_of_current_user, get_clickable_incident_id
import pytest


def test_open_to_do_tasks_of_current_user(mocker):
Expand Down Expand Up @@ -91,3 +92,18 @@ def test_no_open_to_do_tasks(mocker):
table = get_open_to_do_tasks_of_current_user()

assert len(table) == 0


@pytest.mark.parametrize('is_xsoar_8_or_xsiam', [True, False])
def test_clickable_incident_id(mocker, is_xsoar_8_or_xsiam):
'''
Given:
- incident id to create clickable_incident_id
When:
- Running clickable_incident_id in XSIAM/XSOAR 8 and XSOAR 6
Then:
- Ensure '#/' is in the created link only in XSOAR 6.
'''
import MyToDoTasksWidget
mocker.patch.object(MyToDoTasksWidget, 'is_xsiam_or_xsoar_saas', return_value=is_xsoar_8_or_xsiam)
assert ('#/' in get_clickable_incident_id('1234')) == (not is_xsoar_8_or_xsiam)
2 changes: 1 addition & 1 deletion Packs/CommonWidgets/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Common Widgets",
"description": "Frequently used widgets pack.",
"support": "xsoar",
"currentVersion": "1.2.50",
"currentVersion": "1.2.51",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit ae8e6f7

Please sign in to comment.