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

Dev drive insights and pip cache move rebased to changes from main #2486

Merged
merged 6 commits into from
Apr 1, 2024

Conversation

SohamDas2021
Copy link
Contributor

Summary of the pull request

Windows customization root page:
WindowsCustomization

Dev Drive Insights: Listing the dev drives and the Pip cache optimizer card.
DevDriveInsights

Folder picker content dialog to move the cache to dev drive location:
MakeTheDir

User inputs directory on dev drive:
DirChosen

Pip cache optimized card.
DevDriveOptimized
Currently the app needs to be relaunched for reflecting the change.

References and relevant issues

Detailed description of the pull request / Additional comments

Added Dev Drive Insights. User can move pip cache from non dev drive location to the dev drive for optimized performance.

Validation steps performed

pip install works after the change.

PR checklist

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

DevDriveSize = devDrive.DriveSizeInBytes / divider;
DevDriveFreeSize = devDrive.DriveSizeRemainingInBytes / divider;
DevDriveUsedSize = DevDriveSize - DevDriveFreeSize;
DevDriveUnitOfMeasure = (devDrive.DriveUnitOfMeasure == ByteUnit.TB) ? "TB" : "GB";
Copy link
Collaborator

@krschau krschau Mar 29, 2024

Choose a reason for hiding this comment

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

These probably have to be localized. #WontFix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are units of data. Do we localize these elsewhere?

{
var optimizeDevDriveDialog = new OptimizeDevDriveDialog(CacheToBeMoved, ExistingCacheLocation, EnvironmentVariableToBeSet);
optimizeDevDriveDialog.XamlRoot = settingsCard.XamlRoot;
optimizeDevDriveDialog.RequestedTheme = settingsCard.ActualTheme;
Copy link
Collaborator

@krschau krschau Mar 29, 2024

Choose a reason for hiding this comment

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

I don't think you want to do this -- it will use the right theme without it, and if the RequestedTheme is Default, then this will cause a bug when the System theme is changed. For example, if RequestedTheme is Default and ActualTheme is Dark, but then you set the system theme to Light, the theme of the dialog will stay Dark #Pending

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this, I see light theme dialog pop up for a dark themed app.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it make a difference if you include the Style on the dialog like I mentioned below? There should be a way we can remove this.

Copy link
Contributor Author

@SohamDas2021 SohamDas2021 Apr 1, 2024

Choose a reason for hiding this comment

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

I have the following:

Style="{StaticResource DefaultContentDialogStyle}" in the dialog.

That is not making any difference- still seeing light theme dialog with dark theme app without setting the RequestedTheme, if that is what you are referring to.

behaviors:NavigationViewHeaderBehavior.HeaderMode="Never"
mc:Ignorable="d">

<Grid MaxWidth="{ThemeResource MaxPageContentWidth}" Margin="{ThemeResource ContentPageMargin}">
Copy link
Collaborator

@krschau krschau Mar 29, 2024

Choose a reason for hiding this comment

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

This page as it currently is will have this bug: #566 #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am guessing removing the BreadcrumbBar will take care of this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not quite -- you'll have to have a ScrollViewer fill the width, then set the MaxWidth and Margin on whatever's inside the encompassing ScrollViewer.

ItemsSource="{x:Bind Breadcrumbs}" />

<ScrollView Grid.Row="1" VerticalAlignment="Top">
<views:DevDriveInsightsView />
Copy link
Collaborator

@krschau krschau Mar 29, 2024

Choose a reason for hiding this comment

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

Will there be other views that this might contain in the future? Why separate the page and view? #ByDesign

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes there could be other views to be contained here in future.

OptimizeDevDriveDialogDescription = stringResource.GetLocalized("OptimizeDevDriveDialogDescription", ExistingCacheLocation, EnvironmentVariableToBeSet);
}

public string CacheToBeMoved
Copy link
Collaborator

@krschau krschau Mar 29, 2024

Choose a reason for hiding this comment

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

As Branden mentioned elsewhere, these DPs should all just be ObservableProperties. #Resolved

@@ -117,6 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ChooseDirectoryPromptText" xml:space="preserve">
<value>Choose directory on dev drive...</value>
Copy link
Collaborator

@krschau krschau Apr 1, 2024

Choose a reason for hiding this comment

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

Dev Drive should be capitalized, I believe. (Applies to all instances on this page)

