11// Copyright (c) Files Community
22// Licensed under the MIT License.
33
4+ using Microsoft . UI . Xaml . Controls ;
5+
46namespace Files . App . Actions
5- {
7+ {
68 internal sealed class OpenRepoInIDEAction : ObservableObject , IAction
79 {
810 private readonly IDevToolsSettingsService _devToolsSettingsService ;
@@ -28,12 +30,15 @@ public OpenRepoInIDEAction()
2830 _devToolsSettingsService . PropertyChanged += DevSettings_PropertyChanged ;
2931 }
3032
31- public Task ExecuteAsync ( object ? parameter = null )
33+ public async Task ExecuteAsync ( object ? parameter = null )
3234 {
33- return Win32Helper . RunPowershellCommandAsync (
35+ var res = await Win32Helper . RunPowershellCommandAsync (
3436 $ "& \' { _devToolsSettingsService . IDEPath } \' \' { _context . ShellPage ! . InstanceViewModel . GitRepositoryPath } \' ",
3537 PowerShellExecutionOptions . Hidden
3638 ) ;
39+
40+ if ( ! res )
41+ await ShowErrorDialog ( ) ;
3742 }
3843
3944 private void Context_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
@@ -54,5 +59,24 @@ private void DevSettings_PropertyChanged(object? sender, PropertyChangedEventArg
5459 OnPropertyChanged ( nameof ( Description ) ) ;
5560 }
5661 }
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+ }
5781 }
5882}
0 commit comments