Skip to content

Commit

Permalink
Use context to pass the window id around
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Feb 28, 2023
1 parent e0cfcc7 commit c474cc9
Show file tree
Hide file tree
Showing 81 changed files with 250 additions and 140 deletions.
1 change: 0 additions & 1 deletion src/components/AnnotationSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ AnnotationSettings.propTypes = {
displayAllDisabled: PropTypes.bool.isRequired,
t: PropTypes.func.isRequired,
toggleAnnotationDisplay: PropTypes.func.isRequired,
windowId: PropTypes.string.isRequired, // eslint-disable-line react/no-unused-prop-types
};
3 changes: 0 additions & 3 deletions src/components/AttributionPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class AttributionPanel extends Component {
manifestLogo,
requiredStatement,
rights,
windowId,
id,
classes,
t,
Expand All @@ -32,7 +31,6 @@ export class AttributionPanel extends Component {
<CompanionWindow
title={t('attributionTitle')}
paperClassName={ns('attribution-panel')}
windowId={windowId}
id={id}
>
<div className={classes.section}>
Expand Down Expand Up @@ -85,7 +83,6 @@ AttributionPanel.propTypes = {
})),
rights: PropTypes.arrayOf(PropTypes.string),
t: PropTypes.func,
windowId: PropTypes.string.isRequired,
};

