diff --git a/mathesar_ui/src/api/rest/users.ts b/mathesar_ui/src/api/rest/users.ts index 477d881d68..6649efe8e6 100644 --- a/mathesar_ui/src/api/rest/users.ts +++ b/mathesar_ui/src/api/rest/users.ts @@ -1,5 +1,3 @@ -import type { Schema } from '@mathesar/api/rpc/schemas'; -import type { Database } from '@mathesar/AppTypes'; import type { Language } from '@mathesar/i18n/languages/utils'; import { @@ -18,25 +16,9 @@ export interface UnsavedUser { display_language: Language; } -export type UserRole = 'viewer' | 'editor' | 'manager'; - -export interface DatabaseRole { - id: number; - database: Database['id']; - role: UserRole; -} - -export interface SchemaRole { - id: number; - schema: Schema['oid']; - role: UserRole; -} - export interface User extends Omit { readonly id: number; readonly is_superuser: boolean; - readonly database_roles: DatabaseRole[]; - readonly schema_roles: SchemaRole[]; } function list() { @@ -75,38 +57,6 @@ function resetPassword(userId: User['id'], password: string) { }); } -function addDatabaseRole( - userId: User['id'], - databaseId: Database['id'], - role: UserRole, -) { - return postAPI('/api/ui/v0/database_roles/', { - user: userId, - database: databaseId, - role, - }); -} - -function deleteDatabaseRole(roleId: DatabaseRole['id']) { - return deleteAPI(`/api/ui/v0/database_roles/${roleId}/`); -} - -function addSchemaRole( - userId: User['id'], - schemaId: Schema['oid'], - role: UserRole, -) { - return postAPI('/api/ui/v0/schema_roles/', { - user: userId, - schema: schemaId, - role, - }); -} - -function deleteSchemaRole(roleId: SchemaRole['id']) { - return deleteAPI(`/api/ui/v0/schema_roles/${roleId}/`); -} - export default { list, get, @@ -115,8 +65,4 @@ export default { update, changePassword, resetPassword, - addDatabaseRole, - deleteDatabaseRole, - addSchemaRole, - deleteSchemaRole, }; diff --git a/mathesar_ui/src/components/AppHeader.svelte b/mathesar_ui/src/components/AppHeader.svelte index 3bc094ebca..6640491234 100644 --- a/mathesar_ui/src/components/AppHeader.svelte +++ b/mathesar_ui/src/components/AppHeader.svelte @@ -46,10 +46,6 @@ $: database = $currentDatabase; $: schema = $currentSchema; - $: canExecuteDDL = $userProfile?.hasPermission( - { database, schema }, - 'canExecuteDDL', - ); $: upgradable = $releaseDataStore?.value?.upgradeStatus === 'upgradable'; $: isNormalRoutingContext = commonData.routing_context === 'normal'; @@ -84,17 +80,15 @@ {$_('shortcuts')} - {#if canExecuteDDL} - - {$_('new_table_from_scratch')} - - - {$_('new_table_from_data_import')} - - {/if} + + {$_('new_table_from_scratch')} + + + {$_('new_table_from_data_import')} + diff --git a/mathesar_ui/src/pages/database/DatabaseDetails.svelte b/mathesar_ui/src/pages/database/DatabaseDetails.svelte index 24a0805c52..23a23c3111 100644 --- a/mathesar_ui/src/pages/database/DatabaseDetails.svelte +++ b/mathesar_ui/src/pages/database/DatabaseDetails.svelte @@ -14,7 +14,6 @@ iconDatabase, iconDeleteMajor, iconEdit, - iconManageAccess, iconMoreActions, iconRefresh, } from '@mathesar/icons'; @@ -42,12 +41,10 @@ } from '@mathesar-component-library'; import AddEditSchemaModal from './AddEditSchemaModal.svelte'; - import DbAccessControlModal from './DbAccessControlModal.svelte'; import SchemaListSkeleton from './SchemaListSkeleton.svelte'; import SchemaRow from './SchemaRow.svelte'; const addEditModal = modal.spawnModalController(); - const accessControlModal = modal.spawnModalController(); const editConnectionModal = modal.spawnModalController(); const deleteConnectionModal = modal.spawnModalController(); @@ -59,12 +56,6 @@ $: schemasMap = $schemasStore.data; $: schemasRequestStatus = $schemasStore.requestStatus; - $: canExecuteDDL = userProfile?.hasPermission({ database }, 'canExecuteDDL'); - $: canEditPermissions = userProfile?.hasPermission( - { database }, - 'canEditPermissions', - ); - let filterQuery = ''; let targetSchema: Schema | undefined; let isReflectionRunning = false; @@ -107,10 +98,6 @@ }); } - function manageAccess() { - accessControlModal.open(); - } - function handleClearFilterQuery() { filterQuery = ''; } @@ -136,58 +123,50 @@ }} > - {#if canExecuteDDL || canEditPermissions} -
- {#if canEditPermissions} - - {/if} - + + +
+ {$_('sync_external_changes')} + +

+ {$_('sync_external_changes_structure_help')} +

+

+ {$_('sync_external_changes_data_help')} +

+
+
+
+ {#if userProfile?.isSuperUser} editConnectionModal.open()} > -
- {$_('sync_external_changes')} - -

- {$_('sync_external_changes_structure_help')} -

-

- {$_('sync_external_changes_data_help')} -

-
-
+ {$_('edit_connection')}
- {#if userProfile?.isSuperUser} - editConnectionModal.open()} - > - {$_('edit_connection')} - - deleteConnectionModal.open()} - > - {$_('delete_connection')} - - {/if} -
-
- {/if} + deleteConnectionModal.open()} + > + {$_('delete_connection')} + + {/if} + +
@@ -201,12 +180,10 @@ on:clear={handleClearFilterQuery} > - {#if canExecuteDDL} - - {/if} +

editSchema(schema)} on:delete={() => deleteSchema(schema)} /> @@ -255,8 +228,6 @@ schema={targetSchema} /> - - - 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/database/SchemaRow.svelte b/mathesar_ui/src/pages/database/SchemaRow.svelte index 534cec6534..07e88ed0c8 100644 --- a/mathesar_ui/src/pages/database/SchemaRow.svelte +++ b/mathesar_ui/src/pages/database/SchemaRow.svelte @@ -23,7 +23,6 @@ export let database: Database; export let schema: Schema; - export let canExecuteDDL = true; let isHovered = false; let isFocused = false; @@ -44,7 +43,7 @@ {#if isLocked}
- {:else if canExecuteDDL} + {:else} 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} -
-
- - - - -