Skip to content

Commit

Permalink
Merge branch 'staging' into develop
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <[email protected]>
  • Loading branch information
haiodo committed Feb 6, 2025
2 parents 7df63cf + dad177e commit 86494e7
Show file tree
Hide file tree
Showing 31 changed files with 291 additions and 163 deletions.
2 changes: 1 addition & 1 deletion dev/prod/public/config-worker.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

"DESKTOP_UPDATES_CHANNEL": "front",

"FILES_URL": "https://dl.hc.engineering/blob/:workspace/:blobId",
"FILES_URL": "https://dl.hc.engineering/blob/:workspace/:blobId/:filename",

"GITHUB_APP": "huly-github-staging",

Expand Down
10 changes: 5 additions & 5 deletions models/drive/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ function defineResource (builder: Builder): void {
key: '',
presenter: drive.component.ResourcePresenter,
label: drive.string.Name,
sortingKey: 'name'
sortingKey: 'title'
},
'$lookup.file.size',
'comments',
Expand All @@ -366,7 +366,7 @@ function defineResource (builder: Builder): void {
}
} as FindOptions<Resource>,
configOptions: {
hiddenKeys: ['name', 'parent', 'path', 'file', 'versions'],
hiddenKeys: ['title', 'parent', 'path', 'file', 'versions'],
sortable: true
}
},
Expand All @@ -393,7 +393,7 @@ function defineResource (builder: Builder): void {
viewOptions: {
groupBy: [],
orderBy: [
['name', SortingOrder.Ascending],
['title', SortingOrder.Ascending],
['$lookup.file.size', SortingOrder.Ascending],
['$lookup.file.modifiedOn', SortingOrder.Descending]
],
Expand All @@ -404,14 +404,14 @@ function defineResource (builder: Builder): void {
key: '',
presenter: drive.component.ResourcePresenter,
label: drive.string.Name,
sortingKey: 'name'
sortingKey: 'title'
},
'$lookup.file.size',
'$lookup.file.modifiedOn',
'createdBy'
],
configOptions: {
hiddenKeys: ['name', 'parent', 'path', 'file', 'versions'],
hiddenKeys: ['title', 'parent', 'path', 'file', 'versions'],
sortable: true
},
/* eslint-disable @typescript-eslint/consistent-type-assertions */
Expand Down
16 changes: 16 additions & 0 deletions packages/core/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,19 @@ export interface Storage {
export interface FulltextStorage {
searchFulltext: (query: SearchQuery, options: SearchOptions) => Promise<SearchResult>
}

export function shouldShowArchived<T extends Doc> (
query: DocumentQuery<T>,
options: FindOptions<T> | undefined
): boolean {
if (options?.showArchived !== undefined) {
return options.showArchived
}
if (query._id !== undefined && typeof query._id === 'string') {
return true
}
if (query.space !== undefined && typeof query.space === 'string') {
return true
}
return false
}
8 changes: 6 additions & 2 deletions packages/presentation/src/components/ObjectPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,17 @@
case 'disabled':
return { _id: { $nin: ignoreObjects, ..._idExtra } }
case 'fulltext':
return { $search: search, _id: { $nin: ignoreObjects, ..._idExtra } }
return search !== ''
? { $search: search, _id: { $nin: ignoreObjects, ..._idExtra } }
: { _id: { $nin: ignoreObjects, ..._idExtra } }
case 'spotlight':
return extraItems.length > 0
? { _id: { $in: extraItems, $nin: ignoreObjects } }
: { _id: { $nin: ignoreObjects, ..._idExtra } }
default:
return { [searchField]: { $like: '%' + search + '%' }, _id: { $nin: ignoreObjects, ..._idExtra } }
return search !== ''
? { [searchField]: { $like: '%' + search + '%' }, _id: { $nin: ignoreObjects, ..._idExtra } }
: { _id: { $nin: ignoreObjects, ..._idExtra } }
}
})()
}
Expand Down
73 changes: 28 additions & 45 deletions packages/presentation/src/components/PDFViewer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script lang="ts">
// import { Doc } from '@hcengineering/core'
import type { Blob, Ref } from '@hcengineering/core'
import { Button, Dialog, Label, Spinner } from '@hcengineering/ui'
import { Button, Dialog, EmbeddedPDF, Label, Spinner } from '@hcengineering/ui'
import { createEventDispatcher, onMount } from 'svelte'
import presentation, { getFileUrl } from '..'
import ActionContext from './ActionContext.svelte'
Expand Down Expand Up @@ -45,22 +45,9 @@
})
let download: HTMLAnchorElement
$: srcRef = file !== undefined ? getFileUrl(file, name) : undefined
$: src = file !== undefined ? getFileUrl(file, name) : undefined
$: isImage = contentType !== undefined && contentType.startsWith('image/')
let frame: HTMLIFrameElement | undefined = undefined
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
$: if (css !== undefined && frame !== undefined && frame !== null) {
frame.onload = () => {
const head = frame?.contentDocument?.querySelector('head')
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
if (css !== undefined && head !== undefined && head !== null) {
head.appendChild(document.createElement('style')).textContent = css
}
}
}
</script>