AttributionPanel.defaultProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/CompanionArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class CompanionArea extends Component {
<div className={[ns('companion-windows'), companionWindowIds.length > 0 && classes[position], this.areaLayoutClass()].join(' ')} style={{ display: companionAreaOpen ? 'flex' : 'none' }}>
{
companionWindowIds.map(id => (
<CompanionWindowFactory id={id} key={id} windowId={windowId} />
<CompanionWindowFactory id={id} key={id} />
))
}
</div>
Expand Down
7 changes: 2 additions & 5 deletions src/components/CompanionWindowFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export class CompanionWindowFactory extends Component {
render() {
const {
content,
windowId,
id,
t,
} = this.props;
Expand All @@ -50,10 +49,9 @@ export class CompanionWindowFactory extends Component {
return (
<CompanionWindow
title={t('error')}
windowId={windowId}
id={id}
>
<ErrorContent error={error} windowId={windowId} companionWindowId={id} />
<ErrorContent error={error} companionWindowId={id} />
</CompanionWindow>
);
}
Expand All @@ -62,15 +60,14 @@ export class CompanionWindowFactory extends Component {

if (!type) return null;

return createElement(type, { id, windowId });
return createElement(type, { id });
}
}

CompanionWindowFactory.propTypes = {
content: PropTypes.string,
id: PropTypes.string.isRequired,
t: PropTypes.func,
windowId: PropTypes.string.isRequired,
};

CompanionWindowFactory.defaultProps = {
Expand Down
3 changes: 0 additions & 3 deletions src/components/CustomPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ export class CustomPanel extends Component {
children,
t,
title,
windowId,
} = this.props;

return (
<CompanionWindow
title={t(title)}
id={id}
windowId={windowId}
>
{children}
</CompanionWindow>
Expand All @@ -35,7 +33,6 @@ CustomPanel.propTypes = {
id: PropTypes.string.isRequired,
t: PropTypes.func.isRequired,
title: PropTypes.string.isRequired,
windowId: PropTypes.string.isRequired,
};

CustomPanel.defaultProps = {
Expand Down
5 changes: 1 addition & 4 deletions src/components/GalleryView.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class GalleryView extends Component {
*/
render() {
const {
canvases, classes, viewingDirection, windowId,
canvases, classes, viewingDirection,
} = this.props;
const htmlDir = viewingDirection === 'right-to-left' ? 'rtl' : 'ltr';
return (
Expand All @@ -22,13 +22,11 @@ export class GalleryView extends Component {
square
elevation={0}
className={classes.galleryContainer}
id={`${windowId}-gallery`}
>
{
canvases.map(canvas => (
<GalleryViewThumbnail
key={canvas.id}
windowId={windowId}
canvas={canvas}
/>
))
Expand All @@ -42,7 +40,6 @@ GalleryView.propTypes = {
canvases: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
classes: PropTypes.objectOf(PropTypes.string),
viewingDirection: PropTypes.string,
windowId: PropTypes.string.isRequired,
};

GalleryView.defaultProps = {
Expand Down
3 changes: 1 addition & 2 deletions src/components/IIIFAuthentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ export class IIIFAuthentication extends Component {
/** */
defaultAuthBarProps() {
const {
authServiceId, windowId, status, logoutServiceId,
authServiceId, status, logoutServiceId,
} = this.props;

return {
authServiceId,
hasLogoutService: !!logoutServiceId,
status,
windowId,
};
}

Expand Down
4 changes: 0 additions & 4 deletions src/components/LayersPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,19 @@ export class LayersPanel extends Component {
canvasIds,
id,
t,
windowId,
} = this.props;

return (
<CompanionWindow
title={t('layers')}
id={id}
windowId={windowId}
>
{canvasIds.map((canvasId, index) => (
<CanvasLayers
canvasId={canvasId}
index={index}
key={canvasId}
totalSize={canvasIds.length}
windowId={windowId}
/>
))}
</CompanionWindow>
Expand All @@ -42,7 +39,6 @@ LayersPanel.propTypes = {
canvasIds: PropTypes.arrayOf(PropTypes.string),
id: PropTypes.string.isRequired,
t: PropTypes.func.isRequired,
windowId: PropTypes.string.isRequired,
};

LayersPanel.defaultProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/OpenSeadragonViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export class OpenSeadragonViewer extends Component {
aria-live="polite"
>
{ drawAnnotations
&& <AnnotationsOverlay viewer={viewer} windowId={windowId} /> }
&& <AnnotationsOverlay viewer={viewer} /> }
{ enhancedChildren }
<PluginHook viewer={viewer} {...{ ...this.props, children: null }} />
</section>
Expand Down
31 changes: 10 additions & 21 deletions src/components/PrimaryWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,31 @@ export class PrimaryWindow extends Component {
renderViewer() {
const {
audioResources, isCollection,
isFetching, videoResources, view, windowId,
isFetching, videoResources, view,
} = this.props;
if (isCollection) {
return (
<SelectCollection
windowId={windowId}
/>
<SelectCollection />
);
}
if (isFetching === false) {
if (view === 'gallery') {
return (
<GalleryView
windowId={windowId}
/>
<GalleryView />
);
}
if (videoResources.length > 0) {
return (
<VideoViewer
windowId={windowId}
/>
<VideoViewer />
);
}
if (audioResources.length > 0) {
return (
<AudioViewer
windowId={windowId}
/>
<AudioViewer />
);
}
return (
<WindowViewer
windowId={windowId}
/>
<WindowViewer />
);
}
return null;
Expand All @@ -74,13 +64,13 @@ export class PrimaryWindow extends Component {
*/
render() {
const {
isCollectionDialogVisible, windowId, classes, children,
isCollectionDialogVisible, classes, children,
} = this.props;
return (
<div className={classNames(ns('primary-window'), classes.primaryWindow)}>
<WindowSideBar windowId={windowId} />
<CompanionArea windowId={windowId} position="left" />
{ isCollectionDialogVisible && <CollectionDialog windowId={windowId} /> }
<WindowSideBar />
<CompanionArea position="left" />
{ isCollectionDialogVisible && <CollectionDialog /> }
<Suspense fallback={<div />}>
{children || this.renderViewer()}
</Suspense>
Expand All @@ -98,7 +88,6 @@ PrimaryWindow.propTypes = {
isFetching: PropTypes.bool,
videoResources: PropTypes.arrayOf(PropTypes.object), // eslint-disable-line react/forbid-prop-types
view: PropTypes.string,
windowId: PropTypes.string.isRequired,
};

PrimaryWindow.defaultProps = {
Expand Down
6 changes: 1 addition & 5 deletions src/components/SearchPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export class SearchPanel extends Component {
const {
classes,
fetchSearch,
windowId,
id,
query,
removeSearch,
Expand Down Expand Up @@ -51,15 +50,13 @@ export class SearchPanel extends Component {
}
</>
)}
windowId={windowId}
id={id}
titleControls={<SearchPanelControls companionWindowId={id} windowId={windowId} />}
titleControls={<SearchPanelControls companionWindowId={id} />}
ref={this.containerRef}
>
<SearchResults
containerRef={this.containerRef}
companionWindowId={id}
windowId={windowId}
/>
{
fetchSearch && suggestedSearches && query === '' && suggestedSearches.map(search => (
Expand Down Expand Up @@ -89,7 +86,6 @@ SearchPanel.propTypes = {
}).isRequired,
suggestedSearches: PropTypes.arrayOf(PropTypes.string),
t: PropTypes.func,
windowId: PropTypes.string.isRequired,
};

SearchPanel.defaultProps = {
Expand Down
4 changes: 2 additions & 2 deletions src/components/SearchPanelControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class SearchPanelControls extends Component {
/** */
render() {
const {
classes, companionWindowId, searchIsFetching, t, windowId,
classes, companionWindowId, searchIsFetching, t,
} = this.props;

const { search, suggestions } = this.state;
Expand Down Expand Up @@ -152,7 +152,7 @@ export class SearchPanelControls extends Component {
)}
/>
</form>
<SearchPanelNavigation windowId={windowId} companionWindowId={companionWindowId} />
<SearchPanelNavigation companionWindowId={companionWindowId} />
</>
);
}
Expand Down
1 change: 0 additions & 1 deletion src/components/SearchPanelNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ SearchPanelNavigation.propTypes = {
selectAnnotation: PropTypes.func.isRequired,
selectedContentSearchAnnotation: PropTypes.arrayOf(PropTypes.string).isRequired,
t: PropTypes.func,
windowId: PropTypes.string.isRequired, // eslint-disable-line react/no-unused-prop-types
};
SearchPanelNavigation.defaultProps = {
classes: {},
Expand Down
3 changes: 0 additions & 3 deletions src/components/SearchResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class SearchResults extends Component {
containerRef,
searchAnnotations,
searchHits,
windowId,
} = this.props;
const {
focused,
Expand All @@ -55,7 +54,6 @@ export class SearchResults extends Component {
focused={focused}
index={index}
total={searchAnnotations.length}
windowId={windowId}
showDetails={this.toggleFocus}
/>
));
Expand All @@ -71,7 +69,6 @@ export class SearchResults extends Component {
hit={hit}
index={index}
total={searchHits.length}
windowId={windowId}
showDetails={this.toggleFocus}
/>
));
Expand Down
3 changes: 0 additions & 3 deletions src/components/ThumbnailNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ export class ThumbnailNavigation extends Component {
position,
thumbnailNavigation,
viewingDirection,
windowId,
} = this.props;
if (position === 'off') {
return null;
Expand All @@ -190,7 +189,6 @@ export class ThumbnailNavigation extends Component {
canvasGroupings,
height: thumbnailNavigation.height - this.spacing - this.scrollbarSize,
position,
windowId,
};
return (
<Paper
Expand Down Expand Up @@ -245,7 +243,6 @@ ThumbnailNavigation.propTypes = {
thumbnailNavigation: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
view: PropTypes.string,
viewingDirection: PropTypes.string,
windowId: PropTypes.string.isRequired,
};

ThumbnailNavigation.defaultProps = {
Expand Down
Loading

0 comments on commit c474cc9

Please sign in to comment.