mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-26 01:09:10 +01:00
added mockup users page and login page
This commit is contained in:
36
scm-ui/src/Login.js
Normal file
36
scm-ui/src/Login.js
Normal file
@@ -0,0 +1,36 @@
|
||||
//@flow
|
||||
import React from 'react';
|
||||
import injectSheet from 'react-jss';
|
||||
|
||||
const styles = {
|
||||
wrapper: {
|
||||
width: '100%',
|
||||
display: 'flex',
|
||||
height: '10em'
|
||||
},
|
||||
loading: {
|
||||
margin: 'auto',
|
||||
textAlign: 'center'
|
||||
}
|
||||
};
|
||||
|
||||
type Props = {
|
||||
classes: any;
|
||||
}
|
||||
|
||||
class Login extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
const { classes } = this.props;
|
||||
return (
|
||||
<div className={classes.wrapper}>
|
||||
<div className={classes.loading}>
|
||||
You need to log in! ...
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default injectSheet(styles)(Login);
|
||||
@@ -6,6 +6,7 @@ import classNames from 'classnames';
|
||||
import { Route, withRouter } from 'react-router';
|
||||
|
||||
import Page from './containers/Page';
|
||||
import Users from './containers/Users';
|
||||
import {Switch} from 'react-router-dom';
|
||||
|
||||
const styles = {
|
||||
@@ -25,7 +26,8 @@ class Main extends React.Component<Props> {
|
||||
return (
|
||||
<div className={classNames('container', classes.content)}>
|
||||
<Switch>
|
||||
<Route path="/:repository/:branch" component={Page} />
|
||||
<Route exact path="/" component={Page} />
|
||||
<Route exact path="/users" component={Users} />
|
||||
</Switch>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,3 +1,63 @@
|
||||
/**
|
||||
* Created by masuewer on 02.07.18.
|
||||
*/
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { fetchRepositoriesIfNeeded } from '../modules/page';
|
||||
import Login from '../Login';
|
||||
|
||||
|
||||
type Props = {
|
||||
loading: boolean,
|
||||
error: any,
|
||||
repositories: any,
|
||||
fetchRepositoriesIfNeeded: () => void
|
||||
}
|
||||
|
||||
class Page extends React.Component<Props> {
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchRepositoriesIfNeeded();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { loading, error, repositories } = this.props;
|
||||
|
||||
|
||||
if(loading) {
|
||||
return (
|
||||
<div>
|
||||
<h1>SCM</h1>
|
||||
<Login/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
else if(!loading){
|
||||
return (
|
||||
<div>
|
||||
<h1>SCM</h1>
|
||||
<h2>Startpage</h2>
|
||||
<a href={"/users" }>
|
||||
Users hier!
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return null;
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
fetchRepositoriesIfNeeded: () => {
|
||||
dispatch(fetchRepositoriesIfNeeded())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Page);
|
||||
|
||||
58
scm-ui/src/containers/Users.js
Normal file
58
scm-ui/src/containers/Users.js
Normal file
@@ -0,0 +1,58 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { fetchRepositoriesIfNeeded } from '../modules/users';
|
||||
import Login from '../Login';
|
||||
|
||||
type Props = {
|
||||
loading: boolean,
|
||||
error: any,
|
||||
repositories: any,
|
||||
fetchRepositoriesIfNeeded: () => void
|
||||
}
|
||||
|
||||
class Users extends React.Component<Props> {
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchRepositoriesIfNeeded();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { loading, error, repositories } = this.props;
|
||||
|
||||
|
||||
|
||||
if(loading) {
|
||||
return (
|
||||
<div>
|
||||
<h1>SCM</h1>
|
||||
<Login/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
else if(!loading){
|
||||
return (
|
||||
<div>
|
||||
<h1>SCM</h1>
|
||||
<h2>Users</h2>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return null;
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
fetchRepositoriesIfNeeded: () => {
|
||||
dispatch(fetchRepositoriesIfNeeded())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Users);
|
||||
@@ -4,13 +4,15 @@ import { createStore, compose, applyMiddleware, combineReducers } from 'redux';
|
||||
import { routerReducer, routerMiddleware } from 'react-router-redux';
|
||||
|
||||
import page from './modules/page';
|
||||
import users from './modules/users';
|
||||
|
||||
function createReduxStore(history) {
|
||||
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
||||
|
||||
const reducer = combineReducers({
|
||||
router: routerReducer,
|
||||
page
|
||||
page,
|
||||
users
|
||||
});
|
||||
|
||||
return createStore(
|
||||
|
||||
@@ -1,3 +1,61 @@
|
||||
/**
|
||||
* Created by masuewer on 02.07.18.
|
||||
*/
|
||||
//@flow
|
||||
const FETCH_REPOSITORIES = 'smeagol/repositories/FETCH';
|
||||
const FETCH_REPOSITORIES_SUCCESS = 'smeagol/repositories/FETCH_SUCCESS';
|
||||
const FETCH_REPOSITORIES_FAILURE = 'smeagol/repositories/FETCH_FAILURE';
|
||||
|
||||
const THRESHOLD_TIMESTAMP = 10000;
|
||||
|
||||
function requestRepositories() {
|
||||
return {
|
||||
type: FETCH_REPOSITORIES
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function fetchRepositories() {
|
||||
return function(dispatch) {
|
||||
dispatch(requestRepositories());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function shouldFetchRepositories(state: any): boolean {
|
||||
const repositories = state.repositories;
|
||||
return null;
|
||||
}
|
||||
|
||||
export function fetchRepositoriesIfNeeded() {
|
||||
return (dispatch, getState) => {
|
||||
if (shouldFetchRepositories(getState())) {
|
||||
dispatch(fetchRepositories());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default function reducer(state = {}, action = {}) {
|
||||
switch (action.type) {
|
||||
case FETCH_REPOSITORIES:
|
||||
return {
|
||||
...state,
|
||||
loading: true,
|
||||
error: null
|
||||
};
|
||||
case FETCH_REPOSITORIES_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
loading: true,
|
||||
timestamp: action.timestamp,
|
||||
error: null,
|
||||
repositories: action.payload
|
||||
};
|
||||
case FETCH_REPOSITORIES_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
loading: true,
|
||||
error: action.payload
|
||||
};
|
||||
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
61
scm-ui/src/modules/users.js
Normal file
61
scm-ui/src/modules/users.js
Normal file
@@ -0,0 +1,61 @@
|
||||
//@flow
|
||||
const FETCH_REPOSITORIES = 'smeagol/repositories/FETCH';
|
||||
const FETCH_REPOSITORIES_SUCCESS = 'smeagol/repositories/FETCH_SUCCESS';
|
||||
const FETCH_REPOSITORIES_FAILURE = 'smeagol/repositories/FETCH_FAILURE';
|
||||
|
||||
const THRESHOLD_TIMESTAMP = 10000;
|
||||
|
||||
function requestRepositories() {
|
||||
return {
|
||||
type: FETCH_REPOSITORIES
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function fetchRepositories() {
|
||||
return function(dispatch) {
|
||||
dispatch(requestRepositories());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function shouldFetchRepositories(state: any): boolean {
|
||||
const repositories = state.repositories;
|
||||
return null;
|
||||
}
|
||||
|
||||
export function fetchRepositoriesIfNeeded() {
|
||||
return (dispatch, getState) => {
|
||||
if (shouldFetchRepositories(getState())) {
|
||||
dispatch(fetchRepositories());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default function reducer(state = {}, action = {}) {
|
||||
switch (action.type) {
|
||||
case FETCH_REPOSITORIES:
|
||||
return {
|
||||
...state,
|
||||
loading: true,
|
||||
error: null
|
||||
};
|
||||
case FETCH_REPOSITORIES_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
loading: false,
|
||||
timestamp: action.timestamp,
|
||||
error: null,
|
||||
repositories: action.payload
|
||||
};
|
||||
case FETCH_REPOSITORIES_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
loading: false,
|
||||
error: action.payload
|
||||
};
|
||||
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user