mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-03 17:05:16 +03:00
UBER-945: pinning for comments (#4050)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
65e2aa572b
commit
69ac2b781c
@ -55,6 +55,7 @@ import view, { createAction, actionTemplates as viewTemplates } from '@hcenginee
|
|||||||
import workbench from '@hcengineering/model-workbench'
|
import workbench from '@hcengineering/model-workbench'
|
||||||
import chunter from './plugin'
|
import chunter from './plugin'
|
||||||
import { type AnyComponent } from '@hcengineering/ui/src/types'
|
import { type AnyComponent } from '@hcengineering/ui/src/types'
|
||||||
|
import { TypeBoolean } from '@hcengineering/model'
|
||||||
export { chunterId } from '@hcengineering/chunter'
|
export { chunterId } from '@hcengineering/chunter'
|
||||||
export { chunterOperation } from './migration'
|
export { chunterOperation } from './migration'
|
||||||
|
|
||||||
@ -153,6 +154,9 @@ export class TComment extends TAttachedDoc implements Comment {
|
|||||||
|
|
||||||
@Prop(Collection(chunter.class.Reaction), chunter.string.Reactions)
|
@Prop(Collection(chunter.class.Reaction), chunter.string.Reactions)
|
||||||
reactions?: number
|
reactions?: number
|
||||||
|
|
||||||
|
@Prop(TypeBoolean(), chunter.string.PinMessage)
|
||||||
|
pinned?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@Model(chunter.class.Backlink, chunter.class.Comment)
|
@Model(chunter.class.Backlink, chunter.class.Comment)
|
||||||
@ -753,6 +757,18 @@ export function createModel (builder: Builder, options = { addApplication: true
|
|||||||
chunter.ids.ActivityExtension
|
chunter.ids.ActivityExtension
|
||||||
)
|
)
|
||||||
|
|
||||||
|
builder.createDoc(
|
||||||
|
activity.class.ActivityExtension,
|
||||||
|
core.space.Model,
|
||||||
|
{
|
||||||
|
ofClass: chunter.class.Comment,
|
||||||
|
components: {
|
||||||
|
action: chunter.component.PinComment
|
||||||
|
}
|
||||||
|
},
|
||||||
|
chunter.ids.PinExtension
|
||||||
|
)
|
||||||
|
|
||||||
builder.createDoc(
|
builder.createDoc(
|
||||||
activity.class.ActivityExtension,
|
activity.class.ActivityExtension,
|
||||||
core.space.Model,
|
core.space.Model,
|
||||||
|
@ -34,7 +34,8 @@ export default mergeIds(chunterId, chunter, {
|
|||||||
SavedMessages: '' as AnyComponent,
|
SavedMessages: '' as AnyComponent,
|
||||||
ChunterBrowser: '' as AnyComponent,
|
ChunterBrowser: '' as AnyComponent,
|
||||||
CommentReactions: '' as AnyComponent,
|
CommentReactions: '' as AnyComponent,
|
||||||
ReactionsAction: '' as AnyComponent
|
ReactionsAction: '' as AnyComponent,
|
||||||
|
PinComment: '' as AnyComponent
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
MarkCommentUnread: '' as Ref<Action>,
|
MarkCommentUnread: '' as Ref<Action>,
|
||||||
@ -93,7 +94,8 @@ export default mergeIds(chunterId, chunter, {
|
|||||||
TxMessageCreate: '' as Ref<TxViewlet>,
|
TxMessageCreate: '' as Ref<TxViewlet>,
|
||||||
ChunterNotificationGroup: '' as Ref<NotificationGroup>,
|
ChunterNotificationGroup: '' as Ref<NotificationGroup>,
|
||||||
ActivityExtension: '' as Ref<ActivityExtension>,
|
ActivityExtension: '' as Ref<ActivityExtension>,
|
||||||
BackLinkActivityExtension: '' as Ref<ActivityExtension>
|
BackLinkActivityExtension: '' as Ref<ActivityExtension>,
|
||||||
|
PinExtension: '' as Ref<ActivityExtension>
|
||||||
},
|
},
|
||||||
activity: {
|
activity: {
|
||||||
TxCommentCreate: '' as AnyComponent,
|
TxCommentCreate: '' as AnyComponent,
|
||||||
|
@ -85,8 +85,9 @@
|
|||||||
filters: ActivityFilter[],
|
filters: ActivityFilter[],
|
||||||
selected: Ref<Doc>[] | 'All'
|
selected: Ref<Doc>[] | 'All'
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
const txesSorted = txes.sort((tx) => ((tx.doc as any)?.pinned ? -1 : 1))
|
||||||
if (selected === 'All') {
|
if (selected === 'All') {
|
||||||
filtered = txes
|
filtered = txesSorted
|
||||||
dispatch('update', filtered)
|
dispatch('update', filtered)
|
||||||
} else {
|
} else {
|
||||||
selectedFilters = filters.filter((filter) => selected.includes(filter._id))
|
selectedFilters = filters.filter((filter) => selected.includes(filter._id))
|
||||||
@ -95,7 +96,7 @@
|
|||||||
const fltr = await getResource(filter.filter)
|
const fltr = await getResource(filter.filter)
|
||||||
filterActions.push(fltr)
|
filterActions.push(fltr)
|
||||||
}
|
}
|
||||||
filtered = txes.filter((it) => filterActions.some((f) => f(it, object._class)))
|
filtered = txesSorted.filter((it) => filterActions.some((f) => f(it, object._class)))
|
||||||
dispatch('update', filtered)
|
dispatch('update', filtered)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
37
plugins/chunter-resources/src/components/PinComment.svelte
Normal file
37
plugins/chunter-resources/src/components/PinComment.svelte
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<!--
|
||||||
|
// Copyright © 2023 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 { ActionIcon } from '@hcengineering/ui'
|
||||||
|
import { getClient } from '@hcengineering/presentation'
|
||||||
|
import { type Comment } from '@hcengineering/chunter'
|
||||||
|
import view from '@hcengineering/view'
|
||||||
|
|
||||||
|
export let object: Comment | undefined = undefined
|
||||||
|
|
||||||
|
const client = getClient()
|
||||||
|
|
||||||
|
async function pinComment (ev: Event): Promise<void> {
|
||||||
|
if (object !== undefined) {
|
||||||
|
await client.update(object, { pinned: !object?.pinned })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ActionIcon
|
||||||
|
icon={view.icon.Pin}
|
||||||
|
iconProps={object?.pinned === true ? { fill: '#3265cb' } : undefined}
|
||||||
|
size="medium"
|
||||||
|
action={pinComment}
|
||||||
|
/>
|
@ -71,6 +71,7 @@ import TxCommentCreate from './components/activity/TxCommentCreate.svelte'
|
|||||||
import TxMessageCreate from './components/activity/TxMessageCreate.svelte'
|
import TxMessageCreate from './components/activity/TxMessageCreate.svelte'
|
||||||
import ReactionsAction from './components/ReactionsAction.svelte'
|
import ReactionsAction from './components/ReactionsAction.svelte'
|
||||||
import CommentReactions from './components/CommentReactions.svelte'
|
import CommentReactions from './components/CommentReactions.svelte'
|
||||||
|
import PinComment from './components/PinComment.svelte'
|
||||||
|
|
||||||
import notification from '@hcengineering/notification'
|
import notification from '@hcengineering/notification'
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
@ -310,7 +311,8 @@ export default async (): Promise<Resources> => ({
|
|||||||
SavedMessages,
|
SavedMessages,
|
||||||
CommentPanel,
|
CommentPanel,
|
||||||
ReactionsAction,
|
ReactionsAction,
|
||||||
CommentReactions
|
CommentReactions,
|
||||||
|
PinComment
|
||||||
},
|
},
|
||||||
function: {
|
function: {
|
||||||
GetDmName: getDmName,
|
GetDmName: getDmName,
|
||||||
|
@ -103,6 +103,7 @@ export interface Comment extends AttachedDoc {
|
|||||||
message: string
|
message: string
|
||||||
attachments?: number
|
attachments?: number
|
||||||
reactions?: number
|
reactions?: number
|
||||||
|
pinned?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user