Skip to content

Commit

Permalink
Machine config list navigation, and repo config names. (#3119)
Browse files Browse the repository at this point in the history
* Intial proof working

* Removing tab stops

* Adding comments

* Narrator says the correct name in the repo config screen

* Adding comments

* Moving some DevDrive code to the view model.

* Correct indentation
  • Loading branch information
dhoehna authored Jun 5, 2024
1 parent cdcbca4 commit 9ad8dd9
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ public string EditClonePathAutomationName
get; set;
}

/// <summary>
/// Gets or sets the string that the narrator should say when the repo is selected in the config screen.
/// </summary>
public string RepoConfigAutomationName
{
get; set;
}

/// <summary>
/// Gets or sets the name of the button that allows a user to remove the repository from being cloned.
/// This name can't be static because each button name needs to be unique. Because each name needs to be unique
Expand Down
39 changes: 39 additions & 0 deletions tools/SetupFlow/DevHome.SetupFlow/ViewModels/AddRepoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,44 @@ private void RepoProviderSelected(string repositoryProviderName)
_selectedRepoProvider = repositoryProviderName;
}

/// <summary>
/// Adds or removes the default dev drive. This dev drive will be made at the loading screen.
/// </summary>
[RelayCommand]
private void MakeNewDevDrive(bool isCheckBoxChecked)
{
// Getting here means
// 1. The user does not have any existing dev drives
// 2. The user wants to clone to a new dev drive.
// 3. The user un-checked this and does not want a new dev drive.
if (isCheckBoxChecked)
{
UpdateDevDriveInfo();
}
else
{
FolderPickerViewModel.CloneLocationAlias = string.Empty;
FolderPickerViewModel.InDevDriveScenario = false;
EditDevDriveViewModel.RemoveNewDevDrive();
FolderPickerViewModel.EnableBrowseButton();
FolderPickerViewModel.CloneLocation = _addRepoDialog.OldCloneLocation;
}
}

/// <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()
{
Expand Down Expand Up @@ -1066,6 +1104,7 @@ public void AddOrRemoveRepository(string accountName, IList<object> repositories
cloningInformation.OwningAccount = developerId;
cloningInformation.EditClonePathAutomationName = _stringResource.GetLocalized(StringResourceKey.RepoPageEditClonePathAutomationProperties, Path.Join(_selectedRepoProvider, repositoryToAdd.RepoDisplayName));
cloningInformation.RemoveFromCloningAutomationName = _stringResource.GetLocalized(StringResourceKey.RepoPageRemoveRepoAutomationProperties, Path.Join(_selectedRepoProvider, repositoryToAdd.RepoDisplayName));
cloningInformation.RepoConfigAutomationName = Path.Join(_providers.DisplayName(_selectedRepoProvider), repositoryToAdd.RepoDisplayName);
EverythingToClone.Add(cloningInformation);
}
}
Expand Down
18 changes: 15 additions & 3 deletions tools/SetupFlow/DevHome.SetupFlow/Views/AddRepoDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,13 @@
into the command. I tried converting this to use a command on SelectionChanged and pass SelectedItems into the command.
I ran into issues because the viewmodel expects one repository at a time. Not a list.
Another issue is .SelectRange() needs to be called to "select" repos when the dialog is opened more than once. -->
<ListView x:Name="RepositoriesListView" Visibility="{x:Bind AddRepoViewModel.IsFetchingRepos, Mode=OneWay, Converter={StaticResource NegatedBoolToVisibilityConverter}}" SelectionMode="Multiple" Height="300" HorizontalAlignment="Stretch" SelectionChanged="RepositoriesListView_SelectionChanged" ItemsSource="{x:Bind AddRepoViewModel.RepositoriesToDisplay, Mode=OneWay}">
<ListView x:Name="RepositoriesListView"
Visibility="{x:Bind AddRepoViewModel.IsFetchingRepos, Mode=OneWay, Converter={StaticResource NegatedBoolToVisibilityConverter}}"
SelectionMode="Multiple"
Height="300"
HorizontalAlignment="Stretch"
SelectionChanged="RepositoriesListView_SelectionChanged"
ItemsSource="{x:Bind AddRepoViewModel.RepositoriesToDisplay, Mode=OneWay}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="models:RepoViewListItem">
<Grid ColumnSpacing="7" AutomationProperties.Name="{x:Bind RepoDisplayName}">
Expand Down Expand Up @@ -276,12 +282,18 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<CheckBox
Click="MakeNewDevDriveCheckBox_Click"
IsEnabled="{x:Bind AddRepoViewModel.EditDevDriveViewModel.IsDevDriveCheckboxEnabled}"
IsChecked="{x:Bind AddRepoViewModel.EditDevDriveViewModel.IsDevDriveCheckboxChecked, Mode=TwoWay}"
Grid.Column="0"
Grid.Row="0"
x:Uid="NewDevDriveComboBox"/>
x:Uid="NewDevDriveComboBox"
x:Name="NewDevDriveComboBox">
<i:Interaction.Behaviors>
<ic:EventTriggerBehavior EventName="Click">
<ic:InvokeCommandAction Command="{x:Bind AddRepoViewModel.MakeNewDevDriveCommand}" CommandParameter="{x:Bind NewDevDriveComboBox.IsChecked, Mode=OneWay}"/>
</ic:EventTriggerBehavior>
</i:Interaction.Behaviors>
</CheckBox>
<HyperlinkButton
x:Uid="CustomizeHyperLink"
Grid.Column="1"
Expand Down
42 changes: 2 additions & 40 deletions tools/SetupFlow/DevHome.SetupFlow/Views/AddRepoDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public AddRepoViewModel AddRepoViewModel
public SetupFlowOrchestrator Orchestrator { get; set; }

/// <summary>
/// Hold the clone location in case the user decides not to add a dev drive.
/// Gets or sets the clone location in case the user decides not to add a dev drive.
/// </summary>
private string _oldCloneLocation;
public string OldCloneLocation { get; set; }

public AddRepoDialog(
SetupFlowOrchestrator setupFlowOrchestrator,
Expand Down Expand Up @@ -222,30 +222,6 @@ private async void AddRepoContentDialog_PrimaryButtonClick(ContentDialog sender,
}
}

/// <summary>
/// Adds or removes the default dev drive. This dev drive will be made at the loading screen.
/// </summary>
private void MakeNewDevDriveCheckBox_Click(object sender, RoutedEventArgs e)
{
// Getting here means
// 1. The user does not have any existing dev drives
// 2. The user wants to clone to a new dev drive.
// 3. The user un-checked this and does not want a new dev drive.
var isChecked = (sender as CheckBox).IsChecked;
if (isChecked.Value)
{
UpdateDevDriveInfo();
}
else
{
AddRepoViewModel.FolderPickerViewModel.CloneLocationAlias = string.Empty;
AddRepoViewModel.FolderPickerViewModel.InDevDriveScenario = false;
AddRepoViewModel.EditDevDriveViewModel.RemoveNewDevDrive();
AddRepoViewModel.FolderPickerViewModel.EnableBrowseButton();
AddRepoViewModel.FolderPickerViewModel.CloneLocation = _oldCloneLocation;
}
}

/// <summary>
/// Putting the event in the view so SelectRange can be called.
/// SelectRange needs a reference to the ListView.
Expand All @@ -262,20 +238,6 @@ private void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e)
}
}

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

private void FilterSuggestions(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{
sender.ItemsSource = _searchFieldsAndValues[sender.Header.ToString()].Where(x => x.Contains(sender.Text));
Expand Down
Loading

0 comments on commit 9ad8dd9

Please sign in to comment.