Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed form input parameter passing for issue credential action and e… #31

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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