Skip to content

Commit

Permalink
Merge pull request #203 from InseeFr/acceptance
Browse files Browse the repository at this point in the history
3.0.6
  • Loading branch information
alicela authored Jul 23, 2021
2 parents aa3df2d + 4713c0b commit d74cc8a
Show file tree
Hide file tree
Showing 48 changed files with 5,250 additions and 4,126 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 15
node-version: 12.8.0
- run: yarn
# Build modules
- run: yarn build-insee
Expand All @@ -33,11 +33,7 @@ jobs:
with:
name: coverage
path: coverage
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

deploy:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .kubernetes/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
spec:
containers:
- name: bauhaus
image: nicolaslaval/bauhaus:3.0.0
image: nicolaslaval/bauhaus:3.0.6
env:
- name: API_BASE_HOST
value: 'https://bauhaus-api.toto.fr/api'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Web application for the management of concepts, classifications and other statistical objects.

[![Build Status](https://travis-ci.org/InseeFr/Bauhaus.svg?branch=master)](https://travis-ci.org/InseeFr/Bauhaus)
[![Trevas JS CI](https://github.com/InseeFr/Bauhaus/actions/workflows/ci.yml/badge.svg)](https://github.com/InseeFr/Bauhaus/actions/workflows/ci.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=InseeFr_Bauhaus&metric=alert_status)](https://sonarcloud.io/dashboard?id=InseeFr_Bauhaus)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=InseeFr_Bauhaus&metric=coverage)](https://sonarcloud.io/dashboard?id=InseeFr_Bauhaus)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
Expand Down
2 changes: 1 addition & 1 deletion app/.env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REACT_APP_API_BASE_HOST = 'http://localhost:8080/Bauhaus_BO_war/api'
REACT_APP_APPLICATIONS = "concepts,classifications,operations"
REACT_APP_APPLICATIONS = "concepts,classifications,operations,structures,codelists"

2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bauhaus",
"version": "3.0.5",
"version": "3.0.6",
"description": "Web application for the management of concepts, classifications and other statistical objects",
"repository": {
"type": "git",
Expand Down
5 changes: 2 additions & 3 deletions app/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { createContext } from 'react';
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import Root from 'js/router';
Expand All @@ -7,7 +7,7 @@ import Api from 'js/remote-api/api';
import { Error, I18NContext, BackToTop, getLang } from '@inseefr/wilco';
import D from 'js/i18n';
import ApplicationTitle from 'js/applications/shared/application-title';

import { AppContext } from 'bauhaus-utilities';
import '@inseefr/wilco/dist/index.css';
import '@inseefr/iam/dist/index.css';
import 'bauhaus-operations/dist/index.css';
Expand All @@ -16,7 +16,6 @@ import 'bauhaus-utilities/dist/index.css';

import 'main.scss';

export const AppContext = createContext({});
Api.getInit()
.then(
(res) => (res.ok ? res.json() : Promise.reject(res.statusText)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,70 +1,62 @@
import React, { Component } from 'react';
import React, { useEffect, useCallback } from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { useHistory } from 'react-router-dom';
import Keycloak from 'keycloak';
import { Loading } from '@inseefr/wilco';
import { saveUserProps } from 'js/actions/app';
import { Auth } from 'bauhaus-utilities';

const kcConfig = `${window.location.origin}/keycloak.json`;

class LoginOpenIDConnect extends Component {
constructor() {
super();
this.kc = Keycloak(kcConfig);
this.initLogin = this.initLogin.bind(this);
}
const kc = Keycloak(kcConfig);
const LoginOpenIDConnect = ({ saveUserProps, authenticated, WrappedComponent }) => {
const history = useHistory()
const refreshToken = useCallback(() => {
kc
.updateToken(30)
.success(isUpdated => {
if (isUpdated) {
kc.token && Auth.setToken(kc.token);
saveUserProps(
Auth.getAuthPropsFromToken(kc.tokenParsed)
);
}
})
.error(error => this.initLogin());
}, [saveUserProps])

initLogin() {

const initLogin = useCallback(() => {
const redirectUri = window.location.href.replace(
window.location.search,
''
);
this.kc.redirectUri = redirectUri;
this.kc
kc.redirectUri = redirectUri;
kc
.init({
onLoad: 'login-required',
responseMode: 'query',
checkLoginIframe: false,
})
.success(() => {
this.props.saveUserProps(
Auth.getAuthPropsFromToken(this.kc.tokenParsed)
saveUserProps(
Auth.getAuthPropsFromToken(kc.tokenParsed)
);
this.kc.token && Auth.setToken(this.kc.token);
setInterval(() => this.refreshToken(), 20000);
const { history } = this.props;
kc.token && Auth.setToken(kc.token);
setInterval(() => refreshToken(), 20000);
history.push({ pathname: history.location.pathname, state: 'init' });
})
.error(e => console.log('erreur initLogin', e));
}
}, [history, refreshToken, saveUserProps]);

refreshToken() {
this.kc
.updateToken(30)
.success(isUpdated => {
if (isUpdated) {
this.kc.token && Auth.setToken(this.kc.token);
this.props.saveUserProps(
Auth.getAuthPropsFromToken(this.kc.tokenParsed)
);
}
})
.error(error => this.initLogin());
}
useEffect(() => {
initLogin();
}, [initLogin])

componentWillMount() {
this.initLogin();
}

render() {
const { authenticated } = this.props;
const { WrappedComponent } = this.props;
const token = Auth.getToken();
if (authenticated && token && Auth.isTokenValid(token))
return <WrappedComponent />;
return <Loading textType="authentification" />;
}
const token = Auth.getToken();
if (authenticated && token && Auth.isTokenValid(token))
return <WrappedComponent />;
return <Loading textType="authentification" />;
}

export const mapStateToProps = state => ({
Expand All @@ -75,9 +67,9 @@ const mapDispatchToProps = {
saveUserProps,
};

export default withRouter(
export default
connect(
mapStateToProps,
mapDispatchToProps
)(LoginOpenIDConnect)
);

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const Compare = ({
classificationId={classificationId}
itemId={itemId}
secondLang={secondLang}
langs={langs}
/>
<CompareNotes
secondLang={secondLang}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ describe('concepts-compare', () => {
render(
<Provider store={store}>
<Compare
classificationId={'classificationId'}
itemId={'itemId'}
classificationId="classificationId"
itemId="itemId"
general={{
prefLabelLg1: 'prefLabelLg1',
isValidated: 'true',
Expand Down
25 changes: 23 additions & 2 deletions app/src/js/applications/classifications/item/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ import { Link } from 'react-router-dom';
import D from 'js/i18n';
import { Note } from '@inseefr/wilco';

export default ({ general, classificationId, itemId, secondLang }) => {
export default ({ general, classificationId, secondLang, langs }) => {
const { lg1, lg2 } = langs;
const mapping = {
broaderLg1: D.classificationsBroaderLevel,
itemId: D.classificationsNotationTitle,
altLabelLg1: D.altLabelTitle,
altLabelLg2: D.altLabelTitle,
altLabels: length => D.classificationItemAltLabels(length),
isValidated: D.isClassificationItemValidTitle,
conceptVersion: D.classificationConceptVersionTitle,
};

return (
<div className="row">
<Note
Expand Down Expand Up @@ -64,7 +68,24 @@ export default ({ general, classificationId, itemId, secondLang }) => {
general[fieldName]
)}`}</li>
);
} else {
}
if (fieldName === 'altLabelLg1') {
return (
<li>
{mapping[fieldName]} ({lg1}) :
{general.altLabelLg1}
</li>
);
}
if (fieldName === 'altLabelLg2') {
return (
<li>
{mapping[fieldName]} ({lg2}) :
{general.altLabelLg2}
</li>
);
}
else {
return (
<li
key={fieldName}
Expand Down
1 change: 1 addition & 0 deletions app/src/js/applications/classifications/item/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const ItemVisualization = ({
classificationId={classificationId}
itemId={itemId}
secondLang={secondLang}
langs={langs}
/>
{notes && <Notes secondLang={secondLang} notes={notes} langs={langs} />}
{narrowers.length !== 0 && (
Expand Down
15 changes: 13 additions & 2 deletions app/src/js/applications/codelists/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,36 @@ import {
Menu,
Home,
CodelistComponentView,
CodelistEdit,
D,
SearchFormList,
} from 'bauhaus-codelists';

const CodesListComponent = () => {
document.title = 'Bauhaus - ' + D.codelistsTitle;
document.getElementById('root-app').classList = ['structures'];
document.getElementById('root-app').classList = ['codelists'];
return (
<>
<Menu />
<div className="container">
<Switch>
<Route exact path="/codelists" component={Home} />
<Route
exact
path="/codelists/components/create"
component={CodelistEdit}
/>
<Route exact path="/codelists/search" component={SearchFormList} />
<Route
exact
path="/codelists/components/:id"
component={CodelistComponentView}
/>
<Route exact path="/codelists/search" component={SearchFormList} />
<Route
exact
path="/codelists/components/:id/modify"
component={CodelistEdit}
/>
</Switch>
</div>
</>
Expand Down
14 changes: 2 additions & 12 deletions app/src/js/applications/collections/export/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const CollectionsToExport = ({ collections, handleExportCollectionList }) => {
const [ids, setIds] = useState([]);

const handleExportCollectionListCallback = useCallback(
MimeType => {
(MimeType) => {
handleExportCollectionList(ids, MimeType);
},
[ids, handleExportCollectionList]
);

const openModal = useCallback(ids => {
const openModal = useCallback((ids) => {
setDisplayModal(true);
setIds(ids);
}, []);
Expand All @@ -24,11 +24,6 @@ const CollectionsToExport = ({ collections, handleExportCollectionList }) => {
setIds([]);
}, []);

const closePdf = useCallback(() => {
handleExportCollectionListCallback('application/octet-stream');
closeModal();
}, [closeModal, handleExportCollectionListCallback]);

const closeOdt = useCallback(() => {
handleExportCollectionListCallback(
'application/vnd.oasis.opendocument.text'
Expand All @@ -42,11 +37,6 @@ const CollectionsToExport = ({ collections, handleExportCollectionList }) => {
action: closeModal,
style: 'default',
},
{
label: D.btnPdf,
action: closePdf,
style: 'primary',
},
{
label: D.btnOdt,
action: closeOdt,
Expand Down
13 changes: 2 additions & 11 deletions app/src/js/applications/concepts/export/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ConceptsToExport extends Component {
displayModal: false,
ids: [],
};
this.openModal = ids =>
this.openModal = (ids) =>
this.setState({
displayModal: true,
ids,
Expand All @@ -20,15 +20,11 @@ class ConceptsToExport extends Component {
displayModal: false,
ids: [],
});
this.closePdf = () => {
this.handleExportConceptList('application/octet-stream');
this.closeModal();
};
this.closeOdt = () => {
this.handleExportConceptList('application/vnd.oasis.opendocument.text');
this.closeModal();
};
this.handleExportConceptList = MimeType => {
this.handleExportConceptList = (MimeType) => {
this.props.handleExportConceptList(this.state.ids, MimeType);
};
}
Expand All @@ -43,11 +39,6 @@ class ConceptsToExport extends Component {
action: this.closeModal,
style: 'default',
},
{
label: D.btnPdf,
action: this.closePdf,
style: 'primary',
},
{
label: D.btnOdt,
action: this.closeOdt,
Expand Down
Loading

0 comments on commit d74cc8a

Please sign in to comment.