Skip to content

Commit

Permalink
Loading screen messages have the correct automation name. (#3274)
Browse files Browse the repository at this point in the history
* Moving around methods

* Setting the automation name
  • Loading branch information
dhoehna authored Jun 25, 2024
1 parent 7f01cdc commit 76eb695
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 163 deletions.
322 changes: 161 additions & 161 deletions tools/SetupFlow/DevHome.SetupFlow/ViewModels/AddRepoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,62 @@ public List<CloningInformation> EverythingToClone
/// </summary>
private IEnumerable<IRepository> _repositoriesForAccount;

/// <summary>
/// Used to figure out what button is pressed for the split button.
/// This determines the UI elements shown/hidden.
/// </summary>
private enum SegmentedItemTag
{
Account,
URL,
}

/// <summary>
/// Indicates if the ListView is currently filtering items. A result of manually filtering a list view
/// is that the SelectionChanged is fired for any selected item that is removed and the item isn't "re-selected"
/// To prevent our EverythingToClone from changing this flag is used.
/// If true any removals caused by filtering are ignored.
/// Question. If the items aren't "re-selected" how do they become selected? The list view has SelectRange
/// that can be used to re-select items. This is done in the view.
/// </summary>
private bool _isFiltering;

/// <summary>
/// Gets or sets a value indicating whether the SelectionChange event fired because SelectRange was called.
/// After filtering SelectRange is called to re-select all previously selected items. This causes SelectionChanged
/// to be fired for each item. Because EverythingToClone didn't change during filtering it contains every item to select.
/// This flag is to prevent adding duplicate items are being re-selected.
/// </summary>
public bool IsCallingSelectRange { get; set; }

/// <summary>
/// Gets a value indicating whether the UI can skip the account page and switch to the repo page.
/// </summary>
/// <remarks>
/// UI can skip the account tab and go to the repo page if the following conditions are met
/// 1. DevHome has only 1 provider installed.
/// 2. The provider has only 1 logged in account.
/// </remarks>
public bool CanSkipAccountConnection
{
get;
private set;
}

/// <summary>
/// Gets or sets what page the user is currently on. Used to branch logic depending on the page.
/// </summary>
internal PageKind CurrentPage
{
get; set;
}

public bool IsSettingUpLocalMachine => _setupFlowOrchestrator.IsSettingUpLocalMachine;

private TypedEventHandler<IDeveloperIdProvider, IDeveloperId> _developerIdChangedEvent;

private string _selectedRepoProvider = string.Empty;

/// <summary>
/// Names of all providers. This is shown to the user on the accounts page.
/// </summary>
Expand Down Expand Up @@ -290,14 +346,46 @@ public List<CloningInformation> EverythingToClone
private string _selectionOptionsPlaceholderText;

/// <summary>
/// Used to figure out what button is pressed for the split button.
/// This determines the UI elements shown/hidden.
/// The accounts the user is logged into is stored here.
/// </summary>
private enum SegmentedItemTag
{
Account,
URL,
}
[ObservableProperty]
private MenuFlyout _accountsToShow;

/// <summary>
/// Used to show the login UI.
/// </summary>
[ObservableProperty]
private Frame _loginUiContent;

/// <summary>
/// Solely used to reset the account drop down when the account page is navigated to.
/// </summary>
[ObservableProperty]
private int _accountIndex;

/// <summary>
/// Text that prompts the user if they want to add search inputs.
/// </summary>
[ObservableProperty]
private string _askToChangeLabel;

/// <summary>
/// If the extension allows users to further filter repo results.
/// </summary>
[ObservableProperty]
private bool _shouldShowGranularSearch;

/// <summary>
/// Controls if the hyperlink button that allows switching to the search terms page is visible.
/// </summary>
[ObservableProperty]
private bool _shouldShowChangeSearchTermsHyperlinkButton;

[ObservableProperty]
private bool _shouldShowNoRepoMessage;

[ObservableProperty]
private string _noRepositoriesMessage;

/// <summary>
/// Hides/Shows UI elements for the selected button.
Expand Down Expand Up @@ -375,52 +463,6 @@ public void SaveCloneLocation(string location)
ToggleCloneButton();
}

/// <summary>
/// Indicates if the ListView is currently filtering items. A result of manually filtering a list view
/// is that the SelectionChanged is fired for any selected item that is removed and the item isn't "re-selected"
/// To prevent our EverythingToClone from changing this flag is used.
/// If true any removals caused by filtering are ignored.
/// Question. If the items aren't "re-selected" how do they become selected? The list view has SelectRange
/// that can be used to re-select items. This is done in the view.
/// </summary>
private bool _isFiltering;

/// <summary>
/// Gets or sets a value indicating whether the SelectionChange event fired because SelectRange was called.
/// After filtering SelectRange is called to re-select all previously selected items. This causes SelectionChanged
/// to be fired for each item. Because EverythingToClone didn't change during filtering it contains every item to select.
/// This flag is to prevent adding duplicate items are being re-selected.
/// </summary>
public bool IsCallingSelectRange { get; set; }

