redis: hide write operations when connection is readonly

This commit is contained in:
Jan Prochazka
2022-03-27 18:39:42 +02:00
parent 0e8166577f
commit a20a34680d
3 changed files with 27 additions and 23 deletions

View File

@@ -16,6 +16,7 @@
export let indentLevel = 0; export let indentLevel = 0;
export let reloadToken = 0; export let reloadToken = 0;
export let connection;
let reloadToken2 = 0; let reloadToken2 = 0;
let maxShowCount = SHOW_INCREMENT; let maxShowCount = SHOW_INCREMENT;
@@ -33,6 +34,7 @@
{conid} {conid}
{database} {database}
{root} {root}
{connection}
{item} {item}
{indentLevel} {indentLevel}
onRefreshParent={() => { onRefreshParent={() => {

View File

@@ -12,6 +12,7 @@
import { showModal } from '../modals/modalTools'; import { showModal } from '../modals/modalTools';
import { currentDatabase, getExtensions } from '../stores'; import { currentDatabase, getExtensions } from '../stores';
import { apiCall } from '../utility/api'; import { apiCall } from '../utility/api';
import { useConnectionInfo } from '../utility/metadataLoaders';
import DbKeysSubTree from './DbKeysSubTree.svelte'; import DbKeysSubTree from './DbKeysSubTree.svelte';
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte'; import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
@@ -62,5 +63,5 @@
</InlineButton> </InlineButton>
</SearchBoxWrapper> </SearchBoxWrapper>
<WidgetsInnerContainer> <WidgetsInnerContainer>
<DbKeysSubTree {conid} {database} root="" {reloadToken} /> <DbKeysSubTree {conid} {database} root="" {reloadToken} connection={$currentDatabase?.connection} />
</WidgetsInnerContainer> </WidgetsInnerContainer>

View File

@@ -17,6 +17,7 @@
export let conid; export let conid;
export let database; export let database;
export let connection;
export let root; export let root;
@@ -29,8 +30,7 @@
let reloadToken = 0; let reloadToken = 0;
// $: console.log(item.text, indentLevel); // $: console.log(item.text, indentLevel);
async function createMenu() { function createMenu() {
const connection = await getConnectionInfo({ conid });
return [ return [
item.key != null && item.key != null &&
!connection?.isReadOnly && { !connection?.isReadOnly && {
@@ -83,27 +83,28 @@
reloadToken += 1; reloadToken += 1;
}, },
}, },
item.type == 'dir' && { item.type == 'dir' &&
label: 'Delete branch', !connection?.isReadOnly && {
onClick: () => { label: 'Delete branch',
const branch = `${item.root}:*`; onClick: () => {
showModal(ConfirmModal, { const branch = `${item.root}:*`;
message: `Really delete branch ${branch} with all keys?`, showModal(ConfirmModal, {
onConfirm: async () => { message: `Really delete branch ${branch} with all keys?`,
await apiCall('database-connections/call-method', { onConfirm: async () => {
conid, await apiCall('database-connections/call-method', {
database, conid,
method: 'mdel', database,
args: [branch], method: 'mdel',
}); args: [branch],
});
if (onRefreshParent) { if (onRefreshParent) {
onRefreshParent(); onRefreshParent();
} }
}, },
}); });
},
}, },
},
, ,
{ {
label: 'Generate script', label: 'Generate script',
@@ -169,5 +170,5 @@
</div> --> </div> -->
{#if isExpanded} {#if isExpanded}
<DbKeysSubTree {conid} {database} root={item.root} indentLevel={indentLevel + 1} {reloadToken} /> <DbKeysSubTree {conid} {database} root={item.root} indentLevel={indentLevel + 1} {reloadToken} {connection} />
{/if} {/if}