Skip to content

Commit

Permalink
Merge pull request #2695 from microsoft/main
Browse files Browse the repository at this point in the history
Staging - 4/18/24
  • Loading branch information
EricJohnson327 authored Apr 18, 2024
2 parents e400d2a + ccc9498 commit 18ff42e
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@
<comment>Dev drive size free</comment>
</data>
<data name="DevDriveInsightsCard.Description" xml:space="preserve">
<value>All things, Dev Drives, optimizations, etc.</value>
<value>All things Dev Drive, optimizations, etc.</value>
<comment>The description for the Dev Drive Insights settings card</comment>
</data>
<data name="DevDriveInsightsCard.Header" xml:space="preserve">
<value>Dev Drive Insights</value>
<value>Dev Drive insights</value>
<comment>The header for the Dev Drive Insights settings card</comment>
</data>
<data name="DevDriveInsights_Header" xml:space="preserve">
<value>Dev Drive Insights</value>
<value>Dev Drive insights</value>
<comment>Header for Dev Drive insights page in the breadcrumb bar</comment>
</data>
<data name="DevDriveSizeText" xml:space="preserve">
Expand Down Expand Up @@ -201,6 +201,10 @@
<value>Global environment variable {0} is set to {1}, which is not located on Dev Drive. Move contents of this folder to a directory on Dev Drive such as {2} and set {3} to that chosen directory on Dev Drive</value>
<comment>Optimizer dev drive description</comment>
</data>
<data name="OptimizerDevDriveDescriptionWithEnvVarNotSet" xml:space="preserve">
<value>Move contents of {0} to a directory on Dev Drive such as {1} and set {2} to that chosen directory on Dev Drive</value>
<comment>Optimizer dev drive description when environment variable is not set</comment>
</data>
<data name="SettingsAutoSuggestBox.PlaceholderText" xml:space="preserve">
<value>Search</value>
<comment>The placholder text for the settings auto suggest box</comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public DevDriveOptimizerCardViewModel(
string existingCacheLocation,
string exampleLocationOnDevDrive,
string environmentVariableToBeSet,
List<string> existingDevDriveLetters)
List<string> existingDevDriveLetters,
bool environmentVariableHasValue)
{
OptimizeDevDriveDialogViewModelFactory = optimizeDevDriveDialogViewModelFactory;
ExistingDevDriveLetters = existingDevDriveLetters;
Expand All @@ -71,7 +72,16 @@ public DevDriveOptimizerCardViewModel(
ExampleLocationOnDevDrive = exampleLocationOnDevDrive;
EnvironmentVariableToBeSet = environmentVariableToBeSet;
var stringResource = new StringResource("DevHome.Customization.pri", "DevHome.Customization/Resources");
OptimizerDevDriveDescription = stringResource.GetLocalized("OptimizerDevDriveDescription", EnvironmentVariableToBeSet, ExistingCacheLocation, ExampleLocationOnDevDrive, EnvironmentVariableToBeSet);

if (environmentVariableHasValue)
{
OptimizerDevDriveDescription = stringResource.GetLocalized("OptimizerDevDriveDescription", EnvironmentVariableToBeSet, ExistingCacheLocation, ExampleLocationOnDevDrive, EnvironmentVariableToBeSet);
}
else
{
OptimizerDevDriveDescription = stringResource.GetLocalized("OptimizerDevDriveDescriptionWithEnvVarNotSet", ExistingCacheLocation, ExampleLocationOnDevDrive, EnvironmentVariableToBeSet);
}

MakeTheChangeText = stringResource.GetLocalized("MakeTheChangeText");
DevDriveOptimizationSuggestion = stringResource.GetLocalized("DevDriveOptimizationSuggestion");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,11 @@ public void UpdateListViewModelList()
var matchingSubdirectory = subDirectories.FirstOrDefault(subdir => subdir.StartsWith(cacheDirectory, StringComparison.OrdinalIgnoreCase));
if (Directory.Exists(matchingSubdirectory))
{
if (matchingSubdirectory.Contains("PythonSoftwareFoundation"))
var actualCacheDirectory = Path.Join(matchingSubdirectory, "LocalCache", "Local", "pip", CacheStr);
if (matchingSubdirectory.Contains("PythonSoftwareFoundation") && Directory.Exists(actualCacheDirectory))
{
return Path.Join(matchingSubdirectory, "LocalCache", "Local", "pip", CacheStr);
return actualCacheDirectory;
}

return matchingSubdirectory;
}
}
}
Expand Down Expand Up @@ -381,7 +380,8 @@ public void UpdateOptimizerListViewModelList()
existingCacheLocation,
exampleDirectory!, // example location on dev drive to move cache to
cache.EnvironmentVariable!, // environmentVariableToBeSet
existingDevDriveLetters);
existingDevDriveLetters,
!string.IsNullOrEmpty(environmentVariablePath));
DevDriveOptimizerCardCollection.Add(card);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<ScrollView VerticalAlignment="Top">
<Grid MaxWidth="{ThemeResource MaxPageContentWidth}" Margin="{ThemeResource ContentPageMargin}">
<views:DevDriveInsightsView />
</Grid>
</Grid>
</ScrollView>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

<!--- Template for dev drive horizontal cards on the dev insights page. -->
<DataTemplate x:Key="HorizontalCardForDevDriveInsightsPage" x:DataType="devViewModels:DevDriveCardViewModel">
<ctControls:SettingsExpander Header="{Binding DevDriveLabel, Mode=OneWay}">
<ctControls:SettingsExpander.HeaderIcon>
<ctControls:SettingsCard Header="{Binding DevDriveLabel, Mode=OneWay}">
<ctControls:SettingsCard.HeaderIcon>
<FontIcon Glyph="&#xEDA2;" FontSize="25" FontFamily="{ThemeResource AmcFluentIcons}"/>
</ctControls:SettingsExpander.HeaderIcon>
</ctControls:SettingsCard.HeaderIcon>
<Grid Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand All @@ -39,15 +39,15 @@
</TextBlock>
<ProgressBar Grid.Row="1" Width="200" Value="{x:Bind DevDriveFillPercentage, Mode=OneWay}" HorizontalAlignment="Right" />
<Grid Grid.Row="2">
<TextBlock Style="{StaticResource CardBodyStackPanelAltTextBlockStyle}" HorizontalAlignment="Right" Margin="0 0 120 0">
<TextBlock Style="{StaticResource CardBodyStackPanelAltTextBlockStyle}" HorizontalAlignment="Right" Margin="0 0 120 0">
<Run Text="{Binding Path=DevDriveUsedSizeText, Mode=OneWay}" />
</TextBlock>
<TextBlock Style="{StaticResource CardBodyStackPanelAltTextBlockStyle}" HorizontalAlignment="Right">
<TextBlock Style="{StaticResource CardBodyStackPanelAltTextBlockStyle}" HorizontalAlignment="Right">
<Run Text="{Binding Path=DevDriveFreeSizeText, Mode=OneWay}" />
</TextBlock>
</Grid>
</Grid>
</ctControls:SettingsExpander>
</ctControls:SettingsCard>
</DataTemplate>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,34 @@ namespace DevHome.Dashboard.Services;

public interface IWidgetHostingService
{
/// <summary>Get the list of current widgets from the WidgetService.</summary>
/// <returns>A list of widgets, or empty list if there were no widgets or the list could not be retrieved.</returns>
public Task<Widget[]> GetWidgetsAsync();

/// <summary>Gets the widget with the given ID.</summary>
/// <returns>The widget, or null if one could not be retrieved.</returns>
public Task<Widget> GetWidgetAsync(string widgetId);

/// <summary>Create and return a new widget.</summary>
/// <returns>The new widget, or null if one could not be created.</returns>
public Task<Widget> CreateWidgetAsync(string widgetDefinitionId, WidgetSize widgetSize);

/// <summary>Get the catalog of widgets from the WidgetService.</summary>
/// <returns>The catalog of widgets, or null if one could not be created.</returns>
public Task<WidgetCatalog> GetWidgetCatalogAsync();

/// <summary>Get the list of WidgetProviderDefinitions from the WidgetService.</summary>
/// <returns>A list of WidgetProviderDefinitions, or an empty list if there were no widgets
/// or the list could not be retrieved.</returns>
public Task<WidgetProviderDefinition[]> GetProviderDefinitionsAsync();

/// <summary>Get the list of WidgetDefinitions from the WidgetService.</summary>
/// <returns>A list of WidgetDefinitions, or an empty list if there were no widgets
/// or the list could not be retrieved.</returns>
public Task<WidgetDefinition[]> GetWidgetDefinitionsAsync();

/// <summary>Get the WidgetDefinition for the given WidgetDefinitionId from the WidgetService.</summary>
/// <returns>The WidgetDefinition, or null if the widget definition could not be found
/// or there was an error retrieving it.</returns>
public Task<WidgetDefinition> GetWidgetDefinitionAsync(string widgetDefinitionId);
}
40 changes: 9 additions & 31 deletions tools/Dashboard/DevHome.Dashboard/Services/WidgetHostingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ public class WidgetHostingService : IWidgetHostingService

private const int MaxAttempts = 3;

/// <summary>
/// Get the list of current widgets from the WidgetService.
/// </summary>
/// <returns>A list of widgets, or null if there were no widgets or the list could not be retrieved.</returns>
/// <inheritdoc />
public async Task<Widget[]> GetWidgetsAsync()
{
var attempt = 0;
Expand All @@ -35,7 +32,7 @@ public async Task<Widget[]> GetWidgetsAsync()
try
{
_widgetHost ??= await Task.Run(() => WidgetHost.Register(new WidgetHostContext("BAA93438-9B07-4554-AD09-7ACCD7D4F031")));
return await Task.Run(() => _widgetHost.GetWidgets());
return await Task.Run(() => _widgetHost.GetWidgets()) ?? [];
}
catch (COMException ex) when (ex.HResult == RpcServerUnavailable || ex.HResult == RpcCallFailed)
{
Expand All @@ -52,11 +49,10 @@ public async Task<Widget[]> GetWidgetsAsync()
}
}

return null;
return [];
}

/// <summary>Gets the widget with the given ID.</summary>
/// <returns>The widget, or null if one could not be retrieved.</returns>
/// <inheritdoc />
public async Task<Widget> GetWidgetAsync(string widgetId)
{
var attempt = 0;
Expand All @@ -83,10 +79,7 @@ public async Task<Widget> GetWidgetAsync(string widgetId)
return null;
}

