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

Detecting configuration files #2459

Merged
merged 25 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
60ed7f9
WIP
dhoehna Feb 23, 2024
501649f
Merge branch 'main' into user/dhoehna/DetectingConfigurationFiles
dhoehna Feb 26, 2024
4f0f3d8
Builds and runs. no special UI though. :(
dhoehna Feb 28, 2024
19c1ffd
Works. Looks good. View File works.
dhoehna Mar 12, 2024
3b75e0d
Fixing some UI
dhoehna Mar 14, 2024
cf187af
Merging with Main
dhoehna Mar 15, 2024
c08cc92
Stretching the contents. Adding owning account name
dhoehna Mar 15, 2024
bec0cb9
Consolidating localized strings
dhoehna Mar 21, 2024
63c8311
Merge branch 'main' into user/dhoehna/DetectingConfigurationFiles
dhoehna Mar 21, 2024
9fd34d3
Adding back my changes
dhoehna Mar 21, 2024
8287e89
Finally. Expands the whole list view
dhoehna Mar 22, 2024
378338c
Now with proper padding
dhoehna Mar 22, 2024
301e6ed
Adding new borders to compensate for removing the top border from Nex…
dhoehna Mar 22, 2024
c91c13a
Making the code a bit better
dhoehna Mar 22, 2024
82c2f29
Merge branch 'main' into user/dhoehna/DetectingConfigurationFiles
dhoehna Mar 22, 2024
36d314c
Removing un-needed using statements
dhoehna Mar 22, 2024
7ae4a14
Removing un-used code. Adding some syntactical sugar.
dhoehna Mar 25, 2024
af7b2ae
Adding another catch. Removing IHost
dhoehna Mar 26, 2024
06c3a6f
Fixing merge
dhoehna Mar 26, 2024
1d9b87b
Merge branch 'main' into user/dhoehna/DetectingConfigurationFiles
dhoehna Mar 27, 2024
1998f8d
Fixing log and spacing issues
dhoehna Mar 27, 2024
7224ad5
Merge branch 'main' into user/dhoehna/DetectingConfigurationFiles
dhoehna Mar 27, 2024
a2f2b2e
Removing extra white-space
dhoehna Mar 27, 2024
a8006a1
Pulling main
dhoehna Mar 29, 2024
ff73717
Addressing comments. Consolidating exception code
dhoehna Mar 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Diagnostics.Tracing;
using DevHome.Telemetry;
using Microsoft.Diagnostics.Telemetry.Internal;

namespace DevHome.Common.TelemetryEvents.SetupFlow.SummaryPage;

[EventData]
public class CloneRepoNextStepError : EventBase
{
public string Operation { get; }

public string ErrorMessage { get; }

public string RepoName { get; }

public override PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;

public CloneRepoNextStepError(string operation, string errorMessage, string repoName)
{
Operation = operation;
ErrorMessage = errorMessage;
RepoName = repoName;
}

public override void ReplaceSensitiveStrings(Func<string, string> replaceSensitiveStrings)
{
// no op
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Diagnostics.Tracing;
using DevHome.Telemetry;
using Microsoft.Diagnostics.Telemetry.Internal;

namespace DevHome.Common.TelemetryEvents.SetupFlow.SummaryPage;

[EventData]
public class CloneRepoNextStepEvent : EventBase
{
public string Operation { get; }

public string RepoName { get; }

public override PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServicePerformance;

public CloneRepoNextStepEvent(string operation, string repoName)
{
Operation = operation;
RepoName = repoName;
}

public override void ReplaceSensitiveStrings(Func<string, string> replaceSensitiveStrings)
{
// no op
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevHome.Telemetry;
using Microsoft.Diagnostics.Telemetry;
using Microsoft.Diagnostics.Telemetry.Internal;

namespace DevHome.Common.TelemetryEvents.SetupFlow.SummaryPage;

[EventData]
public class CloneRepoNextStepsEvent : EventBase
{
public override PartA_PrivTags PartA_PrivTags => PrivTags.ProductAndServicePerformance;

public int NumberOfConfigurationFilesFound { get; }

public CloneRepoNextStepsEvent(int numberOfConfigurationFilesFound)
{
NumberOfConfigurationFilesFound = numberOfConfigurationFilesFound;
}

public override void ReplaceSensitiveStrings(Func<string, string> replaceSensitiveStrings)
{
// No op.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,11 @@ public static class DscHelpers
public const string DevHomeHeaderBanner =
@"# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
# Reference: https://github.com/microsoft/winget-create#building-the-client
# WinGet Configure file Generated By Dev Home.";
# WinGet Configure file Generated By Dev Home.";

public const string ConfigurationFolderName = ".configurations";

public const string ConfigurationFileYamlExtension = ".dsc.yaml";

public const string ConfigurationFileWingetExtension = ".winget";
}
4 changes: 4 additions & 0 deletions tools/SetupFlow/DevHome.SetupFlow/DevHome.SetupFlow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<None Update="Assets\AppManagementPackages.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Page Update="Views\CloneRepoSummaryInformationView.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\SetupTargetReviewView.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down Expand Up @@ -87,6 +90,7 @@
<None Remove="Styles\SetupFlow_ThemeResources.xaml" />
<None Remove="Styles\SetupToolStyles.xaml" />
<None Remove="Views\AddRepoDialog.xaml" />
<None Remove="Views\CloneRepoSummaryInformationView.xaml" />
<None Remove="Views\DevDriveReviewView.xaml" />
<None Remove="Views\DevDriveView.xaml" />
<None Remove="Views\EditClonePathDialog.xaml" />
Expand Down
10 changes: 10 additions & 0 deletions tools/SetupFlow/DevHome.SetupFlow/Extensions/ServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static IServiceCollection AddSetupFlow(this IServiceCollection services,
services.AddRepoConfig();
services.AddReview();
services.AddSummary();
services.AddSummaryInformation();

// View-models
services.AddSingleton<SetupFlowViewModel>();
Expand Down Expand Up @@ -114,6 +115,14 @@ private static IServiceCollection AddConfigurationFile(this IServiceCollection s
return services;
}

private static IServiceCollection AddSummaryInformation(this IServiceCollection services)
{
// View models
services.AddTransient<CloneRepoSummaryInformationViewModel>();

return services;
}

private static IServiceCollection AddDevDrive(this IServiceCollection services)
{
// View models
Expand All @@ -133,6 +142,7 @@ private static IServiceCollection AddLoading(this IServiceCollection services)
{
// View models
services.AddTransient<LoadingViewModel>();
services.AddTransient<LoadingMessageViewModel>();

return services;
}
Expand Down
39 changes: 37 additions & 2 deletions tools/SetupFlow/DevHome.SetupFlow/Models/CloneRepoTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using DevHome.Common.Extensions;
using DevHome.Common.Services;
using DevHome.Common.TelemetryEvents;
using DevHome.Common.TelemetryEvents.SetupFlow;
using DevHome.SetupFlow.Common;
using DevHome.SetupFlow.Common.Helpers;
using DevHome.SetupFlow.Services;
using DevHome.SetupFlow.ViewModels;
using DevHome.Telemetry;
using Microsoft.Extensions.Hosting;
using Microsoft.Windows.DevHome.SDK;
using Projection::DevHome.SetupFlow.ElevatedComponent;
using Serilog;
Expand All @@ -27,6 +33,8 @@ namespace DevHome.SetupFlow.Models;
/// </summary>
public partial class CloneRepoTask : ObservableObject, ISetupTask
{
private readonly IHost _host;

private readonly ILogger _log = Log.ForContext("SourceContext", nameof(CloneRepoTask));

private readonly Guid _activityId;
Expand Down Expand Up @@ -131,13 +139,17 @@ public bool DependsOnDevDriveToBeInstalled
get; set;
}

private readonly CloneRepoSummaryInformationViewModel _summaryScreenInformation;

public ISummaryInformationViewModel SummaryScreenInformation => _summaryScreenInformation;

/// <summary>
/// Initializes a new instance of the <see cref="CloneRepoTask"/> class.
/// </summary>
/// <param name="cloneLocation">Repository will be placed here. at _cloneLocation.FullName</param>
/// <param name="repositoryToClone">The repository to clone</param>
/// <param name="developerId">Credentials needed to clone a private repo</param>
public CloneRepoTask(IRepositoryProvider repositoryProvider, DirectoryInfo cloneLocation, IRepository repositoryToClone, IDeveloperId developerId, IStringResource stringResource, string providerName, Guid activityId)
public CloneRepoTask(IRepositoryProvider repositoryProvider, DirectoryInfo cloneLocation, IRepository repositoryToClone, IDeveloperId developerId, ISetupFlowStringResource stringResource, string providerName, Guid activityId, IHost host)
{
_cloneLocation = cloneLocation;
this.RepositoryToClone = repositoryToClone;
Expand All @@ -147,6 +159,8 @@ public CloneRepoTask(IRepositoryProvider repositoryProvider, DirectoryInfo clone
_stringResource = stringResource;
_repositoryProvider = repositoryProvider;
_activityId = activityId;
_host = host;
_summaryScreenInformation = new CloneRepoSummaryInformationViewModel(host.GetService<SetupFlowOrchestrator>(), stringResource);
}

/// <summary>
Expand All @@ -155,7 +169,7 @@ public CloneRepoTask(IRepositoryProvider repositoryProvider, DirectoryInfo clone
/// </summary>
/// <param name="cloneLocation">Repository will be placed here, at _cloneLocation.FullName</param>
/// <param name="repositoryToClone">The repository to clone</param>
public CloneRepoTask(IRepositoryProvider repositoryProvider, DirectoryInfo cloneLocation, IRepository repositoryToClone, IStringResource stringResource, string providerName, Guid activityId)
public CloneRepoTask(IRepositoryProvider repositoryProvider, DirectoryInfo cloneLocation, IRepository repositoryToClone, ISetupFlowStringResource stringResource, string providerName, Guid activityId, IHost host)
{
_cloneLocation = cloneLocation;
this.RepositoryToClone = repositoryToClone;
Expand All @@ -165,6 +179,8 @@ public CloneRepoTask(IRepositoryProvider repositoryProvider, DirectoryInfo clone
_stringResource = stringResource;
_repositoryProvider = repositoryProvider;
_activityId = activityId;
_host = host;
_summaryScreenInformation = new CloneRepoSummaryInformationViewModel(host.GetService<SetupFlowOrchestrator>(), stringResource);
}

private void SetMessages(IStringResource stringResource)
Expand Down Expand Up @@ -232,7 +248,26 @@ IAsyncOperation<TaskFinishedState> ISetupTask.Execute()
return TaskFinishedState.Failure;
}

// Search for a configuration file.
var configurationDirectory = Path.Join(_cloneLocation.FullName, DscHelpers.ConfigurationFolderName);
if (Directory.Exists(configurationDirectory))
{
var fileToUse = Directory.EnumerateFiles(configurationDirectory)
dhoehna marked this conversation as resolved.
Show resolved Hide resolved
.Where(file => file.EndsWith(DscHelpers.ConfigurationFileYamlExtension, StringComparison.OrdinalIgnoreCase) ||
file.EndsWith(DscHelpers.ConfigurationFileWingetExtension, StringComparison.OrdinalIgnoreCase))
.OrderByDescending(configurationFile => File.GetLastWriteTime(configurationFile))
.FirstOrDefault();

if (fileToUse != null)
{
_summaryScreenInformation.FilePathAndName = fileToUse;
_summaryScreenInformation.RepoName = RepositoryName;
_summaryScreenInformation.OwningAccount = RepositoryToClone.OwningAccountName ?? string.Empty;
}
}

WasCloningSuccessful = true;

return TaskFinishedState.Success;
}).AsAsyncOperation();
}
Expand Down
11 changes: 7 additions & 4 deletions tools/SetupFlow/DevHome.SetupFlow/Models/ConfigureTargetTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
using DevHome.SetupFlow.Common.Exceptions;
using DevHome.SetupFlow.Exceptions;
using DevHome.SetupFlow.Models.WingetConfigure;
using DevHome.SetupFlow.Services;
using DevHome.SetupFlow.Services;
using DevHome.SetupFlow.ViewModels;
using Microsoft.UI.Xaml;
using Microsoft.Windows.DevHome.SDK;
using Projection::DevHome.SetupFlow.ElevatedComponent;
Expand Down Expand Up @@ -93,7 +94,9 @@ public class ConfigureTargetTask : ISetupTask
public SDKApplyConfigurationResult Result { get; private set; }

public IAsyncOperation<ApplyConfigurationResult> ApplyConfigurationAsyncOperation { get; private set; }


public ISummaryInformationViewModel SummaryScreenInformation { get; }

public ConfigureTargetTask(
ISetupFlowStringResource stringResource,
IComputeSystemManager computeSystemManager,
Expand Down Expand Up @@ -155,8 +158,8 @@ public void OnActionRequired(IApplyConfigurationOperation operation, SDK.ApplyCo
ExtensionAdaptiveCardSession.Stopped += OnAdaptiveCardSessionStopped;

CreateCorrectiveActionPanel(ExtensionAdaptiveCardSession).GetAwaiter().GetResult();
AddMessage(_stringResource.GetLocalized(StringResourceKey.ConfigureTargetApplyConfigurationActionNeeded, UserNumberOfAttempts++), MessageSeverityKind.Warning);

AddMessage(_stringResource.GetLocalized(StringResourceKey.ConfigureTargetApplyConfigurationActionNeeded, UserNumberOfAttempts++, UserMaxNumberOfAttempts), MessageSeverityKind.Warning);
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions tools/SetupFlow/DevHome.SetupFlow/Models/ConfigureTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Threading.Tasks;
using DevHome.SetupFlow.Common.Contracts;
using DevHome.SetupFlow.Services;
using DevHome.SetupFlow.ViewModels;
using Projection::DevHome.SetupFlow.ElevatedComponent;
using Serilog;
using Windows.Foundation;
Expand Down Expand Up @@ -44,6 +45,8 @@ public IList<ConfigurationUnitResult> UnitResults
get; private set;
}

public ISummaryInformationViewModel SummaryScreenInformation { get; }

public ConfigureTask(
ISetupFlowStringResource stringResource,
IDesiredStateConfiguration dsc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using DevHome.SetupFlow.Common.Helpers;
using DevHome.SetupFlow.Common.TelemetryEvents;
using DevHome.SetupFlow.Services;
using DevHome.SetupFlow.ViewModels;
using DevHome.Telemetry;
using Microsoft.Extensions.Hosting;
using Projection::DevHome.SetupFlow.ElevatedComponent;
Expand Down Expand Up @@ -50,6 +51,8 @@ public IDevDrive DevDrive
get; set;
}

public ISummaryInformationViewModel SummaryScreenInformation { get; }

public CreateDevDriveTask(IDevDrive devDrive, IHost host, Guid activityId, ISetupFlowStringResource stringResource)
{
DevDrive = devDrive;
Expand Down
3 changes: 3 additions & 0 deletions tools/SetupFlow/DevHome.SetupFlow/Models/ISetupTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

extern alias Projection;

using DevHome.SetupFlow.ViewModels;
using Projection::DevHome.SetupFlow.ElevatedComponent;
using Windows.Foundation;

Expand Down Expand Up @@ -113,6 +114,8 @@ public abstract bool DependsOnDevDriveToBeInstalled
/// </summary>
public event ChangeMessageHandler AddMessage;

public ISummaryInformationViewModel SummaryScreenInformation { get; }

public delegate void ChangeActionCenterMessageHandler(ActionCenterMessages message, ActionMessageRequestKind requestKind);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using DevHome.SetupFlow.Common.Helpers;
using DevHome.SetupFlow.Exceptions;
using DevHome.SetupFlow.Services;
using DevHome.SetupFlow.ViewModels;
using DevHome.Telemetry;
using Microsoft.Management.Deployment;
using Projection::DevHome.SetupFlow.ElevatedComponent;
Expand Down Expand Up @@ -55,6 +56,8 @@ public bool DependsOnDevDriveToBeInstalled
get;
}

public ISummaryInformationViewModel SummaryScreenInformation { get; }

public string PackageName => _package.Name;

#pragma warning disable 67
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public static class StringResourceKey
public static readonly string CloneRepoErrorForActionCenter = nameof(CloneRepoErrorForActionCenter);
public static readonly string CloneRepoRestart = nameof(CloneRepoRestart);

// Repository Next Steps messages
public static readonly string CloneRepoNextStepsView = nameof(CloneRepoNextStepsView);
public static readonly string CloneRepoNextStepsRun = nameof(CloneRepoNextStepsRun);
public static readonly string CloneRepoNextStepsFileFound = nameof(CloneRepoNextStepsFileFound);
public static readonly string CloneRepoNextStepsDescription = nameof(CloneRepoNextStepsDescription);

// Configure task loading screen messages
public static readonly string ApplyingConfigurationMessage = nameof(ApplyingConfigurationMessage);
public static readonly string ConfigureTaskCreating = nameof(ConfigureTaskCreating);
Expand Down
Loading
Loading