/// <summary>
/// Gets a value indicating whether the UI can skip the account page and switch to the repo page.
/// </summary>
/// <remarks>
/// UI can skip the account tab and go to the repo page if the following conditions are met
/// 1. DevHome has only 1 provider installed.
/// 2. The provider has only 1 logged in account.
/// </remarks>
public bool CanSkipAccountConnection
{
get;
private set;
}

/// <summary>
/// Gets or sets what page the user is currently on. Used to branch logic depending on the page.
/// </summary>
internal PageKind CurrentPage
{
get; set;
}

public bool IsSettingUpLocalMachine => _setupFlowOrchestrator.IsSettingUpLocalMachine;

private TypedEventHandler<IDeveloperIdProvider, IDeveloperId> _developerIdChangedEvent;

private string _selectedRepoProvider = string.Empty;

/// <summary>
/// Logs the user into the provider if they aren't already.
/// Changes the page to show all repositories for the user.
Expand Down Expand Up @@ -469,69 +511,13 @@ private void MakeNewDevDrive(bool isCheckBoxChecked)
}
}

/// <summary>
/// Update dialog to show Dev Drive information.
/// </summary>
public void UpdateDevDriveInfo()
{
EditDevDriveViewModel.MakeDefaultDevDrive();
FolderPickerViewModel.DisableBrowseButton();
_addRepoDialog.OldCloneLocation = FolderPickerViewModel.CloneLocation;
FolderPickerViewModel.CloneLocation = EditDevDriveViewModel.GetDriveDisplayName();
FolderPickerViewModel.CloneLocationAlias = EditDevDriveViewModel.GetDriveDisplayName(DevDriveDisplayNameKind.FormattedDriveLabelKind);
FolderPickerViewModel.InDevDriveScenario = true;
EditDevDriveViewModel.IsDevDriveCheckboxChecked = true;
}

[RelayCommand]
private void CancelButtonPressed()
{
IsLoggingIn = false;
IsCancelling = true;
}

/// <summary>
/// The accounts the user is logged into is stored here.
/// </summary>
[ObservableProperty]
private MenuFlyout _accountsToShow;

/// <summary>
/// Used to show the login UI.
/// </summary>
[ObservableProperty]
private Frame _loginUiContent;

/// <summary>
/// Solely used to reset the account drop down when the account page is navigated to.
/// </summary>
[ObservableProperty]
private int _accountIndex;

/// <summary>
/// Text that prompts the user if they want to add search inputs.
/// </summary>
[ObservableProperty]
private string _askToChangeLabel;

/// <summary>
/// If the extension allows users to further filter repo results.
/// </summary>
[ObservableProperty]
private bool _shouldShowGranularSearch;

/// <summary>
/// Controls if the hyperlink button that allows switching to the search terms page is visible.
/// </summary>
[ObservableProperty]
private bool _shouldShowChangeSearchTermsHyperlinkButton;

[ObservableProperty]
private bool _shouldShowNoRepoMessage;

[ObservableProperty]
private string _noRepositoriesMessage;

/// <summary>
/// Switches the repos shown to the account selected.
/// </summary>
Expand All @@ -548,20 +534,6 @@ private void MenuItemClick(string selectedItemName)
});
}

/// <summary>
/// Uses search inputs to search for repos.
/// </summary>
private void SearchRepos()
{
_dispatcherQueue.TryEnqueue(async () =>
{
await SearchForRepos(_selectedRepoProvider, SelectedAccount);
var sdkDisplayName = _providers.GetSDKProvider(_selectedRepoProvider).DisplayName;
_addRepoDialog.SelectRepositories(SetRepositories(sdkDisplayName, SelectedAccount));
});
}

[RelayCommand]
private async Task OpenFolderPicker()
{
Expand Down Expand Up @@ -662,6 +634,72 @@ public void SaveRepoUrl(string repoUrl)
ToggleCloneButton();
}

public AddRepoViewModel(
SetupFlowOrchestrator setupFlowOrchestrator,
ISetupFlowStringResource stringResource,
List<CloningInformation> previouslySelectedRepos,
IHost host,
Guid activityId,
AddRepoDialog addRepoDialog,
IDevDriveManager devDriveManager)
{
_addRepoDialog = addRepoDialog;
_stringResource = stringResource;
_host = host;
_dispatcherQueue = host.GetService<DispatcherQueue>();
_loginUiContent = new Frame();
_setupFlowOrchestrator = setupFlowOrchestrator;

_previouslySelectedRepos = previouslySelectedRepos ?? new List<CloningInformation>();
EverythingToClone = new List<CloningInformation>(_previouslySelectedRepos);
_activityId = activityId;
FolderPickerViewModel = new FolderPickerViewModel(stringResource, setupFlowOrchestrator);
EditDevDriveViewModel = new EditDevDriveViewModel(devDriveManager, setupFlowOrchestrator);

EditDevDriveViewModel.DevDriveClonePathUpdated += (_, updatedDevDriveRootPath) =>
{
FolderPickerViewModel.CloneLocationAlias = EditDevDriveViewModel.GetDriveDisplayName(DevDriveDisplayNameKind.FormattedDriveLabelKind);
FolderPickerViewModel.CloneLocation = updatedDevDriveRootPath;
};

ChangeToUrlPage();

// override changes ChangeToUrlPage to correctly set the state.
UrlParsingError = string.Empty;
ShouldShowUrlError = false;
ShowErrorTextBox = false;
ShouldShowNoRepoMessage = false;
_accountIndex = -1;
}

