diff --git a/models/notification/src/index.ts b/models/notification/src/index.ts index d6148cc286..778da86387 100644 --- a/models/notification/src/index.ts +++ b/models/notification/src/index.ts @@ -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 @@ -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( @@ -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 }] }) } diff --git a/models/notification/src/plugin.ts b/models/notification/src/plugin.ts index 5ed57a5c1a..24bcc9dff8 100644 --- a/models/notification/src/plugin.ts +++ b/models/notification/src/plugin.ts @@ -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 diff --git a/packages/ui/src/components/ButtonMenu.svelte b/packages/ui/src/components/ButtonMenu.svelte index 8c6e178c48..151cd70df2 100644 --- a/packages/ui/src/components/ButtonMenu.svelte +++ b/packages/ui/src/components/ButtonMenu.svelte @@ -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 = {} @@ -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) diff --git a/packages/ui/src/components/ModernToggle.svelte b/packages/ui/src/components/ModernToggle.svelte index 91cd05b24e..e098078439 100644 --- a/packages/ui/src/components/ModernToggle.svelte +++ b/packages/ui/src/components/ModernToggle.svelte @@ -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 diff --git a/plugins/activity-assets/lang/en.json b/plugins/activity-assets/lang/en.json index dfd9d563f2..9560807984 100644 --- a/plugins/activity-assets/lang/en.json +++ b/plugins/activity-assets/lang/en.json @@ -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", diff --git a/plugins/activity-assets/lang/es.json b/plugins/activity-assets/lang/es.json index c297301833..99eb98a1db 100644 --- a/plugins/activity-assets/lang/es.json +++ b/plugins/activity-assets/lang/es.json @@ -37,6 +37,6 @@ "Mentioned": "Mencionado", "You": "Tú", "Mentions": "Menciones", - "MentionedYouIn": "Has sido Mencionado en {title}" + "MentionedYouIn": "Has sido Mencionado en" } } \ No newline at end of file diff --git a/plugins/activity-assets/lang/pt.json b/plugins/activity-assets/lang/pt.json index 8ca2b0bc42..da81bcea14 100644 --- a/plugins/activity-assets/lang/pt.json +++ b/plugins/activity-assets/lang/pt.json @@ -37,6 +37,6 @@ "Mentioned": "Mencionado", "You": "Tu", "Mentions": "Menções", - "MentionedYouIn": "Foste Mencionado em {title}" + "MentionedYouIn": "Foste Mencionado em" } } \ No newline at end of file diff --git a/plugins/activity-assets/lang/ru.json b/plugins/activity-assets/lang/ru.json index ba7a29ce60..a89b188e2f 100644 --- a/plugins/activity-assets/lang/ru.json +++ b/plugins/activity-assets/lang/ru.json @@ -38,7 +38,7 @@ "Mentioned": "Упомянул(а)", "You": "Вы", "Mentions": "Упоминания", - "MentionedYouIn": "Упомянул(а) вас в {title}", + "MentionedYouIn": "Упомянул(а) вас в", "Messages": "Cообщения", "Thread": "Обсуждение", "AddReaction": "Добавить реакцию", diff --git a/plugins/chunter-resources/src/components/chat/navigator/ChatNavItem.svelte b/plugins/chunter-resources/src/components/chat/navigator/ChatNavItem.svelte index 71b4df1daf..7a798e377e 100644 --- a/plugins/chunter-resources/src/components/chat/navigator/ChatNavItem.svelte +++ b/plugins/chunter-resources/src/components/chat/navigator/ChatNavItem.svelte @@ -83,7 +83,7 @@ }) const excludedActions = [ - notification.action.DeleteContextNotifications, + notification.action.ArchiveContextNotifications, notification.action.UnReadNotifyContext, notification.action.ReadNotifyContext ] diff --git a/plugins/chunter-resources/src/components/chat/utils.ts b/plugins/chunter-resources/src/components/chat/utils.ts index 80ce011326..5377c53ad1 100644 --- a/plugins/chunter-resources/src/components/chat/utils.ts +++ b/plugins/chunter-resources/src/components/chat/utils.ts @@ -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) ) @@ -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) diff --git a/plugins/chunter-resources/src/utils.ts b/plugins/chunter-resources/src/utils.ts index 0af57f74cc..cbfbe34346 100644 --- a/plugins/chunter-resources/src/utils.ts +++ b/plugins/chunter-resources/src/utils.ts @@ -39,7 +39,7 @@ import activity, { type DocUpdateMessage } from '@hcengineering/activity' import { - deleteContextNotifications, + archiveContextNotifications, InboxNotificationsClientImpl, isMentionNotification } from '@hcengineering/notification-resources' @@ -396,7 +396,7 @@ export async function removeChannelAction (context?: DocNotifyContext): Promise< const client = getClient() - await deleteContextNotifications(context) + await archiveContextNotifications(context) await client.remove(context) } diff --git a/plugins/notification-assets/lang/en.json b/plugins/notification-assets/lang/en.json index a1b0e4d6b6..7991414041 100644 --- a/plugins/notification-assets/lang/en.json +++ b/plugins/notification-assets/lang/en.json @@ -45,6 +45,7 @@ "StarDocument": "Star document", "UnstarDocument": "Unstar document", "Unsubscribe": "Unsubscribe", - "Push": "Push" + "Push": "Push", + "Unreads": "Unreads" } } diff --git a/plugins/notification-assets/lang/ru.json b/plugins/notification-assets/lang/ru.json index b166cc92af..1de20658a0 100644 --- a/plugins/notification-assets/lang/ru.json +++ b/plugins/notification-assets/lang/ru.json @@ -45,6 +45,7 @@ "StarDocument": "Добавить в избранное", "UnstarDocument": "Удалить из избранного", "Unsubscribe": "Отписаться", - "Push": "Push" + "Push": "Push", + "Unreads": "Непрочитанные" } } diff --git a/plugins/notification-resources/src/components/DocNotifyContextCard.svelte b/plugins/notification-resources/src/components/DocNotifyContextCard.svelte index e5cdfb17b9..80b6bdb9f9 100644 --- a/plugins/notification-resources/src/components/DocNotifyContextCard.svelte +++ b/plugins/notification-resources/src/components/DocNotifyContextCard.svelte @@ -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[] export let viewlets: ActivityNotificationViewlet[] = [] + export let archived = false const maxNotifications = 3 @@ -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, @@ -83,13 +91,13 @@ isActionMenuOpened = false } - let deletingPromise: Promise | undefined = undefined + let archivingPromise: Promise | undefined = undefined async function checkContext (): Promise { - await deletingPromise - deletingPromise = deleteContextNotifications(value) - await deletingPromise - deletingPromise = undefined + await archivingPromise + archivingPromise = archived ? unarchiveContextNotifications(value) : archiveContextNotifications(value) + await archivingPromise + archivingPromise = undefined } @@ -125,10 +133,10 @@
- {#if deletingPromise !== undefined} + {#if archivingPromise !== undefined} {:else} - + {/if}
- - - diff --git a/plugins/notification-resources/src/components/inbox/ActivityInboxNotificationPresenter.svelte b/plugins/notification-resources/src/components/inbox/ActivityInboxNotificationPresenter.svelte index 4f1d4203cb..07c6e4e92b 100644 --- a/plugins/notification-resources/src/components/inbox/ActivityInboxNotificationPresenter.svelte +++ b/plugins/notification-resources/src/components/inbox/ActivityInboxNotificationPresenter.svelte @@ -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 { const combinedMessages = await combineActivityMessages(sortActivityMessages(messages)) diff --git a/plugins/notification-resources/src/components/inbox/Inbox.svelte b/plugins/notification-resources/src/components/inbox/Inbox.svelte index 92d5a7ac0b..ec337d2c57 100644 --- a/plugins/notification-resources/src/components/inbox/Inbox.svelte +++ b/plugins/notification-resources/src/components/inbox/Inbox.svelte @@ -13,20 +13,18 @@ // limitations under the License. -->
- {#if inboxData.size > 0} - dropdownItemSelected(ev.detail)} - /> - {/if} - + +
@@ -390,7 +417,12 @@ - + diff --git a/plugins/notification-resources/src/components/inbox/InboxGroupedListView.svelte b/plugins/notification-resources/src/components/inbox/InboxGroupedListView.svelte index 6f0dd47ca2..6b3fe2e735 100644 --- a/plugins/notification-resources/src/components/inbox/InboxGroupedListView.svelte +++ b/plugins/notification-resources/src/components/inbox/InboxGroupedListView.svelte @@ -25,11 +25,12 @@ import { InboxNotificationsClientImpl } from '../../inboxNotificationsClient' import DocNotifyContextCard from '../DocNotifyContextCard.svelte' - import { deleteContextNotifications } from '../../utils' + import { archiveContextNotifications, unarchiveContextNotifications } from '../../utils' import { InboxData } from '../../types' export let data: InboxData export let selectedContext: Ref | undefined + export let archived = false const client = getClient() const dispatch = createEventDispatcher() @@ -83,7 +84,11 @@ const contextId = displayData[listSelection]?.[0] const context = $contextByIdStore.get(contextId) - void deleteContextNotifications(context) + if (archived) { + void unarchiveContextNotifications(context) + } else { + void archiveContextNotifications(context) + } } if (key.code === 'Enter') { key.preventDefault() @@ -121,6 +126,7 @@ { dispatch('click', event.detail) diff --git a/plugins/notification-resources/src/components/inbox/InboxMenuButton.svelte b/plugins/notification-resources/src/components/inbox/InboxMenuButton.svelte new file mode 100644 index 0000000000..7117f559d7 --- /dev/null +++ b/plugins/notification-resources/src/components/inbox/InboxMenuButton.svelte @@ -0,0 +1,61 @@ + + + + onSelect(ev.detail)} +/> diff --git a/plugins/notification-resources/src/components/inbox/SettingsButton.svelte b/plugins/notification-resources/src/components/inbox/SettingsButton.svelte new file mode 100644 index 0000000000..b5da214e32 --- /dev/null +++ b/plugins/notification-resources/src/components/inbox/SettingsButton.svelte @@ -0,0 +1,28 @@ + + + + diff --git a/plugins/notification-resources/src/components/inbox/SettingsPopup.svelte b/plugins/notification-resources/src/components/inbox/SettingsPopup.svelte new file mode 100644 index 0000000000..cea6e97097 --- /dev/null +++ b/plugins/notification-resources/src/components/inbox/SettingsPopup.svelte @@ -0,0 +1,107 @@ + + + + + + + +
{ + dispatch('changeContent') + }} + on:keydown={onKeydown} +> +