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