Skip to content

Commit f425160

Browse files
FEATURE (contribute): Update manuals ho wto contribute
1 parent 13f2d39 commit f425160

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

docs/how-to-add-notifier.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# How to add new notifier to Postgresus (Discord, Slack, Telegram, Email, Webhook, etc.)
2+
3+
## Backend part
4+
5+
1. Create new model in `backend/internal/features/notifiers/models/{notifier_name}/` folder. Implement `NotificationSender` interface from parent folder.
6+
- The model should implement `Send(logger *slog.Logger, heading string, message string) error` and `Validate() error` methods
7+
- Use UUID primary key as `NotifierID` that references the main notifiers table
8+
9+
2. Add new notifier type to `backend/internal/features/notifiers/enums.go` in the `NotifierType` constants.
10+
11+
3. Update the main `Notifier` model in `backend/internal/features/notifiers/model.go`:
12+
- Add new notifier field with GORM foreign key relation
13+
- Update `getSpecificNotifier()` method to handle the new type
14+
- Update `Send()` method to route to the new notifier
15+
16+
4. If you need to add some .env variables to test, add them in `backend/internal/config/config.go` (so we can use it in tests)
17+
18+
5. If you need some Docker container to test, add it to `backend/docker-compose.yml.example`. For sensitive data - keep it blank.
19+
20+
6. If you need some sensitive envs to test in pipeline, message @rostislav_dugin so I can add it to GitHub Actions. For example, API keys or credentials.
21+
22+
7. Create new migration in `backend/migrations` folder:
23+
- Create table with `notifier_id` as UUID primary key
24+
- Add foreign key constraint to `notifiers` table with CASCADE DELETE
25+
- Look at existing notifier migrations for reference
26+
27+
8. Make sure that all tests are passing.
28+
29+
## Frontend part
30+
31+
If you are able to develop only backend - it's fine, message @rostislav_dugin so I can complete UI part.
32+
33+
1. Add models and validator to `frontend/src/entity/notifiers/models/{notifier_name}/` folder and update `index.ts` file to include new model exports.
34+
35+
2. Upload an SVG icon to `public/icons/notifiers/`, update `src/entity/notifiers/models/getNotifierLogoFromType.ts` to return new icon path, update `src/entity/notifiers/models/NotifierType.ts` to include new type, and update `src/entity/notifiers/models/getNotifierNameFromType.ts` to return new name.
36+
37+
3. Add UI components to manage your notifier:
38+
- `src/features/notifiers/ui/edit/notifiers/Edit{NotifierName}Component.tsx` (for editing)
39+
- `src/features/notifiers/ui/show/notifier/Show{NotifierName}Component.tsx` (for display)
40+
41+
4. Update main components to handle the new notifier type:
42+
- `EditNotifierComponent.tsx` - add import, validation function, and component rendering
43+
- `ShowNotifierComponent.tsx` - add import and component rendering
44+
45+
5. Make sure everything is working as expected.

docs/how-to-add-storage.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# How to add new storage to Postgresus (S3, FTP, Google Drive, NAS, etc.)
2+
3+
## Backend part
4+
5+
1. Create new model in `backend/internal/features/storages/models/{storage_name}/` folder. Implement `StorageFileSaver` interface from parent folder.
6+
- The model should implement `SaveFile(logger *slog.Logger, fileID uuid.UUID, file io.Reader) error`, `GetFile(fileID uuid.UUID) (io.ReadCloser, error)`, `DeleteFile(fileID uuid.UUID) error`, `Validate() error`, and `TestConnection() error` methods
7+
- Use UUID primary key as `StorageID` that references the main storages table
8+
- Add `TableName() string` method to return the proper table name
9+
10+
2. Add new storage type to `backend/internal/features/storages/enums.go` in the `StorageType` constants.
11+
12+
3. Update the main `Storage` model in `backend/internal/features/storages/model.go`:
13+
- Add new storage field with GORM foreign key relation
14+
- Update `getSpecificStorage()` method to handle the new type
15+
- Update `SaveFile()`, `GetFile()`, and `DeleteFile()` methods to route to the new storage
16+
- Update `Validate()` method to include new storage validation
17+
18+
4. If you need to add some .env variables to test, add them in `backend/internal/config/config.go` (so we can use it in tests)
19+
20+
5. If you need some Docker container to test, add it to `backend/docker-compose.yml.example`. For sensitive data - keep it blank.
21+
22+
6. If you need some sensitive envs to test in pipeline, message @rostislav_dugin so I can add it to GitHub Actions. For example, Google Drive envs or FTP credentials.
23+
24+
7. Create new migration in `backend/migrations` folder:
25+
- Create table with `storage_id` as UUID primary key
26+
- Add foreign key constraint to `storages` table with CASCADE DELETE
27+
- Look at existing storage migrations for reference
28+
29+
8. Update tests in `backend/internal/features/storages/model_test.go` to test new storage
30+
31+
9. Make sure that all tests are passing.
32+
33+
## Frontend part
34+
35+
If you are able to develop only backend - it's fine, message @rostislav_dugin so I can complete UI part.
36+
37+
1. Add models and api to `frontend/src/entity/storages/models/` folder and update `index.ts` file to include new model exports.
38+
- Create TypeScript interface for your storage model
39+
- Add validation function if needed
40+
41+
2. Upload an SVG icon to `public/icons/storages/`, update `src/entity/storages/models/getStorageLogoFromType.ts` to return new icon path, update `src/entity/storages/models/StorageType.ts` to include new type, and update `src/entity/storages/models/getStorageNameFromType.ts` to return new name.
42+
43+
3. Add UI components to manage your storage:
44+
- `src/features/storages/ui/edit/storages/Edit{StorageName}Component.tsx` (for editing)
45+
- `src/features/storages/ui/show/storages/Show{StorageName}Component.tsx` (for display)
46+
47+
4. Update main components to handle the new storage type:
48+
- `EditStorageComponent.tsx` - add import and component rendering
49+
- `ShowStorageComponent.tsx` - add import and component rendering
50+
51+
5. Make sure everything is working as expected.

frontend/src/entity/notifiers/models/getNotifierNameFromType.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export const getNotifierNameFromType = (type: NotifierType) => {
1010
return 'Webhook';
1111
case NotifierType.SLACK:
1212
return 'Slack';
13+
case NotifierType.DISCORD:
14+
return 'Discord';
1315
default:
1416
return '';
1517
}

0 commit comments

Comments
 (0)