From 3944e0c43beb55bff692d8b3a8b22f5b23743623 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 18 Jun 2018 13:55:16 -0700 Subject: [PATCH 01/49] Rename DashboardPage.js to DashboardPage.tsx --- .../dashboards/containers/{DashboardPage.js => DashboardPage.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ui/src/dashboards/containers/{DashboardPage.js => DashboardPage.tsx} (100%) diff --git a/ui/src/dashboards/containers/DashboardPage.js b/ui/src/dashboards/containers/DashboardPage.tsx similarity index 100% rename from ui/src/dashboards/containers/DashboardPage.js rename to ui/src/dashboards/containers/DashboardPage.tsx From c3b556329d87f46916274109f9b81d269c19b446 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 18 Jun 2018 14:18:42 -0700 Subject: [PATCH 02/49] Rename shared/actions/app.js to app.ts --- ui/src/shared/actions/{app.js => app.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ui/src/shared/actions/{app.js => app.ts} (100%) diff --git a/ui/src/shared/actions/app.js b/ui/src/shared/actions/app.ts similarity index 100% rename from ui/src/shared/actions/app.js rename to ui/src/shared/actions/app.ts From c97fcc48d3016c83aa31f86749dd420665745554 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 18 Jun 2018 14:27:46 -0700 Subject: [PATCH 03/49] Type shared/actions/app.ts --- ui/src/shared/actions/app.ts | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/ui/src/shared/actions/app.ts b/ui/src/shared/actions/app.ts index df95c736dc..fb0b45c62c 100644 --- a/ui/src/shared/actions/app.ts +++ b/ui/src/shared/actions/app.ts @@ -1,15 +1,25 @@ +import {Dispatch} from 'redux' + import {PRESENTATION_MODE_ANIMATION_DELAY} from '../constants' // ephemeral state action creators -export const enablePresentationMode = () => ({ +interface EnablePresentationModeAction { + type: 'ENABLE_PRESENTATION_MODE' +} +export const enablePresentationMode = (): EnablePresentationModeAction => ({ type: 'ENABLE_PRESENTATION_MODE', }) -export const disablePresentationMode = () => ({ +interface DisablePresentationModeAction { + type: 'DISABLE_PRESENTATION_MODE' +} +export const disablePresentationMode = (): DisablePresentationModeAction => ({ type: 'DISABLE_PRESENTATION_MODE', }) -export const delayEnablePresentationMode = () => dispatch => { +export const delayEnablePresentationMode = (): (( + dispatch: Dispatch +) => void) => (dispatch: Dispatch): void => { setTimeout( () => dispatch(enablePresentationMode()), PRESENTATION_MODE_ANIMATION_DELAY @@ -17,18 +27,31 @@ export const delayEnablePresentationMode = () => dispatch => { } // persistent state action creators -export const setAutoRefresh = milliseconds => ({ +interface SetAutoRefreshAction { + type: 'SET_AUTOREFRESH' + payload: { + milliseconds: number + } +} +export const setAutoRefresh = (milliseconds: number): SetAutoRefreshAction => ({ type: 'SET_AUTOREFRESH', payload: { milliseconds, }, }) -export const templateControlBarVisibilityToggled = () => ({ +interface TemplateControlBarVisibilityToggledAction { + type: 'TEMPLATE_CONTROL_BAR_VISIBILITY_TOGGLED' +} +export const templateControlBarVisibilityToggled = (): TemplateControlBarVisibilityToggledAction => ({ type: 'TEMPLATE_CONTROL_BAR_VISIBILITY_TOGGLED', }) -export const noop = () => ({ +interface NoopAction { + type: 'NOOP' + payload: object +} +export const noop = (): NoopAction => ({ type: 'NOOP', payload: {}, }) From b9944cbdcbebd7f2103a3ab1a91eb931198ec76c Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 18 Jun 2018 14:59:25 -0700 Subject: [PATCH 04/49] Delete ui/src/shared/dispatchers/index.js & refactor delayEnablePresentationMode action --- ui/src/shared/actions/app.ts | 20 +++++++++++--------- ui/src/shared/dispatchers/index.js | 8 -------- 2 files changed, 11 insertions(+), 17 deletions(-) delete mode 100644 ui/src/shared/dispatchers/index.js diff --git a/ui/src/shared/actions/app.ts b/ui/src/shared/actions/app.ts index fb0b45c62c..0c9714fb0f 100644 --- a/ui/src/shared/actions/app.ts +++ b/ui/src/shared/actions/app.ts @@ -1,7 +1,10 @@ -import {Dispatch} from 'redux' - import {PRESENTATION_MODE_ANIMATION_DELAY} from '../constants' +import {notify} from 'src/shared/actions/notifications' +import {notifyPresentationMode} from 'src/shared/copy/notifications' + +import {Dispatch} from 'redux' + // ephemeral state action creators interface EnablePresentationModeAction { type: 'ENABLE_PRESENTATION_MODE' @@ -17,14 +20,13 @@ export const disablePresentationMode = (): DisablePresentationModeAction => ({ type: 'DISABLE_PRESENTATION_MODE', }) -export const delayEnablePresentationMode = (): (( +export const delayEnablePresentationMode = async ( dispatch: Dispatch -) => void) => (dispatch: Dispatch): void => { - setTimeout( - () => dispatch(enablePresentationMode()), - PRESENTATION_MODE_ANIMATION_DELAY - ) -} +): Promise => + setTimeout(() => { + dispatch(enablePresentationMode()) + notify(notifyPresentationMode()) + }, PRESENTATION_MODE_ANIMATION_DELAY) // persistent state action creators interface SetAutoRefreshAction { diff --git a/ui/src/shared/dispatchers/index.js b/ui/src/shared/dispatchers/index.js deleted file mode 100644 index 2ff6c7741d..0000000000 --- a/ui/src/shared/dispatchers/index.js +++ /dev/null @@ -1,8 +0,0 @@ -import {notify} from 'shared/actions/notifications' -import {delayEnablePresentationMode} from 'shared/actions/app' -import {notifyPresentationMode} from 'shared/copy/notifications' - -export const presentationButtonDispatcher = dispatch => () => { - dispatch(delayEnablePresentationMode()) - dispatch(notify(notifyPresentationMode())) -} From 6c092b645306d4112de9facdccf718833753c5f6 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 18 Jun 2018 18:12:03 -0700 Subject: [PATCH 05/49] Rename shared/actions/errors.js to errors.ts --- ui/src/shared/actions/{errors.js => errors.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ui/src/shared/actions/{errors.js => errors.ts} (100%) diff --git a/ui/src/shared/actions/errors.js b/ui/src/shared/actions/errors.ts similarity index 100% rename from ui/src/shared/actions/errors.js rename to ui/src/shared/actions/errors.ts From fad628f89f6db1f38b6df69368e32cd8aac71b88 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 18 Jun 2018 18:12:42 -0700 Subject: [PATCH 06/49] WIP Type DashboardPage & its dispatchers --- ui/src/dashboards/actions/index.ts | 204 ++++-- .../dashboards/containers/DashboardPage.tsx | 599 +++++++++--------- ui/src/hosts/containers/HostPage.js | 8 +- ui/src/shared/actions/app.ts | 6 +- ui/src/shared/actions/errors.ts | 15 +- ui/src/shared/data/timeRanges.ts | 2 +- 6 files changed, 487 insertions(+), 347 deletions(-) diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index 658574bd6e..1fd06bf640 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -1,6 +1,4 @@ import {bindActionCreators} from 'redux' -import {InjectedRouter} from 'react-router' -import {Location} from 'history' import {replace} from 'react-router-redux' import _ from 'lodash' import queryString from 'query-string' @@ -55,16 +53,24 @@ import idNormalizer, {TYPE_ID} from 'src/normalizers/id' import {defaultTimeRange} from 'src/shared/data/timeRanges' +import {InjectedRouter} from 'react-router' +import {Location} from 'history' +import {Dispatch} from 'redux' import { - Dashboard, - TimeRange, Cell, + Dashboard, + Me, Source, Template, TemplateType, + TimeRange, URLQueryParams, } from 'src/types' import {CellType, DashboardName} from 'src/types/dashboard' +import {TimeRangeOption} from 'src/shared/data/timeRanges' +import {ActionPublishNotification} from 'src/shared/actions/notifications' +import {ErrorThrownAction} from 'src/shared/actions/errors' +import {LocationAction} from 'react-router-redux' interface LoadDashboardsAction { type: 'LOAD_DASHBOARDS' @@ -128,7 +134,7 @@ export const retainRangesDashTimeV1 = ( payload: {dashboardIDs}, }) -interface SetTimeRangeAction { +export interface SetTimeRangeAction { type: 'SET_DASHBOARD_TIME_RANGE' payload: { timeRange: TimeRange @@ -378,8 +384,14 @@ export const setActiveCell = (activeCellID: string): SetActiveCellAction => ({ // Async Action Creators -export const getDashboardsAsync = () => async ( - dispatch +type GetDashboardsDispatcher = () => GetDashboardsThunk + +type GetDashboardsThunk = ( + dispatch: Dispatch +) => Promise + +export const getDashboardsAsync = (): GetDashboardsThunk => async ( + dispatch: Dispatch ): Promise => { try { const { @@ -393,10 +405,20 @@ export const getDashboardsAsync = () => async ( } } +export type GetDashboardsNamesDispatcher = ( + sourceID: string +) => GetDashboardsNamesThunk + +type GetDashboardsNamesThunk = ( + dispatch: Dispatch +) => Promise + // gets update-to-date names of dashboards, but does not dispatch action // in order to avoid duplicate and out-of-sync state problems in redux -export const getDashboardsNamesAsync = (sourceID: string) => async ( - dispatch +export const getDashboardsNamesAsync = ( + sourceID: string +): GetDashboardsNamesThunk => async ( + dispatch: Dispatch ): Promise => { try { // TODO: change this from getDashboardsAJAX to getDashboardsNamesAJAX @@ -458,8 +480,14 @@ const removeUnselectedTemplateValues = (dashboard: Dashboard): Template[] => { return templates } -export const putDashboard = (dashboard: Dashboard) => async ( - dispatch +export type PutDashboardDispatcher = (dashboard: Dashboard) => PutDashboardThunk + +type PutDashboardThunk = ( + dispatch: Dispatch +) => Promise + +export const putDashboard = (dashboard: Dashboard): PutDashboardThunk => async ( + dispatch: Dispatch ): Promise => { try { // save only selected template values to server @@ -485,9 +513,24 @@ export const putDashboard = (dashboard: Dashboard) => async ( } } -export const putDashboardByID = (dashboardID: number) => async ( - dispatch, - getState +interface DashboardsReducerState { + dashboardUI: {dashboards: Dashboard[]} +} + +type PutDashboardByIDThunk = ( + dispatch: Dispatch, + getState: () => DashboardsReducerState +) => Promise + +export type PutDashboardByIDDispatcher = ( + dashboardID: number +) => PutDashboardByIDThunk + +export const putDashboardByID = ( + dashboardID: number +): PutDashboardByIDThunk => async ( + dispatch: Dispatch, + getState: () => DashboardsReducerState ): Promise => { try { const { @@ -655,11 +698,23 @@ export const hydrateTempVarValuesAsync = ( const removeNullValues = obj => _.pickBy(obj, o => o) +type SyncURLQueryFromQueryParamsObjectDispatcher = ( + location: Location, + updatedURLQueryParams: URLQueryParams, + deletedURLQueryParams: URLQueryParams +) => SyncURLQueryFromQueryParamsObjectActionCreator + +type SyncURLQueryFromQueryParamsObjectActionCreator = ( + dispatch: Dispatch +) => void + export const syncURLQueryParamsFromQueryParamsObject = ( location: Location, updatedURLQueryParams: URLQueryParams, deletedURLQueryParams: URLQueryParams = {} -) => (dispatch): void => { +): SyncURLQueryFromQueryParamsObjectActionCreator => ( + dispatch: Dispatch +): void => { const updatedLocationQuery = removeNullValues({ ...location.query, ...updatedURLQueryParams, @@ -680,12 +735,21 @@ export const syncURLQueryParamsFromQueryParamsObject = ( dispatch(replace(updatedLocation)) } +export type SyncURLQueryFromTempVarsDispatcher = ( + location: Location, + tempVars: Template[], + deletedTempVars: Template[], + urlQueryParamsTimeRanges: URLQueryParams +) => SyncURLQueryFromQueryParamsObjectActionCreator + export const syncURLQueryFromTempVars = ( location: Location, tempVars: Template[], deletedTempVars: Template[] = [], urlQueryParamsTimeRanges: URLQueryParams = {} -) => (dispatch): void => { +): SyncURLQueryFromQueryParamsObjectActionCreator => ( + dispatch: Dispatch +): void => { const updatedURLQueryParams = generateURLQueryParamsFromTempVars(tempVars) const deletedURLQueryParams = generateURLQueryParamsFromTempVars( deletedTempVars @@ -696,19 +760,31 @@ export const syncURLQueryFromTempVars = ( ...urlQueryParamsTimeRanges, } - dispatch( - syncURLQueryParamsFromQueryParamsObject( - location, - updatedURLQueryParamsWithTimeRange, - deletedURLQueryParams - ) - ) + syncURLQueryParamsFromQueryParamsObject( + location, + updatedURLQueryParamsWithTimeRange, + deletedURLQueryParams + )(dispatch) } +interface AuthReducerState { + auth: {isUsingAuth: boolean; me: Me} +} +type SyncDashboardTempVarsFromURLQueryParamsDispatcher = ( + dispatch: Dispatch< + ActionPublishNotification | TemplateVariableSelectedAction + >, + getState: () => DashboardsReducerState & AuthReducerState +) => void const syncDashboardTempVarsFromURLQueryParams = ( dashboardID: number, urlQueryParams: URLQueryParams -) => (dispatch, getState): void => { +): SyncDashboardTempVarsFromURLQueryParamsDispatcher => ( + dispatch: Dispatch< + ActionPublishNotification | TemplateVariableSelectedAction + >, + getState: () => DashboardsReducerState & AuthReducerState +): void => { const { dashboardUI, auth: {isUsingAuth, me}, @@ -738,11 +814,25 @@ const syncDashboardTempVarsFromURLQueryParams = ( dispatch(templateVariablesSelectedByName(dashboardID, urlQueryParams)) } +type DashTimeV1Range = TimeRangeOption & {dashboardID: number} + +interface DashTimeV1ReducerState { + dashTimeV1: {ranges: DashTimeV1Range[]} +} + +type SyncDashboardTimeRangeFromURLQueryParamsDispatcher = ( + dispatch: Dispatch, + getState: () => DashboardsReducerState & DashTimeV1ReducerState +) => void + const syncDashboardTimeRangeFromURLQueryParams = ( dashboardID: number, urlQueryParams: URLQueryParams, location: Location -) => (dispatch, getState): void => { +): SyncDashboardTimeRangeFromURLQueryParamsDispatcher => ( + dispatch: Dispatch, + getState: () => DashboardsReducerState & DashTimeV1ReducerState +): void => { const { dashboardUI: {dashboards}, dashTimeV1, @@ -788,37 +878,62 @@ const syncDashboardTimeRangeFromURLQueryParams = ( zoomedLower: validatedZoomedTimeRange.lower, zoomedUpper: validatedZoomedTimeRange.upper, } - dispatch( - syncURLQueryFromTempVars( - location, - dashboard.templates, - [], - urlQueryParamsTimeRanges - ) - ) + + syncURLQueryFromTempVars( + location, + dashboard.templates, + [], + urlQueryParamsTimeRanges + )(dispatch) } +type SyncDashboardFromURLQueryParamsDispatcher = ( + dispatch: Dispatch< + | SyncDashboardTempVarsFromURLQueryParamsDispatcher + | SyncDashboardTimeRangeFromURLQueryParamsDispatcher + > +) => void const syncDashboardFromURLQueryParams = ( dashboardID: number, location: Location -) => (dispatch): void => { +): SyncDashboardFromURLQueryParamsDispatcher => ( + dispatch: Dispatch< + | SyncDashboardTempVarsFromURLQueryParamsDispatcher + | SyncDashboardTimeRangeFromURLQueryParamsDispatcher + > +): void => { const urlQueryParams = queryString.parse(window.location.search) - dispatch(syncDashboardTempVarsFromURLQueryParams(dashboardID, urlQueryParams)) - dispatch( - syncDashboardTimeRangeFromURLQueryParams( - dashboardID, - urlQueryParams, - location - ) + bindActionCreators(syncDashboardTempVarsFromURLQueryParams, dispatch)( + dashboardID, + urlQueryParams + ) + + bindActionCreators(syncDashboardTimeRangeFromURLQueryParams, dispatch)( + dashboardID, + urlQueryParams, + location ) } +export type GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = ( + dashboardID: string, + source: Source, + router: InjectedRouter, + location: Location +) => GetDashboardWithHydratedAndSyncedTempVarsAsyncActionCreator + +type GetDashboardWithHydratedAndSyncedTempVarsAsyncActionCreator = ( + dispatch: Dispatch +) => Promise + export const getDashboardWithHydratedAndSyncedTempVarsAsync = ( dashboardID: string, source: Source, router: InjectedRouter, location: Location -) => async (dispatch): Promise => { +): GetDashboardWithHydratedAndSyncedTempVarsAsyncActionCreator => async ( + dispatch: Dispatch +): Promise => { const dashboard = await bindActionCreators(getDashboardAsync, dispatch)( dashboardID ) @@ -833,7 +948,10 @@ export const getDashboardWithHydratedAndSyncedTempVarsAsync = ( source ) - dispatch(syncDashboardFromURLQueryParams(+dashboardID, location)) + bindActionCreators(syncDashboardFromURLQueryParams, dispatch)( + +dashboardID, + location + ) } export const setZoomedTimeRangeAsync = ( diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 5f7e2027b2..258979d593 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -1,5 +1,4 @@ import React, {Component} from 'react' -import PropTypes from 'prop-types' import {connect} from 'react-redux' import {withRouter} from 'react-router' import {bindActionCreators} from 'redux' @@ -14,13 +13,13 @@ import Dashboard from 'src/dashboards/components/Dashboard' import ManualRefresh from 'src/shared/components/ManualRefresh' import TemplateControlBar from 'src/tempVars/components/TemplateControlBar' -import {errorThrown as errorThrownAction} from 'shared/actions/errors' -import {notify as notifyAction} from 'shared/actions/notifications' +import {errorThrown as errorThrownAction} from 'src/shared/actions/errors' +import {notify as notifyAction} from 'src/shared/actions/notifications' import idNormalizer, {TYPE_ID} from 'src/normalizers/id' import {millisecondTimeRange} from 'src/dashboards/utils/time' import * as dashboardActionCreators from 'src/dashboards/actions' -import * as annotationActions from 'shared/actions/annotations' +import * as annotationActions from 'src/shared/actions/annotations' import { showCellEditorOverlay, @@ -35,23 +34,115 @@ import {dismissEditingAnnotation} from 'src/shared/actions/annotations' import { setAutoRefresh, templateControlBarVisibilityToggled as templateControlBarVisibilityToggledAction, -} from 'shared/actions/app' -import {presentationButtonDispatcher} from 'shared/dispatchers' + delayEnablePresentationMode, +} from 'src/shared/actions/app' + import { interval, DASHBOARD_LAYOUT_ROW_HEIGHT, TEMP_VAR_DASHBOARD_TIME, TEMP_VAR_UPPER_DASHBOARD_TIME, -} from 'shared/constants' +} from 'src/shared/constants' import {FORMAT_INFLUXQL, defaultTimeRange} from 'src/shared/data/timeRanges' -import {colorsStringSchema, colorsNumberSchema} from 'shared/schemas' import {ErrorHandling} from 'src/shared/decorators/errors' import {getDeep} from 'src/utils/wrappers' +import {Location} from 'history' +import {InjectedRouter} from 'react-router' +import {Dispatch} from 'redux' +import { + Cell, + CellType, + Dashboard as IDashboard, + Source, + TimeRange, +} from 'src/types' +import {DashboardName} from 'src/types/dashboard' +import { + SetTimeRangeAction, + PutDashboardDispatcher, + PutDashboardByIDDispatcher, + GetDashboardsNamesDispatcher, + GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher, +} from 'src/dashboards/actions' +import { + SetAutoRefreshAction, + TemplateControlBarVisibilityToggledAction, + EnablePresentationModeAction, +} from 'src/shared/actions/app' +import {ColorNumber, ColorString} from 'src/types/colors' + +interface DashboardActions { + putDashboard: PutDashboardDispatcher + putDashboardByID: PutDashboardByIDDispatcher + getDashboardsNamesAsync: GetDashboardsNamesDispatcher + getDashboardWithHydratedAndSyncedTempVarsAsync: GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher + setTimeRange: (timeRange: TimeRange) => SetTimeRangeAction + addDashboardCellAsync: ( + dashboard: IDashboard, + cellType: CellType + ) => Promise +} +interface Router { + push: (path: string) => void +} + +interface Props { + source: Source + sources: Source[] + params: { + sourceID: string + dashboardID: string + } + location: Location + dashboard: IDashboard + dashboardActions: DashboardActions + dashboards: IDashboard[] + handleChooseAutoRefresh: (milliseconds: number) => SetAutoRefreshAction + autoRefresh: number + templateControlBarVisibilityToggled: () => TemplateControlBarVisibilityToggledAction + timeRange: TimeRange + zoomedTimeRange: TimeRange + showTemplateControlBar: boolean + inPresentationMode: boolean + handleClickPresentationButton: ( + dispatch: Dispatch + ) => Promise + cellQueryStatus: { + queryID: string + status: object + } + errorThrown: () => void // TODO: double-check type + manualRefresh: number + onManualRefresh: () => void // TODO: double-check type + meRole: string + isUsingAuth: boolean + router: Router + notify: () => void // TODO: double-check type + getAnnotationsAsync: () => void // TODO: double-check type + handleShowCellEditorOverlay: () => void // TODO: double-check type + handleHideCellEditorOverlay: () => void // TODO: double-check type + handleDismissEditingAnnotation: () => void // TODO: double-check type + selectedCell: Cell + thresholdsListType: string + thresholdsListColors: ColorNumber[] + gaugeColors: ColorNumber[] + lineColors: ColorString[] + handleShowOverlay: () => void // TODO: double-check type +} + +interface State { + isEditMode: boolean + selectedCell: Cell | null + scrollTop: number + windowHeight: number + dashboardsNames: DashboardName[] +} + @ErrorHandling -class DashboardPage extends Component { +class DashboardPage extends Component { constructor(props) { super(props) @@ -64,7 +155,7 @@ class DashboardPage extends Component { } } - async componentDidMount() { + public async componentDidMount() { const { params: {dashboardID}, dashboardActions: {putDashboardByID}, @@ -99,7 +190,7 @@ class DashboardPage extends Component { this.getDashboardsNames() } - componentWillReceiveProps(nextProps) { + public componentWillReceiveProps(nextProps) { const {source, getAnnotationsAsync, timeRange} = this.props if (this.props.autoRefresh !== nextProps.autoRefresh) { clearInterval(this.intervalID) @@ -112,7 +203,7 @@ class DashboardPage extends Component { } } - componentDidUpdate(prevProps) { + public componentDidUpdate(prevProps) { const prevPath = getDeep(prevProps.location, 'pathname', null) const thisPath = getDeep(this.props.location, 'pathname', null) @@ -121,211 +212,14 @@ class DashboardPage extends Component { } } - handleWindowResize = () => { - this.setState({windowHeight: window.innerHeight}) - } - - componentWillUnmount() { + public componentWillUnmount() { clearInterval(this.intervalID) this.intervalID = false window.removeEventListener('resize', this.handleWindowResize, true) this.props.handleDismissEditingAnnotation() } - async getDashboard() { - const { - params: {dashboardID}, - dashboardActions: {getDashboardWithHydratedAndSyncedTempVarsAsync}, - source, - router, - location, - } = this.props - - return await getDashboardWithHydratedAndSyncedTempVarsAsync( - dashboardID, - source, - router, - location - ) - } - - async getDashboardsNames() { - const { - params: {sourceID}, - dashboardActions: {getDashboardsNamesAsync}, - } = this.props - - const dashboardsNames = await getDashboardsNamesAsync(sourceID) - this.setState({dashboardsNames}) - } - - inView = cell => { - const {scrollTop, windowHeight} = this.state - const bufferValue = 600 - const cellTop = cell.y * DASHBOARD_LAYOUT_ROW_HEIGHT - const cellBottom = (cell.y + cell.h) * DASHBOARD_LAYOUT_ROW_HEIGHT - const bufferedWindowBottom = windowHeight + scrollTop + bufferValue - const bufferedWindowTop = scrollTop - bufferValue - const topInView = cellTop < bufferedWindowBottom - const bottomInView = cellBottom > bufferedWindowTop - - return topInView && bottomInView - } - - handleSaveEditedCell = newCell => { - const { - dashboardActions, - dashboard, - handleHideCellEditorOverlay, - } = this.props - dashboardActions - .updateDashboardCell(dashboard, newCell) - .then(handleHideCellEditorOverlay) - } - - handleChooseTimeRange = timeRange => { - const { - dashboard, - dashboardActions, - getAnnotationsAsync, - source, - location, - } = this.props - - dashboardActions.setDashTimeV1(dashboard.id, { - ...timeRange, - format: FORMAT_INFLUXQL, - }) - - dashboardActions.syncURLQueryParamsFromQueryParamsObject(location, { - lower: timeRange.lower, - upper: timeRange.upper, - }) - - const annotationRange = millisecondTimeRange(timeRange) - getAnnotationsAsync(source.links.annotations, annotationRange) - } - - handleUpdatePosition = cells => { - const {dashboardActions, dashboard, meRole, isUsingAuth} = this.props - const newDashboard = {...dashboard, cells} - - // GridLayout invokes onLayoutChange on first load, which bubbles up to - // invoke handleUpdatePosition. If using auth, Viewer is not authorized to - // PUT, so until the need for PUT is removed, this is prevented. - if (!isUsingAuth || isUserAuthorized(meRole, EDITOR_ROLE)) { - dashboardActions.updateDashboard(newDashboard) - dashboardActions.putDashboard(newDashboard) - } - } - - handleAddCell = () => { - const {dashboardActions, dashboard} = this.props - dashboardActions.addDashboardCellAsync(dashboard) - } - - handleCloneCell = cell => { - const {dashboardActions, dashboard} = this.props - dashboardActions.cloneDashboardCellAsync(dashboard, cell) - } - - handleEditDashboard = () => { - this.setState({isEditMode: true}) - } - - handleCancelEditDashboard = () => { - this.setState({isEditMode: false}) - } - - handleRenameDashboard = async name => { - const {dashboardActions, dashboard} = this.props - this.setState({isEditMode: false}) - const newDashboard = {...dashboard, name} - - dashboardActions.updateDashboard(newDashboard) - await dashboardActions.putDashboard(newDashboard) - this.getDashboardsNames() - } - - handleUpdateDashboardCell = newCell => () => { - const {dashboardActions, dashboard} = this.props - dashboardActions.updateDashboardCell(dashboard, newCell) - } - - handleDeleteDashboardCell = cell => { - const {dashboardActions, dashboard} = this.props - dashboardActions.deleteDashboardCellAsync(dashboard, cell) - } - - handleSelectTemplate = templateID => value => { - const { - dashboardActions, - dashboard, - params: {dashboardID}, - location, - } = this.props - - const currentTempVar = dashboard.templates.find( - tempVar => tempVar.id === templateID - ) - const strippedTempVar = stripTempVar(currentTempVar.tempVar) - const isTempVarInURLQuery = !!location.query[strippedTempVar] - - if (isTempVarInURLQuery) { - const updatedQueryParam = { - [strippedTempVar]: value.value, - } - dashboardActions.syncURLQueryParamsFromQueryParamsObject( - location, - updatedQueryParam - ) - } - dashboardActions.templateVariableSelected(dashboard.id, templateID, [value]) - dashboardActions.putDashboardByID(dashboardID) - } - - handleSaveTemplateVariables = async templates => { - const {location, dashboardActions, dashboard} = this.props - - try { - await dashboardActions.putDashboard({ - ...dashboard, - templates, - }) - const deletedTempVars = dashboard.templates.filter( - ({tempVar: oldTempVar}) => - !templates.find(({tempVar: newTempVar}) => oldTempVar === newTempVar) - ) - dashboardActions.syncURLQueryFromTempVars( - location, - templates, - deletedTempVars - ) - } catch (error) { - console.error(error) - } - } - - handleRunQueryFailure = error => { - console.error(error) - this.props.errorThrown(error) - } - - handleToggleTempVarControls = () => { - this.props.templateControlBarVisibilityToggled() - } - - handleZoomedTimeRange = (zoomedLower, zoomedUpper) => { - const {dashboardActions, location} = this.props - const zoomedTimeRange = {lower: zoomedLower, upper: zoomedUpper} - dashboardActions.setZoomedTimeRangeAsync(zoomedTimeRange, location) - } - - setScrollTop = event => { - this.setState({scrollTop: event.target.scrollTop}) - } - - render() { + public render() { const { isUsingAuth, meRole, @@ -481,93 +375,203 @@ class DashboardPage extends Component { ) } -} -const {arrayOf, bool, func, number, shape, string} = PropTypes + private handleWindowResize = () => { + this.setState({windowHeight: window.innerHeight}) + } -DashboardPage.propTypes = { - source: shape({ - links: shape({ - proxy: string, - self: string, - }), - }).isRequired, - sources: arrayOf(shape({})).isRequired, - params: shape({ - sourceID: string.isRequired, - dashboardID: string.isRequired, - }).isRequired, - location: shape({ - pathname: string.isRequired, - query: shape({}), - }).isRequired, - dashboard: shape({}), - dashboardActions: shape({ - putDashboard: func.isRequired, - getDashboardsNamesAsync: func.isRequired, - getDashboardWithHydratedAndSyncedTempVarsAsync: func.isRequired, - setTimeRange: func.isRequired, - addDashboardCellAsync: func.isRequired, - }).isRequired, - dashboards: arrayOf( - shape({ - id: number.isRequired, - cells: arrayOf(shape({})).isRequired, - templates: arrayOf( - shape({ - type: string.isRequired, - tempVar: string.isRequired, - query: shape({ - db: string, - rp: string, - influxql: string, - }), - values: arrayOf( - shape({ - value: string.isRequired, - selected: bool.isRequired, - type: string.isRequired, - }) - ), - }) - ), + private async getDashboard() { + const { + params: {dashboardID}, + dashboardActions: {getDashboardWithHydratedAndSyncedTempVarsAsync}, + source, + router, + location, + } = this.props + + return await getDashboardWithHydratedAndSyncedTempVarsAsync( + dashboardID, + source, + router, + location + ) + } + + private async getDashboardsNames() { + const { + params: {sourceID}, + dashboardActions: {getDashboardsNamesAsync}, + } = this.props + + const dashboardsNames = await getDashboardsNamesAsync(sourceID) + this.setState({dashboardsNames}) + } + + private inView = cell => { + const {scrollTop, windowHeight} = this.state + const bufferValue = 600 + const cellTop = cell.y * DASHBOARD_LAYOUT_ROW_HEIGHT + const cellBottom = (cell.y + cell.h) * DASHBOARD_LAYOUT_ROW_HEIGHT + const bufferedWindowBottom = windowHeight + scrollTop + bufferValue + const bufferedWindowTop = scrollTop - bufferValue + const topInView = cellTop < bufferedWindowBottom + const bottomInView = cellBottom > bufferedWindowTop + + return topInView && bottomInView + } + + private handleSaveEditedCell = newCell => { + const { + dashboardActions, + dashboard, + handleHideCellEditorOverlay, + } = this.props + dashboardActions + .updateDashboardCell(dashboard, newCell) + .then(handleHideCellEditorOverlay) + } + + private handleChooseTimeRange = timeRange => { + const { + dashboard, + dashboardActions, + getAnnotationsAsync, + source, + location, + } = this.props + + dashboardActions.setDashTimeV1(dashboard.id, { + ...timeRange, + format: FORMAT_INFLUXQL, }) - ), - handleChooseAutoRefresh: func.isRequired, - autoRefresh: number.isRequired, - templateControlBarVisibilityToggled: func.isRequired, - timeRange: shape({ - upper: string, - lower: string, - }), - zoomedTimeRange: shape({ - upper: string, - lower: string, - }), - showTemplateControlBar: bool.isRequired, - inPresentationMode: bool.isRequired, - handleClickPresentationButton: func, - cellQueryStatus: shape({ - queryID: string, - status: shape(), - }).isRequired, - errorThrown: func, - manualRefresh: number.isRequired, - onManualRefresh: func.isRequired, - meRole: string, - isUsingAuth: bool.isRequired, - router: shape().isRequired, - notify: func.isRequired, - getAnnotationsAsync: func.isRequired, - handleShowCellEditorOverlay: func.isRequired, - handleHideCellEditorOverlay: func.isRequired, - handleDismissEditingAnnotation: func.isRequired, - selectedCell: shape({}), - thresholdsListType: string.isRequired, - thresholdsListColors: colorsNumberSchema.isRequired, - gaugeColors: colorsNumberSchema.isRequired, - lineColors: colorsStringSchema.isRequired, - handleShowOverlay: func.isRequired, + + dashboardActions.syncURLQueryParamsFromQueryParamsObject(location, { + lower: timeRange.lower, + upper: timeRange.upper, + }) + + const annotationRange = millisecondTimeRange(timeRange) + getAnnotationsAsync(source.links.annotations, annotationRange) + } + + private handleUpdatePosition = cells => { + const {dashboardActions, dashboard, meRole, isUsingAuth} = this.props + const newDashboard = {...dashboard, cells} + + // GridLayout invokes onLayoutChange on first load, which bubbles up to + // invoke handleUpdatePosition. If using auth, Viewer is not authorized to + // PUT, so until the need for PUT is removed, this is prevented. + if (!isUsingAuth || isUserAuthorized(meRole, EDITOR_ROLE)) { + dashboardActions.updateDashboard(newDashboard) + dashboardActions.putDashboard(newDashboard) + } + } + + private handleAddCell = () => { + const {dashboardActions, dashboard} = this.props + dashboardActions.addDashboardCellAsync(dashboard) + } + + private handleCloneCell = cell => { + const {dashboardActions, dashboard} = this.props + dashboardActions.cloneDashboardCellAsync(dashboard, cell) + } + + private handleEditDashboard = () => { + this.setState({isEditMode: true}) + } + + private handleCancelEditDashboard = () => { + this.setState({isEditMode: false}) + } + + private handleRenameDashboard = async name => { + const {dashboardActions, dashboard} = this.props + this.setState({isEditMode: false}) + const newDashboard = {...dashboard, name} + + dashboardActions.updateDashboard(newDashboard) + await dashboardActions.putDashboard(newDashboard) + this.getDashboardsNames() + } + + private handleUpdateDashboardCell = newCell => () => { + const {dashboardActions, dashboard} = this.props + dashboardActions.updateDashboardCell(dashboard, newCell) + } + + private handleDeleteDashboardCell = cell => { + const {dashboardActions, dashboard} = this.props + dashboardActions.deleteDashboardCellAsync(dashboard, cell) + } + + private handleSelectTemplate = templateID => value => { + const { + dashboardActions, + dashboard, + params: {dashboardID}, + location, + } = this.props + + const currentTempVar = dashboard.templates.find( + tempVar => tempVar.id === templateID + ) + const strippedTempVar = stripTempVar(currentTempVar.tempVar) + const isTempVarInURLQuery = !!location.query[strippedTempVar] + + if (isTempVarInURLQuery) { + const updatedQueryParam = { + [strippedTempVar]: value.value, + } + dashboardActions.syncURLQueryParamsFromQueryParamsObject( + location, + updatedQueryParam + ) + } + dashboardActions.templateVariableSelected(dashboard.id, templateID, [value]) + dashboardActions.putDashboardByID(dashboardID) + } + + private handleSaveTemplateVariables = async templates => { + const {location, dashboardActions, dashboard} = this.props + + try { + await dashboardActions.putDashboard({ + ...dashboard, + templates, + }) + const deletedTempVars = dashboard.templates.filter( + ({tempVar: oldTempVar}) => + !templates.find(({tempVar: newTempVar}) => oldTempVar === newTempVar) + ) + dashboardActions.syncURLQueryFromTempVars( + location, + templates, + deletedTempVars + ) + } catch (error) { + console.error(error) + } + } + + private handleRunQueryFailure = error => { + console.error(error) + this.props.errorThrown(error) + } + + private handleToggleTempVarControls = () => { + this.props.templateControlBarVisibilityToggled() + } + + private handleZoomedTimeRange = (zoomedLower, zoomedUpper) => { + const {dashboardActions, location} = this.props + const zoomedTimeRange = {lower: zoomedLower, upper: zoomedUpper} + dashboardActions.setZoomedTimeRangeAsync(zoomedTimeRange, location) + } + + private setScrollTop = event => { + this.setState({scrollTop: event.target.scrollTop}) + } } const mapStateToProps = (state, {params: {dashboardID}}) => { @@ -628,7 +632,10 @@ const mapDispatchToProps = dispatch => ({ templateControlBarVisibilityToggledAction, dispatch ), - handleClickPresentationButton: presentationButtonDispatcher(dispatch), + handleClickPresentationButton: bindActionCreators( + delayEnablePresentationMode, + dispatch + ), dashboardActions: bindActionCreators(dashboardActionCreators, dispatch), errorThrown: bindActionCreators(errorThrownAction, dispatch), notify: bindActionCreators(notifyAction, dispatch), diff --git a/ui/src/hosts/containers/HostPage.js b/ui/src/hosts/containers/HostPage.js index ff92a7074b..7389bc894d 100644 --- a/ui/src/hosts/containers/HostPage.js +++ b/ui/src/hosts/containers/HostPage.js @@ -19,8 +19,7 @@ import { getAllHosts, } from 'src/hosts/apis' -import {setAutoRefresh} from 'shared/actions/app' -import {presentationButtonDispatcher} from 'shared/dispatchers' +import {setAutoRefresh, delayEnablePresentationMode} from 'shared/actions/app' import {ErrorHandling} from 'src/shared/decorators/errors' @ErrorHandling @@ -247,7 +246,10 @@ const mapStateToProps = ({ const mapDispatchToProps = dispatch => ({ handleChooseAutoRefresh: bindActionCreators(setAutoRefresh, dispatch), - handleClickPresentationButton: presentationButtonDispatcher(dispatch), + handleClickPresentationButton: bindActionCreators( + delayEnablePresentationMode, + dispatch + ), }) export default connect(mapStateToProps, mapDispatchToProps)( diff --git a/ui/src/shared/actions/app.ts b/ui/src/shared/actions/app.ts index 0c9714fb0f..e11d87fac4 100644 --- a/ui/src/shared/actions/app.ts +++ b/ui/src/shared/actions/app.ts @@ -6,7 +6,7 @@ import {notifyPresentationMode} from 'src/shared/copy/notifications' import {Dispatch} from 'redux' // ephemeral state action creators -interface EnablePresentationModeAction { +export interface EnablePresentationModeAction { type: 'ENABLE_PRESENTATION_MODE' } export const enablePresentationMode = (): EnablePresentationModeAction => ({ @@ -29,7 +29,7 @@ export const delayEnablePresentationMode = async ( }, PRESENTATION_MODE_ANIMATION_DELAY) // persistent state action creators -interface SetAutoRefreshAction { +export interface SetAutoRefreshAction { type: 'SET_AUTOREFRESH' payload: { milliseconds: number @@ -42,7 +42,7 @@ export const setAutoRefresh = (milliseconds: number): SetAutoRefreshAction => ({ }, }) -interface TemplateControlBarVisibilityToggledAction { +export interface TemplateControlBarVisibilityToggledAction { type: 'TEMPLATE_CONTROL_BAR_VISIBILITY_TOGGLED' } export const templateControlBarVisibilityToggled = (): TemplateControlBarVisibilityToggledAction => ({ diff --git a/ui/src/shared/actions/errors.ts b/ui/src/shared/actions/errors.ts index 7e19a45377..95c21aa81e 100644 --- a/ui/src/shared/actions/errors.ts +++ b/ui/src/shared/actions/errors.ts @@ -1,4 +1,17 @@ -export const errorThrown = (error, altText, alertType) => ({ +enum AlertType { + 'info', +} +export interface ErrorThrownAction { + type: 'ERROR_THROWN' + error: Error + altText?: string + alertType?: AlertType +} +export const errorThrown = ( + error: Error, + altText?: string, + alertType?: AlertType +): ErrorThrownAction => ({ type: 'ERROR_THROWN', error, altText, diff --git a/ui/src/shared/data/timeRanges.ts b/ui/src/shared/data/timeRanges.ts index f711a56ebf..2b6011dbff 100644 --- a/ui/src/shared/data/timeRanges.ts +++ b/ui/src/shared/data/timeRanges.ts @@ -1,5 +1,5 @@ import {TimeRange} from 'src/types/query' -interface TimeRangeOption extends TimeRange { +export interface TimeRangeOption extends TimeRange { defaultGroupBy: string seconds: number inputValue: string From 46e9d305a30ab07d89da257d36287a0ee413232e Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Wed, 20 Jun 2018 12:15:42 -0700 Subject: [PATCH 07/49] Add type for GetAnnotationsAsync Co-authored-by: Alirie Gray --- ui/src/dashboards/containers/DashboardPage.tsx | 3 ++- ui/src/shared/actions/annotations.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 258979d593..dcadfa4fe2 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -67,6 +67,7 @@ import { GetDashboardsNamesDispatcher, GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher, } from 'src/dashboards/actions' +import {GetAnnotationsDispatcher} from 'src/shared/actions/annotations' import { SetAutoRefreshAction, TemplateControlBarVisibilityToggledAction, @@ -121,7 +122,7 @@ interface Props { isUsingAuth: boolean router: Router notify: () => void // TODO: double-check type - getAnnotationsAsync: () => void // TODO: double-check type + getAnnotationsAsync: GetAnnotationsDispatcher handleShowCellEditorOverlay: () => void // TODO: double-check type handleHideCellEditorOverlay: () => void // TODO: double-check type handleDismissEditingAnnotation: () => void // TODO: double-check type diff --git a/ui/src/shared/actions/annotations.ts b/ui/src/shared/actions/annotations.ts index 47a8421ff1..6a592d2a39 100644 --- a/ui/src/shared/actions/annotations.ts +++ b/ui/src/shared/actions/annotations.ts @@ -1,5 +1,6 @@ import * as api from 'src/shared/apis/annotation' import {AnnotationInterface} from 'src/types' +import {Dispatch} from 'redux' export type Action = | EditingAnnotationAction @@ -137,6 +138,14 @@ export interface AnnotationRange { since: number until: number } +type GetAnnotationsThunk = ( + dispatch: Dispatch +) => Promise + +export type GetAnnotationsDispatcher = ( + indexUrl: string, + annotationRange: AnnotationRange +) => GetAnnotationsThunk export const getAnnotationsAsync = ( indexUrl: string, From 891397ffcd667f99ec2b9f269801adeaebd3dbe3 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Wed, 20 Jun 2018 13:57:12 -0700 Subject: [PATCH 08/49] Simplify mapStateToProps & mapDispatchToProps --- .../dashboards/containers/DashboardPage.tsx | 51 ++++++------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index dcadfa4fe2..3627c4b1b7 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -1,7 +1,6 @@ import React, {Component} from 'react' import {connect} from 'react-redux' import {withRouter} from 'react-router' -import {bindActionCreators} from 'redux' import _ from 'lodash' @@ -575,7 +574,7 @@ class DashboardPage extends Component { } } -const mapStateToProps = (state, {params: {dashboardID}}) => { +const mstp = (state, {params: {dashboardID}}) => { const { app: { ephemeral: {inPresentationMode}, @@ -627,38 +626,18 @@ const mapStateToProps = (state, {params: {dashboardID}}) => { } } -const mapDispatchToProps = dispatch => ({ - handleChooseAutoRefresh: bindActionCreators(setAutoRefresh, dispatch), - templateControlBarVisibilityToggled: bindActionCreators( - templateControlBarVisibilityToggledAction, - dispatch - ), - handleClickPresentationButton: bindActionCreators( - delayEnablePresentationMode, - dispatch - ), - dashboardActions: bindActionCreators(dashboardActionCreators, dispatch), - errorThrown: bindActionCreators(errorThrownAction, dispatch), - notify: bindActionCreators(notifyAction, dispatch), - getAnnotationsAsync: bindActionCreators( - annotationActions.getAnnotationsAsync, - dispatch - ), - handleShowCellEditorOverlay: bindActionCreators( - showCellEditorOverlay, - dispatch - ), - handleHideCellEditorOverlay: bindActionCreators( - hideCellEditorOverlay, - dispatch - ), - handleDismissEditingAnnotation: bindActionCreators( - dismissEditingAnnotation, - dispatch - ), - handleShowOverlay: bindActionCreators(showOverlay, dispatch), -}) +const mdtp = { + handleChooseAutoRefresh: setAutoRefresh, + templateControlBarVisibilityToggled: templateControlBarVisibilityToggledAction, + handleClickPresentationButton: delayEnablePresentationMode, + dashboardActions: dashboardActionCreators, + errorThrown: errorThrownAction, + notify: notifyAction, + getAnnotationsAsync: annotationActions.getAnnotationsAsync, + handleShowCellEditorOverlay: showCellEditorOverlay, + handleHideCellEditorOverlay: hideCellEditorOverlay, + handleDismissEditingAnnotation: dismissEditingAnnotation, + handleShowOverlay: showOverlay, +} -export default connect(mapStateToProps, mapDispatchToProps)( - ManualRefresh(withRouter(DashboardPage)) -) +export default connect(mstp, mdtp)(ManualRefresh(withRouter(DashboardPage))) From c00c2f1a3a82bf89782b32ac5424a4f0df5600b4 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Wed, 20 Jun 2018 14:15:39 -0700 Subject: [PATCH 09/49] WIP --- .../dashboards/actions/cellEditorOverlay.ts | 4 +- ui/src/dashboards/actions/index.ts | 23 ++++++- .../dashboards/containers/DashboardPage.tsx | 60 ++++++++----------- ui/src/shared/actions/overlayTechnology.ts | 8 +-- 4 files changed, 53 insertions(+), 42 deletions(-) diff --git a/ui/src/dashboards/actions/cellEditorOverlay.ts b/ui/src/dashboards/actions/cellEditorOverlay.ts index 701bf8f6a8..2aba0ce1a7 100644 --- a/ui/src/dashboards/actions/cellEditorOverlay.ts +++ b/ui/src/dashboards/actions/cellEditorOverlay.ts @@ -23,7 +23,7 @@ export type Action = | ChangeDecimalPlacesAction | UpdateFieldOptionsAction -interface ShowCellEditorOverlayAction { +export interface ShowCellEditorOverlayAction { type: 'SHOW_CELL_EDITOR_OVERLAY' payload: { cell: Cell @@ -38,7 +38,7 @@ export const showCellEditorOverlay = ( }, }) -interface HideCellEditorOverlayAction { +export interface HideCellEditorOverlayAction { type: 'HIDE_CELL_EDITOR_OVERLAY' } export const hideCellEditorOverlay = (): HideCellEditorOverlayAction => ({ diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index 1fd06bf640..458aa9ab01 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -134,7 +134,11 @@ export const retainRangesDashTimeV1 = ( payload: {dashboardIDs}, }) -export interface SetTimeRangeAction { +export type SetTimeRangeActionCreator = ( + timeRange: TimeRange +) => SetTimeRangeAction + +interface SetTimeRangeAction { type: 'SET_DASHBOARD_TIME_RANGE' payload: { timeRange: TimeRange @@ -575,10 +579,25 @@ export const deleteDashboardAsync = (dashboard: Dashboard) => async ( } } +export type AddDashboardCellDispatcher = ( + dashboard: Dashboard, + cellType: CellType +) => AddDashboardCellThunk + +type AddDashboardCellThunk = ( + dispatch: Dispatch< + AddDashboardCellAction | ActionPublishNotification | ErrorThrownAction + > +) => Promise + export const addDashboardCellAsync = ( dashboard: Dashboard, cellType: CellType -) => async (dispatch): Promise => { +): AddDashboardCellThunk => async ( + dispatch: Dispatch< + AddDashboardCellAction | ActionPublishNotification | ErrorThrownAction + > +): Promise => { try { const {data} = await addDashboardCellAJAX( dashboard, diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 3627c4b1b7..3608ac6f2f 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -49,7 +49,6 @@ import {ErrorHandling} from 'src/shared/decorators/errors' import {getDeep} from 'src/utils/wrappers' import {Location} from 'history' -import {InjectedRouter} from 'react-router' import {Dispatch} from 'redux' import { Cell, @@ -59,31 +58,22 @@ import { TimeRange, } from 'src/types' import {DashboardName} from 'src/types/dashboard' -import { - SetTimeRangeAction, - PutDashboardDispatcher, - PutDashboardByIDDispatcher, - GetDashboardsNamesDispatcher, - GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher, -} from 'src/dashboards/actions' -import {GetAnnotationsDispatcher} from 'src/shared/actions/annotations' -import { - SetAutoRefreshAction, - TemplateControlBarVisibilityToggledAction, - EnablePresentationModeAction, -} from 'src/shared/actions/app' import {ColorNumber, ColorString} from 'src/types/colors' +import * as AnnotationActions from 'src/shared/actions/annotations' +import * as AppActions from 'src/shared/actions/app' +import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay' +import * as DashboardActions from 'src/dashboards/actions' +import * as ErrorActions from 'src/shared/actions/errors' +import * as OverlayTechnologyActions from 'src/shared/actions/overlayTechnology' +import * as NotificationActions from 'src/shared/actions/notifications' interface DashboardActions { - putDashboard: PutDashboardDispatcher - putDashboardByID: PutDashboardByIDDispatcher - getDashboardsNamesAsync: GetDashboardsNamesDispatcher - getDashboardWithHydratedAndSyncedTempVarsAsync: GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher - setTimeRange: (timeRange: TimeRange) => SetTimeRangeAction - addDashboardCellAsync: ( - dashboard: IDashboard, - cellType: CellType - ) => Promise + putDashboard: DashboardActions.PutDashboardDispatcher + putDashboardByID: DashboardActions.PutDashboardByIDDispatcher + getDashboardsNamesAsync: DashboardActions.GetDashboardsNamesDispatcher + getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher + setTimeRange: DashboardActions.SetTimeRangeActionCreator + addDashboardCellAsync: DashboardActions.AddDashboardCellDispatcher } interface Router { push: (path: string) => void @@ -100,37 +90,39 @@ interface Props { dashboard: IDashboard dashboardActions: DashboardActions dashboards: IDashboard[] - handleChooseAutoRefresh: (milliseconds: number) => SetAutoRefreshAction + handleChooseAutoRefresh: ( + milliseconds: number + ) => AppActions.SetAutoRefreshActionCreator autoRefresh: number - templateControlBarVisibilityToggled: () => TemplateControlBarVisibilityToggledAction + templateControlBarVisibilityToggled: () => AppActions.TemplateControlBarVisibilityToggledActionCreator timeRange: TimeRange zoomedTimeRange: TimeRange showTemplateControlBar: boolean inPresentationMode: boolean handleClickPresentationButton: ( - dispatch: Dispatch + dispatch: Dispatch ) => Promise cellQueryStatus: { queryID: string status: object } - errorThrown: () => void // TODO: double-check type + errorThrown: ErrorActions.ErrorThrownActionCreator manualRefresh: number - onManualRefresh: () => void // TODO: double-check type + onManualRefresh: () => void meRole: string isUsingAuth: boolean router: Router - notify: () => void // TODO: double-check type - getAnnotationsAsync: GetAnnotationsDispatcher - handleShowCellEditorOverlay: () => void // TODO: double-check type - handleHideCellEditorOverlay: () => void // TODO: double-check type - handleDismissEditingAnnotation: () => void // TODO: double-check type + notify: NotificationActions.ActionCreatorPublishNotification + getAnnotationsAsync: AnnotationActions.GetAnnotationsDispatcher + handleShowCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator + handleHideCellEditorOverlay: CellEditorOverlayActions.HideCellEditorOverlayActionCreator + handleDismissEditingAnnotation: AnnotationActions.DismissEditingAnnotationActionCreator selectedCell: Cell thresholdsListType: string thresholdsListColors: ColorNumber[] gaugeColors: ColorNumber[] lineColors: ColorString[] - handleShowOverlay: () => void // TODO: double-check type + handleShowOverlay: OverlayTechnologyActions.ShowOverlayActionCreator } interface State { diff --git a/ui/src/shared/actions/overlayTechnology.ts b/ui/src/shared/actions/overlayTechnology.ts index ec19ed4424..400dd7f9b1 100644 --- a/ui/src/shared/actions/overlayTechnology.ts +++ b/ui/src/shared/actions/overlayTechnology.ts @@ -8,12 +8,12 @@ interface Options { transitionTime?: number } -export type ShowOverlay = ( +export type ShowOverlayActionCreator = ( OverlayNode: OverlayNodeType, options: Options -) => ActionOverlayNode +) => ShowOverlayAction -export interface ActionOverlayNode { +interface ShowOverlayAction { type: 'SHOW_OVERLAY' payload: { OverlayNode @@ -24,7 +24,7 @@ export interface ActionOverlayNode { export const showOverlay = ( OverlayNode: OverlayNodeType, options: Options -) => ({ +): ShowOverlayAction => ({ type: 'SHOW_OVERLAY', payload: {OverlayNode, options}, }) From 0fd89449bdaea9a4c6c0acc8f6827b1c1b2ae18d Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Wed, 20 Jun 2018 14:45:07 -0700 Subject: [PATCH 10/49] Add & fix consumption of Dashboard ActionCreator types --- .../dashboards/actions/cellEditorOverlay.ts | 12 +++- ui/src/dashboards/actions/index.ts | 55 ++++++++++++------- .../dashboards/containers/DashboardPage.tsx | 2 +- ui/src/shared/actions/annotations.ts | 11 ++-- ui/src/shared/actions/app.ts | 14 ++++- ui/src/shared/actions/errors.ts | 9 ++- ui/src/shared/actions/notifications.ts | 13 +++-- ui/src/sources/containers/SourcePage.tsx | 4 +- 8 files changed, 81 insertions(+), 39 deletions(-) diff --git a/ui/src/dashboards/actions/cellEditorOverlay.ts b/ui/src/dashboards/actions/cellEditorOverlay.ts index 2aba0ce1a7..b1f91b7b54 100644 --- a/ui/src/dashboards/actions/cellEditorOverlay.ts +++ b/ui/src/dashboards/actions/cellEditorOverlay.ts @@ -23,13 +23,17 @@ export type Action = | ChangeDecimalPlacesAction | UpdateFieldOptionsAction -export interface ShowCellEditorOverlayAction { +export type ShowCellEditorOverlayActionCreator = ( + cell: Cell +) => ShowCellEditorOverlayAction + +interface ShowCellEditorOverlayAction { type: 'SHOW_CELL_EDITOR_OVERLAY' payload: { cell: Cell } } -export const showCellEditorOverlay = ( +export const showCellEditorOverlay: ShowCellEditorOverlayActionCreator = ( cell: Cell ): ShowCellEditorOverlayAction => ({ type: 'SHOW_CELL_EDITOR_OVERLAY', @@ -38,7 +42,9 @@ export const showCellEditorOverlay = ( }, }) -export interface HideCellEditorOverlayAction { +export type HideCellEditorOverlayActionCreator = () => HideCellEditorOverlayAction + +interface HideCellEditorOverlayAction { type: 'HIDE_CELL_EDITOR_OVERLAY' } export const hideCellEditorOverlay = (): HideCellEditorOverlayAction => ({ diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index cdf742d157..810ab39277 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -68,10 +68,15 @@ import { } from 'src/types' import {CellType, DashboardName} from 'src/types/dashboard' import {TimeRangeOption} from 'src/shared/data/timeRanges' -import {ActionPublishNotification} from 'src/shared/actions/notifications' -import {ErrorThrownAction} from 'src/shared/actions/errors' +import {PublishNotificationActionCreator} from 'src/shared/actions/notifications' +import * as ErrorActions from 'src/shared/actions/errors' import {LocationAction} from 'react-router-redux' +export type LoadDashboardsActionCreator = ( + dashboards: Dashboard[], + dashboardID?: number +) => LoadDashboardsAction + interface LoadDashboardsAction { type: 'LOAD_DASHBOARDS' payload: { @@ -79,7 +84,7 @@ interface LoadDashboardsAction { dashboardID: number } } -export const loadDashboards = ( +export const loadDashboards: LoadDashboardsActionCreator = ( dashboards: Dashboard[], dashboardID?: number ): LoadDashboardsAction => ({ @@ -388,14 +393,16 @@ export const setActiveCell = (activeCellID: string): SetActiveCellAction => ({ // Async Action Creators -type GetDashboardsDispatcher = () => GetDashboardsThunk +export type GetDashboardsDispatcher = () => GetDashboardsThunk type GetDashboardsThunk = ( - dispatch: Dispatch + dispatch: Dispatch ) => Promise export const getDashboardsAsync = (): GetDashboardsThunk => async ( - dispatch: Dispatch + dispatch: Dispatch< + LoadDashboardsActionCreator | ErrorActions.ErrorThrownActionCreator + > ): Promise => { try { const { @@ -414,7 +421,7 @@ export type GetDashboardsNamesDispatcher = ( ) => GetDashboardsNamesThunk type GetDashboardsNamesThunk = ( - dispatch: Dispatch + dispatch: Dispatch ) => Promise // gets update-to-date names of dashboards, but does not dispatch action @@ -422,7 +429,7 @@ type GetDashboardsNamesThunk = ( export const getDashboardsNamesAsync = ( sourceID: string ): GetDashboardsNamesThunk => async ( - dispatch: Dispatch + dispatch: Dispatch ): Promise => { try { // TODO: change this from getDashboardsAJAX to getDashboardsNamesAJAX @@ -487,11 +494,15 @@ const removeUnselectedTemplateValues = (dashboard: Dashboard): Template[] => { export type PutDashboardDispatcher = (dashboard: Dashboard) => PutDashboardThunk type PutDashboardThunk = ( - dispatch: Dispatch + dispatch: Dispatch< + UpdateDashboardAction | ErrorActions.ErrorThrownActionCreator + > ) => Promise export const putDashboard = (dashboard: Dashboard): PutDashboardThunk => async ( - dispatch: Dispatch + dispatch: Dispatch< + UpdateDashboardAction | ErrorActions.ErrorThrownActionCreator + > ): Promise => { try { // save only selected template values to server @@ -522,7 +533,7 @@ interface DashboardsReducerState { } type PutDashboardByIDThunk = ( - dispatch: Dispatch, + dispatch: Dispatch, getState: () => DashboardsReducerState ) => Promise @@ -533,7 +544,7 @@ export type PutDashboardByIDDispatcher = ( export const putDashboardByID = ( dashboardID: number ): PutDashboardByIDThunk => async ( - dispatch: Dispatch, + dispatch: Dispatch, getState: () => DashboardsReducerState ): Promise => { try { @@ -586,7 +597,9 @@ export type AddDashboardCellDispatcher = ( type AddDashboardCellThunk = ( dispatch: Dispatch< - AddDashboardCellAction | ActionPublishNotification | ErrorThrownAction + | AddDashboardCellAction + | PublishNotificationActionCreator + | ErrorActions.ErrorThrownActionCreator > ) => Promise @@ -595,7 +608,9 @@ export const addDashboardCellAsync = ( cellType: CellType ): AddDashboardCellThunk => async ( dispatch: Dispatch< - AddDashboardCellAction | ActionPublishNotification | ErrorThrownAction + | AddDashboardCellAction + | PublishNotificationActionCreator + | ErrorActions.ErrorThrownActionCreator > ): Promise => { try { @@ -789,7 +804,7 @@ interface AuthReducerState { } type SyncDashboardTempVarsFromURLQueryParamsDispatcher = ( dispatch: Dispatch< - ActionPublishNotification | TemplateVariableSelectedAction + PublishNotificationActionCreator | TemplateVariableSelectedAction >, getState: () => DashboardsReducerState & AuthReducerState ) => void @@ -798,7 +813,7 @@ const syncDashboardTempVarsFromURLQueryParams = ( urlQueryParams: URLQueryParams ): SyncDashboardTempVarsFromURLQueryParamsDispatcher => ( dispatch: Dispatch< - ActionPublishNotification | TemplateVariableSelectedAction + PublishNotificationActionCreator | TemplateVariableSelectedAction >, getState: () => DashboardsReducerState & AuthReducerState ): void => { @@ -838,7 +853,7 @@ interface DashTimeV1ReducerState { } type SyncDashboardTimeRangeFromURLQueryParamsDispatcher = ( - dispatch: Dispatch, + dispatch: Dispatch, getState: () => DashboardsReducerState & DashTimeV1ReducerState ) => void @@ -847,7 +862,7 @@ const syncDashboardTimeRangeFromURLQueryParams = ( urlQueryParams: URLQueryParams, location: Location ): SyncDashboardTimeRangeFromURLQueryParamsDispatcher => ( - dispatch: Dispatch, + dispatch: Dispatch, getState: () => DashboardsReducerState & DashTimeV1ReducerState ): void => { const { @@ -940,7 +955,7 @@ export type GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = ( ) => GetDashboardWithHydratedAndSyncedTempVarsAsyncActionCreator type GetDashboardWithHydratedAndSyncedTempVarsAsyncActionCreator = ( - dispatch: Dispatch + dispatch: Dispatch ) => Promise export const getDashboardWithHydratedAndSyncedTempVarsAsync = ( @@ -949,7 +964,7 @@ export const getDashboardWithHydratedAndSyncedTempVarsAsync = ( router: InjectedRouter, location: Location ): GetDashboardWithHydratedAndSyncedTempVarsAsyncActionCreator => async ( - dispatch: Dispatch + dispatch: Dispatch ): Promise => { const dashboard = await bindActionCreators(getDashboardAsync, dispatch)( dashboardID diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 3608ac6f2f..2cc6cc9c7e 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -112,7 +112,7 @@ interface Props { meRole: string isUsingAuth: boolean router: Router - notify: NotificationActions.ActionCreatorPublishNotification + notify: NotificationActions.PublishNotificationActionCreator getAnnotationsAsync: AnnotationActions.GetAnnotationsDispatcher handleShowCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator handleHideCellEditorOverlay: CellEditorOverlayActions.HideCellEditorOverlayActionCreator diff --git a/ui/src/shared/actions/annotations.ts b/ui/src/shared/actions/annotations.ts index 6a592d2a39..2bc474c5b6 100644 --- a/ui/src/shared/actions/annotations.ts +++ b/ui/src/shared/actions/annotations.ts @@ -22,7 +22,9 @@ export const editingAnnotation = (): EditingAnnotationAction => ({ type: 'EDITING_ANNOTATION', }) -export interface DismissEditingAnnotationAction { +export type DismissEditingAnnotationActionCreator = () => DismissEditingAnnotationAction + +interface DismissEditingAnnotationAction { type: 'DISMISS_EDITING_ANNOTATION' } export const dismissEditingAnnotation = (): DismissEditingAnnotationAction => ({ @@ -138,15 +140,16 @@ export interface AnnotationRange { since: number until: number } -type GetAnnotationsThunk = ( - dispatch: Dispatch -) => Promise export type GetAnnotationsDispatcher = ( indexUrl: string, annotationRange: AnnotationRange ) => GetAnnotationsThunk +type GetAnnotationsThunk = ( + dispatch: Dispatch +) => Promise + export const getAnnotationsAsync = ( indexUrl: string, {since, until}: AnnotationRange diff --git a/ui/src/shared/actions/app.ts b/ui/src/shared/actions/app.ts index e11d87fac4..e943ed9c52 100644 --- a/ui/src/shared/actions/app.ts +++ b/ui/src/shared/actions/app.ts @@ -6,7 +6,9 @@ import {notifyPresentationMode} from 'src/shared/copy/notifications' import {Dispatch} from 'redux' // ephemeral state action creators -export interface EnablePresentationModeAction { +export type EnablePresentationModeActionCreator = () => EnablePresentationModeAction + +interface EnablePresentationModeAction { type: 'ENABLE_PRESENTATION_MODE' } export const enablePresentationMode = (): EnablePresentationModeAction => ({ @@ -29,7 +31,11 @@ export const delayEnablePresentationMode = async ( }, PRESENTATION_MODE_ANIMATION_DELAY) // persistent state action creators -export interface SetAutoRefreshAction { +export type SetAutoRefreshActionCreator = ( + milliseconds: number +) => SetAutoRefreshAction + +interface SetAutoRefreshAction { type: 'SET_AUTOREFRESH' payload: { milliseconds: number @@ -42,7 +48,9 @@ export const setAutoRefresh = (milliseconds: number): SetAutoRefreshAction => ({ }, }) -export interface TemplateControlBarVisibilityToggledAction { +export type TemplateControlBarVisibilityToggledActionCreator = () => TemplateControlBarVisibilityToggledAction + +interface TemplateControlBarVisibilityToggledAction { type: 'TEMPLATE_CONTROL_BAR_VISIBILITY_TOGGLED' } export const templateControlBarVisibilityToggled = (): TemplateControlBarVisibilityToggledAction => ({ diff --git a/ui/src/shared/actions/errors.ts b/ui/src/shared/actions/errors.ts index 95c21aa81e..453ebbcd67 100644 --- a/ui/src/shared/actions/errors.ts +++ b/ui/src/shared/actions/errors.ts @@ -1,7 +1,14 @@ enum AlertType { 'info', } -export interface ErrorThrownAction { + +export type ErrorThrownActionCreator = ( + error: Error, + altText?: string, + alertType?: AlertType +) => ErrorThrownAction + +interface ErrorThrownAction { type: 'ERROR_THROWN' error: Error altText?: string diff --git a/ui/src/shared/actions/notifications.ts b/ui/src/shared/actions/notifications.ts index 9c8958f85a..c5c6729fee 100644 --- a/ui/src/shared/actions/notifications.ts +++ b/ui/src/shared/actions/notifications.ts @@ -1,19 +1,22 @@ import {Notification} from 'src/types' -export type Action = ActionPublishNotification | ActionDismissNotification +export type Action = PublishNotificationAction | ActionDismissNotification // Publish notification -export type PublishNotification = (n: Notification) => ActionPublishNotification -export interface ActionPublishNotification { +export type PublishNotificationActionCreator = ( + n: Notification +) => PublishNotificationAction + +export interface PublishNotificationAction { type: 'PUBLISH_NOTIFICATION' payload: { notification: Notification } } -export const notify = ( +export const notify: PublishNotificationActionCreator = ( notification: Notification -): ActionPublishNotification => ({ +): PublishNotificationAction => ({ type: 'PUBLISH_NOTIFICATION', payload: {notification}, }) diff --git a/ui/src/sources/containers/SourcePage.tsx b/ui/src/sources/containers/SourcePage.tsx index 602dbd80c7..6f2619960a 100644 --- a/ui/src/sources/containers/SourcePage.tsx +++ b/ui/src/sources/containers/SourcePage.tsx @@ -11,7 +11,7 @@ import { } from 'src/shared/actions/sources' import { notify as notifyAction, - PublishNotification, + PublishNotificationActionCreator, } from 'src/shared/actions/notifications' import {connect} from 'react-redux' @@ -34,7 +34,7 @@ import { import {ErrorHandling} from 'src/shared/decorators/errors' interface Props extends WithRouterProps { - notify: PublishNotification + notify: PublishNotificationActionCreator addSource: AddSource updateSource: UpdateSource } From 3b61fefefefef3cfae25b88fba3ed7dee9c3fd19 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Wed, 20 Jun 2018 16:28:13 -0700 Subject: [PATCH 11/49] Rename dashboards/apis/index.js to .ts --- ui/src/dashboards/apis/{index.js => index.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ui/src/dashboards/apis/{index.js => index.ts} (100%) diff --git a/ui/src/dashboards/apis/index.js b/ui/src/dashboards/apis/index.ts similarity index 100% rename from ui/src/dashboards/apis/index.js rename to ui/src/dashboards/apis/index.ts From bb938c0bf9ad7fceb5cd54528719aa5f942fbd3e Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Wed, 20 Jun 2018 17:42:43 -0700 Subject: [PATCH 12/49] Add & reorg types dirs and files for dashboard reducers, actions, & apis Continue typing DashboardPage. --- ui/src/dashboards/actions/index.ts | 372 ++++-------------- ui/src/dashboards/apis/index.ts | 13 +- .../components/CellEditorOverlay.tsx | 3 +- .../dashboards/components/DashboardHeader.tsx | 13 +- .../components/DashboardsPageContents.tsx | 4 +- .../dashboards/containers/DashboardPage.tsx | 65 ++- ui/src/shared/actions/app.ts | 10 +- ui/src/shared/components/AutoRefresh.tsx | 4 +- ui/src/shared/data/timeRanges.ts | 8 +- .../components/TemplateControlBar.tsx | 1 - ui/src/types/actions/dashboard.ts | 278 +++++++++++++ ui/src/types/apis/dashboard.ts | 5 + ui/src/types/query.ts | 9 + ui/src/types/reducers/dashboard.ts | 15 + ui/src/utils/ajax.ts | 2 +- 15 files changed, 446 insertions(+), 356 deletions(-) create mode 100644 ui/src/types/actions/dashboard.ts create mode 100644 ui/src/types/apis/dashboard.ts create mode 100644 ui/src/types/reducers/dashboard.ts diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index 810ab39277..76ce7bab47 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -53,9 +53,11 @@ import idNormalizer, {TYPE_ID} from 'src/normalizers/id' import {defaultTimeRange} from 'src/shared/data/timeRanges' +import {Dispatch} from 'redux' import {InjectedRouter} from 'react-router' import {Location} from 'history' -import {Dispatch} from 'redux' +import {AxiosResponse} from 'axios' +// import * as AllData from 'src/types' import { Cell, Dashboard, @@ -66,28 +68,18 @@ import { TimeRange, URLQueryParams, } from 'src/types' -import {CellType, DashboardName} from 'src/types/dashboard' -import {TimeRangeOption} from 'src/shared/data/timeRanges' +import * as DashboardData from 'src/types/dashboard' +import * as DashboardActions from 'src/types/actions/dashboard' +import * as DashboardAPIs from 'src/types/apis/dashboard' +import * as DashboardReducers from 'src/types/reducers/dashboard' import {PublishNotificationActionCreator} from 'src/shared/actions/notifications' import * as ErrorActions from 'src/shared/actions/errors' import {LocationAction} from 'react-router-redux' -export type LoadDashboardsActionCreator = ( +export const loadDashboards: DashboardActions.LoadDashboardsActionCreator = ( dashboards: Dashboard[], dashboardID?: number -) => LoadDashboardsAction - -interface LoadDashboardsAction { - type: 'LOAD_DASHBOARDS' - payload: { - dashboards: Dashboard[] - dashboardID: number - } -} -export const loadDashboards: LoadDashboardsActionCreator = ( - dashboards: Dashboard[], - dashboardID?: number -): LoadDashboardsAction => ({ +): DashboardActions.LoadDashboardsAction => ({ type: 'LOAD_DASHBOARDS', payload: { dashboards, @@ -95,30 +87,19 @@ export const loadDashboards: LoadDashboardsActionCreator = ( }, }) -interface LoadDashboardAction { - type: 'LOAD_DASHBOARD' - payload: { - dashboard: Dashboard - } -} -export const loadDashboard = (dashboard: Dashboard): LoadDashboardAction => ({ +export const loadDashboard = ( + dashboard: Dashboard +): DashboardActions.LoadDashboardAction => ({ type: 'LOAD_DASHBOARD', payload: { dashboard, }, }) -interface SetDashTimeV1Action { - type: 'SET_DASHBOARD_TIME_V1' - payload: { - dashboardID: number - timeRange: TimeRange - } -} export const setDashTimeV1 = ( dashboardID: number, timeRange: TimeRange -): SetDashTimeV1Action => ({ +): DashboardActions.SetDashTimeV1Action => ({ type: 'SET_DASHBOARD_TIME_V1', payload: { dashboardID, @@ -126,91 +107,52 @@ export const setDashTimeV1 = ( }, }) -interface RetainRangesDashTimeV1Action { - type: 'RETAIN_RANGES_DASHBOARD_TIME_V1' - payload: { - dashboardIDs: string[] - } -} export const retainRangesDashTimeV1 = ( dashboardIDs: string[] -): RetainRangesDashTimeV1Action => ({ +): DashboardActions.RetainRangesDashTimeV1Action => ({ type: 'RETAIN_RANGES_DASHBOARD_TIME_V1', payload: {dashboardIDs}, }) -export type SetTimeRangeActionCreator = ( +export const setTimeRange = ( timeRange: TimeRange -) => SetTimeRangeAction - -interface SetTimeRangeAction { - type: 'SET_DASHBOARD_TIME_RANGE' - payload: { - timeRange: TimeRange - } -} -export const setTimeRange = (timeRange: TimeRange): SetTimeRangeAction => ({ +): DashboardActions.SetTimeRangeAction => ({ type: 'SET_DASHBOARD_TIME_RANGE', payload: { timeRange, }, }) -interface SetZoomedTimeRangeAction { - type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE' - payload: { - zoomedTimeRange: TimeRange - } -} export const setZoomedTimeRange = ( zoomedTimeRange: TimeRange -): SetZoomedTimeRangeAction => ({ +): DashboardActions.SetZoomedTimeRangeAction => ({ type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE', payload: { zoomedTimeRange, }, }) -interface UpdateDashboardAction { - type: 'UPDATE_DASHBOARD' - payload: { - dashboard: Dashboard - } -} export const updateDashboard = ( dashboard: Dashboard -): UpdateDashboardAction => ({ +): DashboardActions.UpdateDashboardAction => ({ type: 'UPDATE_DASHBOARD', payload: { dashboard, }, }) -interface CreateDashboardAction { - type: 'CREATE_DASHBOARD' - payload: { - dashboard: Dashboard - } -} export const createDashboard = ( dashboard: Dashboard -): CreateDashboardAction => ({ +): DashboardActions.CreateDashboardAction => ({ type: 'CREATE_DASHBOARD', payload: { dashboard, }, }) -interface DeleteDashboardAction { - type: 'DELETE_DASHBOARD' - payload: { - dashboard: Dashboard - dashboardID: number - } -} export const deleteDashboard = ( dashboard: Dashboard -): DeleteDashboardAction => ({ +): DashboardActions.DeleteDashboardAction => ({ type: 'DELETE_DASHBOARD', payload: { dashboard, @@ -218,32 +160,19 @@ export const deleteDashboard = ( }, }) -interface DeleteDashboardFailedAction { - type: 'DELETE_DASHBOARD_FAILED' - payload: { - dashboard: Dashboard - } -} export const deleteDashboardFailed = ( dashboard: Dashboard -): DeleteDashboardFailedAction => ({ +): DashboardActions.DeleteDashboardFailedAction => ({ type: 'DELETE_DASHBOARD_FAILED', payload: { dashboard, }, }) -interface SyncDashboardCellAction { - type: 'SYNC_DASHBOARD_CELL' - payload: { - dashboard: Dashboard - cell: Cell - } -} export const syncDashboardCell = ( dashboard: Dashboard, cell: Cell -): SyncDashboardCellAction => ({ +): DashboardActions.SyncDashboardCellAction => ({ type: 'SYNC_DASHBOARD_CELL', payload: { dashboard, @@ -251,17 +180,10 @@ export const syncDashboardCell = ( }, }) -interface AddDashboardCellAction { - type: 'ADD_DASHBOARD_CELL' - payload: { - dashboard: Dashboard - cell: Cell - } -} export const addDashboardCell = ( dashboard: Dashboard, cell: Cell -): AddDashboardCellAction => ({ +): DashboardActions.AddDashboardCellAction => ({ type: 'ADD_DASHBOARD_CELL', payload: { dashboard, @@ -269,17 +191,10 @@ export const addDashboardCell = ( }, }) -interface DeleteDashboardCellAction { - type: 'DELETE_DASHBOARD_CELL' - payload: { - dashboard: Dashboard - cell: Cell - } -} export const deleteDashboardCell = ( dashboard: Dashboard, cell: Cell -): DeleteDashboardCellAction => ({ +): DashboardActions.DeleteDashboardCellAction => ({ type: 'DELETE_DASHBOARD_CELL', payload: { dashboard, @@ -287,17 +202,10 @@ export const deleteDashboardCell = ( }, }) -interface EditCellQueryStatusAction { - type: 'EDIT_CELL_QUERY_STATUS' - payload: { - queryID: string - status: string - } -} export const editCellQueryStatus = ( queryID: string, status: string -): EditCellQueryStatusAction => ({ +): DashboardActions.EditCellQueryStatusAction => ({ type: 'EDIT_CELL_QUERY_STATUS', payload: { queryID, @@ -305,19 +213,11 @@ export const editCellQueryStatus = ( }, }) -interface TemplateVariableSelectedAction { - type: 'TEMPLATE_VARIABLE_SELECTED' - payload: { - dashboardID: number - templateID: string - values: any[] - } -} export const templateVariableSelected = ( dashboardID: number, templateID: string, values -): TemplateVariableSelectedAction => ({ +): DashboardActions.TemplateVariableSelectedAction => ({ type: 'TEMPLATE_VARIABLE_SELECTED', payload: { dashboardID, @@ -326,17 +226,10 @@ export const templateVariableSelected = ( }, }) -interface TemplateVariablesSelectedByNameAction { - type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME' - payload: { - dashboardID: number - queryParams: URLQueryParams - } -} export const templateVariablesSelectedByName = ( dashboardID: number, queryParams: URLQueryParams -): TemplateVariablesSelectedByNameAction => ({ +): DashboardActions.TemplateVariablesSelectedByNameAction => ({ type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME', payload: { dashboardID, @@ -344,19 +237,11 @@ export const templateVariablesSelectedByName = ( }, }) -interface EditTemplateVariableValuesAction { - type: 'EDIT_TEMPLATE_VARIABLE_VALUES' - payload: { - dashboardID: number - templateID: string - values: any[] - } -} export const editTemplateVariableValues = ( dashboardID: number, templateID: string, values -): EditTemplateVariableValuesAction => ({ +): DashboardActions.EditTemplateVariableValuesAction => ({ type: 'EDIT_TEMPLATE_VARIABLE_VALUES', payload: { dashboardID, @@ -365,26 +250,18 @@ export const editTemplateVariableValues = ( }, }) -interface SetHoverTimeAction { - type: 'SET_HOVER_TIME' - payload: { - hoverTime: string - } -} -export const setHoverTime = (hoverTime: string): SetHoverTimeAction => ({ +export const setHoverTime = ( + hoverTime: string +): DashboardActions.SetHoverTimeAction => ({ type: 'SET_HOVER_TIME', payload: { hoverTime, }, }) -interface SetActiveCellAction { - type: 'SET_ACTIVE_CELL' - payload: { - activeCellID: string - } -} -export const setActiveCell = (activeCellID: string): SetActiveCellAction => ({ +export const setActiveCell = ( + activeCellID: string +): DashboardActions.SetActiveCellAction => ({ type: 'SET_ACTIVE_CELL', payload: { activeCellID, @@ -393,21 +270,18 @@ export const setActiveCell = (activeCellID: string): SetActiveCellAction => ({ // Async Action Creators -export type GetDashboardsDispatcher = () => GetDashboardsThunk - -type GetDashboardsThunk = ( - dispatch: Dispatch -) => Promise - -export const getDashboardsAsync = (): GetDashboardsThunk => async ( +export const getDashboardsAsync = (): DashboardActions.GetDashboardsThunk => async ( dispatch: Dispatch< - LoadDashboardsActionCreator | ErrorActions.ErrorThrownActionCreator + | DashboardActions.LoadDashboardsActionCreator + | ErrorActions.ErrorThrownActionCreator > ): Promise => { try { const { data: {dashboards}, - } = await getDashboardsAJAX() + } = (await getDashboardsAJAX()) as AxiosResponse< + DashboardAPIs.DashboardsResponse + > dispatch(loadDashboards(dashboards)) return dashboards } catch (error) { @@ -416,21 +290,13 @@ export const getDashboardsAsync = (): GetDashboardsThunk => async ( } } -export type GetDashboardsNamesDispatcher = ( - sourceID: string -) => GetDashboardsNamesThunk - -type GetDashboardsNamesThunk = ( - dispatch: Dispatch -) => Promise - // gets update-to-date names of dashboards, but does not dispatch action // in order to avoid duplicate and out-of-sync state problems in redux -export const getDashboardsNamesAsync = ( +export const getDashboardsNamesAsync: DashboardActions.GetDashboardsNamesDispatcher = ( sourceID: string -): GetDashboardsNamesThunk => async ( +): DashboardActions.GetDashboardsNamesThunk => async ( dispatch: Dispatch -): Promise => { +): Promise => { try { // TODO: change this from getDashboardsAJAX to getDashboardsNamesAJAX // to just get dashboard names (and links) as api view call when that @@ -438,7 +304,9 @@ export const getDashboardsNamesAsync = ( // dashboard for each const { data: {dashboards}, - } = await getDashboardsAJAX() + } = (await getDashboardsAJAX()) as AxiosResponse< + DashboardAPIs.DashboardsResponse + > const dashboardsNames = dashboards.map(({id, name}) => ({ id, name, @@ -491,17 +359,12 @@ const removeUnselectedTemplateValues = (dashboard: Dashboard): Template[] => { return templates } -export type PutDashboardDispatcher = (dashboard: Dashboard) => PutDashboardThunk - -type PutDashboardThunk = ( +export const putDashboard = ( + dashboard: Dashboard +): DashboardActions.PutDashboardThunk => async ( dispatch: Dispatch< - UpdateDashboardAction | ErrorActions.ErrorThrownActionCreator - > -) => Promise - -export const putDashboard = (dashboard: Dashboard): PutDashboardThunk => async ( - dispatch: Dispatch< - UpdateDashboardAction | ErrorActions.ErrorThrownActionCreator + | DashboardActions.UpdateDashboardAction + | ErrorActions.ErrorThrownActionCreator > ): Promise => { try { @@ -528,24 +391,11 @@ export const putDashboard = (dashboard: Dashboard): PutDashboardThunk => async ( } } -interface DashboardsReducerState { - dashboardUI: {dashboards: Dashboard[]} -} - -type PutDashboardByIDThunk = ( - dispatch: Dispatch, - getState: () => DashboardsReducerState -) => Promise - -export type PutDashboardByIDDispatcher = ( - dashboardID: number -) => PutDashboardByIDThunk - export const putDashboardByID = ( dashboardID: number -): PutDashboardByIDThunk => async ( +): DashboardActions.PutDashboardByIDThunk => async ( dispatch: Dispatch, - getState: () => DashboardsReducerState + getState: () => DashboardReducers.Dashboards ): Promise => { try { const { @@ -560,8 +410,14 @@ export const putDashboardByID = ( } } -export const updateDashboardCell = (dashboard: Dashboard, cell: Cell) => async ( - dispatch +export const updateDashboardCell: DashboardActions.UpdateDashboardCellDispatcher = ( + dashboard: Dashboard, + cell: Cell +): DashboardActions.UpdateDashboardCellThunk => async ( + dispatch: Dispatch< + | DashboardActions.SyncDashboardCellActionCreator + | ErrorActions.ErrorThrownActionCreator + > ): Promise => { try { const {data} = await updateDashboardCellAJAX(cell) @@ -590,25 +446,12 @@ export const deleteDashboardAsync = (dashboard: Dashboard) => async ( } } -export type AddDashboardCellDispatcher = ( - dashboard: Dashboard, - cellType: CellType -) => AddDashboardCellThunk - -type AddDashboardCellThunk = ( - dispatch: Dispatch< - | AddDashboardCellAction - | PublishNotificationActionCreator - | ErrorActions.ErrorThrownActionCreator - > -) => Promise - export const addDashboardCellAsync = ( dashboard: Dashboard, - cellType: CellType -): AddDashboardCellThunk => async ( + cellType: DashboardData.CellType +): DashboardActions.AddDashboardCellThunk => async ( dispatch: Dispatch< - | AddDashboardCellAction + | DashboardActions.AddDashboardCellAction | PublishNotificationActionCreator | ErrorActions.ErrorThrownActionCreator > @@ -681,7 +524,9 @@ export const importDashboardAsync = (dashboard: Dashboard) => async ( const { data: {dashboards}, - } = await getDashboardsAJAX() + } = (await getDashboardsAJAX()) as AxiosResponse< + DashboardAPIs.DashboardsResponse + > dispatch(loadDashboards(dashboards)) dispatch(notify(notifyDashboardImported(name))) @@ -730,21 +575,11 @@ export const hydrateTempVarValuesAsync = ( const removeNullValues = obj => _.pickBy(obj, o => o) -type SyncURLQueryFromQueryParamsObjectDispatcher = ( - location: Location, - updatedURLQueryParams: URLQueryParams, - deletedURLQueryParams: URLQueryParams -) => SyncURLQueryFromQueryParamsObjectActionCreator - -type SyncURLQueryFromQueryParamsObjectActionCreator = ( - dispatch: Dispatch -) => void - export const syncURLQueryParamsFromQueryParamsObject = ( location: Location, updatedURLQueryParams: URLQueryParams, deletedURLQueryParams: URLQueryParams = {} -): SyncURLQueryFromQueryParamsObjectActionCreator => ( +): DashboardActions.SyncURLQueryFromQueryParamsObjectActionCreator => ( dispatch: Dispatch ): void => { const updatedLocationQuery = removeNullValues({ @@ -767,20 +602,15 @@ export const syncURLQueryParamsFromQueryParamsObject = ( dispatch(replace(updatedLocation)) } -export type SyncURLQueryFromTempVarsDispatcher = ( - location: Location, - tempVars: Template[], - deletedTempVars: Template[], - urlQueryParamsTimeRanges: URLQueryParams -) => SyncURLQueryFromQueryParamsObjectActionCreator - export const syncURLQueryFromTempVars = ( location: Location, tempVars: Template[], deletedTempVars: Template[] = [], urlQueryParamsTimeRanges: URLQueryParams = {} -): SyncURLQueryFromQueryParamsObjectActionCreator => ( - dispatch: Dispatch +): DashboardActions.SyncURLQueryFromQueryParamsObjectActionCreator => ( + dispatch: Dispatch< + DashboardActions.SyncURLQueryFromQueryParamsObjectDispatcher + > ): void => { const updatedURLQueryParams = generateURLQueryParamsFromTempVars(tempVars) const deletedURLQueryParams = generateURLQueryParamsFromTempVars( @@ -799,23 +629,15 @@ export const syncURLQueryFromTempVars = ( )(dispatch) } -interface AuthReducerState { - auth: {isUsingAuth: boolean; me: Me} -} -type SyncDashboardTempVarsFromURLQueryParamsDispatcher = ( - dispatch: Dispatch< - PublishNotificationActionCreator | TemplateVariableSelectedAction - >, - getState: () => DashboardsReducerState & AuthReducerState -) => void const syncDashboardTempVarsFromURLQueryParams = ( dashboardID: number, urlQueryParams: URLQueryParams -): SyncDashboardTempVarsFromURLQueryParamsDispatcher => ( +): DashboardActions.SyncDashboardTempVarsFromURLQueryParamsDispatcher => ( dispatch: Dispatch< - PublishNotificationActionCreator | TemplateVariableSelectedAction + | PublishNotificationActionCreator + | DashboardActions.TemplateVariableSelectedAction >, - getState: () => DashboardsReducerState & AuthReducerState + getState: () => DashboardReducers.Dashboards & AuthReducerState ): void => { const { dashboardUI, @@ -846,24 +668,13 @@ const syncDashboardTempVarsFromURLQueryParams = ( dispatch(templateVariablesSelectedByName(dashboardID, urlQueryParams)) } -type DashTimeV1Range = TimeRangeOption & {dashboardID: number} - -interface DashTimeV1ReducerState { - dashTimeV1: {ranges: DashTimeV1Range[]} -} - -type SyncDashboardTimeRangeFromURLQueryParamsDispatcher = ( - dispatch: Dispatch, - getState: () => DashboardsReducerState & DashTimeV1ReducerState -) => void - const syncDashboardTimeRangeFromURLQueryParams = ( dashboardID: number, urlQueryParams: URLQueryParams, location: Location -): SyncDashboardTimeRangeFromURLQueryParamsDispatcher => ( +): DashboardActions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher => ( dispatch: Dispatch, - getState: () => DashboardsReducerState & DashTimeV1ReducerState + getState: () => DashboardReducers.Dashboards & DashboardReducers.DashTimeV1 ): void => { const { dashboardUI: {dashboards}, @@ -919,19 +730,13 @@ const syncDashboardTimeRangeFromURLQueryParams = ( )(dispatch) } -type SyncDashboardFromURLQueryParamsDispatcher = ( - dispatch: Dispatch< - | SyncDashboardTempVarsFromURLQueryParamsDispatcher - | SyncDashboardTimeRangeFromURLQueryParamsDispatcher - > -) => void const syncDashboardFromURLQueryParams = ( dashboardID: number, location: Location -): SyncDashboardFromURLQueryParamsDispatcher => ( +): DashboardActions.SyncDashboardFromURLQueryParamsDispatcher => ( dispatch: Dispatch< - | SyncDashboardTempVarsFromURLQueryParamsDispatcher - | SyncDashboardTimeRangeFromURLQueryParamsDispatcher + | DashboardActions.SyncDashboardTempVarsFromURLQueryParamsDispatcher + | DashboardActions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher > ): void => { const urlQueryParams = queryString.parse(window.location.search) @@ -947,23 +752,12 @@ const syncDashboardFromURLQueryParams = ( ) } -export type GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = ( - dashboardID: string, - source: Source, - router: InjectedRouter, - location: Location -) => GetDashboardWithHydratedAndSyncedTempVarsAsyncActionCreator - -type GetDashboardWithHydratedAndSyncedTempVarsAsyncActionCreator = ( - dispatch: Dispatch -) => Promise - -export const getDashboardWithHydratedAndSyncedTempVarsAsync = ( +export const getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = ( dashboardID: number, source: Source, router: InjectedRouter, location: Location -): GetDashboardWithHydratedAndSyncedTempVarsAsyncActionCreator => async ( +): DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk => async ( dispatch: Dispatch ): Promise => { const dashboard = await bindActionCreators(getDashboardAsync, dispatch)( diff --git a/ui/src/dashboards/apis/index.ts b/ui/src/dashboards/apis/index.ts index ff04e841a1..918a1efe86 100644 --- a/ui/src/dashboards/apis/index.ts +++ b/ui/src/dashboards/apis/index.ts @@ -1,6 +1,11 @@ -import AJAX from 'utils/ajax' +import AJAX from 'src/utils/ajax' -export function getDashboards() { +import {AxiosResponse} from 'axios' +import {DashboardsResponse} from 'src/types/apis/dashboard' + +export const getDashboards = (): Promise< + AxiosResponse | DashboardsResponse +> => { return AJAX({ method: 'GET', resource: 'dashboards', @@ -19,7 +24,7 @@ export const getDashboard = async dashboardID => { } } -export function updateDashboard(dashboard) { +export const updateDashboard = dashboard => { return AJAX({ method: 'PUT', url: dashboard.links.self, @@ -27,7 +32,7 @@ export function updateDashboard(dashboard) { }) } -export function updateDashboardCell(cell) { +export const updateDashboardCell = cell => { return AJAX({ method: 'PUT', url: cell.links.self, diff --git a/ui/src/dashboards/components/CellEditorOverlay.tsx b/ui/src/dashboards/components/CellEditorOverlay.tsx index 6520416685..2ffe0e262f 100644 --- a/ui/src/dashboards/components/CellEditorOverlay.tsx +++ b/ui/src/dashboards/components/CellEditorOverlay.tsx @@ -42,6 +42,7 @@ import { Status, } from 'src/types' import {ColorString, ColorNumber} from 'src/types/colors' +import * as DashboardActions from 'src/dashboards/actions' import {SourceOption} from 'src/dashboards/components/OverlayControls' type QueryTransitions = typeof queryTransitions @@ -74,7 +75,7 @@ interface QueryStatus { interface Props { sources: Source[] - editQueryStatus: () => void + editQueryStatus: DashboardActions.EditCellQueryStatusActionCreator onCancel: () => void onSave: (cell: Cell) => void source: Source diff --git a/ui/src/dashboards/components/DashboardHeader.tsx b/ui/src/dashboards/components/DashboardHeader.tsx index 2f06e2dc0e..d14c3961bf 100644 --- a/ui/src/dashboards/components/DashboardHeader.tsx +++ b/ui/src/dashboards/components/DashboardHeader.tsx @@ -10,11 +10,10 @@ import TimeRangeDropdown from 'src/shared/components/TimeRangeDropdown' import GraphTips from 'src/shared/components/GraphTips' import DashboardHeaderEdit from 'src/dashboards/components/DashboardHeaderEdit' import DashboardSwitcher from 'src/dashboards/components/DashboardSwitcher' -import {Dashboard, TimeRange} from 'src/types' -interface DashboardName { - text: string -} +import {Dashboard, TimeRange} from 'src/types' +import {DashboardName} from 'src/types/dashboard' +import * as AppActions from 'src/shared/actions/app' interface Props { activeDashboard: string @@ -24,15 +23,15 @@ interface Props { autoRefresh: number isEditMode?: boolean handleChooseTimeRange: (timeRange: TimeRange) => void - handleChooseAutoRefresh: () => void + handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator onManualRefresh: () => void - handleClickPresentationButton: () => void + handleClickPresentationButton: AppActions.DelayEnablePresentationModeThunk onAddCell: () => void onToggleTempVarControls: () => void showTemplateControlBar: boolean zoomedTimeRange: TimeRange onCancel: () => void - onSave: () => void + onSave: (name: string) => Promise names: DashboardName[] isHidden: boolean } diff --git a/ui/src/dashboards/components/DashboardsPageContents.tsx b/ui/src/dashboards/components/DashboardsPageContents.tsx index 780a3dea8a..a8c1fbbb00 100644 --- a/ui/src/dashboards/components/DashboardsPageContents.tsx +++ b/ui/src/dashboards/components/DashboardsPageContents.tsx @@ -10,7 +10,7 @@ import FancyScrollbar from 'src/shared/components/FancyScrollbar' import {ErrorHandling} from 'src/shared/decorators/errors' import { showOverlay as showOverlayAction, - ShowOverlay, + ShowOverlayActionCreator, } from 'src/shared/actions/overlayTechnology' import {OverlayContext} from 'src/shared/components/OverlayTechnology' @@ -27,7 +27,7 @@ interface Props { onExportDashboard: (dashboard: Dashboard) => () => void onImportDashboard: (dashboard: Dashboard) => void notify: (message: Notification) => void - showOverlay: ShowOverlay + showOverlay: ShowOverlayActionCreator dashboardLink: string } diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 2cc6cc9c7e..1f268969ad 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -49,14 +49,8 @@ import {ErrorHandling} from 'src/shared/decorators/errors' import {getDeep} from 'src/utils/wrappers' import {Location} from 'history' -import {Dispatch} from 'redux' -import { - Cell, - CellType, - Dashboard as IDashboard, - Source, - TimeRange, -} from 'src/types' +import {InjectedRouter} from 'react-router' +import {Cell, Dashboard as IDashboard, Source, TimeRange} from 'src/types' import {DashboardName} from 'src/types/dashboard' import {ColorNumber, ColorString} from 'src/types/colors' import * as AnnotationActions from 'src/shared/actions/annotations' @@ -74,9 +68,8 @@ interface DashboardActions { getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher setTimeRange: DashboardActions.SetTimeRangeActionCreator addDashboardCellAsync: DashboardActions.AddDashboardCellDispatcher -} -interface Router { - push: (path: string) => void + editCellQueryStatus: DashboardActions.EditCellQueryStatusActionCreator + updateDashboardCell: DashboardActions.UpdateDashboardCellDispatcher } interface Props { @@ -87,21 +80,18 @@ interface Props { dashboardID: string } location: Location + dashboardID: number dashboard: IDashboard dashboardActions: DashboardActions dashboards: IDashboard[] - handleChooseAutoRefresh: ( - milliseconds: number - ) => AppActions.SetAutoRefreshActionCreator + handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator autoRefresh: number templateControlBarVisibilityToggled: () => AppActions.TemplateControlBarVisibilityToggledActionCreator timeRange: TimeRange zoomedTimeRange: TimeRange showTemplateControlBar: boolean inPresentationMode: boolean - handleClickPresentationButton: ( - dispatch: Dispatch - ) => Promise + handleClickPresentationButton: AppActions.DelayEnablePresentationModeThunk cellQueryStatus: { queryID: string status: object @@ -111,7 +101,7 @@ interface Props { onManualRefresh: () => void meRole: string isUsingAuth: boolean - router: Router + router: InjectedRouter notify: NotificationActions.PublishNotificationActionCreator getAnnotationsAsync: AnnotationActions.GetAnnotationsDispatcher handleShowCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator @@ -135,7 +125,9 @@ interface State { @ErrorHandling class DashboardPage extends Component { - constructor(props) { + private intervalID: number + + public constructor(props: Props) { super(props) this.state = { @@ -149,7 +141,7 @@ class DashboardPage extends Component { public async componentDidMount() { const { - params: {dashboardID}, + dashboardID, dashboardActions: {putDashboardByID}, source, meRole, @@ -163,7 +155,7 @@ class DashboardPage extends Component { getAnnotationsAsync(source.links.annotations, annotationRange) if (autoRefresh) { - this.intervalID = setInterval(() => { + this.intervalID = window.setInterval(() => { getAnnotationsAsync(source.links.annotations, annotationRange) }, autoRefresh) } @@ -188,7 +180,7 @@ class DashboardPage extends Component { clearInterval(this.intervalID) const annotationRange = millisecondTimeRange(timeRange) if (nextProps.autoRefresh) { - this.intervalID = setInterval(() => { + this.intervalID = window.setInterval(() => { getAnnotationsAsync(source.links.annotations, annotationRange) }, nextProps.autoRefresh) } @@ -206,7 +198,6 @@ class DashboardPage extends Component { public componentWillUnmount() { clearInterval(this.intervalID) - this.intervalID = false window.removeEventListener('resize', this.handleWindowResize, true) this.props.handleDismissEditingAnnotation() } @@ -224,6 +215,7 @@ class DashboardPage extends Component { showTemplateControlBar, dashboard, dashboards, + dashboardID, lineColors, gaugeColors, autoRefresh, @@ -239,7 +231,7 @@ class DashboardPage extends Component { handleShowCellEditorOverlay, handleHideCellEditorOverlay, handleClickPresentationButton, - params: {sourceID, dashboardID}, + params: {sourceID}, } = this.props const {dashboardsNames} = this.state @@ -311,9 +303,7 @@ class DashboardPage extends Component { ) : null} { autoRefresh={autoRefresh} manualRefresh={manualRefresh} onZoom={this.handleZoomedTimeRange} - onAddCell={this.handleAddCell} inPresentationMode={inPresentationMode} onPositionChange={this.handleUpdatePosition} - onSelectTemplate={this.handleSelectTemplate} onDeleteCell={this.handleDeleteDashboardCell} onCloneCell={this.handleCloneCell} - showTemplateControlBar={showTemplateControlBar} templatesIncludingDashTime={templatesIncludingDashTime} onSummonOverlayTechnologies={handleShowCellEditorOverlay} /> @@ -368,13 +355,15 @@ class DashboardPage extends Component { ) } - private handleWindowResize = () => { + private handleWindowResize = (): void => { this.setState({windowHeight: window.innerHeight}) } - private async getDashboard() { + private async getDashboard(): Promise< + DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk + > { const { - params: {dashboardID}, + dashboardID, dashboardActions: {getDashboardWithHydratedAndSyncedTempVarsAsync}, source, router, @@ -389,7 +378,7 @@ class DashboardPage extends Component { ) } - private async getDashboardsNames() { + private async getDashboardsNames(): Promise { const { params: {sourceID}, dashboardActions: {getDashboardsNamesAsync}, @@ -477,7 +466,7 @@ class DashboardPage extends Component { this.setState({isEditMode: false}) } - private handleRenameDashboard = async name => { + private handleRenameDashboard = async (name: string): Promise => { const {dashboardActions, dashboard} = this.props this.setState({isEditMode: false}) const newDashboard = {...dashboard, name} @@ -498,12 +487,7 @@ class DashboardPage extends Component { } private handleSelectTemplate = templateID => value => { - const { - dashboardActions, - dashboard, - params: {dashboardID}, - location, - } = this.props + const {dashboardActions, dashboard, dashboardID, location} = this.props const currentTempVar = dashboard.templates.find( tempVar => tempVar.id === templateID @@ -602,6 +586,7 @@ const mstp = (state, {params: {dashboardID}}) => { sources, meRole, dashboard, + dashboardID: Number(dashboardID), timeRange, zoomedTimeRange, dashboards, diff --git a/ui/src/shared/actions/app.ts b/ui/src/shared/actions/app.ts index e943ed9c52..e075b48216 100644 --- a/ui/src/shared/actions/app.ts +++ b/ui/src/shared/actions/app.ts @@ -22,7 +22,11 @@ export const disablePresentationMode = (): DisablePresentationModeAction => ({ type: 'DISABLE_PRESENTATION_MODE', }) -export const delayEnablePresentationMode = async ( +export type DelayEnablePresentationModeThunk = ( + dispatch: Dispatch +) => Promise + +export const delayEnablePresentationMode: DelayEnablePresentationModeThunk = async ( dispatch: Dispatch ): Promise => setTimeout(() => { @@ -41,7 +45,9 @@ interface SetAutoRefreshAction { milliseconds: number } } -export const setAutoRefresh = (milliseconds: number): SetAutoRefreshAction => ({ +export const setAutoRefresh: SetAutoRefreshActionCreator = ( + milliseconds: number +): SetAutoRefreshAction => ({ type: 'SET_AUTOREFRESH', payload: { milliseconds, diff --git a/ui/src/shared/components/AutoRefresh.tsx b/ui/src/shared/components/AutoRefresh.tsx index beccf8c2a3..0f639bc4f7 100644 --- a/ui/src/shared/components/AutoRefresh.tsx +++ b/ui/src/shared/components/AutoRefresh.tsx @@ -56,7 +56,7 @@ const AutoRefresh = ( inView: true, } - private intervalID: NodeJS.Timer | null + private intervalID: number constructor(props: Props) { super(props) @@ -199,7 +199,7 @@ const AutoRefresh = ( this.executeQueries() if (autoRefresh) { - this.intervalID = setInterval(this.executeQueries, autoRefresh) + this.intervalID = window.setInterval(this.executeQueries, autoRefresh) } } diff --git a/ui/src/shared/data/timeRanges.ts b/ui/src/shared/data/timeRanges.ts index fd1563e22a..dd46291e7b 100644 --- a/ui/src/shared/data/timeRanges.ts +++ b/ui/src/shared/data/timeRanges.ts @@ -1,10 +1,4 @@ -import {TimeRange} from 'src/types/query' -export interface TimeRangeOption extends TimeRange { - defaultGroupBy: string - seconds: number - inputValue: string - menuOption: string -} +import {TimeRangeOption} from 'src/types/dashboard' const nowMinus30d = 'now() - 30d' diff --git a/ui/src/tempVars/components/TemplateControlBar.tsx b/ui/src/tempVars/components/TemplateControlBar.tsx index d13fb80b98..b89f125823 100644 --- a/ui/src/tempVars/components/TemplateControlBar.tsx +++ b/ui/src/tempVars/components/TemplateControlBar.tsx @@ -16,7 +16,6 @@ interface Props { source: Source onSelectTemplate: (id: string) => void onSaveTemplates: (templates: Template[]) => void - onCreateTemplateVariable: () => void } interface State { diff --git a/ui/src/types/actions/dashboard.ts b/ui/src/types/actions/dashboard.ts new file mode 100644 index 0000000000..28aee59e71 --- /dev/null +++ b/ui/src/types/actions/dashboard.ts @@ -0,0 +1,278 @@ +import {Dispatch} from 'redux' +import {InjectedRouter} from 'react-router' +import {LocationAction} from 'react-router-redux' +import {Source} from 'src/types' +import * as DashboardData from 'src/types/dashboard' +import * as QueryData from 'src/types/query' +import * as TempVarData from 'src/types/tempVars' +import * as ErrorActions from 'src/shared/actions/errors' +import * as NotificationActions from 'src/shared/actions/notifications' +import * as DashboardReducers from 'src/types/reducers/dashboard' + +export type LoadDashboardsActionCreator = ( + dashboards: DashboardData.Dashboard[], + dashboardID?: number +) => LoadDashboardsAction + +export interface LoadDashboardsAction { + type: 'LOAD_DASHBOARDS' + payload: { + dashboards: DashboardData.Dashboard[] + dashboardID: number + } +} + +export interface LoadDashboardAction { + type: 'LOAD_DASHBOARD' + payload: { + dashboard: DashboardData.Dashboard + } +} + +export interface SetDashTimeV1Action { + type: 'SET_DASHBOARD_TIME_V1' + payload: { + dashboardID: number + timeRange: QueryData.TimeRange + } +} + +export interface RetainRangesDashTimeV1Action { + type: 'RETAIN_RANGES_DASHBOARD_TIME_V1' + payload: { + dashboardIDs: string[] + } +} + +export type SetTimeRangeActionCreator = ( + timeRange: QueryData.TimeRange +) => SetTimeRangeAction + +export interface SetTimeRangeAction { + type: 'SET_DASHBOARD_TIME_RANGE' + payload: { + timeRange: QueryData.TimeRange + } +} + +export interface SetZoomedTimeRangeAction { + type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE' + payload: { + zoomedTimeRange: QueryData.TimeRange + } +} + +export interface UpdateDashboardAction { + type: 'UPDATE_DASHBOARD' + payload: { + dashboard: DashboardData.Dashboard + } +} + +export interface CreateDashboardAction { + type: 'CREATE_DASHBOARD' + payload: { + dashboard: DashboardData.Dashboard + } +} + +export interface DeleteDashboardAction { + type: 'DELETE_DASHBOARD' + payload: { + dashboard: DashboardData.Dashboard + dashboardID: number + } +} + +export interface DeleteDashboardFailedAction { + type: 'DELETE_DASHBOARD_FAILED' + payload: { + dashboard: DashboardData.Dashboard + } +} + +export type SyncDashboardCellActionCreator = ( + dashboard: DashboardData.Dashboard, + cell: DashboardData.Cell +) => SyncDashboardCellAction + +export interface SyncDashboardCellAction { + type: 'SYNC_DASHBOARD_CELL' + payload: { + dashboard: DashboardData.Dashboard + cell: DashboardData.Cell + } +} + +export interface AddDashboardCellAction { + type: 'ADD_DASHBOARD_CELL' + payload: { + dashboard: DashboardData.Dashboard + cell: DashboardData.Cell + } +} +export interface DeleteDashboardCellAction { + type: 'DELETE_DASHBOARD_CELL' + payload: { + dashboard: DashboardData.Dashboard + cell: DashboardData.Cell + } +} + +export type EditCellQueryStatusActionCreator = ( + queryID: string, + status: string +) => EditCellQueryStatusAction + +export interface EditCellQueryStatusAction { + type: 'EDIT_CELL_QUERY_STATUS' + payload: { + queryID: string + status: string + } +} + +export interface TemplateVariableSelectedAction { + type: 'TEMPLATE_VARIABLE_SELECTED' + payload: { + dashboardID: number + templateID: string + values: any[] + } +} + +export interface TemplateVariablesSelectedByNameAction { + type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME' + payload: { + dashboardID: number + queryParams: TempVarData.URLQueryParams + } +} + +export interface EditTemplateVariableValuesAction { + type: 'EDIT_TEMPLATE_VARIABLE_VALUES' + payload: { + dashboardID: number + templateID: string + values: any[] + } +} + +export interface SetHoverTimeAction { + type: 'SET_HOVER_TIME' + payload: { + hoverTime: string + } +} + +export interface SetActiveCellAction { + type: 'SET_ACTIVE_CELL' + payload: { + activeCellID: string + } +} + +export type GetDashboardsDispatcher = () => GetDashboardsThunk + +export type GetDashboardsThunk = ( + dispatch: Dispatch +) => Promise + +export type GetDashboardsNamesDispatcher = ( + sourceID: string +) => GetDashboardsNamesThunk + +export type GetDashboardsNamesThunk = ( + dispatch: Dispatch +) => Promise + +export type PutDashboardDispatcher = ( + dashboard: DashboardData.Dashboard +) => PutDashboardThunk + +export type PutDashboardThunk = ( + dispatch: Dispatch< + UpdateDashboardAction | ErrorActions.ErrorThrownActionCreator + > +) => Promise + +export type PutDashboardByIDThunk = ( + dispatch: Dispatch, + getState: () => DashboardReducers.Dashboards +) => Promise + +export type PutDashboardByIDDispatcher = ( + dashboardID: number +) => PutDashboardByIDThunk + +export type UpdateDashboardCellDispatcher = ( + dashboard: DashboardData.Dashboard, + cell: DashboardData.Cell +) => UpdateDashboardCellThunk + +export type UpdateDashboardCellThunk = ( + dispatch: Dispatch< + SyncDashboardCellActionCreator | ErrorActions.ErrorThrownActionCreator + > +) => Promise + +export type AddDashboardCellDispatcher = ( + dashboard: DashboardData.Dashboard, + cellType: DashboardData.CellType +) => AddDashboardCellThunk + +export type AddDashboardCellThunk = ( + dispatch: Dispatch< + | AddDashboardCellAction + | NotificationActions.PublishNotificationActionCreator + | ErrorActions.ErrorThrownActionCreator + > +) => Promise + +export type SyncURLQueryFromQueryParamsObjectDispatcher = ( + location: Location, + updatedURLQueryParams: TempVarData.URLQueryParams, + deletedURLQueryParams: TempVarData.URLQueryParams +) => SyncURLQueryFromQueryParamsObjectActionCreator + +export type SyncURLQueryFromQueryParamsObjectActionCreator = ( + dispatch: Dispatch +) => void + +export type SyncURLQueryFromTempVarsDispatcher = ( + location: Location, + tempVars: TempVarData.Template[], + deletedTempVars: TempVarData.Template[], + urlQueryParamsTimeRanges: TempVarData.URLQueryParams +) => SyncURLQueryFromQueryParamsObjectActionCreator + +export type SyncDashboardTempVarsFromURLQueryParamsDispatcher = ( + dispatch: Dispatch< + | NotificationActions.PublishNotificationActionCreator + | TemplateVariableSelectedAction + >, + getState: () => DashboardReducers.Dashboards & DashboardReducers.Auth +) => void + +export type SyncDashboardTimeRangeFromURLQueryParamsDispatcher = ( + dispatch: Dispatch, + getState: () => DashboardReducers.Dashboards & DashboardReducers.DashTimeV1 +) => void + +export type SyncDashboardFromURLQueryParamsDispatcher = ( + dispatch: Dispatch< + | SyncDashboardTempVarsFromURLQueryParamsDispatcher + | SyncDashboardTimeRangeFromURLQueryParamsDispatcher + > +) => void + +export type GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = ( + dashboardID: number, + source: Source, + router: InjectedRouter, + location: Location +) => GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk + +export type GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk = ( + dispatch: Dispatch +) => Promise diff --git a/ui/src/types/apis/dashboard.ts b/ui/src/types/apis/dashboard.ts new file mode 100644 index 0000000000..07d7b7debc --- /dev/null +++ b/ui/src/types/apis/dashboard.ts @@ -0,0 +1,5 @@ +import {Dashboard} from 'src/types/dashboard' + +export interface DashboardsResponse { + dashboards: Dashboard[] +} diff --git a/ui/src/types/query.ts b/ui/src/types/query.ts index df3590cf55..88a89d0c6c 100644 --- a/ui/src/types/query.ts +++ b/ui/src/types/query.ts @@ -99,3 +99,12 @@ export interface TimeShift { unit: string quantity: string } + +export interface TimeRangeOption extends TimeRange { + defaultGroupBy: string + seconds: number + inputValue: string + menuOption: string +} + +export type DashTimeV1Range = TimeRangeOption & {dashboardID: number} diff --git a/ui/src/types/reducers/dashboard.ts b/ui/src/types/reducers/dashboard.ts new file mode 100644 index 0000000000..0d1746dc3a --- /dev/null +++ b/ui/src/types/reducers/dashboard.ts @@ -0,0 +1,15 @@ +import {Dashboard} from 'src/types' +import {Me} from 'src/types/auth' +import {DashTimeV1Range} from 'src/types/query' + +export interface Dashboards { + dashboardUI: {dashboards: Dashboard[]} +} + +export interface Auth { + auth: {isUsingAuth: boolean; me: Me} +} + +export interface DashTimeV1 { + dashTimeV1: {ranges: DashTimeV1Range[]} +} diff --git a/ui/src/utils/ajax.ts b/ui/src/utils/ajax.ts index df98a7e0f4..37d178fcd8 100644 --- a/ui/src/utils/ajax.ts +++ b/ui/src/utils/ajax.ts @@ -72,7 +72,7 @@ function generateResponseWithLinks( } interface RequestParams { - url: string | string[] + url?: string | string[] resource?: string | null id?: string | null method?: string From 2ab002c280b7c4acbefa6db10be3d3642178ab9c Mon Sep 17 00:00:00 2001 From: Delmer Reed Date: Thu, 21 Jun 2018 18:17:11 -0400 Subject: [PATCH 13/49] Fix types for presentation mode dispatcher Cleaned up dashboard types and introduced the auth reducers types. Co-authored-by: Jared Scheib --- ui/src/dashboards/actions/index.ts | 40 +++++++++---------- .../components/CellEditorOverlay.tsx | 2 +- .../dashboards/components/DashboardHeader.tsx | 8 ++-- .../dashboards/containers/DashboardPage.tsx | 11 +++-- ui/src/shared/actions/annotations.ts | 6 ++- ui/src/shared/actions/app.ts | 3 +- ui/src/types/actions/dashboard.ts | 37 ++++++++++++----- ui/src/types/reducers/auth.ts | 8 ++++ ui/test/shared/reducers/app.test.js | 1 - 9 files changed, 73 insertions(+), 43 deletions(-) create mode 100644 ui/src/types/reducers/auth.ts diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index 76ce7bab47..fd39fee12b 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -61,7 +61,6 @@ import {AxiosResponse} from 'axios' import { Cell, Dashboard, - Me, Source, Template, TemplateType, @@ -72,6 +71,7 @@ import * as DashboardData from 'src/types/dashboard' import * as DashboardActions from 'src/types/actions/dashboard' import * as DashboardAPIs from 'src/types/apis/dashboard' import * as DashboardReducers from 'src/types/reducers/dashboard' +import * as AuthReducers from 'src/types/reducers/auth' import {PublishNotificationActionCreator} from 'src/shared/actions/notifications' import * as ErrorActions from 'src/shared/actions/errors' import {LocationAction} from 'react-router-redux' @@ -96,7 +96,7 @@ export const loadDashboard = ( }, }) -export const setDashTimeV1 = ( +export const setDashTimeV1: DashboardActions.SetDashTimeV1ActionCreator = ( dashboardID: number, timeRange: TimeRange ): DashboardActions.SetDashTimeV1Action => ({ @@ -107,14 +107,14 @@ export const setDashTimeV1 = ( }, }) -export const retainRangesDashTimeV1 = ( +export const retainRangesDashTimeV1: DashboardActions.RetainRangesDashTimeV1ActionCreator = ( dashboardIDs: string[] ): DashboardActions.RetainRangesDashTimeV1Action => ({ type: 'RETAIN_RANGES_DASHBOARD_TIME_V1', payload: {dashboardIDs}, }) -export const setTimeRange = ( +export const setTimeRange: DashboardActions.SetTimeRangeActionCreator = ( timeRange: TimeRange ): DashboardActions.SetTimeRangeAction => ({ type: 'SET_DASHBOARD_TIME_RANGE', @@ -123,7 +123,7 @@ export const setTimeRange = ( }, }) -export const setZoomedTimeRange = ( +export const setZoomedTimeRange: DashboardActions.SetZoomedTimeRangeActionCreator = ( zoomedTimeRange: TimeRange ): DashboardActions.SetZoomedTimeRangeAction => ({ type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE', @@ -132,7 +132,7 @@ export const setZoomedTimeRange = ( }, }) -export const updateDashboard = ( +export const updateDashboard: DashboardActions.UpdateDashboardActionCreator = ( dashboard: Dashboard ): DashboardActions.UpdateDashboardAction => ({ type: 'UPDATE_DASHBOARD', @@ -141,7 +141,7 @@ export const updateDashboard = ( }, }) -export const createDashboard = ( +export const createDashboard: DashboardActions.CreateDashboardActionCreator = ( dashboard: Dashboard ): DashboardActions.CreateDashboardAction => ({ type: 'CREATE_DASHBOARD', @@ -150,7 +150,7 @@ export const createDashboard = ( }, }) -export const deleteDashboard = ( +export const deleteDashboard: DashboardActions.DeleteDashboardActionCreator = ( dashboard: Dashboard ): DashboardActions.DeleteDashboardAction => ({ type: 'DELETE_DASHBOARD', @@ -160,7 +160,7 @@ export const deleteDashboard = ( }, }) -export const deleteDashboardFailed = ( +export const deleteDashboardFailed: DashboardActions.DeleteDashboardFailedActionCreator = ( dashboard: Dashboard ): DashboardActions.DeleteDashboardFailedAction => ({ type: 'DELETE_DASHBOARD_FAILED', @@ -169,7 +169,7 @@ export const deleteDashboardFailed = ( }, }) -export const syncDashboardCell = ( +export const syncDashboardCell: DashboardActions.SyncDashboardCellActionCreator = ( dashboard: Dashboard, cell: Cell ): DashboardActions.SyncDashboardCellAction => ({ @@ -180,7 +180,7 @@ export const syncDashboardCell = ( }, }) -export const addDashboardCell = ( +export const addDashboardCell: DashboardActions.AddDashboardCellActionCreator = ( dashboard: Dashboard, cell: Cell ): DashboardActions.AddDashboardCellAction => ({ @@ -191,7 +191,7 @@ export const addDashboardCell = ( }, }) -export const deleteDashboardCell = ( +export const deleteDashboardCell: DashboardActions.DeleteDashboardCellActionCreator = ( dashboard: Dashboard, cell: Cell ): DashboardActions.DeleteDashboardCellAction => ({ @@ -202,7 +202,7 @@ export const deleteDashboardCell = ( }, }) -export const editCellQueryStatus = ( +export const editCellQueryStatus: DashboardActions.EditCellQueryStatusActionCreator = ( queryID: string, status: string ): DashboardActions.EditCellQueryStatusAction => ({ @@ -213,7 +213,7 @@ export const editCellQueryStatus = ( }, }) -export const templateVariableSelected = ( +export const templateVariableSelected: DashboardActions.TemplateVariableSelectedActionCreator = ( dashboardID: number, templateID: string, values @@ -226,7 +226,7 @@ export const templateVariableSelected = ( }, }) -export const templateVariablesSelectedByName = ( +export const templateVariablesSelectedByName: DashboardActions.TemplateVariablesSelectedByNameActionCreator = ( dashboardID: number, queryParams: URLQueryParams ): DashboardActions.TemplateVariablesSelectedByNameAction => ({ @@ -237,7 +237,7 @@ export const templateVariablesSelectedByName = ( }, }) -export const editTemplateVariableValues = ( +export const editTemplateVariableValues: DashboardActions.EditTemplateVariableValuesActionCreator = ( dashboardID: number, templateID: string, values @@ -250,7 +250,7 @@ export const editTemplateVariableValues = ( }, }) -export const setHoverTime = ( +export const setHoverTime: DashboardActions.SetHoverTimeActionCreator = ( hoverTime: string ): DashboardActions.SetHoverTimeAction => ({ type: 'SET_HOVER_TIME', @@ -259,7 +259,7 @@ export const setHoverTime = ( }, }) -export const setActiveCell = ( +export const setActiveCell: DashboardActions.SetActiveCellActionCreator = ( activeCellID: string ): DashboardActions.SetActiveCellAction => ({ type: 'SET_ACTIVE_CELL', @@ -270,7 +270,7 @@ export const setActiveCell = ( // Async Action Creators -export const getDashboardsAsync = (): DashboardActions.GetDashboardsThunk => async ( +export const getDashboardsAsync: DashboardActions.GetDashboardsDispatcher = (): DashboardActions.GetDashboardsThunk => async ( dispatch: Dispatch< | DashboardActions.LoadDashboardsActionCreator | ErrorActions.ErrorThrownActionCreator @@ -637,7 +637,7 @@ const syncDashboardTempVarsFromURLQueryParams = ( | PublishNotificationActionCreator | DashboardActions.TemplateVariableSelectedAction >, - getState: () => DashboardReducers.Dashboards & AuthReducerState + getState: () => DashboardReducers.Dashboards & AuthReducers.Auth ): void => { const { dashboardUI, diff --git a/ui/src/dashboards/components/CellEditorOverlay.tsx b/ui/src/dashboards/components/CellEditorOverlay.tsx index 2ffe0e262f..3c77bcf0f0 100644 --- a/ui/src/dashboards/components/CellEditorOverlay.tsx +++ b/ui/src/dashboards/components/CellEditorOverlay.tsx @@ -42,7 +42,7 @@ import { Status, } from 'src/types' import {ColorString, ColorNumber} from 'src/types/colors' -import * as DashboardActions from 'src/dashboards/actions' +import * as DashboardActions from 'src/types/actions/dashboard' import {SourceOption} from 'src/dashboards/components/OverlayControls' type QueryTransitions = typeof queryTransitions diff --git a/ui/src/dashboards/components/DashboardHeader.tsx b/ui/src/dashboards/components/DashboardHeader.tsx index d14c3961bf..ba320a9c59 100644 --- a/ui/src/dashboards/components/DashboardHeader.tsx +++ b/ui/src/dashboards/components/DashboardHeader.tsx @@ -25,7 +25,7 @@ interface Props { handleChooseTimeRange: (timeRange: TimeRange) => void handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator onManualRefresh: () => void - handleClickPresentationButton: AppActions.DelayEnablePresentationModeThunk + handleClickPresentationButton: AppActions.DelayEnablePresentationModeDispatcher onAddCell: () => void onToggleTempVarControls: () => void showTemplateControlBar: boolean @@ -75,7 +75,6 @@ class DashboardHeader extends Component { handleChooseTimeRange, timeRange: {upper, lower}, zoomedTimeRange: {upper: zoomedUpper, lower: zoomedLower}, - handleClickPresentationButton, } = this.props return ( @@ -98,13 +97,16 @@ class DashboardHeader extends Component { /> ) } + private handleClickPresentationButton = (): void => { + this.props.handleClickPresentationButton() + } private get addCellButton(): JSX.Element { const {dashboard, onAddCell} = this.props diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 1f268969ad..42f334182d 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -24,7 +24,6 @@ import { showCellEditorOverlay, hideCellEditorOverlay, } from 'src/dashboards/actions/cellEditorOverlay' -import {showOverlay} from 'src/shared/actions/overlayTechnology' import {stripTempVar} from 'src/dashboards/utils/tempVars' @@ -56,12 +55,14 @@ import {ColorNumber, ColorString} from 'src/types/colors' import * as AnnotationActions from 'src/shared/actions/annotations' import * as AppActions from 'src/shared/actions/app' import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay' -import * as DashboardActions from 'src/dashboards/actions' +import * as DashboardActions from 'src/types/actions/dashboard' import * as ErrorActions from 'src/shared/actions/errors' -import * as OverlayTechnologyActions from 'src/shared/actions/overlayTechnology' import * as NotificationActions from 'src/shared/actions/notifications' interface DashboardActions { + setDashTimeV1: DashboardActions.SetDashTimeV1ActionCreator + updateDashboard: DashboardActions.UpdateDashboardActionCreator + syncURLQueryParamsFromQueryParamsObject: DashboardActions.SyncURLQueryFromQueryParamsObjectDispatcher putDashboard: DashboardActions.PutDashboardDispatcher putDashboardByID: DashboardActions.PutDashboardByIDDispatcher getDashboardsNamesAsync: DashboardActions.GetDashboardsNamesDispatcher @@ -91,7 +92,7 @@ interface Props { zoomedTimeRange: TimeRange showTemplateControlBar: boolean inPresentationMode: boolean - handleClickPresentationButton: AppActions.DelayEnablePresentationModeThunk + handleClickPresentationButton: AppActions.DelayEnablePresentationModeDispatcher cellQueryStatus: { queryID: string status: object @@ -112,7 +113,6 @@ interface Props { thresholdsListColors: ColorNumber[] gaugeColors: ColorNumber[] lineColors: ColorString[] - handleShowOverlay: OverlayTechnologyActions.ShowOverlayActionCreator } interface State { @@ -614,7 +614,6 @@ const mdtp = { handleShowCellEditorOverlay: showCellEditorOverlay, handleHideCellEditorOverlay: hideCellEditorOverlay, handleDismissEditingAnnotation: dismissEditingAnnotation, - handleShowOverlay: showOverlay, } export default connect(mstp, mdtp)(ManualRefresh(withRouter(DashboardPage))) diff --git a/ui/src/shared/actions/annotations.ts b/ui/src/shared/actions/annotations.ts index 2bc474c5b6..25feab26a7 100644 --- a/ui/src/shared/actions/annotations.ts +++ b/ui/src/shared/actions/annotations.ts @@ -150,10 +150,12 @@ type GetAnnotationsThunk = ( dispatch: Dispatch ) => Promise -export const getAnnotationsAsync = ( +export const getAnnotationsAsync: GetAnnotationsDispatcher = ( indexUrl: string, {since, until}: AnnotationRange -) => async dispatch => { +): GetAnnotationsThunk => async ( + dispatch: Dispatch +): Promise => { const annotations = await api.getAnnotations(indexUrl, since, until) dispatch(loadAnnotations(annotations)) } diff --git a/ui/src/shared/actions/app.ts b/ui/src/shared/actions/app.ts index e075b48216..cae0f97963 100644 --- a/ui/src/shared/actions/app.ts +++ b/ui/src/shared/actions/app.ts @@ -22,11 +22,12 @@ export const disablePresentationMode = (): DisablePresentationModeAction => ({ type: 'DISABLE_PRESENTATION_MODE', }) +export type DelayEnablePresentationModeDispatcher = () => DelayEnablePresentationModeThunk export type DelayEnablePresentationModeThunk = ( dispatch: Dispatch ) => Promise -export const delayEnablePresentationMode: DelayEnablePresentationModeThunk = async ( +export const delayEnablePresentationMode: DelayEnablePresentationModeDispatcher = () => async ( dispatch: Dispatch ): Promise => setTimeout(() => { diff --git a/ui/src/types/actions/dashboard.ts b/ui/src/types/actions/dashboard.ts index 28aee59e71..854ea7c3d9 100644 --- a/ui/src/types/actions/dashboard.ts +++ b/ui/src/types/actions/dashboard.ts @@ -8,6 +8,7 @@ import * as TempVarData from 'src/types/tempVars' import * as ErrorActions from 'src/shared/actions/errors' import * as NotificationActions from 'src/shared/actions/notifications' import * as DashboardReducers from 'src/types/reducers/dashboard' +import {Location} from 'history' export type LoadDashboardsActionCreator = ( dashboards: DashboardData.Dashboard[], @@ -22,6 +23,11 @@ export interface LoadDashboardsAction { } } +export type LoadDashboardActionCreator = ( + dashboards: DashboardData.Dashboard[], + dashboardID?: number +) => LoadDashboardAction + export interface LoadDashboardAction { type: 'LOAD_DASHBOARD' payload: { @@ -37,6 +43,11 @@ export interface SetDashTimeV1Action { } } +export type SetDashTimeV1ActionCreator = ( + dashboardID: number, + timeRange: QueryData.TimeRange +) => SetDashTimeV1Action + export interface RetainRangesDashTimeV1Action { type: 'RETAIN_RANGES_DASHBOARD_TIME_V1' payload: { @@ -44,6 +55,10 @@ export interface RetainRangesDashTimeV1Action { } } +export type RetainRangesDashTimeV1ActionCreator = ( + dashboardIDs: string[] +) => RetainRangesDashTimeV1Action + export type SetTimeRangeActionCreator = ( timeRange: QueryData.TimeRange ) => SetTimeRangeAction @@ -69,6 +84,10 @@ export interface UpdateDashboardAction { } } +export type UpdateDashboardActionCreator = ( + dashboard: DashboardData.Dashboard +) => UpdateDashboardAction + export interface CreateDashboardAction { type: 'CREATE_DASHBOARD' payload: { @@ -196,15 +215,15 @@ export type PutDashboardThunk = ( > ) => Promise +export type PutDashboardByIDDispatcher = ( + dashboardID: number +) => PutDashboardByIDThunk + export type PutDashboardByIDThunk = ( dispatch: Dispatch, getState: () => DashboardReducers.Dashboards ) => Promise -export type PutDashboardByIDDispatcher = ( - dashboardID: number -) => PutDashboardByIDThunk - export type UpdateDashboardCellDispatcher = ( dashboard: DashboardData.Dashboard, cell: DashboardData.Cell @@ -232,13 +251,9 @@ export type AddDashboardCellThunk = ( export type SyncURLQueryFromQueryParamsObjectDispatcher = ( location: Location, updatedURLQueryParams: TempVarData.URLQueryParams, - deletedURLQueryParams: TempVarData.URLQueryParams + deletedURLQueryParams?: TempVarData.URLQueryParams ) => SyncURLQueryFromQueryParamsObjectActionCreator -export type SyncURLQueryFromQueryParamsObjectActionCreator = ( - dispatch: Dispatch -) => void - export type SyncURLQueryFromTempVarsDispatcher = ( location: Location, tempVars: TempVarData.Template[], @@ -246,6 +261,10 @@ export type SyncURLQueryFromTempVarsDispatcher = ( urlQueryParamsTimeRanges: TempVarData.URLQueryParams ) => SyncURLQueryFromQueryParamsObjectActionCreator +export type SyncURLQueryFromQueryParamsObjectActionCreator = ( + dispatch: Dispatch +) => void + export type SyncDashboardTempVarsFromURLQueryParamsDispatcher = ( dispatch: Dispatch< | NotificationActions.PublishNotificationActionCreator diff --git a/ui/src/types/reducers/auth.ts b/ui/src/types/reducers/auth.ts new file mode 100644 index 0000000000..ef5796c651 --- /dev/null +++ b/ui/src/types/reducers/auth.ts @@ -0,0 +1,8 @@ +import * as AuthData from 'src/types/auth' + +export interface Auth { + auth: { + isUsingAuth: boolean + me: AuthData.Me + } +} diff --git a/ui/test/shared/reducers/app.test.js b/ui/test/shared/reducers/app.test.js index 77c8f41670..e3e3890085 100644 --- a/ui/test/shared/reducers/app.test.js +++ b/ui/test/shared/reducers/app.test.js @@ -2,7 +2,6 @@ import appReducer from 'shared/reducers/app' import { enablePresentationMode, disablePresentationMode, - // delayEnablePresentationMode, setAutoRefresh, templateControlBarVisibilityToggled, } from 'shared/actions/app' From 3b111cc404d667be7c20124b2101ca6bca3cbd86 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Thu, 21 Jun 2018 20:42:10 -0700 Subject: [PATCH 14/49] Type most of the rest of DashboardPage Add stronger types to Dashboard Actions. Refactor Dygraph.onZoom to pass TimeRange rather than splitting arguments, and refactor respective DashboardPage & LogViewer methods accordingly. --- ui/src/dashboards/actions/index.ts | 84 +++++++---- .../dashboards/containers/DashboardPage.tsx | 66 ++++----- ui/src/dashboards/utils/cellGetters.ts | 2 +- ui/src/logs/components/LogViewerChart.tsx | 2 +- ui/src/logs/containers/LogsPage.tsx | 6 +- ui/src/shared/components/Dygraph.tsx | 9 +- ui/src/shared/data/timeRanges.ts | 2 +- ui/src/types/actions/dashboard.ts | 135 +++++++++++++++--- ui/src/types/query.ts | 1 + 9 files changed, 221 insertions(+), 86 deletions(-) diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index fd39fee12b..fe2d2550f2 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -72,7 +72,7 @@ import * as DashboardActions from 'src/types/actions/dashboard' import * as DashboardAPIs from 'src/types/apis/dashboard' import * as DashboardReducers from 'src/types/reducers/dashboard' import * as AuthReducers from 'src/types/reducers/auth' -import {PublishNotificationActionCreator} from 'src/shared/actions/notifications' +import * as NotificationActions from 'src/shared/actions/notifications' import * as ErrorActions from 'src/shared/actions/errors' import {LocationAction} from 'react-router-redux' @@ -87,7 +87,7 @@ export const loadDashboards: DashboardActions.LoadDashboardsActionCreator = ( }, }) -export const loadDashboard = ( +export const loadDashboard: DashboardActions.LoadDashboardActionCreator = ( dashboard: Dashboard ): DashboardActions.LoadDashboardAction => ({ type: 'LOAD_DASHBOARD', @@ -156,7 +156,6 @@ export const deleteDashboard: DashboardActions.DeleteDashboardActionCreator = ( type: 'DELETE_DASHBOARD', payload: { dashboard, - dashboardID: dashboard.id, }, }) @@ -391,7 +390,7 @@ export const putDashboard = ( } } -export const putDashboardByID = ( +export const putDashboardByID: DashboardActions.PutDashboardByIDDispatcher = ( dashboardID: number ): DashboardActions.PutDashboardByIDThunk => async ( dispatch: Dispatch, @@ -428,8 +427,15 @@ export const updateDashboardCell: DashboardActions.UpdateDashboardCellDispatcher } } -export const deleteDashboardAsync = (dashboard: Dashboard) => async ( - dispatch +export const deleteDashboardAsync: DashboardActions.DeleteDashboardDispatcher = ( + dashboard: Dashboard +): DashboardActions.DeleteDashboardThunk => async ( + dispatch: Dispatch< + | DashboardActions.DeleteDashboardActionCreator + | NotificationActions.PublishNotificationActionCreator + | ErrorActions.ErrorThrownActionCreator + | DashboardActions.DeleteDashboardFailedActionCreator + > ): Promise => { dispatch(deleteDashboard(dashboard)) try { @@ -446,13 +452,13 @@ export const deleteDashboardAsync = (dashboard: Dashboard) => async ( } } -export const addDashboardCellAsync = ( +export const addDashboardCellAsync: DashboardActions.AddDashboardCellDispatcher = ( dashboard: Dashboard, - cellType: DashboardData.CellType + cellType?: DashboardData.CellType ): DashboardActions.AddDashboardCellThunk => async ( dispatch: Dispatch< | DashboardActions.AddDashboardCellAction - | PublishNotificationActionCreator + | NotificationActions.PublishNotificationActionCreator | ErrorActions.ErrorThrownActionCreator > ): Promise => { @@ -469,10 +475,16 @@ export const addDashboardCellAsync = ( } } -export const cloneDashboardCellAsync = ( +export const cloneDashboardCellAsync: DashboardActions.CloneDashboardCellDispatcher = ( dashboard: Dashboard, cell: Cell -) => async (dispatch): Promise => { +): DashboardActions.CloneDashboardCellThunk => async ( + dispatch: Dispatch< + | DashboardActions.AddDashboardCellActionCreator + | NotificationActions.PublishNotificationActionCreator + | ErrorActions.ErrorThrownActionCreator + > +): Promise => { try { const clonedCell = getClonedDashboardCell(dashboard, cell) const {data} = await addDashboardCellAJAX(dashboard, clonedCell) @@ -484,10 +496,16 @@ export const cloneDashboardCellAsync = ( } } -export const deleteDashboardCellAsync = ( +export const deleteDashboardCellAsync: DashboardActions.DeleteDashboardCellDispatcher = ( dashboard: Dashboard, cell: Cell -) => async (dispatch): Promise => { +): DashboardActions.DeleteDashboardCellThunk => async ( + dispatch: Dispatch< + | DashboardActions.DeleteDashboardCellActionCreator + | NotificationActions.PublishNotificationActionCreator + | ErrorActions.ErrorThrownActionCreator + > +): Promise => { try { await deleteDashboardCellAJAX(cell) dispatch(deleteDashboardCell(dashboard, cell)) @@ -602,11 +620,11 @@ export const syncURLQueryParamsFromQueryParamsObject = ( dispatch(replace(updatedLocation)) } -export const syncURLQueryFromTempVars = ( +export const syncURLQueryFromTempVars: DashboardActions.SyncURLQueryFromTempVarsDispatcher = ( location: Location, tempVars: Template[], deletedTempVars: Template[] = [], - urlQueryParamsTimeRanges: URLQueryParams = {} + urlQueryParamsTimeRanges?: URLQueryParams ): DashboardActions.SyncURLQueryFromQueryParamsObjectActionCreator => ( dispatch: Dispatch< DashboardActions.SyncURLQueryFromQueryParamsObjectDispatcher @@ -617,9 +635,15 @@ export const syncURLQueryFromTempVars = ( deletedTempVars ) - const updatedURLQueryParamsWithTimeRange = { + let updatedURLQueryParamsWithTimeRange = { ...updatedURLQueryParams, - ...urlQueryParamsTimeRanges, + } + + if (urlQueryParamsTimeRanges) { + updatedURLQueryParamsWithTimeRange = { + ...updatedURLQueryParamsWithTimeRange, + ...urlQueryParamsTimeRanges, + } } syncURLQueryParamsFromQueryParamsObject( @@ -634,7 +658,7 @@ const syncDashboardTempVarsFromURLQueryParams = ( urlQueryParams: URLQueryParams ): DashboardActions.SyncDashboardTempVarsFromURLQueryParamsDispatcher => ( dispatch: Dispatch< - | PublishNotificationActionCreator + | NotificationActions.PublishNotificationActionCreator | DashboardActions.TemplateVariableSelectedAction >, getState: () => DashboardReducers.Dashboards & AuthReducers.Auth @@ -673,7 +697,7 @@ const syncDashboardTimeRangeFromURLQueryParams = ( urlQueryParams: URLQueryParams, location: Location ): DashboardActions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher => ( - dispatch: Dispatch, + dispatch: Dispatch, getState: () => DashboardReducers.Dashboards & DashboardReducers.DashTimeV1 ): void => { const { @@ -758,7 +782,7 @@ export const getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardActions.Ge router: InjectedRouter, location: Location ): DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk => async ( - dispatch: Dispatch + dispatch: Dispatch ): Promise => { const dashboard = await bindActionCreators(getDashboardAsync, dispatch)( dashboardID @@ -780,19 +804,23 @@ export const getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardActions.Ge ) } -export const setZoomedTimeRangeAsync = ( +export const setZoomedTimeRangeAsync: DashboardActions.SetZoomedTimeRangeDispatcher = ( zoomedTimeRange: TimeRange, location: Location -) => async (dispatch): Promise => { +): DashboardActions.SetZoomedTimeRangeThunk => async ( + dispatch: Dispatch< + | DashboardActions.SetZoomedTimeRangeActionCreator + | DashboardActions.SyncURLQueryFromQueryParamsObjectDispatcher + > +): Promise => { dispatch(setZoomedTimeRange(zoomedTimeRange)) const urlQueryParamsZoomedTimeRange = { zoomedLower: zoomedTimeRange.lower, zoomedUpper: zoomedTimeRange.upper, } - dispatch( - syncURLQueryParamsFromQueryParamsObject( - location, - urlQueryParamsZoomedTimeRange - ) - ) + + syncURLQueryParamsFromQueryParamsObject( + location, + urlQueryParamsZoomedTimeRange + )(dispatch) } diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 42f334182d..c9721d0db9 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -49,7 +49,14 @@ import {getDeep} from 'src/utils/wrappers' import {Location} from 'history' import {InjectedRouter} from 'react-router' -import {Cell, Dashboard as IDashboard, Source, TimeRange} from 'src/types' +import { + Cell, + Dashboard as IDashboard, + Source, + Template, + TemplateValue, + TimeRange, +} from 'src/types' import {DashboardName} from 'src/types/dashboard' import {ColorNumber, ColorString} from 'src/types/colors' import * as AnnotationActions from 'src/shared/actions/annotations' @@ -71,6 +78,11 @@ interface DashboardActions { addDashboardCellAsync: DashboardActions.AddDashboardCellDispatcher editCellQueryStatus: DashboardActions.EditCellQueryStatusActionCreator updateDashboardCell: DashboardActions.UpdateDashboardCellDispatcher + cloneDashboardCellAsync: DashboardActions.CloneDashboardCellDispatcher + deleteDashboardCellAsync: DashboardActions.DeleteDashboardCellDispatcher + templateVariableSelected: DashboardActions.TemplateVariableSelectedActionCreator + syncURLQueryFromTempVars: DashboardActions.SyncURLQueryFromTempVarsDispatcher + setZoomedTimeRangeAsync: DashboardActions.SetZoomedTimeRangeDispatcher } interface Props { @@ -174,7 +186,7 @@ class DashboardPage extends Component { this.getDashboardsNames() } - public componentWillReceiveProps(nextProps) { + public componentWillReceiveProps(nextProps: Props) { const {source, getAnnotationsAsync, timeRange} = this.props if (this.props.autoRefresh !== nextProps.autoRefresh) { clearInterval(this.intervalID) @@ -187,7 +199,7 @@ class DashboardPage extends Component { } } - public componentDidUpdate(prevProps) { + public componentDidUpdate(prevProps: Props) { const prevPath = getDeep(prevProps.location, 'pathname', null) const thisPath = getDeep(this.props.location, 'pathname', null) @@ -214,7 +226,6 @@ class DashboardPage extends Component { zoomedTimeRange: {lower: zoomedLower, upper: zoomedUpper}, showTemplateControlBar, dashboard, - dashboards, dashboardID, lineColors, gaugeColors, @@ -231,7 +242,6 @@ class DashboardPage extends Component { handleShowCellEditorOverlay, handleHideCellEditorOverlay, handleClickPresentationButton, - params: {sourceID}, } = this.props const {dashboardsNames} = this.state @@ -388,7 +398,7 @@ class DashboardPage extends Component { this.setState({dashboardsNames}) } - private inView = cell => { + private inView = (cell: Cell): boolean => { const {scrollTop, windowHeight} = this.state const bufferValue = 600 const cellTop = cell.y * DASHBOARD_LAYOUT_ROW_HEIGHT @@ -401,18 +411,17 @@ class DashboardPage extends Component { return topInView && bottomInView } - private handleSaveEditedCell = newCell => { + private handleSaveEditedCell = async (newCell: Cell): Promise => { const { dashboardActions, dashboard, handleHideCellEditorOverlay, } = this.props - dashboardActions - .updateDashboardCell(dashboard, newCell) - .then(handleHideCellEditorOverlay) + await dashboardActions.updateDashboardCell(dashboard, newCell) + handleHideCellEditorOverlay() } - private handleChooseTimeRange = timeRange => { + private handleChooseTimeRange = (timeRange: TimeRange): void => { const { dashboard, dashboardActions, @@ -435,7 +444,7 @@ class DashboardPage extends Component { getAnnotationsAsync(source.links.annotations, annotationRange) } - private handleUpdatePosition = cells => { + private handleUpdatePosition = (cells: Cell[]): void => { const {dashboardActions, dashboard, meRole, isUsingAuth} = this.props const newDashboard = {...dashboard, cells} @@ -448,21 +457,21 @@ class DashboardPage extends Component { } } - private handleAddCell = () => { + private handleAddCell = (): void => { const {dashboardActions, dashboard} = this.props dashboardActions.addDashboardCellAsync(dashboard) } - private handleCloneCell = cell => { + private handleCloneCell = (cell: Cell): void => { const {dashboardActions, dashboard} = this.props dashboardActions.cloneDashboardCellAsync(dashboard, cell) } - private handleEditDashboard = () => { + private handleEditDashboard = (): void => { this.setState({isEditMode: true}) } - private handleCancelEditDashboard = () => { + private handleCancelEditDashboard = (): void => { this.setState({isEditMode: false}) } @@ -476,17 +485,14 @@ class DashboardPage extends Component { this.getDashboardsNames() } - private handleUpdateDashboardCell = newCell => () => { - const {dashboardActions, dashboard} = this.props - dashboardActions.updateDashboardCell(dashboard, newCell) - } - - private handleDeleteDashboardCell = cell => { + private handleDeleteDashboardCell = (cell: Cell): void => { const {dashboardActions, dashboard} = this.props dashboardActions.deleteDashboardCellAsync(dashboard, cell) } - private handleSelectTemplate = templateID => value => { + private handleSelectTemplate = ( + templateID: string + ): ((value: TemplateValue) => void) => (value: TemplateValue): void => { const {dashboardActions, dashboard, dashboardID, location} = this.props const currentTempVar = dashboard.templates.find( @@ -508,7 +514,9 @@ class DashboardPage extends Component { dashboardActions.putDashboardByID(dashboardID) } - private handleSaveTemplateVariables = async templates => { + private handleSaveTemplateVariables = async ( + templates: Template[] + ): Promise => { const {location, dashboardActions, dashboard} = this.props try { @@ -530,18 +538,12 @@ class DashboardPage extends Component { } } - private handleRunQueryFailure = error => { - console.error(error) - this.props.errorThrown(error) - } - - private handleToggleTempVarControls = () => { + private handleToggleTempVarControls = (): void => { this.props.templateControlBarVisibilityToggled() } - private handleZoomedTimeRange = (zoomedLower, zoomedUpper) => { + private handleZoomedTimeRange = (zoomedTimeRange: TimeRange): void => { const {dashboardActions, location} = this.props - const zoomedTimeRange = {lower: zoomedLower, upper: zoomedUpper} dashboardActions.setZoomedTimeRangeAsync(zoomedTimeRange, location) } diff --git a/ui/src/dashboards/utils/cellGetters.ts b/ui/src/dashboards/utils/cellGetters.ts index 3a3a72c83d..e76334166d 100644 --- a/ui/src/dashboards/utils/cellGetters.ts +++ b/ui/src/dashboards/utils/cellGetters.ts @@ -55,7 +55,7 @@ const getNextAvailablePosition = (dashboard, newCell) => { export const getNewDashboardCell = ( dashboard: Dashboard, - cellType: CellType + cellType?: CellType ): NewDefaultCell => { const type = cellType || CellType.Line const typedCell = { diff --git a/ui/src/logs/components/LogViewerChart.tsx b/ui/src/logs/components/LogViewerChart.tsx index 02831a0265..f5c4823a0b 100644 --- a/ui/src/logs/components/LogViewerChart.tsx +++ b/ui/src/logs/components/LogViewerChart.tsx @@ -5,7 +5,7 @@ import {DEFAULT_LINE_COLORS} from 'src/shared/constants/graphColorPalettes' import {TimeRange} from 'src/types' interface Props { - onZoom: (lower: string, upper: string) => void + onZoom: (timeRange: TimeRange) => void timeRange: TimeRange data: object[] } diff --git a/ui/src/logs/containers/LogsPage.tsx b/ui/src/logs/containers/LogsPage.tsx index c1c6a8d41b..f672491663 100644 --- a/ui/src/logs/containers/LogsPage.tsx +++ b/ui/src/logs/containers/LogsPage.tsx @@ -262,9 +262,9 @@ class LogsPage extends PureComponent { this.props.setNamespaceAsync(namespace) } - private handleChartZoom = (lower, upper) => { - if (lower) { - this.props.changeZoomAsync({lower, upper}) + private handleChartZoom = (timeRange: TimeRange) => { + if (timeRange.lower) { + this.props.changeZoomAsync(timeRange) this.setState({liveUpdating: true}) } } diff --git a/ui/src/shared/components/Dygraph.tsx b/ui/src/shared/components/Dygraph.tsx index 96f1c84d99..33d4a1be45 100644 --- a/ui/src/shared/components/Dygraph.tsx +++ b/ui/src/shared/components/Dygraph.tsx @@ -68,7 +68,7 @@ interface Props { isBarGraph?: boolean staticLegend?: boolean setResolution?: (w: number) => void - onZoom?: (u: number | string, l: number | string) => void + onZoom?: (timeRange: TimeRange) => void mode?: string } @@ -368,10 +368,13 @@ class Dygraph extends Component { const {onZoom} = this.props if (this.dygraph.isZoomed() === false) { - return onZoom(null, null) + return onZoom({lower: null, upper: null}) } - onZoom(this.formatTimeRange(lower), this.formatTimeRange(upper)) + onZoom({ + lower: this.formatTimeRange(lower), + upper: this.formatTimeRange(upper), + }) } private handleDraw = () => { diff --git a/ui/src/shared/data/timeRanges.ts b/ui/src/shared/data/timeRanges.ts index dd46291e7b..972be61c31 100644 --- a/ui/src/shared/data/timeRanges.ts +++ b/ui/src/shared/data/timeRanges.ts @@ -1,4 +1,4 @@ -import {TimeRangeOption} from 'src/types/dashboard' +import {TimeRangeOption} from 'src/types/query' const nowMinus30d = 'now() - 30d' diff --git a/ui/src/types/actions/dashboard.ts b/ui/src/types/actions/dashboard.ts index 854ea7c3d9..d93193c6e8 100644 --- a/ui/src/types/actions/dashboard.ts +++ b/ui/src/types/actions/dashboard.ts @@ -24,8 +24,7 @@ export interface LoadDashboardsAction { } export type LoadDashboardActionCreator = ( - dashboards: DashboardData.Dashboard[], - dashboardID?: number + dashboard: DashboardData.Dashboard ) => LoadDashboardAction export interface LoadDashboardAction { @@ -70,6 +69,22 @@ export interface SetTimeRangeAction { } } +export type SetZoomedTimeRangeDispatcher = ( + zoomedTimeRange: QueryData.TimeRange, + location: Location +) => SetZoomedTimeRangeThunk + +export type SetZoomedTimeRangeThunk = ( + dispatch: Dispatch< + | SetZoomedTimeRangeActionCreator + | SyncURLQueryFromQueryParamsObjectDispatcher + > +) => Promise + +export type SetZoomedTimeRangeActionCreator = ( + zoomedTimeRange: QueryData.TimeRange +) => SetZoomedTimeRangeAction + export interface SetZoomedTimeRangeAction { type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE' payload: { @@ -88,6 +103,10 @@ export type UpdateDashboardActionCreator = ( dashboard: DashboardData.Dashboard ) => UpdateDashboardAction +export type CreateDashboardActionCreator = ( + dashboard: DashboardData.Dashboard +) => CreateDashboardAction + export interface CreateDashboardAction { type: 'CREATE_DASHBOARD' payload: { @@ -95,14 +114,21 @@ export interface CreateDashboardAction { } } +export type DeleteDashboardActionCreator = ( + dashboard: DashboardData.Dashboard +) => DeleteDashboardAction + export interface DeleteDashboardAction { type: 'DELETE_DASHBOARD' payload: { dashboard: DashboardData.Dashboard - dashboardID: number } } +export type DeleteDashboardFailedActionCreator = ( + dashboard: DashboardData.Dashboard +) => DeleteDashboardFailedAction + export interface DeleteDashboardFailedAction { type: 'DELETE_DASHBOARD_FAILED' payload: { @@ -123,6 +149,24 @@ export interface SyncDashboardCellAction { } } +export type AddDashboardCellDispatcher = ( + dashboard: DashboardData.Dashboard, + cellType?: DashboardData.CellType +) => AddDashboardCellThunk + +export type AddDashboardCellThunk = ( + dispatch: Dispatch< + | AddDashboardCellAction + | NotificationActions.PublishNotificationActionCreator + | ErrorActions.ErrorThrownActionCreator + > +) => Promise + +export type AddDashboardCellActionCreator = ( + dashboard: DashboardData.Dashboard, + cell: DashboardData.Cell +) => AddDashboardCellAction + export interface AddDashboardCellAction { type: 'ADD_DASHBOARD_CELL' payload: { @@ -130,6 +174,38 @@ export interface AddDashboardCellAction { cell: DashboardData.Cell } } + +export type CloneDashboardCellDispatcher = ( + dashboard: DashboardData.Dashboard, + cell: DashboardData.Cell +) => CloneDashboardCellThunk + +export type CloneDashboardCellThunk = ( + dispatch: Dispatch< + | AddDashboardCellAction + | NotificationActions.PublishNotificationActionCreator + | ErrorActions.ErrorThrownActionCreator + > +) => Promise + +export type DeleteDashboardCellDispatcher = ( + dashboard: DashboardData.Dashboard, + cell: DashboardData.Cell +) => DeleteDashboardCellThunk + +export type DeleteDashboardCellThunk = ( + dispatch: Dispatch< + | DeleteDashboardCellActionCreator + | NotificationActions.PublishNotificationActionCreator + | ErrorActions.ErrorThrownActionCreator + > +) => Promise + +export type DeleteDashboardCellActionCreator = ( + dashboard: DashboardData.Dashboard, + cell: DashboardData.Cell +) => DeleteDashboardCellAction + export interface DeleteDashboardCellAction { type: 'DELETE_DASHBOARD_CELL' payload: { @@ -151,6 +227,12 @@ export interface EditCellQueryStatusAction { } } +export type TemplateVariableSelectedActionCreator = ( + dashboardID: number, + templateID: string, + values: any[] +) => TemplateVariableSelectedAction + export interface TemplateVariableSelectedAction { type: 'TEMPLATE_VARIABLE_SELECTED' payload: { @@ -160,6 +242,11 @@ export interface TemplateVariableSelectedAction { } } +export type TemplateVariablesSelectedByNameActionCreator = ( + dashboardID: number, + queryParams: TempVarData.URLQueryParams +) => TemplateVariablesSelectedByNameAction + export interface TemplateVariablesSelectedByNameAction { type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME' payload: { @@ -168,6 +255,12 @@ export interface TemplateVariablesSelectedByNameAction { } } +export type EditTemplateVariableValuesActionCreator = ( + dashboardID: number, + templateID: string, + values: any[] +) => EditTemplateVariableValuesAction + export interface EditTemplateVariableValuesAction { type: 'EDIT_TEMPLATE_VARIABLE_VALUES' payload: { @@ -177,6 +270,10 @@ export interface EditTemplateVariableValuesAction { } } +export type SetHoverTimeActionCreator = ( + hoverTime: string +) => SetHoverTimeAction + export interface SetHoverTimeAction { type: 'SET_HOVER_TIME' payload: { @@ -184,6 +281,10 @@ export interface SetHoverTimeAction { } } +export type SetActiveCellActionCreator = ( + activeCellID: string +) => SetActiveCellAction + export interface SetActiveCellAction { type: 'SET_ACTIVE_CELL' payload: { @@ -224,6 +325,19 @@ export type PutDashboardByIDThunk = ( getState: () => DashboardReducers.Dashboards ) => Promise +export type DeleteDashboardDispatcher = ( + dashboard: DashboardData.Dashboard +) => DeleteDashboardThunk + +export type DeleteDashboardThunk = ( + dispatch: Dispatch< + | DeleteDashboardActionCreator + | NotificationActions.PublishNotificationActionCreator + | ErrorActions.ErrorThrownActionCreator + | DeleteDashboardFailedActionCreator + > +) => Promise + export type UpdateDashboardCellDispatcher = ( dashboard: DashboardData.Dashboard, cell: DashboardData.Cell @@ -235,19 +349,6 @@ export type UpdateDashboardCellThunk = ( > ) => Promise -export type AddDashboardCellDispatcher = ( - dashboard: DashboardData.Dashboard, - cellType: DashboardData.CellType -) => AddDashboardCellThunk - -export type AddDashboardCellThunk = ( - dispatch: Dispatch< - | AddDashboardCellAction - | NotificationActions.PublishNotificationActionCreator - | ErrorActions.ErrorThrownActionCreator - > -) => Promise - export type SyncURLQueryFromQueryParamsObjectDispatcher = ( location: Location, updatedURLQueryParams: TempVarData.URLQueryParams, @@ -258,7 +359,7 @@ export type SyncURLQueryFromTempVarsDispatcher = ( location: Location, tempVars: TempVarData.Template[], deletedTempVars: TempVarData.Template[], - urlQueryParamsTimeRanges: TempVarData.URLQueryParams + urlQueryParamsTimeRanges?: TempVarData.URLQueryParams ) => SyncURLQueryFromQueryParamsObjectActionCreator export type SyncURLQueryFromQueryParamsObjectActionCreator = ( diff --git a/ui/src/types/query.ts b/ui/src/types/query.ts index 88a89d0c6c..ecc1bf8c46 100644 --- a/ui/src/types/query.ts +++ b/ui/src/types/query.ts @@ -87,6 +87,7 @@ export interface TimeRange { lower: string upper?: string | null seconds?: number + format?: string } export interface DurationRange { From bcf88dd3369379e655c7a0af00778ee3d64f8803 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 13:11:06 -0700 Subject: [PATCH 15/49] Rename ManualRefresh.js to ManualRefresh.tsx --- ui/src/shared/components/{ManualRefresh.js => ManualRefresh.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ui/src/shared/components/{ManualRefresh.js => ManualRefresh.tsx} (100%) diff --git a/ui/src/shared/components/ManualRefresh.js b/ui/src/shared/components/ManualRefresh.tsx similarity index 100% rename from ui/src/shared/components/ManualRefresh.js rename to ui/src/shared/components/ManualRefresh.tsx From 5e6f698db4fcc8f0f299384d7c189a3291a8bc4f Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 14:07:43 -0700 Subject: [PATCH 16/49] Convert ManualRefresh to TypeScript Co-authored-by: Delmer Reed --- ui/src/shared/components/ManualRefresh.tsx | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/ui/src/shared/components/ManualRefresh.tsx b/ui/src/shared/components/ManualRefresh.tsx index d3edcd1016..43df154935 100644 --- a/ui/src/shared/components/ManualRefresh.tsx +++ b/ui/src/shared/components/ManualRefresh.tsx @@ -1,21 +1,26 @@ -import React, {Component} from 'react' +import React, {Component, ComponentClass} from 'react' -const ManualRefresh = WrappedComponent => - class extends Component { - constructor(props) { +export interface ManualRefreshProps { + manualRefresh: number + onManualRefresh: () => void +} + +interface ManualRefreshState { + manualRefresh: number +} + +const ManualRefresh =

( + WrappedComponent: ComponentClass

+): ComponentClass

=> + class extends Component { + public constructor(props: P) { super(props) this.state = { manualRefresh: Date.now(), } } - handleManualRefresh = () => { - this.setState({ - manualRefresh: Date.now(), - }) - } - - render() { + public render() { return ( /> ) } + + private handleManualRefresh = (): void => { + this.setState({ + manualRefresh: Date.now(), + }) + } } export default ManualRefresh From 9e8221e13b1d9fe9c453cf6d585449212871fe4a Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 14:07:57 -0700 Subject: [PATCH 17/49] Compose DashboardPage prop types with withRouter & ManualRefresh Co-authored-by: Delmer Reed --- .../dashboards/containers/DashboardPage.tsx | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index c9721d0db9..001d6ac333 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -47,6 +47,8 @@ import {ErrorHandling} from 'src/shared/decorators/errors' import {getDeep} from 'src/utils/wrappers' +import {WithRouterProps} from 'react-router' +import {ManualRefreshProps} from 'src/shared/components/ManualRefresh' import {Location} from 'history' import {InjectedRouter} from 'react-router' import { @@ -85,7 +87,7 @@ interface DashboardActions { setZoomedTimeRangeAsync: DashboardActions.SetZoomedTimeRangeDispatcher } -interface Props { +interface ContainerProps { source: Source sources: Source[] params: { @@ -110,8 +112,6 @@ interface Props { status: object } errorThrown: ErrorActions.ErrorThrownActionCreator - manualRefresh: number - onManualRefresh: () => void meRole: string isUsingAuth: boolean router: InjectedRouter @@ -135,11 +135,13 @@ interface State { dashboardsNames: DashboardName[] } +type ComposedProps = ContainerProps & ManualRefreshProps & WithRouterProps + @ErrorHandling -class DashboardPage extends Component { +class DashboardPage extends Component { private intervalID: number - public constructor(props: Props) { + public constructor(props: ComposedProps) { super(props) this.state = { @@ -186,7 +188,7 @@ class DashboardPage extends Component { this.getDashboardsNames() } - public componentWillReceiveProps(nextProps: Props) { + public componentWillReceiveProps(nextProps: ContainerProps) { const {source, getAnnotationsAsync, timeRange} = this.props if (this.props.autoRefresh !== nextProps.autoRefresh) { clearInterval(this.intervalID) @@ -199,7 +201,7 @@ class DashboardPage extends Component { } } - public componentDidUpdate(prevProps: Props) { + public componentDidUpdate(prevProps: ContainerProps) { const prevPath = getDeep(prevProps.location, 'pathname', null) const thisPath = getDeep(this.props.location, 'pathname', null) @@ -618,4 +620,6 @@ const mdtp = { handleDismissEditingAnnotation: dismissEditingAnnotation, } -export default connect(mstp, mdtp)(ManualRefresh(withRouter(DashboardPage))) +export default connect(mstp, mdtp)( + ManualRefresh(withRouter(DashboardPage)) +) From a49a4e76466fb3c44cf6b8e1c68d0009e304a254 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 14:24:27 -0700 Subject: [PATCH 18/49] Refactor ManualRefresh interface to be consistent with withRouter Clarifies relationship between HOCs and how to define DashboardPage props by extending from the props it will receive from its HOCs. Co-authored-by: Delmer Reed --- ui/src/dashboards/containers/DashboardPage.tsx | 14 ++++++-------- ui/src/shared/components/ManualRefresh.tsx | 11 ++++++----- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 001d6ac333..58c396842c 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -87,7 +87,7 @@ interface DashboardActions { setZoomedTimeRangeAsync: DashboardActions.SetZoomedTimeRangeDispatcher } -interface ContainerProps { +interface Props extends ManualRefreshProps, WithRouterProps { source: Source sources: Source[] params: { @@ -135,13 +135,11 @@ interface State { dashboardsNames: DashboardName[] } -type ComposedProps = ContainerProps & ManualRefreshProps & WithRouterProps - @ErrorHandling -class DashboardPage extends Component { +class DashboardPage extends Component { private intervalID: number - public constructor(props: ComposedProps) { + public constructor(props: Props) { super(props) this.state = { @@ -188,7 +186,7 @@ class DashboardPage extends Component { this.getDashboardsNames() } - public componentWillReceiveProps(nextProps: ContainerProps) { + public componentWillReceiveProps(nextProps: Props) { const {source, getAnnotationsAsync, timeRange} = this.props if (this.props.autoRefresh !== nextProps.autoRefresh) { clearInterval(this.intervalID) @@ -201,7 +199,7 @@ class DashboardPage extends Component { } } - public componentDidUpdate(prevProps: ContainerProps) { + public componentDidUpdate(prevProps: Props) { const prevPath = getDeep(prevProps.location, 'pathname', null) const thisPath = getDeep(this.props.location, 'pathname', null) @@ -621,5 +619,5 @@ const mdtp = { } export default connect(mstp, mdtp)( - ManualRefresh(withRouter(DashboardPage)) + ManualRefresh(withRouter(DashboardPage)) ) diff --git a/ui/src/shared/components/ManualRefresh.tsx b/ui/src/shared/components/ManualRefresh.tsx index 43df154935..9cc83b9918 100644 --- a/ui/src/shared/components/ManualRefresh.tsx +++ b/ui/src/shared/components/ManualRefresh.tsx @@ -9,11 +9,11 @@ interface ManualRefreshState { manualRefresh: number } -const ManualRefresh =

( - WrappedComponent: ComponentClass

-): ComponentClass

=> - class extends Component { - public constructor(props: P) { +function ManualRefresh

( + WrappedComponent: ComponentClass

+): ComponentClass

{ + return class extends Component

{ + public constructor(props: P & ManualRefreshProps) { super(props) this.state = { manualRefresh: Date.now(), @@ -36,5 +36,6 @@ const ManualRefresh =

( }) } } +} export default ManualRefresh From bbd66da6e2106dccc7999204e2c0d41e0bf9dd6a Mon Sep 17 00:00:00 2001 From: Delmer Reed Date: Fri, 22 Jun 2018 17:40:21 -0400 Subject: [PATCH 19/49] Update ShowOverlayActionCreator import from overlayTechnoloy --- ui/src/flux/components/FluxHeader.tsx | 8 ++++---- ui/src/flux/containers/CheckServices.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/src/flux/components/FluxHeader.tsx b/ui/src/flux/components/FluxHeader.tsx index 6bbdc0ba71..96ff315a10 100644 --- a/ui/src/flux/components/FluxHeader.tsx +++ b/ui/src/flux/components/FluxHeader.tsx @@ -5,14 +5,14 @@ import FluxOverlay from 'src/flux/components/FluxOverlay' import {OverlayContext} from 'src/shared/components/OverlayTechnology' import PageHeader from 'src/shared/components/PageHeader' import { - showOverlay as showOverlayAction, - ShowOverlay, + showOverlay as showOverlayActionCreator, + ShowOverlayActionCreator, } from 'src/shared/actions/overlayTechnology' import {Service} from 'src/types' interface Props { - showOverlay: ShowOverlay + showOverlay: ShowOverlayActionCreator service: Service } @@ -54,7 +54,7 @@ class FluxHeader extends PureComponent { } const mdtp = { - showOverlay: showOverlayAction, + showOverlay: showOverlayActionCreator, } export default connect(null, mdtp)(FluxHeader) diff --git a/ui/src/flux/containers/CheckServices.tsx b/ui/src/flux/containers/CheckServices.tsx index adc4def462..fe546efed1 100644 --- a/ui/src/flux/containers/CheckServices.tsx +++ b/ui/src/flux/containers/CheckServices.tsx @@ -23,7 +23,7 @@ interface Props { sources: Source[] services: Service[] children: ReactChildren - showOverlay: a.ShowOverlay + showOverlay: a.ShowOverlayActionCreator fetchServicesAsync: b.FetchServicesAsync notify: (message: Notification) => void updateScript: UpdateScript From 8c2e8a2176ef6b54ae0f27885a62dd65583df6e8 Mon Sep 17 00:00:00 2001 From: Delmer Reed Date: Fri, 22 Jun 2018 18:26:40 -0400 Subject: [PATCH 20/49] Add ErrorDescription with auth and links ErrorThrownAction triggers an AUTH_EXPIRED in middleware. AuthReducer extracts auth links to upddate state.links. It's unclear what the shape is of auth.links: Errors.test.js utilizes an auth.links of type arrayOf({ name: string, label:string, login: string, logout: string, callback: string, }) OrganizationsPage consumes links w/ shape of shape({ organizations: string.isRequired, config: shape({ auth: string.isRequired, }).isRequired, }) UsersPage consumes links w/ shape of shape({ users: string.isRequired, }), ProvidersPage consumes links w/ shape of shape({ organizations: string.isRequired, }), Purgatory consumes links w/ shape of shape({ me: string, }), UserNavBlock at some point expected shape({ me: string, external: shape({ custom: arrayOf( shape({ name: string.isRequired, url: string.isRequired, }) ), }), }) --- ui/src/shared/actions/errors.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ui/src/shared/actions/errors.ts b/ui/src/shared/actions/errors.ts index 453ebbcd67..9ca97e20ad 100644 --- a/ui/src/shared/actions/errors.ts +++ b/ui/src/shared/actions/errors.ts @@ -10,12 +10,12 @@ export type ErrorThrownActionCreator = ( interface ErrorThrownAction { type: 'ERROR_THROWN' - error: Error + error: ErrorDescription altText?: string alertType?: AlertType } export const errorThrown = ( - error: Error, + error: ErrorDescription, altText?: string, alertType?: AlertType ): ErrorThrownAction => ({ @@ -24,3 +24,12 @@ export const errorThrown = ( altText, alertType, }) + +interface ErrorDescription { + status: number + auth: { + links: { + me: string + } + } +} From 61130535e55b60417fb52da4a1232ccf8d009d8b Mon Sep 17 00:00:00 2001 From: Delmer Reed Date: Fri, 22 Jun 2018 19:48:57 -0400 Subject: [PATCH 21/49] Update cell editor test to return null --- ui/test/dashboards/components/CellEditorOverlay.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/test/dashboards/components/CellEditorOverlay.test.tsx b/ui/test/dashboards/components/CellEditorOverlay.test.tsx index 698042f49d..c8fd70ea1d 100644 --- a/ui/test/dashboards/components/CellEditorOverlay.test.tsx +++ b/ui/test/dashboards/components/CellEditorOverlay.test.tsx @@ -37,7 +37,7 @@ const setup = (override = {}) => { thresholdsListColors, gaugeColors, lineColors, - editQueryStatus: () => {}, + editQueryStatus: () => null, onCancel: () => {}, onSave: () => {}, notify: () => {}, From 058af91e4637852812a1f6a79cd1307b5757d9da Mon Sep 17 00:00:00 2001 From: Delmer Reed Date: Fri, 22 Jun 2018 20:42:00 -0400 Subject: [PATCH 22/49] Refactor error types to follow new file structure Co-authored-by: Jared Scheib --- ui/src/dashboards/actions/index.ts | 2 +- .../dashboards/containers/DashboardPage.tsx | 2 +- ui/src/index.tsx | 9 +++++- ui/src/shared/actions/errors.ts | 32 +++---------------- ui/src/types/actions/dashboard.ts | 2 +- ui/src/types/actions/error.ts | 14 ++++++++ ui/src/types/error.ts | 13 ++++++++ 7 files changed, 43 insertions(+), 31 deletions(-) create mode 100644 ui/src/types/actions/error.ts create mode 100644 ui/src/types/error.ts diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index fe2d2550f2..b93e1615c7 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -73,7 +73,7 @@ import * as DashboardAPIs from 'src/types/apis/dashboard' import * as DashboardReducers from 'src/types/reducers/dashboard' import * as AuthReducers from 'src/types/reducers/auth' import * as NotificationActions from 'src/shared/actions/notifications' -import * as ErrorActions from 'src/shared/actions/errors' +import * as ErrorActions from 'src/types/actions/error' import {LocationAction} from 'react-router-redux' export const loadDashboards: DashboardActions.LoadDashboardsActionCreator = ( diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 58c396842c..9be4cec1d5 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -65,7 +65,7 @@ import * as AnnotationActions from 'src/shared/actions/annotations' import * as AppActions from 'src/shared/actions/app' import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay' import * as DashboardActions from 'src/types/actions/dashboard' -import * as ErrorActions from 'src/shared/actions/errors' +import * as ErrorActions from 'src/types/actions/error' import * as NotificationActions from 'src/shared/actions/notifications' interface DashboardActions { diff --git a/ui/src/index.tsx b/ui/src/index.tsx index 438517a761..a7c39fefc7 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -49,6 +49,7 @@ import {notify} from 'src/shared/actions/notifications' import 'src/style/chronograf.scss' import {HEARTBEAT_INTERVAL} from 'src/shared/constants' +import * as ErrorData from 'src/types/error' const errorsQueue = [] @@ -185,7 +186,13 @@ class Root extends PureComponent<{}, State> { if (typeof error === 'object') { dispatch(notify(error)) } else { - dispatch(errorThrown({status: 0, auth: null}, error, 'warning')) + dispatch( + errorThrown( + {status: 0, auth: null}, + error, + ErrorData.AlertType.Warning + ) + ) } }) } diff --git a/ui/src/shared/actions/errors.ts b/ui/src/shared/actions/errors.ts index 9ca97e20ad..e00b5e1f91 100644 --- a/ui/src/shared/actions/errors.ts +++ b/ui/src/shared/actions/errors.ts @@ -1,35 +1,13 @@ -enum AlertType { - 'info', -} +import * as ErrorData from 'src/types/error' +import * as ErrorActions from 'src/types/actions/error' -export type ErrorThrownActionCreator = ( - error: Error, - altText?: string, - alertType?: AlertType -) => ErrorThrownAction - -interface ErrorThrownAction { - type: 'ERROR_THROWN' - error: ErrorDescription - altText?: string - alertType?: AlertType -} export const errorThrown = ( - error: ErrorDescription, + error: ErrorData.ErrorDescription, altText?: string, - alertType?: AlertType -): ErrorThrownAction => ({ + alertType?: ErrorData.AlertType +): ErrorActions.ErrorThrownAction => ({ type: 'ERROR_THROWN', error, altText, alertType, }) - -interface ErrorDescription { - status: number - auth: { - links: { - me: string - } - } -} diff --git a/ui/src/types/actions/dashboard.ts b/ui/src/types/actions/dashboard.ts index d93193c6e8..c28c320390 100644 --- a/ui/src/types/actions/dashboard.ts +++ b/ui/src/types/actions/dashboard.ts @@ -5,7 +5,7 @@ import {Source} from 'src/types' import * as DashboardData from 'src/types/dashboard' import * as QueryData from 'src/types/query' import * as TempVarData from 'src/types/tempVars' -import * as ErrorActions from 'src/shared/actions/errors' +import * as ErrorActions from 'src/types/actions/error' import * as NotificationActions from 'src/shared/actions/notifications' import * as DashboardReducers from 'src/types/reducers/dashboard' import {Location} from 'history' diff --git a/ui/src/types/actions/error.ts b/ui/src/types/actions/error.ts new file mode 100644 index 0000000000..185def97ed --- /dev/null +++ b/ui/src/types/actions/error.ts @@ -0,0 +1,14 @@ +import * as ErrorData from 'src/types/error' + +export type ErrorThrownActionCreator = ( + error: ErrorData.ErrorDescription, + altText?: string, + alertType?: ErrorData.AlertType +) => ErrorThrownAction + +export interface ErrorThrownAction { + type: 'ERROR_THROWN' + error: ErrorData.ErrorDescription + altText?: string + alertType?: ErrorData.AlertType +} diff --git a/ui/src/types/error.ts b/ui/src/types/error.ts new file mode 100644 index 0000000000..718355f3f8 --- /dev/null +++ b/ui/src/types/error.ts @@ -0,0 +1,13 @@ +export interface ErrorDescription { + status: number + auth: { + links: { + me: string + } + } +} + +export enum AlertType { + Info = 'info', + Warning = 'warning', +} From 6135a4168f00cbf6a7d7473393dd033411379328 Mon Sep 17 00:00:00 2001 From: Delmer Reed Date: Fri, 22 Jun 2018 20:43:46 -0400 Subject: [PATCH 23/49] Stopgap-fix getDashboardsNamesThunk type error Resolve react-redux type issues later to fix getDashboardsNames typing. Co-authored-by: Jared Scheib --- ui/src/dashboards/containers/DashboardPage.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 9be4cec1d5..c6d10e7d49 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -394,7 +394,9 @@ class DashboardPage extends Component { dashboardActions: {getDashboardsNamesAsync}, } = this.props - const dashboardsNames = await getDashboardsNamesAsync(sourceID) + // TODO: remove any once react-redux connect is properly typed + const dashboardsNames = (await getDashboardsNamesAsync(sourceID)) as any + this.setState({dashboardsNames}) } From a0b2ee4aead41277e54980946c539df9c7c4ad51 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:02:06 -0700 Subject: [PATCH 24/49] Refactor annotations types file structure & imports to new style --- .../dashboards/containers/DashboardPage.tsx | 2 +- ui/src/shared/actions/annotations.ts | 121 ++++-------------- ui/src/shared/components/Annotations.tsx | 2 +- ui/src/shared/reducers/annotations.ts | 2 +- ui/src/types/actions/annotations.ts | 82 ++++++++++++ ui/src/types/annotations.ts | 5 + 6 files changed, 114 insertions(+), 100 deletions(-) create mode 100644 ui/src/types/actions/annotations.ts diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index c6d10e7d49..bfe93fb7c6 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -61,7 +61,7 @@ import { } from 'src/types' import {DashboardName} from 'src/types/dashboard' import {ColorNumber, ColorString} from 'src/types/colors' -import * as AnnotationActions from 'src/shared/actions/annotations' +import * as AnnotationActions from 'src/types/actions/annotations' import * as AppActions from 'src/shared/actions/app' import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay' import * as DashboardActions from 'src/types/actions/dashboard' diff --git a/ui/src/shared/actions/annotations.ts b/ui/src/shared/actions/annotations.ts index 25feab26a7..4f4eb18ede 100644 --- a/ui/src/shared/actions/annotations.ts +++ b/ui/src/shared/actions/annotations.ts @@ -1,125 +1,66 @@ import * as api from 'src/shared/apis/annotation' -import {AnnotationInterface} from 'src/types' import {Dispatch} from 'redux' +import * as AnnotationData from 'src/types/annotations' +import * as AnnotationActions from 'src/types/actions/annotations' -export type Action = - | EditingAnnotationAction - | DismissEditingAnnotationAction - | AddingAnnotationAction - | AddingAnnotationSuccessAction - | DismissAddingAnnotationAction - | MouseEnterTempAnnotationAction - | MouseLeaveTempAnnotationAction - | LoadAnnotationsAction - | UpdateAnnotationAction - | DeleteAnnotationAction - | AddAnnotationAction - -export interface EditingAnnotationAction { - type: 'EDITING_ANNOTATION' -} -export const editingAnnotation = (): EditingAnnotationAction => ({ +export const editingAnnotation = (): AnnotationActions.EditingAnnotationAction => ({ type: 'EDITING_ANNOTATION', }) -export type DismissEditingAnnotationActionCreator = () => DismissEditingAnnotationAction - -interface DismissEditingAnnotationAction { - type: 'DISMISS_EDITING_ANNOTATION' -} -export const dismissEditingAnnotation = (): DismissEditingAnnotationAction => ({ +export const dismissEditingAnnotation = (): AnnotationActions.DismissEditingAnnotationAction => ({ type: 'DISMISS_EDITING_ANNOTATION', }) -export interface AddingAnnotationAction { - type: 'ADDING_ANNOTATION' -} -export const addingAnnotation = (): AddingAnnotationAction => ({ +export const addingAnnotation = (): AnnotationActions.AddingAnnotationAction => ({ type: 'ADDING_ANNOTATION', }) -export interface AddingAnnotationSuccessAction { - type: 'ADDING_ANNOTATION_SUCCESS' -} -export const addingAnnotationSuccess = (): AddingAnnotationSuccessAction => ({ +export const addingAnnotationSuccess = (): AnnotationActions.AddingAnnotationSuccessAction => ({ type: 'ADDING_ANNOTATION_SUCCESS', }) -export interface DismissAddingAnnotationAction { - type: 'DISMISS_ADDING_ANNOTATION' -} -export const dismissAddingAnnotation = (): DismissAddingAnnotationAction => ({ +export const dismissAddingAnnotation = (): AnnotationActions.DismissAddingAnnotationAction => ({ type: 'DISMISS_ADDING_ANNOTATION', }) -export interface MouseEnterTempAnnotationAction { - type: 'MOUSEENTER_TEMP_ANNOTATION' -} -export const mouseEnterTempAnnotation = (): MouseEnterTempAnnotationAction => ({ +export const mouseEnterTempAnnotation = (): AnnotationActions.MouseEnterTempAnnotationAction => ({ type: 'MOUSEENTER_TEMP_ANNOTATION', }) -export interface MouseLeaveTempAnnotationAction { - type: 'MOUSELEAVE_TEMP_ANNOTATION' -} -export const mouseLeaveTempAnnotation = (): MouseLeaveTempAnnotationAction => ({ +export const mouseLeaveTempAnnotation = (): AnnotationActions.MouseLeaveTempAnnotationAction => ({ type: 'MOUSELEAVE_TEMP_ANNOTATION', }) -export interface LoadAnnotationsAction { - type: 'LOAD_ANNOTATIONS' - payload: { - annotations: AnnotationInterface[] - } -} export const loadAnnotations = ( - annotations: AnnotationInterface[] -): LoadAnnotationsAction => ({ + annotations: AnnotationData.AnnotationInterface[] +): AnnotationActions.LoadAnnotationsAction => ({ type: 'LOAD_ANNOTATIONS', payload: { annotations, }, }) -export interface UpdateAnnotationAction { - type: 'UPDATE_ANNOTATION' - payload: { - annotation: AnnotationInterface - } -} export const updateAnnotation = ( - annotation: AnnotationInterface -): UpdateAnnotationAction => ({ + annotation: AnnotationData.AnnotationInterface +): AnnotationActions.UpdateAnnotationAction => ({ type: 'UPDATE_ANNOTATION', payload: { annotation, }, }) -export interface DeleteAnnotationAction { - type: 'DELETE_ANNOTATION' - payload: { - annotation: AnnotationInterface - } -} export const deleteAnnotation = ( - annotation: AnnotationInterface -): DeleteAnnotationAction => ({ + annotation: AnnotationData.AnnotationInterface +): AnnotationActions.DeleteAnnotationAction => ({ type: 'DELETE_ANNOTATION', payload: { annotation, }, }) -export interface AddAnnotationAction { - type: 'ADD_ANNOTATION' - payload: { - annotation: AnnotationInterface - } -} export const addAnnotation = ( - annotation: AnnotationInterface -): AddAnnotationAction => ({ + annotation: AnnotationData.AnnotationInterface +): AnnotationActions.AddAnnotationAction => ({ type: 'ADD_ANNOTATION', payload: { annotation, @@ -128,7 +69,7 @@ export const addAnnotation = ( export const addAnnotationAsync = ( createUrl: string, - annotation: AnnotationInterface + annotation: AnnotationData.AnnotationInterface ) => async dispatch => { dispatch(addAnnotation(annotation)) const savedAnnotation = await api.createAnnotation(createUrl, annotation) @@ -136,39 +77,25 @@ export const addAnnotationAsync = ( dispatch(deleteAnnotation(annotation)) } -export interface AnnotationRange { - since: number - until: number -} - -export type GetAnnotationsDispatcher = ( +export const getAnnotationsAsync: AnnotationActions.GetAnnotationsDispatcher = ( indexUrl: string, - annotationRange: AnnotationRange -) => GetAnnotationsThunk - -type GetAnnotationsThunk = ( - dispatch: Dispatch -) => Promise - -export const getAnnotationsAsync: GetAnnotationsDispatcher = ( - indexUrl: string, - {since, until}: AnnotationRange -): GetAnnotationsThunk => async ( - dispatch: Dispatch + {since, until}: AnnotationData.AnnotationRange +): AnnotationActions.GetAnnotationsThunk => async ( + dispatch: Dispatch ): Promise => { const annotations = await api.getAnnotations(indexUrl, since, until) dispatch(loadAnnotations(annotations)) } export const deleteAnnotationAsync = ( - annotation: AnnotationInterface + annotation: AnnotationData.AnnotationInterface ) => async dispatch => { await api.deleteAnnotation(annotation) dispatch(deleteAnnotation(annotation)) } export const updateAnnotationAsync = ( - annotation: AnnotationInterface + annotation: AnnotationData.AnnotationInterface ) => async dispatch => { await api.updateAnnotation(annotation) dispatch(updateAnnotation(annotation)) diff --git a/ui/src/shared/components/Annotations.tsx b/ui/src/shared/components/Annotations.tsx index 6190530f93..31ff68a337 100644 --- a/ui/src/shared/components/Annotations.tsx +++ b/ui/src/shared/components/Annotations.tsx @@ -18,7 +18,7 @@ import {visibleAnnotations} from 'src/shared/annotations/helpers' import {ErrorHandling} from 'src/shared/decorators/errors' import {AnnotationInterface, DygraphClass, Source} from 'src/types' -import {UpdateAnnotationAction} from 'src/shared/actions/annotations' +import {UpdateAnnotationAction} from 'src/types/actions/annotations' interface Props { dWidth: number diff --git a/ui/src/shared/reducers/annotations.ts b/ui/src/shared/reducers/annotations.ts index f1c3ebb657..b8c0b29b23 100644 --- a/ui/src/shared/reducers/annotations.ts +++ b/ui/src/shared/reducers/annotations.ts @@ -1,6 +1,6 @@ import {ADDING, EDITING, TEMP_ANNOTATION} from 'src/shared/annotations/helpers' -import {Action} from 'src/shared/actions/annotations' +import {Action} from 'src/types/actions/annotations' import {AnnotationInterface} from 'src/types' export interface AnnotationState { diff --git a/ui/src/types/actions/annotations.ts b/ui/src/types/actions/annotations.ts new file mode 100644 index 0000000000..12f99f0546 --- /dev/null +++ b/ui/src/types/actions/annotations.ts @@ -0,0 +1,82 @@ +import {Dispatch} from 'redux' +import * as AnnotationData from 'src/types/annotations' + +export type Action = + | EditingAnnotationAction + | DismissEditingAnnotationAction + | AddingAnnotationAction + | AddingAnnotationSuccessAction + | DismissAddingAnnotationAction + | MouseEnterTempAnnotationAction + | MouseLeaveTempAnnotationAction + | LoadAnnotationsAction + | UpdateAnnotationAction + | DeleteAnnotationAction + | AddAnnotationAction + +export interface EditingAnnotationAction { + type: 'EDITING_ANNOTATION' +} + +export type DismissEditingAnnotationActionCreator = () => DismissEditingAnnotationAction + +export interface DismissEditingAnnotationAction { + type: 'DISMISS_EDITING_ANNOTATION' +} + +export interface AddingAnnotationAction { + type: 'ADDING_ANNOTATION' +} + +export interface AddingAnnotationSuccessAction { + type: 'ADDING_ANNOTATION_SUCCESS' +} + +export interface DismissAddingAnnotationAction { + type: 'DISMISS_ADDING_ANNOTATION' +} + +export interface MouseEnterTempAnnotationAction { + type: 'MOUSEENTER_TEMP_ANNOTATION' +} + +export interface MouseLeaveTempAnnotationAction { + type: 'MOUSELEAVE_TEMP_ANNOTATION' +} + +export interface LoadAnnotationsAction { + type: 'LOAD_ANNOTATIONS' + payload: { + annotations: AnnotationData.AnnotationInterface[] + } +} + +export interface UpdateAnnotationAction { + type: 'UPDATE_ANNOTATION' + payload: { + annotation: AnnotationData.AnnotationInterface + } +} + +export interface DeleteAnnotationAction { + type: 'DELETE_ANNOTATION' + payload: { + annotation: AnnotationData.AnnotationInterface + } +} + +export interface AddAnnotationAction { + type: 'ADD_ANNOTATION' + payload: { + annotation: AnnotationData.AnnotationInterface + } +} + +export type GetAnnotationsDispatcher = ( + indexUrl: string, + annotationRange: AnnotationData.AnnotationRange +) => GetAnnotationsThunk + +export type GetAnnotationsThunk = ( + dispatch: Dispatch +) => Promise diff --git a/ui/src/types/annotations.ts b/ui/src/types/annotations.ts index e35bb06285..595a641814 100644 --- a/ui/src/types/annotations.ts +++ b/ui/src/types/annotations.ts @@ -6,3 +6,8 @@ export interface AnnotationInterface { type: string links: {self: string} } + +export interface AnnotationRange { + since: number + until: number +} From c11205199ef0922c2f2caa03230b65db97d45fc4 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:04:09 -0700 Subject: [PATCH 25/49] Rename types/actions/dashboard.ts to dashboards.ts for consistency --- ui/src/dashboards/actions/index.ts | 2 +- ui/src/dashboards/components/CellEditorOverlay.tsx | 2 +- ui/src/dashboards/containers/DashboardPage.tsx | 2 +- ui/src/types/actions/{dashboard.ts => dashboards.ts} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename ui/src/types/actions/{dashboard.ts => dashboards.ts} (100%) diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index b93e1615c7..8b2b867f6f 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -68,7 +68,7 @@ import { URLQueryParams, } from 'src/types' import * as DashboardData from 'src/types/dashboard' -import * as DashboardActions from 'src/types/actions/dashboard' +import * as DashboardActions from 'src/types/actions/dashboards' import * as DashboardAPIs from 'src/types/apis/dashboard' import * as DashboardReducers from 'src/types/reducers/dashboard' import * as AuthReducers from 'src/types/reducers/auth' diff --git a/ui/src/dashboards/components/CellEditorOverlay.tsx b/ui/src/dashboards/components/CellEditorOverlay.tsx index 3c77bcf0f0..08d17eaad5 100644 --- a/ui/src/dashboards/components/CellEditorOverlay.tsx +++ b/ui/src/dashboards/components/CellEditorOverlay.tsx @@ -42,7 +42,7 @@ import { Status, } from 'src/types' import {ColorString, ColorNumber} from 'src/types/colors' -import * as DashboardActions from 'src/types/actions/dashboard' +import * as DashboardActions from 'src/types/actions/dashboards' import {SourceOption} from 'src/dashboards/components/OverlayControls' type QueryTransitions = typeof queryTransitions diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index bfe93fb7c6..fa31ad2cf3 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -64,7 +64,7 @@ import {ColorNumber, ColorString} from 'src/types/colors' import * as AnnotationActions from 'src/types/actions/annotations' import * as AppActions from 'src/shared/actions/app' import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay' -import * as DashboardActions from 'src/types/actions/dashboard' +import * as DashboardActions from 'src/types/actions/dashboards' import * as ErrorActions from 'src/types/actions/error' import * as NotificationActions from 'src/shared/actions/notifications' diff --git a/ui/src/types/actions/dashboard.ts b/ui/src/types/actions/dashboards.ts similarity index 100% rename from ui/src/types/actions/dashboard.ts rename to ui/src/types/actions/dashboards.ts From 7d4332bb6f7e3ddc7fe566e1aea7d963c0162259 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:05:07 -0700 Subject: [PATCH 26/49] Rename types/actions/error.ts to errors.ts for consistency --- ui/src/index.tsx | 2 +- ui/src/shared/actions/errors.ts | 2 +- ui/src/types/actions/error.ts | 2 +- ui/src/types/{error.ts => errors.ts} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename ui/src/types/{error.ts => errors.ts} (100%) diff --git a/ui/src/index.tsx b/ui/src/index.tsx index a7c39fefc7..2f6aae6aa1 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -49,7 +49,7 @@ import {notify} from 'src/shared/actions/notifications' import 'src/style/chronograf.scss' import {HEARTBEAT_INTERVAL} from 'src/shared/constants' -import * as ErrorData from 'src/types/error' +import * as ErrorData from 'src/types/errors' const errorsQueue = [] diff --git a/ui/src/shared/actions/errors.ts b/ui/src/shared/actions/errors.ts index e00b5e1f91..40ad2fefaa 100644 --- a/ui/src/shared/actions/errors.ts +++ b/ui/src/shared/actions/errors.ts @@ -1,4 +1,4 @@ -import * as ErrorData from 'src/types/error' +import * as ErrorData from 'src/types/errors' import * as ErrorActions from 'src/types/actions/error' export const errorThrown = ( diff --git a/ui/src/types/actions/error.ts b/ui/src/types/actions/error.ts index 185def97ed..715b229259 100644 --- a/ui/src/types/actions/error.ts +++ b/ui/src/types/actions/error.ts @@ -1,4 +1,4 @@ -import * as ErrorData from 'src/types/error' +import * as ErrorData from 'src/types/errors' export type ErrorThrownActionCreator = ( error: ErrorData.ErrorDescription, diff --git a/ui/src/types/error.ts b/ui/src/types/errors.ts similarity index 100% rename from ui/src/types/error.ts rename to ui/src/types/errors.ts From 967bc8173a61ae83d1d6649925ca4737ebdf573d Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:06:26 -0700 Subject: [PATCH 27/49] Rename types/reducers/dashboard.ts to plural for consistency --- ui/src/dashboards/actions/index.ts | 2 +- ui/src/types/actions/dashboards.ts | 2 +- ui/src/types/reducers/{dashboard.ts => dashboards.ts} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename ui/src/types/reducers/{dashboard.ts => dashboards.ts} (100%) diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index 8b2b867f6f..97fee41a63 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -70,7 +70,7 @@ import { import * as DashboardData from 'src/types/dashboard' import * as DashboardActions from 'src/types/actions/dashboards' import * as DashboardAPIs from 'src/types/apis/dashboard' -import * as DashboardReducers from 'src/types/reducers/dashboard' +import * as DashboardReducers from 'src/types/reducers/dashboards' import * as AuthReducers from 'src/types/reducers/auth' import * as NotificationActions from 'src/shared/actions/notifications' import * as ErrorActions from 'src/types/actions/error' diff --git a/ui/src/types/actions/dashboards.ts b/ui/src/types/actions/dashboards.ts index c28c320390..51729344c8 100644 --- a/ui/src/types/actions/dashboards.ts +++ b/ui/src/types/actions/dashboards.ts @@ -7,7 +7,7 @@ import * as QueryData from 'src/types/query' import * as TempVarData from 'src/types/tempVars' import * as ErrorActions from 'src/types/actions/error' import * as NotificationActions from 'src/shared/actions/notifications' -import * as DashboardReducers from 'src/types/reducers/dashboard' +import * as DashboardReducers from 'src/types/reducers/dashboards' import {Location} from 'history' export type LoadDashboardsActionCreator = ( diff --git a/ui/src/types/reducers/dashboard.ts b/ui/src/types/reducers/dashboards.ts similarity index 100% rename from ui/src/types/reducers/dashboard.ts rename to ui/src/types/reducers/dashboards.ts From c7e46bbaee0133824efabb4ca2092e72be56212c Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:07:29 -0700 Subject: [PATCH 28/49] Rename types/actions/error.ts to plural for consistency --- ui/src/dashboards/actions/index.ts | 2 +- ui/src/dashboards/containers/DashboardPage.tsx | 2 +- ui/src/shared/actions/errors.ts | 2 +- ui/src/types/actions/dashboards.ts | 2 +- ui/src/types/actions/{error.ts => errors.ts} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename ui/src/types/actions/{error.ts => errors.ts} (100%) diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index 97fee41a63..be1e1502c7 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -73,7 +73,7 @@ import * as DashboardAPIs from 'src/types/apis/dashboard' import * as DashboardReducers from 'src/types/reducers/dashboards' import * as AuthReducers from 'src/types/reducers/auth' import * as NotificationActions from 'src/shared/actions/notifications' -import * as ErrorActions from 'src/types/actions/error' +import * as ErrorActions from 'src/types/actions/errors' import {LocationAction} from 'react-router-redux' export const loadDashboards: DashboardActions.LoadDashboardsActionCreator = ( diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index fa31ad2cf3..1f8433e044 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -65,7 +65,7 @@ import * as AnnotationActions from 'src/types/actions/annotations' import * as AppActions from 'src/shared/actions/app' import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay' import * as DashboardActions from 'src/types/actions/dashboards' -import * as ErrorActions from 'src/types/actions/error' +import * as ErrorActions from 'src/types/actions/errors' import * as NotificationActions from 'src/shared/actions/notifications' interface DashboardActions { diff --git a/ui/src/shared/actions/errors.ts b/ui/src/shared/actions/errors.ts index 40ad2fefaa..f74cff97cf 100644 --- a/ui/src/shared/actions/errors.ts +++ b/ui/src/shared/actions/errors.ts @@ -1,5 +1,5 @@ import * as ErrorData from 'src/types/errors' -import * as ErrorActions from 'src/types/actions/error' +import * as ErrorActions from 'src/types/actions/errors' export const errorThrown = ( error: ErrorData.ErrorDescription, diff --git a/ui/src/types/actions/dashboards.ts b/ui/src/types/actions/dashboards.ts index 51729344c8..a3a61d7077 100644 --- a/ui/src/types/actions/dashboards.ts +++ b/ui/src/types/actions/dashboards.ts @@ -5,7 +5,7 @@ import {Source} from 'src/types' import * as DashboardData from 'src/types/dashboard' import * as QueryData from 'src/types/query' import * as TempVarData from 'src/types/tempVars' -import * as ErrorActions from 'src/types/actions/error' +import * as ErrorActions from 'src/types/actions/errors' import * as NotificationActions from 'src/shared/actions/notifications' import * as DashboardReducers from 'src/types/reducers/dashboards' import {Location} from 'history' diff --git a/ui/src/types/actions/error.ts b/ui/src/types/actions/errors.ts similarity index 100% rename from ui/src/types/actions/error.ts rename to ui/src/types/actions/errors.ts From 2626cf89558c1fd2ebf87f6d5ed8c6456f7e62b5 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:08:57 -0700 Subject: [PATCH 29/49] Rename types/dashboard.ts to plural for consistency --- ui/src/dashboards/actions/cellEditorOverlay.ts | 4 ++-- ui/src/dashboards/actions/index.ts | 2 +- ui/src/dashboards/components/DashboardEmpty.tsx | 2 +- ui/src/dashboards/components/DashboardHeader.tsx | 2 +- ui/src/dashboards/components/GraphOptionsDecimalPlaces.tsx | 2 +- ui/src/dashboards/components/TableOptions.tsx | 2 +- ui/src/dashboards/components/Visualization.tsx | 2 +- ui/src/dashboards/constants/cellEditor.ts | 2 +- ui/src/dashboards/constants/index.ts | 2 +- ui/src/dashboards/containers/DashboardPage.tsx | 2 +- ui/src/dashboards/containers/DashboardsPage.tsx | 2 +- ui/src/dashboards/graphics/graph.tsx | 2 +- ui/src/dashboards/reducers/cellEditorOverlay.ts | 2 +- ui/src/dashboards/utils/cellGetters.ts | 2 +- ui/src/dashboards/utils/tableGraph.ts | 2 +- ui/src/shared/components/LayoutCellMenu.tsx | 2 +- ui/src/shared/components/SingleStat.tsx | 2 +- ui/src/shared/components/TableGraph.tsx | 2 +- ui/src/shared/components/WidgetCell.tsx | 2 +- ui/src/shared/constants/colorOperations.ts | 2 +- ui/src/shared/constants/index.tsx | 2 +- ui/src/status/fixtures.ts | 2 +- ui/src/types/actions/dashboards.ts | 2 +- ui/src/types/apis/dashboard.ts | 2 +- ui/src/types/{dashboard.ts => dashboards.ts} | 0 ui/test/fixtures/index.ts | 4 ++-- 26 files changed, 27 insertions(+), 27 deletions(-) rename ui/src/types/{dashboard.ts => dashboards.ts} (100%) diff --git a/ui/src/dashboards/actions/cellEditorOverlay.ts b/ui/src/dashboards/actions/cellEditorOverlay.ts index b1f91b7b54..018444bad6 100644 --- a/ui/src/dashboards/actions/cellEditorOverlay.ts +++ b/ui/src/dashboards/actions/cellEditorOverlay.ts @@ -1,12 +1,12 @@ import {Cell} from 'src/types' -import {CellType, ThresholdType} from 'src/types/dashboard' +import {CellType, ThresholdType} from 'src/types/dashboards' import {ColorNumber, ColorString} from 'src/types/colors' import { Axes, DecimalPlaces, FieldOption, TableOptions, -} from 'src/types/dashboard' +} from 'src/types/dashboards' export type Action = | ShowCellEditorOverlayAction diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index be1e1502c7..c15e3b5d12 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -67,7 +67,7 @@ import { TimeRange, URLQueryParams, } from 'src/types' -import * as DashboardData from 'src/types/dashboard' +import * as DashboardData from 'src/types/dashboards' import * as DashboardActions from 'src/types/actions/dashboards' import * as DashboardAPIs from 'src/types/apis/dashboard' import * as DashboardReducers from 'src/types/reducers/dashboards' diff --git a/ui/src/dashboards/components/DashboardEmpty.tsx b/ui/src/dashboards/components/DashboardEmpty.tsx index 5a450dbfd8..c514699750 100644 --- a/ui/src/dashboards/components/DashboardEmpty.tsx +++ b/ui/src/dashboards/components/DashboardEmpty.tsx @@ -1,5 +1,5 @@ import React, {Component} from 'react' -import {Cell} from 'src/types/dashboard' +import {Cell} from 'src/types/dashboards' import {connect} from 'react-redux' import {bindActionCreators} from 'redux' diff --git a/ui/src/dashboards/components/DashboardHeader.tsx b/ui/src/dashboards/components/DashboardHeader.tsx index ba320a9c59..ecf04c380b 100644 --- a/ui/src/dashboards/components/DashboardHeader.tsx +++ b/ui/src/dashboards/components/DashboardHeader.tsx @@ -12,7 +12,7 @@ import DashboardHeaderEdit from 'src/dashboards/components/DashboardHeaderEdit' import DashboardSwitcher from 'src/dashboards/components/DashboardSwitcher' import {Dashboard, TimeRange} from 'src/types' -import {DashboardName} from 'src/types/dashboard' +import {DashboardName} from 'src/types/dashboards' import * as AppActions from 'src/shared/actions/app' interface Props { diff --git a/ui/src/dashboards/components/GraphOptionsDecimalPlaces.tsx b/ui/src/dashboards/components/GraphOptionsDecimalPlaces.tsx index 75de17b1b8..0a1c8c390d 100644 --- a/ui/src/dashboards/components/GraphOptionsDecimalPlaces.tsx +++ b/ui/src/dashboards/components/GraphOptionsDecimalPlaces.tsx @@ -2,7 +2,7 @@ import React, {PureComponent} from 'react' import {ErrorHandling} from 'src/shared/decorators/errors' import OptIn from 'src/shared/components/OptIn' -import {DecimalPlaces} from 'src/types/dashboard' +import {DecimalPlaces} from 'src/types/dashboards' interface Props extends DecimalPlaces { onDecimalPlacesChange: (decimalPlaces: DecimalPlaces) => void diff --git a/ui/src/dashboards/components/TableOptions.tsx b/ui/src/dashboards/components/TableOptions.tsx index 8527929b59..9d365b747d 100644 --- a/ui/src/dashboards/components/TableOptions.tsx +++ b/ui/src/dashboards/components/TableOptions.tsx @@ -24,7 +24,7 @@ import { import {DEFAULT_TIME_FIELD} from 'src/dashboards/constants' import {ErrorHandling} from 'src/shared/decorators/errors' -import {DecimalPlaces} from 'src/types/dashboard' +import {DecimalPlaces} from 'src/types/dashboards' import {QueryConfig} from 'src/types/query' interface DropdownOption { diff --git a/ui/src/dashboards/components/Visualization.tsx b/ui/src/dashboards/components/Visualization.tsx index ddbbc13b93..98b9d440ce 100644 --- a/ui/src/dashboards/components/Visualization.tsx +++ b/ui/src/dashboards/components/Visualization.tsx @@ -15,7 +15,7 @@ import { DecimalPlaces, FieldOption, CellType, -} from 'src/types/dashboard' +} from 'src/types/dashboards' import {ColorString, ColorNumber} from 'src/types/colors' interface Props { diff --git a/ui/src/dashboards/constants/cellEditor.ts b/ui/src/dashboards/constants/cellEditor.ts index a22bc262d6..a7f941bd9f 100644 --- a/ui/src/dashboards/constants/cellEditor.ts +++ b/ui/src/dashboards/constants/cellEditor.ts @@ -1,6 +1,6 @@ import {DEFAULT_TABLE_OPTIONS} from 'src/dashboards/constants' import {stringifyColorValues} from 'src/shared/constants/colorOperations' -import {CellType, Axis} from 'src/types/dashboard' +import {CellType, Axis} from 'src/types/dashboards' import {ColorString, ColorNumber} from 'src/types/colors' export const initializeOptions = (cellType: CellType) => { diff --git a/ui/src/dashboards/constants/index.ts b/ui/src/dashboards/constants/index.ts index 99ec7a64a3..e72994dae1 100644 --- a/ui/src/dashboards/constants/index.ts +++ b/ui/src/dashboards/constants/index.ts @@ -3,7 +3,7 @@ import { DEFAULT_FIX_FIRST_COLUMN, } from 'src/shared/constants/tableGraph' import {Cell, QueryConfig} from 'src/types' -import {CellType, Dashboard, DecimalPlaces} from 'src/types/dashboard' +import {CellType, Dashboard, DecimalPlaces} from 'src/types/dashboards' export const UNTITLED_GRAPH: string = 'Untitled Graph' diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 1f8433e044..1a2443561c 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -59,7 +59,7 @@ import { TemplateValue, TimeRange, } from 'src/types' -import {DashboardName} from 'src/types/dashboard' +import {DashboardName} from 'src/types/dashboards' import {ColorNumber, ColorString} from 'src/types/colors' import * as AnnotationActions from 'src/types/actions/annotations' import * as AppActions from 'src/shared/actions/app' diff --git a/ui/src/dashboards/containers/DashboardsPage.tsx b/ui/src/dashboards/containers/DashboardsPage.tsx index f3452b1c29..450b370053 100644 --- a/ui/src/dashboards/containers/DashboardsPage.tsx +++ b/ui/src/dashboards/containers/DashboardsPage.tsx @@ -26,7 +26,7 @@ import { import {Source, Dashboard} from 'src/types' import {Notification} from 'src/types/notifications' -import {DashboardFile} from 'src/types/dashboard' +import {DashboardFile} from 'src/types/dashboards' interface Props { source: Source diff --git a/ui/src/dashboards/graphics/graph.tsx b/ui/src/dashboards/graphics/graph.tsx index 971e0b8dfa..1f235160ed 100644 --- a/ui/src/dashboards/graphics/graph.tsx +++ b/ui/src/dashboards/graphics/graph.tsx @@ -1,6 +1,6 @@ import React, {ReactElement} from 'react' -import {CellType} from 'src/types/dashboard' +import {CellType} from 'src/types/dashboards' type Graphic = ReactElement diff --git a/ui/src/dashboards/reducers/cellEditorOverlay.ts b/ui/src/dashboards/reducers/cellEditorOverlay.ts index c72d744b95..bf0e8e61c8 100644 --- a/ui/src/dashboards/reducers/cellEditorOverlay.ts +++ b/ui/src/dashboards/reducers/cellEditorOverlay.ts @@ -16,7 +16,7 @@ import { import {initializeOptions} from 'src/dashboards/constants/cellEditor' import {Action} from 'src/dashboards/actions/cellEditorOverlay' import {CellType, Cell} from 'src/types' -import {ThresholdType, TableOptions} from 'src/types/dashboard' +import {ThresholdType, TableOptions} from 'src/types/dashboards' import {ThresholdColor, GaugeColor, LineColor} from 'src/types/colors' interface CEOInitialState { diff --git a/ui/src/dashboards/utils/cellGetters.ts b/ui/src/dashboards/utils/cellGetters.ts index e76334166d..162e5c022d 100644 --- a/ui/src/dashboards/utils/cellGetters.ts +++ b/ui/src/dashboards/utils/cellGetters.ts @@ -1,5 +1,5 @@ import {NEW_DEFAULT_DASHBOARD_CELL} from 'src/dashboards/constants' -import {Cell, CellType, Dashboard} from 'src/types/dashboard' +import {Cell, CellType, Dashboard} from 'src/types/dashboards' import {NewDefaultCell, UNTITLED_GRAPH} from 'src/dashboards/constants' const getMostCommonValue = (values: number[]): number => { diff --git a/ui/src/dashboards/utils/tableGraph.ts b/ui/src/dashboards/utils/tableGraph.ts index b84e3acd07..f4e842a1ba 100644 --- a/ui/src/dashboards/utils/tableGraph.ts +++ b/ui/src/dashboards/utils/tableGraph.ts @@ -13,7 +13,7 @@ import { FieldOption, TableOptions, DecimalPlaces, -} from 'src/types/dashboard' +} from 'src/types/dashboards' import {TimeSeriesValue} from 'src/types/series' interface ColumnWidths { diff --git a/ui/src/shared/components/LayoutCellMenu.tsx b/ui/src/shared/components/LayoutCellMenu.tsx index 8253ad04e5..ed4636cab9 100644 --- a/ui/src/shared/components/LayoutCellMenu.tsx +++ b/ui/src/shared/components/LayoutCellMenu.tsx @@ -11,7 +11,7 @@ import CustomTimeIndicator from 'src/shared/components/CustomTimeIndicator' import Authorized, {EDITOR_ROLE} from 'src/auth/Authorized' import {EDITING} from 'src/shared/annotations/helpers' import {cellSupportsAnnotations} from 'src/shared/constants/index' -import {Cell} from 'src/types/dashboard' +import {Cell} from 'src/types/dashboards' import {QueryConfig} from 'src/types/query' import { diff --git a/ui/src/shared/components/SingleStat.tsx b/ui/src/shared/components/SingleStat.tsx index 1b89456539..cb64f54005 100644 --- a/ui/src/shared/components/SingleStat.tsx +++ b/ui/src/shared/components/SingleStat.tsx @@ -7,7 +7,7 @@ import {SMALL_CELL_HEIGHT} from 'src/shared/graphs/helpers' import {DYGRAPH_CONTAINER_V_MARGIN} from 'src/shared/constants' import {generateThresholdsListHexs} from 'src/shared/constants/colorOperations' import {ColorNumber} from 'src/types/colors' -import {CellType} from 'src/types/dashboard' +import {CellType} from 'src/types/dashboards' import {Data} from 'src/types/dygraphs' import {ErrorHandling} from 'src/shared/decorators/errors' diff --git a/ui/src/shared/components/TableGraph.tsx b/ui/src/shared/components/TableGraph.tsx index 4b2a2c48c6..6d2af48bcd 100644 --- a/ui/src/shared/components/TableGraph.tsx +++ b/ui/src/shared/components/TableGraph.tsx @@ -36,7 +36,7 @@ import { FieldOption, DecimalPlaces, Sort, -} from 'src/types/dashboard' +} from 'src/types/dashboards' interface Label { label: string diff --git a/ui/src/shared/components/WidgetCell.tsx b/ui/src/shared/components/WidgetCell.tsx index 259dbdfa24..f9ce6f95ee 100644 --- a/ui/src/shared/components/WidgetCell.tsx +++ b/ui/src/shared/components/WidgetCell.tsx @@ -4,7 +4,7 @@ import AlertsApp from 'src/alerts/containers/AlertsApp' import NewsFeed from 'src/status/components/NewsFeed' import GettingStarted from 'src/status/components/GettingStarted' -import {Cell} from 'src/types/dashboard' +import {Cell} from 'src/types/dashboards' import {Source} from 'src/types/sources' import {TimeRange} from 'src/types/query' import {RECENT_ALERTS_LIMIT} from 'src/status/constants' diff --git a/ui/src/shared/constants/colorOperations.ts b/ui/src/shared/constants/colorOperations.ts index 0c011709a4..6e7780c150 100644 --- a/ui/src/shared/constants/colorOperations.ts +++ b/ui/src/shared/constants/colorOperations.ts @@ -7,7 +7,7 @@ import { THRESHOLD_TYPE_TEXT, } from 'src/shared/constants/thresholds' -import {CellType} from 'src/types/dashboard' +import {CellType} from 'src/types/dashboards' const getLegibleTextColor = bgColorHex => { const darkText = '#292933' diff --git a/ui/src/shared/constants/index.tsx b/ui/src/shared/constants/index.tsx index 216ed85f15..10f1931b91 100644 --- a/ui/src/shared/constants/index.tsx +++ b/ui/src/shared/constants/index.tsx @@ -1,7 +1,7 @@ import _ from 'lodash' import {TemplateValueType, TemplateType} from 'src/types' -import {CellType} from 'src/types/dashboard' +import {CellType} from 'src/types/dashboards' export const NO_CELL = 'none' diff --git a/ui/src/status/fixtures.ts b/ui/src/status/fixtures.ts index 95c44b5aa6..116b07d2c2 100644 --- a/ui/src/status/fixtures.ts +++ b/ui/src/status/fixtures.ts @@ -3,7 +3,7 @@ import {TEMP_VAR_DASHBOARD_TIME} from 'src/shared/constants' import {NEW_DEFAULT_DASHBOARD_CELL} from 'src/dashboards/constants/index' import {DEFAULT_AXIS} from 'src/dashboards/constants/cellEditor' import {Cell, CellQuery, Axes} from 'src/types' -import {CellType} from 'src/types/dashboard' +import {CellType} from 'src/types/dashboards' const emptyQuery: CellQuery = { query: '', diff --git a/ui/src/types/actions/dashboards.ts b/ui/src/types/actions/dashboards.ts index a3a61d7077..ac50659e7f 100644 --- a/ui/src/types/actions/dashboards.ts +++ b/ui/src/types/actions/dashboards.ts @@ -2,7 +2,7 @@ import {Dispatch} from 'redux' import {InjectedRouter} from 'react-router' import {LocationAction} from 'react-router-redux' import {Source} from 'src/types' -import * as DashboardData from 'src/types/dashboard' +import * as DashboardData from 'src/types/dashboards' import * as QueryData from 'src/types/query' import * as TempVarData from 'src/types/tempVars' import * as ErrorActions from 'src/types/actions/errors' diff --git a/ui/src/types/apis/dashboard.ts b/ui/src/types/apis/dashboard.ts index 07d7b7debc..af470c7dd9 100644 --- a/ui/src/types/apis/dashboard.ts +++ b/ui/src/types/apis/dashboard.ts @@ -1,4 +1,4 @@ -import {Dashboard} from 'src/types/dashboard' +import {Dashboard} from 'src/types/dashboards' export interface DashboardsResponse { dashboards: Dashboard[] diff --git a/ui/src/types/dashboard.ts b/ui/src/types/dashboards.ts similarity index 100% rename from ui/src/types/dashboard.ts rename to ui/src/types/dashboards.ts diff --git a/ui/test/fixtures/index.ts b/ui/test/fixtures/index.ts index 234fea24ee..172651d2fb 100644 --- a/ui/test/fixtures/index.ts +++ b/ui/test/fixtures/index.ts @@ -15,9 +15,9 @@ import { TableOptions, FieldOption, DecimalPlaces, -} from 'src/types/dashboard' +} from 'src/types/dashboards' import {LineColor, ColorNumber} from 'src/types/colors' -import {CellType} from 'src/types/dashboard' +import {CellType} from 'src/types/dashboards' export const sourceLinks: SourceLinks = { services: '/chronograf/v1/sources/4', From d74ad08c2c19fabe99c296fd23d04016035e9261 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:14:21 -0700 Subject: [PATCH 30/49] Fix dashboards.ts import in src/types/index.js --- ui/src/types/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/types/index.ts b/ui/src/types/index.ts index 19b89d98b7..7c9db25cbd 100644 --- a/ui/src/types/index.ts +++ b/ui/src/types/index.ts @@ -1,7 +1,7 @@ import {LayoutCell, LayoutQuery} from './layouts' import {Service, NewService} from './services' import {AuthLinks, Organization, Role, User, Me} from './auth' -import {Cell, CellQuery, Legend, Axes, Dashboard, CellType} from './dashboard' +import {Cell, CellQuery, Legend, Axes, Dashboard, CellType} from './dashboards' import { Template, TemplateQuery, From 28b919908be67f71961e1155c460190bd5a44c45 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:14:46 -0700 Subject: [PATCH 31/49] Refactor notifications types file structure & imports to new style --- ui/src/dashboards/actions/index.ts | 2 +- .../dashboards/containers/DashboardPage.tsx | 2 +- ui/src/shared/actions/notifications.ts | 33 ++++--------------- ui/src/shared/reducers/notifications.ts | 2 +- ui/src/sources/containers/SourcePage.tsx | 11 +++---- ui/src/types/actions/dashboards.ts | 2 +- ui/src/types/actions/notifications.ts | 23 +++++++++++++ 7 files changed, 38 insertions(+), 37 deletions(-) create mode 100644 ui/src/types/actions/notifications.ts diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index c15e3b5d12..c7a689a134 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -72,7 +72,7 @@ import * as DashboardActions from 'src/types/actions/dashboards' import * as DashboardAPIs from 'src/types/apis/dashboard' import * as DashboardReducers from 'src/types/reducers/dashboards' import * as AuthReducers from 'src/types/reducers/auth' -import * as NotificationActions from 'src/shared/actions/notifications' +import * as NotificationActions from 'src/types/actions/notifications' import * as ErrorActions from 'src/types/actions/errors' import {LocationAction} from 'react-router-redux' diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 1a2443561c..d074ffea14 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -66,7 +66,7 @@ import * as AppActions from 'src/shared/actions/app' import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay' import * as DashboardActions from 'src/types/actions/dashboards' import * as ErrorActions from 'src/types/actions/errors' -import * as NotificationActions from 'src/shared/actions/notifications' +import * as NotificationActions from 'src/types/actions/notifications' interface DashboardActions { setDashTimeV1: DashboardActions.SetDashTimeV1ActionCreator diff --git a/ui/src/shared/actions/notifications.ts b/ui/src/shared/actions/notifications.ts index c5c6729fee..ded2d75cf3 100644 --- a/ui/src/shared/actions/notifications.ts +++ b/ui/src/shared/actions/notifications.ts @@ -1,36 +1,15 @@ import {Notification} from 'src/types' +import * as NotificationActions from 'src/types/actions/notifications' -export type Action = PublishNotificationAction | ActionDismissNotification - -// Publish notification -export type PublishNotificationActionCreator = ( - n: Notification -) => PublishNotificationAction - -export interface PublishNotificationAction { - type: 'PUBLISH_NOTIFICATION' - payload: { - notification: Notification - } -} - -export const notify: PublishNotificationActionCreator = ( +export const notify: NotificationActions.PublishNotificationActionCreator = ( notification: Notification -): PublishNotificationAction => ({ +): NotificationActions.PublishNotificationAction => ({ type: 'PUBLISH_NOTIFICATION', payload: {notification}, }) - -// Dismiss notification -export type DismissNotification = (id: string) => ActionDismissNotification -export interface ActionDismissNotification { - type: 'DISMISS_NOTIFICATION' - payload: { - id: string - } -} - -export const dismissNotification = (id: string): ActionDismissNotification => ({ +export const dismissNotification = ( + id: string +): NotificationActions.DismissNotificationAction => ({ type: 'DISMISS_NOTIFICATION', payload: {id}, }) diff --git a/ui/src/shared/reducers/notifications.ts b/ui/src/shared/reducers/notifications.ts index cb9f6fd92f..8c9d938d40 100644 --- a/ui/src/shared/reducers/notifications.ts +++ b/ui/src/shared/reducers/notifications.ts @@ -1,5 +1,5 @@ import uuid from 'uuid' -import {Action} from 'src/shared/actions/notifications' +import {Action} from 'src/types/actions/notifications' import {Notification} from 'src/types' export const initialState: Notification[] = [] diff --git a/ui/src/sources/containers/SourcePage.tsx b/ui/src/sources/containers/SourcePage.tsx index 6f2619960a..306029bdaf 100644 --- a/ui/src/sources/containers/SourcePage.tsx +++ b/ui/src/sources/containers/SourcePage.tsx @@ -9,10 +9,7 @@ import { AddSource, UpdateSource, } from 'src/shared/actions/sources' -import { - notify as notifyAction, - PublishNotificationActionCreator, -} from 'src/shared/actions/notifications' +import {notify as notifyAction} from 'src/shared/actions/notifications' import {connect} from 'react-redux' import Notifications from 'src/shared/components/Notifications' @@ -20,7 +17,6 @@ import SourceForm from 'src/sources/components/SourceForm' import FancyScrollbar from 'src/shared/components/FancyScrollbar' import PageHeader from 'src/shared/components/PageHeader' import {DEFAULT_SOURCE} from 'src/shared/constants' -import {Source} from 'src/types' const INITIAL_PATH = '/sources/new' @@ -33,8 +29,11 @@ import { } from 'src/shared/copy/notifications' import {ErrorHandling} from 'src/shared/decorators/errors' +import {Source} from 'src/types' +import * as NotificationActions from 'src/types/actions/notifications' + interface Props extends WithRouterProps { - notify: PublishNotificationActionCreator + notify: NotificationActions.PublishNotificationActionCreator addSource: AddSource updateSource: UpdateSource } diff --git a/ui/src/types/actions/dashboards.ts b/ui/src/types/actions/dashboards.ts index ac50659e7f..02d7cf544f 100644 --- a/ui/src/types/actions/dashboards.ts +++ b/ui/src/types/actions/dashboards.ts @@ -6,7 +6,7 @@ import * as DashboardData from 'src/types/dashboards' import * as QueryData from 'src/types/query' import * as TempVarData from 'src/types/tempVars' import * as ErrorActions from 'src/types/actions/errors' -import * as NotificationActions from 'src/shared/actions/notifications' +import * as NotificationActions from 'src/types/actions/notifications' import * as DashboardReducers from 'src/types/reducers/dashboards' import {Location} from 'history' diff --git a/ui/src/types/actions/notifications.ts b/ui/src/types/actions/notifications.ts new file mode 100644 index 0000000000..e43d25ad12 --- /dev/null +++ b/ui/src/types/actions/notifications.ts @@ -0,0 +1,23 @@ +import {Notification} from 'src/types' + +export type Action = PublishNotificationAction | DismissNotificationAction + +export type PublishNotificationActionCreator = ( + n: Notification +) => PublishNotificationAction + +export interface PublishNotificationAction { + type: 'PUBLISH_NOTIFICATION' + payload: { + notification: Notification + } +} + +export type DismissNotification = (id: string) => DismissNotificationAction + +export interface DismissNotificationAction { + type: 'DISMISS_NOTIFICATION' + payload: { + id: string + } +} From a57055772aee70cc6873f3ceebaf3a0b61a85ea5 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:22:49 -0700 Subject: [PATCH 32/49] Refactor cellEditorOverlay types file structure & imports to new style --- .../dashboards/actions/cellEditorOverlay.ts | 149 +++--------------- .../dashboards/containers/DashboardPage.tsx | 2 +- .../dashboards/reducers/cellEditorOverlay.ts | 2 +- ui/src/types/actions/cellEditorOverlay.ts | 112 +++++++++++++ 4 files changed, 140 insertions(+), 125 deletions(-) create mode 100644 ui/src/types/actions/cellEditorOverlay.ts diff --git a/ui/src/dashboards/actions/cellEditorOverlay.ts b/ui/src/dashboards/actions/cellEditorOverlay.ts index 018444bad6..245894d60c 100644 --- a/ui/src/dashboards/actions/cellEditorOverlay.ts +++ b/ui/src/dashboards/actions/cellEditorOverlay.ts @@ -1,211 +1,114 @@ import {Cell} from 'src/types' -import {CellType, ThresholdType} from 'src/types/dashboards' import {ColorNumber, ColorString} from 'src/types/colors' -import { - Axes, - DecimalPlaces, - FieldOption, - TableOptions, -} from 'src/types/dashboards' +import * as DashboardData from 'src/types/dashboards' +import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay' -export type Action = - | ShowCellEditorOverlayAction - | HideCellEditorOverlayAction - | ChangeCellTypeAction - | RenameCellAction - | UpdateThresholdsListColorsAction - | UpdateThresholdsListTypeAction - | UpdateGaugeColorsAction - | UpdateAxesAction - | UpdateTableOptionsAction - | UpdateLineColorsAction - | ChangeTimeFormatAction - | ChangeDecimalPlacesAction - | UpdateFieldOptionsAction - -export type ShowCellEditorOverlayActionCreator = ( +export const showCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator = ( cell: Cell -) => ShowCellEditorOverlayAction - -interface ShowCellEditorOverlayAction { - type: 'SHOW_CELL_EDITOR_OVERLAY' - payload: { - cell: Cell - } -} -export const showCellEditorOverlay: ShowCellEditorOverlayActionCreator = ( - cell: Cell -): ShowCellEditorOverlayAction => ({ +): CellEditorOverlayActions.ShowCellEditorOverlayAction => ({ type: 'SHOW_CELL_EDITOR_OVERLAY', payload: { cell, }, }) -export type HideCellEditorOverlayActionCreator = () => HideCellEditorOverlayAction - -interface HideCellEditorOverlayAction { - type: 'HIDE_CELL_EDITOR_OVERLAY' -} -export const hideCellEditorOverlay = (): HideCellEditorOverlayAction => ({ +export const hideCellEditorOverlay = (): CellEditorOverlayActions.HideCellEditorOverlayAction => ({ type: 'HIDE_CELL_EDITOR_OVERLAY', }) -interface ChangeCellTypeAction { - type: 'CHANGE_CELL_TYPE' - payload: { - cellType: CellType - } -} - -export const changeCellType = (cellType: CellType): ChangeCellTypeAction => ({ +export const changeCellType = ( + cellType: DashboardData.CellType +): CellEditorOverlayActions.ChangeCellTypeAction => ({ type: 'CHANGE_CELL_TYPE', payload: { cellType, }, }) -interface RenameCellAction { - type: 'RENAME_CELL' - payload: { - cellName: string - } -} -export const renameCell = (cellName: string): RenameCellAction => ({ +export const renameCell = ( + cellName: string +): CellEditorOverlayActions.RenameCellAction => ({ type: 'RENAME_CELL', payload: { cellName, }, }) -interface UpdateThresholdsListColorsAction { - type: 'UPDATE_THRESHOLDS_LIST_COLORS' - payload: { - thresholdsListColors: ColorNumber[] - } -} export const updateThresholdsListColors = ( thresholdsListColors: ColorNumber[] -): UpdateThresholdsListColorsAction => ({ +): CellEditorOverlayActions.UpdateThresholdsListColorsAction => ({ type: 'UPDATE_THRESHOLDS_LIST_COLORS', payload: { thresholdsListColors, }, }) -interface UpdateThresholdsListTypeAction { - type: 'UPDATE_THRESHOLDS_LIST_TYPE' - payload: { - thresholdsListType: ThresholdType - } -} - export const updateThresholdsListType = ( - thresholdsListType: ThresholdType -): UpdateThresholdsListTypeAction => ({ + thresholdsListType: DashboardData.ThresholdType +): CellEditorOverlayActions.UpdateThresholdsListTypeAction => ({ type: 'UPDATE_THRESHOLDS_LIST_TYPE', payload: { thresholdsListType, }, }) -interface UpdateGaugeColorsAction { - type: 'UPDATE_GAUGE_COLORS' - payload: { - gaugeColors: ColorNumber[] - } -} export const updateGaugeColors = ( gaugeColors: ColorNumber[] -): UpdateGaugeColorsAction => ({ +): CellEditorOverlayActions.UpdateGaugeColorsAction => ({ type: 'UPDATE_GAUGE_COLORS', payload: { gaugeColors, }, }) -interface UpdateAxesAction { - type: 'UPDATE_AXES' - payload: { - axes: Axes - } -} -export const updateAxes = (axes: Axes): UpdateAxesAction => ({ +export const updateAxes = ( + axes: DashboardData.Axes +): CellEditorOverlayActions.UpdateAxesAction => ({ type: 'UPDATE_AXES', payload: { axes, }, }) -interface UpdateTableOptionsAction { - type: 'UPDATE_TABLE_OPTIONS' - payload: { - tableOptions: TableOptions - } -} export const updateTableOptions = ( - tableOptions: TableOptions -): UpdateTableOptionsAction => ({ + tableOptions: DashboardData.TableOptions +): CellEditorOverlayActions.UpdateTableOptionsAction => ({ type: 'UPDATE_TABLE_OPTIONS', payload: { tableOptions, }, }) -interface UpdateLineColorsAction { - type: 'UPDATE_LINE_COLORS' - payload: { - lineColors: ColorString[] - } -} export const updateLineColors = ( lineColors: ColorString[] -): UpdateLineColorsAction => ({ +): CellEditorOverlayActions.UpdateLineColorsAction => ({ type: 'UPDATE_LINE_COLORS', payload: { lineColors, }, }) -interface ChangeTimeFormatAction { - type: 'CHANGE_TIME_FORMAT' - payload: { - timeFormat: string - } -} export const changeTimeFormat = ( timeFormat: string -): ChangeTimeFormatAction => ({ +): CellEditorOverlayActions.ChangeTimeFormatAction => ({ type: 'CHANGE_TIME_FORMAT', payload: { timeFormat, }, }) -interface ChangeDecimalPlacesAction { - type: 'CHANGE_DECIMAL_PLACES' - payload: { - decimalPlaces: DecimalPlaces - } -} export const changeDecimalPlaces = ( - decimalPlaces: DecimalPlaces -): ChangeDecimalPlacesAction => ({ + decimalPlaces: DashboardData.DecimalPlaces +): CellEditorOverlayActions.ChangeDecimalPlacesAction => ({ type: 'CHANGE_DECIMAL_PLACES', payload: { decimalPlaces, }, }) -interface UpdateFieldOptionsAction { - type: 'UPDATE_FIELD_OPTIONS' - payload: { - fieldOptions: FieldOption[] - } -} export const updateFieldOptions = ( - fieldOptions: FieldOption[] -): UpdateFieldOptionsAction => ({ + fieldOptions: DashboardData.FieldOption[] +): CellEditorOverlayActions.UpdateFieldOptionsAction => ({ type: 'UPDATE_FIELD_OPTIONS', payload: { fieldOptions, diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index d074ffea14..55d8ed3435 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -63,7 +63,7 @@ import {DashboardName} from 'src/types/dashboards' import {ColorNumber, ColorString} from 'src/types/colors' import * as AnnotationActions from 'src/types/actions/annotations' import * as AppActions from 'src/shared/actions/app' -import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay' +import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay' import * as DashboardActions from 'src/types/actions/dashboards' import * as ErrorActions from 'src/types/actions/errors' import * as NotificationActions from 'src/types/actions/notifications' diff --git a/ui/src/dashboards/reducers/cellEditorOverlay.ts b/ui/src/dashboards/reducers/cellEditorOverlay.ts index bf0e8e61c8..8b6488c721 100644 --- a/ui/src/dashboards/reducers/cellEditorOverlay.ts +++ b/ui/src/dashboards/reducers/cellEditorOverlay.ts @@ -14,7 +14,7 @@ import { } from 'src/shared/constants/graphColorPalettes' import {initializeOptions} from 'src/dashboards/constants/cellEditor' -import {Action} from 'src/dashboards/actions/cellEditorOverlay' +import {Action} from 'src/types/actions/cellEditorOverlay' import {CellType, Cell} from 'src/types' import {ThresholdType, TableOptions} from 'src/types/dashboards' import {ThresholdColor, GaugeColor, LineColor} from 'src/types/colors' diff --git a/ui/src/types/actions/cellEditorOverlay.ts b/ui/src/types/actions/cellEditorOverlay.ts new file mode 100644 index 0000000000..0648c6cd1a --- /dev/null +++ b/ui/src/types/actions/cellEditorOverlay.ts @@ -0,0 +1,112 @@ +import {Cell} from 'src/types' +import {ColorNumber, ColorString} from 'src/types/colors' +import * as DashboardData from 'src/types/dashboards' + +export type Action = + | ShowCellEditorOverlayAction + | HideCellEditorOverlayAction + | ChangeCellTypeAction + | RenameCellAction + | UpdateThresholdsListColorsAction + | UpdateThresholdsListTypeAction + | UpdateGaugeColorsAction + | UpdateAxesAction + | UpdateTableOptionsAction + | UpdateLineColorsAction + | ChangeTimeFormatAction + | ChangeDecimalPlacesAction + | UpdateFieldOptionsAction + +export type ShowCellEditorOverlayActionCreator = ( + cell: Cell +) => ShowCellEditorOverlayAction + +export interface ShowCellEditorOverlayAction { + type: 'SHOW_CELL_EDITOR_OVERLAY' + payload: { + cell: Cell + } +} + +export type HideCellEditorOverlayActionCreator = () => HideCellEditorOverlayAction + +export interface HideCellEditorOverlayAction { + type: 'HIDE_CELL_EDITOR_OVERLAY' +} + +export interface ChangeCellTypeAction { + type: 'CHANGE_CELL_TYPE' + payload: { + cellType: DashboardData.CellType + } +} + +export interface RenameCellAction { + type: 'RENAME_CELL' + payload: { + cellName: string + } +} + +export interface UpdateThresholdsListColorsAction { + type: 'UPDATE_THRESHOLDS_LIST_COLORS' + payload: { + thresholdsListColors: ColorNumber[] + } +} + +export interface UpdateThresholdsListTypeAction { + type: 'UPDATE_THRESHOLDS_LIST_TYPE' + payload: { + thresholdsListType: DashboardData.ThresholdType + } +} + +export interface UpdateGaugeColorsAction { + type: 'UPDATE_GAUGE_COLORS' + payload: { + gaugeColors: ColorNumber[] + } +} + +export interface UpdateAxesAction { + type: 'UPDATE_AXES' + payload: { + axes: DashboardData.Axes + } +} + +export interface UpdateTableOptionsAction { + type: 'UPDATE_TABLE_OPTIONS' + payload: { + tableOptions: DashboardData.TableOptions + } +} + +export interface UpdateLineColorsAction { + type: 'UPDATE_LINE_COLORS' + payload: { + lineColors: ColorString[] + } +} + +export interface ChangeTimeFormatAction { + type: 'CHANGE_TIME_FORMAT' + payload: { + timeFormat: string + } +} + +export interface ChangeDecimalPlacesAction { + type: 'CHANGE_DECIMAL_PLACES' + payload: { + decimalPlaces: DashboardData.DecimalPlaces + } +} + +export interface UpdateFieldOptionsAction { + type: 'UPDATE_FIELD_OPTIONS' + payload: { + fieldOptions: DashboardData.FieldOption[] + } +} From 04e8ebac0d87b5724ff5dfc8d5d06cbfbdf4b275 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:25:22 -0700 Subject: [PATCH 33/49] Refactor app action types file structure & imports to new style --- .../dashboards/components/DashboardHeader.tsx | 2 +- .../dashboards/containers/DashboardPage.tsx | 2 +- ui/src/shared/actions/app.ts | 47 ++++--------------- ui/src/types/actions/app.ts | 39 +++++++++++++++ 4 files changed, 50 insertions(+), 40 deletions(-) create mode 100644 ui/src/types/actions/app.ts diff --git a/ui/src/dashboards/components/DashboardHeader.tsx b/ui/src/dashboards/components/DashboardHeader.tsx index ecf04c380b..10e603521c 100644 --- a/ui/src/dashboards/components/DashboardHeader.tsx +++ b/ui/src/dashboards/components/DashboardHeader.tsx @@ -13,7 +13,7 @@ import DashboardSwitcher from 'src/dashboards/components/DashboardSwitcher' import {Dashboard, TimeRange} from 'src/types' import {DashboardName} from 'src/types/dashboards' -import * as AppActions from 'src/shared/actions/app' +import * as AppActions from 'src/types/actions/app' interface Props { activeDashboard: string diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 55d8ed3435..04970cd4aa 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -62,7 +62,7 @@ import { import {DashboardName} from 'src/types/dashboards' import {ColorNumber, ColorString} from 'src/types/colors' import * as AnnotationActions from 'src/types/actions/annotations' -import * as AppActions from 'src/shared/actions/app' +import * as AppActions from 'src/types/actions/app' import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay' import * as DashboardActions from 'src/types/actions/dashboards' import * as ErrorActions from 'src/types/actions/errors' diff --git a/ui/src/shared/actions/app.ts b/ui/src/shared/actions/app.ts index cae0f97963..1b368df596 100644 --- a/ui/src/shared/actions/app.ts +++ b/ui/src/shared/actions/app.ts @@ -4,31 +4,20 @@ import {notify} from 'src/shared/actions/notifications' import {notifyPresentationMode} from 'src/shared/copy/notifications' import {Dispatch} from 'redux' +import * as AppActions from 'src/types/actions/app' // ephemeral state action creators -export type EnablePresentationModeActionCreator = () => EnablePresentationModeAction -interface EnablePresentationModeAction { - type: 'ENABLE_PRESENTATION_MODE' -} -export const enablePresentationMode = (): EnablePresentationModeAction => ({ +export const enablePresentationMode = (): AppActions.EnablePresentationModeAction => ({ type: 'ENABLE_PRESENTATION_MODE', }) -interface DisablePresentationModeAction { - type: 'DISABLE_PRESENTATION_MODE' -} -export const disablePresentationMode = (): DisablePresentationModeAction => ({ +export const disablePresentationMode = (): AppActions.DisablePresentationModeAction => ({ type: 'DISABLE_PRESENTATION_MODE', }) -export type DelayEnablePresentationModeDispatcher = () => DelayEnablePresentationModeThunk -export type DelayEnablePresentationModeThunk = ( - dispatch: Dispatch -) => Promise - -export const delayEnablePresentationMode: DelayEnablePresentationModeDispatcher = () => async ( - dispatch: Dispatch +export const delayEnablePresentationMode: AppActions.DelayEnablePresentationModeDispatcher = () => async ( + dispatch: Dispatch ): Promise => setTimeout(() => { dispatch(enablePresentationMode()) @@ -36,39 +25,21 @@ export const delayEnablePresentationMode: DelayEnablePresentationModeDispatcher }, PRESENTATION_MODE_ANIMATION_DELAY) // persistent state action creators -export type SetAutoRefreshActionCreator = ( - milliseconds: number -) => SetAutoRefreshAction -interface SetAutoRefreshAction { - type: 'SET_AUTOREFRESH' - payload: { - milliseconds: number - } -} -export const setAutoRefresh: SetAutoRefreshActionCreator = ( +export const setAutoRefresh: AppActions.SetAutoRefreshActionCreator = ( milliseconds: number -): SetAutoRefreshAction => ({ +): AppActions.SetAutoRefreshAction => ({ type: 'SET_AUTOREFRESH', payload: { milliseconds, }, }) -export type TemplateControlBarVisibilityToggledActionCreator = () => TemplateControlBarVisibilityToggledAction - -interface TemplateControlBarVisibilityToggledAction { - type: 'TEMPLATE_CONTROL_BAR_VISIBILITY_TOGGLED' -} -export const templateControlBarVisibilityToggled = (): TemplateControlBarVisibilityToggledAction => ({ +export const templateControlBarVisibilityToggled = (): AppActions.TemplateControlBarVisibilityToggledAction => ({ type: 'TEMPLATE_CONTROL_BAR_VISIBILITY_TOGGLED', }) -interface NoopAction { - type: 'NOOP' - payload: object -} -export const noop = (): NoopAction => ({ +export const noop = (): AppActions.NoopAction => ({ type: 'NOOP', payload: {}, }) diff --git a/ui/src/types/actions/app.ts b/ui/src/types/actions/app.ts new file mode 100644 index 0000000000..f1f8837a5d --- /dev/null +++ b/ui/src/types/actions/app.ts @@ -0,0 +1,39 @@ +import {Dispatch} from 'redux' + +export type EnablePresentationModeActionCreator = () => EnablePresentationModeAction + +export interface EnablePresentationModeAction { + type: 'ENABLE_PRESENTATION_MODE' +} + +export interface DisablePresentationModeAction { + type: 'DISABLE_PRESENTATION_MODE' +} + +export type DelayEnablePresentationModeDispatcher = () => DelayEnablePresentationModeThunk + +export type DelayEnablePresentationModeThunk = ( + dispatch: Dispatch +) => Promise + +export type SetAutoRefreshActionCreator = ( + milliseconds: number +) => SetAutoRefreshAction + +export interface SetAutoRefreshAction { + type: 'SET_AUTOREFRESH' + payload: { + milliseconds: number + } +} + +export type TemplateControlBarVisibilityToggledActionCreator = () => TemplateControlBarVisibilityToggledAction + +export interface TemplateControlBarVisibilityToggledAction { + type: 'TEMPLATE_CONTROL_BAR_VISIBILITY_TOGGLED' +} + +export interface NoopAction { + type: 'NOOP' + payload: object +} From a883d599606dd2dfa398b223d349c0e7a3b66c7f Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:34:10 -0700 Subject: [PATCH 34/49] Fix broken dashtimev1 delete dashboard test --- ui/src/dashboards/reducers/dashTimeV1.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/dashboards/reducers/dashTimeV1.js b/ui/src/dashboards/reducers/dashTimeV1.js index 0f95484dc1..fc1cfd350b 100644 --- a/ui/src/dashboards/reducers/dashTimeV1.js +++ b/ui/src/dashboards/reducers/dashTimeV1.js @@ -6,8 +6,8 @@ const initialState = { const dashTimeV1 = (state = initialState, action) => { switch (action.type) { case 'DELETE_DASHBOARD': { - const {dashboardID} = action.payload - const ranges = state.ranges.filter(r => r.dashboardID !== dashboardID) + const {dashboard} = action.payload + const ranges = state.ranges.filter(r => r.dashboardID !== dashboard.id) return {...state, ranges} } From 52eef4b2065c06ba642b5394f49ad9de4a07ee43 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:45:56 -0700 Subject: [PATCH 35/49] Type setScrollTop instance method on DashboardPage --- ui/src/dashboards/containers/DashboardPage.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 04970cd4aa..3ce5f24ebb 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -1,4 +1,4 @@ -import React, {Component} from 'react' +import React, {Component, MouseEvent} from 'react' import {connect} from 'react-redux' import {withRouter} from 'react-router' @@ -549,8 +549,10 @@ class DashboardPage extends Component { dashboardActions.setZoomedTimeRangeAsync(zoomedTimeRange, location) } - private setScrollTop = event => { - this.setState({scrollTop: event.target.scrollTop}) + private setScrollTop = (e: MouseEvent): void => { + const target = e.target as HTMLElement + + this.setState({scrollTop: target.scrollTop}) } } From 31cd49e89fcd8733c8bd67095f28d074241ec09d Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:46:28 -0700 Subject: [PATCH 36/49] Refactor DashboardPage getDashboard & getDashboardsNames instance methods to assignment syntax --- ui/src/dashboards/containers/DashboardPage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 3ce5f24ebb..7a1f91297b 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -369,9 +369,9 @@ class DashboardPage extends Component { this.setState({windowHeight: window.innerHeight}) } - private async getDashboard(): Promise< + private getDashboard = async (): Promise< DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk - > { + > => { const { dashboardID, dashboardActions: {getDashboardWithHydratedAndSyncedTempVarsAsync}, @@ -388,7 +388,7 @@ class DashboardPage extends Component { ) } - private async getDashboardsNames(): Promise { + private getDashboardsNames = async (): Promise => { const { params: {sourceID}, dashboardActions: {getDashboardsNamesAsync}, From 65da5cc724bf5ec76c7c21ab17da60874e797786 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Sat, 23 Jun 2018 11:21:10 -0700 Subject: [PATCH 37/49] Fix dashboardActions undefined by de-nesting all action creators Using the object syntax for mapDispatchToProps (mdtp), the nested dashboardActions functions were not being properly bound to dispatch, and lookuped to dashboardActions were failing. This refactors that by de-nesting and spreading action creators directly onto DashboardPage props. --- .../dashboards/containers/DashboardPage.tsx | 87 ++++++++----------- 1 file changed, 36 insertions(+), 51 deletions(-) diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 7a1f91297b..1b10678e11 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -87,7 +87,7 @@ interface DashboardActions { setZoomedTimeRangeAsync: DashboardActions.SetZoomedTimeRangeDispatcher } -interface Props extends ManualRefreshProps, WithRouterProps { +interface Props extends DashboardActions, ManualRefreshProps, WithRouterProps { source: Source sources: Source[] params: { @@ -97,7 +97,6 @@ interface Props extends ManualRefreshProps, WithRouterProps { location: Location dashboardID: number dashboard: IDashboard - dashboardActions: DashboardActions dashboards: IDashboard[] handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator autoRefresh: number @@ -154,7 +153,6 @@ class DashboardPage extends Component { public async componentDidMount() { const { dashboardID, - dashboardActions: {putDashboardByID}, source, meRole, isUsingAuth, @@ -180,7 +178,7 @@ class DashboardPage extends Component { // is refactored so as not to require a write operation (a PUT in this case) if (!isUsingAuth || isUserAuthorized(meRole, EDITOR_ROLE)) { // putDashboardByID refreshes & persists influxql generated template variable values. - await putDashboardByID(dashboardID) + await this.props.putDashboardByID(dashboardID) } this.getDashboardsNames() @@ -236,7 +234,7 @@ class DashboardPage extends Component { cellQueryStatus, thresholdsListType, thresholdsListColors, - dashboardActions, + inPresentationMode, handleChooseAutoRefresh, handleShowCellEditorOverlay, @@ -304,7 +302,7 @@ class DashboardPage extends Component { onSave={this.handleSaveEditedCell} onCancel={handleHideCellEditorOverlay} templates={templatesIncludingDashTime} - editQueryStatus={dashboardActions.editCellQueryStatus} + editQueryStatus={this.props.editCellQueryStatus} thresholdsListType={thresholdsListType} thresholdsListColors={thresholdsListColors} gaugeColors={gaugeColors} @@ -372,15 +370,9 @@ class DashboardPage extends Component { private getDashboard = async (): Promise< DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk > => { - const { - dashboardID, - dashboardActions: {getDashboardWithHydratedAndSyncedTempVarsAsync}, - source, - router, - location, - } = this.props + const {dashboardID, source, router, location} = this.props - return await getDashboardWithHydratedAndSyncedTempVarsAsync( + return await this.props.getDashboardWithHydratedAndSyncedTempVarsAsync( dashboardID, source, router, @@ -391,11 +383,12 @@ class DashboardPage extends Component { private getDashboardsNames = async (): Promise => { const { params: {sourceID}, - dashboardActions: {getDashboardsNamesAsync}, } = this.props // TODO: remove any once react-redux connect is properly typed - const dashboardsNames = (await getDashboardsNamesAsync(sourceID)) as any + const dashboardsNames = (await this.props.getDashboardsNamesAsync( + sourceID + )) as any this.setState({dashboardsNames}) } @@ -414,30 +407,26 @@ class DashboardPage extends Component { } private handleSaveEditedCell = async (newCell: Cell): Promise => { - const { - dashboardActions, - dashboard, - handleHideCellEditorOverlay, - } = this.props - await dashboardActions.updateDashboardCell(dashboard, newCell) + const {dashboard, handleHideCellEditorOverlay} = this.props + await this.props.updateDashboardCell(dashboard, newCell) handleHideCellEditorOverlay() } private handleChooseTimeRange = (timeRange: TimeRange): void => { const { dashboard, - dashboardActions, + getAnnotationsAsync, source, location, } = this.props - dashboardActions.setDashTimeV1(dashboard.id, { + this.props.setDashTimeV1(dashboard.id, { ...timeRange, format: FORMAT_INFLUXQL, }) - dashboardActions.syncURLQueryParamsFromQueryParamsObject(location, { + this.props.syncURLQueryParamsFromQueryParamsObject(location, { lower: timeRange.lower, upper: timeRange.upper, }) @@ -447,26 +436,26 @@ class DashboardPage extends Component { } private handleUpdatePosition = (cells: Cell[]): void => { - const {dashboardActions, dashboard, meRole, isUsingAuth} = this.props + const {dashboard, meRole, isUsingAuth} = this.props const newDashboard = {...dashboard, cells} // GridLayout invokes onLayoutChange on first load, which bubbles up to // invoke handleUpdatePosition. If using auth, Viewer is not authorized to // PUT, so until the need for PUT is removed, this is prevented. if (!isUsingAuth || isUserAuthorized(meRole, EDITOR_ROLE)) { - dashboardActions.updateDashboard(newDashboard) - dashboardActions.putDashboard(newDashboard) + this.props.updateDashboard(newDashboard) + this.props.putDashboard(newDashboard) } } private handleAddCell = (): void => { - const {dashboardActions, dashboard} = this.props - dashboardActions.addDashboardCellAsync(dashboard) + const {dashboard} = this.props + this.props.addDashboardCellAsync(dashboard) } private handleCloneCell = (cell: Cell): void => { - const {dashboardActions, dashboard} = this.props - dashboardActions.cloneDashboardCellAsync(dashboard, cell) + const {dashboard} = this.props + this.props.cloneDashboardCellAsync(dashboard, cell) } private handleEditDashboard = (): void => { @@ -478,24 +467,24 @@ class DashboardPage extends Component { } private handleRenameDashboard = async (name: string): Promise => { - const {dashboardActions, dashboard} = this.props + const {dashboard} = this.props this.setState({isEditMode: false}) const newDashboard = {...dashboard, name} - dashboardActions.updateDashboard(newDashboard) - await dashboardActions.putDashboard(newDashboard) + this.props.updateDashboard(newDashboard) + await this.props.putDashboard(newDashboard) this.getDashboardsNames() } private handleDeleteDashboardCell = (cell: Cell): void => { - const {dashboardActions, dashboard} = this.props - dashboardActions.deleteDashboardCellAsync(dashboard, cell) + const {dashboard} = this.props + this.props.deleteDashboardCellAsync(dashboard, cell) } private handleSelectTemplate = ( templateID: string ): ((value: TemplateValue) => void) => (value: TemplateValue): void => { - const {dashboardActions, dashboard, dashboardID, location} = this.props + const {dashboard, dashboardID, location} = this.props const currentTempVar = dashboard.templates.find( tempVar => tempVar.id === templateID @@ -507,22 +496,22 @@ class DashboardPage extends Component { const updatedQueryParam = { [strippedTempVar]: value.value, } - dashboardActions.syncURLQueryParamsFromQueryParamsObject( + this.props.syncURLQueryParamsFromQueryParamsObject( location, updatedQueryParam ) } - dashboardActions.templateVariableSelected(dashboard.id, templateID, [value]) - dashboardActions.putDashboardByID(dashboardID) + this.props.templateVariableSelected(dashboard.id, templateID, [value]) + this.props.putDashboardByID(dashboardID) } private handleSaveTemplateVariables = async ( templates: Template[] ): Promise => { - const {location, dashboardActions, dashboard} = this.props + const {location, dashboard} = this.props try { - await dashboardActions.putDashboard({ + await this.props.putDashboard({ ...dashboard, templates, }) @@ -530,11 +519,7 @@ class DashboardPage extends Component { ({tempVar: oldTempVar}) => !templates.find(({tempVar: newTempVar}) => oldTempVar === newTempVar) ) - dashboardActions.syncURLQueryFromTempVars( - location, - templates, - deletedTempVars - ) + this.props.syncURLQueryFromTempVars(location, templates, deletedTempVars) } catch (error) { console.error(error) } @@ -545,8 +530,8 @@ class DashboardPage extends Component { } private handleZoomedTimeRange = (zoomedTimeRange: TimeRange): void => { - const {dashboardActions, location} = this.props - dashboardActions.setZoomedTimeRangeAsync(zoomedTimeRange, location) + const {location} = this.props + this.props.setZoomedTimeRangeAsync(zoomedTimeRange, location) } private setScrollTop = (e: MouseEvent): void => { @@ -613,7 +598,7 @@ const mdtp = { handleChooseAutoRefresh: setAutoRefresh, templateControlBarVisibilityToggled: templateControlBarVisibilityToggledAction, handleClickPresentationButton: delayEnablePresentationMode, - dashboardActions: dashboardActionCreators, + ...dashboardActionCreators, errorThrown: errorThrownAction, notify: notifyAction, getAnnotationsAsync: annotationActions.getAnnotationsAsync, From 7e25bb554b5585389f4180cf4d34f2513cd45513 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Sat, 23 Jun 2018 11:41:14 -0700 Subject: [PATCH 38/49] Make all type imports consistent & group all imports --- .../dashboards/containers/DashboardPage.tsx | 122 ++++++++---------- 1 file changed, 57 insertions(+), 65 deletions(-) diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 1b10678e11..17bd703392 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -1,40 +1,33 @@ +// Libraries import React, {Component, MouseEvent} from 'react' import {connect} from 'react-redux' import {withRouter} from 'react-router' - import _ from 'lodash' +// Components import {isUserAuthorized, EDITOR_ROLE} from 'src/auth/Authorized' - +import {ErrorHandling} from 'src/shared/decorators/errors' import CellEditorOverlay from 'src/dashboards/components/CellEditorOverlay' import DashboardHeader from 'src/dashboards/components/DashboardHeader' import Dashboard from 'src/dashboards/components/Dashboard' import ManualRefresh from 'src/shared/components/ManualRefresh' import TemplateControlBar from 'src/tempVars/components/TemplateControlBar' -import {errorThrown as errorThrownAction} from 'src/shared/actions/errors' -import {notify as notifyAction} from 'src/shared/actions/notifications' +// Actions +import * as dashboardActions from 'src/dashboards/actions' +import * as annotationActions from 'src/shared/actions/annotations' +import * as cellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay' +import * as appActions from 'src/shared/actions/app' +import * as errorActions from 'src/shared/actions/errors' +import * as notifyActions from 'src/shared/actions/notifications' + +// Utils import idNormalizer, {TYPE_ID} from 'src/normalizers/id' import {millisecondTimeRange} from 'src/dashboards/utils/time' - -import * as dashboardActionCreators from 'src/dashboards/actions' -import * as annotationActions from 'src/shared/actions/annotations' - -import { - showCellEditorOverlay, - hideCellEditorOverlay, -} from 'src/dashboards/actions/cellEditorOverlay' - import {stripTempVar} from 'src/dashboards/utils/tempVars' +import {getDeep} from 'src/utils/wrappers' -import {dismissEditingAnnotation} from 'src/shared/actions/annotations' - -import { - setAutoRefresh, - templateControlBarVisibilityToggled as templateControlBarVisibilityToggledAction, - delayEnablePresentationMode, -} from 'src/shared/actions/app' - +// Constants import { interval, DASHBOARD_LAYOUT_ROW_HEIGHT, @@ -43,24 +36,16 @@ import { } from 'src/shared/constants' import {FORMAT_INFLUXQL, defaultTimeRange} from 'src/shared/data/timeRanges' -import {ErrorHandling} from 'src/shared/decorators/errors' - -import {getDeep} from 'src/utils/wrappers' - +// Types import {WithRouterProps} from 'react-router' import {ManualRefreshProps} from 'src/shared/components/ManualRefresh' import {Location} from 'history' import {InjectedRouter} from 'react-router' -import { - Cell, - Dashboard as IDashboard, - Source, - Template, - TemplateValue, - TimeRange, -} from 'src/types' -import {DashboardName} from 'src/types/dashboards' -import {ColorNumber, ColorString} from 'src/types/colors' +import * as SourceData from 'src/types/sources' +import * as TempVarData from 'src/types/tempVars' +import * as DashboardData from 'src/types/dashboards' +import * as QueryData from 'src/types/query' +import * as ColorData from 'src/types/colors' import * as AnnotationActions from 'src/types/actions/annotations' import * as AppActions from 'src/types/actions/app' import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay' @@ -88,21 +73,21 @@ interface DashboardActions { } interface Props extends DashboardActions, ManualRefreshProps, WithRouterProps { - source: Source - sources: Source[] + source: SourceData.Source + sources: SourceData.Source[] params: { sourceID: string dashboardID: string } location: Location dashboardID: number - dashboard: IDashboard - dashboards: IDashboard[] + dashboard: DashboardData.Dashboard + dashboards: DashboardData.Dashboard[] handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator autoRefresh: number templateControlBarVisibilityToggled: () => AppActions.TemplateControlBarVisibilityToggledActionCreator - timeRange: TimeRange - zoomedTimeRange: TimeRange + timeRange: QueryData.TimeRange + zoomedTimeRange: QueryData.TimeRange showTemplateControlBar: boolean inPresentationMode: boolean handleClickPresentationButton: AppActions.DelayEnablePresentationModeDispatcher @@ -119,19 +104,19 @@ interface Props extends DashboardActions, ManualRefreshProps, WithRouterProps { handleShowCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator handleHideCellEditorOverlay: CellEditorOverlayActions.HideCellEditorOverlayActionCreator handleDismissEditingAnnotation: AnnotationActions.DismissEditingAnnotationActionCreator - selectedCell: Cell + selectedCell: DashboardData.Cell thresholdsListType: string - thresholdsListColors: ColorNumber[] - gaugeColors: ColorNumber[] - lineColors: ColorString[] + thresholdsListColors: ColorData.ColorNumber[] + gaugeColors: ColorData.ColorNumber[] + lineColors: ColorData.ColorString[] } interface State { isEditMode: boolean - selectedCell: Cell | null + selectedCell: DashboardData.Cell | null scrollTop: number windowHeight: number - dashboardsNames: DashboardName[] + dashboardsNames: DashboardData.DashboardName[] } @ErrorHandling @@ -393,7 +378,7 @@ class DashboardPage extends Component { this.setState({dashboardsNames}) } - private inView = (cell: Cell): boolean => { + private inView = (cell: DashboardData.Cell): boolean => { const {scrollTop, windowHeight} = this.state const bufferValue = 600 const cellTop = cell.y * DASHBOARD_LAYOUT_ROW_HEIGHT @@ -406,13 +391,15 @@ class DashboardPage extends Component { return topInView && bottomInView } - private handleSaveEditedCell = async (newCell: Cell): Promise => { + private handleSaveEditedCell = async ( + newCell: DashboardData.Cell + ): Promise => { const {dashboard, handleHideCellEditorOverlay} = this.props await this.props.updateDashboardCell(dashboard, newCell) handleHideCellEditorOverlay() } - private handleChooseTimeRange = (timeRange: TimeRange): void => { + private handleChooseTimeRange = (timeRange: QueryData.TimeRange): void => { const { dashboard, @@ -435,7 +422,7 @@ class DashboardPage extends Component { getAnnotationsAsync(source.links.annotations, annotationRange) } - private handleUpdatePosition = (cells: Cell[]): void => { + private handleUpdatePosition = (cells: DashboardData.Cell[]): void => { const {dashboard, meRole, isUsingAuth} = this.props const newDashboard = {...dashboard, cells} @@ -453,7 +440,7 @@ class DashboardPage extends Component { this.props.addDashboardCellAsync(dashboard) } - private handleCloneCell = (cell: Cell): void => { + private handleCloneCell = (cell: DashboardData.Cell): void => { const {dashboard} = this.props this.props.cloneDashboardCellAsync(dashboard, cell) } @@ -476,14 +463,16 @@ class DashboardPage extends Component { this.getDashboardsNames() } - private handleDeleteDashboardCell = (cell: Cell): void => { + private handleDeleteDashboardCell = (cell: DashboardData.Cell): void => { const {dashboard} = this.props this.props.deleteDashboardCellAsync(dashboard, cell) } private handleSelectTemplate = ( templateID: string - ): ((value: TemplateValue) => void) => (value: TemplateValue): void => { + ): ((value: TempVarData.TemplateValue) => void) => ( + value: TempVarData.TemplateValue + ): void => { const {dashboard, dashboardID, location} = this.props const currentTempVar = dashboard.templates.find( @@ -506,7 +495,7 @@ class DashboardPage extends Component { } private handleSaveTemplateVariables = async ( - templates: Template[] + templates: TempVarData.Template[] ): Promise => { const {location, dashboard} = this.props @@ -529,7 +518,9 @@ class DashboardPage extends Component { this.props.templateControlBarVisibilityToggled() } - private handleZoomedTimeRange = (zoomedTimeRange: TimeRange): void => { + private handleZoomedTimeRange = ( + zoomedTimeRange: QueryData.TimeRange + ): void => { const {location} = this.props this.props.setZoomedTimeRangeAsync(zoomedTimeRange, location) } @@ -595,16 +586,17 @@ const mstp = (state, {params: {dashboardID}}) => { } const mdtp = { - handleChooseAutoRefresh: setAutoRefresh, - templateControlBarVisibilityToggled: templateControlBarVisibilityToggledAction, - handleClickPresentationButton: delayEnablePresentationMode, - ...dashboardActionCreators, - errorThrown: errorThrownAction, - notify: notifyAction, + ...dashboardActions, + handleChooseAutoRefresh: appActions.setAutoRefresh, + templateControlBarVisibilityToggled: + appActions.templateControlBarVisibilityToggled, + handleClickPresentationButton: appActions.delayEnablePresentationMode, + errorThrown: errorActions.errorThrown, + notify: notifyActions.notify, + handleShowCellEditorOverlay: cellEditorOverlayActions.showCellEditorOverlay, + handleHideCellEditorOverlay: cellEditorOverlayActions.hideCellEditorOverlay, getAnnotationsAsync: annotationActions.getAnnotationsAsync, - handleShowCellEditorOverlay: showCellEditorOverlay, - handleHideCellEditorOverlay: hideCellEditorOverlay, - handleDismissEditingAnnotation: dismissEditingAnnotation, + handleDismissEditingAnnotation: annotationActions.dismissEditingAnnotation, } export default connect(mstp, mdtp)( From 9a5dfcb57d2c0cf089e345b586edfdd7d401bf2e Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Sat, 23 Jun 2018 12:54:24 -0700 Subject: [PATCH 39/49] Create global Types module & consume in DashboardPage for single import --- .../dashboards/containers/DashboardPage.tsx | 114 +++++++++--------- ui/src/types/modules/annotations.ts | 3 + ui/src/types/modules/app.ts | 3 + ui/src/types/modules/cellEditorOverlay.ts | 3 + ui/src/types/modules/colors.ts | 3 + ui/src/types/modules/dashboards.ts | 6 + ui/src/types/modules/errors.ts | 3 + ui/src/types/modules/index.ts | 23 ++++ ui/src/types/modules/notifications.ts | 3 + ui/src/types/modules/queries.ts | 3 + ui/src/types/modules/sources.ts | 3 + ui/src/types/modules/tempVars.ts | 3 + 12 files changed, 111 insertions(+), 59 deletions(-) create mode 100644 ui/src/types/modules/annotations.ts create mode 100644 ui/src/types/modules/app.ts create mode 100644 ui/src/types/modules/cellEditorOverlay.ts create mode 100644 ui/src/types/modules/colors.ts create mode 100644 ui/src/types/modules/dashboards.ts create mode 100644 ui/src/types/modules/errors.ts create mode 100644 ui/src/types/modules/index.ts create mode 100644 ui/src/types/modules/notifications.ts create mode 100644 ui/src/types/modules/queries.ts create mode 100644 ui/src/types/modules/sources.ts create mode 100644 ui/src/types/modules/tempVars.ts diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 17bd703392..2ed19f9907 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -41,82 +41,72 @@ import {WithRouterProps} from 'react-router' import {ManualRefreshProps} from 'src/shared/components/ManualRefresh' import {Location} from 'history' import {InjectedRouter} from 'react-router' -import * as SourceData from 'src/types/sources' -import * as TempVarData from 'src/types/tempVars' -import * as DashboardData from 'src/types/dashboards' -import * as QueryData from 'src/types/query' -import * as ColorData from 'src/types/colors' -import * as AnnotationActions from 'src/types/actions/annotations' -import * as AppActions from 'src/types/actions/app' -import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay' -import * as DashboardActions from 'src/types/actions/dashboards' -import * as ErrorActions from 'src/types/actions/errors' -import * as NotificationActions from 'src/types/actions/notifications' +import * as Types from 'src/types/modules' interface DashboardActions { - setDashTimeV1: DashboardActions.SetDashTimeV1ActionCreator - updateDashboard: DashboardActions.UpdateDashboardActionCreator - syncURLQueryParamsFromQueryParamsObject: DashboardActions.SyncURLQueryFromQueryParamsObjectDispatcher - putDashboard: DashboardActions.PutDashboardDispatcher - putDashboardByID: DashboardActions.PutDashboardByIDDispatcher - getDashboardsNamesAsync: DashboardActions.GetDashboardsNamesDispatcher - getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher - setTimeRange: DashboardActions.SetTimeRangeActionCreator - addDashboardCellAsync: DashboardActions.AddDashboardCellDispatcher - editCellQueryStatus: DashboardActions.EditCellQueryStatusActionCreator - updateDashboardCell: DashboardActions.UpdateDashboardCellDispatcher - cloneDashboardCellAsync: DashboardActions.CloneDashboardCellDispatcher - deleteDashboardCellAsync: DashboardActions.DeleteDashboardCellDispatcher - templateVariableSelected: DashboardActions.TemplateVariableSelectedActionCreator - syncURLQueryFromTempVars: DashboardActions.SyncURLQueryFromTempVarsDispatcher - setZoomedTimeRangeAsync: DashboardActions.SetZoomedTimeRangeDispatcher + setDashTimeV1: Types.Dashboards.Actions.SetDashTimeV1ActionCreator + updateDashboard: Types.Dashboards.Actions.UpdateDashboardActionCreator + syncURLQueryParamsFromQueryParamsObject: Types.Dashboards.Actions.SyncURLQueryFromQueryParamsObjectDispatcher + putDashboard: Types.Dashboards.Actions.PutDashboardDispatcher + putDashboardByID: Types.Dashboards.Actions.PutDashboardByIDDispatcher + getDashboardsNamesAsync: Types.Dashboards.Actions.GetDashboardsNamesDispatcher + getDashboardWithHydratedAndSyncedTempVarsAsync: Types.Dashboards.Actions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher + setTimeRange: Types.Dashboards.Actions.SetTimeRangeActionCreator + addDashboardCellAsync: Types.Dashboards.Actions.AddDashboardCellDispatcher + editCellQueryStatus: Types.Dashboards.Actions.EditCellQueryStatusActionCreator + updateDashboardCell: Types.Dashboards.Actions.UpdateDashboardCellDispatcher + cloneDashboardCellAsync: Types.Dashboards.Actions.CloneDashboardCellDispatcher + deleteDashboardCellAsync: Types.Dashboards.Actions.DeleteDashboardCellDispatcher + templateVariableSelected: Types.Dashboards.Actions.TemplateVariableSelectedActionCreator + syncURLQueryFromTempVars: Types.Dashboards.Actions.SyncURLQueryFromTempVarsDispatcher + setZoomedTimeRangeAsync: Types.Dashboards.Actions.SetZoomedTimeRangeDispatcher } interface Props extends DashboardActions, ManualRefreshProps, WithRouterProps { - source: SourceData.Source - sources: SourceData.Source[] + source: Types.Sources.Data.Source + sources: Types.Sources.Data.Source[] params: { sourceID: string dashboardID: string } location: Location dashboardID: number - dashboard: DashboardData.Dashboard - dashboards: DashboardData.Dashboard[] - handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator + dashboard: Types.Dashboards.Data.Dashboard + dashboards: Types.Dashboards.Data.Dashboard[] + handleChooseAutoRefresh: Types.App.Actions.SetAutoRefreshActionCreator autoRefresh: number - templateControlBarVisibilityToggled: () => AppActions.TemplateControlBarVisibilityToggledActionCreator - timeRange: QueryData.TimeRange - zoomedTimeRange: QueryData.TimeRange + templateControlBarVisibilityToggled: () => Types.App.Actions.TemplateControlBarVisibilityToggledActionCreator + timeRange: Types.Queries.Data.TimeRange + zoomedTimeRange: Types.Queries.Data.TimeRange showTemplateControlBar: boolean inPresentationMode: boolean - handleClickPresentationButton: AppActions.DelayEnablePresentationModeDispatcher + handleClickPresentationButton: Types.App.Actions.DelayEnablePresentationModeDispatcher cellQueryStatus: { queryID: string status: object } - errorThrown: ErrorActions.ErrorThrownActionCreator + errorThrown: Types.Errors.Actions.ErrorThrownActionCreator meRole: string isUsingAuth: boolean router: InjectedRouter - notify: NotificationActions.PublishNotificationActionCreator - getAnnotationsAsync: AnnotationActions.GetAnnotationsDispatcher - handleShowCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator - handleHideCellEditorOverlay: CellEditorOverlayActions.HideCellEditorOverlayActionCreator - handleDismissEditingAnnotation: AnnotationActions.DismissEditingAnnotationActionCreator - selectedCell: DashboardData.Cell + notify: Types.Notifications.Actions.PublishNotificationActionCreator + getAnnotationsAsync: Types.Annotations.Actions.GetAnnotationsDispatcher + handleShowCellEditorOverlay: Types.CellEditorOverlay.Actions.ShowCellEditorOverlayActionCreator + handleHideCellEditorOverlay: Types.CellEditorOverlay.Actions.HideCellEditorOverlayActionCreator + handleDismissEditingAnnotation: Types.Annotations.Actions.DismissEditingAnnotationActionCreator + selectedCell: Types.Dashboards.Data.Cell thresholdsListType: string - thresholdsListColors: ColorData.ColorNumber[] - gaugeColors: ColorData.ColorNumber[] - lineColors: ColorData.ColorString[] + thresholdsListColors: Types.Colors.Data.ColorNumber[] + gaugeColors: Types.Colors.Data.ColorNumber[] + lineColors: Types.Colors.Data.ColorString[] } interface State { isEditMode: boolean - selectedCell: DashboardData.Cell | null + selectedCell: Types.Dashboards.Data.Cell | null scrollTop: number windowHeight: number - dashboardsNames: DashboardData.DashboardName[] + dashboardsNames: Types.Dashboards.Data.DashboardName[] } @ErrorHandling @@ -353,7 +343,7 @@ class DashboardPage extends Component { } private getDashboard = async (): Promise< - DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk + Types.Dashboards.Actions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk > => { const {dashboardID, source, router, location} = this.props @@ -378,7 +368,7 @@ class DashboardPage extends Component { this.setState({dashboardsNames}) } - private inView = (cell: DashboardData.Cell): boolean => { + private inView = (cell: Types.Dashboards.Data.Cell): boolean => { const {scrollTop, windowHeight} = this.state const bufferValue = 600 const cellTop = cell.y * DASHBOARD_LAYOUT_ROW_HEIGHT @@ -392,14 +382,16 @@ class DashboardPage extends Component { } private handleSaveEditedCell = async ( - newCell: DashboardData.Cell + newCell: Types.Dashboards.Data.Cell ): Promise => { const {dashboard, handleHideCellEditorOverlay} = this.props await this.props.updateDashboardCell(dashboard, newCell) handleHideCellEditorOverlay() } - private handleChooseTimeRange = (timeRange: QueryData.TimeRange): void => { + private handleChooseTimeRange = ( + timeRange: Types.Queries.Data.TimeRange + ): void => { const { dashboard, @@ -422,7 +414,9 @@ class DashboardPage extends Component { getAnnotationsAsync(source.links.annotations, annotationRange) } - private handleUpdatePosition = (cells: DashboardData.Cell[]): void => { + private handleUpdatePosition = ( + cells: Types.Dashboards.Data.Cell[] + ): void => { const {dashboard, meRole, isUsingAuth} = this.props const newDashboard = {...dashboard, cells} @@ -440,7 +434,7 @@ class DashboardPage extends Component { this.props.addDashboardCellAsync(dashboard) } - private handleCloneCell = (cell: DashboardData.Cell): void => { + private handleCloneCell = (cell: Types.Dashboards.Data.Cell): void => { const {dashboard} = this.props this.props.cloneDashboardCellAsync(dashboard, cell) } @@ -463,15 +457,17 @@ class DashboardPage extends Component { this.getDashboardsNames() } - private handleDeleteDashboardCell = (cell: DashboardData.Cell): void => { + private handleDeleteDashboardCell = ( + cell: Types.Dashboards.Data.Cell + ): void => { const {dashboard} = this.props this.props.deleteDashboardCellAsync(dashboard, cell) } private handleSelectTemplate = ( templateID: string - ): ((value: TempVarData.TemplateValue) => void) => ( - value: TempVarData.TemplateValue + ): ((value: Types.TempVars.Data.TemplateValue) => void) => ( + value: Types.TempVars.Data.TemplateValue ): void => { const {dashboard, dashboardID, location} = this.props @@ -495,7 +491,7 @@ class DashboardPage extends Component { } private handleSaveTemplateVariables = async ( - templates: TempVarData.Template[] + templates: Types.TempVars.Data.Template[] ): Promise => { const {location, dashboard} = this.props @@ -519,7 +515,7 @@ class DashboardPage extends Component { } private handleZoomedTimeRange = ( - zoomedTimeRange: QueryData.TimeRange + zoomedTimeRange: Types.Queries.Data.TimeRange ): void => { const {location} = this.props this.props.setZoomedTimeRangeAsync(zoomedTimeRange, location) diff --git a/ui/src/types/modules/annotations.ts b/ui/src/types/modules/annotations.ts new file mode 100644 index 0000000000..ca5d216b7a --- /dev/null +++ b/ui/src/types/modules/annotations.ts @@ -0,0 +1,3 @@ +import * as Actions from 'src/types/actions/annotations' + +export {Actions} diff --git a/ui/src/types/modules/app.ts b/ui/src/types/modules/app.ts new file mode 100644 index 0000000000..40444116cb --- /dev/null +++ b/ui/src/types/modules/app.ts @@ -0,0 +1,3 @@ +import * as Actions from 'src/types/actions/app' + +export {Actions} diff --git a/ui/src/types/modules/cellEditorOverlay.ts b/ui/src/types/modules/cellEditorOverlay.ts new file mode 100644 index 0000000000..c7515f387b --- /dev/null +++ b/ui/src/types/modules/cellEditorOverlay.ts @@ -0,0 +1,3 @@ +import * as Actions from 'src/types/actions/cellEditorOverlay' + +export {Actions} diff --git a/ui/src/types/modules/colors.ts b/ui/src/types/modules/colors.ts new file mode 100644 index 0000000000..1efb057641 --- /dev/null +++ b/ui/src/types/modules/colors.ts @@ -0,0 +1,3 @@ +import * as Data from 'src/types/colors' + +export {Data} diff --git a/ui/src/types/modules/dashboards.ts b/ui/src/types/modules/dashboards.ts new file mode 100644 index 0000000000..3d5653cae0 --- /dev/null +++ b/ui/src/types/modules/dashboards.ts @@ -0,0 +1,6 @@ +import * as Data from 'src/types/dashboards' +import * as Actions from 'src/types/actions/dashboards' +import * as Apis from 'src/types/apis/dashboard' +import * as Reducers from 'src/types/reducers/dashboards' + +export {Data, Actions, Apis, Reducers} diff --git a/ui/src/types/modules/errors.ts b/ui/src/types/modules/errors.ts new file mode 100644 index 0000000000..a360b7c560 --- /dev/null +++ b/ui/src/types/modules/errors.ts @@ -0,0 +1,3 @@ +import * as Actions from 'src/types/actions/errors' + +export {Actions} diff --git a/ui/src/types/modules/index.ts b/ui/src/types/modules/index.ts new file mode 100644 index 0000000000..8b19214c38 --- /dev/null +++ b/ui/src/types/modules/index.ts @@ -0,0 +1,23 @@ +import * as Sources from 'src/types/modules/sources' +import * as Dashboards from 'src/types/modules/dashboards' +import * as TempVars from 'src/types/modules/tempVars' +import * as Queries from 'src/types/modules/queries' +import * as Colors from 'src/types/modules/colors' +import * as Annotations from 'src/types/modules/annotations' +import * as App from 'src/types/modules/app' +import * as CellEditorOverlay from 'src/types/modules/cellEditorOverlay' +import * as Errors from 'src/types/modules/errors' +import * as Notifications from 'src/types/modules/notifications' + +export { + Sources, + Dashboards, + TempVars, + Queries, + Colors, + Annotations, + App, + CellEditorOverlay, + Errors, + Notifications, +} diff --git a/ui/src/types/modules/notifications.ts b/ui/src/types/modules/notifications.ts new file mode 100644 index 0000000000..f73f6d9dc3 --- /dev/null +++ b/ui/src/types/modules/notifications.ts @@ -0,0 +1,3 @@ +import * as Actions from 'src/types/actions/notifications' + +export {Actions} diff --git a/ui/src/types/modules/queries.ts b/ui/src/types/modules/queries.ts new file mode 100644 index 0000000000..6478f29538 --- /dev/null +++ b/ui/src/types/modules/queries.ts @@ -0,0 +1,3 @@ +import * as Data from 'src/types/query' + +export {Data} diff --git a/ui/src/types/modules/sources.ts b/ui/src/types/modules/sources.ts new file mode 100644 index 0000000000..297fb23c1e --- /dev/null +++ b/ui/src/types/modules/sources.ts @@ -0,0 +1,3 @@ +import * as Data from 'src/types/sources' + +export {Data} diff --git a/ui/src/types/modules/tempVars.ts b/ui/src/types/modules/tempVars.ts new file mode 100644 index 0000000000..21a65c818c --- /dev/null +++ b/ui/src/types/modules/tempVars.ts @@ -0,0 +1,3 @@ +import * as Data from 'src/types/tempVars' + +export {Data} From 20a84023e5bc61a40372f0bc4e4c23eda00a4c57 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Sat, 23 Jun 2018 13:03:44 -0700 Subject: [PATCH 40/49] Rename types/apis/dashboard.ts dashboards.ts for consistency --- ui/src/dashboards/actions/index.ts | 2 +- ui/src/dashboards/apis/index.ts | 2 +- ui/src/types/apis/{dashboard.ts => dashboards.ts} | 0 ui/src/types/modules/dashboards.ts | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename ui/src/types/apis/{dashboard.ts => dashboards.ts} (100%) diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index c7a689a134..0f60cbf474 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -69,7 +69,7 @@ import { } from 'src/types' import * as DashboardData from 'src/types/dashboards' import * as DashboardActions from 'src/types/actions/dashboards' -import * as DashboardAPIs from 'src/types/apis/dashboard' +import * as DashboardAPIs from 'src/types/apis/dashboards' import * as DashboardReducers from 'src/types/reducers/dashboards' import * as AuthReducers from 'src/types/reducers/auth' import * as NotificationActions from 'src/types/actions/notifications' diff --git a/ui/src/dashboards/apis/index.ts b/ui/src/dashboards/apis/index.ts index 918a1efe86..545c051ea6 100644 --- a/ui/src/dashboards/apis/index.ts +++ b/ui/src/dashboards/apis/index.ts @@ -1,7 +1,7 @@ import AJAX from 'src/utils/ajax' import {AxiosResponse} from 'axios' -import {DashboardsResponse} from 'src/types/apis/dashboard' +import {DashboardsResponse} from 'src/types/apis/dashboards' export const getDashboards = (): Promise< AxiosResponse | DashboardsResponse diff --git a/ui/src/types/apis/dashboard.ts b/ui/src/types/apis/dashboards.ts similarity index 100% rename from ui/src/types/apis/dashboard.ts rename to ui/src/types/apis/dashboards.ts diff --git a/ui/src/types/modules/dashboards.ts b/ui/src/types/modules/dashboards.ts index 3d5653cae0..bd660aa552 100644 --- a/ui/src/types/modules/dashboards.ts +++ b/ui/src/types/modules/dashboards.ts @@ -1,6 +1,6 @@ import * as Data from 'src/types/dashboards' import * as Actions from 'src/types/actions/dashboards' -import * as Apis from 'src/types/apis/dashboard' +import * as Apis from 'src/types/apis/dashboards' import * as Reducers from 'src/types/reducers/dashboards' export {Data, Actions, Apis, Reducers} From a19ed861ce370a348990dde5ce7e3ce14f1a6d64 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Sat, 23 Jun 2018 13:09:22 -0700 Subject: [PATCH 41/49] Add Auth to Types module & sort module index by alpha --- ui/src/types/modules/auth.ts | 4 ++++ ui/src/types/modules/index.ts | 22 ++++++++++++---------- ui/src/types/reducers/auth.ts | 4 ++-- 3 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 ui/src/types/modules/auth.ts diff --git a/ui/src/types/modules/auth.ts b/ui/src/types/modules/auth.ts new file mode 100644 index 0000000000..1f852a6f32 --- /dev/null +++ b/ui/src/types/modules/auth.ts @@ -0,0 +1,4 @@ +import * as Data from 'src/types/auth' +import * as Reducers from 'src/types/reducers/auth' + +export {Data, Reducers} diff --git a/ui/src/types/modules/index.ts b/ui/src/types/modules/index.ts index 8b19214c38..1fdcfc7297 100644 --- a/ui/src/types/modules/index.ts +++ b/ui/src/types/modules/index.ts @@ -1,23 +1,25 @@ -import * as Sources from 'src/types/modules/sources' -import * as Dashboards from 'src/types/modules/dashboards' -import * as TempVars from 'src/types/modules/tempVars' -import * as Queries from 'src/types/modules/queries' -import * as Colors from 'src/types/modules/colors' import * as Annotations from 'src/types/modules/annotations' import * as App from 'src/types/modules/app' +import * as Auth from 'src/types/modules/auth' +import * as Dashboards from 'src/types/modules/dashboards' import * as CellEditorOverlay from 'src/types/modules/cellEditorOverlay' +import * as Colors from 'src/types/modules/colors' import * as Errors from 'src/types/modules/errors' import * as Notifications from 'src/types/modules/notifications' +import * as Queries from 'src/types/modules/queries' +import * as Sources from 'src/types/modules/sources' +import * as TempVars from 'src/types/modules/tempVars' export { - Sources, - Dashboards, - TempVars, - Queries, - Colors, Annotations, App, + Auth, + Dashboards, CellEditorOverlay, + Colors, Errors, Notifications, + Queries, + Sources, + TempVars, } diff --git a/ui/src/types/reducers/auth.ts b/ui/src/types/reducers/auth.ts index ef5796c651..05d55893af 100644 --- a/ui/src/types/reducers/auth.ts +++ b/ui/src/types/reducers/auth.ts @@ -1,8 +1,8 @@ -import * as AuthData from 'src/types/auth' +import * as Types from 'src/types/modules' export interface Auth { auth: { isUsingAuth: boolean - me: AuthData.Me + me: Types.Auth.Data.Me } } From c17eee82585fb5a2595e34e43e0cc5b008b7e765 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Sat, 23 Jun 2018 13:16:26 -0700 Subject: [PATCH 42/49] Refactor dashboards/actions/index to use new Types namespace --- ui/src/dashboards/actions/index.ts | 343 ++++++++++++++--------------- 1 file changed, 170 insertions(+), 173 deletions(-) diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index 0f60cbf474..cd1a6a4858 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -53,33 +53,18 @@ import idNormalizer, {TYPE_ID} from 'src/normalizers/id' import {defaultTimeRange} from 'src/shared/data/timeRanges' +// Types import {Dispatch} from 'redux' import {InjectedRouter} from 'react-router' import {Location} from 'history' import {AxiosResponse} from 'axios' -// import * as AllData from 'src/types' -import { - Cell, - Dashboard, - Source, - Template, - TemplateType, - TimeRange, - URLQueryParams, -} from 'src/types' -import * as DashboardData from 'src/types/dashboards' -import * as DashboardActions from 'src/types/actions/dashboards' -import * as DashboardAPIs from 'src/types/apis/dashboards' -import * as DashboardReducers from 'src/types/reducers/dashboards' -import * as AuthReducers from 'src/types/reducers/auth' -import * as NotificationActions from 'src/types/actions/notifications' -import * as ErrorActions from 'src/types/actions/errors' import {LocationAction} from 'react-router-redux' +import * as Types from 'src/types/modules' -export const loadDashboards: DashboardActions.LoadDashboardsActionCreator = ( - dashboards: Dashboard[], +export const loadDashboards: Types.Dashboards.Actions.LoadDashboardsActionCreator = ( + dashboards: Types.Dashboards.Data.Dashboard[], dashboardID?: number -): DashboardActions.LoadDashboardsAction => ({ +): Types.Dashboards.Actions.LoadDashboardsAction => ({ type: 'LOAD_DASHBOARDS', payload: { dashboards, @@ -87,19 +72,19 @@ export const loadDashboards: DashboardActions.LoadDashboardsActionCreator = ( }, }) -export const loadDashboard: DashboardActions.LoadDashboardActionCreator = ( - dashboard: Dashboard -): DashboardActions.LoadDashboardAction => ({ +export const loadDashboard: Types.Dashboards.Actions.LoadDashboardActionCreator = ( + dashboard: Types.Dashboards.Data.Dashboard +): Types.Dashboards.Actions.LoadDashboardAction => ({ type: 'LOAD_DASHBOARD', payload: { dashboard, }, }) -export const setDashTimeV1: DashboardActions.SetDashTimeV1ActionCreator = ( +export const setDashTimeV1: Types.Dashboards.Actions.SetDashTimeV1ActionCreator = ( dashboardID: number, - timeRange: TimeRange -): DashboardActions.SetDashTimeV1Action => ({ + timeRange: Types.Queries.Data.TimeRange +): Types.Dashboards.Actions.SetDashTimeV1Action => ({ type: 'SET_DASHBOARD_TIME_V1', payload: { dashboardID, @@ -107,71 +92,71 @@ export const setDashTimeV1: DashboardActions.SetDashTimeV1ActionCreator = ( }, }) -export const retainRangesDashTimeV1: DashboardActions.RetainRangesDashTimeV1ActionCreator = ( +export const retainRangesDashTimeV1: Types.Dashboards.Actions.RetainRangesDashTimeV1ActionCreator = ( dashboardIDs: string[] -): DashboardActions.RetainRangesDashTimeV1Action => ({ +): Types.Dashboards.Actions.RetainRangesDashTimeV1Action => ({ type: 'RETAIN_RANGES_DASHBOARD_TIME_V1', payload: {dashboardIDs}, }) -export const setTimeRange: DashboardActions.SetTimeRangeActionCreator = ( - timeRange: TimeRange -): DashboardActions.SetTimeRangeAction => ({ +export const setTimeRange: Types.Dashboards.Actions.SetTimeRangeActionCreator = ( + timeRange: Types.Queries.Data.TimeRange +): Types.Dashboards.Actions.SetTimeRangeAction => ({ type: 'SET_DASHBOARD_TIME_RANGE', payload: { timeRange, }, }) -export const setZoomedTimeRange: DashboardActions.SetZoomedTimeRangeActionCreator = ( - zoomedTimeRange: TimeRange -): DashboardActions.SetZoomedTimeRangeAction => ({ +export const setZoomedTimeRange: Types.Dashboards.Actions.SetZoomedTimeRangeActionCreator = ( + zoomedTimeRange: Types.Queries.Data.TimeRange +): Types.Dashboards.Actions.SetZoomedTimeRangeAction => ({ type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE', payload: { zoomedTimeRange, }, }) -export const updateDashboard: DashboardActions.UpdateDashboardActionCreator = ( - dashboard: Dashboard -): DashboardActions.UpdateDashboardAction => ({ +export const updateDashboard: Types.Dashboards.Actions.UpdateDashboardActionCreator = ( + dashboard: Types.Dashboards.Data.Dashboard +): Types.Dashboards.Actions.UpdateDashboardAction => ({ type: 'UPDATE_DASHBOARD', payload: { dashboard, }, }) -export const createDashboard: DashboardActions.CreateDashboardActionCreator = ( - dashboard: Dashboard -): DashboardActions.CreateDashboardAction => ({ +export const createDashboard: Types.Dashboards.Actions.CreateDashboardActionCreator = ( + dashboard: Types.Dashboards.Data.Dashboard +): Types.Dashboards.Actions.CreateDashboardAction => ({ type: 'CREATE_DASHBOARD', payload: { dashboard, }, }) -export const deleteDashboard: DashboardActions.DeleteDashboardActionCreator = ( - dashboard: Dashboard -): DashboardActions.DeleteDashboardAction => ({ +export const deleteDashboard: Types.Dashboards.Actions.DeleteDashboardActionCreator = ( + dashboard: Types.Dashboards.Data.Dashboard +): Types.Dashboards.Actions.DeleteDashboardAction => ({ type: 'DELETE_DASHBOARD', payload: { dashboard, }, }) -export const deleteDashboardFailed: DashboardActions.DeleteDashboardFailedActionCreator = ( - dashboard: Dashboard -): DashboardActions.DeleteDashboardFailedAction => ({ +export const deleteDashboardFailed: Types.Dashboards.Actions.DeleteDashboardFailedActionCreator = ( + dashboard: Types.Dashboards.Data.Dashboard +): Types.Dashboards.Actions.DeleteDashboardFailedAction => ({ type: 'DELETE_DASHBOARD_FAILED', payload: { dashboard, }, }) -export const syncDashboardCell: DashboardActions.SyncDashboardCellActionCreator = ( - dashboard: Dashboard, - cell: Cell -): DashboardActions.SyncDashboardCellAction => ({ +export const syncDashboardCell: Types.Dashboards.Actions.SyncDashboardCellActionCreator = ( + dashboard: Types.Dashboards.Data.Dashboard, + cell: Types.Dashboards.Data.Cell +): Types.Dashboards.Actions.SyncDashboardCellAction => ({ type: 'SYNC_DASHBOARD_CELL', payload: { dashboard, @@ -179,10 +164,10 @@ export const syncDashboardCell: DashboardActions.SyncDashboardCellActionCreator }, }) -export const addDashboardCell: DashboardActions.AddDashboardCellActionCreator = ( - dashboard: Dashboard, - cell: Cell -): DashboardActions.AddDashboardCellAction => ({ +export const addDashboardCell: Types.Dashboards.Actions.AddDashboardCellActionCreator = ( + dashboard: Types.Dashboards.Data.Dashboard, + cell: Types.Dashboards.Data.Cell +): Types.Dashboards.Actions.AddDashboardCellAction => ({ type: 'ADD_DASHBOARD_CELL', payload: { dashboard, @@ -190,10 +175,10 @@ export const addDashboardCell: DashboardActions.AddDashboardCellActionCreator = }, }) -export const deleteDashboardCell: DashboardActions.DeleteDashboardCellActionCreator = ( - dashboard: Dashboard, - cell: Cell -): DashboardActions.DeleteDashboardCellAction => ({ +export const deleteDashboardCell: Types.Dashboards.Actions.DeleteDashboardCellActionCreator = ( + dashboard: Types.Dashboards.Data.Dashboard, + cell: Types.Dashboards.Data.Cell +): Types.Dashboards.Actions.DeleteDashboardCellAction => ({ type: 'DELETE_DASHBOARD_CELL', payload: { dashboard, @@ -201,10 +186,10 @@ export const deleteDashboardCell: DashboardActions.DeleteDashboardCellActionCrea }, }) -export const editCellQueryStatus: DashboardActions.EditCellQueryStatusActionCreator = ( +export const editCellQueryStatus: Types.Dashboards.Actions.EditCellQueryStatusActionCreator = ( queryID: string, status: string -): DashboardActions.EditCellQueryStatusAction => ({ +): Types.Dashboards.Actions.EditCellQueryStatusAction => ({ type: 'EDIT_CELL_QUERY_STATUS', payload: { queryID, @@ -212,11 +197,11 @@ export const editCellQueryStatus: DashboardActions.EditCellQueryStatusActionCrea }, }) -export const templateVariableSelected: DashboardActions.TemplateVariableSelectedActionCreator = ( +export const templateVariableSelected: Types.Dashboards.Actions.TemplateVariableSelectedActionCreator = ( dashboardID: number, templateID: string, values -): DashboardActions.TemplateVariableSelectedAction => ({ +): Types.Dashboards.Actions.TemplateVariableSelectedAction => ({ type: 'TEMPLATE_VARIABLE_SELECTED', payload: { dashboardID, @@ -225,10 +210,10 @@ export const templateVariableSelected: DashboardActions.TemplateVariableSelected }, }) -export const templateVariablesSelectedByName: DashboardActions.TemplateVariablesSelectedByNameActionCreator = ( +export const templateVariablesSelectedByName: Types.Dashboards.Actions.TemplateVariablesSelectedByNameActionCreator = ( dashboardID: number, - queryParams: URLQueryParams -): DashboardActions.TemplateVariablesSelectedByNameAction => ({ + queryParams: Types.TempVars.Data.URLQueryParams +): Types.Dashboards.Actions.TemplateVariablesSelectedByNameAction => ({ type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME', payload: { dashboardID, @@ -236,11 +221,11 @@ export const templateVariablesSelectedByName: DashboardActions.TemplateVariables }, }) -export const editTemplateVariableValues: DashboardActions.EditTemplateVariableValuesActionCreator = ( +export const editTemplateVariableValues: Types.Dashboards.Actions.EditTemplateVariableValuesActionCreator = ( dashboardID: number, templateID: string, values -): DashboardActions.EditTemplateVariableValuesAction => ({ +): Types.Dashboards.Actions.EditTemplateVariableValuesAction => ({ type: 'EDIT_TEMPLATE_VARIABLE_VALUES', payload: { dashboardID, @@ -249,18 +234,18 @@ export const editTemplateVariableValues: DashboardActions.EditTemplateVariableVa }, }) -export const setHoverTime: DashboardActions.SetHoverTimeActionCreator = ( +export const setHoverTime: Types.Dashboards.Actions.SetHoverTimeActionCreator = ( hoverTime: string -): DashboardActions.SetHoverTimeAction => ({ +): Types.Dashboards.Actions.SetHoverTimeAction => ({ type: 'SET_HOVER_TIME', payload: { hoverTime, }, }) -export const setActiveCell: DashboardActions.SetActiveCellActionCreator = ( +export const setActiveCell: Types.Dashboards.Actions.SetActiveCellActionCreator = ( activeCellID: string -): DashboardActions.SetActiveCellAction => ({ +): Types.Dashboards.Actions.SetActiveCellAction => ({ type: 'SET_ACTIVE_CELL', payload: { activeCellID, @@ -269,17 +254,17 @@ export const setActiveCell: DashboardActions.SetActiveCellActionCreator = ( // Async Action Creators -export const getDashboardsAsync: DashboardActions.GetDashboardsDispatcher = (): DashboardActions.GetDashboardsThunk => async ( +export const getDashboardsAsync: Types.Dashboards.Actions.GetDashboardsDispatcher = (): Types.Dashboards.Actions.GetDashboardsThunk => async ( dispatch: Dispatch< - | DashboardActions.LoadDashboardsActionCreator - | ErrorActions.ErrorThrownActionCreator + | Types.Dashboards.Actions.LoadDashboardsActionCreator + | Types.Errors.Actions.ErrorThrownActionCreator > -): Promise => { +): Promise => { try { const { data: {dashboards}, } = (await getDashboardsAJAX()) as AxiosResponse< - DashboardAPIs.DashboardsResponse + Types.Dashboards.Apis.DashboardsResponse > dispatch(loadDashboards(dashboards)) return dashboards @@ -291,11 +276,11 @@ export const getDashboardsAsync: DashboardActions.GetDashboardsDispatcher = (): // gets update-to-date names of dashboards, but does not dispatch action // in order to avoid duplicate and out-of-sync state problems in redux -export const getDashboardsNamesAsync: DashboardActions.GetDashboardsNamesDispatcher = ( +export const getDashboardsNamesAsync: Types.Dashboards.Actions.GetDashboardsNamesDispatcher = ( sourceID: string -): DashboardActions.GetDashboardsNamesThunk => async ( - dispatch: Dispatch -): Promise => { +): Types.Dashboards.Actions.GetDashboardsNamesThunk => async ( + dispatch: Dispatch +): Promise => { try { // TODO: change this from getDashboardsAJAX to getDashboardsNamesAJAX // to just get dashboard names (and links) as api view call when that @@ -304,7 +289,7 @@ export const getDashboardsNamesAsync: DashboardActions.GetDashboardsNamesDispatc const { data: {dashboards}, } = (await getDashboardsAJAX()) as AxiosResponse< - DashboardAPIs.DashboardsResponse + Types.Dashboards.Apis.DashboardsResponse > const dashboardsNames = dashboards.map(({id, name}) => ({ id, @@ -320,7 +305,7 @@ export const getDashboardsNamesAsync: DashboardActions.GetDashboardsNamesDispatc export const getDashboardAsync = (dashboardID: number) => async ( dispatch -): Promise => { +): Promise => { try { const {data: dashboard} = await getDashboardAJAX(dashboardID) dispatch(loadDashboard(dashboard)) @@ -342,28 +327,32 @@ export const getChronografVersion = () => async (): Promise => { } } -const removeUnselectedTemplateValues = (dashboard: Dashboard): Template[] => { - const templates = getDeep(dashboard, 'templates', []).map( - template => { - if (template.type === TemplateType.CSV) { - return template - } - - const value = template.values.find(val => val.selected) - const values = value ? [value] : [] - - return {...template, values} +const removeUnselectedTemplateValues = ( + dashboard: Types.Dashboards.Data.Dashboard +): Types.TempVars.Data.Template[] => { + const templates = getDeep( + dashboard, + 'templates', + [] + ).map(template => { + if (template.type === Types.TempVars.Data.TemplateType.CSV) { + return template } - ) + + const value = template.values.find(val => val.selected) + const values = value ? [value] : [] + + return {...template, values} + }) return templates } export const putDashboard = ( - dashboard: Dashboard -): DashboardActions.PutDashboardThunk => async ( + dashboard: Types.Dashboards.Data.Dashboard +): Types.Dashboards.Actions.PutDashboardThunk => async ( dispatch: Dispatch< - | DashboardActions.UpdateDashboardAction - | ErrorActions.ErrorThrownActionCreator + | Types.Dashboards.Actions.UpdateDashboardAction + | Types.Errors.Actions.ErrorThrownActionCreator > ): Promise => { try { @@ -390,17 +379,19 @@ export const putDashboard = ( } } -export const putDashboardByID: DashboardActions.PutDashboardByIDDispatcher = ( +export const putDashboardByID: Types.Dashboards.Actions.PutDashboardByIDDispatcher = ( dashboardID: number -): DashboardActions.PutDashboardByIDThunk => async ( - dispatch: Dispatch, - getState: () => DashboardReducers.Dashboards +): Types.Dashboards.Actions.PutDashboardByIDThunk => async ( + dispatch: Dispatch, + getState: () => Types.Dashboards.Reducers.Dashboards ): Promise => { try { const { dashboardUI: {dashboards}, } = getState() - const dashboard: Dashboard = dashboards.find(d => d.id === +dashboardID) + const dashboard: Types.Dashboards.Data.Dashboard = dashboards.find( + d => d.id === +dashboardID + ) const templates = removeUnselectedTemplateValues(dashboard) await updateDashboardAJAX({...dashboard, templates}) } catch (error) { @@ -409,13 +400,13 @@ export const putDashboardByID: DashboardActions.PutDashboardByIDDispatcher = ( } } -export const updateDashboardCell: DashboardActions.UpdateDashboardCellDispatcher = ( - dashboard: Dashboard, - cell: Cell -): DashboardActions.UpdateDashboardCellThunk => async ( +export const updateDashboardCell: Types.Dashboards.Actions.UpdateDashboardCellDispatcher = ( + dashboard: Types.Dashboards.Data.Dashboard, + cell: Types.Dashboards.Data.Cell +): Types.Dashboards.Actions.UpdateDashboardCellThunk => async ( dispatch: Dispatch< - | DashboardActions.SyncDashboardCellActionCreator - | ErrorActions.ErrorThrownActionCreator + | Types.Dashboards.Actions.SyncDashboardCellActionCreator + | Types.Errors.Actions.ErrorThrownActionCreator > ): Promise => { try { @@ -427,14 +418,14 @@ export const updateDashboardCell: DashboardActions.UpdateDashboardCellDispatcher } } -export const deleteDashboardAsync: DashboardActions.DeleteDashboardDispatcher = ( - dashboard: Dashboard -): DashboardActions.DeleteDashboardThunk => async ( +export const deleteDashboardAsync: Types.Dashboards.Actions.DeleteDashboardDispatcher = ( + dashboard: Types.Dashboards.Data.Dashboard +): Types.Dashboards.Actions.DeleteDashboardThunk => async ( dispatch: Dispatch< - | DashboardActions.DeleteDashboardActionCreator - | NotificationActions.PublishNotificationActionCreator - | ErrorActions.ErrorThrownActionCreator - | DashboardActions.DeleteDashboardFailedActionCreator + | Types.Dashboards.Actions.DeleteDashboardActionCreator + | Types.Notifications.Actions.PublishNotificationActionCreator + | Types.Errors.Actions.ErrorThrownActionCreator + | Types.Dashboards.Actions.DeleteDashboardFailedActionCreator > ): Promise => { dispatch(deleteDashboard(dashboard)) @@ -452,14 +443,14 @@ export const deleteDashboardAsync: DashboardActions.DeleteDashboardDispatcher = } } -export const addDashboardCellAsync: DashboardActions.AddDashboardCellDispatcher = ( - dashboard: Dashboard, - cellType?: DashboardData.CellType -): DashboardActions.AddDashboardCellThunk => async ( +export const addDashboardCellAsync: Types.Dashboards.Actions.AddDashboardCellDispatcher = ( + dashboard: Types.Dashboards.Data.Dashboard, + cellType?: Types.Dashboards.Data.CellType +): Types.Dashboards.Actions.AddDashboardCellThunk => async ( dispatch: Dispatch< - | DashboardActions.AddDashboardCellAction - | NotificationActions.PublishNotificationActionCreator - | ErrorActions.ErrorThrownActionCreator + | Types.Dashboards.Actions.AddDashboardCellAction + | Types.Notifications.Actions.PublishNotificationActionCreator + | Types.Errors.Actions.ErrorThrownActionCreator > ): Promise => { try { @@ -475,14 +466,14 @@ export const addDashboardCellAsync: DashboardActions.AddDashboardCellDispatcher } } -export const cloneDashboardCellAsync: DashboardActions.CloneDashboardCellDispatcher = ( - dashboard: Dashboard, - cell: Cell -): DashboardActions.CloneDashboardCellThunk => async ( +export const cloneDashboardCellAsync: Types.Dashboards.Actions.CloneDashboardCellDispatcher = ( + dashboard: Types.Dashboards.Data.Dashboard, + cell: Types.Dashboards.Data.Cell +): Types.Dashboards.Actions.CloneDashboardCellThunk => async ( dispatch: Dispatch< - | DashboardActions.AddDashboardCellActionCreator - | NotificationActions.PublishNotificationActionCreator - | ErrorActions.ErrorThrownActionCreator + | Types.Dashboards.Actions.AddDashboardCellActionCreator + | Types.Notifications.Actions.PublishNotificationActionCreator + | Types.Errors.Actions.ErrorThrownActionCreator > ): Promise => { try { @@ -496,14 +487,14 @@ export const cloneDashboardCellAsync: DashboardActions.CloneDashboardCellDispatc } } -export const deleteDashboardCellAsync: DashboardActions.DeleteDashboardCellDispatcher = ( - dashboard: Dashboard, - cell: Cell -): DashboardActions.DeleteDashboardCellThunk => async ( +export const deleteDashboardCellAsync: Types.Dashboards.Actions.DeleteDashboardCellDispatcher = ( + dashboard: Types.Dashboards.Data.Dashboard, + cell: Types.Dashboards.Data.Cell +): Types.Dashboards.Actions.DeleteDashboardCellThunk => async ( dispatch: Dispatch< - | DashboardActions.DeleteDashboardCellActionCreator - | NotificationActions.PublishNotificationActionCreator - | ErrorActions.ErrorThrownActionCreator + | Types.Dashboards.Actions.DeleteDashboardCellActionCreator + | Types.Notifications.Actions.PublishNotificationActionCreator + | Types.Errors.Actions.ErrorThrownActionCreator > ): Promise => { try { @@ -516,9 +507,9 @@ export const deleteDashboardCellAsync: DashboardActions.DeleteDashboardCellDispa } } -export const importDashboardAsync = (dashboard: Dashboard) => async ( - dispatch -): Promise => { +export const importDashboardAsync = ( + dashboard: Types.Dashboards.Data.Dashboard +) => async (dispatch): Promise => { try { // save only selected template values to server const templatesWithOnlySelectedValues = removeUnselectedTemplateValues( @@ -543,7 +534,7 @@ export const importDashboardAsync = (dashboard: Dashboard) => async ( const { data: {dashboards}, } = (await getDashboardsAJAX()) as AxiosResponse< - DashboardAPIs.DashboardsResponse + Types.Dashboards.Apis.DashboardsResponse > dispatch(loadDashboards(dashboards)) @@ -562,13 +553,13 @@ export const importDashboardAsync = (dashboard: Dashboard) => async ( export const hydrateTempVarValuesAsync = ( dashboardID: number, - source: Source + source: Types.Sources.Data.Source ) => async (dispatch, getState): Promise => { try { const dashboard = getState().dashboardUI.dashboards.find( d => d.id === dashboardID ) - const templates: Template[] = dashboard.templates + const templates: Types.TempVars.Data.Template[] = dashboard.templates const queries = templates .filter( template => getDeep(template, 'query.influxql', '') !== '' @@ -595,9 +586,9 @@ const removeNullValues = obj => _.pickBy(obj, o => o) export const syncURLQueryParamsFromQueryParamsObject = ( location: Location, - updatedURLQueryParams: URLQueryParams, - deletedURLQueryParams: URLQueryParams = {} -): DashboardActions.SyncURLQueryFromQueryParamsObjectActionCreator => ( + updatedURLQueryParams: Types.TempVars.Data.URLQueryParams, + deletedURLQueryParams: Types.TempVars.Data.URLQueryParams = {} +): Types.Dashboards.Actions.SyncURLQueryFromQueryParamsObjectActionCreator => ( dispatch: Dispatch ): void => { const updatedLocationQuery = removeNullValues({ @@ -620,14 +611,14 @@ export const syncURLQueryParamsFromQueryParamsObject = ( dispatch(replace(updatedLocation)) } -export const syncURLQueryFromTempVars: DashboardActions.SyncURLQueryFromTempVarsDispatcher = ( +export const syncURLQueryFromTempVars: Types.Dashboards.Actions.SyncURLQueryFromTempVarsDispatcher = ( location: Location, - tempVars: Template[], - deletedTempVars: Template[] = [], - urlQueryParamsTimeRanges?: URLQueryParams -): DashboardActions.SyncURLQueryFromQueryParamsObjectActionCreator => ( + tempVars: Types.TempVars.Data.Template[], + deletedTempVars: Types.TempVars.Data.Template[] = [], + urlQueryParamsTimeRanges?: Types.TempVars.Data.URLQueryParams +): Types.Dashboards.Actions.SyncURLQueryFromQueryParamsObjectActionCreator => ( dispatch: Dispatch< - DashboardActions.SyncURLQueryFromQueryParamsObjectDispatcher + Types.Dashboards.Actions.SyncURLQueryFromQueryParamsObjectDispatcher > ): void => { const updatedURLQueryParams = generateURLQueryParamsFromTempVars(tempVars) @@ -655,13 +646,14 @@ export const syncURLQueryFromTempVars: DashboardActions.SyncURLQueryFromTempVars const syncDashboardTempVarsFromURLQueryParams = ( dashboardID: number, - urlQueryParams: URLQueryParams -): DashboardActions.SyncDashboardTempVarsFromURLQueryParamsDispatcher => ( + urlQueryParams: Types.TempVars.Data.URLQueryParams +): Types.Dashboards.Actions.SyncDashboardTempVarsFromURLQueryParamsDispatcher => ( dispatch: Dispatch< - | NotificationActions.PublishNotificationActionCreator - | DashboardActions.TemplateVariableSelectedAction + | Types.Notifications.Actions.PublishNotificationActionCreator + | Types.Dashboards.Actions.TemplateVariableSelectedAction >, - getState: () => DashboardReducers.Dashboards & AuthReducers.Auth + getState: () => Types.Dashboards.Reducers.Dashboards & + Types.Auth.Reducers.Auth ): void => { const { dashboardUI, @@ -694,11 +686,14 @@ const syncDashboardTempVarsFromURLQueryParams = ( const syncDashboardTimeRangeFromURLQueryParams = ( dashboardID: number, - urlQueryParams: URLQueryParams, + urlQueryParams: Types.TempVars.Data.URLQueryParams, location: Location -): DashboardActions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher => ( - dispatch: Dispatch, - getState: () => DashboardReducers.Dashboards & DashboardReducers.DashTimeV1 +): Types.Dashboards.Actions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher => ( + dispatch: Dispatch< + Types.Notifications.Actions.PublishNotificationActionCreator + >, + getState: () => Types.Dashboards.Reducers.Dashboards & + Types.Dashboards.Reducers.DashTimeV1 ): void => { const { dashboardUI: {dashboards}, @@ -757,10 +752,10 @@ const syncDashboardTimeRangeFromURLQueryParams = ( const syncDashboardFromURLQueryParams = ( dashboardID: number, location: Location -): DashboardActions.SyncDashboardFromURLQueryParamsDispatcher => ( +): Types.Dashboards.Actions.SyncDashboardFromURLQueryParamsDispatcher => ( dispatch: Dispatch< - | DashboardActions.SyncDashboardTempVarsFromURLQueryParamsDispatcher - | DashboardActions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher + | Types.Dashboards.Actions.SyncDashboardTempVarsFromURLQueryParamsDispatcher + | Types.Dashboards.Actions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher > ): void => { const urlQueryParams = queryString.parse(window.location.search) @@ -776,13 +771,15 @@ const syncDashboardFromURLQueryParams = ( ) } -export const getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = ( +export const getDashboardWithHydratedAndSyncedTempVarsAsync: Types.Dashboards.Actions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = ( dashboardID: number, - source: Source, + source: Types.Sources.Data.Source, router: InjectedRouter, location: Location -): DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk => async ( - dispatch: Dispatch +): Types.Dashboards.Actions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk => async ( + dispatch: Dispatch< + Types.Notifications.Actions.PublishNotificationActionCreator + > ): Promise => { const dashboard = await bindActionCreators(getDashboardAsync, dispatch)( dashboardID @@ -804,13 +801,13 @@ export const getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardActions.Ge ) } -export const setZoomedTimeRangeAsync: DashboardActions.SetZoomedTimeRangeDispatcher = ( - zoomedTimeRange: TimeRange, +export const setZoomedTimeRangeAsync: Types.Dashboards.Actions.SetZoomedTimeRangeDispatcher = ( + zoomedTimeRange: Types.Queries.Data.TimeRange, location: Location -): DashboardActions.SetZoomedTimeRangeThunk => async ( +): Types.Dashboards.Actions.SetZoomedTimeRangeThunk => async ( dispatch: Dispatch< - | DashboardActions.SetZoomedTimeRangeActionCreator - | DashboardActions.SyncURLQueryFromQueryParamsObjectDispatcher + | Types.Dashboards.Actions.SetZoomedTimeRangeActionCreator + | Types.Dashboards.Actions.SyncURLQueryFromQueryParamsObjectDispatcher > ): Promise => { dispatch(setZoomedTimeRange(zoomedTimeRange)) From 88abfcf9ee619bca42ef34f0ead22a17eab62be7 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Sat, 23 Jun 2018 13:55:52 -0700 Subject: [PATCH 43/49] Refactor all type imports modified in #3739 to unified Types ns --- .../dashboards/actions/cellEditorOverlay.ts | 53 +++--- .../components/CellEditorOverlay.tsx | 119 +++++++------- .../dashboards/components/DashboardHeader.tsx | 18 +-- .../dashboards/components/OverlayControls.tsx | 11 +- .../dashboards/components/SourceSelector.tsx | 11 +- ui/src/index.tsx | 5 +- ui/src/shared/actions/annotations.ts | 47 +++--- ui/src/shared/actions/app.ts | 18 +-- ui/src/shared/actions/errors.ts | 9 +- ui/src/shared/actions/notifications.ts | 11 +- ui/src/sources/containers/SourcePage.tsx | 7 +- ui/src/types/actions/cellEditorOverlay.ts | 26 ++- ui/src/types/actions/dashboards.ts | 152 +++++++++--------- ui/src/types/modules/annotations.ts | 3 +- ui/src/types/modules/errors.ts | 3 +- ui/src/types/modules/notifications.ts | 3 +- ui/src/types/sources.ts | 4 + 17 files changed, 251 insertions(+), 249 deletions(-) diff --git a/ui/src/dashboards/actions/cellEditorOverlay.ts b/ui/src/dashboards/actions/cellEditorOverlay.ts index 245894d60c..123fd13551 100644 --- a/ui/src/dashboards/actions/cellEditorOverlay.ts +++ b/ui/src/dashboards/actions/cellEditorOverlay.ts @@ -1,24 +1,21 @@ -import {Cell} from 'src/types' -import {ColorNumber, ColorString} from 'src/types/colors' -import * as DashboardData from 'src/types/dashboards' -import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay' +import * as Types from 'src/types/modules' -export const showCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator = ( - cell: Cell -): CellEditorOverlayActions.ShowCellEditorOverlayAction => ({ +export const showCellEditorOverlay: Types.CellEditorOverlay.Actions.ShowCellEditorOverlayActionCreator = ( + cell: Types.Dashboards.Data.Cell +): Types.CellEditorOverlay.Actions.ShowCellEditorOverlayAction => ({ type: 'SHOW_CELL_EDITOR_OVERLAY', payload: { cell, }, }) -export const hideCellEditorOverlay = (): CellEditorOverlayActions.HideCellEditorOverlayAction => ({ +export const hideCellEditorOverlay = (): Types.CellEditorOverlay.Actions.HideCellEditorOverlayAction => ({ type: 'HIDE_CELL_EDITOR_OVERLAY', }) export const changeCellType = ( - cellType: DashboardData.CellType -): CellEditorOverlayActions.ChangeCellTypeAction => ({ + cellType: Types.Dashboards.Data.CellType +): Types.CellEditorOverlay.Actions.ChangeCellTypeAction => ({ type: 'CHANGE_CELL_TYPE', payload: { cellType, @@ -27,7 +24,7 @@ export const changeCellType = ( export const renameCell = ( cellName: string -): CellEditorOverlayActions.RenameCellAction => ({ +): Types.CellEditorOverlay.Actions.RenameCellAction => ({ type: 'RENAME_CELL', payload: { cellName, @@ -35,8 +32,8 @@ export const renameCell = ( }) export const updateThresholdsListColors = ( - thresholdsListColors: ColorNumber[] -): CellEditorOverlayActions.UpdateThresholdsListColorsAction => ({ + thresholdsListColors: Types.Colors.Data.ColorNumber[] +): Types.CellEditorOverlay.Actions.UpdateThresholdsListColorsAction => ({ type: 'UPDATE_THRESHOLDS_LIST_COLORS', payload: { thresholdsListColors, @@ -44,8 +41,8 @@ export const updateThresholdsListColors = ( }) export const updateThresholdsListType = ( - thresholdsListType: DashboardData.ThresholdType -): CellEditorOverlayActions.UpdateThresholdsListTypeAction => ({ + thresholdsListType: Types.Dashboards.Data.ThresholdType +): Types.CellEditorOverlay.Actions.UpdateThresholdsListTypeAction => ({ type: 'UPDATE_THRESHOLDS_LIST_TYPE', payload: { thresholdsListType, @@ -53,8 +50,8 @@ export const updateThresholdsListType = ( }) export const updateGaugeColors = ( - gaugeColors: ColorNumber[] -): CellEditorOverlayActions.UpdateGaugeColorsAction => ({ + gaugeColors: Types.Colors.Data.ColorNumber[] +): Types.CellEditorOverlay.Actions.UpdateGaugeColorsAction => ({ type: 'UPDATE_GAUGE_COLORS', payload: { gaugeColors, @@ -62,8 +59,8 @@ export const updateGaugeColors = ( }) export const updateAxes = ( - axes: DashboardData.Axes -): CellEditorOverlayActions.UpdateAxesAction => ({ + axes: Types.Dashboards.Data.Axes +): Types.CellEditorOverlay.Actions.UpdateAxesAction => ({ type: 'UPDATE_AXES', payload: { axes, @@ -71,8 +68,8 @@ export const updateAxes = ( }) export const updateTableOptions = ( - tableOptions: DashboardData.TableOptions -): CellEditorOverlayActions.UpdateTableOptionsAction => ({ + tableOptions: Types.Dashboards.Data.TableOptions +): Types.CellEditorOverlay.Actions.UpdateTableOptionsAction => ({ type: 'UPDATE_TABLE_OPTIONS', payload: { tableOptions, @@ -80,8 +77,8 @@ export const updateTableOptions = ( }) export const updateLineColors = ( - lineColors: ColorString[] -): CellEditorOverlayActions.UpdateLineColorsAction => ({ + lineColors: Types.Colors.Data.ColorString[] +): Types.CellEditorOverlay.Actions.UpdateLineColorsAction => ({ type: 'UPDATE_LINE_COLORS', payload: { lineColors, @@ -90,7 +87,7 @@ export const updateLineColors = ( export const changeTimeFormat = ( timeFormat: string -): CellEditorOverlayActions.ChangeTimeFormatAction => ({ +): Types.CellEditorOverlay.Actions.ChangeTimeFormatAction => ({ type: 'CHANGE_TIME_FORMAT', payload: { timeFormat, @@ -98,8 +95,8 @@ export const changeTimeFormat = ( }) export const changeDecimalPlaces = ( - decimalPlaces: DashboardData.DecimalPlaces -): CellEditorOverlayActions.ChangeDecimalPlacesAction => ({ + decimalPlaces: Types.Dashboards.Data.DecimalPlaces +): Types.CellEditorOverlay.Actions.ChangeDecimalPlacesAction => ({ type: 'CHANGE_DECIMAL_PLACES', payload: { decimalPlaces, @@ -107,8 +104,8 @@ export const changeDecimalPlaces = ( }) export const updateFieldOptions = ( - fieldOptions: DashboardData.FieldOption[] -): CellEditorOverlayActions.UpdateFieldOptionsAction => ({ + fieldOptions: Types.Dashboards.Data.FieldOption[] +): Types.CellEditorOverlay.Actions.UpdateFieldOptionsAction => ({ type: 'UPDATE_FIELD_OPTIONS', payload: { fieldOptions, diff --git a/ui/src/dashboards/components/CellEditorOverlay.tsx b/ui/src/dashboards/components/CellEditorOverlay.tsx index 08d17eaad5..b0e87876c2 100644 --- a/ui/src/dashboards/components/CellEditorOverlay.tsx +++ b/ui/src/dashboards/components/CellEditorOverlay.tsx @@ -1,9 +1,10 @@ +// Libraries import React, {Component} from 'react' - import _ from 'lodash' import uuid from 'uuid' -import {getDeep} from 'src/utils/wrappers' +// Components +import {ErrorHandling} from 'src/shared/decorators/errors' import ResizeContainer from 'src/shared/components/ResizeContainer' import QueryMaker from 'src/dashboards/components/QueryMaker' import Visualization from 'src/dashboards/components/Visualization' @@ -11,14 +12,18 @@ import OverlayControls from 'src/dashboards/components/OverlayControls' import DisplayOptions from 'src/dashboards/components/DisplayOptions' import CEOBottom from 'src/dashboards/components/CEOBottom' -import * as queryTransitions from 'src/utils/queryTransitions' +// APIs +import {getQueryConfigAndStatus} from 'src/shared/apis' +// Utils +import {getDeep} from 'src/utils/wrappers' +import * as queryTransitions from 'src/utils/queryTransitions' import defaultQueryConfig from 'src/utils/defaultQueryConfig' import {buildQuery} from 'src/utils/influxql' -import {getQueryConfigAndStatus} from 'src/shared/apis' -import {IS_STATIC_LEGEND} from 'src/shared/constants' import {nextSource} from 'src/dashboards/utils/sources' +// Constants +import {IS_STATIC_LEGEND} from 'src/shared/constants' import {TYPE_QUERY_CONFIG} from 'src/dashboards/constants' import {removeUnselectedTemplateValues} from 'src/tempVars/constants' import {OVERLAY_TECHNOLOGY} from 'src/shared/constants/classNames' @@ -30,20 +35,8 @@ import { } from 'src/shared/constants' import {getCellTypeColors} from 'src/dashboards/constants/cellEditor' -import {ErrorHandling} from 'src/shared/decorators/errors' - -import { - TimeRange, - Source, - QueryConfig, - Cell, - CellQuery, - Legend, - Status, -} from 'src/types' -import {ColorString, ColorNumber} from 'src/types/colors' -import * as DashboardActions from 'src/types/actions/dashboards' -import {SourceOption} from 'src/dashboards/components/OverlayControls' +// Types +import * as Types from 'src/types/modules' type QueryTransitions = typeof queryTransitions type EditRawTextAsyncFunc = ( @@ -59,7 +52,7 @@ export type CellEditorOverlayActions = QueryActions & { editRawTextAsync: EditRawTextAsyncFunc } -const staticLegend: Legend = { +const staticLegend: Types.Dashboards.Data.Legend = { type: 'static', orientation: 'bottom', } @@ -70,37 +63,40 @@ interface Template { interface QueryStatus { queryID: string - status: Status + status: Types.Queries.Data.Status } interface Props { - sources: Source[] - editQueryStatus: DashboardActions.EditCellQueryStatusActionCreator + sources: Types.Sources.Data.Source[] + editQueryStatus: Types.Dashboards.Actions.EditCellQueryStatusActionCreator onCancel: () => void - onSave: (cell: Cell) => void - source: Source + onSave: (cell: Types.Dashboards.Data.Cell) => void + source: Types.Sources.Data.Source dashboardID: number queryStatus: QueryStatus autoRefresh: number templates: Template[] - timeRange: TimeRange + timeRange: Types.Queries.Data.TimeRange thresholdsListType: string - thresholdsListColors: ColorNumber[] - gaugeColors: ColorNumber[] - lineColors: ColorString[] - cell: Cell + thresholdsListColors: Types.Colors.Data.ColorNumber[] + gaugeColors: Types.Colors.Data.ColorNumber[] + lineColors: Types.Colors.Data.ColorString[] + cell: Types.Dashboards.Data.Cell } interface State { - queriesWorkingDraft: QueryConfig[] + queriesWorkingDraft: Types.Queries.Data.QueryConfig[] activeQueryIndex: number isDisplayOptionsTabActive: boolean isStaticLegend: boolean } -const createWorkingDraft = (source: Source, query: CellQuery): QueryConfig => { +const createWorkingDraft = ( + source: Types.Sources.Data.Source, + query: Types.Dashboards.Data.CellQuery +): Types.Queries.Data.QueryConfig => { const {queryConfig} = query - const draft: QueryConfig = { + const draft: Types.Queries.Data.QueryConfig = { ...queryConfig, id: uuid.v4(), source, @@ -110,11 +106,13 @@ const createWorkingDraft = (source: Source, query: CellQuery): QueryConfig => { } const createWorkingDrafts = ( - source: Source, - queries: CellQuery[] -): QueryConfig[] => + source: Types.Sources.Data.Source, + queries: Types.Dashboards.Data.CellQuery[] +): Types.Queries.Data.QueryConfig[] => _.cloneDeep( - queries.map((query: CellQuery) => createWorkingDraft(source, query)) + queries.map((query: Types.Dashboards.Data.CellQuery) => + createWorkingDraft(source, query) + ) ) @ErrorHandling @@ -248,7 +246,7 @@ class CellEditorOverlay extends Component { ) } - private get formattedSources(): SourceOption[] { + private get formattedSources(): Types.Sources.Data.SourceOption[] { const {sources} = this.props return sources.map(s => ({ ...s, @@ -303,15 +301,20 @@ class CellEditorOverlay extends Component { const {queriesWorkingDraft, isStaticLegend} = this.state const {cell, thresholdsListColors, gaugeColors, lineColors} = this.props - const queries: CellQuery[] = queriesWorkingDraft.map(q => { - const timeRange = q.range || {upper: null, lower: TEMP_VAR_DASHBOARD_TIME} - const source = getDeep(q.source, 'links.self', null) - return { - queryConfig: q, - query: q.rawText || buildQuery(TYPE_QUERY_CONFIG, timeRange, q), - source, + const queries: Types.Dashboards.Data.CellQuery[] = queriesWorkingDraft.map( + q => { + const timeRange = q.range || { + upper: null, + lower: TEMP_VAR_DASHBOARD_TIME, + } + const source = getDeep(q.source, 'links.self', null) + return { + queryConfig: q, + query: q.rawText || buildQuery(TYPE_QUERY_CONFIG, timeRange, q), + source, + } } - }) + ) const colors = getCellTypeColors({ cellType: cell.type, @@ -320,7 +323,7 @@ class CellEditorOverlay extends Component { lineColors, }) - const newCell: Cell = { + const newCell: Types.Dashboards.Data.Cell = { ...cell, queries, colors, @@ -342,8 +345,8 @@ class CellEditorOverlay extends Component { this.setState({isStaticLegend}) } - private handleSetQuerySource = (source: Source): void => { - const queriesWorkingDraft: QueryConfig[] = this.state.queriesWorkingDraft.map( + private handleSetQuerySource = (source: Types.Sources.Data.Source): void => { + const queriesWorkingDraft: Types.Queries.Data.QueryConfig[] = this.state.queriesWorkingDraft.map( q => ({ ..._.cloneDeep(q), source, @@ -419,8 +422,8 @@ class CellEditorOverlay extends Component { ) const config = data.queries.find(q => q.id === id) - const nextQueries: QueryConfig[] = this.state.queriesWorkingDraft.map( - (q: QueryConfig) => { + const nextQueries: Types.Queries.Data.QueryConfig[] = this.state.queriesWorkingDraft.map( + (q: Types.Queries.Data.QueryConfig) => { if (q.id === id) { const isQuerySupportedByExplorer = !isUsingUserDefinedTempVars @@ -448,18 +451,20 @@ class CellEditorOverlay extends Component { private findSelectedSource = (): string => { const {source} = this.props const sources = this.formattedSources - const currentSource = getDeep( + const currentSource = getDeep( this.state.queriesWorkingDraft, '0.source', null ) if (!currentSource) { - const defaultSource: Source = sources.find(s => s.id === source.id) + const defaultSource: Types.Sources.Data.Source = sources.find( + s => s.id === source.id + ) return (defaultSource && defaultSource.text) || 'No sources' } - const selected: Source = sources.find( + const selected: Types.Sources.Data.Source = sources.find( s => s.links.self === currentSource.links.self ) return (selected && selected.text) || 'No sources' @@ -503,7 +508,7 @@ class CellEditorOverlay extends Component { const {queriesWorkingDraft} = this.state return queriesWorkingDraft.every( - (query: QueryConfig) => + (query: Types.Queries.Data.QueryConfig) => (!!query.measurement && !!query.database && !!query.fields.length) || !!query.rawText ) @@ -523,7 +528,7 @@ class CellEditorOverlay extends Component { return result } - private get initialSource(): Source { + private get initialSource(): Types.Sources.Data.Source { const { cell: {queries}, source, @@ -542,7 +547,7 @@ class CellEditorOverlay extends Component { return source } - private get source(): Source { + private get source(): Types.Sources.Data.Source { const {source, sources} = this.props const query = _.get(this.state.queriesWorkingDraft, 0, {source: null}) diff --git a/ui/src/dashboards/components/DashboardHeader.tsx b/ui/src/dashboards/components/DashboardHeader.tsx index 10e603521c..8efecc684a 100644 --- a/ui/src/dashboards/components/DashboardHeader.tsx +++ b/ui/src/dashboards/components/DashboardHeader.tsx @@ -11,28 +11,26 @@ import GraphTips from 'src/shared/components/GraphTips' import DashboardHeaderEdit from 'src/dashboards/components/DashboardHeaderEdit' import DashboardSwitcher from 'src/dashboards/components/DashboardSwitcher' -import {Dashboard, TimeRange} from 'src/types' -import {DashboardName} from 'src/types/dashboards' -import * as AppActions from 'src/types/actions/app' +import * as Types from 'src/types/modules' interface Props { activeDashboard: string - dashboard: Dashboard + dashboard: Types.Dashboards.Data.Dashboard onEditDashboard: () => void - timeRange: TimeRange + timeRange: Types.Queries.Data.TimeRange autoRefresh: number isEditMode?: boolean - handleChooseTimeRange: (timeRange: TimeRange) => void - handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator + handleChooseTimeRange: (timeRange: Types.Queries.Data.TimeRange) => void + handleChooseAutoRefresh: Types.App.Actions.SetAutoRefreshActionCreator onManualRefresh: () => void - handleClickPresentationButton: AppActions.DelayEnablePresentationModeDispatcher + handleClickPresentationButton: Types.App.Actions.DelayEnablePresentationModeDispatcher onAddCell: () => void onToggleTempVarControls: () => void showTemplateControlBar: boolean - zoomedTimeRange: TimeRange + zoomedTimeRange: Types.Queries.Data.TimeRange onCancel: () => void onSave: (name: string) => Promise - names: DashboardName[] + names: Types.Dashboards.Data.DashboardName[] isHidden: boolean } diff --git a/ui/src/dashboards/components/OverlayControls.tsx b/ui/src/dashboards/components/OverlayControls.tsx index a87f865f2b..3dc013e5ac 100644 --- a/ui/src/dashboards/components/OverlayControls.tsx +++ b/ui/src/dashboards/components/OverlayControls.tsx @@ -3,11 +3,8 @@ import classnames from 'classnames' import ConfirmOrCancel from 'src/shared/components/ConfirmOrCancel' import SourceSelector from 'src/dashboards/components/SourceSelector' -import {QueryConfig, Source} from 'src/types' -export interface SourceOption extends Source { - text: string -} +import * as Types from 'src/types/modules' interface Props { onCancel: () => void @@ -17,10 +14,10 @@ interface Props { displayOptions: boolean ) => (event: MouseEvent) => void isSavable: boolean - sources: SourceOption[] - onSetQuerySource: (source: Source) => void + sources: Types.Sources.Data.SourceOption[] + onSetQuerySource: (source: Types.Sources.Data.Source) => void selected: string - queries: QueryConfig[] + queries: Types.Queries.Data.QueryConfig[] } const OverlayControls: SFC = ({ diff --git a/ui/src/dashboards/components/SourceSelector.tsx b/ui/src/dashboards/components/SourceSelector.tsx index d09eca2ee5..a6dba804a5 100644 --- a/ui/src/dashboards/components/SourceSelector.tsx +++ b/ui/src/dashboards/components/SourceSelector.tsx @@ -1,13 +1,14 @@ import React, {SFC} from 'react' + import Dropdown from 'src/shared/components/Dropdown' -import {QueryConfig} from 'src/types' -import {SourceOption} from 'src/dashboards/components/OverlayControls' + +import * as Types from 'src/types/modules' interface Props { - sources: SourceOption[] + sources: Types.Sources.Data.SourceOption[] selected: string - onSetQuerySource: (source: SourceOption) => void - queries: QueryConfig[] + onSetQuerySource: (source: Types.Sources.Data.SourceOption) => void + queries: Types.Queries.Data.QueryConfig[] } const SourceSelector: SFC = ({ diff --git a/ui/src/index.tsx b/ui/src/index.tsx index 2f6aae6aa1..9920a75360 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -49,7 +49,8 @@ import {notify} from 'src/shared/actions/notifications' import 'src/style/chronograf.scss' import {HEARTBEAT_INTERVAL} from 'src/shared/constants' -import * as ErrorData from 'src/types/errors' + +import * as Types from 'src/types/modules' const errorsQueue = [] @@ -190,7 +191,7 @@ class Root extends PureComponent<{}, State> { errorThrown( {status: 0, auth: null}, error, - ErrorData.AlertType.Warning + Types.Errors.Data.AlertType.Warning ) ) } diff --git a/ui/src/shared/actions/annotations.ts b/ui/src/shared/actions/annotations.ts index 4f4eb18ede..1fbfea6e40 100644 --- a/ui/src/shared/actions/annotations.ts +++ b/ui/src/shared/actions/annotations.ts @@ -1,39 +1,38 @@ import * as api from 'src/shared/apis/annotation' import {Dispatch} from 'redux' -import * as AnnotationData from 'src/types/annotations' -import * as AnnotationActions from 'src/types/actions/annotations' +import * as Types from 'src/types/modules' -export const editingAnnotation = (): AnnotationActions.EditingAnnotationAction => ({ +export const editingAnnotation = (): Types.Annotations.Actions.EditingAnnotationAction => ({ type: 'EDITING_ANNOTATION', }) -export const dismissEditingAnnotation = (): AnnotationActions.DismissEditingAnnotationAction => ({ +export const dismissEditingAnnotation = (): Types.Annotations.Actions.DismissEditingAnnotationAction => ({ type: 'DISMISS_EDITING_ANNOTATION', }) -export const addingAnnotation = (): AnnotationActions.AddingAnnotationAction => ({ +export const addingAnnotation = (): Types.Annotations.Actions.AddingAnnotationAction => ({ type: 'ADDING_ANNOTATION', }) -export const addingAnnotationSuccess = (): AnnotationActions.AddingAnnotationSuccessAction => ({ +export const addingAnnotationSuccess = (): Types.Annotations.Actions.AddingAnnotationSuccessAction => ({ type: 'ADDING_ANNOTATION_SUCCESS', }) -export const dismissAddingAnnotation = (): AnnotationActions.DismissAddingAnnotationAction => ({ +export const dismissAddingAnnotation = (): Types.Annotations.Actions.DismissAddingAnnotationAction => ({ type: 'DISMISS_ADDING_ANNOTATION', }) -export const mouseEnterTempAnnotation = (): AnnotationActions.MouseEnterTempAnnotationAction => ({ +export const mouseEnterTempAnnotation = (): Types.Annotations.Actions.MouseEnterTempAnnotationAction => ({ type: 'MOUSEENTER_TEMP_ANNOTATION', }) -export const mouseLeaveTempAnnotation = (): AnnotationActions.MouseLeaveTempAnnotationAction => ({ +export const mouseLeaveTempAnnotation = (): Types.Annotations.Actions.MouseLeaveTempAnnotationAction => ({ type: 'MOUSELEAVE_TEMP_ANNOTATION', }) export const loadAnnotations = ( - annotations: AnnotationData.AnnotationInterface[] -): AnnotationActions.LoadAnnotationsAction => ({ + annotations: Types.Annotations.Data.AnnotationInterface[] +): Types.Annotations.Actions.LoadAnnotationsAction => ({ type: 'LOAD_ANNOTATIONS', payload: { annotations, @@ -41,8 +40,8 @@ export const loadAnnotations = ( }) export const updateAnnotation = ( - annotation: AnnotationData.AnnotationInterface -): AnnotationActions.UpdateAnnotationAction => ({ + annotation: Types.Annotations.Data.AnnotationInterface +): Types.Annotations.Actions.UpdateAnnotationAction => ({ type: 'UPDATE_ANNOTATION', payload: { annotation, @@ -50,8 +49,8 @@ export const updateAnnotation = ( }) export const deleteAnnotation = ( - annotation: AnnotationData.AnnotationInterface -): AnnotationActions.DeleteAnnotationAction => ({ + annotation: Types.Annotations.Data.AnnotationInterface +): Types.Annotations.Actions.DeleteAnnotationAction => ({ type: 'DELETE_ANNOTATION', payload: { annotation, @@ -59,8 +58,8 @@ export const deleteAnnotation = ( }) export const addAnnotation = ( - annotation: AnnotationData.AnnotationInterface -): AnnotationActions.AddAnnotationAction => ({ + annotation: Types.Annotations.Data.AnnotationInterface +): Types.Annotations.Actions.AddAnnotationAction => ({ type: 'ADD_ANNOTATION', payload: { annotation, @@ -69,7 +68,7 @@ export const addAnnotation = ( export const addAnnotationAsync = ( createUrl: string, - annotation: AnnotationData.AnnotationInterface + annotation: Types.Annotations.Data.AnnotationInterface ) => async dispatch => { dispatch(addAnnotation(annotation)) const savedAnnotation = await api.createAnnotation(createUrl, annotation) @@ -77,25 +76,25 @@ export const addAnnotationAsync = ( dispatch(deleteAnnotation(annotation)) } -export const getAnnotationsAsync: AnnotationActions.GetAnnotationsDispatcher = ( +export const getAnnotationsAsync: Types.Annotations.Actions.GetAnnotationsDispatcher = ( indexUrl: string, - {since, until}: AnnotationData.AnnotationRange -): AnnotationActions.GetAnnotationsThunk => async ( - dispatch: Dispatch + {since, until}: Types.Annotations.Data.AnnotationRange +): Types.Annotations.Actions.GetAnnotationsThunk => async ( + dispatch: Dispatch ): Promise => { const annotations = await api.getAnnotations(indexUrl, since, until) dispatch(loadAnnotations(annotations)) } export const deleteAnnotationAsync = ( - annotation: AnnotationData.AnnotationInterface + annotation: Types.Annotations.Data.AnnotationInterface ) => async dispatch => { await api.deleteAnnotation(annotation) dispatch(deleteAnnotation(annotation)) } export const updateAnnotationAsync = ( - annotation: AnnotationData.AnnotationInterface + annotation: Types.Annotations.Data.AnnotationInterface ) => async dispatch => { await api.updateAnnotation(annotation) dispatch(updateAnnotation(annotation)) diff --git a/ui/src/shared/actions/app.ts b/ui/src/shared/actions/app.ts index 1b368df596..858203d1c4 100644 --- a/ui/src/shared/actions/app.ts +++ b/ui/src/shared/actions/app.ts @@ -4,20 +4,20 @@ import {notify} from 'src/shared/actions/notifications' import {notifyPresentationMode} from 'src/shared/copy/notifications' import {Dispatch} from 'redux' -import * as AppActions from 'src/types/actions/app' +import * as Types from 'src/types/modules' // ephemeral state action creators -export const enablePresentationMode = (): AppActions.EnablePresentationModeAction => ({ +export const enablePresentationMode = (): Types.App.Actions.EnablePresentationModeAction => ({ type: 'ENABLE_PRESENTATION_MODE', }) -export const disablePresentationMode = (): AppActions.DisablePresentationModeAction => ({ +export const disablePresentationMode = (): Types.App.Actions.DisablePresentationModeAction => ({ type: 'DISABLE_PRESENTATION_MODE', }) -export const delayEnablePresentationMode: AppActions.DelayEnablePresentationModeDispatcher = () => async ( - dispatch: Dispatch +export const delayEnablePresentationMode: Types.App.Actions.DelayEnablePresentationModeDispatcher = () => async ( + dispatch: Dispatch ): Promise => setTimeout(() => { dispatch(enablePresentationMode()) @@ -26,20 +26,20 @@ export const delayEnablePresentationMode: AppActions.DelayEnablePresentationMode // persistent state action creators -export const setAutoRefresh: AppActions.SetAutoRefreshActionCreator = ( +export const setAutoRefresh: Types.App.Actions.SetAutoRefreshActionCreator = ( milliseconds: number -): AppActions.SetAutoRefreshAction => ({ +): Types.App.Actions.SetAutoRefreshAction => ({ type: 'SET_AUTOREFRESH', payload: { milliseconds, }, }) -export const templateControlBarVisibilityToggled = (): AppActions.TemplateControlBarVisibilityToggledAction => ({ +export const templateControlBarVisibilityToggled = (): Types.App.Actions.TemplateControlBarVisibilityToggledAction => ({ type: 'TEMPLATE_CONTROL_BAR_VISIBILITY_TOGGLED', }) -export const noop = (): AppActions.NoopAction => ({ +export const noop = (): Types.App.Actions.NoopAction => ({ type: 'NOOP', payload: {}, }) diff --git a/ui/src/shared/actions/errors.ts b/ui/src/shared/actions/errors.ts index f74cff97cf..3b17c2ea0e 100644 --- a/ui/src/shared/actions/errors.ts +++ b/ui/src/shared/actions/errors.ts @@ -1,11 +1,10 @@ -import * as ErrorData from 'src/types/errors' -import * as ErrorActions from 'src/types/actions/errors' +import * as Types from 'src/types/modules' export const errorThrown = ( - error: ErrorData.ErrorDescription, + error: Types.Errors.Data.ErrorDescription, altText?: string, - alertType?: ErrorData.AlertType -): ErrorActions.ErrorThrownAction => ({ + alertType?: Types.Errors.Data.AlertType +): Types.Errors.Actions.ErrorThrownAction => ({ type: 'ERROR_THROWN', error, altText, diff --git a/ui/src/shared/actions/notifications.ts b/ui/src/shared/actions/notifications.ts index ded2d75cf3..0da924710a 100644 --- a/ui/src/shared/actions/notifications.ts +++ b/ui/src/shared/actions/notifications.ts @@ -1,15 +1,14 @@ -import {Notification} from 'src/types' -import * as NotificationActions from 'src/types/actions/notifications' +import * as Types from 'src/types/modules' -export const notify: NotificationActions.PublishNotificationActionCreator = ( - notification: Notification -): NotificationActions.PublishNotificationAction => ({ +export const notify: Types.Notifications.Actions.PublishNotificationActionCreator = ( + notification: Types.Notifications.Data.Notification +): Types.Notifications.Actions.PublishNotificationAction => ({ type: 'PUBLISH_NOTIFICATION', payload: {notification}, }) export const dismissNotification = ( id: string -): NotificationActions.DismissNotificationAction => ({ +): Types.Notifications.Actions.DismissNotificationAction => ({ type: 'DISMISS_NOTIFICATION', payload: {id}, }) diff --git a/ui/src/sources/containers/SourcePage.tsx b/ui/src/sources/containers/SourcePage.tsx index 306029bdaf..55a005f08a 100644 --- a/ui/src/sources/containers/SourcePage.tsx +++ b/ui/src/sources/containers/SourcePage.tsx @@ -29,11 +29,10 @@ import { } from 'src/shared/copy/notifications' import {ErrorHandling} from 'src/shared/decorators/errors' -import {Source} from 'src/types' -import * as NotificationActions from 'src/types/actions/notifications' +import * as Types from 'src/types/modules' interface Props extends WithRouterProps { - notify: NotificationActions.PublishNotificationActionCreator + notify: Types.Notifications.Actions.PublishNotificationActionCreator addSource: AddSource updateSource: UpdateSource } @@ -41,7 +40,7 @@ interface Props extends WithRouterProps { interface State { isCreated: boolean isLoading: boolean - source: Partial + source: Partial editMode: boolean isInitialSource: boolean } diff --git a/ui/src/types/actions/cellEditorOverlay.ts b/ui/src/types/actions/cellEditorOverlay.ts index 0648c6cd1a..6f1392b36b 100644 --- a/ui/src/types/actions/cellEditorOverlay.ts +++ b/ui/src/types/actions/cellEditorOverlay.ts @@ -1,6 +1,4 @@ -import {Cell} from 'src/types' -import {ColorNumber, ColorString} from 'src/types/colors' -import * as DashboardData from 'src/types/dashboards' +import * as Types from 'src/types/modules' export type Action = | ShowCellEditorOverlayAction @@ -18,13 +16,13 @@ export type Action = | UpdateFieldOptionsAction export type ShowCellEditorOverlayActionCreator = ( - cell: Cell + cell: Types.Dashboards.Data.Cell ) => ShowCellEditorOverlayAction export interface ShowCellEditorOverlayAction { type: 'SHOW_CELL_EDITOR_OVERLAY' payload: { - cell: Cell + cell: Types.Dashboards.Data.Cell } } @@ -37,7 +35,7 @@ export interface HideCellEditorOverlayAction { export interface ChangeCellTypeAction { type: 'CHANGE_CELL_TYPE' payload: { - cellType: DashboardData.CellType + cellType: Types.Dashboards.Data.CellType } } @@ -51,42 +49,42 @@ export interface RenameCellAction { export interface UpdateThresholdsListColorsAction { type: 'UPDATE_THRESHOLDS_LIST_COLORS' payload: { - thresholdsListColors: ColorNumber[] + thresholdsListColors: Types.Colors.Data.ColorNumber[] } } export interface UpdateThresholdsListTypeAction { type: 'UPDATE_THRESHOLDS_LIST_TYPE' payload: { - thresholdsListType: DashboardData.ThresholdType + thresholdsListType: Types.Dashboards.Data.ThresholdType } } export interface UpdateGaugeColorsAction { type: 'UPDATE_GAUGE_COLORS' payload: { - gaugeColors: ColorNumber[] + gaugeColors: Types.Colors.Data.ColorNumber[] } } export interface UpdateAxesAction { type: 'UPDATE_AXES' payload: { - axes: DashboardData.Axes + axes: Types.Dashboards.Data.Axes } } export interface UpdateTableOptionsAction { type: 'UPDATE_TABLE_OPTIONS' payload: { - tableOptions: DashboardData.TableOptions + tableOptions: Types.Dashboards.Data.TableOptions } } export interface UpdateLineColorsAction { type: 'UPDATE_LINE_COLORS' payload: { - lineColors: ColorString[] + lineColors: Types.Colors.Data.ColorString[] } } @@ -100,13 +98,13 @@ export interface ChangeTimeFormatAction { export interface ChangeDecimalPlacesAction { type: 'CHANGE_DECIMAL_PLACES' payload: { - decimalPlaces: DashboardData.DecimalPlaces + decimalPlaces: Types.Dashboards.Data.DecimalPlaces } } export interface UpdateFieldOptionsAction { type: 'UPDATE_FIELD_OPTIONS' payload: { - fieldOptions: DashboardData.FieldOption[] + fieldOptions: Types.Dashboards.Data.FieldOption[] } } diff --git a/ui/src/types/actions/dashboards.ts b/ui/src/types/actions/dashboards.ts index 02d7cf544f..555eca6b31 100644 --- a/ui/src/types/actions/dashboards.ts +++ b/ui/src/types/actions/dashboards.ts @@ -2,35 +2,30 @@ import {Dispatch} from 'redux' import {InjectedRouter} from 'react-router' import {LocationAction} from 'react-router-redux' import {Source} from 'src/types' -import * as DashboardData from 'src/types/dashboards' -import * as QueryData from 'src/types/query' -import * as TempVarData from 'src/types/tempVars' -import * as ErrorActions from 'src/types/actions/errors' -import * as NotificationActions from 'src/types/actions/notifications' -import * as DashboardReducers from 'src/types/reducers/dashboards' import {Location} from 'history' +import * as Types from 'src/types/modules' export type LoadDashboardsActionCreator = ( - dashboards: DashboardData.Dashboard[], + dashboards: Types.Dashboards.Data.Dashboard[], dashboardID?: number ) => LoadDashboardsAction export interface LoadDashboardsAction { type: 'LOAD_DASHBOARDS' payload: { - dashboards: DashboardData.Dashboard[] + dashboards: Types.Dashboards.Data.Dashboard[] dashboardID: number } } export type LoadDashboardActionCreator = ( - dashboard: DashboardData.Dashboard + dashboard: Types.Dashboards.Data.Dashboard ) => LoadDashboardAction export interface LoadDashboardAction { type: 'LOAD_DASHBOARD' payload: { - dashboard: DashboardData.Dashboard + dashboard: Types.Dashboards.Data.Dashboard } } @@ -38,13 +33,13 @@ export interface SetDashTimeV1Action { type: 'SET_DASHBOARD_TIME_V1' payload: { dashboardID: number - timeRange: QueryData.TimeRange + timeRange: Types.Queries.Data.TimeRange } } export type SetDashTimeV1ActionCreator = ( dashboardID: number, - timeRange: QueryData.TimeRange + timeRange: Types.Queries.Data.TimeRange ) => SetDashTimeV1Action export interface RetainRangesDashTimeV1Action { @@ -59,18 +54,18 @@ export type RetainRangesDashTimeV1ActionCreator = ( ) => RetainRangesDashTimeV1Action export type SetTimeRangeActionCreator = ( - timeRange: QueryData.TimeRange + timeRange: Types.Queries.Data.TimeRange ) => SetTimeRangeAction export interface SetTimeRangeAction { type: 'SET_DASHBOARD_TIME_RANGE' payload: { - timeRange: QueryData.TimeRange + timeRange: Types.Queries.Data.TimeRange } } export type SetZoomedTimeRangeDispatcher = ( - zoomedTimeRange: QueryData.TimeRange, + zoomedTimeRange: Types.Queries.Data.TimeRange, location: Location ) => SetZoomedTimeRangeThunk @@ -82,135 +77,135 @@ export type SetZoomedTimeRangeThunk = ( ) => Promise export type SetZoomedTimeRangeActionCreator = ( - zoomedTimeRange: QueryData.TimeRange + zoomedTimeRange: Types.Queries.Data.TimeRange ) => SetZoomedTimeRangeAction export interface SetZoomedTimeRangeAction { type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE' payload: { - zoomedTimeRange: QueryData.TimeRange + zoomedTimeRange: Types.Queries.Data.TimeRange } } export interface UpdateDashboardAction { type: 'UPDATE_DASHBOARD' payload: { - dashboard: DashboardData.Dashboard + dashboard: Types.Dashboards.Data.Dashboard } } export type UpdateDashboardActionCreator = ( - dashboard: DashboardData.Dashboard + dashboard: Types.Dashboards.Data.Dashboard ) => UpdateDashboardAction export type CreateDashboardActionCreator = ( - dashboard: DashboardData.Dashboard + dashboard: Types.Dashboards.Data.Dashboard ) => CreateDashboardAction export interface CreateDashboardAction { type: 'CREATE_DASHBOARD' payload: { - dashboard: DashboardData.Dashboard + dashboard: Types.Dashboards.Data.Dashboard } } export type DeleteDashboardActionCreator = ( - dashboard: DashboardData.Dashboard + dashboard: Types.Dashboards.Data.Dashboard ) => DeleteDashboardAction export interface DeleteDashboardAction { type: 'DELETE_DASHBOARD' payload: { - dashboard: DashboardData.Dashboard + dashboard: Types.Dashboards.Data.Dashboard } } export type DeleteDashboardFailedActionCreator = ( - dashboard: DashboardData.Dashboard + dashboard: Types.Dashboards.Data.Dashboard ) => DeleteDashboardFailedAction export interface DeleteDashboardFailedAction { type: 'DELETE_DASHBOARD_FAILED' payload: { - dashboard: DashboardData.Dashboard + dashboard: Types.Dashboards.Data.Dashboard } } export type SyncDashboardCellActionCreator = ( - dashboard: DashboardData.Dashboard, - cell: DashboardData.Cell + dashboard: Types.Dashboards.Data.Dashboard, + cell: Types.Dashboards.Data.Cell ) => SyncDashboardCellAction export interface SyncDashboardCellAction { type: 'SYNC_DASHBOARD_CELL' payload: { - dashboard: DashboardData.Dashboard - cell: DashboardData.Cell + dashboard: Types.Dashboards.Data.Dashboard + cell: Types.Dashboards.Data.Cell } } export type AddDashboardCellDispatcher = ( - dashboard: DashboardData.Dashboard, - cellType?: DashboardData.CellType + dashboard: Types.Dashboards.Data.Dashboard, + cellType?: Types.Dashboards.Data.CellType ) => AddDashboardCellThunk export type AddDashboardCellThunk = ( dispatch: Dispatch< | AddDashboardCellAction - | NotificationActions.PublishNotificationActionCreator - | ErrorActions.ErrorThrownActionCreator + | Types.Notifications.Actions.PublishNotificationActionCreator + | Types.Errors.Actions.ErrorThrownActionCreator > ) => Promise export type AddDashboardCellActionCreator = ( - dashboard: DashboardData.Dashboard, - cell: DashboardData.Cell + dashboard: Types.Dashboards.Data.Dashboard, + cell: Types.Dashboards.Data.Cell ) => AddDashboardCellAction export interface AddDashboardCellAction { type: 'ADD_DASHBOARD_CELL' payload: { - dashboard: DashboardData.Dashboard - cell: DashboardData.Cell + dashboard: Types.Dashboards.Data.Dashboard + cell: Types.Dashboards.Data.Cell } } export type CloneDashboardCellDispatcher = ( - dashboard: DashboardData.Dashboard, - cell: DashboardData.Cell + dashboard: Types.Dashboards.Data.Dashboard, + cell: Types.Dashboards.Data.Cell ) => CloneDashboardCellThunk export type CloneDashboardCellThunk = ( dispatch: Dispatch< | AddDashboardCellAction - | NotificationActions.PublishNotificationActionCreator - | ErrorActions.ErrorThrownActionCreator + | Types.Notifications.Actions.PublishNotificationActionCreator + | Types.Errors.Actions.ErrorThrownActionCreator > ) => Promise export type DeleteDashboardCellDispatcher = ( - dashboard: DashboardData.Dashboard, - cell: DashboardData.Cell + dashboard: Types.Dashboards.Data.Dashboard, + cell: Types.Dashboards.Data.Cell ) => DeleteDashboardCellThunk export type DeleteDashboardCellThunk = ( dispatch: Dispatch< | DeleteDashboardCellActionCreator - | NotificationActions.PublishNotificationActionCreator - | ErrorActions.ErrorThrownActionCreator + | Types.Notifications.Actions.PublishNotificationActionCreator + | Types.Errors.Actions.ErrorThrownActionCreator > ) => Promise export type DeleteDashboardCellActionCreator = ( - dashboard: DashboardData.Dashboard, - cell: DashboardData.Cell + dashboard: Types.Dashboards.Data.Dashboard, + cell: Types.Dashboards.Data.Cell ) => DeleteDashboardCellAction export interface DeleteDashboardCellAction { type: 'DELETE_DASHBOARD_CELL' payload: { - dashboard: DashboardData.Dashboard - cell: DashboardData.Cell + dashboard: Types.Dashboards.Data.Dashboard + cell: Types.Dashboards.Data.Cell } } @@ -244,14 +239,14 @@ export interface TemplateVariableSelectedAction { export type TemplateVariablesSelectedByNameActionCreator = ( dashboardID: number, - queryParams: TempVarData.URLQueryParams + queryParams: Types.TempVars.Data.URLQueryParams ) => TemplateVariablesSelectedByNameAction export interface TemplateVariablesSelectedByNameAction { type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME' payload: { dashboardID: number - queryParams: TempVarData.URLQueryParams + queryParams: Types.TempVars.Data.URLQueryParams } } @@ -295,24 +290,24 @@ export interface SetActiveCellAction { export type GetDashboardsDispatcher = () => GetDashboardsThunk export type GetDashboardsThunk = ( - dispatch: Dispatch -) => Promise + dispatch: Dispatch +) => Promise export type GetDashboardsNamesDispatcher = ( sourceID: string ) => GetDashboardsNamesThunk export type GetDashboardsNamesThunk = ( - dispatch: Dispatch -) => Promise + dispatch: Dispatch +) => Promise export type PutDashboardDispatcher = ( - dashboard: DashboardData.Dashboard + dashboard: Types.Dashboards.Data.Dashboard ) => PutDashboardThunk export type PutDashboardThunk = ( dispatch: Dispatch< - UpdateDashboardAction | ErrorActions.ErrorThrownActionCreator + UpdateDashboardAction | Types.Errors.Actions.ErrorThrownActionCreator > ) => Promise @@ -321,45 +316,46 @@ export type PutDashboardByIDDispatcher = ( ) => PutDashboardByIDThunk export type PutDashboardByIDThunk = ( - dispatch: Dispatch, - getState: () => DashboardReducers.Dashboards + dispatch: Dispatch, + getState: () => Types.Dashboards.Reducers.Dashboards ) => Promise export type DeleteDashboardDispatcher = ( - dashboard: DashboardData.Dashboard + dashboard: Types.Dashboards.Data.Dashboard ) => DeleteDashboardThunk export type DeleteDashboardThunk = ( dispatch: Dispatch< | DeleteDashboardActionCreator - | NotificationActions.PublishNotificationActionCreator - | ErrorActions.ErrorThrownActionCreator + | Types.Notifications.Actions.PublishNotificationActionCreator + | Types.Errors.Actions.ErrorThrownActionCreator | DeleteDashboardFailedActionCreator > ) => Promise export type UpdateDashboardCellDispatcher = ( - dashboard: DashboardData.Dashboard, - cell: DashboardData.Cell + dashboard: Types.Dashboards.Data.Dashboard, + cell: Types.Dashboards.Data.Cell ) => UpdateDashboardCellThunk export type UpdateDashboardCellThunk = ( dispatch: Dispatch< - SyncDashboardCellActionCreator | ErrorActions.ErrorThrownActionCreator + | SyncDashboardCellActionCreator + | Types.Errors.Actions.ErrorThrownActionCreator > ) => Promise export type SyncURLQueryFromQueryParamsObjectDispatcher = ( location: Location, - updatedURLQueryParams: TempVarData.URLQueryParams, - deletedURLQueryParams?: TempVarData.URLQueryParams + updatedURLQueryParams: Types.TempVars.Data.URLQueryParams, + deletedURLQueryParams?: Types.TempVars.Data.URLQueryParams ) => SyncURLQueryFromQueryParamsObjectActionCreator export type SyncURLQueryFromTempVarsDispatcher = ( location: Location, - tempVars: TempVarData.Template[], - deletedTempVars: TempVarData.Template[], - urlQueryParamsTimeRanges?: TempVarData.URLQueryParams + tempVars: Types.TempVars.Data.Template[], + deletedTempVars: Types.TempVars.Data.Template[], + urlQueryParamsTimeRanges?: Types.TempVars.Data.URLQueryParams ) => SyncURLQueryFromQueryParamsObjectActionCreator export type SyncURLQueryFromQueryParamsObjectActionCreator = ( @@ -368,15 +364,19 @@ export type SyncURLQueryFromQueryParamsObjectActionCreator = ( export type SyncDashboardTempVarsFromURLQueryParamsDispatcher = ( dispatch: Dispatch< - | NotificationActions.PublishNotificationActionCreator + | Types.Notifications.Actions.PublishNotificationActionCreator | TemplateVariableSelectedAction >, - getState: () => DashboardReducers.Dashboards & DashboardReducers.Auth + getState: () => Types.Dashboards.Reducers.Dashboards & + Types.Dashboards.Reducers.Auth ) => void export type SyncDashboardTimeRangeFromURLQueryParamsDispatcher = ( - dispatch: Dispatch, - getState: () => DashboardReducers.Dashboards & DashboardReducers.DashTimeV1 + dispatch: Dispatch< + Types.Notifications.Actions.PublishNotificationActionCreator + >, + getState: () => Types.Dashboards.Reducers.Dashboards & + Types.Dashboards.Reducers.DashTimeV1 ) => void export type SyncDashboardFromURLQueryParamsDispatcher = ( @@ -394,5 +394,7 @@ export type GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = ( ) => GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk export type GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk = ( - dispatch: Dispatch + dispatch: Dispatch< + Types.Notifications.Actions.PublishNotificationActionCreator + > ) => Promise diff --git a/ui/src/types/modules/annotations.ts b/ui/src/types/modules/annotations.ts index ca5d216b7a..f94a00604a 100644 --- a/ui/src/types/modules/annotations.ts +++ b/ui/src/types/modules/annotations.ts @@ -1,3 +1,4 @@ import * as Actions from 'src/types/actions/annotations' +import * as Data from 'src/types/annotations' -export {Actions} +export {Actions, Data} diff --git a/ui/src/types/modules/errors.ts b/ui/src/types/modules/errors.ts index a360b7c560..6ccc21754a 100644 --- a/ui/src/types/modules/errors.ts +++ b/ui/src/types/modules/errors.ts @@ -1,3 +1,4 @@ import * as Actions from 'src/types/actions/errors' +import * as Data from 'src/types/errors' -export {Actions} +export {Actions, Data} diff --git a/ui/src/types/modules/notifications.ts b/ui/src/types/modules/notifications.ts index f73f6d9dc3..90666a2837 100644 --- a/ui/src/types/modules/notifications.ts +++ b/ui/src/types/modules/notifications.ts @@ -1,3 +1,4 @@ import * as Actions from 'src/types/actions/notifications' +import * as Data from 'src/types/notifications' -export {Actions} +export {Actions, Data} diff --git a/ui/src/types/sources.ts b/ui/src/types/sources.ts index 2ba7fb6c40..b3c90c59c0 100644 --- a/ui/src/types/sources.ts +++ b/ui/src/types/sources.ts @@ -37,3 +37,7 @@ export interface SourceLinks { health: string services: string } + +export interface SourceOption extends Source { + text: string +} From 810b75088833223754dbc8389633472b8acf2bc0 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 25 Jun 2018 15:41:57 -0700 Subject: [PATCH 44/49] Refactor HostPage mapDispatchToProps to simpler object syntax & remove bindActionCreators --- ui/src/hosts/containers/HostPage.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/ui/src/hosts/containers/HostPage.js b/ui/src/hosts/containers/HostPage.js index 7389bc894d..6205e81d16 100644 --- a/ui/src/hosts/containers/HostPage.js +++ b/ui/src/hosts/containers/HostPage.js @@ -1,7 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import {connect} from 'react-redux' -import {bindActionCreators} from 'redux' import _ from 'lodash' import classnames from 'classnames' @@ -234,7 +233,7 @@ HostPage.propTypes = { handleClickPresentationButton: func, } -const mapStateToProps = ({ +const mstp = ({ app: { ephemeral: {inPresentationMode}, persisted: {autoRefresh}, @@ -244,14 +243,9 @@ const mapStateToProps = ({ autoRefresh, }) -const mapDispatchToProps = dispatch => ({ - handleChooseAutoRefresh: bindActionCreators(setAutoRefresh, dispatch), - handleClickPresentationButton: bindActionCreators( - delayEnablePresentationMode, - dispatch - ), -}) +const mdtp = { + handleChooseAutoRefresh: setAutoRefresh, + handleClickPresentationButton: delayEnablePresentationMode, +} -export default connect(mapStateToProps, mapDispatchToProps)( - ManualRefresh(HostPage) -) +export default connect(mstp, mdtp)(ManualRefresh(HostPage)) From 4153af9f6449b04c718dff57efeede14cf5c2c38 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 25 Jun 2018 15:45:04 -0700 Subject: [PATCH 45/49] Simplify naming of showOverlay import in FluxHeader --- ui/src/flux/components/FluxHeader.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/src/flux/components/FluxHeader.tsx b/ui/src/flux/components/FluxHeader.tsx index 96ff315a10..d833ce48cf 100644 --- a/ui/src/flux/components/FluxHeader.tsx +++ b/ui/src/flux/components/FluxHeader.tsx @@ -5,7 +5,7 @@ import FluxOverlay from 'src/flux/components/FluxOverlay' import {OverlayContext} from 'src/shared/components/OverlayTechnology' import PageHeader from 'src/shared/components/PageHeader' import { - showOverlay as showOverlayActionCreator, + showOverlay, ShowOverlayActionCreator, } from 'src/shared/actions/overlayTechnology' @@ -36,9 +36,9 @@ class FluxHeader extends PureComponent { } private overlay = () => { - const {showOverlay, service} = this.props + const {service} = this.props - showOverlay( + this.props.showOverlay( {({onDismissOverlay}) => ( { } const mdtp = { - showOverlay: showOverlayActionCreator, + showOverlay, } export default connect(null, mdtp)(FluxHeader) From 96864064fa428b4902c5424176db6a92eeb9a1f6 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 25 Jun 2018 15:47:32 -0700 Subject: [PATCH 46/49] Simplify getNewDashboardCell default value for cell type Co-authored-by: Alirie Gray --- ui/src/dashboards/utils/cellGetters.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/src/dashboards/utils/cellGetters.ts b/ui/src/dashboards/utils/cellGetters.ts index 162e5c022d..28dd124bca 100644 --- a/ui/src/dashboards/utils/cellGetters.ts +++ b/ui/src/dashboards/utils/cellGetters.ts @@ -55,12 +55,11 @@ const getNextAvailablePosition = (dashboard, newCell) => { export const getNewDashboardCell = ( dashboard: Dashboard, - cellType?: CellType + cellType: CellType = CellType.Line ): NewDefaultCell => { - const type = cellType || CellType.Line const typedCell = { ...NEW_DEFAULT_DASHBOARD_CELL, - type, + type: cellType, name: UNTITLED_GRAPH, } From 9b585f5087454a4b6bba9cedf76c1dd0289353a9 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 25 Jun 2018 15:49:58 -0700 Subject: [PATCH 47/49] Merge duplicate imports in test fixtures file --- ui/test/fixtures/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/test/fixtures/index.ts b/ui/test/fixtures/index.ts index 172651d2fb..99160d126a 100644 --- a/ui/test/fixtures/index.ts +++ b/ui/test/fixtures/index.ts @@ -15,9 +15,9 @@ import { TableOptions, FieldOption, DecimalPlaces, + CellType, } from 'src/types/dashboards' import {LineColor, ColorNumber} from 'src/types/colors' -import {CellType} from 'src/types/dashboards' export const sourceLinks: SourceLinks = { services: '/chronograf/v1/sources/4', From 14704686c559cf2be8bebd3f70208b021e85e2cf Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 25 Jun 2018 17:07:56 -0700 Subject: [PATCH 48/49] Revert introduction of /modules for single importable Types After discussion with team, folks felt that it was too explicit and verbose to import * as Types and use Types.*.*.x for all type annotations. So we decided to try importing, for example, all dashboard action types under a single import * as DashboardsActions from 'src/types/actions/dashboards'. --- .../dashboards/actions/cellEditorOverlay.ts | 52 +-- ui/src/dashboards/actions/index.ts | 309 +++++++++--------- .../components/CellEditorOverlay.tsx | 95 +++--- .../dashboards/components/DashboardHeader.tsx | 18 +- .../dashboards/components/OverlayControls.tsx | 9 +- .../dashboards/components/SourceSelector.tsx | 9 +- .../dashboards/containers/DashboardPage.tsx | 112 ++++--- ui/src/index.tsx | 4 +- ui/src/shared/actions/annotations.ts | 47 +-- ui/src/shared/actions/app.ts | 19 +- ui/src/shared/actions/errors.ts | 9 +- ui/src/shared/actions/notifications.ts | 11 +- ui/src/sources/containers/SourcePage.tsx | 7 +- ui/src/types/actions/cellEditorOverlay.ts | 25 +- ui/src/types/actions/dashboards.ts | 155 +++++---- ui/src/types/modules/annotations.ts | 4 - ui/src/types/modules/app.ts | 3 - ui/src/types/modules/auth.ts | 4 - ui/src/types/modules/cellEditorOverlay.ts | 3 - ui/src/types/modules/colors.ts | 3 - ui/src/types/modules/dashboards.ts | 6 - ui/src/types/modules/errors.ts | 4 - ui/src/types/modules/index.ts | 25 -- ui/src/types/modules/notifications.ts | 4 - ui/src/types/modules/queries.ts | 3 - ui/src/types/modules/sources.ts | 3 - ui/src/types/modules/tempVars.ts | 3 - ui/src/types/reducers/auth.ts | 4 +- 28 files changed, 453 insertions(+), 497 deletions(-) delete mode 100644 ui/src/types/modules/annotations.ts delete mode 100644 ui/src/types/modules/app.ts delete mode 100644 ui/src/types/modules/auth.ts delete mode 100644 ui/src/types/modules/cellEditorOverlay.ts delete mode 100644 ui/src/types/modules/colors.ts delete mode 100644 ui/src/types/modules/dashboards.ts delete mode 100644 ui/src/types/modules/errors.ts delete mode 100644 ui/src/types/modules/index.ts delete mode 100644 ui/src/types/modules/notifications.ts delete mode 100644 ui/src/types/modules/queries.ts delete mode 100644 ui/src/types/modules/sources.ts delete mode 100644 ui/src/types/modules/tempVars.ts diff --git a/ui/src/dashboards/actions/cellEditorOverlay.ts b/ui/src/dashboards/actions/cellEditorOverlay.ts index 123fd13551..4c571c7e73 100644 --- a/ui/src/dashboards/actions/cellEditorOverlay.ts +++ b/ui/src/dashboards/actions/cellEditorOverlay.ts @@ -1,21 +1,23 @@ -import * as Types from 'src/types/modules' +import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay' +import * as ColorsModels from 'src/types/colors' +import * as DashboardsModels from 'src/types/dashboards' -export const showCellEditorOverlay: Types.CellEditorOverlay.Actions.ShowCellEditorOverlayActionCreator = ( - cell: Types.Dashboards.Data.Cell -): Types.CellEditorOverlay.Actions.ShowCellEditorOverlayAction => ({ +export const showCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator = ( + cell: DashboardsModels.Cell +): CellEditorOverlayActions.ShowCellEditorOverlayAction => ({ type: 'SHOW_CELL_EDITOR_OVERLAY', payload: { cell, }, }) -export const hideCellEditorOverlay = (): Types.CellEditorOverlay.Actions.HideCellEditorOverlayAction => ({ +export const hideCellEditorOverlay = (): CellEditorOverlayActions.HideCellEditorOverlayAction => ({ type: 'HIDE_CELL_EDITOR_OVERLAY', }) export const changeCellType = ( - cellType: Types.Dashboards.Data.CellType -): Types.CellEditorOverlay.Actions.ChangeCellTypeAction => ({ + cellType: DashboardsModels.CellType +): CellEditorOverlayActions.ChangeCellTypeAction => ({ type: 'CHANGE_CELL_TYPE', payload: { cellType, @@ -24,7 +26,7 @@ export const changeCellType = ( export const renameCell = ( cellName: string -): Types.CellEditorOverlay.Actions.RenameCellAction => ({ +): CellEditorOverlayActions.RenameCellAction => ({ type: 'RENAME_CELL', payload: { cellName, @@ -32,8 +34,8 @@ export const renameCell = ( }) export const updateThresholdsListColors = ( - thresholdsListColors: Types.Colors.Data.ColorNumber[] -): Types.CellEditorOverlay.Actions.UpdateThresholdsListColorsAction => ({ + thresholdsListColors: ColorsModels.ColorNumber[] +): CellEditorOverlayActions.UpdateThresholdsListColorsAction => ({ type: 'UPDATE_THRESHOLDS_LIST_COLORS', payload: { thresholdsListColors, @@ -41,8 +43,8 @@ export const updateThresholdsListColors = ( }) export const updateThresholdsListType = ( - thresholdsListType: Types.Dashboards.Data.ThresholdType -): Types.CellEditorOverlay.Actions.UpdateThresholdsListTypeAction => ({ + thresholdsListType: DashboardsModels.ThresholdType +): CellEditorOverlayActions.UpdateThresholdsListTypeAction => ({ type: 'UPDATE_THRESHOLDS_LIST_TYPE', payload: { thresholdsListType, @@ -50,8 +52,8 @@ export const updateThresholdsListType = ( }) export const updateGaugeColors = ( - gaugeColors: Types.Colors.Data.ColorNumber[] -): Types.CellEditorOverlay.Actions.UpdateGaugeColorsAction => ({ + gaugeColors: ColorsModels.ColorNumber[] +): CellEditorOverlayActions.UpdateGaugeColorsAction => ({ type: 'UPDATE_GAUGE_COLORS', payload: { gaugeColors, @@ -59,8 +61,8 @@ export const updateGaugeColors = ( }) export const updateAxes = ( - axes: Types.Dashboards.Data.Axes -): Types.CellEditorOverlay.Actions.UpdateAxesAction => ({ + axes: DashboardsModels.Axes +): CellEditorOverlayActions.UpdateAxesAction => ({ type: 'UPDATE_AXES', payload: { axes, @@ -68,8 +70,8 @@ export const updateAxes = ( }) export const updateTableOptions = ( - tableOptions: Types.Dashboards.Data.TableOptions -): Types.CellEditorOverlay.Actions.UpdateTableOptionsAction => ({ + tableOptions: DashboardsModels.TableOptions +): CellEditorOverlayActions.UpdateTableOptionsAction => ({ type: 'UPDATE_TABLE_OPTIONS', payload: { tableOptions, @@ -77,8 +79,8 @@ export const updateTableOptions = ( }) export const updateLineColors = ( - lineColors: Types.Colors.Data.ColorString[] -): Types.CellEditorOverlay.Actions.UpdateLineColorsAction => ({ + lineColors: ColorsModels.ColorString[] +): CellEditorOverlayActions.UpdateLineColorsAction => ({ type: 'UPDATE_LINE_COLORS', payload: { lineColors, @@ -87,7 +89,7 @@ export const updateLineColors = ( export const changeTimeFormat = ( timeFormat: string -): Types.CellEditorOverlay.Actions.ChangeTimeFormatAction => ({ +): CellEditorOverlayActions.ChangeTimeFormatAction => ({ type: 'CHANGE_TIME_FORMAT', payload: { timeFormat, @@ -95,8 +97,8 @@ export const changeTimeFormat = ( }) export const changeDecimalPlaces = ( - decimalPlaces: Types.Dashboards.Data.DecimalPlaces -): Types.CellEditorOverlay.Actions.ChangeDecimalPlacesAction => ({ + decimalPlaces: DashboardsModels.DecimalPlaces +): CellEditorOverlayActions.ChangeDecimalPlacesAction => ({ type: 'CHANGE_DECIMAL_PLACES', payload: { decimalPlaces, @@ -104,8 +106,8 @@ export const changeDecimalPlaces = ( }) export const updateFieldOptions = ( - fieldOptions: Types.Dashboards.Data.FieldOption[] -): Types.CellEditorOverlay.Actions.UpdateFieldOptionsAction => ({ + fieldOptions: DashboardsModels.FieldOption[] +): CellEditorOverlayActions.UpdateFieldOptionsAction => ({ type: 'UPDATE_FIELD_OPTIONS', payload: { fieldOptions, diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index cd1a6a4858..d55892b76a 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -59,12 +59,21 @@ import {InjectedRouter} from 'react-router' import {Location} from 'history' import {AxiosResponse} from 'axios' import {LocationAction} from 'react-router-redux' -import * as Types from 'src/types/modules' +import * as AuthReducers from 'src/types/reducers/auth' +import * as DashboardsActions from 'src/types/actions/dashboards' +import * as DashboardsApis from 'src/types/apis/dashboards' +import * as DashboardsModels from 'src/types/dashboards' +import * as DashboardsReducers from 'src/types/reducers/dashboards' +import * as ErrorsActions from 'src/types/actions/errors' +import * as QueriesModels from 'src/types/query' +import * as SourcesModels from 'src/types/sources' +import * as TempVarsModels from 'src/types/tempVars' +import * as NotificationsActions from 'src/types/actions/notifications' -export const loadDashboards: Types.Dashboards.Actions.LoadDashboardsActionCreator = ( - dashboards: Types.Dashboards.Data.Dashboard[], +export const loadDashboards: DashboardsActions.LoadDashboardsActionCreator = ( + dashboards: DashboardsModels.Dashboard[], dashboardID?: number -): Types.Dashboards.Actions.LoadDashboardsAction => ({ +): DashboardsActions.LoadDashboardsAction => ({ type: 'LOAD_DASHBOARDS', payload: { dashboards, @@ -72,19 +81,19 @@ export const loadDashboards: Types.Dashboards.Actions.LoadDashboardsActionCreato }, }) -export const loadDashboard: Types.Dashboards.Actions.LoadDashboardActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard -): Types.Dashboards.Actions.LoadDashboardAction => ({ +export const loadDashboard: DashboardsActions.LoadDashboardActionCreator = ( + dashboard: DashboardsModels.Dashboard +): DashboardsActions.LoadDashboardAction => ({ type: 'LOAD_DASHBOARD', payload: { dashboard, }, }) -export const setDashTimeV1: Types.Dashboards.Actions.SetDashTimeV1ActionCreator = ( +export const setDashTimeV1: DashboardsActions.SetDashTimeV1ActionCreator = ( dashboardID: number, - timeRange: Types.Queries.Data.TimeRange -): Types.Dashboards.Actions.SetDashTimeV1Action => ({ + timeRange: QueriesModels.TimeRange +): DashboardsActions.SetDashTimeV1Action => ({ type: 'SET_DASHBOARD_TIME_V1', payload: { dashboardID, @@ -92,71 +101,71 @@ export const setDashTimeV1: Types.Dashboards.Actions.SetDashTimeV1ActionCreator }, }) -export const retainRangesDashTimeV1: Types.Dashboards.Actions.RetainRangesDashTimeV1ActionCreator = ( +export const retainRangesDashTimeV1: DashboardsActions.RetainRangesDashTimeV1ActionCreator = ( dashboardIDs: string[] -): Types.Dashboards.Actions.RetainRangesDashTimeV1Action => ({ +): DashboardsActions.RetainRangesDashTimeV1Action => ({ type: 'RETAIN_RANGES_DASHBOARD_TIME_V1', payload: {dashboardIDs}, }) -export const setTimeRange: Types.Dashboards.Actions.SetTimeRangeActionCreator = ( - timeRange: Types.Queries.Data.TimeRange -): Types.Dashboards.Actions.SetTimeRangeAction => ({ +export const setTimeRange: DashboardsActions.SetTimeRangeActionCreator = ( + timeRange: QueriesModels.TimeRange +): DashboardsActions.SetTimeRangeAction => ({ type: 'SET_DASHBOARD_TIME_RANGE', payload: { timeRange, }, }) -export const setZoomedTimeRange: Types.Dashboards.Actions.SetZoomedTimeRangeActionCreator = ( - zoomedTimeRange: Types.Queries.Data.TimeRange -): Types.Dashboards.Actions.SetZoomedTimeRangeAction => ({ +export const setZoomedTimeRange: DashboardsActions.SetZoomedTimeRangeActionCreator = ( + zoomedTimeRange: QueriesModels.TimeRange +): DashboardsActions.SetZoomedTimeRangeAction => ({ type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE', payload: { zoomedTimeRange, }, }) -export const updateDashboard: Types.Dashboards.Actions.UpdateDashboardActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard -): Types.Dashboards.Actions.UpdateDashboardAction => ({ +export const updateDashboard: DashboardsActions.UpdateDashboardActionCreator = ( + dashboard: DashboardsModels.Dashboard +): DashboardsActions.UpdateDashboardAction => ({ type: 'UPDATE_DASHBOARD', payload: { dashboard, }, }) -export const createDashboard: Types.Dashboards.Actions.CreateDashboardActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard -): Types.Dashboards.Actions.CreateDashboardAction => ({ +export const createDashboard: DashboardsActions.CreateDashboardActionCreator = ( + dashboard: DashboardsModels.Dashboard +): DashboardsActions.CreateDashboardAction => ({ type: 'CREATE_DASHBOARD', payload: { dashboard, }, }) -export const deleteDashboard: Types.Dashboards.Actions.DeleteDashboardActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard -): Types.Dashboards.Actions.DeleteDashboardAction => ({ +export const deleteDashboard: DashboardsActions.DeleteDashboardActionCreator = ( + dashboard: DashboardsModels.Dashboard +): DashboardsActions.DeleteDashboardAction => ({ type: 'DELETE_DASHBOARD', payload: { dashboard, }, }) -export const deleteDashboardFailed: Types.Dashboards.Actions.DeleteDashboardFailedActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard -): Types.Dashboards.Actions.DeleteDashboardFailedAction => ({ +export const deleteDashboardFailed: DashboardsActions.DeleteDashboardFailedActionCreator = ( + dashboard: DashboardsModels.Dashboard +): DashboardsActions.DeleteDashboardFailedAction => ({ type: 'DELETE_DASHBOARD_FAILED', payload: { dashboard, }, }) -export const syncDashboardCell: Types.Dashboards.Actions.SyncDashboardCellActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard, - cell: Types.Dashboards.Data.Cell -): Types.Dashboards.Actions.SyncDashboardCellAction => ({ +export const syncDashboardCell: DashboardsActions.SyncDashboardCellActionCreator = ( + dashboard: DashboardsModels.Dashboard, + cell: DashboardsModels.Cell +): DashboardsActions.SyncDashboardCellAction => ({ type: 'SYNC_DASHBOARD_CELL', payload: { dashboard, @@ -164,10 +173,10 @@ export const syncDashboardCell: Types.Dashboards.Actions.SyncDashboardCellAction }, }) -export const addDashboardCell: Types.Dashboards.Actions.AddDashboardCellActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard, - cell: Types.Dashboards.Data.Cell -): Types.Dashboards.Actions.AddDashboardCellAction => ({ +export const addDashboardCell: DashboardsActions.AddDashboardCellActionCreator = ( + dashboard: DashboardsModels.Dashboard, + cell: DashboardsModels.Cell +): DashboardsActions.AddDashboardCellAction => ({ type: 'ADD_DASHBOARD_CELL', payload: { dashboard, @@ -175,10 +184,10 @@ export const addDashboardCell: Types.Dashboards.Actions.AddDashboardCellActionCr }, }) -export const deleteDashboardCell: Types.Dashboards.Actions.DeleteDashboardCellActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard, - cell: Types.Dashboards.Data.Cell -): Types.Dashboards.Actions.DeleteDashboardCellAction => ({ +export const deleteDashboardCell: DashboardsActions.DeleteDashboardCellActionCreator = ( + dashboard: DashboardsModels.Dashboard, + cell: DashboardsModels.Cell +): DashboardsActions.DeleteDashboardCellAction => ({ type: 'DELETE_DASHBOARD_CELL', payload: { dashboard, @@ -186,10 +195,10 @@ export const deleteDashboardCell: Types.Dashboards.Actions.DeleteDashboardCellAc }, }) -export const editCellQueryStatus: Types.Dashboards.Actions.EditCellQueryStatusActionCreator = ( +export const editCellQueryStatus: DashboardsActions.EditCellQueryStatusActionCreator = ( queryID: string, status: string -): Types.Dashboards.Actions.EditCellQueryStatusAction => ({ +): DashboardsActions.EditCellQueryStatusAction => ({ type: 'EDIT_CELL_QUERY_STATUS', payload: { queryID, @@ -197,11 +206,11 @@ export const editCellQueryStatus: Types.Dashboards.Actions.EditCellQueryStatusAc }, }) -export const templateVariableSelected: Types.Dashboards.Actions.TemplateVariableSelectedActionCreator = ( +export const templateVariableSelected: DashboardsActions.TemplateVariableSelectedActionCreator = ( dashboardID: number, templateID: string, values -): Types.Dashboards.Actions.TemplateVariableSelectedAction => ({ +): DashboardsActions.TemplateVariableSelectedAction => ({ type: 'TEMPLATE_VARIABLE_SELECTED', payload: { dashboardID, @@ -210,10 +219,10 @@ export const templateVariableSelected: Types.Dashboards.Actions.TemplateVariable }, }) -export const templateVariablesSelectedByName: Types.Dashboards.Actions.TemplateVariablesSelectedByNameActionCreator = ( +export const templateVariablesSelectedByName: DashboardsActions.TemplateVariablesSelectedByNameActionCreator = ( dashboardID: number, - queryParams: Types.TempVars.Data.URLQueryParams -): Types.Dashboards.Actions.TemplateVariablesSelectedByNameAction => ({ + queryParams: TempVarsModels.URLQueryParams +): DashboardsActions.TemplateVariablesSelectedByNameAction => ({ type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME', payload: { dashboardID, @@ -221,11 +230,11 @@ export const templateVariablesSelectedByName: Types.Dashboards.Actions.TemplateV }, }) -export const editTemplateVariableValues: Types.Dashboards.Actions.EditTemplateVariableValuesActionCreator = ( +export const editTemplateVariableValues: DashboardsActions.EditTemplateVariableValuesActionCreator = ( dashboardID: number, templateID: string, values -): Types.Dashboards.Actions.EditTemplateVariableValuesAction => ({ +): DashboardsActions.EditTemplateVariableValuesAction => ({ type: 'EDIT_TEMPLATE_VARIABLE_VALUES', payload: { dashboardID, @@ -234,18 +243,18 @@ export const editTemplateVariableValues: Types.Dashboards.Actions.EditTemplateVa }, }) -export const setHoverTime: Types.Dashboards.Actions.SetHoverTimeActionCreator = ( +export const setHoverTime: DashboardsActions.SetHoverTimeActionCreator = ( hoverTime: string -): Types.Dashboards.Actions.SetHoverTimeAction => ({ +): DashboardsActions.SetHoverTimeAction => ({ type: 'SET_HOVER_TIME', payload: { hoverTime, }, }) -export const setActiveCell: Types.Dashboards.Actions.SetActiveCellActionCreator = ( +export const setActiveCell: DashboardsActions.SetActiveCellActionCreator = ( activeCellID: string -): Types.Dashboards.Actions.SetActiveCellAction => ({ +): DashboardsActions.SetActiveCellAction => ({ type: 'SET_ACTIVE_CELL', payload: { activeCellID, @@ -254,17 +263,17 @@ export const setActiveCell: Types.Dashboards.Actions.SetActiveCellActionCreator // Async Action Creators -export const getDashboardsAsync: Types.Dashboards.Actions.GetDashboardsDispatcher = (): Types.Dashboards.Actions.GetDashboardsThunk => async ( +export const getDashboardsAsync: DashboardsActions.GetDashboardsDispatcher = (): DashboardsActions.GetDashboardsThunk => async ( dispatch: Dispatch< - | Types.Dashboards.Actions.LoadDashboardsActionCreator - | Types.Errors.Actions.ErrorThrownActionCreator + | DashboardsActions.LoadDashboardsActionCreator + | ErrorsActions.ErrorThrownActionCreator > -): Promise => { +): Promise => { try { const { data: {dashboards}, } = (await getDashboardsAJAX()) as AxiosResponse< - Types.Dashboards.Apis.DashboardsResponse + DashboardsApis.DashboardsResponse > dispatch(loadDashboards(dashboards)) return dashboards @@ -276,11 +285,11 @@ export const getDashboardsAsync: Types.Dashboards.Actions.GetDashboardsDispatche // gets update-to-date names of dashboards, but does not dispatch action // in order to avoid duplicate and out-of-sync state problems in redux -export const getDashboardsNamesAsync: Types.Dashboards.Actions.GetDashboardsNamesDispatcher = ( +export const getDashboardsNamesAsync: DashboardsActions.GetDashboardsNamesDispatcher = ( sourceID: string -): Types.Dashboards.Actions.GetDashboardsNamesThunk => async ( - dispatch: Dispatch -): Promise => { +): DashboardsActions.GetDashboardsNamesThunk => async ( + dispatch: Dispatch +): Promise => { try { // TODO: change this from getDashboardsAJAX to getDashboardsNamesAJAX // to just get dashboard names (and links) as api view call when that @@ -289,7 +298,7 @@ export const getDashboardsNamesAsync: Types.Dashboards.Actions.GetDashboardsName const { data: {dashboards}, } = (await getDashboardsAJAX()) as AxiosResponse< - Types.Dashboards.Apis.DashboardsResponse + DashboardsApis.DashboardsResponse > const dashboardsNames = dashboards.map(({id, name}) => ({ id, @@ -305,7 +314,7 @@ export const getDashboardsNamesAsync: Types.Dashboards.Actions.GetDashboardsName export const getDashboardAsync = (dashboardID: number) => async ( dispatch -): Promise => { +): Promise => { try { const {data: dashboard} = await getDashboardAJAX(dashboardID) dispatch(loadDashboard(dashboard)) @@ -328,14 +337,14 @@ export const getChronografVersion = () => async (): Promise => { } const removeUnselectedTemplateValues = ( - dashboard: Types.Dashboards.Data.Dashboard -): Types.TempVars.Data.Template[] => { - const templates = getDeep( + dashboard: DashboardsModels.Dashboard +): TempVarsModels.Template[] => { + const templates = getDeep( dashboard, 'templates', [] ).map(template => { - if (template.type === Types.TempVars.Data.TemplateType.CSV) { + if (template.type === TempVarsModels.TemplateType.CSV) { return template } @@ -348,11 +357,11 @@ const removeUnselectedTemplateValues = ( } export const putDashboard = ( - dashboard: Types.Dashboards.Data.Dashboard -): Types.Dashboards.Actions.PutDashboardThunk => async ( + dashboard: DashboardsModels.Dashboard +): DashboardsActions.PutDashboardThunk => async ( dispatch: Dispatch< - | Types.Dashboards.Actions.UpdateDashboardAction - | Types.Errors.Actions.ErrorThrownActionCreator + | DashboardsActions.UpdateDashboardAction + | ErrorsActions.ErrorThrownActionCreator > ): Promise => { try { @@ -379,17 +388,17 @@ export const putDashboard = ( } } -export const putDashboardByID: Types.Dashboards.Actions.PutDashboardByIDDispatcher = ( +export const putDashboardByID: DashboardsActions.PutDashboardByIDDispatcher = ( dashboardID: number -): Types.Dashboards.Actions.PutDashboardByIDThunk => async ( - dispatch: Dispatch, - getState: () => Types.Dashboards.Reducers.Dashboards +): DashboardsActions.PutDashboardByIDThunk => async ( + dispatch: Dispatch, + getState: () => DashboardsReducers.Dashboards ): Promise => { try { const { dashboardUI: {dashboards}, } = getState() - const dashboard: Types.Dashboards.Data.Dashboard = dashboards.find( + const dashboard: DashboardsModels.Dashboard = dashboards.find( d => d.id === +dashboardID ) const templates = removeUnselectedTemplateValues(dashboard) @@ -400,13 +409,13 @@ export const putDashboardByID: Types.Dashboards.Actions.PutDashboardByIDDispatch } } -export const updateDashboardCell: Types.Dashboards.Actions.UpdateDashboardCellDispatcher = ( - dashboard: Types.Dashboards.Data.Dashboard, - cell: Types.Dashboards.Data.Cell -): Types.Dashboards.Actions.UpdateDashboardCellThunk => async ( +export const updateDashboardCell: DashboardsActions.UpdateDashboardCellDispatcher = ( + dashboard: DashboardsModels.Dashboard, + cell: DashboardsModels.Cell +): DashboardsActions.UpdateDashboardCellThunk => async ( dispatch: Dispatch< - | Types.Dashboards.Actions.SyncDashboardCellActionCreator - | Types.Errors.Actions.ErrorThrownActionCreator + | DashboardsActions.SyncDashboardCellActionCreator + | ErrorsActions.ErrorThrownActionCreator > ): Promise => { try { @@ -418,14 +427,14 @@ export const updateDashboardCell: Types.Dashboards.Actions.UpdateDashboardCellDi } } -export const deleteDashboardAsync: Types.Dashboards.Actions.DeleteDashboardDispatcher = ( - dashboard: Types.Dashboards.Data.Dashboard -): Types.Dashboards.Actions.DeleteDashboardThunk => async ( +export const deleteDashboardAsync: DashboardsActions.DeleteDashboardDispatcher = ( + dashboard: DashboardsModels.Dashboard +): DashboardsActions.DeleteDashboardThunk => async ( dispatch: Dispatch< - | Types.Dashboards.Actions.DeleteDashboardActionCreator - | Types.Notifications.Actions.PublishNotificationActionCreator - | Types.Errors.Actions.ErrorThrownActionCreator - | Types.Dashboards.Actions.DeleteDashboardFailedActionCreator + | DashboardsActions.DeleteDashboardActionCreator + | NotificationsActions.PublishNotificationActionCreator + | ErrorsActions.ErrorThrownActionCreator + | DashboardsActions.DeleteDashboardFailedActionCreator > ): Promise => { dispatch(deleteDashboard(dashboard)) @@ -443,14 +452,14 @@ export const deleteDashboardAsync: Types.Dashboards.Actions.DeleteDashboardDispa } } -export const addDashboardCellAsync: Types.Dashboards.Actions.AddDashboardCellDispatcher = ( - dashboard: Types.Dashboards.Data.Dashboard, - cellType?: Types.Dashboards.Data.CellType -): Types.Dashboards.Actions.AddDashboardCellThunk => async ( +export const addDashboardCellAsync: DashboardsActions.AddDashboardCellDispatcher = ( + dashboard: DashboardsModels.Dashboard, + cellType?: DashboardsModels.CellType +): DashboardsActions.AddDashboardCellThunk => async ( dispatch: Dispatch< - | Types.Dashboards.Actions.AddDashboardCellAction - | Types.Notifications.Actions.PublishNotificationActionCreator - | Types.Errors.Actions.ErrorThrownActionCreator + | DashboardsActions.AddDashboardCellAction + | NotificationsActions.PublishNotificationActionCreator + | ErrorsActions.ErrorThrownActionCreator > ): Promise => { try { @@ -466,14 +475,14 @@ export const addDashboardCellAsync: Types.Dashboards.Actions.AddDashboardCellDis } } -export const cloneDashboardCellAsync: Types.Dashboards.Actions.CloneDashboardCellDispatcher = ( - dashboard: Types.Dashboards.Data.Dashboard, - cell: Types.Dashboards.Data.Cell -): Types.Dashboards.Actions.CloneDashboardCellThunk => async ( +export const cloneDashboardCellAsync: DashboardsActions.CloneDashboardCellDispatcher = ( + dashboard: DashboardsModels.Dashboard, + cell: DashboardsModels.Cell +): DashboardsActions.CloneDashboardCellThunk => async ( dispatch: Dispatch< - | Types.Dashboards.Actions.AddDashboardCellActionCreator - | Types.Notifications.Actions.PublishNotificationActionCreator - | Types.Errors.Actions.ErrorThrownActionCreator + | DashboardsActions.AddDashboardCellActionCreator + | NotificationsActions.PublishNotificationActionCreator + | ErrorsActions.ErrorThrownActionCreator > ): Promise => { try { @@ -487,14 +496,14 @@ export const cloneDashboardCellAsync: Types.Dashboards.Actions.CloneDashboardCel } } -export const deleteDashboardCellAsync: Types.Dashboards.Actions.DeleteDashboardCellDispatcher = ( - dashboard: Types.Dashboards.Data.Dashboard, - cell: Types.Dashboards.Data.Cell -): Types.Dashboards.Actions.DeleteDashboardCellThunk => async ( +export const deleteDashboardCellAsync: DashboardsActions.DeleteDashboardCellDispatcher = ( + dashboard: DashboardsModels.Dashboard, + cell: DashboardsModels.Cell +): DashboardsActions.DeleteDashboardCellThunk => async ( dispatch: Dispatch< - | Types.Dashboards.Actions.DeleteDashboardCellActionCreator - | Types.Notifications.Actions.PublishNotificationActionCreator - | Types.Errors.Actions.ErrorThrownActionCreator + | DashboardsActions.DeleteDashboardCellActionCreator + | NotificationsActions.PublishNotificationActionCreator + | ErrorsActions.ErrorThrownActionCreator > ): Promise => { try { @@ -508,7 +517,7 @@ export const deleteDashboardCellAsync: Types.Dashboards.Actions.DeleteDashboardC } export const importDashboardAsync = ( - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard ) => async (dispatch): Promise => { try { // save only selected template values to server @@ -534,7 +543,7 @@ export const importDashboardAsync = ( const { data: {dashboards}, } = (await getDashboardsAJAX()) as AxiosResponse< - Types.Dashboards.Apis.DashboardsResponse + DashboardsApis.DashboardsResponse > dispatch(loadDashboards(dashboards)) @@ -553,13 +562,13 @@ export const importDashboardAsync = ( export const hydrateTempVarValuesAsync = ( dashboardID: number, - source: Types.Sources.Data.Source + source: SourcesModels.Source ) => async (dispatch, getState): Promise => { try { const dashboard = getState().dashboardUI.dashboards.find( d => d.id === dashboardID ) - const templates: Types.TempVars.Data.Template[] = dashboard.templates + const templates: TempVarsModels.Template[] = dashboard.templates const queries = templates .filter( template => getDeep(template, 'query.influxql', '') !== '' @@ -586,9 +595,9 @@ const removeNullValues = obj => _.pickBy(obj, o => o) export const syncURLQueryParamsFromQueryParamsObject = ( location: Location, - updatedURLQueryParams: Types.TempVars.Data.URLQueryParams, - deletedURLQueryParams: Types.TempVars.Data.URLQueryParams = {} -): Types.Dashboards.Actions.SyncURLQueryFromQueryParamsObjectActionCreator => ( + updatedURLQueryParams: TempVarsModels.URLQueryParams, + deletedURLQueryParams: TempVarsModels.URLQueryParams = {} +): DashboardsActions.SyncURLQueryFromQueryParamsObjectActionCreator => ( dispatch: Dispatch ): void => { const updatedLocationQuery = removeNullValues({ @@ -611,14 +620,14 @@ export const syncURLQueryParamsFromQueryParamsObject = ( dispatch(replace(updatedLocation)) } -export const syncURLQueryFromTempVars: Types.Dashboards.Actions.SyncURLQueryFromTempVarsDispatcher = ( +export const syncURLQueryFromTempVars: DashboardsActions.SyncURLQueryFromTempVarsDispatcher = ( location: Location, - tempVars: Types.TempVars.Data.Template[], - deletedTempVars: Types.TempVars.Data.Template[] = [], - urlQueryParamsTimeRanges?: Types.TempVars.Data.URLQueryParams -): Types.Dashboards.Actions.SyncURLQueryFromQueryParamsObjectActionCreator => ( + tempVars: TempVarsModels.Template[], + deletedTempVars: TempVarsModels.Template[] = [], + urlQueryParamsTimeRanges?: TempVarsModels.URLQueryParams +): DashboardsActions.SyncURLQueryFromQueryParamsObjectActionCreator => ( dispatch: Dispatch< - Types.Dashboards.Actions.SyncURLQueryFromQueryParamsObjectDispatcher + DashboardsActions.SyncURLQueryFromQueryParamsObjectDispatcher > ): void => { const updatedURLQueryParams = generateURLQueryParamsFromTempVars(tempVars) @@ -646,14 +655,13 @@ export const syncURLQueryFromTempVars: Types.Dashboards.Actions.SyncURLQueryFrom const syncDashboardTempVarsFromURLQueryParams = ( dashboardID: number, - urlQueryParams: Types.TempVars.Data.URLQueryParams -): Types.Dashboards.Actions.SyncDashboardTempVarsFromURLQueryParamsDispatcher => ( + urlQueryParams: TempVarsModels.URLQueryParams +): DashboardsActions.SyncDashboardTempVarsFromURLQueryParamsDispatcher => ( dispatch: Dispatch< - | Types.Notifications.Actions.PublishNotificationActionCreator - | Types.Dashboards.Actions.TemplateVariableSelectedAction + | NotificationsActions.PublishNotificationActionCreator + | DashboardsActions.TemplateVariableSelectedAction >, - getState: () => Types.Dashboards.Reducers.Dashboards & - Types.Auth.Reducers.Auth + getState: () => DashboardsReducers.Dashboards & AuthReducers.Auth ): void => { const { dashboardUI, @@ -686,14 +694,11 @@ const syncDashboardTempVarsFromURLQueryParams = ( const syncDashboardTimeRangeFromURLQueryParams = ( dashboardID: number, - urlQueryParams: Types.TempVars.Data.URLQueryParams, + urlQueryParams: TempVarsModels.URLQueryParams, location: Location -): Types.Dashboards.Actions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher => ( - dispatch: Dispatch< - Types.Notifications.Actions.PublishNotificationActionCreator - >, - getState: () => Types.Dashboards.Reducers.Dashboards & - Types.Dashboards.Reducers.DashTimeV1 +): DashboardsActions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher => ( + dispatch: Dispatch, + getState: () => DashboardsReducers.Dashboards & DashboardsReducers.DashTimeV1 ): void => { const { dashboardUI: {dashboards}, @@ -752,10 +757,10 @@ const syncDashboardTimeRangeFromURLQueryParams = ( const syncDashboardFromURLQueryParams = ( dashboardID: number, location: Location -): Types.Dashboards.Actions.SyncDashboardFromURLQueryParamsDispatcher => ( +): DashboardsActions.SyncDashboardFromURLQueryParamsDispatcher => ( dispatch: Dispatch< - | Types.Dashboards.Actions.SyncDashboardTempVarsFromURLQueryParamsDispatcher - | Types.Dashboards.Actions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher + | DashboardsActions.SyncDashboardTempVarsFromURLQueryParamsDispatcher + | DashboardsActions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher > ): void => { const urlQueryParams = queryString.parse(window.location.search) @@ -771,15 +776,13 @@ const syncDashboardFromURLQueryParams = ( ) } -export const getDashboardWithHydratedAndSyncedTempVarsAsync: Types.Dashboards.Actions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = ( +export const getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardsActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = ( dashboardID: number, - source: Types.Sources.Data.Source, + source: SourcesModels.Source, router: InjectedRouter, location: Location -): Types.Dashboards.Actions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk => async ( - dispatch: Dispatch< - Types.Notifications.Actions.PublishNotificationActionCreator - > +): DashboardsActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk => async ( + dispatch: Dispatch ): Promise => { const dashboard = await bindActionCreators(getDashboardAsync, dispatch)( dashboardID @@ -801,13 +804,13 @@ export const getDashboardWithHydratedAndSyncedTempVarsAsync: Types.Dashboards.Ac ) } -export const setZoomedTimeRangeAsync: Types.Dashboards.Actions.SetZoomedTimeRangeDispatcher = ( - zoomedTimeRange: Types.Queries.Data.TimeRange, +export const setZoomedTimeRangeAsync: DashboardsActions.SetZoomedTimeRangeDispatcher = ( + zoomedTimeRange: QueriesModels.TimeRange, location: Location -): Types.Dashboards.Actions.SetZoomedTimeRangeThunk => async ( +): DashboardsActions.SetZoomedTimeRangeThunk => async ( dispatch: Dispatch< - | Types.Dashboards.Actions.SetZoomedTimeRangeActionCreator - | Types.Dashboards.Actions.SyncURLQueryFromQueryParamsObjectDispatcher + | DashboardsActions.SetZoomedTimeRangeActionCreator + | DashboardsActions.SyncURLQueryFromQueryParamsObjectDispatcher > ): Promise => { dispatch(setZoomedTimeRange(zoomedTimeRange)) diff --git a/ui/src/dashboards/components/CellEditorOverlay.tsx b/ui/src/dashboards/components/CellEditorOverlay.tsx index b0e87876c2..1ea868e102 100644 --- a/ui/src/dashboards/components/CellEditorOverlay.tsx +++ b/ui/src/dashboards/components/CellEditorOverlay.tsx @@ -36,7 +36,12 @@ import { import {getCellTypeColors} from 'src/dashboards/constants/cellEditor' // Types -import * as Types from 'src/types/modules' +import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay' +import * as ColorsModels from 'src/types/colors' +import * as DashboardsActions from 'src/types/actions/dashboards' +import * as DashboardsModels from 'src/types/dashboards' +import * as QueriesModels from 'src/types/query' +import * as SourcesModels from 'src/types/sources' type QueryTransitions = typeof queryTransitions type EditRawTextAsyncFunc = ( @@ -52,7 +57,7 @@ export type CellEditorOverlayActions = QueryActions & { editRawTextAsync: EditRawTextAsyncFunc } -const staticLegend: Types.Dashboards.Data.Legend = { +const staticLegend: DashboardsModels.Legend = { type: 'static', orientation: 'bottom', } @@ -63,40 +68,40 @@ interface Template { interface QueryStatus { queryID: string - status: Types.Queries.Data.Status + status: QueriesModels.Status } interface Props { - sources: Types.Sources.Data.Source[] - editQueryStatus: Types.Dashboards.Actions.EditCellQueryStatusActionCreator + sources: SourcesModels.Source[] + editQueryStatus: DashboardsActions.EditCellQueryStatusActionCreator onCancel: () => void - onSave: (cell: Types.Dashboards.Data.Cell) => void - source: Types.Sources.Data.Source + onSave: (cell: DashboardsModels.Cell) => void + source: SourcesModels.Source dashboardID: number queryStatus: QueryStatus autoRefresh: number templates: Template[] - timeRange: Types.Queries.Data.TimeRange + timeRange: QueriesModels.TimeRange thresholdsListType: string - thresholdsListColors: Types.Colors.Data.ColorNumber[] - gaugeColors: Types.Colors.Data.ColorNumber[] - lineColors: Types.Colors.Data.ColorString[] - cell: Types.Dashboards.Data.Cell + thresholdsListColors: ColorsModels.ColorNumber[] + gaugeColors: ColorsModels.ColorNumber[] + lineColors: ColorsModels.ColorString[] + cell: DashboardsModels.Cell } interface State { - queriesWorkingDraft: Types.Queries.Data.QueryConfig[] + queriesWorkingDraft: QueriesModels.QueryConfig[] activeQueryIndex: number isDisplayOptionsTabActive: boolean isStaticLegend: boolean } const createWorkingDraft = ( - source: Types.Sources.Data.Source, - query: Types.Dashboards.Data.CellQuery -): Types.Queries.Data.QueryConfig => { + source: SourcesModels.Source, + query: DashboardsModels.CellQuery +): QueriesModels.QueryConfig => { const {queryConfig} = query - const draft: Types.Queries.Data.QueryConfig = { + const draft: QueriesModels.QueryConfig = { ...queryConfig, id: uuid.v4(), source, @@ -106,11 +111,11 @@ const createWorkingDraft = ( } const createWorkingDrafts = ( - source: Types.Sources.Data.Source, - queries: Types.Dashboards.Data.CellQuery[] -): Types.Queries.Data.QueryConfig[] => + source: SourcesModels.Source, + queries: DashboardsModels.CellQuery[] +): QueriesModels.QueryConfig[] => _.cloneDeep( - queries.map((query: Types.Dashboards.Data.CellQuery) => + queries.map((query: DashboardsModels.CellQuery) => createWorkingDraft(source, query) ) ) @@ -246,7 +251,7 @@ class CellEditorOverlay extends Component { ) } - private get formattedSources(): Types.Sources.Data.SourceOption[] { + private get formattedSources(): SourcesModels.SourceOption[] { const {sources} = this.props return sources.map(s => ({ ...s, @@ -301,20 +306,18 @@ class CellEditorOverlay extends Component { const {queriesWorkingDraft, isStaticLegend} = this.state const {cell, thresholdsListColors, gaugeColors, lineColors} = this.props - const queries: Types.Dashboards.Data.CellQuery[] = queriesWorkingDraft.map( - q => { - const timeRange = q.range || { - upper: null, - lower: TEMP_VAR_DASHBOARD_TIME, - } - const source = getDeep(q.source, 'links.self', null) - return { - queryConfig: q, - query: q.rawText || buildQuery(TYPE_QUERY_CONFIG, timeRange, q), - source, - } + const queries: DashboardsModels.CellQuery[] = queriesWorkingDraft.map(q => { + const timeRange = q.range || { + upper: null, + lower: TEMP_VAR_DASHBOARD_TIME, } - ) + const source = getDeep(q.source, 'links.self', null) + return { + queryConfig: q, + query: q.rawText || buildQuery(TYPE_QUERY_CONFIG, timeRange, q), + source, + } + }) const colors = getCellTypeColors({ cellType: cell.type, @@ -323,7 +326,7 @@ class CellEditorOverlay extends Component { lineColors, }) - const newCell: Types.Dashboards.Data.Cell = { + const newCell: DashboardsModels.Cell = { ...cell, queries, colors, @@ -345,8 +348,8 @@ class CellEditorOverlay extends Component { this.setState({isStaticLegend}) } - private handleSetQuerySource = (source: Types.Sources.Data.Source): void => { - const queriesWorkingDraft: Types.Queries.Data.QueryConfig[] = this.state.queriesWorkingDraft.map( + private handleSetQuerySource = (source: SourcesModels.Source): void => { + const queriesWorkingDraft: QueriesModels.QueryConfig[] = this.state.queriesWorkingDraft.map( q => ({ ..._.cloneDeep(q), source, @@ -422,8 +425,8 @@ class CellEditorOverlay extends Component { ) const config = data.queries.find(q => q.id === id) - const nextQueries: Types.Queries.Data.QueryConfig[] = this.state.queriesWorkingDraft.map( - (q: Types.Queries.Data.QueryConfig) => { + const nextQueries: QueriesModels.QueryConfig[] = this.state.queriesWorkingDraft.map( + (q: QueriesModels.QueryConfig) => { if (q.id === id) { const isQuerySupportedByExplorer = !isUsingUserDefinedTempVars @@ -451,20 +454,20 @@ class CellEditorOverlay extends Component { private findSelectedSource = (): string => { const {source} = this.props const sources = this.formattedSources - const currentSource = getDeep( + const currentSource = getDeep( this.state.queriesWorkingDraft, '0.source', null ) if (!currentSource) { - const defaultSource: Types.Sources.Data.Source = sources.find( + const defaultSource: SourcesModels.Source = sources.find( s => s.id === source.id ) return (defaultSource && defaultSource.text) || 'No sources' } - const selected: Types.Sources.Data.Source = sources.find( + const selected: SourcesModels.Source = sources.find( s => s.links.self === currentSource.links.self ) return (selected && selected.text) || 'No sources' @@ -508,7 +511,7 @@ class CellEditorOverlay extends Component { const {queriesWorkingDraft} = this.state return queriesWorkingDraft.every( - (query: Types.Queries.Data.QueryConfig) => + (query: QueriesModels.QueryConfig) => (!!query.measurement && !!query.database && !!query.fields.length) || !!query.rawText ) @@ -528,7 +531,7 @@ class CellEditorOverlay extends Component { return result } - private get initialSource(): Types.Sources.Data.Source { + private get initialSource(): SourcesModels.Source { const { cell: {queries}, source, @@ -547,7 +550,7 @@ class CellEditorOverlay extends Component { return source } - private get source(): Types.Sources.Data.Source { + private get source(): SourcesModels.Source { const {source, sources} = this.props const query = _.get(this.state.queriesWorkingDraft, 0, {source: null}) diff --git a/ui/src/dashboards/components/DashboardHeader.tsx b/ui/src/dashboards/components/DashboardHeader.tsx index 8efecc684a..2ae7f50fef 100644 --- a/ui/src/dashboards/components/DashboardHeader.tsx +++ b/ui/src/dashboards/components/DashboardHeader.tsx @@ -11,26 +11,28 @@ import GraphTips from 'src/shared/components/GraphTips' import DashboardHeaderEdit from 'src/dashboards/components/DashboardHeaderEdit' import DashboardSwitcher from 'src/dashboards/components/DashboardSwitcher' -import * as Types from 'src/types/modules' +import * as AppActions from 'src/types/actions/app' +import * as DashboardsModels from 'src/types/dashboards' +import * as QueriesModels from 'src/types/query' interface Props { activeDashboard: string - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard onEditDashboard: () => void - timeRange: Types.Queries.Data.TimeRange + timeRange: QueriesModels.TimeRange autoRefresh: number isEditMode?: boolean - handleChooseTimeRange: (timeRange: Types.Queries.Data.TimeRange) => void - handleChooseAutoRefresh: Types.App.Actions.SetAutoRefreshActionCreator + handleChooseTimeRange: (timeRange: QueriesModels.TimeRange) => void + handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator onManualRefresh: () => void - handleClickPresentationButton: Types.App.Actions.DelayEnablePresentationModeDispatcher + handleClickPresentationButton: AppActions.DelayEnablePresentationModeDispatcher onAddCell: () => void onToggleTempVarControls: () => void showTemplateControlBar: boolean - zoomedTimeRange: Types.Queries.Data.TimeRange + zoomedTimeRange: QueriesModels.TimeRange onCancel: () => void onSave: (name: string) => Promise - names: Types.Dashboards.Data.DashboardName[] + names: DashboardsModels.DashboardName[] isHidden: boolean } diff --git a/ui/src/dashboards/components/OverlayControls.tsx b/ui/src/dashboards/components/OverlayControls.tsx index 3dc013e5ac..522e36fcee 100644 --- a/ui/src/dashboards/components/OverlayControls.tsx +++ b/ui/src/dashboards/components/OverlayControls.tsx @@ -4,7 +4,8 @@ import classnames from 'classnames' import ConfirmOrCancel from 'src/shared/components/ConfirmOrCancel' import SourceSelector from 'src/dashboards/components/SourceSelector' -import * as Types from 'src/types/modules' +import * as QueriesModels from 'src/types/query' +import * as SourcesModels from 'src/types/sources' interface Props { onCancel: () => void @@ -14,10 +15,10 @@ interface Props { displayOptions: boolean ) => (event: MouseEvent) => void isSavable: boolean - sources: Types.Sources.Data.SourceOption[] - onSetQuerySource: (source: Types.Sources.Data.Source) => void + sources: SourcesModels.SourceOption[] + onSetQuerySource: (source: SourcesModels.Source) => void selected: string - queries: Types.Queries.Data.QueryConfig[] + queries: QueriesModels.QueryConfig[] } const OverlayControls: SFC = ({ diff --git a/ui/src/dashboards/components/SourceSelector.tsx b/ui/src/dashboards/components/SourceSelector.tsx index a6dba804a5..982c2df6a9 100644 --- a/ui/src/dashboards/components/SourceSelector.tsx +++ b/ui/src/dashboards/components/SourceSelector.tsx @@ -2,13 +2,14 @@ import React, {SFC} from 'react' import Dropdown from 'src/shared/components/Dropdown' -import * as Types from 'src/types/modules' +import * as QueriesModels from 'src/types/query' +import * as SourcesModels from 'src/types/sources' interface Props { - sources: Types.Sources.Data.SourceOption[] + sources: SourcesModels.SourceOption[] selected: string - onSetQuerySource: (source: Types.Sources.Data.SourceOption) => void - queries: Types.Queries.Data.QueryConfig[] + onSetQuerySource: (source: SourcesModels.SourceOption) => void + queries: QueriesModels.QueryConfig[] } const SourceSelector: SFC = ({ diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index 2ed19f9907..ad6298db10 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -41,72 +41,82 @@ import {WithRouterProps} from 'react-router' import {ManualRefreshProps} from 'src/shared/components/ManualRefresh' import {Location} from 'history' import {InjectedRouter} from 'react-router' -import * as Types from 'src/types/modules' +import * as AnnotationsActions from 'src/types/actions/annotations' +import * as AppActions from 'src/types/actions/app' +import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay' +import * as ColorsModels from 'src/types/colors' +import * as DashboardsActions from 'src/types/actions/dashboards' +import * as DashboardsModels from 'src/types/dashboards' +import * as ErrorsActions from 'src/types/actions/errors' +import * as QueriesModels from 'src/types/query' +import * as SourcesModels from 'src/types/sources' +import * as TempVarsModels from 'src/types/tempVars' +import * as NotificationsActions from 'src/types/actions/notifications' interface DashboardActions { - setDashTimeV1: Types.Dashboards.Actions.SetDashTimeV1ActionCreator - updateDashboard: Types.Dashboards.Actions.UpdateDashboardActionCreator - syncURLQueryParamsFromQueryParamsObject: Types.Dashboards.Actions.SyncURLQueryFromQueryParamsObjectDispatcher - putDashboard: Types.Dashboards.Actions.PutDashboardDispatcher - putDashboardByID: Types.Dashboards.Actions.PutDashboardByIDDispatcher - getDashboardsNamesAsync: Types.Dashboards.Actions.GetDashboardsNamesDispatcher - getDashboardWithHydratedAndSyncedTempVarsAsync: Types.Dashboards.Actions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher - setTimeRange: Types.Dashboards.Actions.SetTimeRangeActionCreator - addDashboardCellAsync: Types.Dashboards.Actions.AddDashboardCellDispatcher - editCellQueryStatus: Types.Dashboards.Actions.EditCellQueryStatusActionCreator - updateDashboardCell: Types.Dashboards.Actions.UpdateDashboardCellDispatcher - cloneDashboardCellAsync: Types.Dashboards.Actions.CloneDashboardCellDispatcher - deleteDashboardCellAsync: Types.Dashboards.Actions.DeleteDashboardCellDispatcher - templateVariableSelected: Types.Dashboards.Actions.TemplateVariableSelectedActionCreator - syncURLQueryFromTempVars: Types.Dashboards.Actions.SyncURLQueryFromTempVarsDispatcher - setZoomedTimeRangeAsync: Types.Dashboards.Actions.SetZoomedTimeRangeDispatcher + setDashTimeV1: DashboardsActions.SetDashTimeV1ActionCreator + updateDashboard: DashboardsActions.UpdateDashboardActionCreator + syncURLQueryParamsFromQueryParamsObject: DashboardsActions.SyncURLQueryFromQueryParamsObjectDispatcher + putDashboard: DashboardsActions.PutDashboardDispatcher + putDashboardByID: DashboardsActions.PutDashboardByIDDispatcher + getDashboardsNamesAsync: DashboardsActions.GetDashboardsNamesDispatcher + getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardsActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher + setTimeRange: DashboardsActions.SetTimeRangeActionCreator + addDashboardCellAsync: DashboardsActions.AddDashboardCellDispatcher + editCellQueryStatus: DashboardsActions.EditCellQueryStatusActionCreator + updateDashboardCell: DashboardsActions.UpdateDashboardCellDispatcher + cloneDashboardCellAsync: DashboardsActions.CloneDashboardCellDispatcher + deleteDashboardCellAsync: DashboardsActions.DeleteDashboardCellDispatcher + templateVariableSelected: DashboardsActions.TemplateVariableSelectedActionCreator + syncURLQueryFromTempVars: DashboardsActions.SyncURLQueryFromTempVarsDispatcher + setZoomedTimeRangeAsync: DashboardsActions.SetZoomedTimeRangeDispatcher } interface Props extends DashboardActions, ManualRefreshProps, WithRouterProps { - source: Types.Sources.Data.Source - sources: Types.Sources.Data.Source[] + source: SourcesModels.Source + sources: SourcesModels.Source[] params: { sourceID: string dashboardID: string } location: Location dashboardID: number - dashboard: Types.Dashboards.Data.Dashboard - dashboards: Types.Dashboards.Data.Dashboard[] - handleChooseAutoRefresh: Types.App.Actions.SetAutoRefreshActionCreator + dashboard: DashboardsModels.Dashboard + dashboards: DashboardsModels.Dashboard[] + handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator autoRefresh: number - templateControlBarVisibilityToggled: () => Types.App.Actions.TemplateControlBarVisibilityToggledActionCreator - timeRange: Types.Queries.Data.TimeRange - zoomedTimeRange: Types.Queries.Data.TimeRange + templateControlBarVisibilityToggled: () => AppActions.TemplateControlBarVisibilityToggledActionCreator + timeRange: QueriesModels.TimeRange + zoomedTimeRange: QueriesModels.TimeRange showTemplateControlBar: boolean inPresentationMode: boolean - handleClickPresentationButton: Types.App.Actions.DelayEnablePresentationModeDispatcher + handleClickPresentationButton: AppActions.DelayEnablePresentationModeDispatcher cellQueryStatus: { queryID: string status: object } - errorThrown: Types.Errors.Actions.ErrorThrownActionCreator + errorThrown: ErrorsActions.ErrorThrownActionCreator meRole: string isUsingAuth: boolean router: InjectedRouter - notify: Types.Notifications.Actions.PublishNotificationActionCreator - getAnnotationsAsync: Types.Annotations.Actions.GetAnnotationsDispatcher - handleShowCellEditorOverlay: Types.CellEditorOverlay.Actions.ShowCellEditorOverlayActionCreator - handleHideCellEditorOverlay: Types.CellEditorOverlay.Actions.HideCellEditorOverlayActionCreator - handleDismissEditingAnnotation: Types.Annotations.Actions.DismissEditingAnnotationActionCreator - selectedCell: Types.Dashboards.Data.Cell + notify: NotificationsActions.PublishNotificationActionCreator + getAnnotationsAsync: AnnotationsActions.GetAnnotationsDispatcher + handleShowCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator + handleHideCellEditorOverlay: CellEditorOverlayActions.HideCellEditorOverlayActionCreator + handleDismissEditingAnnotation: AnnotationsActions.DismissEditingAnnotationActionCreator + selectedCell: DashboardsModels.Cell thresholdsListType: string - thresholdsListColors: Types.Colors.Data.ColorNumber[] - gaugeColors: Types.Colors.Data.ColorNumber[] - lineColors: Types.Colors.Data.ColorString[] + thresholdsListColors: ColorsModels.ColorNumber[] + gaugeColors: ColorsModels.ColorNumber[] + lineColors: ColorsModels.ColorString[] } interface State { isEditMode: boolean - selectedCell: Types.Dashboards.Data.Cell | null + selectedCell: DashboardsModels.Cell | null scrollTop: number windowHeight: number - dashboardsNames: Types.Dashboards.Data.DashboardName[] + dashboardsNames: DashboardsModels.DashboardName[] } @ErrorHandling @@ -343,7 +353,7 @@ class DashboardPage extends Component { } private getDashboard = async (): Promise< - Types.Dashboards.Actions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk + DashboardsActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk > => { const {dashboardID, source, router, location} = this.props @@ -368,7 +378,7 @@ class DashboardPage extends Component { this.setState({dashboardsNames}) } - private inView = (cell: Types.Dashboards.Data.Cell): boolean => { + private inView = (cell: DashboardsModels.Cell): boolean => { const {scrollTop, windowHeight} = this.state const bufferValue = 600 const cellTop = cell.y * DASHBOARD_LAYOUT_ROW_HEIGHT @@ -382,7 +392,7 @@ class DashboardPage extends Component { } private handleSaveEditedCell = async ( - newCell: Types.Dashboards.Data.Cell + newCell: DashboardsModels.Cell ): Promise => { const {dashboard, handleHideCellEditorOverlay} = this.props await this.props.updateDashboardCell(dashboard, newCell) @@ -390,7 +400,7 @@ class DashboardPage extends Component { } private handleChooseTimeRange = ( - timeRange: Types.Queries.Data.TimeRange + timeRange: QueriesModels.TimeRange ): void => { const { dashboard, @@ -414,9 +424,7 @@ class DashboardPage extends Component { getAnnotationsAsync(source.links.annotations, annotationRange) } - private handleUpdatePosition = ( - cells: Types.Dashboards.Data.Cell[] - ): void => { + private handleUpdatePosition = (cells: DashboardsModels.Cell[]): void => { const {dashboard, meRole, isUsingAuth} = this.props const newDashboard = {...dashboard, cells} @@ -434,7 +442,7 @@ class DashboardPage extends Component { this.props.addDashboardCellAsync(dashboard) } - private handleCloneCell = (cell: Types.Dashboards.Data.Cell): void => { + private handleCloneCell = (cell: DashboardsModels.Cell): void => { const {dashboard} = this.props this.props.cloneDashboardCellAsync(dashboard, cell) } @@ -457,17 +465,15 @@ class DashboardPage extends Component { this.getDashboardsNames() } - private handleDeleteDashboardCell = ( - cell: Types.Dashboards.Data.Cell - ): void => { + private handleDeleteDashboardCell = (cell: DashboardsModels.Cell): void => { const {dashboard} = this.props this.props.deleteDashboardCellAsync(dashboard, cell) } private handleSelectTemplate = ( templateID: string - ): ((value: Types.TempVars.Data.TemplateValue) => void) => ( - value: Types.TempVars.Data.TemplateValue + ): ((value: TempVarsModels.TemplateValue) => void) => ( + value: TempVarsModels.TemplateValue ): void => { const {dashboard, dashboardID, location} = this.props @@ -491,7 +497,7 @@ class DashboardPage extends Component { } private handleSaveTemplateVariables = async ( - templates: Types.TempVars.Data.Template[] + templates: TempVarsModels.Template[] ): Promise => { const {location, dashboard} = this.props @@ -515,7 +521,7 @@ class DashboardPage extends Component { } private handleZoomedTimeRange = ( - zoomedTimeRange: Types.Queries.Data.TimeRange + zoomedTimeRange: QueriesModels.TimeRange ): void => { const {location} = this.props this.props.setZoomedTimeRangeAsync(zoomedTimeRange, location) diff --git a/ui/src/index.tsx b/ui/src/index.tsx index 9920a75360..e5ffd35083 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -50,7 +50,7 @@ import 'src/style/chronograf.scss' import {HEARTBEAT_INTERVAL} from 'src/shared/constants' -import * as Types from 'src/types/modules' +import * as ErrorsModels from 'src/types/errors' const errorsQueue = [] @@ -191,7 +191,7 @@ class Root extends PureComponent<{}, State> { errorThrown( {status: 0, auth: null}, error, - Types.Errors.Data.AlertType.Warning + ErrorsModels.AlertType.Warning ) ) } diff --git a/ui/src/shared/actions/annotations.ts b/ui/src/shared/actions/annotations.ts index 1fbfea6e40..83566f251e 100644 --- a/ui/src/shared/actions/annotations.ts +++ b/ui/src/shared/actions/annotations.ts @@ -1,38 +1,39 @@ import * as api from 'src/shared/apis/annotation' import {Dispatch} from 'redux' -import * as Types from 'src/types/modules' +import * as AnnotationsActions from 'src/types/actions/annotations' +import * as AnnotationsModels from 'src/types/annotations' -export const editingAnnotation = (): Types.Annotations.Actions.EditingAnnotationAction => ({ +export const editingAnnotation = (): AnnotationsActions.EditingAnnotationAction => ({ type: 'EDITING_ANNOTATION', }) -export const dismissEditingAnnotation = (): Types.Annotations.Actions.DismissEditingAnnotationAction => ({ +export const dismissEditingAnnotation = (): AnnotationsActions.DismissEditingAnnotationAction => ({ type: 'DISMISS_EDITING_ANNOTATION', }) -export const addingAnnotation = (): Types.Annotations.Actions.AddingAnnotationAction => ({ +export const addingAnnotation = (): AnnotationsActions.AddingAnnotationAction => ({ type: 'ADDING_ANNOTATION', }) -export const addingAnnotationSuccess = (): Types.Annotations.Actions.AddingAnnotationSuccessAction => ({ +export const addingAnnotationSuccess = (): AnnotationsActions.AddingAnnotationSuccessAction => ({ type: 'ADDING_ANNOTATION_SUCCESS', }) -export const dismissAddingAnnotation = (): Types.Annotations.Actions.DismissAddingAnnotationAction => ({ +export const dismissAddingAnnotation = (): AnnotationsActions.DismissAddingAnnotationAction => ({ type: 'DISMISS_ADDING_ANNOTATION', }) -export const mouseEnterTempAnnotation = (): Types.Annotations.Actions.MouseEnterTempAnnotationAction => ({ +export const mouseEnterTempAnnotation = (): AnnotationsActions.MouseEnterTempAnnotationAction => ({ type: 'MOUSEENTER_TEMP_ANNOTATION', }) -export const mouseLeaveTempAnnotation = (): Types.Annotations.Actions.MouseLeaveTempAnnotationAction => ({ +export const mouseLeaveTempAnnotation = (): AnnotationsActions.MouseLeaveTempAnnotationAction => ({ type: 'MOUSELEAVE_TEMP_ANNOTATION', }) export const loadAnnotations = ( - annotations: Types.Annotations.Data.AnnotationInterface[] -): Types.Annotations.Actions.LoadAnnotationsAction => ({ + annotations: AnnotationsModels.AnnotationInterface[] +): AnnotationsActions.LoadAnnotationsAction => ({ type: 'LOAD_ANNOTATIONS', payload: { annotations, @@ -40,8 +41,8 @@ export const loadAnnotations = ( }) export const updateAnnotation = ( - annotation: Types.Annotations.Data.AnnotationInterface -): Types.Annotations.Actions.UpdateAnnotationAction => ({ + annotation: AnnotationsModels.AnnotationInterface +): AnnotationsActions.UpdateAnnotationAction => ({ type: 'UPDATE_ANNOTATION', payload: { annotation, @@ -49,8 +50,8 @@ export const updateAnnotation = ( }) export const deleteAnnotation = ( - annotation: Types.Annotations.Data.AnnotationInterface -): Types.Annotations.Actions.DeleteAnnotationAction => ({ + annotation: AnnotationsModels.AnnotationInterface +): AnnotationsActions.DeleteAnnotationAction => ({ type: 'DELETE_ANNOTATION', payload: { annotation, @@ -58,8 +59,8 @@ export const deleteAnnotation = ( }) export const addAnnotation = ( - annotation: Types.Annotations.Data.AnnotationInterface -): Types.Annotations.Actions.AddAnnotationAction => ({ + annotation: AnnotationsModels.AnnotationInterface +): AnnotationsActions.AddAnnotationAction => ({ type: 'ADD_ANNOTATION', payload: { annotation, @@ -68,7 +69,7 @@ export const addAnnotation = ( export const addAnnotationAsync = ( createUrl: string, - annotation: Types.Annotations.Data.AnnotationInterface + annotation: AnnotationsModels.AnnotationInterface ) => async dispatch => { dispatch(addAnnotation(annotation)) const savedAnnotation = await api.createAnnotation(createUrl, annotation) @@ -76,25 +77,25 @@ export const addAnnotationAsync = ( dispatch(deleteAnnotation(annotation)) } -export const getAnnotationsAsync: Types.Annotations.Actions.GetAnnotationsDispatcher = ( +export const getAnnotationsAsync: AnnotationsActions.GetAnnotationsDispatcher = ( indexUrl: string, - {since, until}: Types.Annotations.Data.AnnotationRange -): Types.Annotations.Actions.GetAnnotationsThunk => async ( - dispatch: Dispatch + {since, until}: AnnotationsModels.AnnotationRange +): AnnotationsActions.GetAnnotationsThunk => async ( + dispatch: Dispatch ): Promise => { const annotations = await api.getAnnotations(indexUrl, since, until) dispatch(loadAnnotations(annotations)) } export const deleteAnnotationAsync = ( - annotation: Types.Annotations.Data.AnnotationInterface + annotation: AnnotationsModels.AnnotationInterface ) => async dispatch => { await api.deleteAnnotation(annotation) dispatch(deleteAnnotation(annotation)) } export const updateAnnotationAsync = ( - annotation: Types.Annotations.Data.AnnotationInterface + annotation: AnnotationsModels.AnnotationInterface ) => async dispatch => { await api.updateAnnotation(annotation) dispatch(updateAnnotation(annotation)) diff --git a/ui/src/shared/actions/app.ts b/ui/src/shared/actions/app.ts index 858203d1c4..3619856b5e 100644 --- a/ui/src/shared/actions/app.ts +++ b/ui/src/shared/actions/app.ts @@ -4,20 +4,21 @@ import {notify} from 'src/shared/actions/notifications' import {notifyPresentationMode} from 'src/shared/copy/notifications' import {Dispatch} from 'redux' -import * as Types from 'src/types/modules' + +import * as AppActions from 'src/types/actions/app' // ephemeral state action creators -export const enablePresentationMode = (): Types.App.Actions.EnablePresentationModeAction => ({ +export const enablePresentationMode = (): AppActions.EnablePresentationModeAction => ({ type: 'ENABLE_PRESENTATION_MODE', }) -export const disablePresentationMode = (): Types.App.Actions.DisablePresentationModeAction => ({ +export const disablePresentationMode = (): AppActions.DisablePresentationModeAction => ({ type: 'DISABLE_PRESENTATION_MODE', }) -export const delayEnablePresentationMode: Types.App.Actions.DelayEnablePresentationModeDispatcher = () => async ( - dispatch: Dispatch +export const delayEnablePresentationMode: AppActions.DelayEnablePresentationModeDispatcher = () => async ( + dispatch: Dispatch ): Promise => setTimeout(() => { dispatch(enablePresentationMode()) @@ -26,20 +27,20 @@ export const delayEnablePresentationMode: Types.App.Actions.DelayEnablePresentat // persistent state action creators -export const setAutoRefresh: Types.App.Actions.SetAutoRefreshActionCreator = ( +export const setAutoRefresh: AppActions.SetAutoRefreshActionCreator = ( milliseconds: number -): Types.App.Actions.SetAutoRefreshAction => ({ +): AppActions.SetAutoRefreshAction => ({ type: 'SET_AUTOREFRESH', payload: { milliseconds, }, }) -export const templateControlBarVisibilityToggled = (): Types.App.Actions.TemplateControlBarVisibilityToggledAction => ({ +export const templateControlBarVisibilityToggled = (): AppActions.TemplateControlBarVisibilityToggledAction => ({ type: 'TEMPLATE_CONTROL_BAR_VISIBILITY_TOGGLED', }) -export const noop = (): Types.App.Actions.NoopAction => ({ +export const noop = (): AppActions.NoopAction => ({ type: 'NOOP', payload: {}, }) diff --git a/ui/src/shared/actions/errors.ts b/ui/src/shared/actions/errors.ts index 3b17c2ea0e..00ce9524e1 100644 --- a/ui/src/shared/actions/errors.ts +++ b/ui/src/shared/actions/errors.ts @@ -1,10 +1,11 @@ -import * as Types from 'src/types/modules' +import * as ErrorsActions from 'src/types/actions/errors' +import * as ErrorsModels from 'src/types/errors' export const errorThrown = ( - error: Types.Errors.Data.ErrorDescription, + error: ErrorsModels.ErrorDescription, altText?: string, - alertType?: Types.Errors.Data.AlertType -): Types.Errors.Actions.ErrorThrownAction => ({ + alertType?: ErrorsModels.AlertType +): ErrorsActions.ErrorThrownAction => ({ type: 'ERROR_THROWN', error, altText, diff --git a/ui/src/shared/actions/notifications.ts b/ui/src/shared/actions/notifications.ts index 0da924710a..8df5946676 100644 --- a/ui/src/shared/actions/notifications.ts +++ b/ui/src/shared/actions/notifications.ts @@ -1,14 +1,15 @@ -import * as Types from 'src/types/modules' +import * as NotificationsActions from 'src/types/actions/notifications' +import * as NotificationsModels from 'src/types/notifications' -export const notify: Types.Notifications.Actions.PublishNotificationActionCreator = ( - notification: Types.Notifications.Data.Notification -): Types.Notifications.Actions.PublishNotificationAction => ({ +export const notify: NotificationsActions.PublishNotificationActionCreator = ( + notification: NotificationsModels.Notification +): NotificationsActions.PublishNotificationAction => ({ type: 'PUBLISH_NOTIFICATION', payload: {notification}, }) export const dismissNotification = ( id: string -): Types.Notifications.Actions.DismissNotificationAction => ({ +): NotificationsActions.DismissNotificationAction => ({ type: 'DISMISS_NOTIFICATION', payload: {id}, }) diff --git a/ui/src/sources/containers/SourcePage.tsx b/ui/src/sources/containers/SourcePage.tsx index 55a005f08a..e76c1fd5d3 100644 --- a/ui/src/sources/containers/SourcePage.tsx +++ b/ui/src/sources/containers/SourcePage.tsx @@ -29,10 +29,11 @@ import { } from 'src/shared/copy/notifications' import {ErrorHandling} from 'src/shared/decorators/errors' -import * as Types from 'src/types/modules' +import * as SourcesModels from 'src/types/sources' +import * as NotificationsActions from 'src/types/actions/notifications' interface Props extends WithRouterProps { - notify: Types.Notifications.Actions.PublishNotificationActionCreator + notify: NotificationsActions.PublishNotificationActionCreator addSource: AddSource updateSource: UpdateSource } @@ -40,7 +41,7 @@ interface Props extends WithRouterProps { interface State { isCreated: boolean isLoading: boolean - source: Partial + source: Partial editMode: boolean isInitialSource: boolean } diff --git a/ui/src/types/actions/cellEditorOverlay.ts b/ui/src/types/actions/cellEditorOverlay.ts index 6f1392b36b..779e454977 100644 --- a/ui/src/types/actions/cellEditorOverlay.ts +++ b/ui/src/types/actions/cellEditorOverlay.ts @@ -1,4 +1,5 @@ -import * as Types from 'src/types/modules' +import * as ColorsModels from 'src/types/colors' +import * as DashboardsModels from 'src/types/dashboards' export type Action = | ShowCellEditorOverlayAction @@ -16,13 +17,13 @@ export type Action = | UpdateFieldOptionsAction export type ShowCellEditorOverlayActionCreator = ( - cell: Types.Dashboards.Data.Cell + cell: DashboardsModels.Cell ) => ShowCellEditorOverlayAction export interface ShowCellEditorOverlayAction { type: 'SHOW_CELL_EDITOR_OVERLAY' payload: { - cell: Types.Dashboards.Data.Cell + cell: DashboardsModels.Cell } } @@ -35,7 +36,7 @@ export interface HideCellEditorOverlayAction { export interface ChangeCellTypeAction { type: 'CHANGE_CELL_TYPE' payload: { - cellType: Types.Dashboards.Data.CellType + cellType: DashboardsModels.CellType } } @@ -49,42 +50,42 @@ export interface RenameCellAction { export interface UpdateThresholdsListColorsAction { type: 'UPDATE_THRESHOLDS_LIST_COLORS' payload: { - thresholdsListColors: Types.Colors.Data.ColorNumber[] + thresholdsListColors: ColorsModels.ColorNumber[] } } export interface UpdateThresholdsListTypeAction { type: 'UPDATE_THRESHOLDS_LIST_TYPE' payload: { - thresholdsListType: Types.Dashboards.Data.ThresholdType + thresholdsListType: DashboardsModels.ThresholdType } } export interface UpdateGaugeColorsAction { type: 'UPDATE_GAUGE_COLORS' payload: { - gaugeColors: Types.Colors.Data.ColorNumber[] + gaugeColors: ColorsModels.ColorNumber[] } } export interface UpdateAxesAction { type: 'UPDATE_AXES' payload: { - axes: Types.Dashboards.Data.Axes + axes: DashboardsModels.Axes } } export interface UpdateTableOptionsAction { type: 'UPDATE_TABLE_OPTIONS' payload: { - tableOptions: Types.Dashboards.Data.TableOptions + tableOptions: DashboardsModels.TableOptions } } export interface UpdateLineColorsAction { type: 'UPDATE_LINE_COLORS' payload: { - lineColors: Types.Colors.Data.ColorString[] + lineColors: ColorsModels.ColorString[] } } @@ -98,13 +99,13 @@ export interface ChangeTimeFormatAction { export interface ChangeDecimalPlacesAction { type: 'CHANGE_DECIMAL_PLACES' payload: { - decimalPlaces: Types.Dashboards.Data.DecimalPlaces + decimalPlaces: DashboardsModels.DecimalPlaces } } export interface UpdateFieldOptionsAction { type: 'UPDATE_FIELD_OPTIONS' payload: { - fieldOptions: Types.Dashboards.Data.FieldOption[] + fieldOptions: DashboardsModels.FieldOption[] } } diff --git a/ui/src/types/actions/dashboards.ts b/ui/src/types/actions/dashboards.ts index 555eca6b31..850eaf511c 100644 --- a/ui/src/types/actions/dashboards.ts +++ b/ui/src/types/actions/dashboards.ts @@ -3,29 +3,35 @@ import {InjectedRouter} from 'react-router' import {LocationAction} from 'react-router-redux' import {Source} from 'src/types' import {Location} from 'history' -import * as Types from 'src/types/modules' +import * as DashboardsModels from 'src/types/dashboards' +import * as DashboardsReducers from 'src/types/reducers/dashboards' +import * as ErrorsActions from 'src/types/actions/errors' +import * as QueriesModels from 'src/types/query' +import * as TempVarsModels from 'src/types/tempVars' +import * as NotificationsActions from 'src/types/actions/notifications' + export type LoadDashboardsActionCreator = ( - dashboards: Types.Dashboards.Data.Dashboard[], + dashboards: DashboardsModels.Dashboard[], dashboardID?: number ) => LoadDashboardsAction export interface LoadDashboardsAction { type: 'LOAD_DASHBOARDS' payload: { - dashboards: Types.Dashboards.Data.Dashboard[] + dashboards: DashboardsModels.Dashboard[] dashboardID: number } } export type LoadDashboardActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard ) => LoadDashboardAction export interface LoadDashboardAction { type: 'LOAD_DASHBOARD' payload: { - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard } } @@ -33,13 +39,13 @@ export interface SetDashTimeV1Action { type: 'SET_DASHBOARD_TIME_V1' payload: { dashboardID: number - timeRange: Types.Queries.Data.TimeRange + timeRange: QueriesModels.TimeRange } } export type SetDashTimeV1ActionCreator = ( dashboardID: number, - timeRange: Types.Queries.Data.TimeRange + timeRange: QueriesModels.TimeRange ) => SetDashTimeV1Action export interface RetainRangesDashTimeV1Action { @@ -54,18 +60,18 @@ export type RetainRangesDashTimeV1ActionCreator = ( ) => RetainRangesDashTimeV1Action export type SetTimeRangeActionCreator = ( - timeRange: Types.Queries.Data.TimeRange + timeRange: QueriesModels.TimeRange ) => SetTimeRangeAction export interface SetTimeRangeAction { type: 'SET_DASHBOARD_TIME_RANGE' payload: { - timeRange: Types.Queries.Data.TimeRange + timeRange: QueriesModels.TimeRange } } export type SetZoomedTimeRangeDispatcher = ( - zoomedTimeRange: Types.Queries.Data.TimeRange, + zoomedTimeRange: QueriesModels.TimeRange, location: Location ) => SetZoomedTimeRangeThunk @@ -77,135 +83,135 @@ export type SetZoomedTimeRangeThunk = ( ) => Promise export type SetZoomedTimeRangeActionCreator = ( - zoomedTimeRange: Types.Queries.Data.TimeRange + zoomedTimeRange: QueriesModels.TimeRange ) => SetZoomedTimeRangeAction export interface SetZoomedTimeRangeAction { type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE' payload: { - zoomedTimeRange: Types.Queries.Data.TimeRange + zoomedTimeRange: QueriesModels.TimeRange } } export interface UpdateDashboardAction { type: 'UPDATE_DASHBOARD' payload: { - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard } } export type UpdateDashboardActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard ) => UpdateDashboardAction export type CreateDashboardActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard ) => CreateDashboardAction export interface CreateDashboardAction { type: 'CREATE_DASHBOARD' payload: { - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard } } export type DeleteDashboardActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard ) => DeleteDashboardAction export interface DeleteDashboardAction { type: 'DELETE_DASHBOARD' payload: { - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard } } export type DeleteDashboardFailedActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard ) => DeleteDashboardFailedAction export interface DeleteDashboardFailedAction { type: 'DELETE_DASHBOARD_FAILED' payload: { - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard } } export type SyncDashboardCellActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard, - cell: Types.Dashboards.Data.Cell + dashboard: DashboardsModels.Dashboard, + cell: DashboardsModels.Cell ) => SyncDashboardCellAction export interface SyncDashboardCellAction { type: 'SYNC_DASHBOARD_CELL' payload: { - dashboard: Types.Dashboards.Data.Dashboard - cell: Types.Dashboards.Data.Cell + dashboard: DashboardsModels.Dashboard + cell: DashboardsModels.Cell } } export type AddDashboardCellDispatcher = ( - dashboard: Types.Dashboards.Data.Dashboard, - cellType?: Types.Dashboards.Data.CellType + dashboard: DashboardsModels.Dashboard, + cellType?: DashboardsModels.CellType ) => AddDashboardCellThunk export type AddDashboardCellThunk = ( dispatch: Dispatch< | AddDashboardCellAction - | Types.Notifications.Actions.PublishNotificationActionCreator - | Types.Errors.Actions.ErrorThrownActionCreator + | NotificationsActions.PublishNotificationActionCreator + | ErrorsActions.ErrorThrownActionCreator > ) => Promise export type AddDashboardCellActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard, - cell: Types.Dashboards.Data.Cell + dashboard: DashboardsModels.Dashboard, + cell: DashboardsModels.Cell ) => AddDashboardCellAction export interface AddDashboardCellAction { type: 'ADD_DASHBOARD_CELL' payload: { - dashboard: Types.Dashboards.Data.Dashboard - cell: Types.Dashboards.Data.Cell + dashboard: DashboardsModels.Dashboard + cell: DashboardsModels.Cell } } export type CloneDashboardCellDispatcher = ( - dashboard: Types.Dashboards.Data.Dashboard, - cell: Types.Dashboards.Data.Cell + dashboard: DashboardsModels.Dashboard, + cell: DashboardsModels.Cell ) => CloneDashboardCellThunk export type CloneDashboardCellThunk = ( dispatch: Dispatch< | AddDashboardCellAction - | Types.Notifications.Actions.PublishNotificationActionCreator - | Types.Errors.Actions.ErrorThrownActionCreator + | NotificationsActions.PublishNotificationActionCreator + | ErrorsActions.ErrorThrownActionCreator > ) => Promise export type DeleteDashboardCellDispatcher = ( - dashboard: Types.Dashboards.Data.Dashboard, - cell: Types.Dashboards.Data.Cell + dashboard: DashboardsModels.Dashboard, + cell: DashboardsModels.Cell ) => DeleteDashboardCellThunk export type DeleteDashboardCellThunk = ( dispatch: Dispatch< | DeleteDashboardCellActionCreator - | Types.Notifications.Actions.PublishNotificationActionCreator - | Types.Errors.Actions.ErrorThrownActionCreator + | NotificationsActions.PublishNotificationActionCreator + | ErrorsActions.ErrorThrownActionCreator > ) => Promise export type DeleteDashboardCellActionCreator = ( - dashboard: Types.Dashboards.Data.Dashboard, - cell: Types.Dashboards.Data.Cell + dashboard: DashboardsModels.Dashboard, + cell: DashboardsModels.Cell ) => DeleteDashboardCellAction export interface DeleteDashboardCellAction { type: 'DELETE_DASHBOARD_CELL' payload: { - dashboard: Types.Dashboards.Data.Dashboard - cell: Types.Dashboards.Data.Cell + dashboard: DashboardsModels.Dashboard + cell: DashboardsModels.Cell } } @@ -239,14 +245,14 @@ export interface TemplateVariableSelectedAction { export type TemplateVariablesSelectedByNameActionCreator = ( dashboardID: number, - queryParams: Types.TempVars.Data.URLQueryParams + queryParams: TempVarsModels.URLQueryParams ) => TemplateVariablesSelectedByNameAction export interface TemplateVariablesSelectedByNameAction { type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME' payload: { dashboardID: number - queryParams: Types.TempVars.Data.URLQueryParams + queryParams: TempVarsModels.URLQueryParams } } @@ -290,24 +296,24 @@ export interface SetActiveCellAction { export type GetDashboardsDispatcher = () => GetDashboardsThunk export type GetDashboardsThunk = ( - dispatch: Dispatch -) => Promise + dispatch: Dispatch +) => Promise export type GetDashboardsNamesDispatcher = ( sourceID: string ) => GetDashboardsNamesThunk export type GetDashboardsNamesThunk = ( - dispatch: Dispatch -) => Promise + dispatch: Dispatch +) => Promise export type PutDashboardDispatcher = ( - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard ) => PutDashboardThunk export type PutDashboardThunk = ( dispatch: Dispatch< - UpdateDashboardAction | Types.Errors.Actions.ErrorThrownActionCreator + UpdateDashboardAction | ErrorsActions.ErrorThrownActionCreator > ) => Promise @@ -316,46 +322,43 @@ export type PutDashboardByIDDispatcher = ( ) => PutDashboardByIDThunk export type PutDashboardByIDThunk = ( - dispatch: Dispatch, - getState: () => Types.Dashboards.Reducers.Dashboards + dispatch: Dispatch, + getState: () => DashboardsReducers.Dashboards ) => Promise export type DeleteDashboardDispatcher = ( - dashboard: Types.Dashboards.Data.Dashboard + dashboard: DashboardsModels.Dashboard ) => DeleteDashboardThunk export type DeleteDashboardThunk = ( dispatch: Dispatch< | DeleteDashboardActionCreator - | Types.Notifications.Actions.PublishNotificationActionCreator - | Types.Errors.Actions.ErrorThrownActionCreator + | NotificationsActions.PublishNotificationActionCreator + | ErrorsActions.ErrorThrownActionCreator | DeleteDashboardFailedActionCreator > ) => Promise export type UpdateDashboardCellDispatcher = ( - dashboard: Types.Dashboards.Data.Dashboard, - cell: Types.Dashboards.Data.Cell + dashboard: DashboardsModels.Dashboard, + cell: DashboardsModels.Cell ) => UpdateDashboardCellThunk export type UpdateDashboardCellThunk = ( - dispatch: Dispatch< - | SyncDashboardCellActionCreator - | Types.Errors.Actions.ErrorThrownActionCreator - > + dispatch: Dispatch ) => Promise export type SyncURLQueryFromQueryParamsObjectDispatcher = ( location: Location, - updatedURLQueryParams: Types.TempVars.Data.URLQueryParams, - deletedURLQueryParams?: Types.TempVars.Data.URLQueryParams + updatedURLQueryParams: TempVarsModels.URLQueryParams, + deletedURLQueryParams?: TempVarsModels.URLQueryParams ) => SyncURLQueryFromQueryParamsObjectActionCreator export type SyncURLQueryFromTempVarsDispatcher = ( location: Location, - tempVars: Types.TempVars.Data.Template[], - deletedTempVars: Types.TempVars.Data.Template[], - urlQueryParamsTimeRanges?: Types.TempVars.Data.URLQueryParams + tempVars: TempVarsModels.Template[], + deletedTempVars: TempVarsModels.Template[], + urlQueryParamsTimeRanges?: TempVarsModels.URLQueryParams ) => SyncURLQueryFromQueryParamsObjectActionCreator export type SyncURLQueryFromQueryParamsObjectActionCreator = ( @@ -364,19 +367,15 @@ export type SyncURLQueryFromQueryParamsObjectActionCreator = ( export type SyncDashboardTempVarsFromURLQueryParamsDispatcher = ( dispatch: Dispatch< - | Types.Notifications.Actions.PublishNotificationActionCreator + | NotificationsActions.PublishNotificationActionCreator | TemplateVariableSelectedAction >, - getState: () => Types.Dashboards.Reducers.Dashboards & - Types.Dashboards.Reducers.Auth + getState: () => DashboardsReducers.Dashboards & DashboardsReducers.Auth ) => void export type SyncDashboardTimeRangeFromURLQueryParamsDispatcher = ( - dispatch: Dispatch< - Types.Notifications.Actions.PublishNotificationActionCreator - >, - getState: () => Types.Dashboards.Reducers.Dashboards & - Types.Dashboards.Reducers.DashTimeV1 + dispatch: Dispatch, + getState: () => DashboardsReducers.Dashboards & DashboardsReducers.DashTimeV1 ) => void export type SyncDashboardFromURLQueryParamsDispatcher = ( @@ -394,7 +393,5 @@ export type GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = ( ) => GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk export type GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk = ( - dispatch: Dispatch< - Types.Notifications.Actions.PublishNotificationActionCreator - > + dispatch: Dispatch ) => Promise diff --git a/ui/src/types/modules/annotations.ts b/ui/src/types/modules/annotations.ts deleted file mode 100644 index f94a00604a..0000000000 --- a/ui/src/types/modules/annotations.ts +++ /dev/null @@ -1,4 +0,0 @@ -import * as Actions from 'src/types/actions/annotations' -import * as Data from 'src/types/annotations' - -export {Actions, Data} diff --git a/ui/src/types/modules/app.ts b/ui/src/types/modules/app.ts deleted file mode 100644 index 40444116cb..0000000000 --- a/ui/src/types/modules/app.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as Actions from 'src/types/actions/app' - -export {Actions} diff --git a/ui/src/types/modules/auth.ts b/ui/src/types/modules/auth.ts deleted file mode 100644 index 1f852a6f32..0000000000 --- a/ui/src/types/modules/auth.ts +++ /dev/null @@ -1,4 +0,0 @@ -import * as Data from 'src/types/auth' -import * as Reducers from 'src/types/reducers/auth' - -export {Data, Reducers} diff --git a/ui/src/types/modules/cellEditorOverlay.ts b/ui/src/types/modules/cellEditorOverlay.ts deleted file mode 100644 index c7515f387b..0000000000 --- a/ui/src/types/modules/cellEditorOverlay.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as Actions from 'src/types/actions/cellEditorOverlay' - -export {Actions} diff --git a/ui/src/types/modules/colors.ts b/ui/src/types/modules/colors.ts deleted file mode 100644 index 1efb057641..0000000000 --- a/ui/src/types/modules/colors.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as Data from 'src/types/colors' - -export {Data} diff --git a/ui/src/types/modules/dashboards.ts b/ui/src/types/modules/dashboards.ts deleted file mode 100644 index bd660aa552..0000000000 --- a/ui/src/types/modules/dashboards.ts +++ /dev/null @@ -1,6 +0,0 @@ -import * as Data from 'src/types/dashboards' -import * as Actions from 'src/types/actions/dashboards' -import * as Apis from 'src/types/apis/dashboards' -import * as Reducers from 'src/types/reducers/dashboards' - -export {Data, Actions, Apis, Reducers} diff --git a/ui/src/types/modules/errors.ts b/ui/src/types/modules/errors.ts deleted file mode 100644 index 6ccc21754a..0000000000 --- a/ui/src/types/modules/errors.ts +++ /dev/null @@ -1,4 +0,0 @@ -import * as Actions from 'src/types/actions/errors' -import * as Data from 'src/types/errors' - -export {Actions, Data} diff --git a/ui/src/types/modules/index.ts b/ui/src/types/modules/index.ts deleted file mode 100644 index 1fdcfc7297..0000000000 --- a/ui/src/types/modules/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import * as Annotations from 'src/types/modules/annotations' -import * as App from 'src/types/modules/app' -import * as Auth from 'src/types/modules/auth' -import * as Dashboards from 'src/types/modules/dashboards' -import * as CellEditorOverlay from 'src/types/modules/cellEditorOverlay' -import * as Colors from 'src/types/modules/colors' -import * as Errors from 'src/types/modules/errors' -import * as Notifications from 'src/types/modules/notifications' -import * as Queries from 'src/types/modules/queries' -import * as Sources from 'src/types/modules/sources' -import * as TempVars from 'src/types/modules/tempVars' - -export { - Annotations, - App, - Auth, - Dashboards, - CellEditorOverlay, - Colors, - Errors, - Notifications, - Queries, - Sources, - TempVars, -} diff --git a/ui/src/types/modules/notifications.ts b/ui/src/types/modules/notifications.ts deleted file mode 100644 index 90666a2837..0000000000 --- a/ui/src/types/modules/notifications.ts +++ /dev/null @@ -1,4 +0,0 @@ -import * as Actions from 'src/types/actions/notifications' -import * as Data from 'src/types/notifications' - -export {Actions, Data} diff --git a/ui/src/types/modules/queries.ts b/ui/src/types/modules/queries.ts deleted file mode 100644 index 6478f29538..0000000000 --- a/ui/src/types/modules/queries.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as Data from 'src/types/query' - -export {Data} diff --git a/ui/src/types/modules/sources.ts b/ui/src/types/modules/sources.ts deleted file mode 100644 index 297fb23c1e..0000000000 --- a/ui/src/types/modules/sources.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as Data from 'src/types/sources' - -export {Data} diff --git a/ui/src/types/modules/tempVars.ts b/ui/src/types/modules/tempVars.ts deleted file mode 100644 index 21a65c818c..0000000000 --- a/ui/src/types/modules/tempVars.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as Data from 'src/types/tempVars' - -export {Data} diff --git a/ui/src/types/reducers/auth.ts b/ui/src/types/reducers/auth.ts index 05d55893af..5dd128de88 100644 --- a/ui/src/types/reducers/auth.ts +++ b/ui/src/types/reducers/auth.ts @@ -1,8 +1,8 @@ -import * as Types from 'src/types/modules' +import * as AuthModels from 'src/types/auth' export interface Auth { auth: { isUsingAuth: boolean - me: Types.Auth.Data.Me + me: AuthModels.Me } } From 3125f23b1663159d08c5da5fde8a5addd18e0d51 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 25 Jun 2018 17:10:34 -0700 Subject: [PATCH 49/49] Rename types/query to types/queries for consistency --- ui/src/dashboards/actions/index.ts | 2 +- ui/src/dashboards/components/CellEditorOverlay.tsx | 2 +- ui/src/dashboards/components/DashboardHeader.tsx | 2 +- ui/src/dashboards/components/OverlayControls.tsx | 2 +- ui/src/dashboards/components/SourceSelector.tsx | 2 +- ui/src/dashboards/components/TableOptions.tsx | 2 +- ui/src/dashboards/containers/DashboardPage.tsx | 2 +- ui/src/dashboards/utils/time.ts | 2 +- ui/src/data_explorer/components/QueryMakerTab.tsx | 2 +- ui/src/shared/apis/databases.ts | 2 +- ui/src/shared/components/CustomTimeIndicator.tsx | 2 +- ui/src/shared/components/DatabaseList.tsx | 2 +- ui/src/shared/components/DatabaseListItem.tsx | 2 +- ui/src/shared/components/LayoutCellMenu.tsx | 2 +- ui/src/shared/components/QueryTabList.tsx | 2 +- ui/src/shared/components/WidgetCell.tsx | 2 +- ui/src/shared/data/timeRanges.ts | 2 +- ui/src/tempVars/constants/index.ts | 2 +- ui/src/types/actions/dashboards.ts | 2 +- ui/src/types/index.ts | 2 +- ui/src/types/{query.ts => queries.ts} | 0 ui/src/types/reducers/dashboards.ts | 2 +- 22 files changed, 21 insertions(+), 21 deletions(-) rename ui/src/types/{query.ts => queries.ts} (100%) diff --git a/ui/src/dashboards/actions/index.ts b/ui/src/dashboards/actions/index.ts index d55892b76a..1c0bd0cc91 100644 --- a/ui/src/dashboards/actions/index.ts +++ b/ui/src/dashboards/actions/index.ts @@ -65,7 +65,7 @@ import * as DashboardsApis from 'src/types/apis/dashboards' import * as DashboardsModels from 'src/types/dashboards' import * as DashboardsReducers from 'src/types/reducers/dashboards' import * as ErrorsActions from 'src/types/actions/errors' -import * as QueriesModels from 'src/types/query' +import * as QueriesModels from 'src/types/queries' import * as SourcesModels from 'src/types/sources' import * as TempVarsModels from 'src/types/tempVars' import * as NotificationsActions from 'src/types/actions/notifications' diff --git a/ui/src/dashboards/components/CellEditorOverlay.tsx b/ui/src/dashboards/components/CellEditorOverlay.tsx index 1ea868e102..949eb2805a 100644 --- a/ui/src/dashboards/components/CellEditorOverlay.tsx +++ b/ui/src/dashboards/components/CellEditorOverlay.tsx @@ -40,7 +40,7 @@ import * as CellEditorOverlayActions from 'src/types/actions/cellEditorOverlay' import * as ColorsModels from 'src/types/colors' import * as DashboardsActions from 'src/types/actions/dashboards' import * as DashboardsModels from 'src/types/dashboards' -import * as QueriesModels from 'src/types/query' +import * as QueriesModels from 'src/types/queries' import * as SourcesModels from 'src/types/sources' type QueryTransitions = typeof queryTransitions diff --git a/ui/src/dashboards/components/DashboardHeader.tsx b/ui/src/dashboards/components/DashboardHeader.tsx index 2ae7f50fef..f27354b9bd 100644 --- a/ui/src/dashboards/components/DashboardHeader.tsx +++ b/ui/src/dashboards/components/DashboardHeader.tsx @@ -13,7 +13,7 @@ import DashboardSwitcher from 'src/dashboards/components/DashboardSwitcher' import * as AppActions from 'src/types/actions/app' import * as DashboardsModels from 'src/types/dashboards' -import * as QueriesModels from 'src/types/query' +import * as QueriesModels from 'src/types/queries' interface Props { activeDashboard: string diff --git a/ui/src/dashboards/components/OverlayControls.tsx b/ui/src/dashboards/components/OverlayControls.tsx index 522e36fcee..7907798d06 100644 --- a/ui/src/dashboards/components/OverlayControls.tsx +++ b/ui/src/dashboards/components/OverlayControls.tsx @@ -4,7 +4,7 @@ import classnames from 'classnames' import ConfirmOrCancel from 'src/shared/components/ConfirmOrCancel' import SourceSelector from 'src/dashboards/components/SourceSelector' -import * as QueriesModels from 'src/types/query' +import * as QueriesModels from 'src/types/queries' import * as SourcesModels from 'src/types/sources' interface Props { diff --git a/ui/src/dashboards/components/SourceSelector.tsx b/ui/src/dashboards/components/SourceSelector.tsx index 982c2df6a9..5479bde4c5 100644 --- a/ui/src/dashboards/components/SourceSelector.tsx +++ b/ui/src/dashboards/components/SourceSelector.tsx @@ -2,7 +2,7 @@ import React, {SFC} from 'react' import Dropdown from 'src/shared/components/Dropdown' -import * as QueriesModels from 'src/types/query' +import * as QueriesModels from 'src/types/queries' import * as SourcesModels from 'src/types/sources' interface Props { diff --git a/ui/src/dashboards/components/TableOptions.tsx b/ui/src/dashboards/components/TableOptions.tsx index 9d365b747d..97321aa258 100644 --- a/ui/src/dashboards/components/TableOptions.tsx +++ b/ui/src/dashboards/components/TableOptions.tsx @@ -25,7 +25,7 @@ import {DEFAULT_TIME_FIELD} from 'src/dashboards/constants' import {ErrorHandling} from 'src/shared/decorators/errors' import {DecimalPlaces} from 'src/types/dashboards' -import {QueryConfig} from 'src/types/query' +import {QueryConfig} from 'src/types/queries' interface DropdownOption { text: string diff --git a/ui/src/dashboards/containers/DashboardPage.tsx b/ui/src/dashboards/containers/DashboardPage.tsx index ad6298db10..107e7fb505 100644 --- a/ui/src/dashboards/containers/DashboardPage.tsx +++ b/ui/src/dashboards/containers/DashboardPage.tsx @@ -48,7 +48,7 @@ import * as ColorsModels from 'src/types/colors' import * as DashboardsActions from 'src/types/actions/dashboards' import * as DashboardsModels from 'src/types/dashboards' import * as ErrorsActions from 'src/types/actions/errors' -import * as QueriesModels from 'src/types/query' +import * as QueriesModels from 'src/types/queries' import * as SourcesModels from 'src/types/sources' import * as TempVarsModels from 'src/types/tempVars' import * as NotificationsActions from 'src/types/actions/notifications' diff --git a/ui/src/dashboards/utils/time.ts b/ui/src/dashboards/utils/time.ts index 172aa62282..f89405ca45 100644 --- a/ui/src/dashboards/utils/time.ts +++ b/ui/src/dashboards/utils/time.ts @@ -1,4 +1,4 @@ -import {TimeRange} from 'src/types/query' +import {TimeRange} from 'src/types/queries' import moment from 'moment' import {timeRanges} from 'src/shared/data/timeRanges' diff --git a/ui/src/data_explorer/components/QueryMakerTab.tsx b/ui/src/data_explorer/components/QueryMakerTab.tsx index 539af199cb..235a29a21c 100644 --- a/ui/src/data_explorer/components/QueryMakerTab.tsx +++ b/ui/src/data_explorer/components/QueryMakerTab.tsx @@ -1,7 +1,7 @@ import React, {PureComponent} from 'react' import classnames from 'classnames' import {ErrorHandling} from 'src/shared/decorators/errors' -import {QueryConfig} from 'src/types/query' +import {QueryConfig} from 'src/types/queries' interface Props { isActive: boolean diff --git a/ui/src/shared/apis/databases.ts b/ui/src/shared/apis/databases.ts index 3bcf8dd2a6..68e6bd163e 100644 --- a/ui/src/shared/apis/databases.ts +++ b/ui/src/shared/apis/databases.ts @@ -4,7 +4,7 @@ import {showDatabases, showRetentionPolicies} from 'src/shared/apis/metaQuery' import showDatabasesParser from 'src/shared/parsing/showDatabases' import showRetentionPoliciesParser from 'src/shared/parsing/showRetentionPolicies' -import {Namespace} from 'src/types/query' +import {Namespace} from 'src/types/queries' export const getDatabasesWithRetentionPolicies = async ( proxy: string diff --git a/ui/src/shared/components/CustomTimeIndicator.tsx b/ui/src/shared/components/CustomTimeIndicator.tsx index 34d1d942d6..2a84039431 100644 --- a/ui/src/shared/components/CustomTimeIndicator.tsx +++ b/ui/src/shared/components/CustomTimeIndicator.tsx @@ -2,7 +2,7 @@ import React, {SFC} from 'react' import _ from 'lodash' import {TEMP_VAR_DASHBOARD_TIME} from 'src/shared/constants' -import {QueryConfig} from 'src/types/query' +import {QueryConfig} from 'src/types/queries' interface Query { config: QueryConfig diff --git a/ui/src/shared/components/DatabaseList.tsx b/ui/src/shared/components/DatabaseList.tsx index 8b5d1128de..824eaec0ec 100644 --- a/ui/src/shared/components/DatabaseList.tsx +++ b/ui/src/shared/components/DatabaseList.tsx @@ -4,7 +4,7 @@ import PropTypes from 'prop-types' import _ from 'lodash' import {QueryConfig, Source} from 'src/types' -import {Namespace} from 'src/types/query' +import {Namespace} from 'src/types/queries' import DatabaseListItem from 'src/shared/components/DatabaseListItem' import FancyScrollbar from 'src/shared/components/FancyScrollbar' diff --git a/ui/src/shared/components/DatabaseListItem.tsx b/ui/src/shared/components/DatabaseListItem.tsx index 22db6de542..2cce0fd7e0 100644 --- a/ui/src/shared/components/DatabaseListItem.tsx +++ b/ui/src/shared/components/DatabaseListItem.tsx @@ -2,7 +2,7 @@ import React, {SFC} from 'react' import classnames from 'classnames' -import {Namespace} from 'src/types/query' +import {Namespace} from 'src/types/queries' export interface DatabaseListItemProps { isActive: boolean diff --git a/ui/src/shared/components/LayoutCellMenu.tsx b/ui/src/shared/components/LayoutCellMenu.tsx index ed4636cab9..8f6535cddc 100644 --- a/ui/src/shared/components/LayoutCellMenu.tsx +++ b/ui/src/shared/components/LayoutCellMenu.tsx @@ -12,7 +12,7 @@ import Authorized, {EDITOR_ROLE} from 'src/auth/Authorized' import {EDITING} from 'src/shared/annotations/helpers' import {cellSupportsAnnotations} from 'src/shared/constants/index' import {Cell} from 'src/types/dashboards' -import {QueryConfig} from 'src/types/query' +import {QueryConfig} from 'src/types/queries' import { addingAnnotation, diff --git a/ui/src/shared/components/QueryTabList.tsx b/ui/src/shared/components/QueryTabList.tsx index 1e3ee9cae8..fe5594e9b6 100644 --- a/ui/src/shared/components/QueryTabList.tsx +++ b/ui/src/shared/components/QueryTabList.tsx @@ -1,7 +1,7 @@ import React, {PureComponent} from 'react' import QueryMakerTab from 'src/data_explorer/components/QueryMakerTab' import buildInfluxQLQuery from 'src/utils/influxql' -import {QueryConfig, TimeRange} from 'src/types/query' +import {QueryConfig, TimeRange} from 'src/types/queries' interface Props { queries: QueryConfig[] diff --git a/ui/src/shared/components/WidgetCell.tsx b/ui/src/shared/components/WidgetCell.tsx index f9ce6f95ee..fc14c4166e 100644 --- a/ui/src/shared/components/WidgetCell.tsx +++ b/ui/src/shared/components/WidgetCell.tsx @@ -6,7 +6,7 @@ import GettingStarted from 'src/status/components/GettingStarted' import {Cell} from 'src/types/dashboards' import {Source} from 'src/types/sources' -import {TimeRange} from 'src/types/query' +import {TimeRange} from 'src/types/queries' import {RECENT_ALERTS_LIMIT} from 'src/status/constants' interface Props { diff --git a/ui/src/shared/data/timeRanges.ts b/ui/src/shared/data/timeRanges.ts index 972be61c31..87c3945969 100644 --- a/ui/src/shared/data/timeRanges.ts +++ b/ui/src/shared/data/timeRanges.ts @@ -1,4 +1,4 @@ -import {TimeRangeOption} from 'src/types/query' +import {TimeRangeOption} from 'src/types/queries' const nowMinus30d = 'now() - 30d' diff --git a/ui/src/tempVars/constants/index.ts b/ui/src/tempVars/constants/index.ts index d5fa36e058..4f3e469105 100644 --- a/ui/src/tempVars/constants/index.ts +++ b/ui/src/tempVars/constants/index.ts @@ -1,6 +1,6 @@ import uuid from 'uuid' -import {TimeRange} from 'src/types/query' +import {TimeRange} from 'src/types/queries' import {TEMP_VAR_DASHBOARD_TIME} from 'src/shared/constants' import {Template, TemplateType, TemplateValueType} from 'src/types' diff --git a/ui/src/types/actions/dashboards.ts b/ui/src/types/actions/dashboards.ts index 850eaf511c..d9168ac72e 100644 --- a/ui/src/types/actions/dashboards.ts +++ b/ui/src/types/actions/dashboards.ts @@ -6,7 +6,7 @@ import {Location} from 'history' import * as DashboardsModels from 'src/types/dashboards' import * as DashboardsReducers from 'src/types/reducers/dashboards' import * as ErrorsActions from 'src/types/actions/errors' -import * as QueriesModels from 'src/types/query' +import * as QueriesModels from 'src/types/queries' import * as TempVarsModels from 'src/types/tempVars' import * as NotificationsActions from 'src/types/actions/notifications' diff --git a/ui/src/types/index.ts b/ui/src/types/index.ts index 7c9db25cbd..15fdda9ba8 100644 --- a/ui/src/types/index.ts +++ b/ui/src/types/index.ts @@ -27,7 +27,7 @@ import { Tag, Tags, TagValues, -} from './query' +} from './queries' import {AlertRule, Kapacitor, Task, RuleValues} from './kapacitor' import {NewSource, Source, SourceLinks} from './sources' import {DropdownAction, DropdownItem, Constructable} from './shared' diff --git a/ui/src/types/query.ts b/ui/src/types/queries.ts similarity index 100% rename from ui/src/types/query.ts rename to ui/src/types/queries.ts diff --git a/ui/src/types/reducers/dashboards.ts b/ui/src/types/reducers/dashboards.ts index 0d1746dc3a..6c67a5d6e4 100644 --- a/ui/src/types/reducers/dashboards.ts +++ b/ui/src/types/reducers/dashboards.ts @@ -1,6 +1,6 @@ import {Dashboard} from 'src/types' import {Me} from 'src/types/auth' -import {DashTimeV1Range} from 'src/types/query' +import {DashTimeV1Range} from 'src/types/queries' export interface Dashboards { dashboardUI: {dashboards: Dashboard[]}