Skip to content

Commit

Permalink
New notification type - task closed
Browse files Browse the repository at this point in the history
  • Loading branch information
StaNov committed Jan 29, 2025
1 parent e962fab commit d3bc103
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.tolgee.constants
enum class NotificationType {
TASK_ASSIGNED,
TASK_COMPLETED,
TASK_CLOSED,
MFA_ENABLED,
MFA_DISABLED,
PASSWORD_CHANGED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,12 +558,17 @@ class TaskService(
}

private fun createNotificationIfApplicable(task: Task) {
if (task.state != TaskState.DONE) return
val notificationType = when (task.state) {
TaskState.DONE -> NotificationType.TASK_COMPLETED
TaskState.CLOSED -> NotificationType.TASK_CLOSED
else -> return
}

val author = task.author ?: return

notificationService.save(
Notification().apply {
type = NotificationType.TASK_COMPLETED
type = notificationType
user = author
project = task.project
originatingUser = authenticationFacade.authenticatedUserEntity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TaskAssignedItem } from 'tg.component/layout/Notifications/TaskAssignedItem';
import { TaskCompletedItem } from 'tg.component/layout/Notifications/TaskCompletedItem';
import { TaskClosedItem } from 'tg.component/layout/Notifications/TaskClosedItem';
import { MfaEnabledItem } from 'tg.component/layout/Notifications/MfaEnabledItem';
import { MfaDisabledItem } from 'tg.component/layout/Notifications/MfaDisabledItem';
import { PasswordChangedItem } from 'tg.component/layout/Notifications/PasswordChangedItem';
Expand All @@ -15,6 +16,7 @@ type NotificationsComponentMap = Record<
export const notificationComponents: NotificationsComponentMap = {
TASK_ASSIGNED: TaskAssignedItem,
TASK_COMPLETED: TaskCompletedItem,
TASK_CLOSED: TaskClosedItem,
MFA_ENABLED: MfaEnabledItem,
MFA_DISABLED: MfaDisabledItem,
PASSWORD_CHANGED: PasswordChangedItem,
Expand Down
19 changes: 19 additions & 0 deletions webapp/src/component/layout/Notifications/TaskClosedItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { default as React, FunctionComponent } from 'react';
import { T } from '@tolgee/react';
import {
TaskItem,
TaskItemProps,
} from 'tg.component/layout/Notifications/TaskItem';

type TaskClosedItemProps = TaskItemProps;

export const TaskClosedItem: FunctionComponent<TaskClosedItemProps> = ({
notification,
...props
}) => {
return (
<TaskItem notification={notification} {...props}>
<T keyName="notifications-task-closed" />
</TaskItem>
);
};
1 change: 1 addition & 0 deletions webapp/src/service/apiSchema.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2930,6 +2930,7 @@ export interface components {
type:
| "TASK_ASSIGNED"
| "TASK_COMPLETED"
| "TASK_CLOSED"
| "MFA_ENABLED"
| "MFA_DISABLED"
| "PASSWORD_CHANGED";
Expand Down

0 comments on commit d3bc103

Please sign in to comment.