imported current state of the mockup into the public repo

Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
Philip Molares 2020-05-14 15:41:38 +02:00
commit 93ce059577
161 changed files with 17419 additions and 0 deletions

View file

@ -0,0 +1,20 @@
import {Action, ActionCreator} from 'redux';
import {ApplicationConfigState} from "./types";
export const SET_APPLICATION_CONFIG_ACTION_TYPE = 'config/set';
export interface SetApplicationConfigAction extends Action {
type: string;
payload: {
state: ApplicationConfigState;
};
}
export const setApplicationConfig: ActionCreator<SetApplicationConfigAction> = (state: ApplicationConfigState) => ({
type: SET_APPLICATION_CONFIG_ACTION_TYPE,
payload: {
state
},
})
export type ApplicationConfigActions = SetApplicationConfigAction;

View file

@ -0,0 +1,33 @@
import {Reducer} from 'redux';
import {ApplicationConfigState} from './types';
import {ApplicationConfigActions, SET_APPLICATION_CONFIG_ACTION_TYPE} from "./actions";
export const initialState: ApplicationConfigState = {
allowAnonymous: true,
authProviders: {
facebook: true,
github: false,
twitter: false,
gitlab: false,
dropbox: false,
ldap: false,
google: false,
saml: false,
oauth2: false,
email: false
},
specialLinks: {
privacy: "",
termsOfUse: "",
imprint: "",
}
};
export const ApplicationConfigReducer: Reducer<ApplicationConfigState, ApplicationConfigActions> = (state: ApplicationConfigState = initialState, action: ApplicationConfigActions) => {
switch (action.type) {
case SET_APPLICATION_CONFIG_ACTION_TYPE:
return action.payload.state;
default:
return state;
}
};

View file

@ -0,0 +1,25 @@
export interface ApplicationConfigState {
allowAnonymous: boolean,
authProviders: AuthProvidersState,
specialLinks: SpecialLinks,
}
export interface AuthProvidersState {
facebook: true,
github: false,
twitter: false,
gitlab: false,
dropbox: false,
ldap: false,
google: false,
saml: false,
oauth2: false,
email: false,
}
export interface SpecialLinks {
privacy: string,
termsOfUse: string,
imprint: string,
}

View file

@ -0,0 +1,13 @@
import {createStore} from 'redux';
import {allReducers} from '../index';
import {Provider} from "react-redux";
import React, {ReactNode} from "react";
interface JustChildrenProps {
children: ReactNode;
}
export const ApplicationStateStoreProvider: React.FC<JustChildrenProps> = (props: JustChildrenProps) => {
const store = createStore(allReducers);
return <Provider store={store}>{props.children}</Provider>;
}

19
src/redux/index.ts Normal file
View file

@ -0,0 +1,19 @@
import {combineReducers, Reducer} from 'redux';
import {UserState} from "./user/types";
import {UserReducer} from "./user/reducers";
import {ApplicationConfigReducer} from "./application-config/reducers";
import {ApplicationConfigState} from "./application-config/types";
import {ModalShowReducer} from "./modal/reducers";
import {ModalShowState} from "./modal/types";
export interface ApplicationState {
user: UserState;
modalShow: ModalShowState;
applicationConfig: ApplicationConfigState;
}
export const allReducers: Reducer<ApplicationState> = combineReducers<ApplicationState>({
user: UserReducer,
modalShow: ModalShowReducer,
applicationConfig: ApplicationConfigReducer
});

View file

@ -0,0 +1,15 @@
import {Action, ActionCreator} from 'redux';
export const SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE = 'modal/history-delete/set';
export interface SetHistoryDeleteModalShowAction extends Action {
type: string;
payload: boolean;
}
export const setSignInModalShow: ActionCreator<SetHistoryDeleteModalShowAction> = (historyDelete: boolean) => ({
type: SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE,
payload: historyDelete,
})
export type ModalShowActions = SetHistoryDeleteModalShowAction;

View file

@ -0,0 +1,19 @@
import {Reducer} from 'redux';
import {ModalShowState} from './types';
import {ModalShowActions, SET_HISTORY_DELETE_MODAL_SHOW_ACTION_TYPE} from "./actions";
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;
}
};

3
src/redux/modal/types.ts Normal file
View file

@ -0,0 +1,3 @@
export interface ModalShowState {
historyDelete: boolean
}

32
src/redux/user/actions.ts Normal file
View file

@ -0,0 +1,32 @@
import {Action, ActionCreator} from 'redux';
import {UserState} from "./types";
export const SET_USER_ACTION_TYPE = 'user/set';
export const CLEAR_USER_ACTION_TYPE = 'user/clear';
export interface SetUserAction extends Action {
type: string;
payload: {
state: UserState,
};
}
export interface ClearUserAction extends Action {
type: string;
payload: {};
}
export const setUser: ActionCreator<SetUserAction> = (state: UserState) => ({
type: SET_USER_ACTION_TYPE,
payload: {
state
},
})
export const clearUser: ActionCreator<ClearUserAction> = () => ({
type: CLEAR_USER_ACTION_TYPE,
payload: {},
})
export type UserActions = SetUserAction | ClearUserAction;

View file

@ -0,0 +1,21 @@
import {Reducer} from 'redux';
import {LoginStatus, UserState} from './types';
import {CLEAR_USER_ACTION_TYPE, SET_USER_ACTION_TYPE, SetUserAction, UserActions} from "./actions";
export const initialState: UserState = {
id: "",
name: "",
photo: "",
status: LoginStatus.forbidden
};
export const UserReducer: Reducer<UserState, UserActions> = (state: UserState = initialState, action: UserActions) => {
switch (action.type) {
case SET_USER_ACTION_TYPE:
return (action as SetUserAction).payload.state;
case CLEAR_USER_ACTION_TYPE:
return initialState;
default:
return state;
}
};

11
src/redux/user/types.ts Normal file
View file

@ -0,0 +1,11 @@
export interface UserState {
status: LoginStatus;
id: string;
name: string;
photo: string;
}
export enum LoginStatus {
forbidden = "forbidden",
ok = "ok"
}