-
Notifications
You must be signed in to change notification settings - Fork 337
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
Changes from 2 commits
6058ab8
1a0d87f
aa482b9
f162c12
a1a730a
54fd0cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,8 @@ | |
using System.Threading.Tasks; | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.Input; | ||
using CommunityToolkit.WinUI.Collections; | ||
using DevHome.Common.Models; | ||
using DevHome.Common.Services; | ||
using DevHome.Customization.Models.Environments; | ||
using DevHome.Customization.ViewModels.Environments; | ||
using DevHome.Customization.Views; | ||
using DevHome.SetupFlow.Services; | ||
|
@@ -21,7 +19,7 @@ | |
|
||
namespace DevHome.Customization.ViewModels; | ||
|
||
public partial class DevDriveInsightsViewModel : SetupPageViewModelBase | ||
public partial class DevDriveInsightsViewModel : ObservableObject | ||
{ | ||
private readonly Microsoft.UI.Dispatching.DispatcherQueue _dispatcher; | ||
|
||
|
@@ -31,6 +29,8 @@ public partial class DevDriveInsightsViewModel : SetupPageViewModelBase | |
|
||
public ObservableCollection<DevDriveOptimizedCardViewModel> DevDriveOptimizedCardCollection { get; private set; } = new(); | ||
|
||
private readonly OptimizeDevDriveDialogViewModelFactory _optimizeDevDriveDialogViewModelFactory; | ||
|
||
[ObservableProperty] | ||
private bool _shouldShowCollectionView; | ||
|
||
|
@@ -53,50 +53,19 @@ public partial class DevDriveInsightsViewModel : SetupPageViewModelBase | |
|
||
private IEnumerable<IDevDrive> ExistingDevDrives { get; set; } = Enumerable.Empty<IDevDrive>(); | ||
|
||
public DevDriveInsightsViewModel( | ||
ISetupFlowStringResource stringResource, | ||
SetupFlowViewModel setupflowModel, | ||
SetupFlowOrchestrator orchestrator, | ||
IDevDriveManager devDriveManager, | ||
ToastNotificationService toastNotificationService) | ||
: base(stringResource, orchestrator) | ||
public DevDriveInsightsViewModel(IDevDriveManager devDriveManager, OptimizeDevDriveDialogViewModelFactory optimizeDevDriveDialogViewModelFactory) | ||
{ | ||
_optimizeDevDriveDialogViewModelFactory = optimizeDevDriveDialogViewModelFactory; | ||
_dispatcher = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread(); | ||
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. If this isn't running on the UI thread, this will return null. Use WindowEx instead. 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. Running on UI thread. 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. 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. |
||
DevDriveManagerObj = devDriveManager; | ||
|
||
_ = this.OnFirstNavigateToAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Compares two strings and returns true if they are equal. This method is case insensitive. | ||
/// </summary> | ||
/// <param name="text">First string to use in comparison</param> | ||
/// <param name="text2">Second string to use in comparison</param> | ||
private bool CompareStrings(string text, string text2) | ||
{ | ||
return string.Equals(text, text2, StringComparison.OrdinalIgnoreCase); | ||
} | ||
|
||
public bool CanEnableSyncButton() | ||
{ | ||
return DevDriveLoadingCompleted; | ||
} | ||
|
||
[RelayCommand(CanExecute = nameof(CanEnableSyncButton))] | ||
public void SyncDevDrives() | ||
{ | ||
GetDevDrives(); | ||
} | ||
|
||
/// <summary> | ||
/// Make sure we only get the list of DevDrives from the DevDriveManager once when the page is first navigated to. | ||
/// All other times will be through the use of the sync button. | ||
/// </summary> | ||
protected async override Task OnFirstNavigateToAsync() | ||
public void OnFirstNavigateTo() | ||
{ | ||
// Do nothing, but we need to override this as the base expects a task to be returned. | ||
await Task.CompletedTask; | ||
|
||
GetDevDrives(); | ||
GetDevDriveOptimizers(); | ||
GetDevDriveOptimizeds(); | ||
|
@@ -306,6 +275,7 @@ public void UpdateOptimizerListViewModelList() | |
if (existingPipCacheLocation != null && !CacheInDevDrive(existingPipCacheLocation)) | ||
{ | ||
var card = new DevDriveOptimizerCardViewModel( | ||
_optimizeDevDriveDialogViewModelFactory, | ||
"Pip cache (Python)", | ||
existingPipCacheLocation, | ||
"D:\\packages" + cacheSubDir /*example location on dev drive to move cache to*/, | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ namespace DevHome.Customization.ViewModels.Environments; | |
/// </summary> | ||
public partial class DevDriveOptimizerCardViewModel : ObservableObject | ||
{ | ||
public OptimizeDevDriveDialogViewModelFactory OptimizeDevDriveDialogViewModelFactory { get; set; } | ||
|
||
public string CacheToBeMoved { get; set; } | ||
|
||
public string DevDriveOptimizationSuggestion { get; set; } | ||
|
@@ -37,15 +39,17 @@ private async Task OptimizeDevDriveAsync(object sender) | |
var settingsCard = sender as Button; | ||
if (settingsCard != null) | ||
{ | ||
var optimizeDevDriveDialog = new OptimizeDevDriveDialog(CacheToBeMoved, ExistingCacheLocation, EnvironmentVariableToBeSet); | ||
var optimizeDevDriveViewModel = OptimizeDevDriveDialogViewModelFactory(ExistingCacheLocation, EnvironmentVariableToBeSet); | ||
var optimizeDevDriveDialog = new OptimizeDevDriveDialog(optimizeDevDriveViewModel); | ||
optimizeDevDriveDialog.XamlRoot = settingsCard.XamlRoot; | ||
optimizeDevDriveDialog.RequestedTheme = settingsCard.ActualTheme; | ||
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. 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 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. Without this, I see light theme dialog pop up for a dark themed app. 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. 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. 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. 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. |
||
await optimizeDevDriveDialog.ShowAsync(); | ||
} | ||
} | ||
|
||
public DevDriveOptimizerCardViewModel(string cacheToBeMoved, string existingCacheLocation, string exampleLocationOnDevDrive, string environmentVariableToBeSet) | ||
public DevDriveOptimizerCardViewModel(OptimizeDevDriveDialogViewModelFactory optimizeDevDriveDialogViewModelFactory, string cacheToBeMoved, string existingCacheLocation, string exampleLocationOnDevDrive, string environmentVariableToBeSet) | ||
{ | ||
OptimizeDevDriveDialogViewModelFactory = optimizeDevDriveDialogViewModelFactory; | ||
CacheToBeMoved = cacheToBeMoved; | ||
ExistingCacheLocation = existingCacheLocation; | ||
ExampleLocationOnDevDrive = exampleLocationOnDevDrive; | ||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks.