diff --git a/models/chunter/src/index.ts b/models/chunter/src/index.ts index 879f4f6d7a..98090eed57 100644 --- a/models/chunter/src/index.ts +++ b/models/chunter/src/index.ts @@ -161,6 +161,44 @@ export function createModel (builder: Builder): void { action: chunter.action.MarkUnread }) + builder.createDoc( + view.class.Action, + core.space.Model, + { + label: chunter.string.ArchiveChannel, + icon: view.icon.Archive, + action: chunter.actionImpl.ArchiveChannel + }, + chunter.action.ArchiveChannel + ) + + builder.createDoc( + view.class.Action, + core.space.Model, + { + label: chunter.string.UnarchiveChannel, + icon: view.icon.Archive, + action: chunter.actionImpl.UnarchiveChannel + }, + chunter.action.UnarchiveChannel + ) + + builder.createDoc(view.class.ActionTarget, core.space.Model, { + target: chunter.class.Channel, + action: chunter.action.ArchiveChannel, + query: { + archived: false + } + }) + + builder.createDoc(view.class.ActionTarget, core.space.Model, { + target: chunter.class.Channel, + action: chunter.action.UnarchiveChannel, + query: { + archived: true + } + }) + builder.createDoc(view.class.ActionTarget, core.space.Model, { target: chunter.class.ThreadMessage, action: chunter.action.MarkCommentUnread @@ -172,6 +210,15 @@ export function createModel (builder: Builder): void { hidden: false, navigatorModel: { specials: [ + { + id: 'archive', + component: workbench.component.Archive, + icon: view.icon.Archive, + label: workbench.string.Archive, + position: 'top', + visibleIf: workbench.function.HasArchiveSpaces, + spaceClass: chunter.class.Channel + }, { id: 'threads', label: chunter.string.Threads, diff --git a/models/chunter/src/plugin.ts b/models/chunter/src/plugin.ts index d555ea68d7..6e0f892504 100644 --- a/models/chunter/src/plugin.ts +++ b/models/chunter/src/plugin.ts @@ -31,11 +31,15 @@ export default mergeIds(chunterId, chunter, { }, action: { MarkCommentUnread: '' as Ref, - MarkUnread: '' as Ref + MarkUnread: '' as Ref, + ArchiveChannel: '' as Ref, + UnarchiveChannel: '' as Ref }, actionImpl: { MarkUnread: '' as Resource<(object: Doc) => Promise>, - MarkCommentUnread: '' as Resource<(object: Doc) => Promise> + MarkCommentUnread: '' as Resource<(object: Doc) => Promise>, + ArchiveChannel: '' as Resource<(object: Doc) => Promise>, + UnarchiveChannel: '' as Resource<(object: Doc) => Promise> }, string: { ApplicationLabelChunter: '' as IntlString, diff --git a/plugins/chunter-assets/lang/en.json b/plugins/chunter-assets/lang/en.json index 81ec212e59..d2394797ec 100644 --- a/plugins/chunter-assets/lang/en.json +++ b/plugins/chunter-assets/lang/en.json @@ -39,6 +39,11 @@ "Edited": "edited", "DeleteMessage": "Delete message", "AndYou": "{participants, plural, =0 {Just you} other {and you}}", - "ShowMoreReplies": "Show {count} more replies" + "ShowMoreReplies": "Show {count} more replies", + "Settings": "Settings", + "ArchiveChannel": "Archive channel", + "UnarchiveChannel": "Unarchive channel", + "ArchiveConfirm": "Do you want to archive channel?", + "UnarchiveConfirm": "Do you want to unarchive channel?" } } \ No newline at end of file diff --git a/plugins/chunter-assets/lang/ru.json b/plugins/chunter-assets/lang/ru.json index 1d02530394..60d255e184 100644 --- a/plugins/chunter-assets/lang/ru.json +++ b/plugins/chunter-assets/lang/ru.json @@ -38,6 +38,11 @@ "Edited": "отредактировано", "DeleteMessage": "Удалить сообщение", "AndYou": "{participants, plural, =0 {Только вы} other {и вы}}", - "ShowMoreReplies": "{count, plural, =3 {Показать еще # ответа} =4 {Показать еще # ответа} other {Показать еще # ответов}}" + "ShowMoreReplies": "{count, plural, =3 {Показать еще # ответа} =4 {Показать еще # ответа} other {Показать еще # ответов}}", + "Settings": "Настройки", + "ArchiveChannel": "Архивировать канал", + "UnarchiveChannel": "Разархивировать канал", + "ArchiveConfirm": "Вы действительно хотите архивировать канал?", + "UnarchiveConfirm": "Вы действительно хотите разархивировать канал?" } } \ No newline at end of file diff --git a/plugins/chunter-resources/src/components/EditChannel.svelte b/plugins/chunter-resources/src/components/EditChannel.svelte index d596ae81e5..15334f9a5a 100644 --- a/plugins/chunter-resources/src/components/EditChannel.svelte +++ b/plugins/chunter-resources/src/components/EditChannel.svelte @@ -23,6 +23,7 @@ import chunter from '../plugin' import EditChannelDescriptionTab from './EditChannelDescriptionTab.svelte' + import EditChannelSettingsTab from './EditChannelSettingsTab.svelte' export let _id: Ref export let _class: Ref> @@ -39,7 +40,7 @@ channel = result[0] }) - const tabLabels: IntlString[] = [chunter.string.Channel, chunter.string.Members] + const tabLabels: IntlString[] = [chunter.string.Channel, chunter.string.Members, chunter.string.Settings] let selectedTabIndex = 0 @@ -83,9 +84,11 @@ {#if selectedTabIndex === 0} - {:else} + {:else if selectedTabIndex === 1} + {:else if selectedTabIndex === 2} + {/if} diff --git a/plugins/chunter-resources/src/components/EditChannelSettingsTab.svelte b/plugins/chunter-resources/src/components/EditChannelSettingsTab.svelte new file mode 100644 index 0000000000..1d83356f42 --- /dev/null +++ b/plugins/chunter-resources/src/components/EditChannelSettingsTab.svelte @@ -0,0 +1,23 @@ + + +{#if channel} +
+
+{/if} diff --git a/plugins/chunter-resources/src/index.ts b/plugins/chunter-resources/src/index.ts index 624e0e2799..c8818c67e3 100644 --- a/plugins/chunter-resources/src/index.ts +++ b/plugins/chunter-resources/src/index.ts @@ -17,7 +17,8 @@ import core from '@anticrm/core' import chunter, { Channel, ChunterMessage, Message, ThreadMessage } from '@anticrm/chunter' import { NotificationClientImpl } from '@anticrm/notification-resources' import { Resources } from '@anticrm/platform' -import { getClient } from '@anticrm/presentation' +import { getClient, MessageBox } from '@anticrm/presentation' +import { getCurrentLocation, navigate, showPopup } from '@anticrm/ui' import TxBacklinkCreate from './components/activity/TxBacklinkCreate.svelte' import TxBacklinkReference from './components/activity/TxBacklinkReference.svelte' import TxCommentCreate from './components/activity/TxCommentCreate.svelte' @@ -80,6 +81,50 @@ export async function UnpinMessage (message: ChunterMessage): Promise { }) } +export async function ArchiveChannel (channel: Channel, afterArchive?: () => void): Promise { + showPopup( + MessageBox, + { + label: chunter.string.ArchiveChannel, + message: chunter.string.ArchiveConfirm + }, + undefined, + (result: boolean) => { + if (result) { + const client = getClient() + + // eslint-disable-next-line @typescript-eslint/no-floating-promises + client.update(channel, { archived: true }) + if (afterArchive != null) afterArchive() + + const loc = getCurrentLocation() + if (loc.path[2] === channel._id) { + loc.path.length = 2 + navigate(loc) + } + } + } + ) +} + +async function UnarchiveChannel (channel: Channel): Promise { + showPopup( + MessageBox, + { + label: chunter.string.UnarchiveChannel, + message: chunter.string.UnarchiveConfirm + }, + undefined, + (result: boolean) => { + if (result) { + const client = getClient() + + // eslint-disable-next-line @typescript-eslint/no-floating-promises + client.update(channel, { archived: false }) + } + } + ) +} export default async (): Promise => ({ component: { CommentInput, @@ -104,6 +149,8 @@ export default async (): Promise => ({ SubscribeMessage, UnsubscribeMessage, PinMessage, - UnpinMessage + UnpinMessage, + ArchiveChannel, + UnarchiveChannel } }) diff --git a/plugins/chunter/src/index.ts b/plugins/chunter/src/index.ts index 04b85aa6dc..4ee14c8085 100644 --- a/plugins/chunter/src/index.ts +++ b/plugins/chunter/src/index.ts @@ -112,7 +112,12 @@ export default plugin(chunterId, { string: { EditUpdate: '' as IntlString, EditCancel: '' as IntlString, - Comments: '' as IntlString + Comments: '' as IntlString, + Settings: '' as IntlString, + ArchiveChannel: '' as IntlString, + UnarchiveChannel: '' as IntlString, + ArchiveConfirm: '' as IntlString, + UnarchiveConfirm: '' as IntlString }, app: { Chunter: '' as Ref