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

Add updates to allow for Dev Box creation in Dev Home #2639

Merged
merged 10 commits into from
Apr 17, 2024

Conversation

bbonaby
Copy link
Contributor

@bbonaby bbonaby commented Apr 16, 2024

Summary of the pull request

This PR adds the necessary changes to support the creation of Dev Boxes. This PR should be merged before the PR in the Azure extension here: microsoft/DevHomeAzureExtension#154

(Note in a future PR we'll add more documentation surrounding how other card authors can use these changes)
Here are the following changes:

  • A custom renderer called DevHomeChoiceSetWithDynamicRefresh is added to allow the choiceset data for choicesets within an adaptive card to be updated dynamically based on the selection of other input elements in the card, without the need to submit the adaptive card. Note: Adaptivecards doesn't support this but there has been a request to add it [Feature Request] ChoiceSet options should dynamically change subsequent ChoiceSet options, or at least, toggle visibility of other ChoiceSets AdaptiveCards#8598. We'll need to follow up on that to see if we can get a native adaptive card implementation working without a custom renderer.
  • To do this we look for the following key/values:
  • devHomeRefreshChildChoiceSetOnSelectionChanged. This signals to Dev Home that the choice set should be used to refresh data in the card in a selection changed event.
  • A devHomeParentChoiceSetId property, where the parent Id is the Id of the adaptive card element that contains the devHomeRefreshChildChoiceSetOnSelectionChanged property and has the data needed to update the adaptive card element that the devHomeChildChoiceSetId points to.
  • A 'devHomeSelectionChangedDataForChildChoiceSet` property for parent choiceSet which contains all the data that the child choiceSet can be updated with.
  • The DevHomeChoiceSetWithDynamicRefresh also renders a choiceSet that can contain a title, subtitle and value, not just the default title and value. Currently only the compact adaptive card styling gets this treatment but the implementation can be updated for the expanded and filter styles as well.
  • The DevHomeChoicesData class has been added which contains the title, subtitle and value properties. Card authors would add these to their json like
{
  "type": "Input.ChoiceSet",
  "id": "PoolsComboBox",
  "style": "compact",
  "devHomeChoicesData": [
    {
      "$data": "${PoolsList}",
      "title": "${title}",
      "subtitle": "${subtitle}",
      "value": "${value}"
    }
  ]
}

The devHomeChoicesData array would appear in the choiceSets "AdditionalProperties" property and Dev Home can then
deserialized them into a list of DevHomeChoicesData objects.

  • A new template was added to AdaptiveCardResourceTemplates.xaml called ChoiceSetWithSubtitleTemplate that will display the title and subtitle inside a combo box item

  • The DevHomeActionSet renderer has been updated to look for the Id DevHomeTopLevelActionSet when making a decision to hide/show a set of actions within an action set. Before had it would hide all other action sets.

  • Updated EnvironmentCreationOptionsViewModel.cs so it doesn't get a new adaptive card everytime you move from the review page back to the configure environment page

  • Updated the EnvironmentCreationOptionsView.xaml.cs and CreateEnvironmentReviewView.xaml.cs views to remove the elements within the adaptive cards individually before adding it to the grid in its xaml. This is so when moving to and from the configure environment page to the review page no UI elements are still parented to a view of another page, now that we no longer get a new extension adaptive card session when going between the pages. This is to prevent the multi parent xaml exception when an element has multiple parents.

  • updated the CreateComputeSystemOperationViewModel.cs to remove the completed operation from the view and add the new compute system to the view after creation. Beforehand we instructed the user to click the sync page, now we'll automatically update it on completion.

  • Changed _isCreationInProgress property to _isOperationInProgress to be more generic so we can reuse it for other operations in ComputeSystemCardBase.cs

  • Fixed page contaent margins in the creation flow

Video Of DevBox creation once the other change goes in (Creation takes 20 - 30 minutes so I'll update this with another creation operation finishing when done):

DevBoxCreationInDevHome.mp4

Example Json for adaptive card additions:

{
  "type": "AdaptiveCard",
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.5",
  "body": [
    {
      "type": "ColumnSet",
      "spacing": "large",
      "columns": [
        {
          "type": "Column",
          "width": "auto",
          "items": [
            {
              "type": "Input.Text",
              "id": "NewEnvironmentName",
              "label": "${EnterNewEnvironmentTextBoxLabel}",
              "maxLength": 100,
              "isRequired": true,
              "errorMessage": "${DevBoxTextBoxErrorMessage}",
              "regex": "${DevBoxNameRegex}",
              "spacing": "large",
              "value": "${TextBoxText}"
            }
          ]
        }
      ]
    },
    {
      "type": "ColumnSet",
      "spacing": "large",
      "columns": [
        {
          "type": "Column",
          "width": "stretch",
          "items": [
            {
              "type": "Input.ChoiceSet",
              "id": "ProjectsComboBox",
              "label": "${ProjectComboBoxLabel}",
              "devHomeChildChoiceSetId": "PoolsComboBox",
              "devHomeSelectionChangedDataForChildChoiceSet": "${SelectionChangedDataForChildChoiceSet}",
              "devHomeRefreshChildChoiceSetOnSelectionChanged": true,
              "isRequired": true,
              "errorMessage": "${DevBoxProjectComboBoxErrorMessage}",
              "style": "compact",
              "value": "${SelectedProjectIndex}",
              "choices": [
                {
                  "$data": "${ProjectList}",
                  "title": "${title}",
                  "value": "${value}"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "type": "ColumnSet",
      "spacing": "large",
      "columns": [
        {
          "type": "Column",
          "width": "stretch",
          "items": [

            {
              "type": "Input.ChoiceSet",
              "id": "PoolsComboBox",
              "devHomeParentChoiceSetId": "ProjectsComboBox",
              "label": "${DevBoxPoolComboBoxLabel}",
              "isRequired": true,
              "errorMessage": "${DevBoxPoolsComboBoxErrorMessage}",
              "placeholder": "${DevBoxPoolsPlaceHolder}",
              "style": "compact",
              "value": "${SelectedPoolIndex}",
              "devHomeChoicesData": [
                {
                  "$data": "${PoolsList}",
                  "title": "${title}",
                  "subtitle": "${subtitle}",
                  "value": "${value}"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "type": "ActionSet",
      "id": "DevHomeTopLevelActionSet",
      "actions": [
        {
          "id": "DevHomeMachineConfigurationNextButton",
          "type": "Action.Submit",
          "title": "${PrimaryButtonLabelForCreationFlow}"
        },
        {
          "id": "DevHomeMachineConfigurationPreviousButton",
          "type": "Action.Submit",
          "title": "${SecondaryButtonLabelForCreationFlow}"
        }
      ]
    }
  ]
}

References and relevant issues

Detailed description of the pull request / Additional comments

Validation steps performed

PR checklist

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


private void SetupOperationProgressBasedOnState()
{
if (IsComputeSystemStateTransitioning(State))
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: IsOperationInProgress = IsComputeSystemStateTransitioning(State)

@bbonaby bbonaby merged commit 6df049a into main Apr 17, 2024
4 checks passed
@krschau krschau added this to the Dev Home v0.13 milestone Apr 17, 2024
@bbonaby bbonaby linked an issue Apr 17, 2024 that may be closed by this pull request
@@ -193,12 +195,16 @@ public void ReleaseRemoteOperationObject()

partial void OnCurrentPageViewModelChanging(SetupPageViewModelBase value) => PageChanging?.Invoke(null, EventArgs.Empty);

public bool IsNavigatingForward { get; private set; }

public bool IsNavigatingBackward { get; private set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems unnecessary. Backward is just !Forward.

</InfoBar>
</Grid>

<!--- Show the adaptive card on the page if its loaded -->
<Grid
<!--- Show the adaptive card on the page if its loaded. -15 Padding added as the adaptive card adds an extra 40px of padding on all sides -->
Copy link
Contributor

@huzaifa-d huzaifa-d Apr 17, 2024

Choose a reason for hiding this comment

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

Should be 30px, instead of 40. Unless I am understanding this incorrectly.

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