diff --git a/src/index.js b/src/index.js index c54effadc7ea094ffbe0460747366dcbac7d90f8..efa1720ca4d8050cdb0d3701c48cd6e03ce60fe8 100644 --- a/src/index.js +++ b/src/index.js @@ -2,10 +2,12 @@ import miradorAnnotationPlugin from './plugins/miradorAnnotationPlugin'; import externalStorageAnnotationPlugin from './plugins/externalStorageAnnotationPlugin'; import canvasAnnotationsPlugin from './plugins/canvasAnnotationsPlugin'; import annotationCreationCompanionWindow from './plugins/annotationCreationCompanionWindow'; +import windowSideBarButtonsPlugin from './plugins/windowSideBarButtonsPlugin'; export { miradorAnnotationPlugin, externalStorageAnnotationPlugin, canvasAnnotationsPlugin, annotationCreationCompanionWindow, + windowSideBarButtonsPlugin, }; export default [ @@ -13,4 +15,5 @@ export default [ externalStorageAnnotationPlugin, canvasAnnotationsPlugin, annotationCreationCompanionWindow, + windowSideBarButtonsPlugin, ]; diff --git a/src/plugins/windowSideBarButtonsPlugin.js b/src/plugins/windowSideBarButtonsPlugin.js new file mode 100644 index 0000000000000000000000000000000000000000..7232f7594cd360e52df935fe623e02b31aff7676 --- /dev/null +++ b/src/plugins/windowSideBarButtonsPlugin.js @@ -0,0 +1,39 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; + +/** + * A wrapper plugin that sets hasAnyAnnotations to true so that the annotation + * companion window button is present + */ +class WindowSideBarButtonWrapper extends Component { + /** */ + render() { + const { PluginComponents, TargetComponent, targetProps } = this.props; + targetProps.hasAnyAnnotations = true; + return ( + <TargetComponent + {...targetProps} // eslint-disable-line react/jsx-props-no-spreading + PluginComponents={PluginComponents} + /> + ); + } +} + +WindowSideBarButtonWrapper.propTypes = { + PluginComponents: PropTypes.array, // eslint-disable-line react/forbid-prop-types + TargetComponent: PropTypes.oneOfType([ + PropTypes.func, + PropTypes.node, + ]).isRequired, + targetProps: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types +}; + +WindowSideBarButtonWrapper.defaultProps = { + PluginComponents: [], +}; + +export default { + component: WindowSideBarButtonWrapper, + mode: 'wrap', + target: 'WindowSideBarButtons', +};