mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 20:06:00 +00:00
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import type { QuickExportDefinition } from 'dbgate-types';
|
|
import { currentArchive, getCurrentArchive, getExtensions } from '../stores';
|
|
import hasPermission from './hasPermission';
|
|
import { _t } from '../translations'
|
|
import { isProApp } from './proTools';
|
|
|
|
export function createQuickExportMenuItems(handler: (fmt: QuickExportDefinition) => Function, advancedExportMenuItem) {
|
|
const extensions = getExtensions();
|
|
return [
|
|
isProApp() && {
|
|
text: _t('export.exportAdvanced', { defaultMessage : 'Export advanced...'}),
|
|
...advancedExportMenuItem,
|
|
},
|
|
{ divider: true },
|
|
...extensions.quickExports.map(fmt => ({
|
|
text: fmt.label,
|
|
onClick: handler(fmt),
|
|
})),
|
|
{ divider: true },
|
|
isProApp() && {
|
|
text: _t('export.currentArchive', { defaultMessage : 'Current archive'}),
|
|
onClick: handler({
|
|
extension: 'jsonl',
|
|
label: _t('export.currentArchive', { defaultMessage : 'Current archive'}),
|
|
noFilenameDependency: true,
|
|
createWriter: (fileName, dataName) => ({
|
|
functionName: 'archiveWriter',
|
|
props: {
|
|
fileName: dataName,
|
|
folderName: getCurrentArchive(),
|
|
},
|
|
}),
|
|
}),
|
|
},
|
|
];
|
|
}
|
|
|
|
export default function createQuickExportMenu(
|
|
handler: (fmt: QuickExportDefinition) => Function,
|
|
advancedExportMenuItem,
|
|
additionalFields = {}
|
|
) {
|
|
if (!hasPermission('dbops/export')) {
|
|
return null;
|
|
}
|
|
|
|
return {
|
|
text: 'Export',
|
|
submenu: createQuickExportMenuItems(handler, advancedExportMenuItem),
|
|
...additionalFields,
|
|
};
|
|
}
|