From 004db00ce97684956abf93426cffcbd9fdcab889 Mon Sep 17 00:00:00 2001 From: pavish Date: Sun, 14 Jul 2024 16:19:56 +0530 Subject: [PATCH 01/12] Remove existing Access control models --- mathesar_ui/src/i18n/languages/en/dict.json | 1 - .../src/pages/database/DatabaseDetails.svelte | 14 - .../database/DbAccessControlModal.svelte | 68 ----- .../schema/SchemaAccessControlModal.svelte | 85 ------ .../src/pages/schema/SchemaPage.svelte | 19 +- .../AccessControlRow.svelte | 266 ------------------ .../AccessControlView.svelte | 192 ------------- .../systems/users-and-permissions/index.ts | 1 - 8 files changed, 1 insertion(+), 645 deletions(-) delete mode 100644 mathesar_ui/src/pages/database/DbAccessControlModal.svelte delete mode 100644 mathesar_ui/src/pages/schema/SchemaAccessControlModal.svelte delete mode 100644 mathesar_ui/src/systems/users-and-permissions/AccessControlRow.svelte delete mode 100644 mathesar_ui/src/systems/users-and-permissions/AccessControlView.svelte diff --git a/mathesar_ui/src/i18n/languages/en/dict.json b/mathesar_ui/src/i18n/languages/en/dict.json index c2edf16583..cb35003739 100644 --- a/mathesar_ui/src/i18n/languages/en/dict.json +++ b/mathesar_ui/src/i18n/languages/en/dict.json @@ -278,7 +278,6 @@ "loading_release_data": "Loading release data", "loading_spinner_no_progress_bar": "You will see a loading spinner but no progress bar.", "log_out": "Log Out", - "manage_access": "Manage Access", "manage_connections": "Manage Connections", "manage_database_access": "Manage [databaseName] Database Access", "manage_schema_access": "Manage [databaseName] Schema Access", diff --git a/mathesar_ui/src/pages/database/DatabaseDetails.svelte b/mathesar_ui/src/pages/database/DatabaseDetails.svelte index 6a1b655a3c..f66455305b 100644 --- a/mathesar_ui/src/pages/database/DatabaseDetails.svelte +++ b/mathesar_ui/src/pages/database/DatabaseDetails.svelte @@ -13,7 +13,6 @@ iconDatabase, iconDeleteMajor, iconEdit, - iconManageAccess, iconMoreActions, iconRefresh, } from '@mathesar/icons'; @@ -46,7 +45,6 @@ import SchemaRow from './SchemaRow.svelte'; const addEditModal = modal.spawnModalController(); - const accessControlModal = modal.spawnModalController(); const editConnectionModal = modal.spawnModalController(); const deleteConnectionModal = modal.spawnModalController(); @@ -106,10 +104,6 @@ }); } - function manageAccess() { - accessControlModal.open(); - } - function handleClearFilterQuery() { filterQuery = ''; } @@ -137,12 +131,6 @@ {#if canExecuteDDL || canEditPermissions}
- {#if canEditPermissions} - - {/if} - - - import { _ } from 'svelte-i18n'; - - import type { UserRole } from '@mathesar/api/rest/users'; - import type { Database } from '@mathesar/AppTypes'; - import Identifier from '@mathesar/components/Identifier.svelte'; - import ErrorBox from '@mathesar/components/message-boxes/ErrorBox.svelte'; - import { RichText } from '@mathesar/components/rich-text'; - import { - type UserModel, - setUsersStoreInContext, - } from '@mathesar/stores/users'; - import { AccessControlView } from '@mathesar/systems/users-and-permissions'; - import type { ObjectRoleMap } from '@mathesar/utils/permissions'; - import { - ControlledModal, - type ModalController, - } from '@mathesar-component-library'; - - export let controller: ModalController; - export let database: Database; - - const usersStore = setUsersStoreInContext(); - const { requestStatus } = usersStore; - - $: usersWithoutAccess = usersStore.getUsersWithoutAccessToDb(database); - $: usersWithAccess = usersStore.getUsersWithAccessToDb(database); - - async function addAccessForUser(user: UserModel, role: UserRole) { - await usersStore.addDatabaseRoleForUser(user.id, database, role); - } - - async function removeAccessForUser(user: UserModel) { - await usersStore.removeDatabaseAccessForUser(user.id, database); - } - - function getUserRoles(user: UserModel): ObjectRoleMap | undefined { - const dbRole = user.getRoleForDb(database); - return dbRole ? new Map([['database', dbRole.role]]) : undefined; - } - - - - - - {#if slotName === 'databaseName'} - {database.nickname} - {/if} - - - - {#if $requestStatus?.state === 'success'} - - {:else if $requestStatus?.state === 'processing'} -
{$_('loading')}
- {:else if $requestStatus?.state === 'failure'} - - {$requestStatus.errors.join(', ')} - - {/if} -
diff --git a/mathesar_ui/src/pages/schema/SchemaAccessControlModal.svelte b/mathesar_ui/src/pages/schema/SchemaAccessControlModal.svelte deleted file mode 100644 index cb22a2a557..0000000000 --- a/mathesar_ui/src/pages/schema/SchemaAccessControlModal.svelte +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - {#if slotName === 'databaseName'} - {schema.name} - {/if} - - - - {#if $requestStatus?.state === 'success'} - - {:else if $requestStatus?.state === 'processing'} -
{$_('loading')}
- {:else if $requestStatus?.state === 'failure'} - - {$requestStatus.errors.join(', ')} - - {/if} -
diff --git a/mathesar_ui/src/pages/schema/SchemaPage.svelte b/mathesar_ui/src/pages/schema/SchemaPage.svelte index fab522012b..6802f85a07 100644 --- a/mathesar_ui/src/pages/schema/SchemaPage.svelte +++ b/mathesar_ui/src/pages/schema/SchemaPage.svelte @@ -3,7 +3,7 @@ import type { Database, SchemaEntry } from '@mathesar/AppTypes'; import AppSecondaryHeader from '@mathesar/components/AppSecondaryHeader.svelte'; - import { iconEdit, iconManageAccess, iconSchema } from '@mathesar/icons'; + import { iconEdit, iconSchema } from '@mathesar/icons'; import LayoutWithHeader from '@mathesar/layouts/LayoutWithHeader.svelte'; import { makeSimplePageTitle } from '@mathesar/pages/pageTitleUtils'; import { @@ -24,7 +24,6 @@ import AddEditSchemaModal from '../database/AddEditSchemaModal.svelte'; import ExplorationSkeleton from './ExplorationSkeleton.svelte'; - import SchemaAccessControlModal from './SchemaAccessControlModal.svelte'; import SchemaExplorations from './SchemaExplorations.svelte'; import SchemaOverview from './SchemaOverview.svelte'; import SchemaTables from './SchemaTables.svelte'; @@ -42,13 +41,8 @@ $: canEditMetadata = userProfile?.hasPermission({ database, schema }, 'canEditMetadata') ?? false; - $: canEditPermissions = userProfile?.hasPermission( - { database, schema }, - 'canEditPermissions', - ); const addEditModal = modal.spawnModalController(); - const accessControlModal = modal.spawnModalController(); // NOTE: This has to be same as the name key in the paths prop of Route component type TabsKey = 'overview' | 'tables' | 'explorations'; @@ -92,10 +86,6 @@ $: isDefault = schema.name === 'public'; - function manageAccess() { - accessControlModal.open(); - } - logEvent('opened_schema', { database_name: database.nickname, schema_name: schema.name, @@ -127,12 +117,6 @@ {$_('edit_schema')} {/if} - {#if canEditPermissions} - - {/if}
@@ -191,7 +175,6 @@ - diff --git a/mathesar_ui/src/systems/users-and-permissions/AccessControlView.svelte b/mathesar_ui/src/systems/users-and-permissions/AccessControlView.svelte deleted file mode 100644 index 9aa9679357..0000000000 --- a/mathesar_ui/src/systems/users-and-permissions/AccessControlView.svelte +++ /dev/null @@ -1,192 +0,0 @@ - - -
- {#if !showAddForm} - - {/if} - - {#if showAddForm} -
-
- - - - -