fix(search): avoid duplicate external ticket tabs
This commit is contained in:
@@ -15,7 +15,7 @@ namespace FasdDesktopUi.Basics.Helper
|
|||||||
{
|
{
|
||||||
private const string DefaultTicketActivityType = "SPSActivityTypeTicket";
|
private const string DefaultTicketActivityType = "SPSActivityTypeTicket";
|
||||||
|
|
||||||
internal static bool TryOpenTicketRelationExternally(cF4sdApiSearchResultRelation relation)
|
internal static bool TryOpenTicketRelationExternally(cF4sdApiSearchResultRelation relation, bool forceExternal = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,7 @@ namespace FasdDesktopUi.Basics.Helper
|
|||||||
|
|
||||||
// check if we have a valid user id in the id list => if not we could open this ticket only extern.
|
// check if we have a valid user id in the id list => if not we could open this ticket only extern.
|
||||||
var hasUser = HasValidUserIdentity(relation);
|
var hasUser = HasValidUserIdentity(relation);
|
||||||
if (!hasUser)
|
if (forceExternal || !hasUser)
|
||||||
processing = enumTicketProcessing.Extern;
|
processing = enumTicketProcessing.Extern;
|
||||||
|
|
||||||
if (processing == enumTicketProcessing.Intern)
|
if (processing == enumTicketProcessing.Intern)
|
||||||
|
|||||||
@@ -1008,8 +1008,11 @@ namespace FasdDesktopUi.Pages.SearchPage
|
|||||||
if (relation == null || relation.Type != enumF4sdSearchResultClass.Ticket)
|
if (relation == null || relation.Type != enumF4sdSearchResultClass.Ticket)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
if (TryOpenTicketOverviewRelationExternally(relation))
|
if (!TicketExternalLinkHelper.HasValidUserIdentity(relation))
|
||||||
|
{
|
||||||
|
TryOpenTicketOverviewRelationExternally(relation, forceExternal: true);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
var ticketName = string.IsNullOrWhiteSpace(relation.DisplayName) ? relation.Name : relation.DisplayName;
|
var ticketName = string.IsNullOrWhiteSpace(relation.DisplayName) ? relation.Name : relation.DisplayName;
|
||||||
var ticketId = relation.id;
|
var ticketId = relation.id;
|
||||||
@@ -1028,15 +1031,15 @@ namespace FasdDesktopUi.Pages.SearchPage
|
|||||||
relation.Infos.TryGetValue("UserSid", out sids);
|
relation.Infos.TryGetValue("UserSid", out sids);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RunTicketSearchAsync(ticketName, ticketId, userName, sids, suppressUi: true);
|
return RunTicketSearchAsync(ticketName, ticketId, userName, sids, suppressUi: true, ticketOverviewRelation: relation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryOpenTicketOverviewRelationExternally(cF4sdApiSearchResultRelation relation)
|
private bool TryOpenTicketOverviewRelationExternally(cF4sdApiSearchResultRelation relation, bool forceExternal = false)
|
||||||
{
|
{
|
||||||
return TicketExternalLinkHelper.TryOpenTicketRelationExternally(relation);
|
return TicketExternalLinkHelper.TryOpenTicketRelationExternally(relation, forceExternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task RunTicketSearchAsync(string ticketName, Guid ticketId, string userName, string sids, bool suppressUi = false)
|
private Task RunTicketSearchAsync(string ticketName, Guid ticketId, string userName, string sids, bool suppressUi = false, cF4sdApiSearchResultRelation ticketOverviewRelation = null)
|
||||||
{
|
{
|
||||||
if (ticketId == Guid.Empty)
|
if (ticketId == Guid.Empty)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
@@ -1054,6 +1057,7 @@ namespace FasdDesktopUi.Pages.SearchPage
|
|||||||
if (_result is null || _result.Count == 0 || _result.First().Value.Count == 0)
|
if (_result is null || _result.Count == 0 || _result.First().Value.Count == 0)
|
||||||
{
|
{
|
||||||
LogEntry($"No corresponding user could be found for ticket '{ticketName}'", LogLevels.Warning);
|
LogEntry($"No corresponding user could be found for ticket '{ticketName}'", LogLevels.Warning);
|
||||||
|
TryOpenTicketOverviewRelationExternally(ticketOverviewRelation, forceExternal: true);
|
||||||
if (suppressUi)
|
if (suppressUi)
|
||||||
EndTicketOverviewAutoContinue(showSearch: true);
|
EndTicketOverviewAutoContinue(showSearch: true);
|
||||||
return;
|
return;
|
||||||
@@ -1063,6 +1067,7 @@ namespace FasdDesktopUi.Pages.SearchPage
|
|||||||
if (userId == Guid.Empty)
|
if (userId == Guid.Empty)
|
||||||
{
|
{
|
||||||
LogEntry($"No valid user id could be found for ticket '{ticketName}'", LogLevels.Warning);
|
LogEntry($"No valid user id could be found for ticket '{ticketName}'", LogLevels.Warning);
|
||||||
|
TryOpenTicketOverviewRelationExternally(ticketOverviewRelation, forceExternal: true);
|
||||||
if (suppressUi)
|
if (suppressUi)
|
||||||
EndTicketOverviewAutoContinue(showSearch: true);
|
EndTicketOverviewAutoContinue(showSearch: true);
|
||||||
return;
|
return;
|
||||||
@@ -1074,6 +1079,9 @@ namespace FasdDesktopUi.Pages.SearchPage
|
|||||||
DisplayName = ticketName,
|
DisplayName = ticketName,
|
||||||
id = ticketId,
|
id = ticketId,
|
||||||
Status = enumF4sdSearchResultStatus.Active,
|
Status = enumF4sdSearchResultStatus.Active,
|
||||||
|
Infos = ticketOverviewRelation?.Infos == null
|
||||||
|
? null
|
||||||
|
: new Dictionary<string, string>(ticketOverviewRelation.Infos),
|
||||||
Identities = new cF4sdIdentityList
|
Identities = new cF4sdIdentityList
|
||||||
{
|
{
|
||||||
new cF4sdIdentityEntry()
|
new cF4sdIdentityEntry()
|
||||||
|
|||||||
Reference in New Issue
Block a user