Skip to content
Snippets Groups Projects
Commit 19fee425 authored by Anthony's avatar Anthony
Browse files

WIP moving video support on MUI5

parent 3def696e
No related tags found
No related merge requests found
Pipeline #1642 failed
import React, { Component } from 'react'; import React, { Component, useState } from 'react';
import Accordion from '@mui/material/Accordion'; import Accordion from '@mui/material/Accordion';
import AccordionSummary from '@mui/material/AccordionSummary'; import AccordionSummary from '@mui/material/AccordionSummary';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
...@@ -10,14 +10,7 @@ import AnnotationManifestsItem from '../containers/AnnotationManifestsItem'; ...@@ -10,14 +10,7 @@ import AnnotationManifestsItem from '../containers/AnnotationManifestsItem';
/** /**
* AnnotationManifestsAccordion * AnnotationManifestsAccordion
*/ */
export class AnnotationManifestsAccordion extends Component { export default function AnnotationManifestsAccordion({ annotation, classes, ...props }) {
/**
* constructor
*/
constructor(props) {
super(props);
this.handleOpenAccordion = this.handleOpenAccordion.bind(this);
/** Search if the annotation is a manifest. URL must be resolvable for the annotation. So the manifest url is added at the end of the id */ /** Search if the annotation is a manifest. URL must be resolvable for the annotation. So the manifest url is added at the end of the id */
function searchManifestInID(id) { function searchManifestInID(id) {
const match = id.match( const match = id.match(
...@@ -26,38 +19,20 @@ export class AnnotationManifestsAccordion extends Component { ...@@ -26,38 +19,20 @@ export class AnnotationManifestsAccordion extends Component {
return match ? match[0].split('#').slice(-1) : null; return match ? match[0].split('#').slice(-1) : null;
} }
const { annotation } = this.props; const [annotationDisplayed, setAnnotationDisplayed] = useState(annotation);
annotationDisplayed.manifestsOpen = false;
annotation.manifestsOpen = false; annotationDisplayed.manifests = searchManifestInID(annotationDisplayed.id);
annotation.manifests = searchManifestInID(annotation.id); if (annotationDisplayed.manifests) {
if (annotation.manifests) { annotationDisplayed.manifests = annotationDisplayed.manifests.map(id => ({ id }));
annotation.manifests = annotation.manifests.map(id => ({ id }));
} else { } else {
annotation.manifests = []; annotationDisplayed.manifests = [];
}
this.state = { annotation };
} }
/** */ /** */
// eslint-disable-next-line class-methods-use-this,require-jsdoc function handleOpenAccordion(e) {
handleOpenAccordion(e) { annotationDisplayed.manifestsOpen = true;
const { annotation } = this.state; setAnnotationDisplayed(annotationDisplayed);
annotation.manifestsOpen = true;
e.stopPropagation(); e.stopPropagation();
this.state = { annotation };
}
/** */
render() {
const {
classes, t, i18n,
} = this.props;
const { annotation } = this.state;
if (annotation.manifests === null || annotation.manifests.length === 0) {
return null;
} }
return ( return (
...@@ -65,19 +40,17 @@ export class AnnotationManifestsAccordion extends Component { ...@@ -65,19 +40,17 @@ export class AnnotationManifestsAccordion extends Component {
<Accordion> <Accordion>
<AccordionSummary <AccordionSummary
expandIcon={<ExpandMoreIcon />} expandIcon={<ExpandMoreIcon />}
onClick={(e) => this.handleOpenAccordion(e)} onClick={(e) => handleOpenAccordion(e)}
> >
<Typography className={classes.heading}>{t('manifestFound')}</Typography> <Typography>manifestFound</Typography>
</AccordionSummary> </AccordionSummary>
{ {
annotation.manifestsOpen && ( annotationDisplayed.manifestsOpen && (
<AccordionDetails className={classes.manifestContainer}> <AccordionDetails>
{annotation.manifests.map(manifest => ( {annotationDisplayed.manifests.map(manifest => (
<AnnotationManifestsItem <AnnotationManifestsItem
manifestId={manifest.id} manifestId={manifest.id}
language={i18n.language}
key={manifest} key={manifest}
t={t}
/> />
))} ))}
</AccordionDetails> </AccordionDetails>
...@@ -87,7 +60,6 @@ export class AnnotationManifestsAccordion extends Component { ...@@ -87,7 +60,6 @@ export class AnnotationManifestsAccordion extends Component {
</div> </div>
); );
} }
}
AnnotationManifestsAccordion.propsTypes = { AnnotationManifestsAccordion.propsTypes = {
annotation: PropTypes.shape( annotation: PropTypes.shape(
......
import { compose } from 'redux'; import { compose } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
import { withStyles } from '@mui/styles';
import { withPlugins } from '../extend/withPlugins'; import { withPlugins } from '../extend/withPlugins';
import { AnnotationManifestsAccordion } from '../components/AnnotationManifestsAccordion'; import AnnotationManifestsAccordion from '../components/AnnotationManifestsAccordion';
import { getConfig } from '../state/selectors'; import { getConfig } from '../state/selectors';
/** For connect */ /** For connect */
...@@ -20,7 +19,7 @@ const mapDispatchToProps = { ...@@ -20,7 +19,7 @@ const mapDispatchToProps = {
}; };
/** For withStyles */ /** For TODO withStyles */
const styles = theme => ({ const styles = theme => ({
manifestContainer: { manifestContainer: {
display: 'flex', display: 'flex',
...@@ -32,7 +31,6 @@ const styles = theme => ({ ...@@ -32,7 +31,6 @@ const styles = theme => ({
const enhance = compose( const enhance = compose(
withTranslation(), withTranslation(),
withStyles(styles),
connect(mapStateToProps, mapDispatchToProps), connect(mapStateToProps, mapDispatchToProps),
withPlugins('AnnotationManifestsAccordion'), withPlugins('AnnotationManifestsAccordion'),
); );
......
import { compose } from 'redux'; import { compose } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
import { withStyles } from '@mui/styles';
import { withPlugins } from '../extend/withPlugins'; import { withPlugins } from '../extend/withPlugins';
import * as actions from '../state/actions'; import * as actions from '../state/actions';
import { ViewerNavigationVideo } from '../components/ViewerNavigationVideo'; import { ViewerNavigationVideo } from '../components/ViewerNavigationVideo';
...@@ -39,6 +38,7 @@ const mapDispatchToProps = (dispatch, { windowId }) => ({ ...@@ -39,6 +38,7 @@ const mapDispatchToProps = (dispatch, { windowId }) => ({
), ),
}); });
// TODO withStyles
const styles = { const styles = {
divider: { divider: {
borderRight: '1px solid #808080', borderRight: '1px solid #808080',
...@@ -69,7 +69,6 @@ const styles = { ...@@ -69,7 +69,6 @@ const styles = {
}; };
const enhance = compose( const enhance = compose(
withStyles(styles),
withTranslation(), withTranslation(),
connect(mapStateToProps, mapDispatchToProps), connect(mapStateToProps, mapDispatchToProps),
withPlugins('ViewerNavigationVideo'), withPlugins('ViewerNavigationVideo'),
......
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { compose } from 'redux'; import { compose } from 'redux';
import { withSize } from 'react-sizeme'; import { withSize } from 'react-sizeme';
import { styled } from '@mui/styles';
import { withPlugins } from '../extend/withPlugins'; import { withPlugins } from '../extend/withPlugins';
import { getWorkspace } from '../state/selectors'; import { getWorkspace } from '../state/selectors';
import { WindowCanvasNavigationControlsVideo } from '../components/WindowCanvasNavigationControlsVideo'; import { WindowCanvasNavigationControlsVideo } from '../components/WindowCanvasNavigationControlsVideo';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment