From 44cb276cdfc46f52f2234e9b962e53c55d47cdf1 Mon Sep 17 00:00:00 2001 From: Severiano Badajoz Date: Wed, 25 Sep 2019 19:23:49 -0700 Subject: [PATCH] Add configurable `about this dataset` links (#907) * add about arg * add simple url validator * attach about link to config api * add links to configDefaults * add conditional link in top left and menu item * whitespace * change to lower case * move --about arg before click.command() if this fixes it I have no idea why * change link>URL * be more descriptive about URL * Make error more explicit * refactor attach_data to accept about * format * change icon * add trailing parenthesis * whitespace --- .../leftSidebar/topLeftLogoAndTitle.js | 22 ++++++++++-------- client/src/components/menubar/index.js | 11 ++++++--- client/src/components/menubar/infoMenu.js | 13 ++++++++++- client/src/globals.js | 3 ++- server/app/app.py | 4 ++-- server/app/rest_api/rest.py | 3 +++ server/cli/launch.py | 23 ++++++++++++++++++- 7 files changed, 62 insertions(+), 17 deletions(-) diff --git a/client/src/components/leftSidebar/topLeftLogoAndTitle.js b/client/src/components/leftSidebar/topLeftLogoAndTitle.js index a4acfc06..be56e531 100644 --- a/client/src/components/leftSidebar/topLeftLogoAndTitle.js +++ b/client/src/components/leftSidebar/topLeftLogoAndTitle.js @@ -7,15 +7,26 @@ import Logo from "../framework/logo"; @connect(state => ({ responsive: state.responsive, datasetTitle: state.config?.displayNames?.dataset ?? "", + aboutURL: state.config?.links?.["about-dataset"], scatterplotXXaccessor: state.controls.scatterplotXXaccessor, scatterplotYYaccessor: state.controls.scatterplotYYaccessor })) class LeftSideBar extends React.Component { render() { - const { datasetTitle } = this.props; + const { datasetTitle, aboutURL } = this.props; const paddingToAvoidScrollBar = 15; + const displayTitle = + datasetTitle.length > globals.datasetTitleMaxCharacterCount + ? `${datasetTitle.substring( + 0, + Math.floor(globals.datasetTitleMaxCharacterCount / 2) + )}…${datasetTitle.slice( + -Math.floor(globals.datasetTitleMaxCharacterCount / 2) + )}` + : datasetTitle; + return (
- {datasetTitle.length > globals.datasetTitleMaxCharacterCount - ? `${datasetTitle.substring( - 0, - Math.floor(globals.datasetTitleMaxCharacterCount / 2) - )}…${datasetTitle.slice( - -Math.floor(globals.datasetTitleMaxCharacterCount / 2) - )}` - : datasetTitle} + {aboutURL ? {displayTitle} : displayTitle}
); diff --git a/client/src/components/menubar/index.js b/client/src/components/menubar/index.js index cbb9a32a..ab93aaa9 100644 --- a/client/src/components/menubar/index.js +++ b/client/src/components/menubar/index.js @@ -38,7 +38,8 @@ import { tooltipHoverOpenDelay } from "../../globals"; celllist2: state.differential.celllist2, libraryVersions: state.config?.library_versions, // eslint-disable-line camelcase undoDisabled: state["@@undoable/past"].length === 0, - redoDisabled: state["@@undoable/future"].length === 0 + redoDisabled: state["@@undoable/future"].length === 0, + aboutLink: state.config?.links?.["about-dataset"] })) class MenuBar extends React.Component { static isValidDigitKeyEvent(e) { @@ -267,7 +268,8 @@ class MenuBar extends React.Component { clipPercentileMin, clipPercentileMax, layoutChoice, - graphInteractionMode + graphInteractionMode, + aboutLink } = this.props; const { pendingClipPercentiles } = this.state; @@ -473,7 +475,10 @@ class MenuBar extends React.Component { undoDisabled={undoDisabled} redoDisabled={redoDisabled} /> - + ); } diff --git a/client/src/components/menubar/infoMenu.js b/client/src/components/menubar/infoMenu.js index 736e2968..681bbc10 100644 --- a/client/src/components/menubar/infoMenu.js +++ b/client/src/components/menubar/infoMenu.js @@ -3,12 +3,23 @@ import React from "react"; import { Button, Popover, Menu, MenuItem, Position } from "@blueprintjs/core"; function InformationMenu(props) { - const { libraryVersions } = props; + const { libraryVersions, aboutLink } = props; return (
+ {aboutLink ? ( + + ) : ( + "" + )} +