mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 01:03:58 +00:00
table editor permissions
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
icon: 'icon add-column',
|
icon: 'icon add-column',
|
||||||
toolbar: true,
|
toolbar: true,
|
||||||
isRelatedToTab: true,
|
isRelatedToTab: true,
|
||||||
testEnabled: () => getCurrentEditor()?.writable(),
|
testEnabled: () => getCurrentEditor()?.getIsWritable(),
|
||||||
onClick: () => getCurrentEditor().addColumn(),
|
onClick: () => getCurrentEditor().addColumn(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
icon: 'icon add-key',
|
icon: 'icon add-key',
|
||||||
toolbar: true,
|
toolbar: true,
|
||||||
isRelatedToTab: true,
|
isRelatedToTab: true,
|
||||||
testEnabled: () => getCurrentEditor()?.writable(),
|
testEnabled: () => getCurrentEditor()?.getIsWritable(),
|
||||||
onClick: () => getCurrentEditor().addForeignKey(),
|
onClick: () => getCurrentEditor().addForeignKey(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
icon: 'icon add-key',
|
icon: 'icon add-key',
|
||||||
toolbar: true,
|
toolbar: true,
|
||||||
isRelatedToTab: true,
|
isRelatedToTab: true,
|
||||||
testEnabled: () => getCurrentEditor()?.writable(),
|
testEnabled: () => getCurrentEditor()?.getIsWritable(),
|
||||||
onClick: () => getCurrentEditor().addIndex(),
|
onClick: () => getCurrentEditor().addIndex(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
icon: 'icon add-key',
|
icon: 'icon add-key',
|
||||||
toolbar: true,
|
toolbar: true,
|
||||||
isRelatedToTab: true,
|
isRelatedToTab: true,
|
||||||
testEnabled: () => getCurrentEditor()?.writable(),
|
testEnabled: () => getCurrentEditor()?.getIsWritable(),
|
||||||
onClick: () => getCurrentEditor().addUnique(),
|
onClick: () => getCurrentEditor().addUnique(),
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -89,8 +89,10 @@
|
|||||||
export let dbInfo;
|
export let dbInfo;
|
||||||
export let driver;
|
export let driver;
|
||||||
|
|
||||||
export function writable() {
|
$: isWritable = !!setTableInfo;
|
||||||
return !!setTableInfo;
|
|
||||||
|
export function getIsWritable() {
|
||||||
|
return isWritable;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addColumn() {
|
export function addColumn() {
|
||||||
@@ -106,7 +108,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function allowAddPrimaryKey() {
|
export function allowAddPrimaryKey() {
|
||||||
return writable() && !tableInfo?.primaryKey;
|
return isWritable && !tableInfo?.primaryKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addPrimaryKey() {
|
export function addPrimaryKey() {
|
||||||
@@ -158,9 +160,9 @@
|
|||||||
collection={columns?.map((x, index) => ({ ...x, ordinal: index + 1 }))}
|
collection={columns?.map((x, index) => ({ ...x, ordinal: index + 1 }))}
|
||||||
title={`Columns (${columns?.length || 0})`}
|
title={`Columns (${columns?.length || 0})`}
|
||||||
emptyMessage="No columns defined"
|
emptyMessage="No columns defined"
|
||||||
clickable={writable()}
|
clickable
|
||||||
on:clickrow={e => showModal(ColumnEditorModal, { columnInfo: e.detail, tableInfo, setTableInfo, driver })}
|
on:clickrow={e => showModal(ColumnEditorModal, { columnInfo: e.detail, tableInfo, setTableInfo, driver })}
|
||||||
onAddNew={writable() ? addColumn : null}
|
onAddNew={isWritable ? addColumn : null}
|
||||||
columns={[
|
columns={[
|
||||||
{
|
{
|
||||||
fieldName: 'notNull',
|
fieldName: 'notNull',
|
||||||
@@ -212,7 +214,7 @@
|
|||||||
header: 'Comment',
|
header: 'Comment',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
writable()
|
isWritable
|
||||||
? {
|
? {
|
||||||
fieldName: 'actions',
|
fieldName: 'actions',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
@@ -240,9 +242,9 @@
|
|||||||
<ObjectListControl
|
<ObjectListControl
|
||||||
collection={_.compact([primaryKey])}
|
collection={_.compact([primaryKey])}
|
||||||
title="Primary key"
|
title="Primary key"
|
||||||
emptyMessage={writable() ? 'No primary key defined' : null}
|
emptyMessage={isWritable ? 'No primary key defined' : null}
|
||||||
onAddNew={writable() && !primaryKey && columns?.length > 0 ? addPrimaryKey : null}
|
onAddNew={isWritable && !primaryKey && columns?.length > 0 ? addPrimaryKey : null}
|
||||||
clickable={writable()}
|
clickable
|
||||||
on:clickrow={e => showModal(PrimaryKeyEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo })}
|
on:clickrow={e => showModal(PrimaryKeyEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo })}
|
||||||
columns={[
|
columns={[
|
||||||
{
|
{
|
||||||
@@ -250,7 +252,7 @@
|
|||||||
header: 'Columns',
|
header: 'Columns',
|
||||||
slot: 0,
|
slot: 0,
|
||||||
},
|
},
|
||||||
writable()
|
isWritable
|
||||||
? {
|
? {
|
||||||
fieldName: 'actions',
|
fieldName: 'actions',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
@@ -273,10 +275,10 @@
|
|||||||
|
|
||||||
<ObjectListControl
|
<ObjectListControl
|
||||||
collection={indexes}
|
collection={indexes}
|
||||||
onAddNew={writable() && columns?.length > 0 ? addIndex : null}
|
onAddNew={isWritable && columns?.length > 0 ? addIndex : null}
|
||||||
title={`Indexes (${indexes?.length || 0})`}
|
title={`Indexes (${indexes?.length || 0})`}
|
||||||
emptyMessage={writable() ? 'No index defined' : null}
|
emptyMessage={isWritable ? 'No index defined' : null}
|
||||||
clickable={writable()}
|
clickable
|
||||||
on:clickrow={e => showModal(IndexEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo })}
|
on:clickrow={e => showModal(IndexEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo })}
|
||||||
columns={[
|
columns={[
|
||||||
{
|
{
|
||||||
@@ -289,7 +291,7 @@
|
|||||||
header: 'Unique',
|
header: 'Unique',
|
||||||
slot: 1,
|
slot: 1,
|
||||||
},
|
},
|
||||||
writable()
|
isWritable
|
||||||
? {
|
? {
|
||||||
fieldName: 'actions',
|
fieldName: 'actions',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
@@ -313,10 +315,10 @@
|
|||||||
|
|
||||||
<ObjectListControl
|
<ObjectListControl
|
||||||
collection={uniques}
|
collection={uniques}
|
||||||
onAddNew={writable() && columns?.length > 0 ? addUnique : null}
|
onAddNew={isWritable && columns?.length > 0 ? addUnique : null}
|
||||||
title={`Unique constraints (${uniques?.length || 0})`}
|
title={`Unique constraints (${uniques?.length || 0})`}
|
||||||
emptyMessage={writable() ? 'No unique defined' : null}
|
emptyMessage={isWritable ? 'No unique defined' : null}
|
||||||
clickable={writable()}
|
clickable
|
||||||
on:clickrow={e => showModal(UniqueEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo })}
|
on:clickrow={e => showModal(UniqueEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo })}
|
||||||
columns={[
|
columns={[
|
||||||
{
|
{
|
||||||
@@ -324,7 +326,7 @@
|
|||||||
header: 'Columns',
|
header: 'Columns',
|
||||||
slot: 0,
|
slot: 0,
|
||||||
},
|
},
|
||||||
writable()
|
isWritable
|
||||||
? {
|
? {
|
||||||
fieldName: 'actions',
|
fieldName: 'actions',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
@@ -347,10 +349,10 @@
|
|||||||
|
|
||||||
<ForeignKeyObjectListControl
|
<ForeignKeyObjectListControl
|
||||||
collection={foreignKeys}
|
collection={foreignKeys}
|
||||||
onAddNew={writable() && columns?.length > 0 ? addForeignKey : null}
|
onAddNew={isWritable && columns?.length > 0 ? addForeignKey : null}
|
||||||
title={`Foreign keys (${foreignKeys?.length || 0})`}
|
title={`Foreign keys (${foreignKeys?.length || 0})`}
|
||||||
emptyMessage={writable() ? 'No foreign key defined' : null}
|
emptyMessage={isWritable ? 'No foreign key defined' : null}
|
||||||
clickable={writable()}
|
clickable
|
||||||
onRemove={row => setTableInfo(tbl => editorDeleteConstraint(tbl, row))}
|
onRemove={row => setTableInfo(tbl => editorDeleteConstraint(tbl, row))}
|
||||||
on:clickrow={e => showModal(ForeignKeyEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo, dbInfo })}
|
on:clickrow={e => showModal(ForeignKeyEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo, dbInfo })}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user