Skip to content

Commit

Permalink
Fix #341 UrlActionToken is not handling when the provided url already…
Browse files Browse the repository at this point in the history
… has a querystring; Opened view was always showing "Loading..." as a label.
  • Loading branch information
napernik committed Jan 30, 2017
1 parent d4d148a commit b7e052e
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions Composite/C1Console/Actions/UrlActionToken.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Composite.C1Console.Security;
using Composite.C1Console.Events;
using System.Web;
Expand All @@ -15,7 +13,6 @@ namespace Composite.C1Console.Actions
[ActionExecutor(typeof(UrlActionTokenActionExecutor))]
public sealed class UrlActionToken : ActionToken
{
private readonly IEnumerable<PermissionType> _permissionTypes;
/// <summary>
/// To add a custom URL action
/// </summary>
Expand All @@ -24,20 +21,19 @@ public sealed class UrlActionToken : ActionToken
/// <param name="permissionTypes"></param>
public UrlActionToken(string label, string url, IEnumerable<PermissionType> permissionTypes)
{
this.Url = url;
_permissionTypes = permissionTypes;
Label = label;
Url = url;
PermissionTypes = permissionTypes;
}

/// <exclude />
public string Label { get; private set; }
public string Label { get; }

/// <exclude />
public string Url { get; private set; }
public string Url { get; }

/// <exclude />
public override IEnumerable<PermissionType> PermissionTypes
{
get { return _permissionTypes; }
}
public override IEnumerable<PermissionType> PermissionTypes { get; }

/// <exclude />
public override string Serialize()
Expand Down Expand Up @@ -67,9 +63,18 @@ public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowC

string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

string url = string.Format("{0}?EntityToken={1}", urlActionToken.Url, HttpUtility.UrlEncode(serializedEntityToken));
string url = urlActionToken.Url;

string extendedUrl = $"{url}{(url.Contains("?") ? "&" : "?")}EntityToken={HttpUtility.UrlEncode(serializedEntityToken)}";

ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem { Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = urlActionToken.Label }, currentConsoleId);
ConsoleMessageQueueFacade.Enqueue(
new OpenViewMessageQueueItem
{
Url = extendedUrl,
ViewId = Guid.NewGuid().ToString(),
ViewType = ViewType.Main,
Label = urlActionToken.Label
}, currentConsoleId);

return null;
}
Expand Down

0 comments on commit b7e052e

Please sign in to comment.