Skip to content
Snippets Groups Projects
Commit b022a5db authored by Lutz Helm's avatar Lutz Helm
Browse files

Rename "download" to "export"

parent a2ee3f60
Branches
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@ const config = {
annotation: {
adapter: (canvasId) => new LocalStorageAdapter(`localStorage://?canvasId=${canvasId}`),
// adapter: (canvasId) => new AnnototAdapter(canvasId, endpointUrl),
downloadLocalStorageAnnotations: false,
exportLocalStorageAnnotations: false,
},
id: 'demo',
window: {
......
......@@ -11,12 +11,12 @@ import Typography from '@material-ui/core/Typography';
import PropTypes, { bool } from 'prop-types';
/** */
class AnnotationDownloadDialog extends Component {
class AnnotationExportDialog extends Component {
/** */
constructor(props) {
super(props);
this.state = {
downloadLinks: [],
exportLinks: [],
};
this.closeDialog = this.closeDialog.bind(this);
}
......@@ -46,8 +46,8 @@ class AnnotationDownloadDialog extends Component {
return resolvedAcc;
};
if (canvases && canvases.length > 0) {
canvases.reduce(reducer, []).then((downloadLinks) => {
this.setState({ downloadLinks });
canvases.reduce(reducer, []).then((exportLinks) => {
this.setState({ exportLinks });
});
}
}
......@@ -56,36 +56,36 @@ class AnnotationDownloadDialog extends Component {
/** */
closeDialog() {
const { handleClose } = this.props;
this.setState({ downloadLinks: [] });
this.setState({ exportLinks: [] });
handleClose();
}
/** */
render() {
const { handleClose, open } = this.props;
const { downloadLinks } = this.state;
const { exportLinks } = this.state;
return (
<Dialog
aria-labelledby="annotation-download-dialog-title"
id="annotation-download-dialog"
aria-labelledby="annotation-export-dialog-title"
id="annotation-export-dialog"
onClose={handleClose}
onEscapeKeyDown={this.closeDialog}
open={open}
>
<DialogTitle id="annotation-download-dialog-title" disableTypography>
<Typography variant="h2">Download Annotations</Typography>
<DialogTitle id="annotation-export-dialog-title" disableTypography>
<Typography variant="h2">Export Annotations</Typography>
</DialogTitle>
<DialogContent>
{ downloadLinks === undefined || downloadLinks.length === 0 ? (
{ exportLinks === undefined || exportLinks.length === 0 ? (
<Typography variant="body1">No annotations stored yet.</Typography>
) : (
<List>
{ downloadLinks.map((dl) => (
{ exportLinks.map((dl) => (
<ListItem
button
component="a"
key={dl.canvasId}
aria-label={`Download annotations for ${dl.label}`}
aria-label={`Export annotations for ${dl.label}`}
href={dl.url}
download={`${dl.id}.json`}
>
......@@ -93,7 +93,7 @@ class AnnotationDownloadDialog extends Component {
<GetAppIcon />
</ListItemIcon>
<ListItemText>
{`Download annotations for "${dl.label}"`}
{`Export annotations for "${dl.label}"`}
</ListItemText>
</ListItem>
))}
......@@ -105,7 +105,7 @@ class AnnotationDownloadDialog extends Component {
}
}
AnnotationDownloadDialog.propTypes = {
AnnotationExportDialog.propTypes = {
canvases: PropTypes.arrayOf(
PropTypes.shape({ id: PropTypes.string, index: PropTypes.number }),
).isRequired,
......@@ -118,4 +118,4 @@ AnnotationDownloadDialog.propTypes = {
open: bool.isRequired,
};
export default AnnotationDownloadDialog;
export default AnnotationExportDialog;
......@@ -5,7 +5,7 @@ import AddBoxIcon from '@material-ui/icons/AddBox';
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 AnnotationExportDialog from '../AnnotationExportDialog';
import LocalStorageAdapter from '../LocalStorageAdapter';
/** */
......@@ -14,10 +14,10 @@ class MiradorAnnotation extends Component {
constructor(props) {
super(props);
this.state = {
annotationDownloadDialogOpen: false,
annotationExportDialogOpen: false,
};
this.openCreateAnnotationCompanionWindow = this.openCreateAnnotationCompanionWindow.bind(this);
this.toggleCanvasDownloadDialog = this.toggleCanvasDownloadDialog.bind(this);
this.toggleCanvasExportDialog = this.toggleCanvasExportDialog.bind(this);
}
/** */
......@@ -32,10 +32,10 @@ class MiradorAnnotation extends Component {
}
/** */
toggleCanvasDownloadDialog(e) {
const { annotationDownloadDialogOpen } = this.state;
toggleCanvasExportDialog(e) {
const { annotationExportDialogOpen } = this.state;
const newState = {
annotationDownloadDialogOpen: !annotationDownloadDialogOpen,
annotationExportDialogOpen: !annotationExportDialogOpen,
};
this.setState(newState);
}
......@@ -45,10 +45,10 @@ class MiradorAnnotation extends Component {
const {
canvases, config, TargetComponent, targetProps,
} = this.props;
const { annotationDownloadDialogOpen } = this.state;
const { annotationExportDialogOpen } = this.state;
const storageAdapter = config.annotation && config.annotation.adapter('poke');
const offerDownloadDialog = config.annotation && storageAdapter instanceof LocalStorageAdapter
&& config.annotation.downloadLocalStorageAnnotations;
const offerExportDialog = config.annotation && storageAdapter instanceof LocalStorageAdapter
&& config.annotation.exportLocalStorageAnnotations;
return (
<div>
<TargetComponent
......@@ -61,21 +61,21 @@ class MiradorAnnotation extends Component {
>
<AddBoxIcon />
</MiradorMenuButton>
{ offerDownloadDialog && (
{ offerExportDialog && (
<MiradorMenuButton
aria-label="Download local annotations for visible items"
onClick={this.toggleCanvasDownloadDialog}
aria-label="Export local annotations for visible items"
onClick={this.toggleCanvasExportDialog}
size="small"
>
<GetAppIcon />
</MiradorMenuButton>
)}
{ offerDownloadDialog && (
<AnnotationDownloadDialog
{ offerExportDialog && (
<AnnotationExportDialog
canvases={canvases}
config={config}
handleClose={this.toggleCanvasDownloadDialog}
open={annotationDownloadDialogOpen}
handleClose={this.toggleCanvasExportDialog}
open={annotationExportDialogOpen}
/>
)}
</div>
......@@ -91,7 +91,7 @@ MiradorAnnotation.propTypes = {
config: PropTypes.shape({
annotation: PropTypes.shape({
adapter: PropTypes.func,
downloadLocalStorageAnnotations: PropTypes.bool,
exportLocalStorageAnnotations: PropTypes.bool,
}),
}).isRequired,
TargetComponent: PropTypes.oneOfType([
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment