From 250c8df997e8ffe6e9a469549f397412680d017d Mon Sep 17 00:00:00 2001 From: alexpaxton Date: Thu, 17 Jan 2019 16:18:55 -0800 Subject: [PATCH] Moar Polish (#11255) * Allow for custom classnames in panels * Rename "Collectors" to "Telegraf Configurations" * Allow query builder blocks to always be removable Use standard margin variables in query builder * Fix alignment of labels in tasks list * Amend * Simplify context menu items * Ensure cloned cells have same dimensions as source * Update test snapshots --- .../context_menu/ContextMenuItem.tsx | 7 +-- ui/src/clockface/components/panel/Panel.tsx | 10 +++- ui/src/dashboards/actions/v2/index.ts | 5 +- .../dashboards/components/DashboardPage.tsx | 2 +- ui/src/dashboards/utils/cellGetters.ts | 15 +++++- .../organizations/components/Collectors.tsx | 48 +++++++++++++++---- ui/src/organizations/components/Scrapers.tsx | 3 +- .../components/TelegrafExplainer.scss | 8 ++++ .../components/TelegrafExplainer.tsx | 30 ++++++++++++ .../containers/OrganizationView.tsx | 3 +- ui/src/shared/components/TagSelector.scss | 26 +++++----- ui/src/shared/components/TagSelector.tsx | 28 ++++++++++- .../components/TimeMachineQueryBuilder.scss | 2 +- .../shared/components/cells/CellContext.tsx | 18 ++----- ui/src/tasks/components/TaskRow.tsx | 21 +++++--- ui/src/tasks/components/TasksList.tsx | 32 ++++++------- .../__snapshots__/TaskRow.test.tsx.snap | 27 ++++++----- .../__snapshots__/TasksList.test.tsx.snap | 36 +++++++------- .../__snapshots__/TasksPage.test.tsx.snap | 36 +++++++------- 19 files changed, 233 insertions(+), 124 deletions(-) create mode 100644 ui/src/organizations/components/TelegrafExplainer.scss create mode 100644 ui/src/organizations/components/TelegrafExplainer.tsx diff --git a/ui/src/clockface/components/context_menu/ContextMenuItem.tsx b/ui/src/clockface/components/context_menu/ContextMenuItem.tsx index e55c37ff44..785d2142c5 100644 --- a/ui/src/clockface/components/context_menu/ContextMenuItem.tsx +++ b/ui/src/clockface/components/context_menu/ContextMenuItem.tsx @@ -4,7 +4,8 @@ import classnames from 'classnames' interface Props { label: string - action: () => void + action: (value?: any) => void + value?: any onCollapseMenu?: () => void disabled?: boolean } @@ -33,14 +34,14 @@ class ContextMenuItem extends Component { } private handleClick = (): void => { - const {action, onCollapseMenu} = this.props + const {action, onCollapseMenu, value} = this.props if (!onCollapseMenu) { return } onCollapseMenu() - action() + action(value) } } diff --git a/ui/src/clockface/components/panel/Panel.tsx b/ui/src/clockface/components/panel/Panel.tsx index 0fbee67bad..e0dbf1cf44 100644 --- a/ui/src/clockface/components/panel/Panel.tsx +++ b/ui/src/clockface/components/panel/Panel.tsx @@ -1,6 +1,7 @@ // Libraries import React, {Component, ComponentClass} from 'react' import _ from 'lodash' +import classnames from 'classnames' // Components import PanelHeader from 'src/clockface/components/panel/PanelHeader' @@ -11,6 +12,7 @@ import {ErrorHandling} from 'src/shared/decorators/errors' interface Props { children: JSX.Element[] | JSX.Element + className?: string } @ErrorHandling @@ -35,11 +37,15 @@ class Panel extends Component { ).join(', ') public render() { - const {children} = this.props + const {children, className} = this.props this.validateChildren() - return
{children}
+ return ( +
+ {children} +
+ ) } private validateChildren = (): void => { diff --git a/ui/src/dashboards/actions/v2/index.ts b/ui/src/dashboards/actions/v2/index.ts index fe600877f7..5db628ac7f 100644 --- a/ui/src/dashboards/actions/v2/index.ts +++ b/ui/src/dashboards/actions/v2/index.ts @@ -284,10 +284,11 @@ export const addCellAsync = (dashboard: Dashboard) => async ( export const createCellWithView = ( dashboard: Dashboard, - view: NewView + view: NewView, + clonedCell?: Cell ) => async (dispatch: Dispatch): Promise => { try { - const cell: CreateCell = getNewDashboardCell(dashboard) + const cell: CreateCell = getNewDashboardCell(dashboard, clonedCell) const createdCell = await addCellAJAX(dashboard.id, cell) const updatedView = await updateViewAJAX(dashboard.id, createdCell.id, view) diff --git a/ui/src/dashboards/components/DashboardPage.tsx b/ui/src/dashboards/components/DashboardPage.tsx index c5f4c07b45..e161d5cead 100644 --- a/ui/src/dashboards/components/DashboardPage.tsx +++ b/ui/src/dashboards/components/DashboardPage.tsx @@ -325,7 +325,7 @@ class DashboardPage extends Component { const {dashboard, onCreateCellWithView, views} = this.props const viewEntry = views[cell.id] if (viewEntry && viewEntry.view) { - await onCreateCellWithView(dashboard, viewEntry.view) + await onCreateCellWithView(dashboard, viewEntry.view, cell) } } diff --git a/ui/src/dashboards/utils/cellGetters.ts b/ui/src/dashboards/utils/cellGetters.ts index 7907340876..e0fa98dc7c 100644 --- a/ui/src/dashboards/utils/cellGetters.ts +++ b/ui/src/dashboards/utils/cellGetters.ts @@ -53,7 +53,10 @@ const getNextAvailablePosition = (dashboard, newCell) => { } } -export const getNewDashboardCell = (dashboard: Dashboard): NewCell => { +export const getNewDashboardCell = ( + dashboard: Dashboard, + clonedCell?: Cell +): NewCell => { const defaultCell = { x: 0, y: 0, @@ -76,12 +79,20 @@ export const getNewDashboardCell = (dashboard: Dashboard): NewCell => { const mostCommonCellWidth = getMostCommonValue(existingCellWidths) const mostCommonCellHeight = getMostCommonValue(existingCellHeights) - const newCell = { + let newCell = { ...defaultCell, w: mostCommonCellWidth, h: mostCommonCellHeight, } + if (clonedCell) { + newCell = { + ...defaultCell, + w: clonedCell.w, + h: clonedCell.h, + } + } + const {x, y} = getNextAvailablePosition(dashboard, newCell) return { diff --git a/ui/src/organizations/components/Collectors.tsx b/ui/src/organizations/components/Collectors.tsx index e67242d472..e8de0a584d 100644 --- a/ui/src/organizations/components/Collectors.tsx +++ b/ui/src/organizations/components/Collectors.tsx @@ -7,12 +7,15 @@ import {downloadTextFile} from 'src/shared/utils/download' // Components import TabbedPageHeader from 'src/shared/components/tabbed_page/TabbedPageHeader' import CollectorList from 'src/organizations/components/CollectorList' +import TelegrafExplainer from 'src/organizations/components/TelegrafExplainer' import { Button, ComponentColor, IconFont, ComponentSize, EmptyState, + Grid, + Columns, } from 'src/clockface' // Actions @@ -34,35 +37,60 @@ interface Props { collectors: Telegraf[] onChange: () => void notify: NotificationsActions.PublishNotificationActionCreator + orgName: string } @ErrorHandling -export default class OrgOptions extends PureComponent { +export default class Collectors extends PureComponent { public render() { const {collectors} = this.props return ( <> -

Collectors

+

Telegraf Configurations