redis: rename key command

This commit is contained in:
Jan Prochazka
2022-03-27 13:06:39 +02:00
parent 1f0ae98c88
commit e06894372f

View File

@@ -5,6 +5,7 @@
import { plusExpandIcon } from '../icons/expandIcons'; import { plusExpandIcon } from '../icons/expandIcons';
import FontIcon from '../icons/FontIcon.svelte'; import FontIcon from '../icons/FontIcon.svelte';
import ConfirmModal from '../modals/ConfirmModal.svelte'; import ConfirmModal from '../modals/ConfirmModal.svelte';
import InputTextModal from '../modals/InputTextModal.svelte';
import { showModal } from '../modals/modalTools'; import { showModal } from '../modals/modalTools';
import newQuery from '../query/newQuery'; import newQuery from '../query/newQuery';
import { activeDbKeysStore } from '../stores'; import { activeDbKeysStore } from '../stores';
@@ -30,7 +31,7 @@
function createMenu() { function createMenu() {
return [ return [
item.key != null && { item.key != null && {
label: 'Delete', label: 'Delete key',
onClick: () => { onClick: () => {
showModal(ConfirmModal, { showModal(ConfirmModal, {
message: `Really delete key ${item.key}?`, message: `Really delete key ${item.key}?`,
@@ -49,35 +50,56 @@
}); });
}, },
}, },
item.type == 'dir' && [ item.key != null && {
{ label: 'Rename key',
label: 'Reload', onClick: () => {
onClick: () => { showModal(InputTextModal, {
reloadToken += 1; value: item.key,
}, label: 'New name',
}, header: 'Rename key',
{ onConfirm: async newName => {
label: 'Delete branch', await apiCall('database-connections/call-method', {
onClick: () => { conid,
const branch = `${item.root}:*`; database,
showModal(ConfirmModal, { method: 'rename',
message: `Really delete branch ${branch} with all keys?`, args: [item.key, newName],
onConfirm: async () => { });
await apiCall('database-connections/call-method', {
conid,
database,
method: 'mdel',
args: [branch],
});
if (onRefreshParent) { if (onRefreshParent) {
onRefreshParent(); onRefreshParent();
} }
}, },
}); });
},
}, },
], },
item.type == 'dir' && {
label: 'Reload',
onClick: () => {
reloadToken += 1;
},
},
item.type == 'dir' && {
label: 'Delete branch',
onClick: () => {
const branch = `${item.root}:*`;
showModal(ConfirmModal, {
message: `Really delete branch ${branch} with all keys?`,
onConfirm: async () => {
await apiCall('database-connections/call-method', {
conid,
database,
method: 'mdel',
args: [branch],
});
if (onRefreshParent) {
onRefreshParent();
}
},
});
},
},
,
{ {
label: 'Generate script', label: 'Generate script',
onClick: async () => { onClick: async () => {