<ActionContext context={{ mode: 'browser' }} />
Expand All @@ -85,41 +72,37 @@
</svelte:fragment>

<svelte:fragment slot="utils">
{#await srcRef then src}
{#if !isLoading && src !== ''}
<a class="no-line" href={src} download={name} bind:this={download}>
<Button
icon={Download}
kind={'ghost'}
on:click={() => {
download.click()
}}
showTooltip={{ label: presentation.string.Download }}
/>
</a>
{/if}
{/await}
{#if !isLoading && src !== ''}
<a class="no-line" href={src} download={name} bind:this={download}>
<Button
icon={Download}
kind={'ghost'}
on:click={() => {
download.click()
}}
showTooltip={{ label: presentation.string.Download }}
/>
</a>
{/if}
</svelte:fragment>

{#await srcRef then src}
{#if !isLoading}
{#if src === '' || src === undefined}
<div class="centered">
<Label label={presentation.string.FailedToPreview} />
</div>
{:else if isImage}
<div class="pdfviewer-content img">
<img class="img-fit" {src} alt="" />
</div>
{:else}
<iframe bind:this={frame} class="pdfviewer-content" src={src + '#view=FitH&navpanes=0'} title="" />
{/if}
{:else}
{#if !isLoading}
{#if src === '' || src === undefined}
<div class="centered">
<Spinner size="medium" />
<Label label={presentation.string.FailedToPreview} />
</div>
{:else if isImage}
<div class="pdfviewer-content img">
<img class="img-fit" {src} alt="" />
</div>
{:else}
<EmbeddedPDF {src} {name} {css} fit />
{/if}
{/await}
{:else}
<div class="centered">
<Spinner size="medium" />
</div>
{/if}
</Dialog>

<style lang="scss">
Expand Down
4 changes: 2 additions & 2 deletions packages/query/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import core, {
getObjectValue,
matchQuery,
reduceCalls,
shouldShowArchived,
toFindResult
} from '@hcengineering/core'
import { PlatformError } from '@hcengineering/platform'
Expand Down Expand Up @@ -519,8 +520,7 @@ export class LiveQuery implements WithTx, Client {
if (q.options?.lookup !== undefined) {
options.lookup = q.options?.lookup
}
const showArchived: boolean =
options?.showArchived ?? (q.query._id !== undefined && typeof q.query._id === 'string')
const showArchived = shouldShowArchived(q.query, q.options)

options.showArchived = showArchived
const docIdKey = _id + JSON.stringify(options ?? {}) + q._class
Expand Down
88 changes: 88 additions & 0 deletions packages/ui/src/components/EmbeddedPDF.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<!--
// Copyright © 2025 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 { onDestroy } from 'svelte'
import Loading from './Loading.svelte'
export let src: string
export let name: string
export let fit: boolean = false
export let css: string | undefined = undefined
let iframeSrc: string | undefined = undefined
async function loadFile (src: string): Promise<void> {
if (iframeSrc !== undefined) {
URL.revokeObjectURL(iframeSrc)
iframeSrc = undefined
}
const response = await fetch(src)
const blob = await response.blob()
iframeSrc = URL.createObjectURL(blob)
}
$: void loadFile(src)
let iframe: HTMLIFrameElement | undefined = undefined
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
$: if (css !== undefined && iframe !== undefined && iframe !== null) {
iframe.onload = () => {
const head = iframe?.contentDocument?.querySelector('head')
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
if (css !== undefined && head !== undefined && head !== null) {
head.appendChild(document.createElement('style')).textContent = css
}
}
if (iframe.contentDocument !== undefined) {
const style = iframe.contentDocument?.querySelector('head style')
if (style != null) {
style.textContent = css
}
}
}
onDestroy(() => {
if (iframeSrc !== undefined) {
URL.revokeObjectURL(iframeSrc)
}
})
</script>

{#if iframeSrc}
<iframe bind:this={iframe} class:fit src={iframeSrc + '#view=FitH&navpanes=0'} title={name} on:load />
{:else}
<Loading />
{/if}

<style lang="scss">
iframe {
width: 100%;
border: none;
&.fit {
min-height: 100%;
}
&:not(.fit) {
height: 80vh;
min-height: 20rem;
}
}
</style>
1 change: 1 addition & 0 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export { default as CodeForm } from './components/CodeForm.svelte'
export { default as CodeInput } from './components/CodeInput.svelte'
export { default as TimeLeft } from './components/TimeLeft.svelte'
export { default as SectionEmpty } from './components/SectionEmpty.svelte'
export { default as EmbeddedPDF } from './components/EmbeddedPDF.svelte'

export { default as Dock } from './components/Dock.svelte'

Expand Down
1 change: 1 addition & 0 deletions plugins/contact-resources/src/components/Contacts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
bind:viewlet
bind:preference
bind:loading
ignoreFragment
viewletQuery={{
attachTo: contact.class.Contact,
descriptor: view.viewlet.Table
Expand Down
28 changes: 2 additions & 26 deletions plugins/print-resources/src/components/DOCXViewer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { type Blob, type Ref } from '@hcengineering/core'
import { getMetadata } from '@hcengineering/platform'
import presentation, { BlobMetadata, getFileUrl } from '@hcengineering/presentation'
import { Spinner, themeStore } from '@hcengineering/ui'
import { EmbeddedPDF, Spinner, themeStore } from '@hcengineering/ui'
import { convertToHTML } from '@hcengineering/print'
export let value: Ref<Blob>
Expand Down Expand Up @@ -55,7 +55,6 @@
--scrollbar-bar-color: #e0e0e0;
--scrollbar-bar-hover: #90959d;
`
let oldColors = colors
$: css = `
* {
Expand Down Expand Up @@ -262,29 +261,6 @@
border-radius: 2px;
}
`
let frame: HTMLIFrameElement | undefined = undefined
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
$: if (css !== undefined && frame !== undefined && frame !== null) {
frame.onload = () => {
const head = frame?.contentDocument?.querySelector('head')
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
if (css !== undefined && head !== undefined && head !== null) {
head.appendChild(document.createElement('style')).textContent = css
oldColors = colors
}
}
}
$: if (oldColors !== colors && css !== undefined && frame != null) {
const style = frame?.contentDocument?.querySelector('head style')
if (style != null) {
style.textContent = css
oldColors = colors
}
}
</script>

{#if src}
Expand All @@ -293,7 +269,7 @@
<Spinner size="medium" />
</div>
{:else}
<iframe bind:this={frame} src={src + '#view=FitH&navpanes=0'} class="w-full h-full" title={name} />
<EmbeddedPDF {src} {name} {css} />
{/if}
{/if}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
isRegular: true,
disableLink: true
}}
searchField={'code'}
excluded={excludedChangeControl}
kind={'regular'}
size={'small'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<Table
_class={recruit.class.Applicant}
config={preference?.config ?? viewlet.config}
options={{ showArchived: true }}
query={{ attachedTo: objectId, ...(viewlet?.baseQuery ?? {}) }}
loadingProps={{ length: applications }}
{readonly}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
_class={recruit.class.Applicant}
config={['', '$lookup.space.name', '$lookup.space.company', 'status']}
query={{ attachedTo: value._id }}
options={{ showArchived: true }}
loadingProps={{ length: value.applications ?? 0 }}
/>
</div>
Expand Down
Loading

0 comments on commit 86494e7

Please sign in to comment.