From d17918932b1fe129824e6b640a96f9cf7795b703 Mon Sep 17 00:00:00 2001
From: Vyacheslav Tumanov <me@slavatumanov.me>
Date: Thu, 29 Jun 2023 22:10:38 +0500
Subject: [PATCH] UBER-537: review support in inbox (#3471)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
---
 models/all/src/index.ts                       | 26 +++++++--------
 models/recruit/src/plugin.ts                  |  4 ++-
 models/recruit/src/review.ts                  | 32 +++++++++++++++++++
 plugins/recruit-assets/lang/en.json           |  3 +-
 plugins/recruit-assets/lang/ru.json           |  3 +-
 .../src/components/VacancyApplications.svelte |  2 +-
 plugins/recruit-resources/src/plugin.ts       |  3 +-
 7 files changed, 55 insertions(+), 18 deletions(-)

diff --git a/models/all/src/index.ts b/models/all/src/index.ts
index e86239489f..c396abfaae 100644
--- a/models/all/src/index.ts
+++ b/models/all/src/index.ts
@@ -125,6 +125,18 @@ export default function buildModel (enabled: string[] = ['*'], disabled: string[
       }
     ],
     [taskModel, taskId],
+    [
+      calendarModel,
+      calendarId,
+      {
+        label: calendar.string.ConfigLabel,
+        description: calendar.string.ConfigDescription,
+        enabled: false,
+        beta: true,
+        icon: calendar.icon.Calendar,
+        classFilter: defaultFilter
+      }
+    ],
     [
       recruitModel,
       recruitId,
@@ -237,18 +249,6 @@ export default function buildModel (enabled: string[] = ['*'], disabled: string[
         classFilter: defaultFilter
       }
     ],
-    [
-      calendarModel,
-      calendarId,
-      {
-        label: calendar.string.ConfigLabel,
-        description: calendar.string.ConfigDescription,
-        enabled: false,
-        beta: true,
-        icon: calendar.icon.Calendar,
-        classFilter: defaultFilter
-      }
-    ],
     [
       bitrixModel,
       bitrixId,
@@ -284,8 +284,8 @@ export default function buildModel (enabled: string[] = ['*'], disabled: string[
     [serverTagsModel, serverTagsId],
     [serverTaskModel, serverTaskId],
     [serverTrackerModel, serverTrackerId],
-    [serverRecruitModel, serverRecruitId],
     [serverCalendarModel, serverCalendarId],
+    [serverRecruitModel, serverRecruitId],
     [serverGmailModel, serverGmailId],
     [serverTelegramModel, serverTelegramId],
     [serverHrModel, serverHrId],
diff --git a/models/recruit/src/plugin.ts b/models/recruit/src/plugin.ts
index cfefb646a9..2ffc4a5091 100644
--- a/models/recruit/src/plugin.ts
+++ b/models/recruit/src/plugin.ts
@@ -72,9 +72,11 @@ export default mergeIds(recruitId, recruit, {
   ids: {
     VacancyNotificationGroup: '' as Ref<NotificationGroup>,
     CandidateNotificationGroup: '' as Ref<NotificationGroup>,
+    ReviewNotificationGroup: '' as Ref<NotificationGroup>,
     ApplicationNotificationGroup: '' as Ref<NotificationGroup>,
     AssigneeNotification: '' as Ref<NotificationType>,
-    ApplicationCreateNotification: '' as Ref<NotificationType>
+    ApplicationCreateNotification: '' as Ref<NotificationType>,
+    ReviewCreateNotification: '' as Ref<NotificationType>
   },
   component: {
     CreateApplication: '' as AnyComponent,
diff --git a/models/recruit/src/review.ts b/models/recruit/src/review.ts
index d25f71dd1b..0a43603106 100644
--- a/models/recruit/src/review.ts
+++ b/models/recruit/src/review.ts
@@ -7,6 +7,8 @@ import view, { createAction } from '@hcengineering/model-view'
 import { Review } from '@hcengineering/recruit'
 import { BuildModelKey } from '@hcengineering/view'
 import recruit from './plugin'
+import notification from '@hcengineering/notification'
+import { generateClassNotificationTypes } from '@hcengineering/model-notification'
 
 export const reviewTableOptions: FindOptions<Review> = {
   lookup: {
@@ -113,6 +115,36 @@ export function createReviewModel (builder: Builder): void {
     },
     recruit.viewlet.CalendarReview
   )
+
+  builder.createDoc(
+    notification.class.NotificationGroup,
+    core.space.Model,
+    {
+      label: recruit.string.Review,
+      icon: recruit.icon.Reviews,
+      objectClass: recruit.class.Review
+    },
+    recruit.ids.ReviewNotificationGroup
+  )
+
+  generateClassNotificationTypes(builder, recruit.class.Review, recruit.ids.ReviewNotificationGroup, [], ['comments'])
+
+  builder.createDoc(
+    notification.class.NotificationType,
+    core.space.Model,
+    {
+      hidden: false,
+      generated: false,
+      label: recruit.string.NewReview,
+      group: recruit.ids.ReviewNotificationGroup,
+      txClasses: [core.class.TxCreateDoc],
+      objectClass: recruit.class.Review,
+      providers: {
+        [notification.providers.PlatformNotification]: true
+      }
+    },
+    recruit.ids.ReviewCreateNotification
+  )
 }
 
 function createTableViewlet (builder: Builder): void {
diff --git a/plugins/recruit-assets/lang/en.json b/plugins/recruit-assets/lang/en.json
index ea5583ddca..fd4ebbeed6 100644
--- a/plugins/recruit-assets/lang/en.json
+++ b/plugins/recruit-assets/lang/en.json
@@ -13,7 +13,7 @@
     "VacancyPlaceholder": "Software Engineer",
     "CreateAnApplication": "New Application",
     "NoApplicationsForTalent": "There are no applications for this talent.",
-    "NoApplicationsForVacany": "There are no applications for this vacancy.",
+    "NoApplicationsForVacancy": "There are no applications for this vacancy.",
     "CreateApplication": "New Application",
     "ApplicationCreateLabel": "Application",
     "SelectVacancy": "Select vacancy",
@@ -64,6 +64,7 @@
     "Reviews": "Reviews",
     "Review": "Review",
     "ReviewCreateLabel": "Review",
+    "NewReview": "New Review",
     "Opinions": "Opinions",
     "Opinion": "Opinion",
     "OpinionValue": "Rating",
diff --git a/plugins/recruit-assets/lang/ru.json b/plugins/recruit-assets/lang/ru.json
index a37b047906..02c73c41af 100644
--- a/plugins/recruit-assets/lang/ru.json
+++ b/plugins/recruit-assets/lang/ru.json
@@ -13,7 +13,7 @@
     "VacancyPlaceholder": "Разработчик",
     "CreateAnApplication": "Новый Кандидат",
     "NoApplicationsForTalent": "Нет кандидатов для данного таланта.",
-    "NoApplicationsForVacany": "Нет кандидатов для данной вакансии.",
+    "NoApplicationsForVacancy": "Нет кандидатов для данной вакансии.",
     "CreateApplication": "Новый Кандидат",
     "SelectVacancy": "Выбрать вакансию",
     "Talent": "Талант",
@@ -65,6 +65,7 @@
     "Reviews": "Ревью",
     "Review": "Ревью",
     "ReviewCreateLabel": "Ревью",
+    "NewReview": "Новое Ревью",
     "Opinions": "Мнения",
     "Opinion": "Мнение",
     "OpinionValue": "Значение",
diff --git a/plugins/recruit-resources/src/components/VacancyApplications.svelte b/plugins/recruit-resources/src/components/VacancyApplications.svelte
index 20d75fbc01..a751a36db0 100644
--- a/plugins/recruit-resources/src/components/VacancyApplications.svelte
+++ b/plugins/recruit-resources/src/components/VacancyApplications.svelte
@@ -98,7 +98,7 @@
         <FileDuo size={'large'} />
       </div>
       <span class="content-dark-color">
-        <Label label={recruit.string.NoApplicationsForVacany} />
+        <Label label={recruit.string.NoApplicationsForVacancy} />
       </span>
       <span class="over-underline content-color" on:click={createApp}>
         <Label label={recruit.string.CreateAnApplication} />
diff --git a/plugins/recruit-resources/src/plugin.ts b/plugins/recruit-resources/src/plugin.ts
index ac96ab63e8..b76b03df58 100644
--- a/plugins/recruit-resources/src/plugin.ts
+++ b/plugins/recruit-resources/src/plugin.ts
@@ -40,7 +40,7 @@ export default mergeIds(recruitId, recruit, {
     CandidatesDescription: '' as IntlString,
     CreateAnApplication: '' as IntlString,
     NoApplicationsForTalent: '' as IntlString,
-    NoApplicationsForVacany: '' as IntlString,
+    NoApplicationsForVacancy: '' as IntlString,
     FirstName: '' as IntlString,
     LastName: '' as IntlString,
     Talents: '' as IntlString,
@@ -91,6 +91,7 @@ export default mergeIds(recruitId, recruit, {
 
     Review: '' as IntlString,
     ReviewCreateLabel: '' as IntlString,
+    NewReview: '' as IntlString,
     CreateReview: '' as IntlString,
     CreateReviewParams: '' as IntlString,
     Reviews: '' as IntlString,