mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 17:55:17 -04:00
parent
557386f78f
commit
e2155e735d
65 changed files with 834 additions and 467 deletions
|
@ -1,7 +1,7 @@
|
|||
import { BackendConfigState, SET_BACKEND_CONFIG_ACTION_TYPE, SetBackendConfigAction } from './types'
|
||||
import { store } from '../../utils/store'
|
||||
|
||||
export const setBackendConfig: (state: BackendConfigState) => void = (state: BackendConfigState) => {
|
||||
export const setBackendConfig = (state: BackendConfigState): void => {
|
||||
const action: SetBackendConfigAction = {
|
||||
type: SET_BACKEND_CONFIG_ACTION_TYPE,
|
||||
payload: {
|
||||
|
|
14
src/redux/editor/methods.ts
Normal file
14
src/redux/editor/methods.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import {
|
||||
EditorMode,
|
||||
SET_EDITOR_CONFIG_MODE_ACTION_TYPE,
|
||||
SetEditorConfigAction
|
||||
} from './types'
|
||||
import { store } from '../../utils/store'
|
||||
|
||||
export const setEditorModeConfig = (editorMode: EditorMode): void => {
|
||||
const action: SetEditorConfigAction = {
|
||||
type: SET_EDITOR_CONFIG_MODE_ACTION_TYPE,
|
||||
payload: editorMode
|
||||
}
|
||||
store.dispatch(action)
|
||||
}
|
23
src/redux/editor/reducers.ts
Normal file
23
src/redux/editor/reducers.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { Reducer } from 'redux'
|
||||
import {
|
||||
EditorConfigActions,
|
||||
EditorConfigState,
|
||||
EditorMode,
|
||||
SET_EDITOR_CONFIG_MODE_ACTION_TYPE
|
||||
} from './types'
|
||||
|
||||
export const initialState: EditorConfigState = {
|
||||
editorMode: EditorMode.PREVIEW
|
||||
}
|
||||
|
||||
export const EditorConfigReducer: Reducer<EditorConfigState, EditorConfigActions> = (state: EditorConfigState = initialState, action: EditorConfigActions) => {
|
||||
switch (action.type) {
|
||||
case SET_EDITOR_CONFIG_MODE_ACTION_TYPE:
|
||||
return {
|
||||
...state,
|
||||
editorMode: action.payload
|
||||
}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
20
src/redux/editor/types.ts
Normal file
20
src/redux/editor/types.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { Action } from 'redux'
|
||||
|
||||
export const SET_EDITOR_CONFIG_MODE_ACTION_TYPE = 'editor/mode/set'
|
||||
|
||||
export interface EditorConfigState {
|
||||
editorMode: EditorMode;
|
||||
}
|
||||
|
||||
export enum EditorMode {
|
||||
PREVIEW,
|
||||
BOTH,
|
||||
EDITOR,
|
||||
}
|
||||
|
||||
export interface SetEditorConfigAction extends Action {
|
||||
type: string;
|
||||
payload: EditorMode;
|
||||
}
|
||||
|
||||
export type EditorConfigActions = SetEditorConfigAction;
|
|
@ -1,7 +1,7 @@
|
|||
import { FrontendConfigState, SET_FRONTEND_CONFIG_ACTION_TYPE, SetFrontendConfigAction } from './types'
|
||||
import { store } from '../../utils/store'
|
||||
|
||||
export const setFrontendConfig: (state: FrontendConfigState) => void = (state: FrontendConfigState) => {
|
||||
export const setFrontendConfig = (state: FrontendConfigState): void => {
|
||||
const action: SetFrontendConfigAction = {
|
||||
type: SET_FRONTEND_CONFIG_ACTION_TYPE,
|
||||
payload: {
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
import { combineReducers, Reducer } from 'redux'
|
||||
import { UserState } from './user/types'
|
||||
import { UserReducer } from './user/reducers'
|
||||
import { ModalShowReducer } from './modal/reducers'
|
||||
import { ModalShowState } from './modal/types'
|
||||
import { BackendConfigState } from './backend-config/types'
|
||||
import { FrontendConfigState } from './frontend-config/types'
|
||||
import { BackendConfigReducer } from './backend-config/reducers'
|
||||
import { FrontendConfigReducer } from './frontend-config/reducers'
|
||||
import { EditorConfigState } from './editor/types'
|
||||
import { EditorConfigReducer } from './editor/reducers'
|
||||
|
||||
export interface ApplicationState {
|
||||
user: UserState;
|
||||
modalShow: ModalShowState;
|
||||
backendConfig: BackendConfigState;
|
||||
frontendConfig: FrontendConfigState;
|
||||
editorConfig: EditorConfigState;
|
||||
}
|
||||
|
||||
export const allReducers: Reducer<ApplicationState> = combineReducers<ApplicationState>({
|
||||
user: UserReducer,
|
||||
modalShow: ModalShowReducer,
|
||||
backendConfig: BackendConfigReducer,
|
||||
frontendConfig: FrontendConfigReducer
|
||||
frontendConfig: FrontendConfigReducer,
|
||||
editorConfig: EditorConfigReducer
|
||||
})
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
import { ActionCreator } from 'redux'
|
||||
import { SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE, SetHistoryDeleteModalShowAction } from './types'
|
||||
|
||||
export const setSignInModalShow: ActionCreator<SetHistoryDeleteModalShowAction> = (historyDelete: boolean) => ({
|
||||
type: SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE,
|
||||
payload: historyDelete
|
||||
})
|
|
@ -1,18 +0,0 @@
|
|||
import { Reducer } from 'redux'
|
||||
import { ModalShowActions, ModalShowState, SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE } from './types'
|
||||
|
||||
export const initialState: ModalShowState = {
|
||||
historyDelete: false
|
||||
}
|
||||
|
||||
export const ModalShowReducer: Reducer<ModalShowState, ModalShowActions> = (state: ModalShowState = initialState, action: ModalShowActions) => {
|
||||
switch (action.type) {
|
||||
case SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE:
|
||||
return {
|
||||
...state,
|
||||
historyDelete: action.payload
|
||||
}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
import { Action } from 'redux'
|
||||
|
||||
export const SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE = 'modal/history-delete/set'
|
||||
|
||||
export interface ModalShowState {
|
||||
historyDelete: boolean
|
||||
}
|
||||
|
||||
export interface SetHistoryDeleteModalShowAction extends Action {
|
||||
type: string;
|
||||
payload: boolean;
|
||||
}
|
||||
|
||||
export type ModalShowActions = SetHistoryDeleteModalShowAction;
|
Loading…
Add table
Add a link
Reference in a new issue