Skip to content

Commit

Permalink
Requested changes & Build Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrariofilippo committed Feb 10, 2025
1 parent 9b159fb commit 351d49f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 60 deletions.
29 changes: 4 additions & 25 deletions src/Files.App/Actions/Open/OpenInIDEAction.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

using Microsoft.UI.Xaml.Controls;

namespace Files.App.Actions
{
internal sealed partial class OpenInIDEAction : ObservableObject, IAction
Expand All @@ -14,12 +12,12 @@ internal sealed partial class OpenInIDEAction : ObservableObject, IAction
public string Label
=> string.Format(
"OpenInIDE".GetLocalizedResource(),
_devToolsSettingsService.FriendlyIDEName);
_devToolsSettingsService.IDEFriendlyName);

public string Description
=> string.Format(
"OpenInIDEDescription".GetLocalizedResource(),
_devToolsSettingsService.FriendlyIDEName);
_devToolsSettingsService.IDEFriendlyName);

public bool IsExecutable =>
_context.Folder is not null &&
Expand All @@ -41,7 +39,7 @@ public async Task ExecuteAsync(object? parameter = null)
);

if (!res)
await ShowErrorDialog();
await DynamicDialogFactory.ShowFor_IDEErrorDialog();
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand All @@ -56,30 +54,11 @@ private void DevSettings_PropertyChanged(object? sender, PropertyChangedEventArg
{
OnPropertyChanged(nameof(IsExecutable));
}
else if (e.PropertyName == nameof(IDevToolsSettingsService.FriendlyIDEName))
else if (e.PropertyName == nameof(IDevToolsSettingsService.IDEFriendlyName))
{
OnPropertyChanged(nameof(Label));
OnPropertyChanged(nameof(Description));
}
}

private async Task ShowErrorDialog()
{
var commands = Ioc.Default.GetRequiredService<ICommandManager>();
var errorDialog = new ContentDialog()
{
Title = Strings.IDEError.GetLocalizedResource(),
Content = Strings.SelectedIDENotValid.GetLocalizedResource(),
PrimaryButtonText = Strings.OK.GetLocalizedResource(),
SecondaryButtonText = Strings.EditInSettings.GetLocalizedResource(),
};

if (await errorDialog.TryShowAsync() == ContentDialogResult.Secondary)
{
await commands.OpenSettings.ExecuteAsync(
new SettingsNavigationParams() { PageKind = SettingsPageKind.DevToolsPage }
);
}
}
}
}
29 changes: 4 additions & 25 deletions src/Files.App/Actions/Open/OpenRepoInIDEAction.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

using Microsoft.UI.Xaml.Controls;

namespace Files.App.Actions
{
internal sealed partial class OpenRepoInIDEAction : ObservableObject, IAction
Expand All @@ -12,10 +10,10 @@ internal sealed partial class OpenRepoInIDEAction : ObservableObject, IAction
private readonly IContentPageContext _context;

public string Label
=> string.Format("OpenRepoInIDE".GetLocalizedResource(), _devToolsSettingsService.FriendlyIDEName);
=> string.Format("OpenRepoInIDE".GetLocalizedResource(), _devToolsSettingsService.IDEFriendlyName);

public string Description
=> string.Format("OpenRepoInIDEDescription".GetLocalizedResource(), _devToolsSettingsService.FriendlyIDEName);
=> string.Format("OpenRepoInIDEDescription".GetLocalizedResource(), _devToolsSettingsService.IDEFriendlyName);

public bool IsExecutable =>
_context.Folder is not null &&
Expand All @@ -38,7 +36,7 @@ public async Task ExecuteAsync(object? parameter = null)
);

if (!res)
await ShowErrorDialog();
await DynamicDialogFactory.ShowFor_IDEErrorDialog();
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand All @@ -53,30 +51,11 @@ private void DevSettings_PropertyChanged(object? sender, PropertyChangedEventArg
{
OnPropertyChanged(nameof(IsExecutable));
}
else if (e.PropertyName == nameof(IDevToolsSettingsService.FriendlyIDEName))
else if (e.PropertyName == nameof(IDevToolsSettingsService.IDEFriendlyName))
{
OnPropertyChanged(nameof(Label));
OnPropertyChanged(nameof(Description));
}
}

