diff --git a/ui/src/clockface/components/empty_state/EmptyState.scss b/ui/src/clockface/components/empty_state/EmptyState.scss index e9f40238be..037f7df023 100644 --- a/ui/src/clockface/components/empty_state/EmptyState.scss +++ b/ui/src/clockface/components/empty_state/EmptyState.scss @@ -3,6 +3,8 @@ ------------------------------------------------------------------------------ */ +@import 'src/style/modules'; + .empty-state { display: flex; width: 100%; @@ -12,42 +14,59 @@ .empty-state--text, .empty-state--sub-text { + margin-bottom: 0; + text-align: center; color: $empty-state-text; @extend %no-user-select; + + em { + font-weight: 600; + font-style: normal; + color: $empty-state-highlight; + } +} + +/* + Size Modifiers + ------------------------------------------------------------------------------ +*/ +@mixin emptyStateSizeModifier($fontSize, $padding) { + padding: ceil($padding * 2.75) 0; + + .empty-state--text, + .empty-state--sub-text { + margin-top: ceil($fontSize * 0.75); + } + + .button { + margin-top: $padding; + } + + > *:last-child { + margin-bottom: ceil($fontSize * 0.75); + } + + .empty-state--text { + font-size: ceil($fontSize * 1.25); + } + + .empty-state--sub-text { + font-size: $fontSize; + } } .empty-state--xs { - padding: $ix-marg-a 0; - - .empty-state--text, - .empty-state--sub-text { - margin: $ix-marg-a 0; - } + @include emptyStateSizeModifier($form-xs-font, $ix-marg-a); } .empty-state--sm { - padding: $ix-marg-c 0; - - .empty-state--text, - .empty-state--sub-text { - margin: $ix-marg-b 0; - } + @include emptyStateSizeModifier($form-sm-font, $ix-marg-b); } .empty-state--md { - padding: $ix-marg-d 0; - - .empty-state--text, - .empty-state--sub-text { - margin: $ix-marg-b 0; - } + @include emptyStateSizeModifier($form-md-font, $ix-marg-c); } .empty-state--lg { - padding: $ix-marg-f 0; - - .empty-state--text, - .empty-state--sub-text { - margin: $ix-marg-c 0; - } -} \ No newline at end of file + @include emptyStateSizeModifier($form-lg-font, $ix-marg-d); +} diff --git a/ui/src/clockface/components/empty_state/EmptyState.tsx b/ui/src/clockface/components/empty_state/EmptyState.tsx index e67deb505e..4ace23ccb0 100644 --- a/ui/src/clockface/components/empty_state/EmptyState.tsx +++ b/ui/src/clockface/components/empty_state/EmptyState.tsx @@ -8,6 +8,10 @@ import EmptyStateSubText from 'src/clockface/components/empty_state/EmptyStateSu // Types import {ComponentSize} from 'src/clockface/types' +// Styles +import 'src/clockface/components/empty_state/EmptyState.scss' + +// Decorators import {ErrorHandling} from 'src/shared/decorators/errors' interface Props { diff --git a/ui/src/clockface/components/empty_state/EmptyStateText.tsx b/ui/src/clockface/components/empty_state/EmptyStateText.tsx index 6a9fe06e7b..f907418fbd 100644 --- a/ui/src/clockface/components/empty_state/EmptyStateText.tsx +++ b/ui/src/clockface/components/empty_state/EmptyStateText.tsx @@ -1,12 +1,38 @@ // Libraries -import React, {SFC} from 'react' +import React, {SFC, Fragment} from 'react' +import _ from 'lodash' +import uuid from 'uuid' interface Props { text: string + highlightWords?: string | string[] } -const EmptyStateText: SFC = ({text}) => ( -

{text}

+const highlighter = ( + text: string, + highlightWords: string | string[] +): JSX.Element[] => { + const splitString = text.replace(/[\\][n]/g, 'LINEBREAK').split(' ') + + return splitString.map(word => { + if (_.includes(highlightWords, word)) { + return {`${word}`} + } + + if (word === 'LINEBREAK') { + return
+ } + + if (word === 'SPACECHAR') { + return   + } + + return {`${word} `} + }) +} + +const EmptyStateText: SFC = ({text, highlightWords}) => ( +

{highlighter(text, highlightWords)}

) export default EmptyStateText diff --git a/ui/src/dashboards/components/Dashboard.tsx b/ui/src/dashboards/components/Dashboard.tsx index 5e998f7f9e..9d4412b881 100644 --- a/ui/src/dashboards/components/Dashboard.tsx +++ b/ui/src/dashboards/components/Dashboard.tsx @@ -23,6 +23,7 @@ interface Props { onPositionChange: (cells: Cell[]) => void setScrollTop: (e: MouseEvent) => void onEditView: (viewID: string) => void + onAddCell: () => void } @ErrorHandling @@ -40,6 +41,7 @@ class DashboardComponent extends PureComponent { onPositionChange, inPresentationMode, setScrollTop, + onAddCell, } = this.props return ( @@ -63,7 +65,7 @@ class DashboardComponent extends PureComponent { onEditView={onEditView} /> ) : ( - + )} {/* This element is used as a portal container for note tooltips in cell headers */}
diff --git a/ui/src/dashboards/components/DashboardHeader.tsx b/ui/src/dashboards/components/DashboardHeader.tsx index 308e718120..b4772106a7 100644 --- a/ui/src/dashboards/components/DashboardHeader.tsx +++ b/ui/src/dashboards/components/DashboardHeader.tsx @@ -10,6 +10,12 @@ import GraphTips from 'src/shared/components/graph_tips/GraphTips' import RenamablePageTitle from 'src/pageLayout/components/RenamablePageTitle' import {Button, ButtonShape, ComponentColor, IconFont} from 'src/clockface' +// Constants +import { + DEFAULT_DASHBOARD_NAME, + DASHBOARD_NAME_MAX_LENGTH, +} from 'src/dashboards/constants/index' + // Actions import {addNote} from 'src/dashboards/actions/v2/notes' @@ -122,8 +128,10 @@ class DashboardHeader extends Component { if (dashboard) { return ( ) } diff --git a/ui/src/dashboards/components/DashboardPage.tsx b/ui/src/dashboards/components/DashboardPage.tsx index a68f9bd73b..06f9c74eae 100644 --- a/ui/src/dashboards/components/DashboardPage.tsx +++ b/ui/src/dashboards/components/DashboardPage.tsx @@ -213,6 +213,7 @@ class DashboardPage extends Component { onPositionChange={this.handlePositionChange} onDeleteCell={this.handleDeleteDashboardCell} onEditView={this.handleEditView} + onAddCell={this.handleAddCell} /> )} diff --git a/ui/src/dashboards/components/VEOHeader.tsx b/ui/src/dashboards/components/VEOHeader.tsx index 9e36245e38..2c9d8772d8 100644 --- a/ui/src/dashboards/components/VEOHeader.tsx +++ b/ui/src/dashboards/components/VEOHeader.tsx @@ -12,6 +12,12 @@ import { } from 'src/clockface' import {Page} from 'src/pageLayout' +// Constants +import { + DEFAULT_CELL_NAME, + CELL_NAME_MAX_LENGTH, +} from 'src/dashboards/constants/index' + interface Props { name: string onSetName: (name: string) => void @@ -27,7 +33,12 @@ class VEOHeader extends PureComponent {
- +
) } } -const mdtp = { - addDashboardCell: addCellAsync, -} - -export default connect( - null, - mdtp -)(DashboardEmpty) +export default DashboardEmpty diff --git a/ui/src/dashboards/components/dashboard_index/DashboardsIndex.tsx b/ui/src/dashboards/components/dashboard_index/DashboardsIndex.tsx index ea3639554f..f446bb1206 100644 --- a/ui/src/dashboards/components/dashboard_index/DashboardsIndex.tsx +++ b/ui/src/dashboards/components/dashboard_index/DashboardsIndex.tsx @@ -40,6 +40,9 @@ import { dashboardCreateFailed, } from 'src/shared/copy/notifications' +// Constants +import {DEFAULT_DASHBOARD_NAME} from 'src/dashboards/constants/index' + // Types import {Notification} from 'src/types/notifications' import {DashboardFile} from 'src/types/v2/dashboards' @@ -152,7 +155,7 @@ class DashboardIndex extends PureComponent { const {router, notify} = this.props try { const newDashboard = { - name: 'Name this dashboard', + name: DEFAULT_DASHBOARD_NAME, cells: [], } const data = await createDashboard(newDashboard) @@ -215,7 +218,7 @@ class DashboardIndex extends PureComponent { h: 4, } - const name = _.get(dashboard, 'name', 'Name this dashboard') + const name = _.get(dashboard, 'name', DEFAULT_DASHBOARD_NAME) const cellsWithDefaultsApplied = getDeep( dashboard, 'cells', diff --git a/ui/src/dashboards/components/dashboard_index/Table.tsx b/ui/src/dashboards/components/dashboard_index/Table.tsx index 976ad1f961..392a94bd7f 100644 --- a/ui/src/dashboards/components/dashboard_index/Table.tsx +++ b/ui/src/dashboards/components/dashboard_index/Table.tsx @@ -141,19 +141,23 @@ class DashboardsTable extends PureComponent { if (searchTerm) { return ( - + ) } return ( - +