Suggested change
<value>Choose directory on dev drive...</value>
<value>Choose directory on Dev Drive...</value>
``` #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is what it says in the Figma.

Copy link
Contributor

Choose a reason for hiding this comment

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

actually @SohamDas2021 it should be like Kristen outlined, If I recall, it was from Marketing who said that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So capitalize all Dev Drive in the text?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks.

private async Task BrowseButtonClick(object sender)
{
// Create a folder picker dialog
var folderPicker = new FolderPicker
Copy link
Collaborator

@krschau krschau Apr 1, 2024

Choose a reason for hiding this comment

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

Should this be using @AmelBawa-msft 's new Picker APIs? If this is ever launched from admin, it definitely should. #Resolved

Copy link
Contributor Author

@SohamDas2021 SohamDas2021 Apr 1, 2024

Choose a reason for hiding this comment

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

I have noted this down as a suggestion and will do it as a bug fix later. Will be opening issue to track this. Trying to complete this today.

private string _exampleDevDriveLocation;

[ObservableProperty]
private string _chooseDirectoryPromptText;
Copy link
Collaborator

@krschau krschau Apr 1, 2024

Choose a reason for hiding this comment

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

Rather than saving all these strings in the ViewModel, you should reference them from the xaml markup directly. See https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/mrtcore/localize-strings#refer-to-a-string-resource-identifier-from-xaml #WontFix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Many of these strings have dynamic bindings-
Contents of {0} will be copied to chosen directory. And {1} will be set to chosen directory.

Can't seem to find a way of doing this through the xaml. Won't fixing for now. Keeping a note and will be opening an issue to track.

@@ -24,6 +24,8 @@

<ItemGroup>
<ProjectReference Include="..\..\..\common\DevHome.Common.csproj" />
<ProjectReference Include="..\..\SetupFlow\DevHome.SetupFlow.Common\DevHome.SetupFlow.Common.csproj" />
Copy link
Collaborator

@krschau krschau Apr 1, 2024

Choose a reason for hiding this comment

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

Would be great if you could add the DevHome.Customization project to the mermaid diagram of project relationships in https://github.com/microsoft/devhome/blob/main/docs/architecture.md #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

public DevDriveInsightsViewModel(IDevDriveManager devDriveManager, OptimizeDevDriveDialogViewModelFactory optimizeDevDriveDialogViewModelFactory)
{
_optimizeDevDriveDialogViewModelFactory = optimizeDevDriveDialogViewModelFactory;
_dispatcher = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
Copy link
Collaborator

@krschau krschau Apr 1, 2024

Choose a reason for hiding this comment

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

If this isn't running on the UI thread, this will return null. Use WindowEx instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Running on UI thread.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It isn't guaranteed that this will run on the UI thread every time. I can forward you the internal thread I started about this. This can return null and will result in a crash.

xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:ctControls="using:CommunityToolkit.WinUI.Controls"
mc:Ignorable="d"
Loaded="UserControl_Loaded">
Copy link
Collaborator

@krschau krschau Apr 1, 2024

Choose a reason for hiding this comment

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

You should bind this to a RelayCommand directly on the ViewModel, so that you don't need the intermediate event handler on the View. It will also prevent any concurrency issues if a user were to switch between pages really quickly. #WontFix

<StackPanel>
<TextBlock Text="{x:Bind ViewModel.OptimizeDevDriveDialogDescription}" TextWrapping="Wrap"/>
<Grid Margin="0 10 0 0">
<TextBox HorizontalAlignment="Left" Width="300" Grid.Column="0" x:Name="DirectoryPathTextBox" PlaceholderText="Choose a directory" Text="{x:Bind ViewModel.DirectoryPathTextBox , Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
Copy link
Collaborator

@krschau krschau Apr 1, 2024

Choose a reason for hiding this comment

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

Suggest using MinWidth, so that it can scale up in size if text scale is turned up (preventing accessibility bug) #Resolved

xmlns:d="https://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="https://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="using:DevHome.Customization.Views"
behaviors:NavigationViewHeaderBehavior.HeaderMode="Always"
Copy link
Contributor

@nieubank nieubank Apr 1, 2024

Choose a reason for hiding this comment

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

Always

You add the breadcrumb logic now -

see #2501 #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will do it as a separate PR once I check this in.

Copy link
Contributor

@bbonaby bbonaby left a comment

Choose a reason for hiding this comment

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

Thanks for working on this and getting it into its current state. I don't think I've seen anything that would block the check in

<comment>Dev drive size free</comment>
</data>
<data name="DevDriveInsightsCard.Description" xml:space="preserve">
<value>All things, dev drives, optimizations, etc.</value>
Copy link
Contributor

@bbonaby bbonaby Apr 1, 2024

Choose a reason for hiding this comment

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

Missed this one, but will let you update it in another PR #Resolved

if (directoryPath != null)
{
// Handle the selected folder
// TODO: If chosen folder not a dev drive location, currently we no-op. Instead we should display the error.
Copy link
Contributor

@bbonaby bbonaby Apr 1, 2024

Choose a reason for hiding this comment

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

Do we have an issue on GitHub for this? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yet to create the issues, will do.

@SohamDas2021
Copy link
Contributor Author

Thanks for approving.


In reply to: 1972049143

@SohamDas2021 SohamDas2021 changed the base branch from microsoftfeature/dev-drive-insights-new to main April 1, 2024 20:32
@kanismohammed kanismohammed self-requested a review April 1, 2024 20:36
Copy link
Contributor

@nieubank nieubank left a comment

Choose a reason for hiding this comment

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

:shipit:

@SohamDas2021 SohamDas2021 merged commit f4e9a64 into main Apr 1, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants