Skip to content

Commit

Permalink
Improve Summary screen by adding more details about applied resources (
Browse files Browse the repository at this point in the history
  • Loading branch information
betanzos authored Oct 2, 2023
1 parent 81c060c commit 830b22a
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public sealed class ElevatedConfigureUnitTaskResult
{
public string? UnitName { get; set; }

public string? Id { get; set; }

public string? Description { get; set; }

public string? Intent { get; set; }

public bool IsSkipped { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ public IAsyncOperation<ElevatedConfigureTaskResult> ApplyConfiguration(string fi
taskResult.TaskAttempted = true;
taskResult.TaskSucceeded = result.Succeeded;
taskResult.RebootRequired = result.RequiresReboot;
taskResult.UnitResults = result.Result.UnitResults.Select(unitResult => new ElevatedConfigureUnitTaskResult
taskResult.UnitResults = result.Result.UnitResults.Select(unitResult =>
{
UnitName = unitResult.Unit.UnitName,
Intent = unitResult.Unit.Intent.ToString(),
IsSkipped = unitResult.State == ConfigurationUnitState.Skipped,
HResult = unitResult.ResultInformation?.ResultCode?.HResult ?? HRESULT.S_OK,
unitResult.Unit.Directives.TryGetValue("description", out var descriptionObj);
return new ElevatedConfigureUnitTaskResult
{
UnitName = unitResult.Unit.UnitName,
Id = unitResult.Unit.Identifier,
Description = descriptionObj?.ToString() ?? string.Empty,
Intent = unitResult.Unit.Intent.ToString(),
IsSkipped = unitResult.State == ConfigurationUnitState.Skipped,
HResult = unitResult.ResultInformation?.ResultCode?.HResult ?? HRESULT.S_OK,
};
}).ToList();
if (result.ResultException != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class ConfigurationUnitResult
public ConfigurationUnitResult(ApplyConfigurationUnitResult result)
{
UnitName = result.Unit.UnitName;
Id = result.Unit.Identifier;
result.Unit.Directives.TryGetValue("description", out var descriptionObj);
Description = descriptionObj?.ToString() ?? string.Empty;
Intent = result.Unit.Intent.ToString();
IsSkipped = result.State == ConfigurationUnitState.Skipped;
HResult = result.ResultInformation?.ResultCode?.HResult ?? HRESULT.S_OK;
Expand All @@ -21,13 +24,19 @@ public ConfigurationUnitResult(ApplyConfigurationUnitResult result)
public ConfigurationUnitResult(ElevatedConfigureUnitTaskResult result)
{
UnitName = result.UnitName;
Id = result.Id;
Description = result.Description;
Intent = result.Intent;
IsSkipped = result.IsSkipped;
HResult = result.HResult;
}

public string UnitName { get; }

public string Id { get; }

public string Description { get; }

public string Intent { get; }

public bool IsSkipped { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public static class StringResourceKey
public static readonly string ConfigurationUnitFailed = nameof(ConfigurationUnitFailed);
public static readonly string ConfigurationUnitSkipped = nameof(ConfigurationUnitSkipped);
public static readonly string ConfigurationUnitSuccess = nameof(ConfigurationUnitSuccess);
public static readonly string ConfigurationUnitSummary = nameof(ConfigurationUnitSummary);
public static readonly string ConfigurationUnitSummaryFull = nameof(ConfigurationUnitSummaryFull);
public static readonly string ConfigurationUnitSummaryMinimal = nameof(ConfigurationUnitSummaryMinimal);
public static readonly string ConfigurationUnitSummaryNoDescription = nameof(ConfigurationUnitSummaryNoDescription);
public static readonly string ConfigurationUnitSummaryNoId = nameof(ConfigurationUnitSummaryNoId);
public static readonly string ConfigurationUnitStats = nameof(ConfigurationUnitStats);
public static readonly string ConfigurationViewTitle = nameof(ConfigurationViewTitle);
public static readonly string DevDriveReviewTitle = nameof(DevDriveReviewTitle);
Expand Down
16 changes: 14 additions & 2 deletions tools/SetupFlow/DevHome.SetupFlow/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,21 @@
<value>Configuration successfully applied</value>
<comment>Message displayed when applying a configuration unit succeeds.</comment>
</data>
<data name="ConfigurationUnitSummary" xml:space="preserve">
<data name="ConfigurationUnitSummaryFull" xml:space="preserve">
<value>{0} : {3} [{1} {2}]</value>
<comment>{Locked="{0}","{1}","{2}","{3}"}Summary text for a configuration unit. {0} is replaced by the configuration unit intent (e.g. Assert, Inform, Apply). {1} is replaced by the configuration unit name. {2} is replaced by the configuration unit id. {3} is replaced by the configuration unit description. A string with all values replaced could look like "Apply : Install VS [WinGetPackage vspackage]"</comment>
</data>
<data name="ConfigurationUnitSummaryMinimal" xml:space="preserve">
<value>{0} : {1}</value>
<comment>{Locked="{0}","{1}"}Summary text for a configuration unit. {0} is replaced by the configuration unit intent (e.g. Assert, Inform, Apply). {1} is replaced by the configuration unit name.</comment>
<comment>{Locked="{0}","{1}"}Summary text for a configuration unit. {0} is replaced by the configuration unit intent (e.g. Assert, Inform, Apply). {1} is replaced by the configuration unit name. A string with all values replaced could look like "Apply : WinGetPackage"</comment>
</data>
<data name="ConfigurationUnitSummaryNoDescription" xml:space="preserve">
<value>{0} : {1} [{2}]</value>
<comment>{Locked="{0}","{1}","{2}"}Summary text for a configuration unit. {0} is replaced by the configuration unit intent (e.g. Assert, Inform, Apply). {1} is replaced by the configuration unit name. {2} is replaced by the configuration unit id. A string with all values replaced could look like "Apply : WinGetPackage [vspackage]"</comment>
</data>
<data name="ConfigurationUnitSummaryNoId" xml:space="preserve">
<value>{0} : {2} [{1}]</value>
<comment>{Locked="{0}","{1}","{2}"}Summary text for a configuration unit. {0} is replaced by the configuration unit intent (e.g. Assert, Inform, Apply). {1} is replaced by the configuration unit name. {2} is replaced by the configuration unit description. A string with all values replaced could look like "Apply : Install VS [WinGetPackage]"</comment>
</data>
<data name="ConfigurationUnitStats" xml:space="preserve">
<value>Succeeded: {0} | Failed: {1} | Skipped: {2}</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ConfigurationUnitResultViewModel(ISetupFlowStringResource stringResource,
_unitResult = unitResult;
}

public string Title => _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummary, _unitResult.Intent, _unitResult.UnitName);
public string Title => BuildTitle();

public string ApplyResult => GetApplyResult();

Expand All @@ -54,4 +54,24 @@ private string GetApplyResult()

return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSuccess);
}

private string BuildTitle()
{
if (string.IsNullOrEmpty(_unitResult.Id) && string.IsNullOrEmpty(_unitResult.Description))
{
return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryMinimal, _unitResult.Intent, _unitResult.UnitName);
}

if (string.IsNullOrEmpty(_unitResult.Id))
{
return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryNoId, _unitResult.Intent, _unitResult.UnitName, _unitResult.Description);
}

if (string.IsNullOrEmpty(_unitResult.Description))
{
return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryNoDescription, _unitResult.Intent, _unitResult.UnitName, _unitResult.Id);
}

return _stringResource.GetLocalized(StringResourceKey.ConfigurationUnitSummaryFull, _unitResult.Intent, _unitResult.UnitName, _unitResult.Id, _unitResult.Description);
}
}

0 comments on commit 830b22a

Please sign in to comment.