From 72d913b955bbcbbba2a26a350efa026d6b0034cc Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 22 Jun 2018 18:25:22 -0700 Subject: [PATCH] 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 ecf04c380..10e603521 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 55d8ed343..04970cd4a 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 cae0f9796..1b368df59 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 000000000..f1f8837a5 --- /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 +}