Skip to content

Commit

Permalink
Merge pull request #383 from NYPL/main
Browse files Browse the repository at this point in the history
Search results title bug fix
  • Loading branch information
charmingduchess authored Oct 28, 2024
2 parents 5d4c6bb + f732651 commit be79212
Show file tree
Hide file tree
Showing 14 changed files with 438 additions and 47 deletions.
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ NEXT_PUBLIC_APP_ENV="development"
PLATFORM_API_CLIENT_ID=[secret]
PLATFORM_API_CLIENT_SECRET=[secret]
NYPL_HEADER_URL=https://ds-header.nypl.org
CLOSED_LOCATIONS=""
RECAP_CLOSED_LOCATIONS=""
NON_RECAP_CLOSED_LOCATIONS=""
ADOBE_EMBED_URL=https://assets.adobedtm.com/1a9376472d37/ddf1bedfe52e/launch-4eefcc91c90e.min.js
SHEP_API=http://[fqdn]/api/v0.1
SIERRA_KEY=[secret]
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Prerelease

## Updated

- Better handling of bibs with no titles in SearchResultsBib model

## 1.3.5 2024-10-23

### Updated
Expand All @@ -14,7 +20,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Call number search scope to search dropdown options [(SCC-4260)](https://newyorkpubliclibrary.atlassian.net/browse/SCC-4260)
- Search tip per search scope [(SCC-4263)](https://newyorkpubliclibrary.atlassian.net/browse/SCC-4263)

### Added

- Add server side delivery location fetch and location utils (SCC-3759)

### Updated

- Moved closedLocations from environment variables to appConfig (SCC-3759)

### Fixed

### [1.3.4] Hotfix 2024-10-17

- Fix 500 error caused by assumption in buildHoldingDetails that location field will be present in the bib holdings returned from discovery (SCC-4314)
Expand Down
27 changes: 12 additions & 15 deletions ENVIRONMENTVARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,18 @@ If an environment variable is updated, make sure to restart the server for the a

These environment variables control how certain elements on the page render and where to fetch data.

| Variable | Type | Value Example | Description |
| ----------------------------------- | ------- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `NEXT_PUBLIC_APP_ENV` | string | "development" | App environment key used to determine various environment-specific app settings. |
| `NYPL_HEADER_URL` | string | "https://ds-header.nypl.org" | The base URL of the NYPL environment-specific header and footer scripts. |
| `CLOSED_LOCATIONS` | string | "all;Library of the Performing Arts" | A semicolon-delimited list of strings. Include quotes around the string. All locations beginning with any string in this list will be removed from the list of request options in the `ElectronicDelivery`, `HoldRequest`, and `ItemTableRow` components. Currently used physical locations: `Schwarzman;Science;Library for the Performing Arts;Schomburg`. To close all locations, add `all`. This will also remove EDD as a request option, the 'Request' buttons, and also disable the hold request/edd forms. If `all` is not present, EDD and 'Request' buttons will still be available. |
| `RECAP_CLOSED_LOCATIONS` | string | "" | A semicolon-delimited list of closed locations that are recap. |
| `NON_RECAP_CLOSED_LOCATIONS` | string | "" | A semicolon-delimited list of closed locations that are not recap. |
| `ADOBE_EMBED_URL` | string | "" | Url endpoint used for Adobe Analytics event tracking. |
| `SHEP_API` | string | "" | SHEP API endpoint used for fetching Subject Heading data |
| `SEARCH_RESULTS_NOTIFICATION` | string | "Due to winter holiday closures, the delivery time for off-site requests will be delayed..." | A string that can include HTML that will be rendered as a notification on the Home and Search Results pages. |
| `LOGIN_BASE_URL` | string | "" | The base URL used to construct the environment-dependent login/logout link. |
| `NEXT_PUBLIC_REVERSE_PROXY_ENABLED` | boolean | true | Feature flag that disables Next router navigation on Searches to fix issues navigating between research-catalog and discovery-front-end |
| `SIERRA_BASE` | string | "" | Sierra base url |
| `SOURCE_EMAIL` | string | "" | Default source email used in feedback form submissions |
| `LIB_ANSWERS_EMAIL` | string | "" | Destination email for feedback form submissions |
| Variable | Type | Value Example | Description |
| ----------------------------------- | ------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `NEXT_PUBLIC_APP_ENV` | string | "development" | App environment key used to determine various environment-specific app settings. |
| `NYPL_HEADER_URL` | string | "https://ds-header.nypl.org" | The base URL of the NYPL environment-specific header and footer scripts. |
| `ADOBE_EMBED_URL` | string | "" | Url endpoint used for Adobe Analytics event tracking. |
| `SHEP_API` | string | "" | SHEP API endpoint used for fetching Subject Heading data |
| `SEARCH_RESULTS_NOTIFICATION` | string | "Due to winter holiday closures, the delivery time for off-site requests will be delayed..." | A string that can include HTML that will be rendered as a notification on the Home and Search Results pages. |
| `LOGIN_BASE_URL` | string | "" | The base URL used to construct the environment-dependent login/logout link. |
| `NEXT_PUBLIC_REVERSE_PROXY_ENABLED` | boolean | true | Feature flag that disables Next router navigation on Searches to fix issues navigating between research-catalog and discovery-front-end |
| `SIERRA_BASE` | string | "" | Sierra base url |
| `SOURCE_EMAIL` | string | "" | Default source email used in feedback form submissions |
| `LIB_ANSWERS_EMAIL` | string | "" | Destination email for feedback form submissions |

## AWS ECS Environment Variables

Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const Layout = ({
padding: "2em 2em .5em 2em",
}}
>
<EDSBanner />
{showSearch && <EDSBanner />}
{showNotification && bannerNotification && (
<Banner
className={styles.banner}
Expand Down
12 changes: 6 additions & 6 deletions src/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseLocations } from "../utils/itemUtils"
import type { AppConfig, Environment } from "../types/appTypes"
import type { NYPLocationKey, RecapLocationKey } from "../types/locationTypes"

export const appConfig: AppConfig = {
environment:
Expand Down Expand Up @@ -78,11 +78,11 @@ export const appConfig: AppConfig = {
"https://www.nypl.org/help/request-research-materials",
tokenUrl: "https://isso.nypl.org/",
},
closedLocations: parseLocations(process.env.CLOSED_LOCATIONS),
recapClosedLocations: parseLocations(process.env.RECAP_CLOSED_LOCATIONS),
nonRecapClosedLocations: parseLocations(
process.env.NON_RECAP_CLOSED_LOCATIONS
),
// Array of closed nypl location keys (available options for NYPL locations: all, schwarzman, schomburg, lpa)
closedLocations: [] as (NYPLocationKey | "all")[],
// Array of closed recap location keys (only "all" option available for now)
recapClosedLocations: [] as (RecapLocationKey | "all")[],
nonRecapClosedLocations: [] as (NYPLocationKey | "all")[],
jwtPublicKey: `-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA44ilHg/PxcJYsISHMRyo
xsmez178qZpkJVXg7rOMVTLZuf05an7Pl+lX4nw/rqcvGQDXyrimciLgLkWu00xh
Expand Down
16 changes: 16 additions & 0 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { appConfig } from "./config"
import type { DeliveryLocation, NYPLocationKey } from "../types/locationTypes"

export const BASE_URL = "/research/research-catalog"
export const SITE_NAME = "Research Catalog | NYPL"
Expand Down Expand Up @@ -119,3 +120,18 @@ export const SEARCH_FORM_OPTIONS = {
placeholder: `${example} Ornithology or Greek Architecture`,
},
}

export const NYPL_LOCATIONS = {
lpa: {
shortName: "Library for the Performing Arts",
address: "40 Lincoln Center Plaza",
},
schomburg: {
shortName: "Schomburg Center",
address: "515 Malcolm X Boulevard",
},
schwarzman: {
shortName: "Schwarzman Building",
address: "476 Fifth Avenue (42nd St and Fifth Ave)",
},
}
2 changes: 1 addition & 1 deletion src/models/Bib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class Bib {

constructor(result: DiscoveryBibResult) {
this.id = result["@id"] ? result["@id"].substring(4) : ""
this.title = result.title[0] || ""
this.title = result.title?.[0] || result.titleDisplay?.[0] || "[Untitled]"
this.titleDisplay = this.getTitleDisplayFromResult(result)
this.electronicResources = result.electronicResources || null
this.numPhysicalItems = result.numItemsTotal || 0
Expand Down
16 changes: 16 additions & 0 deletions src/models/modelTests/SearchResultsBib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ describe("SearchResultsBib model", () => {
{ "@id": "urn:biblevel:s", prefLabel: "serial" },
])
})
it("defaults to title display when no title", () => {
const bibWithNoTitle = new SearchResultsBib({
...bibWithItems.resource,
title: undefined,
titleDisplay: ["Display title"],
})
expect(bibWithNoTitle.title).toBe("Display title")
})
it("defaults to '[Untitled]' when no title or titleDisplay", () => {
const bibWithNoTitle = new SearchResultsBib({
...bibWithItems.resource,
title: undefined,
titleDisplay: undefined,
})
expect(bibWithNoTitle.title).toBe("[Untitled]")
})

it("initializes the yearPublished based on dateStartYear and dateEndYear", () => {
expect(searchResultsBib.yearPublished).toBe("1999-present")
Expand Down
Loading

0 comments on commit be79212

Please sign in to comment.