RolesPermission ve UsersPermission düzenlemesi

This commit is contained in:
Sedat Öztürk 2026-03-19 00:38:06 +03:00
parent ac7784c030
commit ac1ff56288
5 changed files with 104 additions and 75 deletions

View file

@ -61,9 +61,6 @@ public class ListFormWizardAppService(
var descLangKey = WizardConsts.WizardKeyDesc(wizardName); var descLangKey = WizardConsts.WizardKeyDesc(wizardName);
var code = WizardConsts.WizardKey(wizardName); var code = WizardConsts.WizardKey(wizardName);
// Clear Redis Cache
await _languageTextAppService.ClearRedisCacheAsync();
//Dil - Language Keys //Dil - Language Keys
await CreateLangKey(nameLangKey, input.LanguageTextMenuEn, input.LanguageTextMenuTr); await CreateLangKey(nameLangKey, input.LanguageTextMenuEn, input.LanguageTextMenuTr);
await CreateLangKey(titleLangKey, input.LanguageTextTitleEn, input.LanguageTextTitleTr); await CreateLangKey(titleLangKey, input.LanguageTextTitleEn, input.LanguageTextTitleTr);
@ -256,6 +253,10 @@ public class ListFormWizardAppService(
await CreateLangKey(captionName, item.EnglishCaption, item.TurkishCaption); await CreateLangKey(captionName, item.EnglishCaption, item.TurkishCaption);
} }
} }
// Clear Redis Cache
await _languageTextAppService.ClearRedisCacheAsync();
} }
private async Task<LanguageKey> CreateLangKey(string key, string textEn, string textTr) private async Task<LanguageKey> CreateLangKey(string key, string textEn, string textTr)

View file

