Skip to content

Commit 5595b44

Browse files
authored
Merge branch 'main' into bug_viewer_crash
2 parents c095751 + a8daa02 commit 5595b44

8 files changed

Lines changed: 38 additions & 17 deletions

File tree

__tests__/fixtures/config/export.example.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@
179179
"thumbnailNavigation": {
180180
"defaultPosition": "far-bottom",
181181
"height": 150,
182-
"width": 100
182+
"width": 100,
183+
"showThumbnailLabels": true
183184
},
184185
"workspace": {
185186
"type": "mosaic"

__tests__/src/components/ThumbnailCanvasGrouping.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function createWrapper(props) {
1818
top: 0,
1919
width: 100,
2020
}}
21+
showThumbnailLabels
2122
{...props}
2223
/>,
2324
);

__tests__/src/selectors/manifests.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ describe('getManifestSearchService', () => {
509509
});
510510

511511
it('supports v1 of the search spec', () => {
512-
const v1 = JSON.parse(JSON.stringify(manifestFixtureFg165hz3589));
512+
const v1 = structuredClone(manifestFixtureFg165hz3589);
513513
v1.service[0].profile = 'http://iiif.io/api/search/1/search';
514514
const state = { manifests: { x: { json: v1 } } };
515515
expect(getManifestSearchService(state, { manifestId: 'x' }).id).toEqual('https://contentsearch.stanford.edu/fg165hz3589/search');
@@ -528,7 +528,7 @@ describe('getManifestAutocompleteService', () => {
528528
});
529529

530530
it('supports v1 of the search spec', () => {
531-
const v1 = JSON.parse(JSON.stringify(manifestFixtureFg165hz3589));
531+
const v1 = structuredClone(manifestFixtureFg165hz3589);
532532
v1.service[0].profile = 'http://iiif.io/api/search/1/search';
533533
v1.service[0].service.profile = 'http://iiif.io/api/search/1/autocomplete';
534534
const state = { manifests: { x: { json: v1 } } };

src/components/ThumbnailCanvasGrouping.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class ThumbnailCanvasGrouping extends PureComponent {
3939
/** */
4040
render() {
4141
const {
42-
index, style, data, currentCanvasId,
42+
index, style, data, currentCanvasId, showThumbnailLabels,
4343
} = this.props;
4444
const {
4545
canvasGroupings, position, height,
@@ -87,7 +87,7 @@ export class ThumbnailCanvasGrouping extends PureComponent {
8787
<IIIFThumbnail
8888
key={canvas.id}
8989
resource={canvas}
90-
labelled
90+
labelled={showThumbnailLabels}
9191
maxHeight={(position === 'far-right') ? style.height - (1.5 * SPACING) : height - (1.5 * SPACING)}
9292
variant="inside"
9393
/>
@@ -103,5 +103,6 @@ ThumbnailCanvasGrouping.propTypes = {
103103
data: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
104104
index: PropTypes.number.isRequired,
105105
setCanvas: PropTypes.func.isRequired,
106+
showThumbnailLabels: PropTypes.bool.isRequired,
106107
style: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
107108
};

src/components/WorkspaceAdd.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useRef, useState } from 'react';
1+
import { useRef, useState, useEffect } from 'react';
22
import PropTypes from 'prop-types';
33
import { styled } from '@mui/material/styles';
44
import classNames from 'classnames';
@@ -44,6 +44,14 @@ export function WorkspaceAdd({
4444
const { t } = useTranslation();
4545
const [addResourcesOpen, setAddResourcesVisibility] = useState(false);
4646
const ref = useRef();
47+
const [refWidth, setRefWidth] = useState('100%');
48+
49+
/** */
50+
const updateRefWidth = () => {
51+
if (ref.current) {
52+
setRefWidth(ref.current.offsetWidth);
53+
}
54+
};
4755

4856
/** */
4957
const handleDrop = ({ manifestId, manifestJson }, props, monitor) => {
@@ -84,9 +92,19 @@ export function WorkspaceAdd({
8492
addResource, catalog, setWorkspaceAddVisibility, t, ...rest,
8593
};
8694

95+
useEffect(() => {
96+
window.addEventListener('resize', updateRefWidth);
97+
98+
updateRefWidth();
99+
100+
return () => {
101+
window.removeEventListener('resize', updateRefWidth);
102+
};
103+
}, []);
104+
87105
return (
88106
<IIIFDropTarget onDrop={handleDrop}>
89-
<StyledWorkspaceAdd ref={ref} className={classNames(ns('workspace-add'))}>
107+
<StyledWorkspaceAdd className={classNames(ns('workspace-add'))} ref={ref}>
90108
{catalog.length < 1 ? (
91109
<Grid
92110
alignItems="center"
@@ -138,10 +156,8 @@ export function WorkspaceAdd({
138156
sx={theme => ({
139157
'.MuiDrawer-paper': {
140158
borderTop: '0',
141-
left: '0',
142-
[theme.breakpoints.up('sm')]: {
143-
left: '65px',
144-
},
159+
left: 'unset',
160+
width: refWidth,
145161
},
146162
...(!addResourcesOpen && {
147163
display: 'none',

src/config/settings.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,15 +515,16 @@ export default {
515515
defaultPosition: 'off', // Which position for the thumbnail navigation to be be displayed. Other possible values are "far-bottom" or "far-right"
516516
displaySettings: true, // Display the settings for this in WindowTopMenu
517517
height: 130, // height of entire ThumbnailNavigation area when position is "far-bottom"
518+
showThumbnailLabels: true, // Configure if thumbnail labels should be displayed
518519
width: 100, // width of one canvas (doubled for book view) in ThumbnailNavigation area when position is "far-right"
519520
},
520521
workspace: {
521-
draggingEnabled: true,
522522
allowNewWindows: true,
523-
id: uuid(),
524-
isWorkspaceAddVisible: false, // Catalog/Workspace add window feature visible by default
523+
draggingEnabled: true,
525524
exposeModeOn: false, // unused?
526525
height: 5000, // height of the elastic mode's virtual canvas
526+
id: uuid(),
527+
isWorkspaceAddVisible: false, // Catalog/Workspace add window feature visible by default
527528
showZoomControls: true, // Configure if zoom controls should be displayed by default
528529
type: 'mosaic', // Which workspace type to load by default. Other possible values are "elastic". If "mosaic" or "elastic" are not selected no worksapce type will be used.
529530
viewportPosition: { // center coordinates for the elastic mode workspace

src/containers/ThumbnailCanvasGrouping.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { compose } from 'redux';
22
import { connect } from 'react-redux';
33
import { withPlugins } from '../extend/withPlugins';
44
import * as actions from '../state/actions';
5-
import { getCurrentCanvas } from '../state/selectors';
5+
import { getCurrentCanvas, getConfig } from '../state/selectors';
66
import { ThumbnailCanvasGrouping } from '../components/ThumbnailCanvasGrouping';
77

88
/**
@@ -21,6 +21,7 @@ const mapDispatchToProps = (dispatch, { data }) => ({
2121
*/
2222
const mapStateToProps = (state, { data }) => ({
2323
currentCanvasId: (getCurrentCanvas(state, { windowId: data.windowId }) || {}).id,
24+
showThumbnailLabels: getConfig(state).thumbnailNavigation.showThumbnailLabels,
2425
});
2526

2627
const enhance = compose(

src/state/selectors/manifests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { getConfig } from './config';
99
/** */
1010
function createManifestoInstance(json, locale) {
1111
if (!json) return undefined;
12-
// Use JSON stringify/parse to create a deep copy and prevent Manifesto from mutating the json
13-
const manifestoObject = Utils.parseManifest(JSON.parse(JSON.stringify(json)), locale ? { locale } : undefined);
12+
// Use structuredClone to create a deep copy and prevent Manifesto from mutating the json
13+
const manifestoObject = Utils.parseManifest(structuredClone(json), locale ? { locale } : undefined);
1414
if (manifestoObject) {
1515
// Local patching of Manifesto so that when its a Collection, it behaves similarly
1616
if (typeof manifestoObject.getSequences != 'function') {

0 commit comments

Comments
 (0)