From 01888f2538c5648755eb115f79dd37fad5514aff Mon Sep 17 00:00:00 2001 From: Vishal Joshi Date: Mon, 16 Dec 2024 21:03:37 +0530 Subject: [PATCH 1/6] Added Table Permission Modal in Table Card Menu --- mathesar_ui/src/pages/schema/TableCard.svelte | 5 ++- .../table-inspector/table/TableMode.svelte | 2 +- .../table/TablePermissions.svelte | 34 ++++++++++++------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/mathesar_ui/src/pages/schema/TableCard.svelte b/mathesar_ui/src/pages/schema/TableCard.svelte index 0b9afb3a33..5cf452d85c 100644 --- a/mathesar_ui/src/pages/schema/TableCard.svelte +++ b/mathesar_ui/src/pages/schema/TableCard.svelte @@ -29,6 +29,7 @@ Icon, Truncate, } from '@mathesar-component-library'; + import TablePermissions from '@mathesar/systems/table-view/table-inspector/table/TablePermissions.svelte'; const recordSelector = getRecordSelectorFromContext(); @@ -127,7 +128,7 @@ showArrow={false} triggerAppearance="ghost" triggerClass="dropdown-menu-button" - closeOnInnerClick={true} + closeOnInnerClick={false} placements={['bottom-end', 'right-start', 'left-start']} label="" icon={iconMoreActions} @@ -148,6 +149,8 @@ > {$_('edit_table')} + + {/if} - + diff --git a/mathesar_ui/src/systems/table-view/table-inspector/table/TablePermissions.svelte b/mathesar_ui/src/systems/table-view/table-inspector/table/TablePermissions.svelte index 5695cd4a6f..acf94409db 100644 --- a/mathesar_ui/src/systems/table-view/table-inspector/table/TablePermissions.svelte +++ b/mathesar_ui/src/systems/table-view/table-inspector/table/TablePermissions.svelte @@ -15,7 +15,6 @@ import AsyncRpcApiStore from '@mathesar/stores/AsyncRpcApiStore'; import { AsyncStoreValue } from '@mathesar/stores/AsyncStore'; import { modal } from '@mathesar/stores/modal'; - import { getTabularDataStoreFromContext } from '@mathesar/stores/table-data'; import { toast } from '@mathesar/stores/toast'; import { type AccessControlConfig, @@ -23,12 +22,12 @@ PermissionsOverview, TransferOwnership, } from '@mathesar/systems/permissions'; - import { Button, ImmutableMap } from '@mathesar-component-library'; + import { Button, ButtonMenuItem, ImmutableMap } from '@mathesar-component-library'; const controller = modal.spawnModalController(); - const tabularData = getTabularDataStoreFromContext(); - - $: table = $tabularData.table; + + export let table: Table; + export let fromTableCard = false; $: tablePrivileges = table.constructTablePrivilegesStore(); const databaseContext = DatabaseRouteContext.get(); @@ -135,14 +134,23 @@
- + {#if fromTableCard} + controller.open()} + icon={iconPermissions} + > + {$_('table_permissions')} + + {:else} + + {/if}
Date: Wed, 18 Dec 2024 23:03:06 +0530 Subject: [PATCH 2/6] Changed TablePermissions component to TablePermissionsModal --- mathesar_ui/src/pages/schema/TableCard.svelte | 17 ++++++++--- .../table-inspector/table/TableMode.svelte | 22 +++++++++++++-- ...ns.svelte => TablePermissionsModal.svelte} | 28 ++----------------- 3 files changed, 35 insertions(+), 32 deletions(-) rename mathesar_ui/src/systems/table-view/table-inspector/table/{TablePermissions.svelte => TablePermissionsModal.svelte} (84%) diff --git a/mathesar_ui/src/pages/schema/TableCard.svelte b/mathesar_ui/src/pages/schema/TableCard.svelte index 5cf452d85c..1d243f73a3 100644 --- a/mathesar_ui/src/pages/schema/TableCard.svelte +++ b/mathesar_ui/src/pages/schema/TableCard.svelte @@ -8,6 +8,7 @@ iconEdit, iconExploration, iconMoreActions, + iconPermissions, iconSelectRecord, } from '@mathesar/icons'; import type { Database } from '@mathesar/models/Database'; @@ -22,6 +23,7 @@ import { createDataExplorerUrlToExploreATable } from '@mathesar/systems/data-explorer'; import { getRecordSelectorFromContext } from '@mathesar/systems/record-selector/RecordSelectorController'; import TableDeleteConfirmationBody from '@mathesar/systems/table-view/table-inspector/table/TableDeleteConfirmationBody.svelte'; + import TablePermissionsModal from '@mathesar/systems/table-view/table-inspector/table/TablePermissionsModal.svelte'; import { tableRequiresImportConfirmation } from '@mathesar/utils/tables'; import { ButtonMenuItem, @@ -29,7 +31,7 @@ Icon, Truncate, } from '@mathesar-component-library'; - import TablePermissions from '@mathesar/systems/table-view/table-inspector/table/TablePermissions.svelte'; + import { modal } from '@mathesar/stores/modal'; const recordSelector = getRecordSelectorFromContext(); @@ -43,6 +45,7 @@ let isHoveringMenuTrigger = false; let isHoveringBottomButton = false; let isTableCardFocused = false; + const permissionModal = modal.spawnModalController(); $: requiresImportConfirmation = tableRequiresImportConfirmation(table); $: tablePageUrl = requiresImportConfirmation @@ -128,7 +131,7 @@ showArrow={false} triggerAppearance="ghost" triggerClass="dropdown-menu-button" - closeOnInnerClick={false} + closeOnInnerClick={true} placements={['bottom-end', 'right-start', 'left-start']} label="" icon={iconMoreActions} @@ -149,8 +152,12 @@ > {$_('edit_table')}
- - + permissionModal.open()} + icon={iconPermissions} + > + {$_('table_permissions')} + {/if} {/if} + +