From 05bfc5eaa7dd5e51842ea5d79408ff201c2e8ae7 Mon Sep 17 00:00:00 2001 From: Lorenzo Natali Date: Thu, 20 Apr 2017 15:14:08 +0200 Subject: [PATCH] Fix #1750. Add smarter shareURLs generator and tests (#1751) * Fix #1728. Generalized Share embedded strings. More tests (#1729) * Fix #1738. Made optional share api and showTOC (#1739) With this options you can remove via configuration the API share tool and the showTOC checkbox. * Fix #1750.Add smarter shareURLs generator and tests --- docma-config.json | 3 +- web/client/actions/fullscreen.js | 6 +- web/client/components/share/ShareEmbed.jsx | 25 ++++++--- web/client/components/share/SharePanel.jsx | 52 +++++++++++++---- .../share/__tests__/ShareEmbed-test.jsx | 25 ++++++++- .../share/__tests__/SharePanel-test.jsx | 19 ++++++- web/client/plugins/Share.jsx | 52 +++++++---------- web/client/utils/ShareUtils.js | 56 +++++++++++++++++++ web/client/utils/__tests__/ShareUtils-test.js | 52 +++++++++++++++++ 9 files changed, 233 insertions(+), 57 deletions(-) create mode 100644 web/client/utils/ShareUtils.js create mode 100644 web/client/utils/__tests__/ShareUtils-test.js diff --git a/docma-config.json b/docma-config.json index 848891deb7..cbaeebb585 100644 --- a/docma-config.json +++ b/docma-config.json @@ -127,7 +127,8 @@ "web/client/epics/search.js", "web/client/utils/index.jsdoc", - "web/client/utils/PluginsUtils.js" + "web/client/utils/PluginsUtils.js", + "web/client/utils/ShareUtils.js" ], "jsapi": "web/client/jsapi/MapStore2.js", "plugins": [ diff --git a/web/client/actions/fullscreen.js b/web/client/actions/fullscreen.js index 535fe706ab..b0a2ed03dd 100644 --- a/web/client/actions/fullscreen.js +++ b/web/client/actions/fullscreen.js @@ -10,6 +10,7 @@ const TOGGLE_FULLSCREEN = "TOGGLE_FULLSCREEN"; /** * when fullscreen have to be toggled + * @memberof actions.fullscreen * @param {boolean} enable true for enable, false for disable * @param {string} elementSelector querySelector string to use to get the element to fullscreen. * @return {action} the action of type `TOGGLE_FULLSCREEN` with enable flag and element selector. @@ -21,7 +22,10 @@ function toggleFullscreen(enable, elementSelector) { elementSelector }; } - +/** + * Actions for FullScreen Plugin. + * @name actions.fullscreen + */ module.exports = { toggleFullscreen, TOGGLE_FULLSCREEN diff --git a/web/client/components/share/ShareEmbed.jsx b/web/client/components/share/ShareEmbed.jsx index 5ee585fb4a..8ea237836b 100644 --- a/web/client/components/share/ShareEmbed.jsx +++ b/web/client/components/share/ShareEmbed.jsx @@ -24,10 +24,23 @@ require('./share.css'); const ShareEmbed = React.createClass({ propTypes: { - shareUrl: React.PropTypes.string + shareUrl: React.PropTypes.string, + showTOCToggle: React.PropTypes.bool }, - getInitialState() { - return {copied: false, forceDrawer: false}; + getInitialState() { + return {copied: false, forceDrawer: false}; + }, + getDefaultProps() { + return { + showTOCToggle: true + }; + }, + renderTools() { + if (this.props.showTOCToggle) { + return ( this.setState({forceDrawer: !this.state.forceDrawer})}> + + ); + } }, render() { @@ -44,16 +57,12 @@ const ShareEmbed = React.createClass({ ); return (
- -

- this.setState({forceDrawer: !this.state.forceDrawer})}> - - + {this.renderTools()}