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

Update environments to show supported operations dynamically based the state change events. #2732

Merged
merged 4 commits into from
May 1, 2024

Conversation

bbonaby
Copy link
Contributor

@bbonaby bbonaby commented Apr 24, 2024

Summary of the pull request

This PR aims to allow the compute system operations that appear in the horizontal dots menu flyout and the launch split button menu flyout to be dynamically updated based on the state of the compute system. For background, each compute system view model contains an observable collection with view models for both of the flyouts. Each item in the collection is a view model that contains a relay command.

Changes:

  1. I updated the card flyout control to subscribe/unsubscribe to collection changed events so when the collection is cleared and new items are added the list of menuflyout items are updated.
  2. I also consolidated the InitializePinDataAsync and UpdateOperationsPostCreation methods into the InitializeOperationDataAsync method where we now populate the dot and launch observable collections.
    3.Upon a state change, we call the InitializeOperationDataAsync to clear and add the supported operations for the compute system
  3. Removed line where we set the IsOperationInProgress to false after the extension completes the operation, as we will rely on the state of the compute system to tell us when the progress bar should not be shown. This is needed for providers like Dev box where an operation may not be completely done just because the extension returns the completed result. (Cloud operations can take a while so the Dev Box extension polls the Dev Center for the status of the operation which could take minutes). The initial result returned to Dev Home in that case would just be that the request was sent successfully and the operation has initiated without errors. We use this method
    private bool IsComputeSystemStateTransitioning(ComputeSystemState state)
    to check if the compute system's state is transitioning into/out of a processing state.

Video of flow: (takes 20 - 40 minutes to create a Dev Box in the cloud so paused and unpaused video when I received the creation email). Key parts to take note of is, the launch button no longer appearing during creation, and after creation the dot and launch operations now appear based on the supported operations of the compute system.

dev.box.creation.now.with.dynamic.operation.support.mp4

References and relevant issues

Also updated dev box in azure extension to show correct state immediately after creation: microsoft/DevHomeAzureExtension#163

Detailed description of the pull request / Additional comments

Validation steps performed

Tested and confirmed it is now working as expected with change:

PR checklist

  • Closes #xxx
  • Tests added/passed
  • Documentation updated

@bbonaby bbonaby marked this pull request as ready for review April 24, 2024 09:52

if (args.OldValue != null)
{
var oldOperationsViewModel = (INotifyCollectionChanged)args.OldValue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This'll crash if args.OldValue isn't an INotifyCollectionChanged is that okay in this context?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest using "as" rather than c style casting so you can null check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants