mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 18:51:10 +01:00
refactoring/renaming
This commit is contained in:
@@ -5,7 +5,7 @@ import classNames from 'classnames';
|
||||
|
||||
import { Route, withRouter } from 'react-router';
|
||||
|
||||
import Page from './containers/Page';
|
||||
import Repositories from './containers/Repositories';
|
||||
import Users from './containers/Users';
|
||||
import {Switch} from 'react-router-dom';
|
||||
|
||||
@@ -26,7 +26,7 @@ class Main extends React.Component<Props> {
|
||||
return (
|
||||
<div className={classNames('container', classes.content)}>
|
||||
<Switch>
|
||||
<Route exact path="/" component={Page} />
|
||||
<Route exact path="/" component={Repositories} />
|
||||
<Route exact path="/users" component={Users} />
|
||||
</Switch>
|
||||
</div>
|
||||
|
||||
@@ -2,18 +2,16 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { fetchRepositoriesIfNeeded } from '../modules/page';
|
||||
import { fetchRepositoriesIfNeeded } from '../modules/repositories';
|
||||
import Login from '../Login';
|
||||
|
||||
|
||||
type Props = {
|
||||
login: boolean,
|
||||
error: any,
|
||||
repositories: any,
|
||||
fetchRepositoriesIfNeeded: () => void
|
||||
}
|
||||
|
||||
class Page extends React.Component<Props> {
|
||||
class Repositories extends React.Component<Props> {
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchRepositoriesIfNeeded();
|
||||
@@ -60,4 +58,4 @@ const mapDispatchToProps = (dispatch) => {
|
||||
}
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Page);
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Repositories);
|
||||
@@ -2,24 +2,24 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { fetchRepositoriesIfNeeded } from '../modules/users';
|
||||
import { fetchUsersIfNeeded } from '../modules/users';
|
||||
import Login from '../Login';
|
||||
|
||||
type Props = {
|
||||
login: boolean,
|
||||
error: any,
|
||||
repositories: any,
|
||||
fetchRepositoriesIfNeeded: () => void
|
||||
users: any,
|
||||
fetchUsersIfNeeded: () => void
|
||||
}
|
||||
|
||||
class Users extends React.Component<Props> {
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchRepositoriesIfNeeded();
|
||||
this.props.fetchUsersIfNeeded();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { login, error, repositories } = this.props;
|
||||
const { login, error, users } = this.props;
|
||||
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ const mapStateToProps = (state) => {
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
fetchRepositoriesIfNeeded: () => {
|
||||
dispatch(fetchRepositoriesIfNeeded())
|
||||
fetchUsersIfNeeded: () => {
|
||||
dispatch(fetchUsersIfNeeded())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import logger from 'redux-logger';
|
||||
import { createStore, compose, applyMiddleware, combineReducers } from 'redux';
|
||||
import { routerReducer, routerMiddleware } from 'react-router-redux';
|
||||
|
||||
import page from './modules/page';
|
||||
import repositories from './modules/repositories';
|
||||
import users from './modules/users';
|
||||
|
||||
function createReduxStore(history) {
|
||||
@@ -11,7 +11,7 @@ function createReduxStore(history) {
|
||||
|
||||
const reducer = combineReducers({
|
||||
router: routerReducer,
|
||||
page,
|
||||
repositories,
|
||||
users
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
//@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;
|
||||
const FETCH_REPOSITORIES = 'scm/repositories/FETCH';
|
||||
const FETCH_REPOSITORIES_SUCCESS = 'scm/repositories/FETCH_SUCCESS';
|
||||
const FETCH_REPOSITORIES_FAILURE = 'scm/repositories/FETCH_FAILURE';
|
||||
|
||||
function requestRepositories() {
|
||||
return {
|
||||
@@ -1,54 +1,54 @@
|
||||
//@flow
|
||||
const FETCH_REPOSITORIES = 'smeagol/repositories/FETCH';
|
||||
const FETCH_REPOSITORIES_SUCCESS = 'smeagol/repositories/FETCH_SUCCESS';
|
||||
const FETCH_REPOSITORIES_FAILURE = 'smeagol/repositories/FETCH_FAILURE';
|
||||
const FETCH_USERS = 'scm/users/FETCH';
|
||||
const FETCH_USERS_SUCCESS= 'scm/users/FETCH_SUCCESS';
|
||||
const FETCH_USERS_FAILURE = 'scm/users/FETCH_FAILURE';
|
||||
|
||||
const THRESHOLD_TIMESTAMP = 10000;
|
||||
|
||||
function requestRepositories() {
|
||||
function requestUsers() {
|
||||
return {
|
||||
type: FETCH_REPOSITORIES
|
||||
type: FETCH_USERS
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function fetchRepositories() {
|
||||
function fetchUsers() {
|
||||
return function(dispatch) {
|
||||
dispatch(requestRepositories());
|
||||
dispatch(requestUsers());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function shouldFetchRepositories(state: any): boolean {
|
||||
const repositories = state.repositories;
|
||||
export function shouldFetchUsers(state: any): boolean {
|
||||
const users = state.users;
|
||||
return null;
|
||||
}
|
||||
|
||||
export function fetchRepositoriesIfNeeded() {
|
||||
export function fetchUsersIfNeeded() {
|
||||
return (dispatch, getState) => {
|
||||
if (shouldFetchRepositories(getState())) {
|
||||
dispatch(fetchRepositories());
|
||||
if (shouldFetchUsers(getState())) {
|
||||
dispatch(fetchUsers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default function reducer(state = {}, action = {}) {
|
||||
switch (action.type) {
|
||||
case FETCH_REPOSITORIES:
|
||||
case FETCH_USERS:
|
||||
return {
|
||||
...state,
|
||||
login: true,
|
||||
error: null
|
||||
};
|
||||
case FETCH_REPOSITORIES_SUCCESS:
|
||||
case FETCH_USERS_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
login: false,
|
||||
timestamp: action.timestamp,
|
||||
error: null,
|
||||
repositories: action.payload
|
||||
users: action.payload
|
||||
};
|
||||
case FETCH_REPOSITORIES_FAILURE:
|
||||
case FETCH_USERS_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
login: false,
|
||||
|
||||
Reference in New Issue
Block a user