/// <summary>
/// Create and return a new widget.
/// </summary>
/// <returns>The new widget, or null if one could not be created.</returns>
/// <inheritdoc />
public async Task<Widget> CreateWidgetAsync(string widgetDefinitionId, WidgetSize widgetSize)
{
var attempt = 0;
Expand All @@ -113,10 +106,7 @@ public async Task<Widget> CreateWidgetAsync(string widgetDefinitionId, WidgetSiz
return null;
}

/// <summary>
/// Get the catalog of widgets from the WidgetService.
/// </summary>
/// <returns>The catalog of widgets, or null if one could not be created.</returns>
/// <inheritdoc />
public async Task<WidgetCatalog> GetWidgetCatalogAsync()
{
var attempt = 0;
Expand Down Expand Up @@ -149,11 +139,7 @@ public async Task<WidgetCatalog> GetWidgetCatalogAsync()
return _widgetCatalog;
}

/// <summary>
/// Get the list of WidgetProviderDefinitions from the WidgetService.
/// </summary>
/// <returns>A list of WidgetProviderDefinitions, or an empty list if there were no widgets
/// or the list could not be retrieved.</returns>
/// <inheritdoc />
public async Task<WidgetProviderDefinition[]> GetProviderDefinitionsAsync()
{
var attempt = 0;
Expand Down Expand Up @@ -182,11 +168,7 @@ public async Task<WidgetProviderDefinition[]> GetProviderDefinitionsAsync()
return [];
}

/// <summary>
/// Get the list of WidgetDefinitions from the WidgetService.
/// </summary>
/// <returns>A list of WidgetDefinitions, or an empty list if there were no widgets
/// or the list could not be retrieved.</returns>
/// <inheritdoc />
public async Task<WidgetDefinition[]> GetWidgetDefinitionsAsync()
{
var attempt = 0;
Expand Down Expand Up @@ -215,11 +197,7 @@ public async Task<WidgetDefinition[]> GetWidgetDefinitionsAsync()
return [];
}

/// <summary>
/// Get the WidgetDefinition for the given WidgetDefinitionId from the WidgetService.
/// </summary>
/// <returns>The WidgetDefinition, or null if the widget definition could not be found
/// or there was an error retrieving it.</returns>
/// <inheritdoc />
public async Task<WidgetDefinition> GetWidgetDefinitionAsync(string widgetDefinitionId)
{
var attempt = 0;
Expand Down
12 changes: 5 additions & 7 deletions tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,14 @@ private async Task InitializeDashboard()
private async Task InitializePinnedWidgetListAsync(bool isFirstDashboardRun)
{
var hostWidgets = await GetPreviouslyPinnedWidgets();

if ((hostWidgets == null || hostWidgets.Length == 0) && isFirstDashboardRun)
if ((hostWidgets.Length == 0) && isFirstDashboardRun)
{
// If it's the first time the Dashboard has been displayed and we have no other widgets pinned to a
// different version of Dev Home, pin some default widgets.
_log.Information($"Pin default widgets");
await PinDefaultWidgetsAsync();
}
else if (hostWidgets != null)
else
{
await RestorePinnedWidgetsAsync(hostWidgets);
}
Expand All @@ -235,11 +234,10 @@ private async Task<ComSafeWidget[]> GetPreviouslyPinnedWidgets()
{
_log.Information("Get widgets for current host");
var unsafeHostWidgets = await ViewModel.WidgetHostingService.GetWidgetsAsync();

if (unsafeHostWidgets == null)
if (unsafeHostWidgets.Length == 0)
{
_log.Information($"Found 0 widgets for this host");
return null;
return [];
}

var comSafeHostWidgets = new List<ComSafeWidget>();
Expand Down Expand Up @@ -380,7 +378,7 @@ private async Task DeleteAbandonedWidgetAsync(ComSafeWidget widget)
await widget.DeleteAsync();

var newWidgetList = await ViewModel.WidgetHostingService.GetWidgetsAsync();
length = (newWidgetList == null) ? 0 : newWidgetList.Length;
length = newWidgetList.Length;
_log.Information($"After delete, {length} widgets for this host");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<!-- Header icon -->
<ctControls:SettingsExpander.HeaderIcon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xefff;"/>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe9d9;"/>
</ctControls:SettingsExpander.HeaderIcon>

<!-- Quiet session setting area -->
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions tools/SetupFlow/DevHome.SetupFlow/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@
<comment>{Locked="{0}"}Title for the page showing the contents of a configuration file. {0} is replaced by the configuration file name.</comment>
</data>
<data name="ConfigurationActivationFailedDisabled" xml:space="preserve">
<value>Winget configuration is currently disabled on your machine. We are initiating the enablement process, which may take a few minutes. Please try again soon.</value>
<comment>Message displayed to the user when they attempt to activate Dev Home from a file but the Winget configuration feature is disabled.</comment>
<value>WinGet configuration is currently disabled on your machine. We are initiating the enablement process, which may take a few minutes. Please try again soon.</value>
<comment>Message displayed to the user when they attempt to activate Dev Home from a file but the WinGet configuration feature is disabled.</comment>
</data>
<data name="ConfigurationActivationFailedBusy" xml:space="preserve">
<value>The DSC flow cannot be activated while machine configuration is in progress. Please complete your current configuration tasks and then try again.</value>
Expand Down Expand Up @@ -526,7 +526,7 @@
<comment>Header text for a group of controls giving multiple choices for configuring the machine, but not a full setup flow</comment>
</data>
<data name="MainPage_SetupFlow.Description" xml:space="preserve">
<value>Clone repositories, install applications, and generate Winget Configuration files together</value>
<value>Clone repositories, install applications, and generate WinGet Configuration files together.</value>
<comment>Body text description for a card than when clicked takes the user to a multi-step flow for setting up their machine</comment>
</data>
<data name="MainPage_SetupFlow.Header" xml:space="preserve">
Expand All @@ -538,7 +538,7 @@
<comment>Header for a card that when clicked takes the user to a multi-step flow for setting up for a remote machine</comment>
</data>
<data name="MainPage_SetupFlow_For_target.Description" xml:space="preserve">
<value>Clone repositories, install applications, and generate a Winget Configuration file to apply to an environment.</value>
<value>Clone repositories, install applications, and generate a WinGet Configuration file to apply to an environment.</value>
<comment>Body text description for a card than when clicked takes the user to a multi-step flow for setting up their machine</comment>
</data>
<data name="NoAppsToInstall.Text" xml:space="preserve">
Expand Down Expand Up @@ -1573,7 +1573,7 @@
<comment>Text for when the configuration operation on a remote machine is on going but the extension is waiting for the current user to logon to the machine</comment>
</data>
<data name="SetupTargetConfigurationSkipped" xml:space="preserve">
<value>Winget skipped this unit</value>
<value>WinGet skipped this unit</value>
<comment>Text for when the a part of the configuration on the remove machine was completed but its completed status was set to skipped.</comment>
</data>
<data name="SetupTargetConfigurationOpenConfigFailed" xml:space="preserve">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public partial class LoadingViewModel : SetupPageViewModelBase
private static readonly BitmapImage DarkCaution = new(new Uri("ms-appx:///DevHome.SetupFlow/Assets/DarkCaution.png"));
private static readonly BitmapImage DarkError = new(new Uri("ms-appx:///DevHome.SetupFlow/Assets/DarkError.png"));
private static readonly BitmapImage DarkSuccess = new(new Uri("ms-appx:///DevHome.SetupFlow/Assets/DarkSuccess.png"));
private static readonly BitmapImage DarkInfo = new(new Uri("ms-appx:///DevHome.SetupFlow/Assets/DarkCaution.png"));
private static readonly BitmapImage DarkInfo = new(new Uri("ms-appx:///DevHome.SetupFlow/Assets/DarkInfo.png"));
private static readonly BitmapImage LightCaution = new(new Uri("ms-appx:///DevHome.SetupFlow/Assets/LightCaution.png"));
private static readonly BitmapImage LightError = new(new Uri("ms-appx:///DevHome.SetupFlow/Assets/LightError.png"));
private static readonly BitmapImage LightSuccess = new(new Uri("ms-appx:///DevHome.SetupFlow/Assets/LightSuccess.png"));
private static readonly BitmapImage LightInfo = new(new Uri("ms-appx:///DevHome.SetupFlow/Assets/LightCaution.png"));
private static readonly BitmapImage LightInfo = new(new Uri("ms-appx:///DevHome.SetupFlow/Assets/LightInfo.png"));

#pragma warning disable SA1310 // Field names should not contain underscore
private const int MAX_RETRIES = 1;
Expand Down

0 comments on commit 18ff42e

Please sign in to comment.