diff --git a/__tests__/Hearing/__snapshots__/HearingContainer.react-test.js.snap b/__tests__/Hearing/__snapshots__/HearingContainer.react-test.js.snap index c16413c2f..b50526c78 100644 --- a/__tests__/Hearing/__snapshots__/HearingContainer.react-test.js.snap +++ b/__tests__/Hearing/__snapshots__/HearingContainer.react-test.js.snap @@ -5,6 +5,9 @@ exports[`HearingContainer component should render as expected 1`] = ` className="hearing-page" >
+
+
diff --git a/__tests__/Hearings/__snapshots__/HearingList.react-test.js.snap b/__tests__/Hearings/__snapshots__/HearingList.react-test.js.snap index 81429ef6b..23c323bba 100644 --- a/__tests__/Hearings/__snapshots__/HearingList.react-test.js.snap +++ b/__tests__/Hearings/__snapshots__/HearingList.react-test.js.snap @@ -134,6 +134,7 @@ exports[`HearingsList component should render as expected 1`] = ` "inLanguage-sv": "ruotsiksi", "infoHeaderDescription": "Tämä on palvelun väliaikainen prototyyppi, josta toivomme käyttäjien kommentteja", "infoHeaderText": "Tietoa palvelusta", + "infoPage": "Tietoa palvelusta", "labelPlaceholder": "Anna asiasanan nimi...", "lang-en": "English", "lang-fi": "Suomi", @@ -143,10 +144,13 @@ exports[`HearingsList component should render as expected 1`] = ` "leastCommented": "Vähiten kommentoitu", "list": "Lista", "login": "Kirjaudu sisään", + "loginToComment": "Kirjaudu sisään kommentoidaksesi.", "loginToContinue": "Kirjaudu sisään jatkaaksesi", + "loginToVoteComment": "Kirjaudu sisään äänestääksesi kommenttia.", "logout": "Kirjaudu ulos", "mainSection": "Pääosio", "map": "Kartta", + "mapView": "Kaikki kuulemiset kartalla", "mostCommented": "Eniten kommentoitu", "moveDown": "Siirrä alas", "moveUp": "Siirrä ylös", @@ -178,7 +182,7 @@ exports[`HearingsList component should render as expected 1`] = ` "publishingQueue": "Julkaisujono", "register": "Rekisteröidy", "registered": "rekisteröitynyt", - "registeredUsersOnly": "Vain rekisteröityneet käyttäjät", + "registeredUsersOnly": "Vain kirjautuneet käyttäjät", "removeImage": "Poista kuva", "revertPublishing": "Peru julkaisu", "saveAndPreviewHearing": "Tallenna ja tarkastele luonnosta", diff --git a/__tests__/Hearings/__snapshots__/Hearings.react-test.js.snap b/__tests__/Hearings/__snapshots__/Hearings.react-test.js.snap index 30ad0f966..c53a1be2e 100644 --- a/__tests__/Hearings/__snapshots__/Hearings.react-test.js.snap +++ b/__tests__/Hearings/__snapshots__/Hearings.react-test.js.snap @@ -192,6 +192,7 @@ exports[`Hearings component should render as expected 1`] = ` "inLanguage-sv": "ruotsiksi", "infoHeaderDescription": "Tämä on palvelun väliaikainen prototyyppi, josta toivomme käyttäjien kommentteja", "infoHeaderText": "Tietoa palvelusta", + "infoPage": "Tietoa palvelusta", "labelPlaceholder": "Anna asiasanan nimi...", "lang-en": "English", "lang-fi": "Suomi", @@ -201,10 +202,13 @@ exports[`Hearings component should render as expected 1`] = ` "leastCommented": "Vähiten kommentoitu", "list": "Lista", "login": "Kirjaudu sisään", + "loginToComment": "Kirjaudu sisään kommentoidaksesi.", "loginToContinue": "Kirjaudu sisään jatkaaksesi", + "loginToVoteComment": "Kirjaudu sisään äänestääksesi kommenttia.", "logout": "Kirjaudu ulos", "mainSection": "Pääosio", "map": "Kartta", + "mapView": "Kaikki kuulemiset kartalla", "mostCommented": "Eniten kommentoitu", "moveDown": "Siirrä alas", "moveUp": "Siirrä ylös", @@ -236,7 +240,7 @@ exports[`Hearings component should render as expected 1`] = ` "publishingQueue": "Julkaisujono", "register": "Rekisteröidy", "registered": "rekisteröitynyt", - "registeredUsersOnly": "Vain rekisteröityneet käyttäjät", + "registeredUsersOnly": "Vain kirjautuneet käyttäjät", "removeImage": "Poista kuva", "revertPublishing": "Peru julkaisu", "saveAndPreviewHearing": "Tallenna ja tarkastele luonnosta", diff --git a/__tests__/Home/__snapshots__/FullWidthHearing.react-test.js.snap b/__tests__/Home/__snapshots__/FullWidthHearing.react-test.js.snap index 1904a73c8..419b02aa9 100644 --- a/__tests__/Home/__snapshots__/FullWidthHearing.react-test.js.snap +++ b/__tests__/Home/__snapshots__/FullWidthHearing.react-test.js.snap @@ -118,6 +118,7 @@ exports[`FullWidthHearing component should render as expected 1`] = ` "inLanguage-sv": "ruotsiksi", "infoHeaderDescription": "Tämä on palvelun väliaikainen prototyyppi, josta toivomme käyttäjien kommentteja", "infoHeaderText": "Tietoa palvelusta", + "infoPage": "Tietoa palvelusta", "labelPlaceholder": "Anna asiasanan nimi...", "lang-en": "English", "lang-fi": "Suomi", @@ -127,10 +128,13 @@ exports[`FullWidthHearing component should render as expected 1`] = ` "leastCommented": "Vähiten kommentoitu", "list": "Lista", "login": "Kirjaudu sisään", + "loginToComment": "Kirjaudu sisään kommentoidaksesi.", "loginToContinue": "Kirjaudu sisään jatkaaksesi", + "loginToVoteComment": "Kirjaudu sisään äänestääksesi kommenttia.", "logout": "Kirjaudu ulos", "mainSection": "Pääosio", "map": "Kartta", + "mapView": "Kaikki kuulemiset kartalla", "mostCommented": "Eniten kommentoitu", "moveDown": "Siirrä alas", "moveUp": "Siirrä ylös", @@ -162,7 +166,7 @@ exports[`FullWidthHearing component should render as expected 1`] = ` "publishingQueue": "Julkaisujono", "register": "Rekisteröidy", "registered": "rekisteröitynyt", - "registeredUsersOnly": "Vain rekisteröityneet käyttäjät", + "registeredUsersOnly": "Vain kirjautuneet käyttäjät", "removeImage": "Poista kuva", "revertPublishing": "Peru julkaisu", "saveAndPreviewHearing": "Tallenna ja tarkastele luonnosta", diff --git a/__tests__/SortableCommentList.react-test.js b/__tests__/SortableCommentList.react-test.js index beffabdc3..be2bec3cf 100644 --- a/__tests__/SortableCommentList.react-test.js +++ b/__tests__/SortableCommentList.react-test.js @@ -20,6 +20,7 @@ const setup = propOverrides => { hearingId: mockHearingWithSections.data.id, section: mockHearingWithSections.data.sections[1], language: 'fi', + published: true, fetchComments: () => {} }, propOverrides); diff --git a/__tests__/__snapshots__/Carousel.react-test.js.snap b/__tests__/__snapshots__/Carousel.react-test.js.snap index 185feae4a..a8a3528a8 100644 --- a/__tests__/__snapshots__/Carousel.react-test.js.snap +++ b/__tests__/__snapshots__/Carousel.react-test.js.snap @@ -26,6 +26,12 @@ exports[`Carousel component should render as expected 1`] = ` focusOnSelect={true} infinite={false} initialSlide={1} + prevArrow={ + + } responsive={ Array [ Object { diff --git a/__tests__/__snapshots__/SortableCommentList.react-test.js.snap b/__tests__/__snapshots__/SortableCommentList.react-test.js.snap index a89864df7..cbe835d85 100644 --- a/__tests__/__snapshots__/SortableCommentList.react-test.js.snap +++ b/__tests__/__snapshots__/SortableCommentList.react-test.js.snap @@ -35,7 +35,7 @@ exports[`SortableCommentList component should render as expected 1`] = ` name="comment-o" />   - 1 + 59
+
); diff --git a/src/actions/index.js b/src/actions/index.js index 561690d1c..82a42e381 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -32,6 +32,28 @@ export function requestErrorHandler() { }; } +export const postCommentErrorHandler = () => { + return (err) => { + Raven.captureException(err); + if (err.response.status === 403) { + localizedNotifyError("loginToComment"); + } else { + localizedNotifyError(err.message); + } + }; +}; + +export const voteCommentErrorHandler = () => { + return (err) => { + Raven.captureException(err); + if (err.response.status === 403) { + localizedNotifyError("loginToVoteComment"); + } else { + localizedNotifyError(err.message); + } + }; +}; + export function fetchInitialHearingList(listId, endpoint, params) { return (dispatch, getState) => { const fetchAction = createAction("beginFetchHearingList")({listId, params}); @@ -178,7 +200,7 @@ export function postSectionComment(hearingSlug, sectionId, commentData = {}) { // we must update hearing comment count dispatch(fetchHearing(hearingSlug)); localizedAlert("commentReceived"); - }).catch(requestErrorHandler()); + }).catch(postCommentErrorHandler()); }; } @@ -223,6 +245,6 @@ export function postVote(commentId, hearingSlug, sectionId) { dispatch(createAction("postedCommentVote")({commentId, sectionId})); localizedNotifySuccess("voteReceived"); } - }).catch(requestErrorHandler()); + }).catch(voteCommentErrorHandler()); }; } diff --git a/src/components/Carousel.js b/src/components/Carousel.js index 63b92b403..571b345b8 100644 --- a/src/components/Carousel.js +++ b/src/components/Carousel.js @@ -16,6 +16,24 @@ import {FormattedMessage, intlShape} from 'react-intl'; import Icon from '../utils/Icon'; import {Grid} from 'react-bootstrap'; +// Custom prev button is used because for some reason Slicks default button is always disabled... +const PrevButton = ({slidePrev, currentSlide}) => ( + +); + +PrevButton.propTypes = { + slidePrev: PropTypes.func, + currentSlide: PropTypes.number +}; + export class SectionCarousel extends React.Component { componentWillReceiveProps(nextProps) { const {hearing, match: {params}} = this.props; @@ -90,6 +108,7 @@ export class SectionCarousel extends React.Component { ref={slider => { this.slider = slider; }} + prevArrow={ this.slider.slickPrev())} currentSlide={this.slider && this.slider.state.currentSlide} />} initialSlide={getInitialSlideIndex(hearing, params)} infinite={false} focusOnSelect @@ -166,7 +185,6 @@ const SliderItem = ({section, to, language, hearingTitle, active}) => { ); }; - SliderItem.propTypes = { section: PropTypes.object, to: PropTypes.object, diff --git a/src/components/Header/index.js b/src/components/Header/index.js index 5ba45f0e7..2f50801e8 100644 --- a/src/components/Header/index.js +++ b/src/components/Header/index.js @@ -18,7 +18,11 @@ class Header extends React.Component { if (typeof window !== 'undefined') { this._handleNavFix = throttle(() => { const scrollY = scrolltop(); - document.body.classList.toggle('nav-fixed', scrollY > 115); + if (scrollY > 115) { + document.body.classList.add('nav-fixed'); + } else { + document.body.classList.remove('nav-fixed'); + } }, 25); window.addEventListener('scroll', this._handleNavFix, false); } diff --git a/src/components/Hearing/Section/SectionClosureInfo.js b/src/components/Hearing/Section/SectionClosureInfo.js index 07dd94245..99dc17446 100644 --- a/src/components/Hearing/Section/SectionClosureInfo.js +++ b/src/components/Hearing/Section/SectionClosureInfo.js @@ -3,9 +3,7 @@ import PropTypes from 'prop-types'; export const SectionClosureInfoComponent = ({content}) => { return ( -
- {content} -
+
); }; diff --git a/src/components/Hearing/Section/SectionContainer.js b/src/components/Hearing/Section/SectionContainer.js index e3e4aa734..3c1f39e96 100644 --- a/src/components/Hearing/Section/SectionContainer.js +++ b/src/components/Hearing/Section/SectionContainer.js @@ -47,7 +47,8 @@ import Link from '../../LinkWithLang'; export class SectionContainerComponent extends React.Component { state = { showDeleteModal: false, - commentToDelete: {} + commentToDelete: {}, + showLightbox: false }; getSectionNav = () => { @@ -137,6 +138,14 @@ export class SectionContainerComponent extends React.Component { return isSectionCommentable(hearing, section, user) && !hasPlugin; } + openLightbox = () => { + this.setState({showLightbox: true}); + } + + closeLightbox = () => { + this.setState({showLightbox: false}); + } + render() { const { hearing, @@ -150,6 +159,7 @@ export class SectionContainerComponent extends React.Component { fetchAllComments, mainSectionComments } = this.props; + const {showLightbox} = this.state; const mainSection = sections.find(sec => sec.type === SectionTypes.MAIN); const section = sections.find(sec => sec.id === match.params.sectionId) || mainSection; const sectionImage = section.images[0]; @@ -175,6 +185,9 @@ export class SectionContainerComponent extends React.Component { image={sectionImage} caption={getAttr(sectionImage.caption, language)} title={getAttr(sectionImage.title, language)} + showLightbox={showLightbox} + openLightbox={this.openLightbox} + closeLightbox={this.closeLightbox} /> } {!isEmpty(section.abstract) && @@ -204,7 +217,7 @@ export class SectionContainerComponent extends React.Component {
} {showSectionBrowser && } - + {section.id === mainSection.id && } {hasFullscreenMapPlugin(hearing) &&