From 38c534b3aa0dcad03b05aefe929b637905d48dbe Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Fri, 27 Dec 2019 21:03:21 +0530 Subject: [PATCH] Add action types --- lib/actions/index.ts | 2 +- lib/constants/config.ts | 14 +++++ lib/constants/index.ts | 8 ++- lib/constants/notifications.ts | 13 +++++ lib/constants/sessions.ts | 92 ++++++++++++++++++++++++++++++ lib/constants/tabs.ts | 9 +++ lib/constants/term-groups.ts | 22 +++++++ lib/constants/ui.ts | 101 +++++++++++++++++++++++++++++++++ lib/constants/updater.ts | 13 +++++ lib/hyper.d.ts | 20 +++++++ 10 files changed, 291 insertions(+), 3 deletions(-) diff --git a/lib/actions/index.ts b/lib/actions/index.ts index efa5aed8..a4094f30 100644 --- a/lib/actions/index.ts +++ b/lib/actions/index.ts @@ -1,5 +1,5 @@ import rpc from '../rpc'; -import INIT from '../constants'; +import {INIT} from '../constants'; import {Dispatch} from 'redux'; export default function init() { diff --git a/lib/constants/config.ts b/lib/constants/config.ts index 5221aa4e..02c199ac 100644 --- a/lib/constants/config.ts +++ b/lib/constants/config.ts @@ -1,2 +1,16 @@ export const CONFIG_LOAD = 'CONFIG_LOAD'; export const CONFIG_RELOAD = 'CONFIG_RELOAD'; + +export interface ConfigLoadAction { + type: typeof CONFIG_LOAD; + config: any; + now?: number; +} + +export interface ConfigReloadAction { + type: typeof CONFIG_RELOAD; + config: any; + now: number; +} + +export type ConfigActions = ConfigLoadAction | ConfigReloadAction; diff --git a/lib/constants/index.ts b/lib/constants/index.ts index ab791e74..70bc0535 100644 --- a/lib/constants/index.ts +++ b/lib/constants/index.ts @@ -1,3 +1,7 @@ -const INIT = 'INIT'; +export const INIT = 'INIT'; -export default INIT; +export interface InitAction { + type: typeof INIT; +} + +export type InitActions = InitAction; diff --git a/lib/constants/notifications.ts b/lib/constants/notifications.ts index b1387d1c..c89507af 100644 --- a/lib/constants/notifications.ts +++ b/lib/constants/notifications.ts @@ -1,2 +1,15 @@ export const NOTIFICATION_MESSAGE = 'NOTIFICATION_MESSAGE'; export const NOTIFICATION_DISMISS = 'NOTIFICATION_DISMISS'; + +export interface NotificationMessageAction { + type: typeof NOTIFICATION_MESSAGE; + text: string; + url: string | null; + dismissable: boolean; +} +export interface NotificationDismissAction { + type: typeof NOTIFICATION_DISMISS; + id: string; +} + +export type NotificationActions = NotificationMessageAction | NotificationDismissAction; diff --git a/lib/constants/sessions.ts b/lib/constants/sessions.ts index 427b8929..a399d410 100644 --- a/lib/constants/sessions.ts +++ b/lib/constants/sessions.ts @@ -14,3 +14,95 @@ export const SESSION_SET_XTERM_TITLE = 'SESSION_SET_XTERM_TITLE'; export const SESSION_SET_CWD = 'SESSION_SET_CWD'; export const SESSION_SEARCH = 'SESSION_SEARCH'; export const SESSION_SEARCH_CLOSE = 'SESSION_SEARCH_CLOSE'; + +export interface SessionAddAction { + type: typeof SESSION_ADD; + uid: string; + shell: string | null; + pid: number | null; + cols: number | null; + rows: number | null; + splitDirection?: string; + activeUid: string | null; + now: number; +} +export interface SessionResizeAction { + type: typeof SESSION_RESIZE; + uid: string; + cols: number; + rows: number; + isStandaloneTerm: boolean; + now: number; +} +export interface SessionRequestAction { + type: typeof SESSION_REQUEST; +} +export interface SessionAddDataAction { + type: typeof SESSION_ADD_DATA; +} +export interface SessionPtyDataAction { + type: typeof SESSION_PTY_DATA; + uid: string; + now: number; +} +export interface SessionPtyExitAction { + type: typeof SESSION_PTY_EXIT; + uid: string; +} +export interface SessionUserExitAction { + type: typeof SESSION_USER_EXIT; + uid: string; +} +export interface SessionSetActiveAction { + type: typeof SESSION_SET_ACTIVE; + uid: string; +} +export interface SessionClearActiveAction { + type: typeof SESSION_CLEAR_ACTIVE; +} +export interface SessionUserDataAction { + type: typeof SESSION_USER_DATA; +} +export interface SessionUrlSetAction { + type: typeof SESSION_URL_SET; + uid: string; +} +export interface SessionUrlUnsetAction { + type: typeof SESSION_URL_UNSET; + uid: string; +} +export interface SessionSetXtermTitleAction { + type: typeof SESSION_SET_XTERM_TITLE; + uid: string; + title: string; +} +export interface SessionSetCwdAction { + type: typeof SESSION_SET_CWD; + cwd: string; +} +export interface SessionSearchAction { + type: typeof SESSION_SEARCH; + uid: string; +} +export interface SessionSearchCloseAction { + type: typeof SESSION_SEARCH_CLOSE; + uid: string; +} + +export type SessionActions = + | SessionAddAction + | SessionResizeAction + | SessionRequestAction + | SessionAddDataAction + | SessionPtyDataAction + | SessionPtyExitAction + | SessionUserExitAction + | SessionSetActiveAction + | SessionClearActiveAction + | SessionUserDataAction + | SessionUrlSetAction + | SessionUrlUnsetAction + | SessionSetXtermTitleAction + | SessionSetCwdAction + | SessionSearchAction + | SessionSearchCloseAction; diff --git a/lib/constants/tabs.ts b/lib/constants/tabs.ts index c31375ba..35a7fb3e 100644 --- a/lib/constants/tabs.ts +++ b/lib/constants/tabs.ts @@ -1,2 +1,11 @@ export const CLOSE_TAB = 'CLOSE_TAB'; export const CHANGE_TAB = 'CHANGE_TAB'; + +export interface CloseTabAction { + type: typeof CLOSE_TAB; +} +export interface ChangeTabAction { + type: typeof CHANGE_TAB; +} + +export type TabActions = CloseTabAction | ChangeTabAction; diff --git a/lib/constants/term-groups.ts b/lib/constants/term-groups.ts index 8a084ee8..ca7c7f60 100644 --- a/lib/constants/term-groups.ts +++ b/lib/constants/term-groups.ts @@ -6,3 +6,25 @@ export const DIRECTION = { HORIZONTAL: 'HORIZONTAL', VERTICAL: 'VERTICAL' }; + +export interface TermGroupRequestAction { + type: typeof TERM_GROUP_REQUEST; +} +export interface TermGroupExitAction { + type: typeof TERM_GROUP_EXIT; + uid: string; +} +export interface TermGroupResizeAction { + type: typeof TERM_GROUP_RESIZE; + uid: string; + sizes: number[]; +} +export interface TermGroupExitActiveAction { + type: typeof TERM_GROUP_EXIT_ACTIVE; +} + +export type TermGroupActions = + | TermGroupRequestAction + | TermGroupExitAction + | TermGroupResizeAction + | TermGroupExitActiveAction; diff --git a/lib/constants/ui.ts b/lib/constants/ui.ts index bb710a7d..c54c722b 100644 --- a/lib/constants/ui.ts +++ b/lib/constants/ui.ts @@ -22,3 +22,104 @@ export const UI_ENTER_FULLSCREEN = 'UI_ENTER_FULLSCREEN'; export const UI_LEAVE_FULLSCREEN = 'UI_LEAVE_FULLSCREEN'; export const UI_CONTEXTMENU_OPEN = 'UI_CONTEXTMENU_OPEN'; export const UI_COMMAND_EXEC = 'UI_COMMAND_EXEC'; + +export interface UIFontSizeSetAction { + type: typeof UI_FONT_SIZE_SET; + value: number; +} +export interface UIFontSizeIncrAction { + type: typeof UI_FONT_SIZE_INCR; +} +export interface UIFontSizeDecrAction { + type: typeof UI_FONT_SIZE_DECR; +} +export interface UIFontSizeResetAction { + type: typeof UI_FONT_SIZE_RESET; +} +export interface UIFontSmoothingSetAction { + type: typeof UI_FONT_SMOOTHING_SET; + fontSmoothing: string; +} +export interface UIMoveLeftAction { + type: typeof UI_MOVE_LEFT; +} +export interface UIMoveRightAction { + type: typeof UI_MOVE_RIGHT; +} +export interface UIMoveToAction { + type: typeof UI_MOVE_TO; +} +export interface UIMoveNextPaneAction { + type: typeof UI_MOVE_NEXT_PANE; +} +export interface UIMovePrevPaneAction { + type: typeof UI_MOVE_PREV_PANE; +} +export interface UIShowPreferencesAction { + type: typeof UI_SHOW_PREFERENCES; +} +export interface UIWindowMoveAction { + type: typeof UI_WINDOW_MOVE; +} +export interface UIWindowMaximizeAction { + type: typeof UI_WINDOW_MAXIMIZE; +} +export interface UIWindowUnmaximizeAction { + type: typeof UI_WINDOW_UNMAXIMIZE; +} +export interface UIWindowGeometryChangedAction { + type: typeof UI_WINDOW_GEOMETRY_CHANGED; +} +export interface UIOpenFileAction { + type: typeof UI_OPEN_FILE; +} +export interface UIOpenSshUrlAction { + type: typeof UI_OPEN_SSH_URL; +} +export interface UIOpenHamburgerMenuAction { + type: typeof UI_OPEN_HAMBURGER_MENU; +} +export interface UIWindowMinimizeAction { + type: typeof UI_WINDOW_MINIMIZE; +} +export interface UIWindowCloseAction { + type: typeof UI_WINDOW_CLOSE; +} +export interface UIEnterFullscreenAction { + type: typeof UI_ENTER_FULLSCREEN; +} +export interface UILeaveFullscreenAction { + type: typeof UI_LEAVE_FULLSCREEN; +} +export interface UIContextmenuOpenAction { + type: typeof UI_CONTEXTMENU_OPEN; +} +export interface UICommandExecAction { + type: typeof UI_COMMAND_EXEC; +} + +export type UIActions = + | UIFontSizeSetAction + | UIFontSizeIncrAction + | UIFontSizeDecrAction + | UIFontSizeResetAction + | UIFontSmoothingSetAction + | UIMoveLeftAction + | UIMoveRightAction + | UIMoveToAction + | UIMoveNextPaneAction + | UIMovePrevPaneAction + | UIShowPreferencesAction + | UIWindowMoveAction + | UIWindowMaximizeAction + | UIWindowUnmaximizeAction + | UIWindowGeometryChangedAction + | UIOpenFileAction + | UIOpenSshUrlAction + | UIOpenHamburgerMenuAction + | UIWindowMinimizeAction + | UIWindowCloseAction + | UIEnterFullscreenAction + | UILeaveFullscreenAction + | UIContextmenuOpenAction + | UICommandExecAction; diff --git a/lib/constants/updater.ts b/lib/constants/updater.ts index 624115a9..f769e48b 100644 --- a/lib/constants/updater.ts +++ b/lib/constants/updater.ts @@ -1,2 +1,15 @@ export const UPDATE_INSTALL = 'UPDATE_INSTALL'; export const UPDATE_AVAILABLE = 'UPDATE_AVAILABLE'; + +export interface UpdateInstallAction { + type: typeof UPDATE_INSTALL; +} +export interface UpdateAvailableAction { + type: typeof UPDATE_AVAILABLE; + version: string; + notes: string | null; + releaseUrl: string; + canInstall: boolean; +} + +export type UpdateActions = UpdateInstallAction | UpdateAvailableAction; diff --git a/lib/hyper.d.ts b/lib/hyper.d.ts index 6e0b4046..d6af5f2a 100644 --- a/lib/hyper.d.ts +++ b/lib/hyper.d.ts @@ -155,6 +155,26 @@ export type hyperPlugin = { import rootReducer from './reducers/index'; export type HyperState = ReturnType; +import {UIActions} from './constants/ui'; +import {ConfigActions} from './constants/config'; +import {SessionActions} from './constants/sessions'; +import {NotificationActions} from './constants/notifications'; +import {UpdateActions} from './constants/updater'; +import {TermGroupActions} from './constants/term-groups'; +import {InitActions} from './constants'; +import {TabActions} from './constants/tabs'; + +export type HyperActions = ( + | UIActions + | ConfigActions + | SessionActions + | NotificationActions + | UpdateActions + | TermGroupActions + | InitActions + | TabActions +) & {effect?: () => void}; + type immutableRecord = {[k in keyof T]: Immutable}; export type TermsProps = {