diff --git a/demo/src/index.js b/demo/src/index.js index d501089b0f113d226c66c6bbedfa278a2175b976..6187e3a8916ae50511ff906394f4a32fcc923691 100644 --- a/demo/src/index.js +++ b/demo/src/index.js @@ -9,7 +9,7 @@ const config = { annotation: { adapter: (canvasId) => new LocalStorageAdapter(`localStorage://?canvasId=${canvasId}`), // adapter: (canvasId) => new AnnototAdapter(canvasId, endpointUrl), - // downloadCanvasAnnotations: true, + downloadLocalStorageAnnotations: false, }, id: 'demo', window: { diff --git a/src/AnnotationDownloadDialog.js b/src/AnnotationDownloadDialog.js index bcba9564be2f459279be6d3b3db9ece3353b40dc..832a09b289b351154edda410cda9922b7a8e3a2a 100644 --- a/src/AnnotationDownloadDialog.js +++ b/src/AnnotationDownloadDialog.js @@ -86,15 +86,14 @@ export class AnnotationDownloadDialog extends Component { component="a" key={dl.canvasId} aria-label={`Download annotations for ${dl.label}`} - startIcon={<GetAppIcon />} href={dl.url} - download={`annotations-${dl.id}.json`} + download={`${dl.id}.json`} > <ListItemIcon> <GetAppIcon /> </ListItemIcon> <ListItemText> - {`Download annotations for canvas "${dl.label}"`} + {`Download annotations for "${dl.label}"`} </ListItemText> </ListItem> ))} diff --git a/src/plugins/miradorAnnotationPlugin.js b/src/plugins/miradorAnnotationPlugin.js index 4845c8744f6debdc1570d326ddd52d38de73f0b6..e8bcf7bd17be5a9ca68f10caabc93bafae23354d 100644 --- a/src/plugins/miradorAnnotationPlugin.js +++ b/src/plugins/miradorAnnotationPlugin.js @@ -6,6 +6,7 @@ import GetAppIcon from '@material-ui/icons/GetApp'; import { MiradorMenuButton } from 'mirador/dist/es/src/components/MiradorMenuButton'; import { getVisibleCanvases } from 'mirador/dist/es/src/state/selectors/canvases'; import { AnnotationDownloadDialog } from '../AnnotationDownloadDialog'; +import LocalStorageAdapter from '../LocalStorageAdapter'; /** */ class MiradorAnnotation extends Component { @@ -45,7 +46,9 @@ class MiradorAnnotation extends Component { canvases, config, TargetComponent, targetProps, } = this.props; const { annotationDownloadDialogOpen } = this.state; - const showDownloadDialog = config.annotation && config.annotation.downloadCanvasAnnotations; + const storageAdapter = config.annotation && config.annotation.adapter('poke'); + const offerDownloadDialog = config.annotation && storageAdapter instanceof LocalStorageAdapter + && config.annotation.downloadLocalStorageAnnotations; return ( <div> <TargetComponent @@ -58,16 +61,16 @@ class MiradorAnnotation extends Component { > <AddBoxIcon /> </MiradorMenuButton> - { showDownloadDialog && ( + { offerDownloadDialog && ( <MiradorMenuButton - aria-label="Download annotation page for canvas" + aria-label="Download local annotations for visible items" onClick={this.toggleCanvasDownloadDialog} size="small" > <GetAppIcon /> </MiradorMenuButton> )} - { showDownloadDialog && ( + { offerDownloadDialog && ( <AnnotationDownloadDialog canvases={canvases} config={config} @@ -88,7 +91,7 @@ MiradorAnnotation.propTypes = { config: PropTypes.shape({ annotation: PropTypes.shape({ adapter: PropTypes.func, - downloadCanvasAnnotations: PropTypes.bool, + downloadLocalStorageAnnotations: PropTypes.bool, }), }).isRequired, TargetComponent: PropTypes.oneOfType([