diff --git a/src/Aiplugs.PoshApp/ElectronIpc.cs b/src/Aiplugs.PoshApp/ElectronIpc.cs index 02555d3..39a7c2c 100644 --- a/src/Aiplugs.PoshApp/ElectronIpc.cs +++ b/src/Aiplugs.PoshApp/ElectronIpc.cs @@ -6,7 +6,7 @@ namespace Aiplugs.PoshApp { public class ElectronIpc { - public static void Setup() + public static async void Setup() { var menu = new MenuItem[] { new MenuItem { @@ -55,18 +55,47 @@ public static void Setup() Electron.Menu.SetApplicationMenu(menu); + Electron.IpcMain.On("select-repository-path", async (args) => + { + var mainWindow = Electron.WindowManager.BrowserWindows.First(); + var options = new OpenDialogOptions + { + Properties = new OpenDialogProperty[] { + OpenDialogProperty.openDirectory, + } + }; + + string[] dirs = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options); + Electron.IpcMain.Send(mainWindow, "select-repository-path-reply", dirs.First()); + }); + Electron.IpcMain.On("select-directory", async (args) => { var mainWindow = Electron.WindowManager.BrowserWindows.First(); var options = new OpenDialogOptions { Properties = new OpenDialogProperty[] { - OpenDialogProperty.openDirectory - } + OpenDialogProperty.openDirectory, + } + }; + + string[] dirs = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options); + Electron.IpcMain.Send(mainWindow, "select-directory-reply", dirs.First(), args); + }); + + Electron.IpcMain.On("select-directories", async (args) => + { + var mainWindow = Electron.WindowManager.BrowserWindows.First(); + var options = new OpenDialogOptions + { + Properties = new OpenDialogProperty[] { + OpenDialogProperty.openDirectory, + OpenDialogProperty.multiSelections, + } }; string[] dirs = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options); - Electron.IpcMain.Send(mainWindow, "select-directory-reply", dirs, args); + Electron.IpcMain.Send(mainWindow, "select-directories-reply", dirs, args); }); Electron.IpcMain.On("select-file", async (args) => @@ -76,11 +105,26 @@ public static void Setup() { Properties = new OpenDialogProperty[] { OpenDialogProperty.openFile, - } + } }; - string[] dirs = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options); - Electron.IpcMain.Send(mainWindow, "select-file-reply", dirs, args); + string[] files = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options); + Electron.IpcMain.Send(mainWindow, "select-file-reply", files.First(), args); + }); + + Electron.IpcMain.On("select-files", async (args) => + { + var mainWindow = Electron.WindowManager.BrowserWindows.First(); + var options = new OpenDialogOptions + { + Properties = new OpenDialogProperty[] { + OpenDialogProperty.openFile, + OpenDialogProperty.multiSelections, + } + }; + + string[] files = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options); + Electron.IpcMain.Send(mainWindow, "select-files-reply", files, args); }); Electron.IpcMain.On("open-activation", async (args) => @@ -93,10 +137,7 @@ public static void Setup() Electron.Clipboard.WriteText(text.ToString()); }); - Electron.IpcMain.On("check-update", async (args) => - { - await Electron.AutoUpdater.CheckForUpdatesAndNotifyAsync(); - }); + await Electron.AutoUpdater.CheckForUpdatesAndNotifyAsync(); } } } diff --git a/src/Aiplugs.PoshApp/Startup.cs b/src/Aiplugs.PoshApp/Startup.cs index f3b49a6..db45bbf 100644 --- a/src/Aiplugs.PoshApp/Startup.cs +++ b/src/Aiplugs.PoshApp/Startup.cs @@ -81,6 +81,7 @@ await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions Title = "POSH App", Width = 1152, Height = 864, + AutoHideMenuBar = true, Show = true, }); } diff --git a/src/Aiplugs.PoshApp/Views/Shared/PowershellUI/Prompt.cshtml b/src/Aiplugs.PoshApp/Views/Shared/PowershellUI/Prompt.cshtml index 2d6346a..b466b68 100644 --- a/src/Aiplugs.PoshApp/Views/Shared/PowershellUI/Prompt.cshtml +++ b/src/Aiplugs.PoshApp/Views/Shared/PowershellUI/Prompt.cshtml @@ -94,10 +94,20 @@ this.dialog = false; }, openDirManager(desc) { - ipcRenderer.send('select-directory', desc.name); - }, + if (desc.parameterTypeFullName.endsWith('[]') || desc.parameterTypeFullName.startsWith('IEnumerable')) { + ipcRenderer.send('select-directories', desc.name); + } + else { + ipcRenderer.send('select-directory', desc.name); + } + }, openFileManager(desc) { - ipcRenderer.send('select-file', desc.name); + if (desc.parameterTypeFullName.endsWith('[]') || desc.parameterTypeFullName.startsWith('IEnumerable')) { + ipcRenderer.send('select-files', desc.name); + } + else { + ipcRenderer.send('select-file', desc.name); + } } }, mounted() { @@ -111,7 +121,13 @@ this.dialog = true; this.$refs.form.reset(); }) - ipcRenderer.on('select-directory-reply', (sender, path, name) => { + ipcRenderer.on('select-directories-reply', (sender, path, name) => { + this.value[name] = path; + }); + ipcRenderer.on('select-director-reply', (sender, path, name) => { + this.value[name] = path; + }); + ipcRenderer.on('select-files-reply', (sender, path, name) => { this.value[name] = path; }); ipcRenderer.on('select-file-reply', (sender, path, name) => { diff --git a/src/Aiplugs.PoshApp/Views/Shared/Repositories/Nav.cshtml b/src/Aiplugs.PoshApp/Views/Shared/Repositories/Nav.cshtml index dbbd62f..2cd80ee 100644 --- a/src/Aiplugs.PoshApp/Views/Shared/Repositories/Nav.cshtml +++ b/src/Aiplugs.PoshApp/Views/Shared/Repositories/Nav.cshtml @@ -83,7 +83,7 @@ - + Are you sure you want to Delete? @@ -115,7 +115,7 @@ v => /^[a-zA-Z0-9_]*$/.test(v) || 'Valid characters are A-Z a-z 0-9 _' ], pathRules: [ - v => !!v || 'Repository Name is required' + v => !!v || 'Repository Path is required' ], originRules: [ v => this.repositoryType == 'local' || !!v || 'Origin Url is required' @@ -126,6 +126,9 @@ computed: { ...Vuex.mapState('repositories', ['repositories']), ...Vuex.mapGetters('activation', ['exceededFreePlanForRepositories']), + deleteDialog() { + return this.deleteTarget != null; + } }, methods: { ...Vuex.mapActions('repositories', ['loadRepositories', 'createRepository', 'updateRepository', 'deleteRepository']), @@ -201,12 +204,12 @@ this.deleteTarget = repository; }, openFileManager() { - ipcRenderer.send('select-directory', '$repository'); + ipcRenderer.send('select-repository-path'); } }, async mounted() { await this.loadRepositories(); - ipcRenderer.on('select-directory-reply', (sender, path) => { + ipcRenderer.on('select-repository-path-reply', (sender, path) => { this.path = path; }); this.$signalr.on('GitCloneFaild', name => { @@ -214,7 +217,7 @@ }); }, beforeRouteLeave (to, from , next) { - ipcRenderer.removeAllListeners('select-directory-reply'); + ipcRenderer.removeAllListeners('select-repository-path-reply'); this.$signalr.off('GitCloneFaild'); next(); } diff --git a/src/Aiplugs.PoshApp/electron.manifest.json b/src/Aiplugs.PoshApp/electron.manifest.json index 72f9c7c..1f9b417 100644 --- a/src/Aiplugs.PoshApp/electron.manifest.json +++ b/src/Aiplugs.PoshApp/electron.manifest.json @@ -8,7 +8,7 @@ "appId": "com.aiplugs.poshapp", "productName": "POSH App", "copyright": "Copyright © 2019", - "buildVersion": "0.9.7", + "buildVersion": "0.9.9", "compression": "maximum", "directories": { "output": "../../../bin/Desktop"