Skip to content

Commit

Permalink
UBERF-9297: Fix space selection for emails (#8035)
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Savchenko <[email protected]>
  • Loading branch information
ArtyomSavchenko authored Feb 18, 2025
1 parent 7e0b60e commit f86beb0
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 7 deletions.
3 changes: 3 additions & 0 deletions models/my-space/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export function createModel (builder: Builder): void {
label: mySpace.string.Mail,
createLabel: mail.string.CreateMail,
createComponent: mail.component.CreateMail
},
queryOptions: {
filterBySpace: true
}
}
]
Expand Down
5 changes: 3 additions & 2 deletions plugins/mail-resources/src/components/CreateMail.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//
-->
<script lang="ts">
import core, { Data, Doc, generateId, getCurrentAccount, Ref, Space } from '@hcengineering/core'
import { Data, Doc, generateId, getCurrentAccount, Ref, Space } from '@hcengineering/core'
import chunter, { type ChatMessage } from '@hcengineering/chunter'
import { Card, getClient, isSpace } from '@hcengineering/presentation'
import { MailThread } from '@hcengineering/mail'
Expand All @@ -30,6 +30,7 @@
const client = getClient()
const account = getCurrentAccount()
export let space: Ref<Space>
export let mailThreadId: Ref<MailThread> | undefined = undefined
export let to = ''
Expand Down Expand Up @@ -84,7 +85,7 @@
preview: getMessagePreview(message)
}
const threadId = await client.createDoc(mail.class.MailThread, core.space.Space, data)
const threadId = await client.createDoc(mail.class.MailThread, space, data)
return await client.findOne(mail.class.MailThread, { _id: threadId as any })
}
Expand Down
8 changes: 5 additions & 3 deletions plugins/workbench-resources/src/components/SpecialView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
import { Class, Doc, DocumentQuery, FindOptions, Ref, Space, WithLookup } from '@hcengineering/core'
import { Class, Doc, DocumentQuery, FindOptions, Ref, Space, WithLookup, mergeQueries } from '@hcengineering/core'
import { Asset, IntlString } from '@hcengineering/platform'
import { getClient } from '@hcengineering/presentation'
import {
Expand All @@ -38,7 +38,7 @@
ViewletSelector,
ViewletSettingButton
} from '@hcengineering/view-resources'
import { ParentsNavigationModel } from '@hcengineering/workbench'
import { QueryOptions, ParentsNavigationModel } from '@hcengineering/workbench'
import ComponentNavigator from './ComponentNavigator.svelte'
Expand All @@ -56,6 +56,7 @@
export let baseQuery: DocumentQuery<Doc> | undefined = undefined
export let modes: IModeSelector<any> | undefined = undefined
export let navigationModel: ParentsNavigationModel | undefined = undefined
export let queryOptions: QueryOptions | undefined = undefined
const client = getClient()
const hierarchy = client.getHierarchy()
Expand All @@ -68,7 +69,8 @@
let viewlets: Array<WithLookup<Viewlet>> = []
let viewOptions: ViewOptions | undefined
$: _baseQuery = { ...(baseQuery ?? {}), ...(viewlet?.baseQuery ?? {}) }
$: spaceQuery = queryOptions?.filterBySpace === true && space !== undefined ? { space } : {}
$: _baseQuery = mergeQueries(mergeQueries(baseQuery ?? {}, viewlet?.baseQuery ?? {}), spaceQuery)
$: query = { ..._baseQuery }
$: searchQuery = search === '' ? query : { ...query, $search: search }
$: resultQuery = searchQuery
Expand Down
3 changes: 2 additions & 1 deletion plugins/workbench-resources/src/components/Workbench.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,8 @@
currentSpace,
space: currentSpace,
navigationModel: specialComponent?.navigationModel,
workbenchWidth
workbenchWidth,
queryOptions: specialComponent?.queryOptions
}}
on:action={(e) => {
if (e?.detail) {
Expand Down
9 changes: 9 additions & 0 deletions plugins/workbench/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export interface SpecialNavModel {
(inboxNotificationsByContext: Map<Ref<DocNotifyContext>, InboxNotification[]>) => number
>
navigationModel?: ParentsNavigationModel
queryOptions?: QueryOptions
}

/**
Expand All @@ -202,6 +203,14 @@ export interface ParentsNavigationModel {
createButton?: AnyComponent
}

/**
* @public
*/
export interface QueryOptions {
// If specified should display only documents from the current space
filterBySpace?: boolean
}

/**
* @public
*/
Expand Down
2 changes: 1 addition & 1 deletion rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -2284,7 +2284,7 @@
{
"packageName": "@hcengineering/mail",
"projectFolder": "plugins/mail",
"shouldPublish": false
"shouldPublish": true
},
{
"packageName": "@hcengineering/model-mail",
Expand Down

0 comments on commit f86beb0

Please sign in to comment.