From 6212ae98915d1e2dc8eae3ca870906beb905ad10 Mon Sep 17 00:00:00 2001 From: Lionel Date: Thu, 7 Feb 2019 15:21:31 +0100 Subject: [PATCH] feat(frontend): allow user to extends search to all documents (#497) * fix(css): fix vertical rythm inside alert * feat(frontend): allow user to extends search to all documents * test: update snaptshot fixes #299 --- .../docs/css/components/_search.css | 6 +-- .../docs/css/global/_layout.css | 1 + .../src/common/Answer.js | 2 +- .../src/common/FeedbackForm.js | 5 +- .../src/common/FeedbackModal.js | 10 +++- .../src/common/__tests__/FeebackForm.test.js | 7 +++ .../__snapshots__/Answer.test.js.snap | 47 ++++++++++++------- .../__snapshots__/FeebackForm.test.js.snap | 5 ++ .../__snapshots__/FeedbackModal.test.js.snap | 5 ++ .../src/search/Search.js | 47 ++++++++++--------- .../src/search/SearchQuery.js | 10 ++-- .../src/search/SearchResults.js | 18 +++++-- .../__snapshots__/Search.test.js.snap | 16 +++---- .../__snapshots__/SearchResults.test.js.snap | 4 +- 14 files changed, 121 insertions(+), 62 deletions(-) diff --git a/packages/code-du-travail-css/docs/css/components/_search.css b/packages/code-du-travail-css/docs/css/components/_search.css index 293b9b59a1..5b6000f4d9 100755 --- a/packages/code-du-travail-css/docs/css/components/_search.css +++ b/packages/code-du-travail-css/docs/css/components/_search.css @@ -18,7 +18,7 @@ flex: 1 1 auto; display: flex; } -.search__facets { +.search__sources { position: absolute; display: flex; align-items: center; @@ -28,13 +28,13 @@ border-radius: var(--border-radius-base); background-color: var(--color-lighter-grey); } -.facet-icon { +.select-sources__icon { position: absolute; width: 1.25rem; height: 1.25rem; margin: 0 calc(var(--spacing-small) / 2); } -.facet-value { +.select-sources__value { color: var(--color-almost-black); font-size: var(--font-size-small); border: 1px solid transparent; diff --git a/packages/code-du-travail-css/docs/css/global/_layout.css b/packages/code-du-travail-css/docs/css/global/_layout.css index c63a880c3d..e7242addef 100755 --- a/packages/code-du-travail-css/docs/css/global/_layout.css +++ b/packages/code-du-travail-css/docs/css/global/_layout.css @@ -185,6 +185,7 @@ It is also possible to nest a `.wrapper-narrow` class in a `.wrapper-dark` or /* Cancel vertical rhythm for last childs in `.container` or `wrapper-*`. */ .container > :--vertical-rythm-elements:last-child, +.alert > :--vertical-rythm-elements:last-child, [class^="wrapper-"] > :--vertical-rythm-elements:last-child { margin-bottom: 0; } diff --git a/packages/code-du-travail-frontend/src/common/Answer.js b/packages/code-du-travail-frontend/src/common/Answer.js index 2d63e3f8d0..801a1cac05 100644 --- a/packages/code-du-travail-frontend/src/common/Answer.js +++ b/packages/code-du-travail-frontend/src/common/Answer.js @@ -37,7 +37,6 @@ class Answer extends React.Component { this.setState({ modalVisible: true }); }; closeModal = () => { - ReactPiwik.push(["trackEvent", "feedback", "cancel"]); this.setState({ modalVisible: false }); }; setResults = searchResults => { @@ -71,6 +70,7 @@ class Answer extends React.Component { isOpen={this.state.modalVisible} closeModal={this.closeModal} query={router.query.q || title} + source={router.query.source} url={router.asPath} />
+ {results && results.length > 0 && (

diff --git a/packages/code-du-travail-frontend/src/common/FeedbackModal.js b/packages/code-du-travail-frontend/src/common/FeedbackModal.js index 995381d8c3..391390f43c 100644 --- a/packages/code-du-travail-frontend/src/common/FeedbackModal.js +++ b/packages/code-du-travail-frontend/src/common/FeedbackModal.js @@ -9,14 +9,19 @@ class FeedbackModal extends React.Component { isOpen: PropTypes.bool, closeModal: PropTypes.func.isRequired, query: PropTypes.string, + source: PropTypes.string, url: PropTypes.string, results: PropTypes.arrayOf(PropTypes.object) }; static defaultProps = { - isOpen: false + isOpen: false, + query: "", + source: "Tous contenus", + url: "", + results: [] }; render() { - const { results, isOpen, closeModal, query, url } = this.props; + const { results, isOpen, closeModal, query, url, source } = this.props; return ( diff --git a/packages/code-du-travail-frontend/src/common/__tests__/FeebackForm.test.js b/packages/code-du-travail-frontend/src/common/__tests__/FeebackForm.test.js index 83924dc960..05db5c2b7c 100644 --- a/packages/code-du-travail-frontend/src/common/__tests__/FeebackForm.test.js +++ b/packages/code-du-travail-frontend/src/common/__tests__/FeebackForm.test.js @@ -21,6 +21,7 @@ describe("", () => { const { container, getByValue } = render( @@ -33,6 +34,7 @@ describe("", () => { const { getByText } = render( @@ -47,6 +49,7 @@ describe("", () => { const { getByText, getByPlaceholderText } = render( @@ -64,6 +67,7 @@ describe("", () => { const { getByText, getByPlaceholderText } = render( @@ -85,6 +89,7 @@ describe("", () => { const { getByText, getByPlaceholderText } = render( @@ -104,6 +109,7 @@ describe("", () => { const { getByText, queryByText, getByPlaceholderText } = render( @@ -123,6 +129,7 @@ describe("", () => { const { getByText, queryByText, getByPlaceholderText } = render( diff --git a/packages/code-du-travail-frontend/src/common/__tests__/__snapshots__/Answer.test.js.snap b/packages/code-du-travail-frontend/src/common/__tests__/__snapshots__/Answer.test.js.snap index 4f9899f79c..4ecd328d57 100644 --- a/packages/code-du-travail-frontend/src/common/__tests__/__snapshots__/Answer.test.js.snap +++ b/packages/code-du-travail-frontend/src/common/__tests__/__snapshots__/Answer.test.js.snap @@ -51,7 +51,7 @@ exports[` should display feedback modal when click on feedback button class="search__fields" >