This repository was archived by the owner on Jun 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Fix multi user extension login for setup environment and create environment flows #3907
Merged
bbonaby
merged 2 commits into
main
from
user/bbonaby/allow-multiple-environments-from-same-provider
Oct 3, 2024
Merged
Changes from 1 commit
Commits
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
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
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
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
57 changes: 57 additions & 0 deletions
57
tools/SetupFlow/DevHome.SetupFlow/Converters/CreationStateKindToVisibilityConverter.cs
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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using DevHome.Common.Environments.Models; | ||
| using DevHome.SetupFlow.ViewModels.Environments; | ||
| using Microsoft.UI.Xaml; | ||
| using Microsoft.UI.Xaml.Data; | ||
| using Microsoft.UI.Xaml.Media; | ||
|
|
||
| namespace DevHome.SetupFlow.Converters; | ||
|
|
||
| /// <summary> | ||
| /// Converter to convert the state of the EnvironmentCreationOptions page to a visibility enum. | ||
bbonaby marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// </summary> | ||
| public class CreationStateKindToVisibilityConverter : IValueConverter | ||
| { | ||
| private const string ProgressRingGridName = "ProgressRingGrid"; | ||
|
|
||
| private const string AdaptiveCardGridName = "AdaptiveCardGrid"; | ||
|
|
||
| public object Convert(object value, Type targetType, object parameter, string language) | ||
| { | ||
| var parameterString = (string)parameter; | ||
| var creationStateKind = (CreationPageStateKind)value; | ||
|
|
||
| if (parameterString.Equals(AdaptiveCardGridName, StringComparison.Ordinal)) | ||
| { | ||
| return creationStateKind switch | ||
| { | ||
| CreationPageStateKind.InitialPageAdaptiveCardLoaded => Visibility.Visible, | ||
| _ => Visibility.Collapsed, | ||
| }; | ||
| } | ||
|
|
||
| if (parameterString.Equals(ProgressRingGridName, StringComparison.Ordinal)) | ||
| { | ||
| return creationStateKind switch | ||
| { | ||
| CreationPageStateKind.InitialPageAdaptiveCardLoading => Visibility.Visible, | ||
| CreationPageStateKind.OtherPageAdaptiveCardLoading => Visibility.Visible, | ||
| _ => Visibility.Collapsed, | ||
| }; | ||
| } | ||
|
|
||
| return Visibility.Collapsed; | ||
| } | ||
|
|
||
| public object ConvertBack(object value, Type targetType, object parameter, string language) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
| } | ||
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
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
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
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 |
|---|---|---|
|
|
@@ -48,8 +48,6 @@ public partial class ComputeSystemsListViewModel : ObservableObject | |
|
|
||
| public AdvancedCollectionView ComputeSystemCardAdvancedCollectionView { get; private set; } | ||
|
|
||
| public Dictionary<DeveloperIdWrapper, ComputeSystemsResult> DevIdToComputeSystemMap { get; set; } | ||
|
|
||
| public ComputeSystemProvider Provider { get; set; } | ||
|
|
||
| public DeveloperIdWrapper CurrentDeveloperId { get; set; } | ||
|
Contributor
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. Do we handle logout already? If we're reloading the environments on page load, we're probably fine, since the user will have to move to a different page to logout. If not, we might need to listen to DevId logout event
Contributor
Author
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. Thats a good call out we'd probably need listen for the event and refresh the page accordingly. I'll create an issue for that since we probably don't want this PR getting too big |
||
|
|
@@ -101,21 +99,22 @@ public override string ToString() | |
| return AccessibilityName; | ||
| } | ||
|
|
||
| public ComputeSystemsListViewModel(ComputeSystemsLoadedData loadedData) | ||
| public ComputeSystemsListViewModel( | ||
| ComputeSystemProviderDetails providerDetails, | ||
| KeyValuePair<DeveloperIdWrapper, ComputeSystemsResult> devIdComputeSystemPair) | ||
| { | ||
| Provider = loadedData.ProviderDetails.ComputeSystemProvider; | ||
| DevIdToComputeSystemMap = loadedData.DevIdToComputeSystemMap; | ||
|
|
||
| // Get the first developerId and compute system result. | ||
| var devIdToResultKeyValuePair = DevIdToComputeSystemMap.FirstOrDefault(); | ||
| CurrentResult = devIdToResultKeyValuePair.Value; | ||
| CurrentDeveloperId = devIdToResultKeyValuePair.Key; | ||
| Provider = providerDetails.ComputeSystemProvider; | ||
| CurrentResult = devIdComputeSystemPair.Value; | ||
| CurrentDeveloperId = devIdComputeSystemPair.Key; | ||
|
|
||
| DisplayName = Provider.DisplayName; | ||
|
|
||
| if ((CurrentResult != null) && (CurrentResult.ComputeSystems != null)) | ||
| { | ||
| ComputeSystems = CurrentResult.ComputeSystems.Select(computeSystem => new ComputeSystemCache(computeSystem)).ToList(); | ||
| // Filter out compute systems that do not support configuration. | ||
bbonaby marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ComputeSystems = CurrentResult.ComputeSystems | ||
| .Where(computeSystem => computeSystem.SupportedOperations.HasFlag(ComputeSystemOperations.ApplyConfiguration)) | ||
| .Select(computeSystem => new ComputeSystemCache(computeSystem)).ToList(); | ||
| } | ||
|
|
||
| // Create a new AdvancedCollectionView for the ComputeSystemCards collection. | ||
|
|
||
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.