Skip to content

Commit

Permalink
Merge pull request #64 from EmmanuelDemey/lerna
Browse files Browse the repository at this point in the history
Modularisation (pour Nico)
  • Loading branch information
NicoLaval authored Aug 19, 2019
2 parents 78a9a8e + c3deb52 commit 0b6bc66
Show file tree
Hide file tree
Showing 24 changed files with 272 additions and 297 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import MenuClassifications from './';
import MenuClassifications from '.';

describe('menu-classifications', () => {
it('renders without crashing', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { Link, withRouter } from 'react-router-dom';
import MenuReferentiels from '../referentiels';
import MenuReferentiels from 'js/components/menu/referentiels';
import D from 'js/i18n';
import './classifications.scss';

Expand Down
100 changes: 100 additions & 0 deletions app/src/js/components/classifications/routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import React from 'react';
import { Switch, Route } from 'react-router-dom';

import ClassificationsFamiliesContainer from 'js/components/classifications/families/home-container';
import ClassificationsFamilyContainer from 'js/components/classifications/families/visualization/home-container';
import ClassificationsSeriesContainer from 'js/components/classifications/series/home-container';
import ClassificationsOneSeriesContainer from 'js/components/classifications/series/visualization/home-container';
import ClassificationsContainer from 'js/components/classifications/home-container';
import ClassificationContainer from 'js/components/classifications/visualization/home-container';
import ClassificationItemsContainer from 'js/components/classifications/visualization/items/home-container';
import ClassificationTreeContainer from 'js/components/classifications/visualization/tree/home-container';
import ClassificationLevelContainer from 'js/components/classifications/level/home-container';
import ClassificationItemContainer from 'js/components/classifications/item/home-container';
import ClassificationItemCompareContainer from 'js/components/classifications/item/compare/home-container';
import ClassificationsCorrespondencesContainer from 'js/components/classifications/correspondences/home-container';
import ClassificationsCorrespondenceContainer from 'js/components/classifications/correspondences/visualization/home-container';
import ClassificationsCorrespondenceAssociationContainer from 'js/components/classifications/correspondences/association/home-container';
import D from 'js/i18n';
import Menu from 'js/components/classifications/menu';

export default () => {
document.title = 'Bauhaus - ' + D.classificationsTitle;
return (
<>
<Menu />
<Switch>
<Route
exact
path="/classifications/families"
component={ClassificationsFamiliesContainer}
/>
<Route
exact
path="/classifications/family/:id"
component={ClassificationsFamilyContainer}
/>
<Route
exact
path="/classifications/series"
component={ClassificationsSeriesContainer}
/>
<Route
exact
path="/classifications/series/:id"
component={ClassificationsOneSeriesContainer}
/>
<Route
exact
path="/classifications"
component={ClassificationsContainer}
/>
<Route
exact
path="/classifications/classification/:id"
component={ClassificationContainer}
/>
<Route
exact
path="/classifications/classification/:id/items"
component={ClassificationItemsContainer}
/>
<Route
exact
path="/classifications/classification/:id/tree"
component={ClassificationTreeContainer}
/>
<Route
exact
path="/classifications/classification/:classificationId/level/:levelId"
component={ClassificationLevelContainer}
/>
<Route
exact
path="/classifications/classification/:classificationId/item/:itemId"
component={ClassificationItemContainer}
/>
<Route
exact
path="/classifications/classification/:classificationId/item/:itemId/compare"
component={ClassificationItemCompareContainer}
/>
<Route
exact
path="/classifications/correspondences"
component={ClassificationsCorrespondencesContainer}
/>
<Route
exact
path="/classifications/correspondence/:id"
component={ClassificationsCorrespondenceContainer}
/>
<Route
exact
path="/classifications/correspondence/:correspondenceId/association/:associationId"
component={ClassificationsCorrespondenceAssociationContainer}
/>
</Switch>
</>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import MenuConcepts from './';
import MenuConcepts from '.';

describe('menu-concepts', () => {
it('renders without crashing', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, { Component } from 'react';
import { Link, withRouter } from 'react-router-dom';
import MenuReferentiels from '../referentiels';
import MenuReferentiels from 'js/components/menu/referentiels';
import check from 'js/utils/auth';
import { propTypes as permissionOverviewPropTypes } from 'js/utils/auth/permission-overview';
import D from 'js/i18n';
import './concepts.scss';
import { compose } from 'recompose';
import { withPermissions } from 'js/components/menu/home-container';

class MenuConcepts extends Component {
constructor(props) {
Expand Down Expand Up @@ -132,4 +134,7 @@ MenuConcepts.propTypes = {
permission: permissionOverviewPropTypes.isRequired,
};

export default withRouter(MenuConcepts);
export default compose(
withRouter,
withPermissions
)(MenuConcepts);
Original file line number Diff line number Diff line change
Expand Up @@ -23,87 +23,99 @@ import Help from 'js/components/help/home';
import Administration from 'js/components/administration/home-container';
import ConceptsDashboard from 'js/components/administration/dashboard/concepts/home-container';
import D from 'js/i18n';
import Menu from 'js/components/concepts/menu';

export default () => {
document.title = 'Bauhaus - ' + D.conceptsTitle;
return (
<Switch>
<Route exact path="/concepts" component={ConceptsContainer} />
<Route
exact
path="/concepts/search"
component={ConceptsSearchListContainer}
/>
<Route
exact
path="/concept/create"
component={ConceptCreationContainer}
/>
<Route
exact
path="/concept/:id"
component={ConceptVisualizationContainer}
/>
<Route
exact
path="/concept/:id/compare"
component={ConceptCompareContainer}
/>
<Route exact path="/concept/:id/send" component={ConceptSendContainer} />
<Route
exact
path="/concept/:id/modify"
component={ConceptEditionContainer}
/>
<Route
exact
path="/concepts/validation"
component={ConceptsToValidateContainer}
/>
<Route
exact
path="/concepts/export"
component={ConceptsToExportContainer}
/>
<Route exact path="/collections" component={CollectionsContainer} />
<Route
exact
path="/collection/create"
component={CollectionCreationContainer}
/>
<Route
exact
path="/collection/:id"
component={CollectionVisualizationContainer}
/>
<Route
exact
path="/collection/:id/send"
component={CollectionSendContainer}
/>
<Route
exact
path="/collection/:id/modify"
component={CollectionEditionContainer}
/>
<Route
exact
path="/collections/validation"
component={CollectionsToValidateContainer}
/>
<Route
exact
path="/collections/export"
component={CollectionsToExportContainer}
/>
<Route exact path="/concepts/help/:id" component={Help} />
<Route exact path="/concepts/administration" component={Administration} />
<>
<Menu />
<Switch>
<Route exact path="/concepts" component={ConceptsContainer} />
<Route
exact
path="/concepts/search"
component={ConceptsSearchListContainer}
/>
<Route
exact
path="/concept/create"
component={ConceptCreationContainer}
/>
<Route
exact
path="/concept/:id"
component={ConceptVisualizationContainer}
/>
<Route
exact
path="/concept/:id/compare"
component={ConceptCompareContainer}
/>
<Route
exact
path="/concept/:id/send"
component={ConceptSendContainer}
/>
<Route
exact
path="/concept/:id/modify"
component={ConceptEditionContainer}
/>
<Route
exact
path="/concepts/validation"
component={ConceptsToValidateContainer}
/>
<Route
exact
path="/concepts/export"
component={ConceptsToExportContainer}
/>
<Route exact path="/collections" component={CollectionsContainer} />
<Route
exact
path="/collection/create"
component={CollectionCreationContainer}
/>
<Route
exact
path="/collection/:id"
component={CollectionVisualizationContainer}
/>
<Route
exact
path="/collection/:id/send"
component={CollectionSendContainer}
/>
<Route
exact
path="/collection/:id/modify"
component={CollectionEditionContainer}
/>
<Route
exact
path="/collections/validation"
component={CollectionsToValidateContainer}
/>
<Route
exact
path="/collections/export"
component={CollectionsToExportContainer}
/>
<Route exact path="/concepts/help/:id" component={Help} />
<Route
exact
path="/concepts/administration"
component={Administration}
/>

<Route
exact
path="/concepts/administration/dashboard"
component={ConceptsDashboard}
/>
</Switch>
<Route
exact
path="/concepts/administration/dashboard"
component={ConceptsDashboard}
/>
</Switch>
</>
);
};
31 changes: 18 additions & 13 deletions app/src/js/components/menu/home-container.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import React, { Component } from 'react';
import React from 'react';
import { connect } from 'react-redux';
import Menu from './home';
import * as select from 'js/reducers';

class MenuContainer extends Component {
render() {
const { permission } = this.props;
return <Menu permission={permission} />;
}
}
export function withPermissions(WrappedComponent) {
const mapStateToProps = state => {
const permission = select.getPermission(state);
return { permission };
};

const mapStateToProps = state => {
const permission = select.getPermission(state);
return { permission };
};
class MenuContainer extends React.Component {
render() {
return (
<WrappedComponent
permissions={this.props.permissions}
{...this.props}
/>
);
}
}

export default connect(mapStateToProps)(MenuContainer);
return connect(mapStateToProps)(MenuContainer);
}
Loading

0 comments on commit 0b6bc66

Please sign in to comment.