Commit 22529886 authored by Stefan Probst's avatar Stefan Probst
Browse files

fix: display embedded media, fix actor-search query

parent d32d49a4
Pipeline #223956 passed with stages
in 9 minutes and 48 seconds
This diff is collapsed.
......@@ -148,7 +148,8 @@ function ActorComboBox(props: ActorComboBoxProps): JSX.Element {
const [searchTerm, setSearchTerm] = useState(initialLabel)
const debouncedsearchTerm = useDebouncedState(searchTerm, 150).trim()
const actors = useSearchActors(
{ q: debouncedsearchTerm },
// @ts-expect-error Search on dynamic property
{ 'd.name': debouncedsearchTerm },
{
// enabled: debouncedsearchTerm.length > 2,
keepPreviousData: true,
......
......@@ -465,7 +465,7 @@ function sanitizeQuery(params?: ParsedUrlQuery): SearchActors.QueryParameters {
const sanitized = []
if (params.q != null && params.q.length > 0) {
sanitized.push(['q', params.q])
sanitized.push(['d.name', params.q])
}
if (params.page !== undefined) {
......
......@@ -127,7 +127,7 @@ export default function ModerateItemsScreen(): JSX.Element {
<ul className="space-y-2.5">
{items.data.items?.map((item) => {
return (
<li key={item.persistentId}>
<li key={item.persistentId + '-' + item.id}>
<ContributedItem item={item} />
</li>
)
......@@ -349,7 +349,7 @@ function SourceFacet(props: SourceFacetProps) {
variant="form"
aria-labelledby="facet-source"
onChange={onChange}
// defaultValue={filter['d.status']}
// defaultValue={filter['d.source']}
>
{allowedSources.map((source) => {
return (
......@@ -943,6 +943,8 @@ function sanitizeQuery(params?: ParsedUrlQuery): ItemSearchQuery {
'dataset',
'publication',
'tool-or-service',
'training-material',
'workflow',
]
const categories = ensureArray(params.categories).filter((category) =>
(allowedCategories as Array<string>).includes(category),
......
......@@ -30,6 +30,7 @@ import type {
ItemCategory as ItemCategoryWithStep,
ItemSearchQuery,
} from '@/api/sshoc/types'
import { Icon } from '@/elements/Icon/Icon'
import DocumentIcon from '@/elements/icons/small/document.svg'
import { useToast } from '@/elements/Toast/useToast'
import { useAuth } from '@/modules/auth/AuthContext'
......@@ -51,7 +52,7 @@ import { formatDate } from '@/utils/formatDate'
import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLabel'
import type { RequiredFields } from '@/utils/ts/object'
import { Svg as UrlIcon } from '@@/assets/icons/url.svg'
import OrcidIcon from '@@/public/assets/images/orcid.svg'
import { Svg as OrcidIcon } from '@@/public/assets/images/orcid.svg'
/** lazy load markdown processor */
const Markdown = dynamic(() => import('@/modules/markdown/Markdown'))
......@@ -399,6 +400,14 @@ function ItemMedia({ media }: { media: Item['media'] }) {
src={currentMediaUrl}
className="object-contain w-full h-full"
/>
) : currentMediaCategory === 'embed' ? (
<iframe
src={currentMediaUrl}
className="object-contain w-full h-full"
title="Embedded content"
allow="autoplay; fullscreen; picture-in-picture"
loading="lazy"
/>
) : (
<div className="grid place-items-center">
<a href={currentMediaUrl} download rel="noopener noreferrer">
......@@ -573,7 +582,7 @@ function useItemMetadata({
* Only show hidden properties for admins.
*/
if (property.type?.hidden === true) {
if (!user || !['Administrator', 'Moderator'].includes(user.role!)) {
if (!user || !['administrator', 'moderator'].includes(user.role!)) {
return
}
}
......@@ -682,9 +691,6 @@ function useItemMetadata({
</span>
<ul className="flex flex-col space-y-2">
{actors.map((actor) => {
const orcid = actor.externalIds?.find(
(a) => a.identifierService?.code === 'ORCID',
)
return (
<li key={actor.id} className="flex flex-col">
<span className="flex flex-wrap items-center">
......@@ -710,6 +716,12 @@ function useItemMetadata({
) : null}
{Array.isArray(actor.externalIds)
? actor.externalIds.map((id) => {
// TODO: should icons be returned on externalIds?
const icon =
id.identifierService?.code === 'ORCID'
? OrcidIcon
: null
return id.identifierService?.urlTemplate !=
null ? (
<Anchor
......@@ -717,12 +729,12 @@ function useItemMetadata({
'{source-actor-id}',
id.identifier!,
)}
className="flex items-center space-x-1.5"
>
{id.identifier}
{icon != null ? <Icon icon={icon} /> : null}
<span>{id.identifierService.label}</span>
</Anchor>
) : (
<span>{id.identifier}</span>
)
) : null
})
: null}
</li>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment