mirror of
https://github.com/dbgate/dbgate
synced 2024-11-10 05:36:29 +00:00
try to guess desired import target+preselect it
This commit is contained in:
parent
a96851b38f
commit
5cc78c4e50
@ -272,7 +272,7 @@ registerCommand({
|
||||
icon: 'icon import',
|
||||
onClick: () =>
|
||||
showModal(ImportExportModal, {
|
||||
importToArchive: true,
|
||||
importToCurrentTarget: true,
|
||||
initialValues: { sourceStorageType: getDefaultFileFormat(get(extensions)).storageType },
|
||||
}),
|
||||
});
|
||||
|
@ -15,7 +15,7 @@
|
||||
import { getDefaultFileFormat } from '../plugins/fileformats';
|
||||
import RunnerOutputFiles from '../query/RunnerOutputFiles.svelte';
|
||||
import SocketMessageView from '../query/SocketMessageView.svelte';
|
||||
import { currentArchive, extensions, selectedWidget } from '../stores';
|
||||
import { currentArchive, currentDatabase, extensions, selectedWidget } from '../stores';
|
||||
import axiosInstance from '../utility/axiosInstance';
|
||||
import createRef from '../utility/createRef';
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
@ -35,11 +35,35 @@
|
||||
export let initialValues;
|
||||
export let uploadedFile = undefined;
|
||||
export let openedFile = undefined;
|
||||
export let importToArchive = false;
|
||||
export let importToCurrentTarget = false;
|
||||
|
||||
const refreshArchiveFolderRef = createRef(null);
|
||||
|
||||
$: targetArchiveFolder = importToArchive ? `import-${moment().format('YYYY-MM-DD-hh-mm-ss')}` : $currentArchive;
|
||||
function detectCurrentTarget() {
|
||||
if (!importToCurrentTarget) return {};
|
||||
|
||||
if ($currentDatabase && $selectedWidget != 'archive') {
|
||||
return {
|
||||
targetStorageType: 'database',
|
||||
targetConnectionId: $currentDatabase?.connection?._id,
|
||||
targetDatabaseName: $currentDatabase?.name,
|
||||
};
|
||||
}
|
||||
|
||||
if ($currentArchive == 'default') {
|
||||
return {
|
||||
targetStorageType: 'archive',
|
||||
targetArchiveFolder: `import-${moment().format('YYYY-MM-DD-hh-mm-ss')}`,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
targetStorageType: 'archive',
|
||||
targetArchiveFolder: $currentArchive,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// $: targetArchiveFolder = importToArchive ? `import-${moment().format('YYYY-MM-DD-hh-mm-ss')}` : $currentArchive;
|
||||
|
||||
$: effect = useEffect(() => registerRunnerDone(runnerId));
|
||||
|
||||
@ -107,9 +131,10 @@
|
||||
<FormProvider
|
||||
initialValues={{
|
||||
sourceStorageType: 'database',
|
||||
targetStorageType: importToArchive ? 'archive' : getDefaultFileFormat($extensions).storageType,
|
||||
targetStorageType: getDefaultFileFormat($extensions).storageType,
|
||||
targetArchiveFolder: $currentArchive,
|
||||
sourceArchiveFolder: $currentArchive,
|
||||
targetArchiveFolder,
|
||||
...detectCurrentTarget(),
|
||||
...initialValues,
|
||||
}}
|
||||
>
|
||||
|
@ -89,7 +89,7 @@ export function openElectronFileCore(filePath, extensions) {
|
||||
storageType: format.storageType,
|
||||
shortName: parsed.name,
|
||||
},
|
||||
importToArchive: true,
|
||||
importToCurrentTarget: true,
|
||||
initialValues: {
|
||||
sourceStorageType: format.storageType,
|
||||
},
|
||||
|
@ -66,7 +66,7 @@ export default function uploadFiles(files) {
|
||||
if (findFileFormat(ext, fileData.storageType)) {
|
||||
showModal(ImportExportModal, {
|
||||
uploadedFile: fileData,
|
||||
importToArchive: true,
|
||||
importToCurrentTarget: true,
|
||||
initialValues: {
|
||||
sourceStorageType: fileData.storageType,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user