Skip to content

Commit

Permalink
TSK-1038: Fix comments presenter (#2896)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
  • Loading branch information
haiodo authored and Anton Brechka committed Apr 6, 2023
1 parent dc121ca commit 4c29732
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 61 deletions.
10 changes: 9 additions & 1 deletion models/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,18 @@ export function createModel (builder: Builder): void {
'tx._class',
'tx.objectClass',
'tx.operations.attachedTo',
'space',
'objectSpace',
{
_class: 1,
objectSpace: 1,
_id: 1
_id: 1,
modifiedOn: 1
},
{
_class: 1,
_id: 1,
modifiedOn: 1
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export async function createClient (
const atxes = await conn.findAll(
core.class.Tx,
{ modifiedOn: { $gt: lastTx } },
{ sort: { _id: SortingOrder.Ascending }, limit: transactionThreshold }
{ sort: { modifiedOn: SortingOrder.Ascending, _id: SortingOrder.Ascending }, limit: transactionThreshold }
)
if (atxes.total < transactionThreshold) {
console.log('applying input transactions', atxes.length)
Expand Down Expand Up @@ -226,7 +226,7 @@ async function loadModel (
const atxes = await conn.findAll(
core.class.Tx,
{ objectSpace: core.space.Model, _id: { $nin: Array.from(processedTx.values()) } },
{ sort: { _id: SortingOrder.Ascending } }
{ sort: { modifiedOn: SortingOrder.Ascending, _id: SortingOrder.Ascending } }
)

let systemTx: Tx[] = []
Expand Down
6 changes: 5 additions & 1 deletion packages/presentation/src/components/message/Nodes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
{:else if node.nodeName === 'STRONG'}
<strong><svelte:self nodes={node.childNodes} /></strong>
{:else if node.nodeName === 'P'}
<p class="p-inline"><svelte:self nodes={node.childNodes} /></p>
{#if node.childNodes.length > 0}
<p class="p-inline">
<svelte:self nodes={node.childNodes} />
</p>
{/if}
{:else if node.nodeName === 'BLOCKQUOTE'}
<blockquote><svelte:self nodes={node.childNodes} /></blockquote>
{:else if node.nodeName === 'CODE'}
Expand Down
16 changes: 13 additions & 3 deletions plugins/attachment-resources/src/components/AttachmentPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,26 @@
// limitations under the License.
-->
<script lang="ts">
import type { Ref, Doc } from '@hcengineering/core'
import { Table } from '@hcengineering/view-resources'
import type { Doc, Ref } from '@hcengineering/core'
import { DocNavLink, ObjectPresenter, Table } from '@hcengineering/view-resources'
import attachment from '../plugin'
import { Label } from '@hcengineering/ui'
import view from '@hcengineering/view'
import attachment from '../plugin'
export let objectId: Ref<Doc>
export let attachments: number
export let object: Doc
</script>

<div class="flex flex-between flex-grow p-1 mb-4">
<div class="fs-title">
<Label label={attachment.string.Attachments} />
</div>
<DocNavLink {object}>
<ObjectPresenter _class={object._class} objectId={object._id} value={object} />
</DocNavLink>
</div>
<Table
_class={attachment.class.Attachment}
config={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<script lang="ts">
import type { Doc } from '@hcengineering/core'
import { IconAttachment, tooltip } from '@hcengineering/ui'
import attachment from '../plugin'
import { DocNavLink } from '@hcengineering/view-resources'
import AttachmentPopup from './AttachmentPopup.svelte'
export let value: number | undefined
Expand All @@ -27,18 +27,18 @@

{#if value && value > 0}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
use:tooltip={{
label: attachment.string.Attachments,
component: AttachmentPopup,
props: { objectId: object._id, attachments: value }
}}
on:click|preventDefault|stopPropagation={() => {}}
class="sm-tool-icon ml-1 mr-1"
>
<span class="icon"><IconAttachment {size} /></span>
{#if showCounter}
&nbsp;{value}
{/if}
</div>
<DocNavLink {object} inline noUnderline={true}>
<div
use:tooltip={{
component: AttachmentPopup,
props: { objectId: object._id, attachments: value, object }
}}
class="sm-tool-icon ml-1 mr-1"
>
<span class="icon"><IconAttachment {size} /></span>
{#if showCounter}
&nbsp;{value}
{/if}
</div>
</DocNavLink>
{/if}
30 changes: 23 additions & 7 deletions plugins/chunter-resources/src/components/CommentPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
// limitations under the License.
-->
<script lang="ts">
import { Ref, Doc, SortingOrder } from '@hcengineering/core'
import { Doc, Ref, SortingOrder } from '@hcengineering/core'
import chunter, { Comment } from '@hcengineering/chunter'
import { createQuery } from '@hcengineering/presentation'
import { Label } from '@hcengineering/ui'
import { DocNavLink, ObjectPresenter } from '@hcengineering/view-resources'
import CommentPresenter from './CommentPresenter.svelte'
export let objectId: Ref<Doc>
export let object: Doc
let comments: Comment[] = []
const query = createQuery()
Expand All @@ -30,21 +33,34 @@
(res) => {
comments = res
},
{ limit: 3, sort: { modifiedOn: SortingOrder.Descending } }
{ sort: { modifiedOn: SortingOrder.Descending } }
)
</script>

{#each comments as comment}
<div class="item">
<CommentPresenter value={comment} />
<div class="flex flex-between flex-grow p-1 mb-4">
<div class="fs-title">
<Label label={chunter.string.Comments} />
</div>
{/each}
<DocNavLink {object}>
<ObjectPresenter _class={object._class} objectId={object._id} value={object} />
</DocNavLink>
</div>
<div class="comments max-h-120 flex-row">
{#each comments as comment}
<div class="item">
<CommentPresenter value={comment} />
</div>
{/each}
</div>

<style lang="scss">
.item {
max-width: 30rem;
}
.item + .item {
margin-top: 1.25rem;
margin-top: 0.75rem;
}
.comments {
overflow: auto;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
import type { Comment } from '@hcengineering/chunter'
import chunter from '@hcengineering/chunter'
import contact, { Employee, EmployeeAccount, getName } from '@hcengineering/contact'
import { employeeByIdStore } from '@hcengineering/contact-resources'
import { Avatar, employeeByIdStore } from '@hcengineering/contact-resources'
import { Ref } from '@hcengineering/core'
import { getClient, MessageViewer } from '@hcengineering/presentation'
import { Avatar } from '@hcengineering/contact-resources'
import { Icon, ShowMore, TimeSince } from '@hcengineering/ui'
export let value: Comment
Expand Down Expand Up @@ -64,7 +63,7 @@
</div>
<div class="dark-color ml-4"><TimeSince value={value.modifiedOn} /></div>
</div>
<ShowMore limit={126} fixed>
<ShowMore fixed>
<MessageViewer message={value.message} />
<AttachmentDocList {value} />
</ShowMore>
Expand Down
30 changes: 15 additions & 15 deletions plugins/chunter-resources/src/components/CommentsPresenter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
// limitations under the License.
-->
<script lang="ts">
import chunter from '@hcengineering/chunter'
import type { Doc } from '@hcengineering/core'
import { IconThread, tooltip } from '@hcengineering/ui'
import { DocNavLink } from '@hcengineering/view-resources'
import CommentPopup from './CommentPopup.svelte'
export let value: number | undefined
Expand All @@ -27,18 +27,18 @@

{#if value && value > 0}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
use:tooltip={{
label: chunter.string.Comments,
component: CommentPopup,
props: { objectId: object._id }
}}
on:click|preventDefault|stopPropagation={() => {}}
class="sm-tool-icon ml-1 mr-1"
>
<span class="icon"><IconThread {size} /></span>
{#if showCounter}
&nbsp;{value}
{/if}
</div>
<DocNavLink {object} inline noUnderline={true}>
<div
use:tooltip={{
component: CommentPopup,
props: { objectId: object._id, object }
}}
class="sm-tool-icon ml-1 mr-1"
>
<span class="icon"><IconThread {size} /></span>
{#if showCounter}
&nbsp;{value}
{/if}
</div>
</DocNavLink>
{/if}
13 changes: 11 additions & 2 deletions plugins/recruit-resources/src/components/ApplicationsPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@
-->
<script lang="ts">
import type { Candidate } from '@hcengineering/recruit'
import recruit from '@hcengineering/recruit'
import { Table } from '@hcengineering/view-resources'
import { Label } from '@hcengineering/ui'
import { DocNavLink, ObjectPresenter, Table } from '@hcengineering/view-resources'
import recruit from '../plugin'
export let value: Candidate
</script>

<div class="flex flex-between flex-grow p-1 mb-4">
<div class="fs-title">
<Label label={recruit.string.Applications} />
</div>
<DocNavLink object={value}>
<ObjectPresenter _class={value._class} objectId={value._id} {value} />
</DocNavLink>
</div>
<Table
_class={recruit.class.Applicant}
config={['', '$lookup.space.name', '$lookup.space.company', 'state', 'doneState']}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<script lang="ts">
import type { Candidate } from '@hcengineering/recruit'
import { Icon, tooltip } from '@hcengineering/ui'
import { DocNavLink } from '@hcengineering/view-resources'
import recruit from '../plugin'
import ApplicationsPopup from './ApplicationsPopup.svelte'
Expand All @@ -24,14 +25,15 @@
</script>

{#if value && value > 0}
<div
use:tooltip={{
label: recruit.string.Applications,
component: ApplicationsPopup,
props: { value: object }
}}
class="sm-tool-icon"
>
<span class="icon"><Icon icon={recruit.icon.Application} size={'small'} /></span>&nbsp;{value}
</div>
<DocNavLink {object} inline noUnderline={true}>
<div
use:tooltip={{
component: ApplicationsPopup,
props: { value: object }
}}
class="sm-tool-icon"
>
<span class="icon"><Icon icon={recruit.icon.Application} size={'small'} /></span>&nbsp;{value}
</div>
</DocNavLink>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<Label label={chunter.string.Comments} />:
</div>
<div class="ml-2">
<CommentPopup objectId={issue._id} />
<CommentPopup objectId={issue._id} object={issue} />
</div>
{/if}
{/if}
Expand Down
6 changes: 5 additions & 1 deletion server/tool/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ async function createUpdateIndexes (connection: CoreClient, db: Db): Promise<voi
const collection = db.collection(d)
const bb: (string | FieldIndex<Doc>)[] = []
for (const vv of v.values()) {
await collection.createIndex(vv)
try {
await collection.createIndex(vv)
} catch (err: any) {
console.error(err)
}
bb.push(vv)
}
if (bb.length > 0) {
Expand Down

0 comments on commit 4c29732

Please sign in to comment.