-
Notifications
You must be signed in to change notification settings - Fork 761
Added support for prompting for parameter values in run mode #10235
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
88fc925
Added support for prompting for parameter values
davidfowl 985ca1c
Refactor HandleUnresolvedParametersAsync to use List for inputs inste…
davidfowl 42001b5
Add unit tests for ParameterProcessor functionality
davidfowl c7f95fc
Refactor HandleUnresolvedParametersAsync for improved testing and int…
davidfowl 03e5755
Refactor HandleUnresolvedParametersAsync test to use array for parame…
davidfowl 4adeb7a
Refactor HandleUnresolvedParametersAsync tests to improve async handl…
davidfowl cfdc386
Refactor HandleUnresolvedParametersAsync test to enhance interaction …
davidfowl a44dfae
Refactor exception handling in environment variable tests to use Miss…
davidfowl 8954f93
Add MissingParameterValueException for handling missing parameter values
davidfowl a6d7c4c
PR feedback
davidfowl 19e90b6
Fix capitalization in interaction titles for unresolved parameters
davidfowl 9ad2e0d
Update HandleUnresolvedParametersAsync to set Required property to fa…
davidfowl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PR feedback
- Loading branch information
commit a6d7c4c89e6df7876afffb8eb901bd62a9dfe34e
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,8 +18,6 @@ internal sealed class ParameterProcessor( | |
| IInteractionService interactionService, | ||
| ILogger<ParameterProcessor> logger) | ||
| { | ||
| private readonly ResourceNotificationService _notificationService = notificationService; | ||
| private readonly ResourceLoggerService _loggerService = loggerService; | ||
| private readonly List<ParameterResource> _unresolvedParameters = []; | ||
|
|
||
| public async Task InitializeParametersAsync(IEnumerable<ParameterResource> parameterResources) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this take a cancellation token? |
||
|
|
@@ -51,7 +49,7 @@ public async Task InitializeParametersAsync(IEnumerable<ParameterResource> param | |
| } | ||
| catch (Exception ex) | ||
| { | ||
| logger.LogError(ex, "Failed to handle unresolved parameters"); | ||
| logger.LogError(ex, "Failed to handle unresolved parameters."); | ||
| } | ||
| }); | ||
| } | ||
|
|
@@ -64,7 +62,7 @@ private async Task ProcessParameterAsync(ParameterResource parameterResource) | |
| { | ||
| var value = parameterResource.Value ?? ""; | ||
|
|
||
| await _notificationService.PublishUpdateAsync(parameterResource, s => | ||
| await notificationService.PublishUpdateAsync(parameterResource, s => | ||
| { | ||
| return s with | ||
| { | ||
|
|
@@ -74,7 +72,7 @@ await _notificationService.PublishUpdateAsync(parameterResource, s => | |
| }) | ||
| .ConfigureAwait(false); | ||
|
|
||
| parameterResource.WaitForValueTcs?.SetResult(value); | ||
| parameterResource.WaitForValueTcs?.TrySetResult(value); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
|
|
@@ -85,23 +83,23 @@ await _notificationService.PublishUpdateAsync(parameterResource, s => | |
| // Add the parameter to unresolved parameters list. | ||
| _unresolvedParameters.Add(parameterResource); | ||
|
|
||
| _loggerService.GetLogger(parameterResource) | ||
| loggerService.GetLogger(parameterResource) | ||
| .LogWarning(ex, "Parameter resource {ResourceName} could not be initialized. Waiting for user input.", parameterResource.Name); | ||
| } | ||
| else | ||
| { | ||
| // If interaction service is not available, we log the error and set the state to error. | ||
| parameterResource.WaitForValueTcs?.SetException(ex); | ||
| parameterResource.WaitForValueTcs?.TrySetException(ex); | ||
|
|
||
| _loggerService.GetLogger(parameterResource) | ||
| .LogError(ex, "Failed to initialize parameter resource {ResourceName}", parameterResource.Name); | ||
| loggerService.GetLogger(parameterResource) | ||
| .LogError(ex, "Failed to initialize parameter resource {ResourceName}.", parameterResource.Name); | ||
| } | ||
|
|
||
| var stateText = ex is MissingParameterValueException ? | ||
| "Value missing" : | ||
| "Error initializing parameter"; | ||
|
|
||
| await _notificationService.PublishUpdateAsync(parameterResource, s => | ||
| await notificationService.PublishUpdateAsync(parameterResource, s => | ||
| { | ||
| return s with | ||
| { | ||
|
|
@@ -128,12 +126,12 @@ internal async Task HandleUnresolvedParametersAsync(IList<ParameterResource> unr | |
| { | ||
| // First we show a notification that there are unresolved parameters. | ||
| var result = await interactionService.PromptMessageBarAsync( | ||
| "Unresolved Parameters", | ||
| "Unresolved parameters", | ||
| "There are unresolved parameters that need to be set. Please provide values for them.", | ||
| new MessageBarInteractionOptions | ||
| { | ||
| Intent = MessageIntent.Warning, | ||
| PrimaryButtonText = "Enter Values" | ||
| PrimaryButtonText = "Enter values" | ||
| }) | ||
| .ConfigureAwait(false); | ||
|
|
||
|
|
@@ -155,9 +153,9 @@ internal async Task HandleUnresolvedParametersAsync(IList<ParameterResource> unr | |
| } | ||
|
|
||
| var valuesPrompt = await interactionService.PromptInputsAsync( | ||
| "Set Unresolved Parameters", | ||
| "Set unresolved parameters", | ||
| "Please provide values for the unresolved parameters.", | ||
| [.. inputs], | ||
| inputs, | ||
| new InputsDialogInteractionOptions | ||
| { | ||
| PrimaryButtonText = "Submit", | ||
davidfowl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
@@ -182,7 +180,7 @@ internal async Task HandleUnresolvedParametersAsync(IList<ParameterResource> unr | |
| parameter.WaitForValueTcs?.TrySetResult(inputValue); | ||
|
|
||
| // Update the parameter resource state to active with the provided value. | ||
| await _notificationService.PublishUpdateAsync(parameter, s => | ||
| await notificationService.PublishUpdateAsync(parameter, s => | ||
| { | ||
| return s with | ||
| { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.