1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00

ExportTemplates command

This commit is contained in:
Andrew Simachev 2021-05-21 11:31:19 +03:00
parent 1510ef44e4
commit 07f1d6646e
3 changed files with 37 additions and 1 deletions

View file

@ -554,6 +554,10 @@ function menuInit () {
{
label: 'Dev Tools', accelerator: 'Alt+CmdOrCtrl+I',
click: () => { win.webContents.openDevTools(); }
},
{
label: 'Export templates',
click: () => { send('command', 'exportTemplates'); }
}
]
});

View file

@ -514,6 +514,8 @@ class App extends React.Component<Props, State> {
onCommand (e: any, key: string) {
const rootId = keyboard.getRootId();
let options: any = {};
switch (key) {
case 'undo':
C.BlockUndo(rootId);
@ -528,7 +530,7 @@ class App extends React.Component<Props, State> {
break;
case 'save':
const options: any = {
options = {
properties: [ 'openDirectory' ],
};
@ -547,6 +549,27 @@ class App extends React.Component<Props, State> {
});
});
break;
case 'exportTemplates':
options = {
properties: [ 'openDirectory' ],
};
dialog.showOpenDialog(options).then((result: any) => {
const files = result.filePaths;
if ((files == undefined) || !files.length) {
return;
};
C.ExportTemplates(files[0], (message: any) => {
if (message.error.code) {
return;
};
ipcRenderer.send('pathOpen', files[0]);
});
});
break;
};
};

View file

@ -58,6 +58,14 @@ const Export = (path: string, ids: string[], format: I.ExportFormat, zip: boolea
dispatcher.request('export', request, callBack);
};
const ExportTemplates = (path: string, callBack?: (message: any) => void) => {
const request = new Rpc.ExportTemplates.Request();
request.setPath(path);
dispatcher.request('exportTemplates', request, callBack);
};
const UploadFile = (url: string, path: string, type: I.FileType, enc: boolean, callBack?: (message: any) => void) => {
if (!url && !path) {
return;
@ -966,6 +974,7 @@ export {
UploadFile,
ProcessCancel,
Export,
ExportTemplates,
WalletCreate,
WalletRecover,