Chunter: archive channel (#1416)

Signed-off-by: budaeva <irina.budaeva@xored.com>
This commit is contained in:
budaeva 2022-04-18 12:56:25 +07:00 committed by GitHub
parent 3240cac4df
commit 5cd7771257
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 148 additions and 9 deletions

View File

@ -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,

View File

@ -31,11 +31,15 @@ export default mergeIds(chunterId, chunter, {
},
action: {
MarkCommentUnread: '' as Ref<Action>,
MarkUnread: '' as Ref<Action>
MarkUnread: '' as Ref<Action>,
ArchiveChannel: '' as Ref<Action>,
UnarchiveChannel: '' as Ref<Action>
},
actionImpl: {
MarkUnread: '' as Resource<(object: Doc) => Promise<void>>,
MarkCommentUnread: '' as Resource<(object: Doc) => Promise<void>>
MarkCommentUnread: '' as Resource<(object: Doc) => Promise<void>>,
ArchiveChannel: '' as Resource<(object: Doc) => Promise<void>>,
UnarchiveChannel: '' as Resource<(object: Doc) => Promise<void>>
},
string: {
ApplicationLabelChunter: '' as IntlString,

View File

@ -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?"
}
}

View File

@ -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": "Вы действительно хотите разархивировать канал?"
}
}

View File

@ -23,6 +23,7 @@
import chunter from '../plugin'
import EditChannelDescriptionTab from './EditChannelDescriptionTab.svelte'
import EditChannelSettingsTab from './EditChannelSettingsTab.svelte'
export let _id: Ref<Channel>
export let _class: Ref<Class<Channel>>
@ -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
</script>
@ -83,9 +84,11 @@
<Scroller padding>
{#if selectedTabIndex === 0}
<EditChannelDescriptionTab {channel} {_id} {_class} />
{:else}
{:else if selectedTabIndex === 1}
<!-- Channel members -->
<Members />
{:else if selectedTabIndex === 2}
<EditChannelSettingsTab {channel} on:close />
{/if}
</Scroller>
</div>

View File

@ -0,0 +1,23 @@
<script lang="ts">
import { Channel } from '@anticrm/chunter'
import { Button } from '@anticrm/ui'
import { createEventDispatcher } from 'svelte';
import { ArchiveChannel } from '../index'
import chunter from '../plugin'
export let channel: Channel
const dispatch = createEventDispatcher()
</script>
{#if channel}
<div class="flex-col flex-gap-3">
<Button
label={chunter.string.ArchiveChannel}
justify={'left'}
on:click={() => {
ArchiveChannel(channel, () => dispatch('close'))
}}
/>
</div>
{/if}

View File

@ -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<void> {
})
}
export async function ArchiveChannel (channel: Channel, afterArchive?: () => void): Promise<void> {
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<void> {
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<Resources> => ({
component: {
CommentInput,
@ -104,6 +149,8 @@ export default async (): Promise<Resources> => ({
SubscribeMessage,
UnsubscribeMessage,
PinMessage,
UnpinMessage
UnpinMessage,
ArchiveChannel,
UnarchiveChannel
}
})

View File

@ -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<Doc>