Skip to content

Commit

Permalink
fix filemanager
Browse files Browse the repository at this point in the history
  • Loading branch information
iwate committed Feb 21, 2020
1 parent c4b916e commit 996f6eb
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 21 deletions.
63 changes: 52 additions & 11 deletions src/Aiplugs.PoshApp/ElectronIpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) =>
Expand All @@ -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) =>
Expand All @@ -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();
}
}
}
1 change: 1 addition & 0 deletions src/Aiplugs.PoshApp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
Title = "POSH App",
Width = 1152,
Height = 864,
AutoHideMenuBar = true,
Show = true,
});
}
Expand Down
24 changes: 20 additions & 4 deletions src/Aiplugs.PoshApp/Views/Shared/PowershellUI/Prompt.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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) => {
Expand Down
13 changes: 8 additions & 5 deletions src/Aiplugs.PoshApp/Views/Shared/Repositories/Nav.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-model="deleteTarget" max-width="600">
<v-dialog :value="deleteDialog" max-width="600">
<v-card>
<v-card-title>Are you sure you want to Delete?</v-card-title>
<v-card-actions>
Expand Down Expand Up @@ -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'
Expand All @@ -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']),
Expand Down Expand Up @@ -201,20 +204,20 @@
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 => {
this.deleteRepository({ name });
});
},
beforeRouteLeave (to, from , next) {
ipcRenderer.removeAllListeners('select-directory-reply');
ipcRenderer.removeAllListeners('select-repository-path-reply');
this.$signalr.off('GitCloneFaild');
next();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Aiplugs.PoshApp/electron.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 996f6eb

Please sign in to comment.