Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBERF-6205: add real archive for notifications #5385

Merged
merged 5 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions models/notification/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ export class TInboxNotification extends TDoc implements InboxNotification {
// @Index(IndexKind.Indexed)
isViewed!: boolean

@Prop(TypeBoolean(), core.string.Boolean)
archived?: boolean

title?: IntlString
body?: IntlString
intlParams?: Record<string, string | number>
Expand Down Expand Up @@ -537,15 +540,29 @@ export function createModel (builder: Builder): void {
createAction(
builder,
{
action: notification.actionImpl.DeleteContextNotifications,
label: notification.string.Archive,
action: notification.actionImpl.ArchiveContextNotifications,
label: view.string.Archive,
icon: view.icon.CheckCircle,
input: 'focus',
category: notification.category.Notification,
target: notification.class.DocNotifyContext,
context: { mode: ['panel'], application: notification.app.Notification, group: 'remove' }
},
notification.action.DeleteContextNotifications
notification.action.ArchiveContextNotifications
)

createAction(
builder,
{
action: notification.actionImpl.UnarchiveContextNotifications,
label: view.string.UnArchive,
icon: view.icon.Circle,
input: 'focus',
category: notification.category.Notification,
target: notification.class.DocNotifyContext,
context: { mode: ['panel'], application: notification.app.Notification, group: 'remove' }
},
notification.action.UnarchiveContextNotifications
)

createAction(
Expand Down Expand Up @@ -669,6 +686,7 @@ export function createModel (builder: Builder): void {
})
builder.createDoc(core.class.DomainIndexConfiguration, core.space.Model, {
domain: DOMAIN_NOTIFICATION,
indexes: [{ user: 1, archived: 1 }],
disabled: [{ modifiedOn: 1 }, { modifiedBy: 1 }, { createdBy: 1 }, { isViewed: 1 }, { hidden: 1 }]
})
}
Expand Down
3 changes: 2 additions & 1 deletion models/notification/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export default mergeIds(notificationId, notification, {
PinDocNotifyContext: '' as ViewAction,
UnReadNotifyContext: '' as ViewAction,
ReadNotifyContext: '' as ViewAction,
DeleteContextNotifications: '' as ViewAction,
ArchiveContextNotifications: '' as ViewAction,
UnarchiveContextNotifications: '' as ViewAction,
ArchiveAll: '' as ViewAction,
ReadAll: '' as ViewAction,
UnreadAll: '' as ViewAction
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/components/ButtonMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
export let disabled: boolean = false
export let loading: boolean = false
export let inheritColor: boolean = false
export let noSelection: boolean = false

export let items: DropdownIntlItem[]
export let params: Record<string, any> = {}
Expand All @@ -46,7 +47,7 @@
function openPopup () {
if (!opened) {
opened = true
showPopup(ModernPopup, { items, selected, params }, element, (result) => {
showPopup(ModernPopup, { items, selected: noSelection ? undefined : selected, params }, element, (result) => {
if (result) {
selected = result
dispatch('selected', result)
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/ModernToggle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// © 2023 Hardcore Engineering, Inc. All Rights Reserved.
// Licensed under the Eclipse Public License v2.0 (SPDX: EPL-2.0).
//
import type { Asset, IntlString } from '@hcengineering/platform'
import type { IntlString } from '@hcengineering/platform'
import Label from './Label.svelte'

export let title: string | undefined = undefined
Expand Down
2 changes: 1 addition & 1 deletion plugins/activity-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"Mentioned": "Mentioned",
"You": "You",
"Mentions": "Mentions",
"MentionedYouIn": "Mentioned you in {title}",
"MentionedYouIn": "Mentioned you in",
"Messages": "Messages",
"Thread": "Thread",
"AddReaction": "Add reaction",
Expand Down
2 changes: 1 addition & 1 deletion plugins/activity-assets/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
"Mentioned": "Mencionado",
"You": "Tú",
"Mentions": "Menciones",
"MentionedYouIn": "Has sido Mencionado en {title}"
"MentionedYouIn": "Has sido Mencionado en"
}
}
2 changes: 1 addition & 1 deletion plugins/activity-assets/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
"Mentioned": "Mencionado",
"You": "Tu",
"Mentions": "Menções",
"MentionedYouIn": "Foste Mencionado em {title}"
"MentionedYouIn": "Foste Mencionado em"
}
}
2 changes: 1 addition & 1 deletion plugins/activity-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"Mentioned": "Упомянул(а)",
"You": "Вы",
"Mentions": "Упоминания",
"MentionedYouIn": "Упомянул(а) вас в {title}",
"MentionedYouIn": "Упомянул(а) вас в",
"Messages": "Cообщения",
"Thread": "Обсуждение",
"AddReaction": "Добавить реакцию",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
})

const excludedActions = [
notification.action.DeleteContextNotifications,
notification.action.ArchiveContextNotifications,
notification.action.UnReadNotifyContext,
notification.action.ReadNotifyContext
]
Expand Down
4 changes: 2 additions & 2 deletions plugins/chunter-resources/src/components/chat/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export async function removeActivityChannels (contexts: DocNotifyContext[]): Pro
try {
for (const context of contexts) {
const notifications = notificationsByContext.get(context._id) ?? []
await client.deleteNotifications(
await client.archiveNotifications(
ops,
notifications.map(({ _id }) => _id)
)
Expand All @@ -293,7 +293,7 @@ export async function readActivityChannels (contexts: DocNotifyContext[]): Promi
try {
for (const context of contexts) {
const notifications = notificationsByContext.get(context._id) ?? []
await client.deleteNotifications(
await client.archiveNotifications(
ops,
notifications
.filter(({ _class }) => _class === notification.class.ActivityInboxNotification)
Expand Down
4 changes: 2 additions & 2 deletions plugins/chunter-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import activity, {
type DocUpdateMessage
} from '@hcengineering/activity'
import {
deleteContextNotifications,
archiveContextNotifications,
InboxNotificationsClientImpl,
isMentionNotification
} from '@hcengineering/notification-resources'
Expand Down Expand Up @@ -396,7 +396,7 @@ export async function removeChannelAction (context?: DocNotifyContext): Promise<

const client = getClient()

await deleteContextNotifications(context)
await archiveContextNotifications(context)
await client.remove(context)
}

Expand Down
3 changes: 2 additions & 1 deletion plugins/notification-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"StarDocument": "Star document",
"UnstarDocument": "Unstar document",
"Unsubscribe": "Unsubscribe",
"Push": "Push"
"Push": "Push",
"Unreads": "Unreads"
}
}
3 changes: 2 additions & 1 deletion plugins/notification-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"StarDocument": "Добавить в избранное",
"UnstarDocument": "Удалить из избранного",
"Unsubscribe": "Отписаться",
"Push": "Push"
"Push": "Push",
"Unreads": "Непрочитанные"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@

import InboxNotificationPresenter from './inbox/InboxNotificationPresenter.svelte'
import NotifyContextIcon from './NotifyContextIcon.svelte'
import { deleteContextNotifications } from '../utils'
import { archiveContextNotifications, unarchiveContextNotifications } from '../utils'

export let value: DocNotifyContext
export let notifications: WithLookup<DisplayInboxNotification>[]
export let viewlets: ActivityNotificationViewlet[] = []
export let archived = false

const maxNotifications = 3

Expand Down Expand Up @@ -67,6 +68,13 @@
{
object: value,
baseMenuClass: notification.class.DocNotifyContext,
excludedActions: archived
? [
notification.action.ArchiveContextNotifications,
notification.action.ReadNotifyContext,
notification.action.UnReadNotifyContext
]
: [notification.action.UnarchiveContextNotifications],
mode: 'panel'
},
ev.target as HTMLElement,
Expand All @@ -83,13 +91,13 @@
isActionMenuOpened = false
}

let deletingPromise: Promise<any> | undefined = undefined
let archivingPromise: Promise<any> | undefined = undefined

async function checkContext (): Promise<void> {
await deletingPromise
deletingPromise = deleteContextNotifications(value)
await deletingPromise
deletingPromise = undefined
await archivingPromise
archivingPromise = archived ? unarchiveContextNotifications(value) : archiveContextNotifications(value)
await archivingPromise
archivingPromise = undefined
}
</script>

Expand Down Expand Up @@ -125,10 +133,10 @@

<div class="actions clear-mins">
<div class="flex-center">
{#if deletingPromise !== undefined}
{#if archivingPromise !== undefined}
<Spinner size="small" />
{:else}
<CheckBox checked={false} kind="todo" size="medium" on:value={checkContext} />
<CheckBox checked={archived} kind="todo" size="medium" on:value={checkContext} />
{/if}
</div>
<ButtonIcon
Expand Down
48 changes: 0 additions & 48 deletions plugins/notification-resources/src/components/Filter.svelte

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,16 @@
import { getActions } from '@hcengineering/view-resources'
import { getResource } from '@hcengineering/platform'

import { InboxNotificationsClientImpl } from '../../inboxNotificationsClient'

export let value: DisplayActivityInboxNotification
export let viewlets: ActivityNotificationViewlet[] = []

const client = getClient()
const inboxClient = InboxNotificationsClientImpl.getClient()
const activityNotificationsStore = inboxClient.activityInboxNotifications

let viewlet: ActivityNotificationViewlet | undefined = undefined
let displayMessage: DisplayActivityMessage | undefined = undefined
let actions: Action[] = []

$: combinedNotifications = $activityNotificationsStore.filter(({ _id }) => value.combinedIds.includes(_id))
$: messages = combinedNotifications
.map((it) => it.$lookup?.attachedTo)
.filter((it): it is ActivityMessage => it !== undefined)

$: void updateDisplayMessage(messages)
$: void updateDisplayMessage(value.combinedMessages)

async function updateDisplayMessage (messages: ActivityMessage[]): Promise<void> {
const combinedMessages = await combineActivityMessages(sortActivityMessages(messages))
Expand Down
Loading