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,14 +50,35 @@
}); });
}, },
}, },
item.type == 'dir' && [ item.key != null && {
{ label: 'Rename key',
onClick: () => {
showModal(InputTextModal, {
value: item.key,
label: 'New name',
header: 'Rename key',
onConfirm: async newName => {
await apiCall('database-connections/call-method', {
conid,
database,
method: 'rename',
args: [item.key, newName],
});
if (onRefreshParent) {
onRefreshParent();
}
},
});
},
},
item.type == 'dir' && {
label: 'Reload', label: 'Reload',
onClick: () => { onClick: () => {
reloadToken += 1; reloadToken += 1;
}, },
}, },
{ item.type == 'dir' && {
label: 'Delete branch', label: 'Delete branch',
onClick: () => { onClick: () => {
const branch = `${item.root}:*`; const branch = `${item.root}:*`;
@@ -77,7 +99,7 @@
}); });
}, },
}, },
], ,
{ {
label: 'Generate script', label: 'Generate script',
onClick: async () => { onClick: async () => {