From 444261ba3900562953fe0db237fb3ac3b0821c6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Sat, 2 May 2026 22:31:43 +0300 Subject: [PATCH] =?UTF-8?q?Seeder=20ve=20WizardFileManager=20d=C3=BCzeltme?= =?UTF-8?q?si?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Seeds/LanguagesData.json | 30 +++ .../Seeds/WizardDataSeeder.cs | 46 ++--- .../listForm/wizard/WizardFileManager.tsx | 179 +++++++++--------- 3 files changed, 147 insertions(+), 108 deletions(-) diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json index dc5d6a5..256ac81 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json @@ -15998,6 +15998,36 @@ "en": "Listform Wizard", "tr": "Listform Sihirbazı" }, + { + "resourceName": "Platform", + "key": "App.Listforms.WizardFileLoadError", + "en": "Failed to load wizard files.", + "tr": "Wizard dosyaları yüklenemedi." + }, + { + "resourceName": "Platform", + "key": "App.Listforms.WizardNoFiles", + "en": "No wizard file saved yet.", + "tr": "Henüz kaydedilmiş wizard dosyası yok." + }, + { + "resourceName": "Platform", + "key": "App.Listforms.WizardFileDeleteConfirm", + "en": "Are you sure you want to delete this wizard file? All related database records (permission, menu, language, listform) will also be deleted. This action cannot be undone.", + "tr": "Bu wizard dosyasını silmek istediğinizden emin misiniz? ve buna ait tüm veritabanı kayıtları (izin, menü, dil, listform) silinecek. Bu işlem geri alınamaz." + }, + { + "resourceName": "Platform", + "key": "App.Listforms.WizardFileDeleteError", + "en": "Failed to delete wizard file.", + "tr": "Wizard dosyası silinemedi." + }, + { + "resourceName": "Platform", + "key": "App.Listforms.WizardFileDeleteSuccess", + "en": "Wizard file deleted successfully.", + "tr": "Wizard dosyası başarıyla silindi." + }, { "resourceName": "Platform", "key": "App.Listforms.WizardManager", diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/WizardDataSeeder.cs b/api/src/Sozsoft.Platform.DbMigrator/Seeds/WizardDataSeeder.cs index 7a17f51..a3501c5 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/WizardDataSeeder.cs +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/WizardDataSeeder.cs @@ -70,18 +70,18 @@ public class WizardDataSeeder : IDataSeedContributor, ITransientDependency var wizardDataPath = Path.Combine(Directory.GetCurrentDirectory(), "Seeds", "WizardData"); if (!Directory.Exists(wizardDataPath)) { - _logger.LogInformation("Seeds/WizardData dizini bulunamadı, atlanıyor."); + _logger.LogInformation("Seeds/WizardData directory not found, skipping."); return; } var jsonFiles = Directory.GetFiles(wizardDataPath, "*.json").OrderBy(f => Path.GetFileName(f)).ToArray(); if (jsonFiles.Length == 0) { - _logger.LogInformation("Seeds/WizardData dizininde JSON dosyası bulunamadı, atlanıyor."); + _logger.LogInformation("No JSON files found in Seeds/WizardData directory, skipping."); return; } - _logger.LogInformation("WizardDataSeeder başladı. {Count} dosya işlenecek.", jsonFiles.Length); + _logger.LogInformation("WizardDataSeeder started. {Count} files to be processed.", jsonFiles.Length); var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; @@ -94,14 +94,14 @@ public class WizardDataSeeder : IDataSeedContributor, ITransientDependency if (seedFile?.Wizard == null) { - _logger.LogWarning("Geçersiz dosya atlandı: {FilePath}", filePath); + _logger.LogWarning("Invalid file skipped: {FilePath}", filePath); continue; } var wizardName = seedFile.Wizard.WizardName?.Trim(); if (string.IsNullOrWhiteSpace(wizardName)) { - _logger.LogWarning("WizardName boş olduğu için atlandı: {FilePath}", filePath); + _logger.LogWarning("WizardName is empty, skipped: {FilePath}", filePath); continue; } @@ -110,13 +110,13 @@ public class WizardDataSeeder : IDataSeedContributor, ITransientDependency // Zaten seeded mi kontrol et (ListForm var mı?) if (await _repoListForm.AnyAsync(a => a.ListFormCode == seedFile.Wizard.ListFormCode)) { - _logger.LogInformation("[{File}] '{WizardName}' zaten mevcut, atlandı.", fileName, wizardName); + _logger.LogInformation("[{File}] '{WizardName}' already exists, skipped.", fileName, wizardName); continue; } - _logger.LogInformation("[{File}] '{WizardName}' uygulanıyor...", fileName, wizardName); + _logger.LogInformation("[{File}] '{WizardName}' is being applied...", fileName, wizardName); await ApplyWizardSeedAsync(seedFile); - _logger.LogInformation("[{File}] '{WizardName}' başarıyla uygulandı.", fileName, wizardName); + _logger.LogInformation("[{File}] '{WizardName}' has been successfully applied.", fileName, wizardName); } catch (Exception ex) { @@ -190,23 +190,23 @@ public class WizardDataSeeder : IDataSeedContributor, ITransientDependency permNote = await _repoPerm.InsertAsync(new PermissionDefinitionRecord( Guid.NewGuid(), groupName, WizardConsts.PermNote(wizardName), permRead.Name, WizardConsts.LangKeyNote, true, MultiTenancySides.Both), autoSave: true); - // Permission Grants - Admin role için, sadece eksik olanları ekle - var existingGrants = await _permissionGrantRepository.GetListAsync("R", PlatformConsts.AbpIdentity.User.AdminRoleName); - var existingGrantNames = new HashSet(existingGrants.Select(g => g.Name)); + // // Permission Grants - Admin role için, sadece eksik olanları ekle + // var existingGrants = await _permissionGrantRepository.GetListAsync("R", PlatformConsts.AbpIdentity.User.AdminRoleName); + // var existingGrantNames = new HashSet(existingGrants.Select(g => g.Name)); - var grantsToInsert = new[] - { - permRead.Name, permCreate.Name, permUpdate.Name, - permDelete.Name, permExport.Name, permImport.Name, permNote.Name - } - .Where(name => !existingGrantNames.Contains(name)) - .Select(name => new PermissionGrant(Guid.NewGuid(), name, "R", PlatformConsts.AbpIdentity.User.AdminRoleName)) - .ToList(); + // var grantsToInsert = new[] + // { + // permRead.Name, permCreate.Name, permUpdate.Name, + // permDelete.Name, permExport.Name, permImport.Name, permNote.Name + // } + // .Where(name => !existingGrantNames.Contains(name)) + // .Select(name => new PermissionGrant(Guid.NewGuid(), name, "R", PlatformConsts.AbpIdentity.User.AdminRoleName)) + // .ToList(); - if (grantsToInsert.Count > 0) - { - await _permissionGrantRepository.InsertManyAsync(grantsToInsert, autoSave: true); - } + // if (grantsToInsert.Count > 0) + // { + // await _permissionGrantRepository.InsertManyAsync(grantsToInsert, autoSave: true); + // } // Menu Parent var menuQueryable = await _repoMenu.GetQueryableAsync(); diff --git a/ui/src/views/admin/listForm/wizard/WizardFileManager.tsx b/ui/src/views/admin/listForm/wizard/WizardFileManager.tsx index c129c7f..67afbf6 100644 --- a/ui/src/views/admin/listForm/wizard/WizardFileManager.tsx +++ b/ui/src/views/admin/listForm/wizard/WizardFileManager.tsx @@ -4,7 +4,14 @@ import classNames from 'classnames' import { Button, Input, Notification, toast } from '@/components/ui' import Container from '@/components/shared/Container' import { WizardFileInfoDto } from '@/proxy/admin/list-form/models' -import { FaTrash, FaSync, FaDatabase, FaPlus, FaExclamationTriangle, FaSearch } from 'react-icons/fa' +import { + FaTrash, + FaSync, + FaDatabase, + FaPlus, + FaExclamationTriangle, + FaSearch, +} from 'react-icons/fa' import { deleteWizardFile, getWizardFiles } from '@/services/wizard.service' import { useCurrentMenuIcon } from '@/utils/hooks/useCurrentMenuIcon' import { useLocalization } from '@/utils/hooks/useLocalization' @@ -56,7 +63,9 @@ const WizardFileManager = () => { setFiles(res.data ?? []) } catch { toast.push( - Wizard dosyaları yüklenemedi., + + {translate('::App.Listforms.WizardFileLoadError') || 'Failed to load wizard files.'} + , { placement: 'top-end' }, ) } finally { @@ -76,7 +85,9 @@ const WizardFileManager = () => { await deleteWizardFile(confirm.fileName) toast.push( - {confirm.wizardName} silindi. + {confirm.wizardName}{' '} + {translate('::App.Listforms.WizardFileDeleteSuccess') || + 'wizard file deleted successfully.'} , { placement: 'top-end' }, ) @@ -84,7 +95,8 @@ const WizardFileManager = () => { } catch (err: any) { toast.push( - Silme başarısız: {err?.message ?? 'Bilinmeyen hata'} + {translate('::App.Listforms.WizardFileDeleteError') || 'Failed to delete wizard file.'}:{' '} + {err?.message ?? 'Unknown error'} , { placement: 'top-end' }, ) @@ -134,102 +146,99 @@ const WizardFileManager = () => { className="flex items-center" > - {translate('::ListForms.ListForm.AddNewRecord') || 'Add New Record'} + {translate('::ListForms.ListForm.AddNewRecord') || 'Add New Record'}
+ {filteredFiles.length === 0 && !loading && ( +

+ {translate('::App.Listforms.WizardNoFiles') || 'No wizard files found.'} +

+ )} - {filteredFiles.length === 0 && !loading && ( -

- Henüz kaydedilmiş wizard dosyası yok. -

- )} + {loading && ( +

+ {translate('::App.Platform.Loading') || 'Loading...'} +

+ )} - {loading && ( -

Yükleniyor...

- )} - -
- {filteredFiles.map((f) => ( -
-
- -
-
- {f.wizardName || f.fileName} -
-
- {formatTimestamp(f.createdAt)} - {f.listFormCode} +
+ {filteredFiles.map((f) => ( +
+
+ +
+
+ {f.wizardName || f.fileName} +
+
+ {formatTimestamp(f.createdAt)} + {f.listFormCode} +
-
-
- {!f.hasInsertedRecords && ( - + {!f.hasInsertedRecords && ( + + + + )} + -
-
- ))} -
- - {/* Confirm Dialog */} - {confirm && ( -
-
-
- -
-

Wizard Sil

-

- {confirm.wizardName} wizard'ı ve buna ait tüm veritabanı - kayıtları (izin, menü, dil, listform) silinecek. Bu işlem geri alınamaz. -

+ +
-
- - + ))} +
+ + {/* Confirm Dialog */} + {confirm && ( +
+
+
+ +
+

{translate('::App.Platform.DeleteAction')}

+

+ {translate('::App.Listforms.WizardFileDeleteConfirm')} +

+
+
+
+ + +
-
- )} + )}
)