private async Task ShowErrorDialog()
{
var commands = Ioc.Default.GetRequiredService<ICommandManager>();
var errorDialog = new ContentDialog()
{
Title = Strings.IDEError.GetLocalizedResource(),
Content = Strings.SelectedIDENotValid.GetLocalizedResource(),
PrimaryButtonText = Strings.OK.GetLocalizedResource(),
SecondaryButtonText = Strings.EditInSettings.GetLocalizedResource(),
};

if (await errorDialog.TryShowAsync() == ContentDialogResult.Secondary)
{
await commands.OpenSettings.ExecuteAsync(
new SettingsNavigationParams() { PageKind = SettingsPageKind.DevToolsPage }
);
}
}
}
}
2 changes: 1 addition & 1 deletion src/Files.App/Data/Contracts/IDevToolsSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public interface IDevToolsSettingsService : IBaseSettingsService, INotifyPropert
/// <summary>
/// Gets or sets the friendly name of the chosen IDE.
/// </summary>
string FriendlyIDEName { get; set; }
string IDEFriendlyName { get; set; }
}
}
20 changes: 20 additions & 0 deletions src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,5 +404,25 @@ public static DynamicDialog GetFor_CreateAlternateDataStreamDialog()

return dialog;
}

public static async Task ShowFor_IDEErrorDialog()
{
var commands = Ioc.Default.GetRequiredService<ICommandManager>();
var dialog = new DynamicDialog(new DynamicDialogViewModel()
{
TitleText = Strings.IDEError.GetLocalizedResource(),
SubtitleText = Strings.SelectedIDENotValid.GetLocalizedResource(),
PrimaryButtonText = Strings.OK.GetLocalizedResource(),
SecondaryButtonText = Strings.EditInSettings.GetLocalizedResource(),
DynamicButtons = DynamicDialogButtons.Primary | DynamicDialogButtons.Secondary,
});

await dialog.TryShowAsync();

if (dialog.DynamicResult is DynamicDialogResult.Secondary)
await commands.OpenSettings.ExecuteAsync(
new SettingsNavigationParams() { PageKind = SettingsPageKind.DevToolsPage }
);
}
}
}
8 changes: 3 additions & 5 deletions src/Files.App/Services/Settings/DevToolsSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace Files.App.Services.Settings
{
internal sealed partial class DevToolsSettingsService : BaseObservableJsonSettings, IDevToolsSettingsService
{
private bool _isVSCodeInstalled = SoftwareHelpers.IsVSCodeInstalled();

public DevToolsSettingsService(ISettingsSharingContext settingsSharingContext)
{
// Register root
Expand All @@ -23,14 +21,14 @@ public OpenInIDEOption OpenInIDEOption
/// <inheritdoc/>
public string IDEPath
{
get => Get(_isVSCodeInstalled ? "code" : string.Empty) ?? string.Empty;
get => Get(SoftwareHelpers.IsVSCodeInstalled() ? "code" : string.Empty) ?? string.Empty;
set => Set(value);
}

/// <inheritdoc/>
public string FriendlyIDEName
public string IDEFriendlyName
{
get => Get(_isVSCodeInstalled ? Strings.VisualStudioCode.GetLocalizedResource() : string.Empty) ?? string.Empty;
get => Get(SoftwareHelpers.IsVSCodeInstalled() ? Strings.VisualStudioCode.GetLocalizedResource() : string.Empty) ?? string.Empty;
set => Set(value);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/ViewModels/Settings/DevToolsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public DevToolsViewModel()
SelectedOpenInIDEOption = OpenInIDEOptions[DevToolsSettingsService.OpenInIDEOption];

IDEPath = DevToolsSettingsService.IDEPath;
IDEFriendlyName = DevToolsSettingsService.FriendlyIDEName;
IDEFriendlyName = DevToolsSettingsService.IDEFriendlyName;
IsIDEPathValid = true;
IsFriendlyNameValid = true;

Expand Down Expand Up @@ -149,7 +149,7 @@ private void DoCancelIDEChanges()
{
IsEditingIDEConfig = false;
IDEPath = DevToolsSettingsService.IDEPath;
IDEFriendlyName = DevToolsSettingsService.FriendlyIDEName;
IDEFriendlyName = DevToolsSettingsService.IDEFriendlyName;
IsIDEPathValid = true;
IsFriendlyNameValid = true;
}
Expand All @@ -160,7 +160,7 @@ private void DoSaveIDEChanges()
IsIDEPathValid = true;
IsFriendlyNameValid = true;
DevToolsSettingsService.IDEPath = IDEPath;
DevToolsSettingsService.FriendlyIDEName = IDEFriendlyName;
DevToolsSettingsService.IDEFriendlyName = IDEFriendlyName;
}

private void DoStartEditingIDE()
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/Settings/DevToolsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="using:Files.App.UserControls"
xmlns:vm="using:Files.App.ViewModels.Settings"
xmlns:wctconverters="using:CommunityToolkit.WinUI.UI.Converters"
xmlns:wctconverters="using:CommunityToolkit.WinUI.Converters"
mc:Ignorable="d">

<Page.Resources>
Expand Down

0 comments on commit 351d49f

Please sign in to comment.