/// <summary>
/// Update dialog to show Dev Drive information.
/// </summary>
public void UpdateDevDriveInfo()
{
EditDevDriveViewModel.MakeDefaultDevDrive();
FolderPickerViewModel.DisableBrowseButton();
_addRepoDialog.OldCloneLocation = FolderPickerViewModel.CloneLocation;
FolderPickerViewModel.CloneLocation = EditDevDriveViewModel.GetDriveDisplayName();
FolderPickerViewModel.CloneLocationAlias = EditDevDriveViewModel.GetDriveDisplayName(DevDriveDisplayNameKind.FormattedDriveLabelKind);
FolderPickerViewModel.InDevDriveScenario = true;
EditDevDriveViewModel.IsDevDriveCheckboxChecked = true;
}

/// <summary>
/// Uses search inputs to search for repos.
/// </summary>
private void SearchRepos()
{
_dispatcherQueue.TryEnqueue(async () =>
{
await SearchForRepos(_selectedRepoProvider, SelectedAccount);
var sdkDisplayName = _providers.GetSDKProvider(_selectedRepoProvider).DisplayName;
_addRepoDialog.SelectRepositories(SetRepositories(sdkDisplayName, SelectedAccount));
});
}

/// <summary>
/// Filters all repos down to any that start with text.
/// A side-effect of filtering is that SelectionChanged fires for every selected repo but only on removal.
Expand Down Expand Up @@ -717,44 +755,6 @@ private MenuFlyout ConstructFlyout()
return newMenu;
}

public AddRepoViewModel(
SetupFlowOrchestrator setupFlowOrchestrator,
ISetupFlowStringResource stringResource,
List<CloningInformation> previouslySelectedRepos,
IHost host,
Guid activityId,
AddRepoDialog addRepoDialog,
IDevDriveManager devDriveManager)
{
_addRepoDialog = addRepoDialog;
_stringResource = stringResource;
_host = host;
_dispatcherQueue = host.GetService<DispatcherQueue>();
_loginUiContent = new Frame();
_setupFlowOrchestrator = setupFlowOrchestrator;

_previouslySelectedRepos = previouslySelectedRepos ?? new List<CloningInformation>();
EverythingToClone = new List<CloningInformation>(_previouslySelectedRepos);
_activityId = activityId;
FolderPickerViewModel = new FolderPickerViewModel(stringResource, setupFlowOrchestrator);
EditDevDriveViewModel = new EditDevDriveViewModel(devDriveManager, setupFlowOrchestrator);

EditDevDriveViewModel.DevDriveClonePathUpdated += (_, updatedDevDriveRootPath) =>
{
FolderPickerViewModel.CloneLocationAlias = EditDevDriveViewModel.GetDriveDisplayName(DevDriveDisplayNameKind.FormattedDriveLabelKind);
FolderPickerViewModel.CloneLocation = updatedDevDriveRootPath;
};

ChangeToUrlPage();

// override changes ChangeToUrlPage to correctly set the state.
UrlParsingError = string.Empty;
ShouldShowUrlError = false;
ShowErrorTextBox = false;
ShouldShowNoRepoMessage = false;
_accountIndex = -1;
}

/// <summary>
/// Handles logic when the primary button is clicked. Actions change depending on the screen
/// then user is on.
Expand Down
4 changes: 2 additions & 2 deletions tools/SetupFlow/DevHome.SetupFlow/Views/LoadingView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
SelectionMode="Single">
<ListView.ItemTemplate>
<DataTemplate x:DataType="viewmodels:LoadingMessageViewModel">
<Grid ColumnSpacing="5">
<Grid AutomationProperties.Name="{x:Bind MessageToShow}" ColumnSpacing="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource SymbolAndProgressRingColumnWidth}" />
<ColumnDefinition Width="*" />
Expand All @@ -212,7 +212,7 @@
SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate x:DataType="viewmodels:LoadingMessageViewModel">
<Grid ColumnSpacing="5">
<Grid AutomationProperties.Name="{x:Bind MessageToShow}" ColumnSpacing="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource SymbolAndProgressRingColumnWidth}" />
<ColumnDefinition Width="*" />
Expand Down

0 comments on commit 76eb695

Please sign in to comment.