From 11ec9627545a5aaf6bd6b3b874de4b00724489f1 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Fri, 11 Jan 2019 11:46:02 +0100 Subject: [PATCH] =?UTF-8?q?Change=20le=20chemin=20des=20r=C3=A8gles=20vers?= =?UTF-8?q?=20"documentation"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Provider.js | 15 ++- source/actions/actions.js | 11 ++ source/components/ComparativeTargets.js | 20 ++- source/components/RuleLink.js | 21 ++-- source/components/RulePage.js | 44 +++---- source/components/SalarySimulation.js | 19 +-- source/components/SearchBar.js | 16 ++- source/components/SearchButton.js | 3 +- source/components/TargetSelection.js | 56 ++++----- source/components/Targets.js | 8 +- source/components/rule/Namespace.js | 76 ++++++------ source/components/rule/Rule.js | 18 +-- source/components/rule/RuleValueVignette.js | 2 +- .../simulationConfigs/withSimulationConfig.js | 2 - source/components/utils/withSitePaths.js | 29 +++++ source/engine/mecanismViews/common.js | 27 +++- source/engine/rules.js | 4 +- source/locales/en.yaml | 2 +- source/règles/base.yaml | 2 +- source/selectors/analyseSelectors.js | 4 +- source/selectors/companyStatusSelectors.js | 1 + source/selectors/regleSelectors.js | 2 +- .../sites/embauche.gouv.fr/pages/RulesList.js | 8 +- source/sites/mycompanyinfrance.fr/App.js | 28 ++++- .../layout/Navigation/Navigation.js | 59 ++++----- .../layout/ProgressHeader/ProgressHeader.js | 18 +-- .../pages/Company/AfterRegistration.js | 12 +- .../pages/Company/CreationChecklist.js | 9 +- .../pages/Company/Find.js | 15 +-- .../pages/Company/Home.js | 12 +- .../pages/Company/PickLegalStatus.js | 37 +++--- .../pages/Company/PreviousAnswers.js | 17 ++- .../pages/Company/YourCompany.js | 16 +-- .../pages/Company/index.js | 48 ++++---- .../pages/Documentation/index.js | 0 .../pages/HiringProcess.js | 6 +- .../mycompanyinfrance.fr/pages/Landing.js | 115 +++++++++--------- .../mycompanyinfrance.fr/pages/Sitemap.js | 22 ++-- .../pages/SocialSecurity/Home.js | 26 ++-- .../pages/SocialSecurity/index.js | 62 ++++------ 40 files changed, 505 insertions(+), 387 deletions(-) create mode 100644 source/components/utils/withSitePaths.js create mode 100644 source/sites/mycompanyinfrance.fr/pages/Documentation/index.js diff --git a/source/Provider.js b/source/Provider.js index f2096bdb6..161f353bd 100644 --- a/source/Provider.js +++ b/source/Provider.js @@ -1,4 +1,5 @@ import SetCSSColour from 'Components/utils/SetCssColour' +import { SitePathProvider } from 'Components/utils/withSitePaths' import { TrackerProvider } from 'Components/utils/withTracker' import createHistory from 'history/createBrowserHistory' import i18next from 'i18next' @@ -66,12 +67,14 @@ export default class Layout extends PureComponent { // If IE < 11 display nothing - - - - <>{this.props.children} - - + + + + + <>{this.props.children} + + + ) diff --git a/source/actions/actions.js b/source/actions/actions.js index ac0deb0a4..75ab621a6 100644 --- a/source/actions/actions.js +++ b/source/actions/actions.js @@ -51,6 +51,17 @@ export function setExample(name, situation, dottedName) { return { type: 'SET_EXAMPLE', name, situation, dottedName } } +export const goBackToSimulation = () => ( + dispatch: any => void, + _: any, + history: RouterHistory +): void => { + while (history.location.pathname.includes('documentation')) { + history.goBack() + } + dispatch({ type: 'SET_EXAMPLE', name: null }) +} + export function loadPreviousSimulation(): LoadPreviousSimulationAction { return { type: 'LOAD_PREVIOUS_SIMULATION' diff --git a/source/components/ComparativeTargets.js b/source/components/ComparativeTargets.js index a7237ac6e..d7d5e8791 100644 --- a/source/components/ComparativeTargets.js +++ b/source/components/ComparativeTargets.js @@ -1,6 +1,7 @@ import PeriodSwitch from 'Components/PeriodSwitch' import withColours from 'Components/utils/withColours' -import { findRuleByDottedName } from 'Engine/rules' +import withSitePaths from 'Components/utils/withSitePaths' +import { encodeRuleName, findRuleByDottedName } from 'Engine/rules' import { compose } from 'ramda' import React from 'react' import emoji from 'react-easy-emoji' @@ -26,7 +27,8 @@ export default compose( setSituationBranch: id => dispatch({ type: 'SET_SITUATION_BRANCH', id }) }) ), - withColours + withColours, + withSitePaths )( class ComparativeTargets extends React.Component { render() { @@ -35,6 +37,7 @@ export default compose( analyses, target, setSituationBranch, + sitePaths, simulationBranches } = this.props if (!simulationBranches) { @@ -44,7 +47,6 @@ export default compose( // This is not elegant let getRatioPrélèvements = analysis => analysis.targets.find(t => t.dottedName === 'ratio de prélèvements') - return (

{target.title}

@@ -87,7 +89,11 @@ export default compose( setSituationBranch(i)} className="explanation"> {emoji('📖')} @@ -99,7 +105,11 @@ export default compose( de{' '} + to={ + sitePaths.documentation.index + + '/' + + encodeRuleName(ratioPrélèvements.dottedName) + }> prélèvements diff --git a/source/components/RuleLink.js b/source/components/RuleLink.js index dc87a2e60..5879429b4 100644 --- a/source/components/RuleLink.js +++ b/source/components/RuleLink.js @@ -1,21 +1,26 @@ /* @flow */ import withColours from 'Components/utils/withColours' +import withSitePaths from 'Components/utils/withSitePaths' import { compose } from 'ramda' import React from 'react' -import { withRouter } from 'react-router' import { Link } from 'react-router-dom' -import { capitalise0, normalizeBasePath } from '../utils' +import { capitalise0 } from '../utils' import './RuleLink.css' import type { Règle } from 'Types/RegleTypes' -import type { Match } from 'react-router' + type Props = Règle & { - match: Match, + sitePaths: Object, style: CSSStyleDeclaration, colours: { colour: string } } -const RuleLink = ({ lien, nom, colours: { colour }, match, style }: Props) => { - const newPath = - normalizeBasePath(match.path).replace(/simulation\/$/, '') + lien +const RuleLink = ({ + lien, + nom, + colours: { colour }, + style, + sitePaths +}: Props) => { + const newPath = sitePaths.documentation.index + '/' + lien return ( { } export default compose( - withRouter, + withSitePaths, withColours )(RuleLink) diff --git a/source/components/RulePage.js b/source/components/RulePage.js index a1c392463..865ae61db 100644 --- a/source/components/RulePage.js +++ b/source/components/RulePage.js @@ -1,4 +1,4 @@ -import { setExample } from 'Actions/actions' +import { goBackToSimulation } from 'Actions/actions' import { ScrollToTop } from 'Components/utils/Scroll' import { encodeRuleName } from 'Engine/rules' import { @@ -25,9 +25,9 @@ export default compose( connect(state => ({ themeColours: state.themeColours, valuesToShow: !noUserInputSelector(state), - flatRules: flatRulesSelector(state), - situationBranch: - state.simulationConfig?.branches[state.situationBranch]?.nom + flatRules: flatRulesSelector(state) + // situationBranch: + // state.simulationConfig?.branches[state.situationBranch]?.nom })), withNamespaces() )( @@ -57,7 +57,7 @@ export default compose( let { situationBranch } = this.props return (
- +
{situationBranch} )} - +
@@ -81,12 +78,7 @@ export default compose( const BackToSimulation = compose( connect( null, - dispatch => ({ - setExample: compose( - dispatch, - setExample - ) - }) + { goBackToSimulation } ), withRouter, withNamespaces() @@ -94,18 +86,20 @@ const BackToSimulation = compose( // Triggers rerender when the language changes class BackToSimulation extends Component { render() { - let { colour, setExample, visible } = this.props + let { goBackToSimulation, visible } = this.props return ( - { - setExample(null) - }} - style={{ color: colour, visibility: visible ? 'visible' : 'hidden' }}> -