Skip to content

Commit

Permalink
Merge pull request #31 from bsandmann/dev
Browse files Browse the repository at this point in the history
fixed form input parameter passing for  issue credential action and e…
  • Loading branch information
ndigirigijohn authored Feb 24, 2025
2 parents 3898400 + 4f16d81 commit 92f6e60
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
<div class="p-4 text-sm">
@if (showToast)
{
<div
class="fixed top-4 right-4 bg-slate-800 text-white px-4 py-2 rounded-lg shadow-lg transition-opacity duration-500 @(showToast ? "opacity-100" : "opacity-0")">
<div class="fixed top-4 right-4 bg-slate-800 text-white px-4 py-2 rounded-lg shadow-lg transition-opacity duration-500 @(showToast ? "opacity-100" : "opacity-0")">
@toastMessage
</div>
}
Expand All @@ -37,9 +36,18 @@
}
else
{
<div class="w-2/3 px-2 py-1 text-xs text-gray-600">
Using subject DID from trigger input
</div>
<select class="w-2/3 rounded border px-2 py-1 text-xs"
@bind="ActionInput.SubjectDid.Path"
@bind:after="OnValueChanged">
<option value="">Select trigger parameter</option>
@if (TriggerParameters?.Any() == true)
{
@foreach (var param in TriggerParameters)
{
<option value="@param">@param</option>
}
}
</select>
}
</div>
</div>
Expand All @@ -52,11 +60,9 @@
@bind:after="OnIssuerDidChanged">
@foreach (var key in IssuingKeys)
{
// Truncate the DID if longer than 20 characters
var displayedDid = key.Did.Length <= 20
? key.Did
: key.Did.Substring(0, 20) + "...";

<option value="@key.IssuingKeyId.ToString()">
@key.Name (@displayedDid)
</option>
Expand All @@ -68,9 +74,8 @@
<div class="border-t pt-3">
<div class="flex justify-between items-center mb-2">
<h4 class="text-xs font-medium text-gray-700">Claims</h4>
<button
class="bg-slate-700 hover:bg-slate-600 text-white text-xs py-1 px-2 rounded transition-colors duration-200 flex items-center"
@onclick="AddNewClaim">
<button class="bg-slate-700 hover:bg-slate-600 text-white text-xs py-1 px-2 rounded transition-colors duration-200 flex items-center"
@onclick="AddNewClaim">
<span class="material-symbols-outlined text-sm mr-1">add</span>
Add Claim
</button>
Expand Down Expand Up @@ -102,31 +107,24 @@
@bind="claim.Value.Value"
@bind:after="OnValueChanged"/>
}
else
else if (claim.Value.Type == ClaimValueType.TriggerProperty)
{
if (claim.Value.ParameterReference == null)
{
claim.Value.ParameterReference = new ParameterReference { Source = ParameterSource.TriggerInput };
}

@if (TriggerParameters?.Any() == true)
{
<select class="w-2/3 rounded border px-2 py-1 text-xs bg-white"
@bind="claim.Value.ParameterReference.Path"
@bind:after="OnValueChanged">
<option value="">Select trigger parameter</option>
<select class="w-2/3 rounded border px-2 py-1 text-xs bg-white"
@bind="claim.Value.ParameterReference!.Path"
@bind:after="OnValueChanged">
<option value="">Select trigger parameter</option>
@if (TriggerParameters?.Any() == true)
{
@foreach (var param in TriggerParameters)
{
<option value="@param">@param</option>
}
</select>
}
else
{
<div class="w-2/3 px-2 py-1 text-xs text-gray-600">
No trigger parameters available
</div>
}
}
else
{
<option value="" disabled>No parameters available</option>
}
</select>
}
</div>
</div>
Expand All @@ -142,22 +140,24 @@

private string? toastMessage;
private bool showToast;

private List<IssuingKey> IssuingKeys { get; set; } = new();

protected override async Task OnInitializedAsync()
{
await LoadIssuingKeys();
}

private async Task LoadIssuingKeys()
{
var tenant = AppStateService.Tenant;
var tenantId = tenant.TenantId;

var result = await Mediator.Send(new GetIssuingKeysRequest(tenantId));
if (result.IsSuccess)
{
IssuingKeys = result.Value;
}
else
{
// Handle error if needed
await ShowToast("Could not load Issuing Keys");
}
}
Expand Down Expand Up @@ -192,7 +192,10 @@
{
ActionInput.SubjectDid.Path = "subjectDid";
}

else
{
ActionInput.SubjectDid.Path = "";
}
await OnValueChanged();
}

Expand Down Expand Up @@ -230,5 +233,4 @@
await OnChange.InvokeAsync();
await ShowToast("Claim removed");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,21 @@
private IEnumerable<string>? GetTriggerParameters()
{
var trigger = FlowItems.FirstOrDefault(x => x is Trigger) as Trigger;
if (trigger?.Input is TriggerInputHttpRequest incomingRequest)
if (trigger == null)
return null;

if (trigger.Input is TriggerInputHttpRequest incomingRequest)
{
return incomingRequest.Parameters.Keys;
}
else if (trigger.Input is TriggerInputForm formTrigger)
{
return formTrigger.Parameters.Keys;
}

return null;
}

private async Task HandleError(string message)
{
_errorMessage = message;
Expand Down

0 comments on commit 92f6e60

Please sign in to comment.