Skip to content

Commit 5b78a81

Browse files
committed
Some index fixes
1 parent 66c7a10 commit 5b78a81

File tree

8 files changed

+18980
-14050
lines changed

8 files changed

+18980
-14050
lines changed

package-lock.json

Lines changed: 18914 additions & 14017 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
"fairdigitalobject"
2727
],
2828
"scripts": {
29-
"storybook:dev": "storybook dev",
29+
"storybook:dev": "storybook dev -p 6006",
3030
"storybook:build": "storybook build",
31+
"storybook:test": "test-storybook",
3132
"build": "rm -rf ./dist && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.app.json && tailwind build -i src/index.css -o dist/index.css && cp ./src/elastic-ui.css ./dist"
3233
},
3334
"dependencies": {
@@ -76,6 +77,7 @@
7677
"@storybook/react": "^8.4.7",
7778
"@storybook/react-vite": "^8.4.7",
7879
"@storybook/test": "^8.4.7",
80+
"@storybook/test-runner": "^0.21.0",
7981
"@types/node": "^22.10.1",
8082
"@types/react": "^18.3.12",
8183
"@types/react-dom": "^18.3.1",

src/components/FairDOElasticSearch.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,27 @@ export function FairDOElasticSearch({
136136
)}
137137
/>
138138
)}
139-
{/*{wasSearched && (
140-
<Sorting
141-
sortOptions={[
142-
{
143-
name: "Relevance",
144-
value: "",
145-
direction: ""
146-
},
147-
{
148-
name: "Title",
149-
value: "name.keyword",
150-
direction: "asc"
151-
},
152-
{
153-
name: "Image",
154-
value: "locationPreview/Sample.keyword",
155-
direction: "asc"
156-
}
157-
]}
158-
/>
159-
)}*/}
139+
{/*{wasSearched && (*/}
140+
{/* <Sorting*/}
141+
{/* sortOptions={[*/}
142+
{/* {*/}
143+
{/* name: "Relevance",*/}
144+
{/* value: "_score",*/}
145+
{/* direction: ""*/}
146+
{/* },*/}
147+
{/* {*/}
148+
{/* name: "Title",*/}
149+
{/* value: "name",*/}
150+
{/* direction: "asc"*/}
151+
{/* },*/}
152+
{/* {*/}
153+
{/* name: "Image",*/}
154+
{/* value: "locationPreview/Sample.keyword",*/}
155+
{/* direction: "asc"*/}
156+
{/* }*/}
157+
{/* ]}*/}
158+
{/* />*/}
159+
{/*)}*/}
160160
</div>
161161
}
162162
bodyFooter={

src/components/result/GenericResultView.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ export interface GenericResultViewProps {
4848
*/
4949
digitalObjectLocationField?: string
5050

51+
/**
52+
* The elastic field where the landing page location will be read from
53+
*/
54+
landingPageLocationField?: string
55+
5156
/**
5257
* The elastic field where the PID of the current FDO will be read from. Can be omitted if you don't have a PID
5358
*/
@@ -99,6 +104,7 @@ export function GenericResultView({
99104
descriptionField = "description",
100105
imageField,
101106
invertImageInDarkMode = false,
107+
landingPageLocationField = "landingPageLocation",
102108
digitalObjectLocationField = "digitalObjectLocation",
103109
pidField = "pid",
104110
relatedItemPidsField = "isMetadataFor",
@@ -187,6 +193,10 @@ export function GenericResultView({
187193
else return `https://doi.org/${value}`
188194
}, [digitalObjectLocationField, getField])
189195

196+
const landingPageLocation = useMemo(() => {
197+
return getField(landingPageLocationField ?? "landingPageLocation")
198+
}, [getField, landingPageLocationField])
199+
190200
const previewImage = useMemo(() => {
191201
const images = getArrayOrSingleField(imageField ?? "imageURL")
192202
return Array.isArray(images) ? (images.length === 1 ? images[0] : images) : images
@@ -335,9 +345,9 @@ export function GenericResultView({
335345
</Button>
336346
)}
337347

338-
{doLocation && (
348+
{landingPageLocation && (
339349
<div className="rfs-flex rfs-items-center">
340-
<a href={doLocation} target="_blank" className="grow">
350+
<a href={landingPageLocation} target="_blank" className="grow">
341351
<Button size="sm" className="rfs-w-full rfs-rounded-r-none rfs-px-4">
342352
Open
343353
</Button>

src/components/result/GenericResultViewTag.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface GenericResultViewTagProps {
1515
export function GenericResultViewTag({ field, result, icon, label, valueMapper }: GenericResultViewTagProps) {
1616
const value = useMemo(() => {
1717
const value = autoUnwrap(result[field])
18+
if (!value) return undefined
1819
if (valueMapper) return valueMapper(value)
1920
else return value
2021
}, [field, result, valueMapper])
@@ -30,6 +31,7 @@ export function GenericResultViewTag({ field, result, icon, label, valueMapper }
3031
}, [icon, value])
3132

3233
if (!label) return base
34+
if (!value) return null
3335

3436
return (
3537
<Tooltip delayDuration={500}>

src/components/result/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export function autoUnwrap(item?: string | { raw?: string }) {
33
return undefined
44
} else if (typeof item === "string") {
55
return item
6-
} else if (typeof item === "object" && "raw" in item && typeof item.raw === "string") {
6+
} else if (typeof item === "object" && "raw" in item) {
77
return item.raw
88
} else {
99
return JSON.stringify(item)

src/components/search/SliderFacet.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Slider } from "@/components/ui/slider"
2+
import { useState } from "react"
3+
4+
export function SliderFacet() {
5+
const [value, setValue] = useState<number[]>([0, 1000])
6+
7+
return (
8+
<div className="rfs-px-4 rfs-pt-0 rfs-pb-8">
9+
<div className="rfs-text-sm rfs-font-bold rfs-pb-7">Compound</div>
10+
<Slider value={value} onValueChange={setValue} min={0} max={1000} step={0.1} className="rfs-w-full" />
11+
</div>
12+
)
13+
}

src/stories/FairDOElasticSearch.stories.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const demoConfig: FairDOConfig = {
2323
apiKey: "UGNoTW1KUUJ3WmluUHBTcEVpalo6cGloOUVKZ0tTdnlMYVlpTzV4SXBrUQ==",
2424
indices: [
2525
{
26-
name: "fdo-test-3",
26+
name: "fdo-test-4",
2727
facets: [
2828
{
2929
key: "resourceType.keyword",
@@ -79,7 +79,7 @@ const demoConfigWithCompound: FairDOConfig = {
7979
name: "fdo-test-4",
8080
facets: [
8181
{
82-
key: "Compound.keyword",
82+
key: "Compound.Molar_mass",
8383
label: "Compound",
8484
type: "min-max-slider"
8585
}
@@ -130,16 +130,19 @@ export const GenericResultRenderer: Story = {
130130
{
131131
icon: <GlobeIcon className="rfs-shrink-0 rfs-size-4 rfs-mr-2" />,
132132
field: "hadPrimarySource",
133-
valueMapper: tryURLPrettyPrint
133+
valueMapper: tryURLPrettyPrint,
134+
label: "Source"
134135
},
135136
{
136137
icon: <ScaleIcon className="rfs-shrink-0 rfs-size-4 rfs-mr-2" />,
137138
field: "licenseURL",
138-
valueMapper: tryURLPrettyPrint
139+
valueMapper: tryURLPrettyPrint,
140+
label: "License URL"
139141
},
140142
{
141143
icon: <AtomIcon className="rfs-shrink-0 rfs-size-4 rfs-mr-2" />,
142-
field: "Compound"
144+
field: "Compound.Molar_mass",
145+
label: "Molar Mass"
143146
}
144147
]}
145148
titleField="name"
@@ -173,16 +176,19 @@ export const CompoundSlider: Story = {
173176
{
174177
icon: <GlobeIcon className="rfs-shrink-0 rfs-size-4 rfs-mr-2" />,
175178
field: "hadPrimarySource",
176-
valueMapper: tryURLPrettyPrint
179+
valueMapper: tryURLPrettyPrint,
180+
label: "Source"
177181
},
178182
{
179183
icon: <ScaleIcon className="rfs-shrink-0 rfs-size-4 rfs-mr-2" />,
180184
field: "licenseURL",
181-
valueMapper: tryURLPrettyPrint
185+
valueMapper: tryURLPrettyPrint,
186+
label: "License URL"
182187
},
183188
{
184189
icon: <AtomIcon className="rfs-shrink-0 rfs-size-4 rfs-mr-2" />,
185-
field: "Compound"
190+
field: "Compound.Molar_mass",
191+
label: "Molar Mass"
186192
}
187193
]}
188194
titleField="name"

0 commit comments

Comments
 (0)