@ -41,7 +41,7 @@ export const abpConfigModel: AbpConfigModel = {
const currentCulture = helpers.getState().config?.localization.currentCulture.cultureName const currentCulture = helpers.getState().config?.localization.currentCulture.cultureName
const isCultureDifferent = newCulture && currentCulture !== newCulture const isCultureDifferent = newCulture && currentCulture !== newCulture
const isTextsEmpty = !helpers.getState().texts const isTextsEmpty = !helpers.getState().texts
if (isCultureDifferent || isTextsEmpty) { if (payload || isCultureDifferent || isTextsEmpty) {
await actions.getTexts({ await actions.getTexts({
cultureName: newCulture ?? currentCulture ?? appConfig.locale, cultureName: newCulture ?? currentCulture ?? appConfig.locale,
onlyDynamics: false, onlyDynamics: false,

View file

@ -313,8 +313,12 @@ const Wizard = () => {
} }
const handleDeploy = async () => { const handleDeploy = async () => {
try {
if (!formikRef.current) throw new Error('Form bulunamadı') if (!formikRef.current) throw new Error('Form bulunamadı')
const values = formikRef.current.values const values = formikRef.current.values
// 🔴 Önce kayıt işlemi TAMAMLANSIN
await postListFormWizard({ await postListFormWizard({
...values, ...values,
groups: editingGroups.map((g) => ({ groups: editingGroups.map((g) => ({
@ -322,6 +326,7 @@ const Wizard = () => {
colCount: g.colCount, colCount: g.colCount,
items: g.items.map((item) => { items: g.items.map((item) => {
const col = selectCommandColumns.find((c) => c.columnName === item.dataField) const col = selectCommandColumns.find((c) => c.columnName === item.dataField)
return { return {
dataField: item.dataField, dataField: item.dataField,
editorType: item.editorType, editorType: item.editorType,
@ -329,25 +334,30 @@ const Wizard = () => {
editorScript: item.editorScript ?? '', editorScript: item.editorScript ?? '',
colSpan: item.colSpan, colSpan: item.colSpan,
isRequired: item.isRequired, isRequired: item.isRequired,
dbSourceType: col ? sqlDataTypeToDbType(col.dataType) : 12, // 12 = DbType.String dbSourceType: col ? sqlDataTypeToDbType(col.dataType) : 12,
turkishCaption: item.turkishCaption, turkishCaption: item.turkishCaption,
englishCaption: item.englishCaption, englishCaption: item.englishCaption,
} }
}), }),
})), })),
}) })
// ✅ sonra config çek
await getConfig(true)
// ✅ sonra navigate
navigate(ROUTES_ENUM.protected.admin.list.replace(':listFormCode', values.listFormCode), { replace: true })
// ✅ en son kullanıcıya mesaj
toast.push( toast.push(
<Notification type="success" duration={2000}> <Notification type="success" duration={2000}>
{translate('::ListForms.FormBilgileriKaydedildi')} {translate('::ListForms.FormBilgileriKaydedildi')}
</Notification>, </Notification>,
{ placement: 'top-end' }, { placement: 'top-end' },
) )
setTimeout(async () => { } catch (err) {
getConfig(true) console.error(err)
}
navigate(ROUTES_ENUM.protected.admin.list.replace(':listFormCode', values.listFormCode))
}, 6000)
} }
return ( return (
@ -377,25 +387,30 @@ const Wizard = () => {
validationSchema={listFormValidationSchema} validationSchema={listFormValidationSchema}
onSubmit={async (values, { setSubmitting }) => { onSubmit={async (values, { setSubmitting }) => {
setSubmitting(true) setSubmitting(true)
try { try {
// 🔴 1. Kaydet (bekle)
await postListFormWizard({ ...values }) await postListFormWizard({ ...values })
// 🔴 2. Config güncelle (bekle)
await getConfig(true)
// 🔴 3. Navigate
navigate(ROUTES_ENUM.protected.admin.list.replace(':listFormCode', values.listFormCode), { replace: true })
// 🔴 4. Toast (istersen navigate öncesi de olabilir)
toast.push( toast.push(
<Notification type="success" duration={2000}> <Notification type="success" duration={2000}>
{translate('::ListForms.FormBilgileriKaydedildi')} {translate('::ListForms.FormBilgileriKaydedildi')}
</Notification>, </Notification>,
{ placement: 'top-end' }, { placement: 'top-end' },
) )
setSubmitting(false)
setTimeout(async () => {
getConfig(true)
navigate(ROUTES_ENUM.protected.admin.list.replace(':listFormCode', values.listFormCode))
}, 6000)
} catch (error: any) { } catch (error: any) {
toast.push(<Notification title={error.message} type="danger" />, { toast.push(<Notification title={error.message} type="danger" />, {
placement: 'top-end', placement: 'top-end',
}) })
} finally {
setSubmitting(false)
} }
}} }}
> >

View file

@ -58,7 +58,8 @@ function RolesPermission({
.map((group: any) => { .map((group: any) => {
const filteredPermissions = group.permissions.filter((perm: any) => { const filteredPermissions = group.permissions.filter((perm: any) => {
if (!perm.menuGroup) return false if (!perm.menuGroup) return false
const groups = typeof perm.menuGroup === 'string' const groups =
typeof perm.menuGroup === 'string'
? perm.menuGroup.split('|').map((g: string) => g.trim()) ? perm.menuGroup.split('|').map((g: string) => g.trim())
: perm.menuGroup : perm.menuGroup
return groups.includes(tenantGroup) return groups.includes(tenantGroup)
@ -97,35 +98,41 @@ function RolesPermission({
} }
const onDialogOk = async () => { const onDialogOk = async () => {
try {
setIsLoading(true) setIsLoading(true)
setTimeout(async () => {
if (permissionList?.groups && name) { if (permissionList?.groups && name) {
const listPermissions = await getPermissions(providerName, name) const listPermissions = await getPermissions(providerName, name)
const unChangedPermissions = getPermissionsWithGroupName(listPermissions.data?.groups) const unChangedPermissions = getPermissionsWithGroupName(listPermissions.data?.groups)
const changedPermissions = getPermissionsWithGroupName(permissionList.groups) const changedPermissions = getPermissionsWithGroupName(permissionList.groups)
const updatePermList: UpdatePermissionDto[] = changedPermissions const updatePermList = changedPermissions
.filter((per) => .filter(
(per) =>
(unChangedPermissions.find((unChanged) => unChanged.name === per.name) || {}) (unChangedPermissions.find((unChanged) => unChanged.name === per.name) || {})
.isGranted === per.isGranted .isGranted !== per.isGranted,
? false
: true,
) )
.map(({ name, isGranted }) => ({ name, isGranted })) .map(({ name, isGranted }) => ({ name, isGranted }))
updatePermissions(providerName, name, { permissions: updatePermList }) // 🔴 KRİTİK NOKTA
await updatePermissions(providerName, name, {
permissions: updatePermList,
})
// ✅ artık backend kesin güncel
await getConfig(false)
toast.push(<Notification title={'Permission updated'} type="success" />, { toast.push(<Notification title={'Permission updated'} type="success" />, {
placement: 'top-end', placement: 'top-end',
}) })
} }
onDialogClose() onDialogClose()
} catch (err) {
console.error(err)
} finally {
setIsLoading(false) setIsLoading(false)
}, 1000) }
setTimeout(async () => {
getConfig(true)
}, 6000)
} }
function getPermissionsWithGroupName(groups: PermissionGroupDto[]): PermissionWithGroupName[] { function getPermissionsWithGroupName(groups: PermissionGroupDto[]): PermissionWithGroupName[] {

View file

@ -76,35 +76,41 @@ function UsersPermission({
} }
const onDialogOk = async () => { const onDialogOk = async () => {
try {
setIsLoading(true) setIsLoading(true)
setTimeout(async () => {
if (permissionList?.groups && id) { if (permissionList?.groups && id) {
const listPermissions = await getPermissions(providerName, id) const listPermissions = await getPermissions(providerName, id)
const unChangedPermissions = getPermissionsWithGroupName(listPermissions.data?.groups) const unChangedPermissions = getPermissionsWithGroupName(listPermissions.data?.groups)
const changedPermissions = getPermissionsWithGroupName(permissionList.groups) const changedPermissions = getPermissionsWithGroupName(permissionList.groups)
const updatePermList: UpdatePermissionDto[] = changedPermissions const updatePermList = changedPermissions
.filter((per) => .filter(
(per) =>
(unChangedPermissions.find((unChanged) => unChanged.name === per.name) || {}) (unChangedPermissions.find((unChanged) => unChanged.name === per.name) || {})
.isGranted === per.isGranted .isGranted !== per.isGranted,
? false
: true,
) )
.map(({ name, isGranted }) => ({ name, isGranted })) .map(({ name, isGranted }) => ({ name, isGranted }))
updatePermissions(providerName, id, { permissions: updatePermList }) // 🔴 EN KRİTİK SATIR
await updatePermissions(providerName, id, {
permissions: updatePermList,
})
// ✅ permission kaydı bittikten sonra config çek
await getConfig(false)
toast.push(<Notification title={'Permission updated'} type="success" />, { toast.push(<Notification title={'Permission updated'} type="success" />, {
placement: 'top-end', placement: 'top-end',
}) })
} }
onDialogClose() onDialogClose()
} catch (err) {
console.error(err)
} finally {
setIsLoading(false) setIsLoading(false)
}, 1000) }
setTimeout(async () => {
getConfig(true)
}, 6000)
} }
function getPermissionsWithGroupName(groups: PermissionGroupDto[]): PermissionWithGroupName[] { function getPermissionsWithGroupName(groups: PermissionGroupDto[]): PermissionWithGroupName[] {