mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-26 04:23:58 +03:00
Chunter: Convert direct message to private channel (#1752)
Signed-off-by: Denis Bunakalya <denis.bunakalya@xored.com>
This commit is contained in:
parent
b834d4c4ee
commit
d689bf57c1
@ -278,6 +278,22 @@ export function createModel (builder: Builder): void {
|
||||
chunter.action.UnarchiveChannel
|
||||
)
|
||||
|
||||
createAction(
|
||||
builder,
|
||||
{
|
||||
action: chunter.actionImpl.ConvertDmToPrivateChannel,
|
||||
label: chunter.string.ConvertToPrivate,
|
||||
icon: chunter.icon.Lock,
|
||||
input: 'focus',
|
||||
category: chunter.category.Chunter,
|
||||
target: chunter.class.DirectMessage,
|
||||
context: {
|
||||
mode: 'context'
|
||||
}
|
||||
},
|
||||
chunter.action.ConvertToPrivate
|
||||
)
|
||||
|
||||
builder.createDoc(
|
||||
workbench.class.Application,
|
||||
core.space.Model,
|
||||
|
@ -35,13 +35,15 @@ export default mergeIds(chunterId, chunter, {
|
||||
MarkCommentUnread: '' as Ref<Action>,
|
||||
MarkUnread: '' as Ref<Action>,
|
||||
ArchiveChannel: '' as Ref<Action>,
|
||||
UnarchiveChannel: '' as Ref<Action>
|
||||
UnarchiveChannel: '' as Ref<Action>,
|
||||
ConvertToPrivate: '' as Ref<Action>
|
||||
},
|
||||
actionImpl: {
|
||||
MarkUnread: '' as ViewAction,
|
||||
MarkCommentUnread: '' as ViewAction,
|
||||
ArchiveChannel: '' as ViewAction,
|
||||
UnarchiveChannel: '' as ViewAction
|
||||
UnarchiveChannel: '' as ViewAction,
|
||||
ConvertDmToPrivateChannel: '' as ViewAction
|
||||
},
|
||||
category: {
|
||||
Chunter: '' as Ref<ActionCategory>
|
||||
|
@ -58,6 +58,7 @@
|
||||
"LeaveChannel": "Leave channel",
|
||||
"ChannelBrowser": "Channel browser",
|
||||
"SavedItems": "Saved items",
|
||||
"AddMembersHeader": "Add members to {channel}:"
|
||||
"AddMembersHeader": "Add members to {channel}:",
|
||||
"ConvertToPrivate": "Convert to private channel"
|
||||
}
|
||||
}
|
@ -57,6 +57,7 @@
|
||||
"LeaveChannel": "Покинуть канал",
|
||||
"ChannelBrowser": "Браузер каналов",
|
||||
"SavedItems": "Сохраненные объекты",
|
||||
"AddMembersHeader": "Добавить пользователей в {channel}:"
|
||||
"AddMembersHeader": "Добавить пользователей в {channel}:",
|
||||
"ConvertToPrivate": "Конвертировать в закрытый канал"
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
<!--
|
||||
// Copyright © 2022 Anticrm Platform Contributors.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
|
||||
import { getClient, Card } from '@anticrm/presentation'
|
||||
import { DirectMessage } from '@anticrm/chunter'
|
||||
import workbench from '@anticrm/workbench'
|
||||
import { getResource } from '@anticrm/platform'
|
||||
import { EditBox, IconFolder } from '@anticrm/ui'
|
||||
|
||||
import chunter from '../plugin'
|
||||
|
||||
export let dm: DirectMessage
|
||||
|
||||
let name = ''
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
async function convertDmToPrivateChannel () {
|
||||
const client = getClient()
|
||||
|
||||
await client.updateDoc(dm._class, dm.space, dm._id, {
|
||||
_class: chunter.class.Channel,
|
||||
name
|
||||
} as any)
|
||||
|
||||
const navigate = await getResource(workbench.actionImpl.Navigate)
|
||||
|
||||
await navigate([], undefined as any, {
|
||||
mode: 'space',
|
||||
space: dm.space
|
||||
})
|
||||
|
||||
await navigate([], undefined as any, {
|
||||
mode: 'space',
|
||||
space: dm._id
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<Card
|
||||
label={chunter.string.ConvertToPrivate}
|
||||
okLabel={chunter.string.ConvertToPrivate}
|
||||
okAction={convertDmToPrivateChannel}
|
||||
canSave={!!name}
|
||||
on:close={() => {
|
||||
dispatch('close')
|
||||
}}
|
||||
>
|
||||
<EditBox
|
||||
label={chunter.string.ChannelName}
|
||||
icon={IconFolder}
|
||||
bind:value={name}
|
||||
placeholder={chunter.string.ChannelNamePlaceholder}
|
||||
maxWidth={'16rem'}
|
||||
focus
|
||||
/>
|
||||
</Card>
|
@ -14,7 +14,7 @@
|
||||
//
|
||||
|
||||
import core from '@anticrm/core'
|
||||
import chunter, { ChunterSpace, Channel, ChunterMessage, Message, ThreadMessage } from '@anticrm/chunter'
|
||||
import chunter, { ChunterSpace, Channel, ChunterMessage, Message, ThreadMessage, DirectMessage } from '@anticrm/chunter'
|
||||
import { NotificationClientImpl } from '@anticrm/notification-resources'
|
||||
import { Resources } from '@anticrm/platform'
|
||||
import preference from '@anticrm/preference'
|
||||
@ -37,6 +37,7 @@ import EditChannel from './components/EditChannel.svelte'
|
||||
import ThreadView from './components/ThreadView.svelte'
|
||||
import Threads from './components/Threads.svelte'
|
||||
import SavedMessages from './components/SavedMessages.svelte'
|
||||
import ConvertDmToPrivateChannelModal from './components/ConvertDmToPrivateChannel.svelte'
|
||||
|
||||
import { getDmName } from './utils'
|
||||
|
||||
@ -135,6 +136,13 @@ async function UnarchiveChannel (channel: Channel): Promise<void> {
|
||||
)
|
||||
}
|
||||
|
||||
async function ConvertDmToPrivateChannel (dm: DirectMessage): Promise<void> {
|
||||
showPopup(ConvertDmToPrivateChannelModal, {
|
||||
label: chunter.string.ConvertToPrivate,
|
||||
dm
|
||||
})
|
||||
}
|
||||
|
||||
export async function AddMessageToSaved (message: ChunterMessage): Promise<void> {
|
||||
const client = getClient()
|
||||
|
||||
@ -185,6 +193,7 @@ export default async (): Promise<Resources> => ({
|
||||
PinMessage,
|
||||
UnpinMessage,
|
||||
ArchiveChannel,
|
||||
UnarchiveChannel
|
||||
UnarchiveChannel,
|
||||
ConvertDmToPrivateChannel
|
||||
}
|
||||
})
|
||||
|
@ -140,7 +140,8 @@ export default plugin(chunterId, {
|
||||
ArchiveChannel: '' as IntlString,
|
||||
UnarchiveChannel: '' as IntlString,
|
||||
ArchiveConfirm: '' as IntlString,
|
||||
UnarchiveConfirm: '' as IntlString
|
||||
UnarchiveConfirm: '' as IntlString,
|
||||
ConvertToPrivate: '' as IntlString
|
||||
},
|
||||
app: {
|
||||
Chunter: '' as Ref<Doc>
|
||||
|
Loading…
Reference in New Issue
Block a user