From 9fb838dcba755daae83fa98a7b72a4adf1ffbb0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96ZT=C3=9CRK?= <76204082+iamsedatozturk@users.noreply.github.com> Date: Mon, 30 Mar 2026 13:53:50 +0300 Subject: [PATCH] RolePermission kopyalama --- .../Seeds/LanguagesData.json | 8 +- .../admin/role-management/RolesPermission.tsx | 105 +++++++++++++++++- .../developerKit/SqlTableDesignerDialog.tsx | 4 +- 3 files changed, 108 insertions(+), 9 deletions(-) diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json index 354cc17..7282a69 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json @@ -1182,6 +1182,12 @@ "en": "Change permissions", "tr": "İzinleri değiştir" }, + { + "resourceName": "Platform", + "key": "AbpIdentity.Roles.CopyPermissions", + "en": "Copy permissions", + "tr": "İzinleri kopyala" + }, { "resourceName": "Platform", "key": "AbpIdentity.Users", @@ -16782,7 +16788,7 @@ }, { "resourceName": "Platform", - "key": "App.SqlQueryManager.SelectPlaceholder", + "key": "App.Select", "en": "— Select —", "tr": "— Seçiniz —" }, diff --git a/ui/src/views/admin/role-management/RolesPermission.tsx b/ui/src/views/admin/role-management/RolesPermission.tsx index c7cac85..a09a639 100644 --- a/ui/src/views/admin/role-management/RolesPermission.tsx +++ b/ui/src/views/admin/role-management/RolesPermission.tsx @@ -10,7 +10,7 @@ import { PermissionWithGroupName, PermissionWithStyle, } from '@/proxy/admin/models' -import { getPermissions, updatePermissions } from '@/services/identity.service' +import { getPermissions, getRoles, updatePermissions } from '@/services/identity.service' import { useStoreActions, useStoreState } from '@/store' import { useLocalization } from '@/utils/hooks/useLocalization' import { ChangeEvent, useEffect, useMemo, useState } from 'react' @@ -311,6 +311,55 @@ function RolesPermission({ fetchDataPermissions() }, [name]) + // --- Copy Permissions State and Logic --- + const [roleList, setRoleList] = useState([]) + + // --- Copy Permissions Dialog State --- + const [copyDialogOpen, setCopyDialogOpen] = useState(false) + const [copyDialogRole, setCopyDialogRole] = useState('') + + // Fetch all roles for select (except current) + useEffect(() => { + async function fetchRoles() { + try { + const res = await getRoles() + setRoleList(res.data.items?.map((r: any) => r.name) || []) + } catch (e) { + setRoleList([]) + } + } + fetchRoles() + }, [copyDialogOpen]) + + // Dialog üzerinden kopyalama işlemi + const handleCopyDialogConfirm = async () => { + if (!copyDialogRole || !permissionList) return + setIsLoading(true) + try { + const res = await getPermissions(providerName, copyDialogRole) + const sourcePerms = getPermissionsWithGroupName(res.data?.groups) + const grantedNames = new Set(sourcePerms.filter((p) => p.isGranted).map((p) => p.name)) + permissionList.groups.forEach((group) => { + group.permissions.forEach((perm) => { + perm.isGranted = grantedNames.has(perm.name) + }) + }) + setPermissionList({ ...permissionList }) + changeGroup(selectedGroup?.name) + toast.push(, { + placement: 'top-end', + }) + setCopyDialogOpen(false) + setCopyDialogRole('') + } catch (e) { + toast.push(, { + placement: 'top-end', + }) + } finally { + setIsLoading(false) + } + } + return permissionList ? ( - @@ -422,12 +470,57 @@ function RolesPermission({ -
- +
+
+ + +
+ +
+ + {/* Copy Permissions Dialog */} + setCopyDialogOpen(false)} + > +
{translate('::AbpIdentity.Roles.CopyPermissions')}
+
+ +
+
+ -
diff --git a/ui/src/views/developerKit/SqlTableDesignerDialog.tsx b/ui/src/views/developerKit/SqlTableDesignerDialog.tsx index 175440a..aafb9f7 100644 --- a/ui/src/views/developerKit/SqlTableDesignerDialog.tsx +++ b/ui/src/views/developerKit/SqlTableDesignerDialog.tsx @@ -2057,7 +2057,7 @@ const SqlTableDesignerDialog = ({ className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-sm dark:bg-gray-700 dark:text-white focus:ring-2 focus:ring-indigo-500" > {columns .filter((c) => c.columnName.trim()) @@ -2082,7 +2082,7 @@ const SqlTableDesignerDialog = ({ className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-sm dark:bg-gray-700 dark:text-white focus:ring-2 focus:ring-indigo-500" > {dbTables.map((t) => (