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

Chunter: Convert direct message to private channel #1752

Merged
merged 3 commits into from
May 17, 2022
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
16 changes: 16 additions & 0 deletions models/chunter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions models/chunter/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 2 additions & 1 deletion plugins/chunter-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
3 changes: 2 additions & 1 deletion plugins/chunter-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"LeaveChannel": "Покинуть канал",
"ChannelBrowser": "Браузер каналов",
"SavedItems": "Сохраненные объекты",
"AddMembersHeader": "Добавить пользователей в {channel}:"
"AddMembersHeader": "Добавить пользователей в {channel}:",
"ConvertToPrivate": "Конвертировать в закрытый канал"
}
}
Original file line number Diff line number Diff line change
@@ -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>
13 changes: 11 additions & 2 deletions plugins/chunter-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -185,6 +193,7 @@ export default async (): Promise<Resources> => ({
PinMessage,
UnpinMessage,
ArchiveChannel,
UnarchiveChannel
UnarchiveChannel,
ConvertDmToPrivateChannel
}
})
3 changes: 2 additions & 1 deletion plugins/chunter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down