This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose save/open dialogs to plugins (#1793)
- Loading branch information
Showing
7 changed files
with
77 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/renderer/services/plugin-manager/sandbox/dialogs-sandbox.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { PLUGINS } from '@config' | ||
import electron from '@/mixins/electron' | ||
import { ensureDirSync } from 'fs-extra' | ||
import path from 'path' | ||
|
||
export function create (walletApi) { | ||
return () => { | ||
walletApi.dialogs = { | ||
save: async (raw, filename, filters) => { | ||
ensureDirSync(PLUGINS.sharePath) | ||
|
||
return electron.methods.electron_writeFile(raw, path.resolve(PLUGINS.sharePath, filename), { | ||
restrictToPath: PLUGINS.sharePath, | ||
filters | ||
}) | ||
}, | ||
|
||
open: async (filters) => { | ||
return electron.methods.electron_readFile(PLUGINS.sharePath, { filters }) | ||
} | ||
} | ||
} | ||
} |