Move reply to thread to quick actions (#4603)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2024-02-12 12:57:28 +04:00 committed by GitHub
parent 19c1edf719
commit 318f4eab1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 56 additions and 28 deletions

View File

@ -630,21 +630,6 @@ export function createModel (builder: Builder, options = { addApplication: true
chunter.action.DeleteChatMessage
)
createAction(
builder,
{
action: chunter.actionImpl.ReplyToThread,
label: chunter.string.ReplyToThread,
icon: chunter.icon.Thread,
input: 'focus',
category: chunter.category.Chunter,
target: activity.class.ActivityMessage,
visibilityTester: chunter.function.CanReplyToThread,
context: { mode: 'context', application: notification.app.Notification, group: 'edit' }
},
chunter.action.ReplyToThread
)
createAction(
builder,
{
@ -694,6 +679,21 @@ export function createModel (builder: Builder, options = { addApplication: true
components: [{ kind: 'footer', component: chunter.component.Replies }]
})
builder.createDoc(activity.class.ActivityMessageExtension, core.space.Model, {
ofMessage: chunter.class.ChatMessage,
components: [{ kind: 'action', component: chunter.component.ReplyToThreadAction }]
})
builder.createDoc(activity.class.ActivityMessageExtension, core.space.Model, {
ofMessage: activity.class.DocUpdateMessage,
components: [{ kind: 'action', component: chunter.component.ReplyToThreadAction }]
})
builder.createDoc(activity.class.ActivityMessageExtension, core.space.Model, {
ofMessage: activity.class.ActivityInfoMessage,
components: [{ kind: 'action', component: chunter.component.ReplyToThreadAction }]
})
builder.mixin(chunter.class.Channel, core.class.Class, chunter.mixin.ObjectChatPanel, {
ignoreKeys: ['archived', 'collaborators', 'lastMessage', 'pinned', 'topic', 'description']
})

View File

@ -48,8 +48,7 @@ export default mergeIds(chunterId, chunter, {
ArchiveChannel: '' as ViewAction,
UnarchiveChannel: '' as ViewAction,
ConvertDmToPrivateChannel: '' as ViewAction,
DeleteChatMessage: '' as ViewAction,
ReplyToThread: '' as ViewAction
DeleteChatMessage: '' as ViewAction
},
category: {
Chunter: '' as Ref<ActionCategory>
@ -106,7 +105,6 @@ export default mergeIds(chunterId, chunter, {
GetFragment: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
DmIdentifierProvider: '' as Resource<<T extends Doc>(client: Client, ref: Ref<T>, doc?: T) => Promise<string>>,
CanDeleteMessage: '' as Resource<(doc?: Doc | Doc[]) => Promise<boolean>>,
CanReplyToThread: '' as Resource<(doc?: Doc | Doc[]) => Promise<boolean>>,
CanCopyMessageLink: '' as Resource<(doc?: Doc | Doc[]) => Promise<boolean>>,
GetChunterSpaceLinkFragment: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
GetThreadLink: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>

View File

@ -66,9 +66,9 @@
<div class="root">
{#if withFlatActions}
<AddReactionAction object={message} on:open on:close />
<ActivityMessageExtensionComponent kind="action" {extensions} props={{ object: message }} on:close on:open />
<PinMessageAction object={message} />
<SaveMessageAction object={message} />
<ActivityMessageExtensionComponent kind="action" {extensions} props={{ object: message }} on:close on:open />
{/if}
{#if withActionMenu}
<ActivityMessageAction icon={IconMoreV} action={showMenu} opened={isActionMenuOpened} />

View File

@ -0,0 +1,32 @@
<!--
// Copyright © 2024 Hardcore Engineering Inc.
//
// 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 { ActivityMessage } from '@hcengineering/activity'
import { ActivityMessageAction } from '@hcengineering/activity-resources'
import chunter from './../plugin'
import { replyToThread } from '../index'
import { canReplyToThread } from '../utils'
export let object: ActivityMessage
function onReply (): void {
replyToThread(object)
}
</script>
{#if canReplyToThread(object)}
<ActivityMessageAction size="x-small" icon={chunter.icon.Thread} action={onReply} />
{/if}

View File

@ -68,13 +68,13 @@ import ThreadNotificationPresenter from './components/notification/ThreadNotific
import ChatMessageNotificationLabel from './components/notification/ChatMessageNotificationLabel.svelte'
import ChatAside from './components/chat/ChatAside.svelte'
import Replies from './components/Replies.svelte'
import ReplyToThreadAction from './components/ReplyToThreadAction.svelte'
import { updateBacklinksList } from './backlinks'
import {
ChannelTitleProvider,
DirectTitleProvider,
canDeleteMessage,
canReplyToThread,
chunterSpaceLinkFragmentProvider,
dmIdentifierProvider,
getDmName,
@ -284,7 +284,8 @@ export default async (): Promise<Resources> => ({
ChatMessageNotificationLabel,
ThreadNotificationPresenter,
ChatAside,
Replies
Replies,
ReplyToThreadAction
},
function: {
GetDmName: getDmName,
@ -295,7 +296,6 @@ export default async (): Promise<Resources> => ({
ChannelTitleProvider,
DmIdentifierProvider: dmIdentifierProvider,
CanDeleteMessage: canDeleteMessage,
CanReplyToThread: canReplyToThread,
CanCopyMessageLink: canCopyMessageLink,
GetChunterSpaceLinkFragment: chunterSpaceLinkFragmentProvider,
GetUnreadThreadsCount: getUnreadThreadsCount,
@ -310,8 +310,7 @@ export default async (): Promise<Resources> => ({
ConvertDmToPrivateChannel,
DeleteChatMessage: deleteChatMessage,
OpenChannel,
UnpinAllChannels,
ReplyToThread: replyToThread
UnpinAllChannels
},
backreference: {
Update: update

View File

@ -119,7 +119,7 @@ export async function canDeleteMessage (doc?: ChatMessage): Promise<boolean> {
return doc.createdBy === me._id
}
export async function canReplyToThread (doc?: ActivityMessage): Promise<boolean> {
export function canReplyToThread (doc?: ActivityMessage): boolean {
if (doc === undefined) {
return false
}
@ -400,7 +400,6 @@ export function buildThreadLink (loc: Location, contextId: Ref<DocNotifyContext>
loc.path[3] = contextId
loc.path[4] = _id
loc.fragment = undefined
loc.query = { message: _id }
return loc
}

View File

@ -179,7 +179,8 @@ export default plugin(chunterId, {
ChatMessagePresenter: '' as AnyComponent,
ThreadMessagePresenter: '' as AnyComponent,
ChatAside: '' as AnyComponent,
Replies: '' as AnyComponent
Replies: '' as AnyComponent,
ReplyToThreadAction: '' as AnyComponent
},
class: {
Message: '' as Ref<Class<Message>>,
@ -251,7 +252,6 @@ export default plugin(chunterId, {
},
action: {
DeleteChatMessage: '' as Ref<Action>,
ReplyToThread: '' as Ref<Action>,
OpenChannel: '' as Ref<Action>
}
})