Fix positioning of CustomTimeIndicator

pull/10616/head
Andrew Watkins 2018-01-02 16:35:26 -08:00
parent 711cb48d14
commit 924960bbcc
5 changed files with 59 additions and 66 deletions

View File

@ -57,6 +57,7 @@ class LayoutCell extends Component {
<Authorized requiredRole={EDITOR_ROLE}> <Authorized requiredRole={EDITOR_ROLE}>
<LayoutCellMenu <LayoutCellMenu
cell={cell} cell={cell}
queries={queries}
dataExists={!!celldata.length} dataExists={!!celldata.length}
isDeleting={isDeleting} isDeleting={isDeleting}
isEditable={isEditable} isEditable={isEditable}
@ -67,11 +68,7 @@ class LayoutCell extends Component {
onCSVDownload={this.handleCSVDownload} onCSVDownload={this.handleCSVDownload}
/> />
</Authorized> </Authorized>
<LayoutCellHeader <LayoutCellHeader cellName={cell.name} isEditable={isEditable} />
queries={queries}
cellName={cell.name}
isEditable={isEditable}
/>
<div className="dash-graph--container"> <div className="dash-graph--container">
{queries.length {queries.length
? children ? children

View File

@ -1,14 +1,11 @@
import React, {PropTypes} from 'react' import React, {PropTypes} from 'react'
import CustomTimeIndicator from 'shared/components/CustomTimeIndicator'
import {NEW_DEFAULT_DASHBOARD_CELL} from 'src/dashboards/constants/index' import {NEW_DEFAULT_DASHBOARD_CELL} from 'src/dashboards/constants/index'
const LayoutCellHeader = ({queries, isEditable, cellName}) => { const LayoutCellHeader = ({isEditable, cellName}) => {
const cellNameIsDefault = cellName === NEW_DEFAULT_DASHBOARD_CELL.name const cellNameIsDefault = cellName === NEW_DEFAULT_DASHBOARD_CELL.name
const headingClass = `dash-graph--heading ${isEditable const headingClass = `dash-graph--heading ${isEditable
? 'dash-graph--heading-draggable' ? 'dash-graph--draggable dash-graph--heading-draggable'
: ''}` : ''}`
return ( return (
@ -21,20 +18,14 @@ const LayoutCellHeader = ({queries, isEditable, cellName}) => {
} }
> >
{cellName} {cellName}
<div className="dash-graph--custom-indicators">
{queries && queries.length
? <CustomTimeIndicator queries={queries} />
: null}
</div>
</span> </span>
</div> </div>
) )
} }
const {arrayOf, bool, shape, string} = PropTypes const {bool, string} = PropTypes
LayoutCellHeader.propTypes = { LayoutCellHeader.propTypes = {
queries: arrayOf(shape()),
isEditable: bool, isEditable: bool,
cellName: string, cellName: string,
} }

View File

@ -1,61 +1,62 @@
import React, {PropTypes} from 'react' import React, {PropTypes} from 'react'
import OnClickOutside from 'react-onclickoutside' import OnClickOutside from 'react-onclickoutside'
import CustomTimeIndicator from 'shared/components/CustomTimeIndicator'
const LayoutCellMenu = OnClickOutside( const LayoutCellMenu = OnClickOutside(
({ ({
isDeleting,
onEdit,
onDeleteClick,
onDelete,
onCSVDownload,
dataExists,
cell, cell,
onEdit,
queries,
onDelete,
isEditable,
dataExists,
isDeleting,
onDeleteClick,
onCSVDownload,
}) => }) =>
<div <div className="dash-graph-context">
className={ <div
isDeleting className={`${isEditable
? 'dash-graph-context dash-graph-context__deleting' ? 'dash-graph--custom-indicators dash-graph--draggable'
: 'dash-graph-context' : 'dash-graph--custom-indicators'}`}
} >
> {queries && queries.length && <CustomTimeIndicator queries={queries} />}
<div className="dash-graph-context--button" onClick={onEdit(cell)}>
<span className="icon pencil" />
</div> </div>
{dataExists {isEditable &&
? <div <div clasnName="dash-graph--buttons">
className="dash-graph-context--button" <div className="dash-graph-context--button" onClick={onEdit(cell)}>
onClick={onCSVDownload(cell)} <span className="icon pencil" />
>
<span className="icon download" />
</div> </div>
: null} {dataExists &&
{isDeleting
? <div className="dash-graph-context--button active">
<span className="icon trash" />
<div <div
className="dash-graph-context--confirm" className="dash-graph-context--button"
onClick={onDelete(cell)} onClick={onCSVDownload(cell)}
> >
Confirm <span className="icon download" />
</div> </div>}
</div> {isDeleting
: <div className="dash-graph-context--button" onClick={onDeleteClick}> ? <div className="dash-graph-context--button active">
<span className="icon trash" /> <span className="icon trash" />
</div>} <div
className="dash-graph-context--confirm"
onClick={onDelete(cell)}
>
Confirm
</div>
</div>
: <div
className="dash-graph-context--button"
onClick={onDeleteClick}
>
<span className="icon trash" />
</div>}
</div>}
</div> </div>
) )
const LayoutCellMenuContainer = props => { const {arrayOf, bool, func, shape} = PropTypes
if (!props.isEditable) {
return null
}
return <LayoutCellMenu {...props} /> LayoutCellMenu.propTypes = {
}
const {bool, func, shape} = PropTypes
LayoutCellMenuContainer.propTypes = {
isDeleting: bool, isDeleting: bool,
onEdit: func, onEdit: func,
onDelete: func, onDelete: func,
@ -63,8 +64,7 @@ LayoutCellMenuContainer.propTypes = {
cell: shape(), cell: shape(),
isEditable: bool, isEditable: bool,
dataExists: bool, dataExists: bool,
queries: arrayOf(shape()),
} }
LayoutCellMenu.propTypes = LayoutCellMenuContainer.propTypes export default LayoutCellMenu
export default LayoutCellMenuContainer

View File

@ -106,7 +106,7 @@ class LayoutRenderer extends Component {
useCSSTransforms={false} useCSSTransforms={false}
onResize={this.handleCellResize} onResize={this.handleCellResize}
onLayoutChange={this.handleLayoutChange} onLayoutChange={this.handleLayoutChange}
draggableHandle={'.dash-graph--name'} draggableHandle={'.dash-graph--draggable'}
isDraggable={isDashboard} isDraggable={isDashboard}
isResizable={isDashboard} isResizable={isDashboard}
> >

View File

@ -186,13 +186,15 @@ $dash-graph-options-arrow: 8px;
.dash-graph--name.dash-graph--name__default { .dash-graph--name.dash-graph--name__default {
font-style: italic; font-style: italic;
} }
.dash-graph--draggable {
cursor: move !important;
}
.dash-graph--custom-indicators { .dash-graph--custom-indicators {
height: 24px; height: 24px;
border-radius: 3px; border-radius: 3px;
position: absolute;
top: 3px; top: 3px;
right: 0;
display: flex; display: flex;
cursor: default;
> .custom-indicator, > .custom-indicator,
> .source-indicator { > .source-indicator {
@ -225,6 +227,9 @@ $dash-graph-options-arrow: 8px;
align-items: center; align-items: center;
flex-wrap: nowrap; flex-wrap: nowrap;
} }
.dash-graph-context--buttons {
display: flex;
}
.dash-graph-context--button { .dash-graph-context--button {
width: 24px; width: 24px;
height: 24px; height: 24px;