Skip to content

Commit f8a52ae

Browse files
ferrariofilippoyaira2
authored andcommitted
Requested changes & Build Errors
1 parent d91ae8f commit f8a52ae

File tree

7 files changed

+36
-60
lines changed

7 files changed

+36
-60
lines changed
Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4-
using Microsoft.UI.Xaml.Controls;
5-
64
namespace Files.App.Actions
75
{
86
internal sealed partial class OpenInIDEAction : ObservableObject, IAction
@@ -14,12 +12,12 @@ internal sealed partial class OpenInIDEAction : ObservableObject, IAction
1412
public string Label
1513
=> string.Format(
1614
"OpenInIDE".GetLocalizedResource(),
17-
_devToolsSettingsService.FriendlyIDEName);
15+
_devToolsSettingsService.IDEFriendlyName);
1816

1917
public string Description
2018
=> string.Format(
2119
"OpenInIDEDescription".GetLocalizedResource(),
22-
_devToolsSettingsService.FriendlyIDEName);
20+
_devToolsSettingsService.IDEFriendlyName);
2321

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

4341
if (!res)
44-
await ShowErrorDialog();
42+
await DynamicDialogFactory.ShowFor_IDEErrorDialog();
4543
}
4644

4745
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
@@ -56,30 +54,11 @@ private void DevSettings_PropertyChanged(object? sender, PropertyChangedEventArg
5654
{
5755
OnPropertyChanged(nameof(IsExecutable));
5856
}
59-
else if (e.PropertyName == nameof(IDevToolsSettingsService.FriendlyIDEName))
57+
else if (e.PropertyName == nameof(IDevToolsSettingsService.IDEFriendlyName))
6058
{
6159
OnPropertyChanged(nameof(Label));
6260
OnPropertyChanged(nameof(Description));
6361
}
6462
}
65-
66-
private async Task ShowErrorDialog()
67-
{
68-
var commands = Ioc.Default.GetRequiredService<ICommandManager>();
69-
var errorDialog = new ContentDialog()
70-
{
71-
Title = Strings.IDEError.GetLocalizedResource(),
72-
Content = Strings.SelectedIDENotValid.GetLocalizedResource(),
73-
PrimaryButtonText = Strings.OK.GetLocalizedResource(),
74-
SecondaryButtonText = Strings.EditInSettings.GetLocalizedResource(),
75-
};
76-
77-
if (await errorDialog.TryShowAsync() == ContentDialogResult.Secondary)
78-
{
79-
await commands.OpenSettings.ExecuteAsync(
80-
new SettingsNavigationParams() { PageKind = SettingsPageKind.DevToolsPage }
81-
);
82-
}
83-
}
8463
}
8564
}
Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4-
using Microsoft.UI.Xaml.Controls;
5-
64
namespace Files.App.Actions
75
{
86
internal sealed partial class OpenRepoInIDEAction : ObservableObject, IAction
@@ -12,10 +10,10 @@ internal sealed partial class OpenRepoInIDEAction : ObservableObject, IAction
1210
private readonly IContentPageContext _context;
1311

1412
public string Label
15-
=> string.Format("OpenRepoInIDE".GetLocalizedResource(), _devToolsSettingsService.FriendlyIDEName);
13+
=> string.Format("OpenRepoInIDE".GetLocalizedResource(), _devToolsSettingsService.IDEFriendlyName);
1614

1715
public string Description
18-
=> string.Format("OpenRepoInIDEDescription".GetLocalizedResource(), _devToolsSettingsService.FriendlyIDEName);
16+
=> string.Format("OpenRepoInIDEDescription".GetLocalizedResource(), _devToolsSettingsService.IDEFriendlyName);
1917

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

4038
if (!res)
41-
await ShowErrorDialog();
39+
await DynamicDialogFactory.ShowFor_IDEErrorDialog();
4240
}
4341

4442
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
@@ -53,30 +51,11 @@ private void DevSettings_PropertyChanged(object? sender, PropertyChangedEventArg
5351
{
5452
OnPropertyChanged(nameof(IsExecutable));
5553
}
56-
else if (e.PropertyName == nameof(IDevToolsSettingsService.FriendlyIDEName))
54+
else if (e.PropertyName == nameof(IDevToolsSettingsService.IDEFriendlyName))
5755
{
5856
OnPropertyChanged(nameof(Label));
5957
OnPropertyChanged(nameof(Description));
6058
}
6159
}
62-
63-
private async Task ShowErrorDialog()
64-
{
65-
var commands = Ioc.Default.GetRequiredService<ICommandManager>();
66-
var errorDialog = new ContentDialog()
67-
{
68-
Title = Strings.IDEError.GetLocalizedResource(),
69-
Content = Strings.SelectedIDENotValid.GetLocalizedResource(),
70-
PrimaryButtonText = Strings.OK.GetLocalizedResource(),
71-
SecondaryButtonText = Strings.EditInSettings.GetLocalizedResource(),
72-
};
73-
74-
if (await errorDialog.TryShowAsync() == ContentDialogResult.Secondary)
75-
{
76-
await commands.OpenSettings.ExecuteAsync(
77-
new SettingsNavigationParams() { PageKind = SettingsPageKind.DevToolsPage }
78-
);
79-
}
80-
}
8160
}
8261
}

