Skip to content

Commit 810bf14

Browse files
author
Siziy Ivan
committed
refactor: enhance history and notification permission checks with UI request handling
1 parent 4d69a4e commit 810bf14

67 files changed

Lines changed: 384 additions & 334 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/Catalog.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ interface CatalogItem extends Item {
505505
description?: string;
506506
}
507507

508-
// Группа продуктов
508+
// Product group
509509
class ProductGroup extends AbstractGroup<CatalogItem> {
510510
readonly type = 'group';
511511
readonly name = 'Product Group';
@@ -634,7 +634,7 @@ class ProductGroup extends AbstractGroup<CatalogItem> {
634634
}
635635
}
636636

637-
// Продукт
637+
// Product
638638
class ProductItem extends AbstractItem<CatalogItem> {
639639
readonly type = 'product';
640640
readonly name = 'Product';
@@ -772,7 +772,7 @@ class ProductItem extends AbstractItem<CatalogItem> {
772772
}
773773
}
774774

775-
// Каталог продуктов
775+
// Product catalog
776776
export class ProductCatalog extends AbstractCatalog {
777777
readonly name = 'Product Catalog';
778778
readonly slug = 'products';
@@ -791,12 +791,12 @@ export class ProductCatalog extends AbstractCatalog {
791791
### Регистрация каталога
792792

793793
```typescript
794-
// В файле инициализации Adminizer
794+
// In the Adminizer bootstrap file
795795
import { ProductCatalog } from './lib/catalog/ProductCatalog';
796796

797797
const adminizer = new Adminizer(/* config */);
798798

799-
// Регистрация каталога
799+
// Catalog registration
800800
adminizer.catalogHandler.add(new ProductCatalog(adminizer));
801801
```
802802

docs/CommentTranslation.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Comment Translation to English
2+
3+
## Scope
4+
5+
Project comments were translated from Russian to English across:
6+
7+
- Backend source files in `src/`
8+
- Frontend source files in `src/assets/js/`
9+
- Test files in `test/`
10+
- Fixture and module helper files in `fixture/` and `modules/`
11+
- Code snippets in documentation where inline code comments were still in Russian
12+
13+
## Validation
14+
15+
To verify that no Russian comments remain, run:
16+
17+
```bash
18+
rg -n --pcre2 --hidden --glob '!.git' --glob '!node_modules' --glob '!dist' '(//[^\n]*[А-Яа-яЁё])|(\/\*[^\n]*[А-Яа-яЁё][^\n]*\*\/)|(^\s*\*[^\n]*[А-Яа-яЁё])'
19+
```
20+
21+
Expected result: no matches.

docs/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ This configuration loads all sail models as they are. Just place in `config\adm
415415

416416
```javascript
417417
// @ts-check
418-
// import { AdminizerConfig } from "adminizer"; // Тип импортируем через комментарий
418+
// import { AdminizerConfig } from "adminizer"; // Import the type via JSDoc comment
419419

420420
/** @type {import("adminizer").AdminizerConfig} */
421421
const config = {
@@ -752,4 +752,4 @@ displayModifier: function (data) {
752752
// for edit view
753753
return data.label + data.date
754754
}
755-
```
755+
```

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default [
3333

3434
rules: {
3535
"no-console": "warn",
36-
// Отключаем все правила, кроме @typescript-eslint/no-explicit-any
36+
// Disable all rules except @typescript-eslint/no-explicit-any
3737
"no-unused-vars": "off",
3838
"no-undef": "off",
3939
"no-warning-comments": ["error", {

fixture/cors-api/api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export function corsApi(adminizer: Adminizer) {
66
const routePrefix = adminizer.config.routePrefix || '';
77
const frontendJwtSecret = process.env.FRONTEND_JWT_SECRET || 'frontend-secret';
88

9-
// Эндпоинт для получения CSRF токена
9+
// Endpoint for receiving a CSRF token
1010
adminizer.app.get(`${routePrefix}/api/csrf-token`, (req: any, res: any) => {
11-
// Inertia middleware уже установила токен в cookies
12-
// Мы просто возвращаем его в ответе для удобства
11+
// Inertia middleware has already set the token in cookies
12+
// We're just returning it in the response for convenience.
1313
const csrfToken = req.cookies['XSRF-TOKEN'];
1414
res.json({
1515
csrfToken,
@@ -62,7 +62,7 @@ export function corsApi(adminizer: Adminizer) {
6262
httpOnly: true,
6363
sameSite: 'lax',
6464
path: '/',
65-
maxAge: 60 * 60 * 24 * 7 * 2, // 2 недели
65+
maxAge: 60 * 60 * 24 * 7 * 2, // 2 weeks
6666
}));
6767

6868
res.json({

fixture/helpers/notifications.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface SendNotificationsOptions {
66
delayMs?: number;
77
userId?: number;
88
onlyGeneral?: boolean;
9-
generalRatio?: number; // Вероятность general уведомлений (0-1)
9+
generalRatio?: number; // Probability of general notifications (0-1)
1010
}
1111

1212
export async function sendNotificationsWithDelay(
@@ -16,15 +16,15 @@ export async function sendNotificationsWithDelay(
1616
const {
1717
count = 10,
1818
delayMs = 2000,
19-
generalRatio = 0.7 // 70% general, 30% system по умолчанию
19+
generalRatio = 0.7 // 70% general, 30% system default
2020
} = options;
2121

2222
const systemChannels = ['created', 'updated', 'deleted', 'system'] as const;
2323
const entities = ['user', 'product', 'order', 'category', 'payment'] as const;
2424
const actions = ['create', 'update', 'delete', 'approve', 'reject'] as const;
2525

2626
const generateRandomNotification = (): Omit<INotification, 'id' | 'createdAt' | 'icon'> => {
27-
// Определяем тип уведомления с учетом вероятности
27+
// Determining the type of notification based on probability
2828
const isGeneral = options.onlyGeneral ? true : faker.number.float({ min: 0, max: 1 }) < generalRatio;
2929

3030
if (!isGeneral) {
@@ -56,9 +56,9 @@ export async function sendNotificationsWithDelay(
5656
} else {
5757
// General notification
5858
const userIdOption = options.userId ?? faker.helpers.arrayElement([
59-
undefined, // для всех пользователей
60-
1, // пользователь с ID 1
61-
2 // пользователь с ID 2
59+
undefined, // for all users
60+
1, // user with ID 1
61+
2 // user with ID 2
6262
]);
6363

6464
const hasUserId = userIdOption !== undefined;
@@ -82,7 +82,7 @@ export async function sendNotificationsWithDelay(
8282
channel: '',
8383
};
8484

85-
// Добавляем userId только если он указан
85+
// Add userId only if it is specified
8686
if (hasUserId) {
8787
return {
8888
...notification,

fixture/helpers/seedDatabase.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export async function seedDatabase(
9696
: await userModel.create(userData).fetch();
9797

9898

99-
// Привязка к группам (упрощённая логика)
99+
// Linking to groups (simplified logic)
100100
const groupName = u.isAdministrator ? 'Admins' : 'Users';
101101

102102
const group = isSequelize
@@ -120,7 +120,7 @@ export async function seedDatabase(
120120
const allUsers: UserAP[] = isSequelize
121121
? await userModel.findAll()
122122
: await userModel.find();
123-
123+
124124
if (exampleCount === 0) {
125125
const fakeExamples = Array.from({ length: count }, () => {
126126
const randomUser = faker.helpers.arrayElement(allUsers);
@@ -155,7 +155,7 @@ export async function seedDatabase(
155155
await exampleModel.createEach(fakeExamples).fetch();
156156
}
157157
}
158-
158+
159159
// ------------------ Tests ------------------ //
160160
const testCount = isSequelize
161161
? await testModel.count()

fixture/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ async function ormSharedFixtureLift(adminizer: Adminizer) {
237237
adminizer.catalogHandler.add(new TestCatalog(adminizer, 'testcatalog'))
238238

239239
/** Test notifications */
240-
//setTimeout(() => sendNotificationsWithDelay(adminizer, {count: 150, onlyGeneral: false, generalRatio: 0.5, delayMs: 300}), 5000); // Начальная задержка 10 секунд
240+
//setTimeout(() => sendNotificationsWithDelay(adminizer, {count: 150, onlyGeneral: false, generalRatio: 0.5, delayMs: 300}), 5000); // Initial delay 10 seconds
241241

242242
} catch (e) {
243243
console.log(e)

fixture/models/sequelize/Example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ import {UserAP} from "../../../src";
108108
static associate(sequelize: Sequelize) {
109109
const UserAPModel = sequelize.model('UserAP') as ModelStatic<Model<UserAP>>;
110110

111-
// 1-to-1: ownerId → один UserAP
111+
// 1-to-1: ownerId -> one UserAP
112112
this.belongsTo(UserAPModel, {
113113
foreignKey: 'ownerId',
114114
as: 'owner',

fixture/models/sequelize/Test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ export class Test extends Model<
6363
declare owner?: UserAP;
6464

6565
// ——————————————————————————————————————————————
66-
// Many-to-many с UserAP через `test_useraps`
66+
// Many-to-many with UserAP via `test_useraps`
6767
// ——————————————————————————————————————————————
6868
declare userAPs?: UserAP[];
6969

7070
static associate(sequelize: Sequelize) {
7171
const UserAPModel = sequelize.model('UserAP') as ModelStatic<Model<UserAP>>;
72-
// 1-to-1: ownerId → один UserAP
72+
// 1-to-1: ownerId -> one UserAP
7373
this.belongsTo(UserAPModel, {
7474
foreignKey: 'ownerId',
7575
as: 'owner',
7676
});
7777

78-
// M-to-N: через таблицу test_useraps
78+
// M-to-N: via the test_useraps table
7979
this.belongsToMany(UserAPModel, {
8080
through: 'test_useraps',
8181
foreignKey: 'testId',

0 commit comments

Comments
 (0)