src/Files.App/Data/Contracts/IDevToolsSettingsService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ public interface IDevToolsSettingsService : IBaseSettingsService, INotifyPropert
1818
/// <summary>
1919
/// Gets or sets the friendly name of the chosen IDE.
2020
/// </summary>
21-
string FriendlyIDEName { get; set; }
21+
string IDEFriendlyName { get; set; }
2222
}
2323
}

src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,5 +404,25 @@ public static DynamicDialog GetFor_CreateAlternateDataStreamDialog()
404404

405405
return dialog;
406406
}
407+
408+
public static async Task ShowFor_IDEErrorDialog()
409+
{
410+
var commands = Ioc.Default.GetRequiredService<ICommandManager>();
411+
var dialog = new DynamicDialog(new DynamicDialogViewModel()
412+
{
413+
TitleText = Strings.IDEError.GetLocalizedResource(),
414+
SubtitleText = Strings.SelectedIDENotValid.GetLocalizedResource(),
415+
PrimaryButtonText = Strings.OK.GetLocalizedResource(),
416+
SecondaryButtonText = Strings.EditInSettings.GetLocalizedResource(),
417+
DynamicButtons = DynamicDialogButtons.Primary | DynamicDialogButtons.Secondary,
418+
});
419+
420+
await dialog.TryShowAsync();
421+
422+
if (dialog.DynamicResult is DynamicDialogResult.Secondary)
423+
await commands.OpenSettings.ExecuteAsync(
424+
new SettingsNavigationParams() { PageKind = SettingsPageKind.DevToolsPage }
425+
);
426+
}
407427
}
408428
}

src/Files.App/Services/Settings/DevToolsSettingsService.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ namespace Files.App.Services.Settings
55
{
66
internal sealed partial class DevToolsSettingsService : BaseObservableJsonSettings, IDevToolsSettingsService
77
{
8-
private bool _isVSCodeInstalled = SoftwareHelpers.IsVSCodeInstalled();
9-
108
public DevToolsSettingsService(ISettingsSharingContext settingsSharingContext)
119
{
1210
// Register root
@@ -23,14 +21,14 @@ public OpenInIDEOption OpenInIDEOption
2321
/// <inheritdoc/>
2422
public string IDEPath
2523
{
26-
get => Get(_isVSCodeInstalled ? "code" : string.Empty) ?? string.Empty;
24+
get => Get(SoftwareHelpers.IsVSCodeInstalled() ? "code" : string.Empty) ?? string.Empty;
2725
set => Set(value);
2826
}
2927

3028
/// <inheritdoc/>
31-
public string FriendlyIDEName
29+
public string IDEFriendlyName
3230
{
33-
get => Get(_isVSCodeInstalled ? Strings.VisualStudioCode.GetLocalizedResource() : string.Empty) ?? string.Empty;
31+
get => Get(SoftwareHelpers.IsVSCodeInstalled() ? Strings.VisualStudioCode.GetLocalizedResource() : string.Empty) ?? string.Empty;
3432
set => Set(value);
3533
}
3634

src/Files.App/ViewModels/Settings/DevToolsViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public DevToolsViewModel()
102102
SelectedOpenInIDEOption = OpenInIDEOptions[DevToolsSettingsService.OpenInIDEOption];
103103

104104
IDEPath = DevToolsSettingsService.IDEPath;
105-
IDEFriendlyName = DevToolsSettingsService.FriendlyIDEName;
105+
IDEFriendlyName = DevToolsSettingsService.IDEFriendlyName;
106106
IsIDEPathValid = true;
107107
IsFriendlyNameValid = true;
108108

@@ -149,7 +149,7 @@ private void DoCancelIDEChanges()
149149
{
150150
IsEditingIDEConfig = false;
151151
IDEPath = DevToolsSettingsService.IDEPath;
152-
IDEFriendlyName = DevToolsSettingsService.FriendlyIDEName;
152+
IDEFriendlyName = DevToolsSettingsService.IDEFriendlyName;
153153
IsIDEPathValid = true;
154154
IsFriendlyNameValid = true;
155155
}
@@ -160,7 +160,7 @@ private void DoSaveIDEChanges()
160160
IsIDEPathValid = true;
161161
IsFriendlyNameValid = true;
162162
DevToolsSettingsService.IDEPath = IDEPath;
163-
DevToolsSettingsService.FriendlyIDEName = IDEFriendlyName;
163+
DevToolsSettingsService.IDEFriendlyName = IDEFriendlyName;
164164
}
165165

166166
private void DoStartEditingIDE()

src/Files.App/Views/Settings/DevToolsPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
1212
xmlns:uc="using:Files.App.UserControls"
1313
xmlns:vm="using:Files.App.ViewModels.Settings"
14-
xmlns:wctconverters="using:CommunityToolkit.WinUI.UI.Converters"
14+
xmlns:wctconverters="using:CommunityToolkit.WinUI.Converters"
1515
mc:Ignorable="d">
1616

1717
<Page.Resources>

0 commit comments

Comments
 (0)