Add feature user-admin
Change-Id: Idcdc718ee502fd803a96409e67109cdac5b8b806
This commit is contained in:
parent
deefc950f9
commit
07bc32c05d
@ -2,6 +2,7 @@ import { combineReducers } from 'redux';
|
|||||||
import { routerReducer } from 'react-router-redux';
|
import { routerReducer } from 'react-router-redux';
|
||||||
import homeReducer from '../features/home/redux/reducer';
|
import homeReducer from '../features/home/redux/reducer';
|
||||||
import commonReducer from '../features/common/redux/reducer';
|
import commonReducer from '../features/common/redux/reducer';
|
||||||
|
import userAdminReducer from '../features/user-admin/redux/reducer';
|
||||||
|
|
||||||
// NOTE 1: DO NOT CHANGE the 'reducerMap' name and the declaration pattern.
|
// NOTE 1: DO NOT CHANGE the 'reducerMap' name and the declaration pattern.
|
||||||
// This is used for Rekit cmds to register new features, remove features, etc.
|
// This is used for Rekit cmds to register new features, remove features, etc.
|
||||||
@ -12,6 +13,7 @@ const reducerMap = {
|
|||||||
router: routerReducer,
|
router: routerReducer,
|
||||||
home: homeReducer,
|
home: homeReducer,
|
||||||
common: commonReducer,
|
common: commonReducer,
|
||||||
|
userAdmin: userAdminReducer,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default combineReducers(reducerMap);
|
export default combineReducers(reducerMap);
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
import { App } from '../features/home';
|
import { App } from '../features/home';
|
||||||
import { PageNotFound } from '../features/common';
|
import { PageNotFound } from '../features/common';
|
||||||
import homeRoute from '../features/home/route';
|
|
||||||
import commonRoute from '../features/common/route';
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import commonRoute from '../features/common/route';
|
||||||
|
import homeRoute from '../features/home/route';
|
||||||
|
import userAdminRoute from '../features/user-admin/route';
|
||||||
|
|
||||||
// NOTE: DO NOT CHANGE the 'childRoutes' name and the declaration pattern.
|
// NOTE: DO NOT CHANGE the 'childRoutes' name and the declaration pattern.
|
||||||
// This is used for Rekit cmds to register routes config for new features, and remove config when remove features, etc.
|
// This is used for Rekit cmds to register routes config for new features, and remove config when remove features, etc.
|
||||||
const childRoutes = [
|
const childRoutes = [
|
||||||
homeRoute,
|
homeRoute,
|
||||||
commonRoute,
|
commonRoute,
|
||||||
|
userAdminRoute,
|
||||||
];
|
];
|
||||||
|
|
||||||
const routes = [{
|
const routes = [{
|
||||||
|
39
src/features/user-admin/DefaultPage.js
Normal file
39
src/features/user-admin/DefaultPage.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { bindActionCreators } from 'redux';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import * as actions from './redux/actions';
|
||||||
|
|
||||||
|
export class DefaultPage extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
userAdmin: PropTypes.object.isRequired,
|
||||||
|
actions: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div className="user-admin-default-page">
|
||||||
|
Page Content: user-admin/DefaultPage
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
function mapStateToProps(state) {
|
||||||
|
return {
|
||||||
|
userAdmin: state.userAdmin,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
function mapDispatchToProps(dispatch) {
|
||||||
|
return {
|
||||||
|
actions: bindActionCreators({ ...actions }, dispatch)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(DefaultPage);
|
5
src/features/user-admin/DefaultPage.scss
Normal file
5
src/features/user-admin/DefaultPage.scss
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
@import '../../styles/mixins';
|
||||||
|
|
||||||
|
.user-admin-default-page {
|
||||||
|
|
||||||
|
}
|
1
src/features/user-admin/index.js
Normal file
1
src/features/user-admin/index.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default as DefaultPage } from './DefaultPage';
|
0
src/features/user-admin/redux/actions.js
Normal file
0
src/features/user-admin/redux/actions.js
Normal file
0
src/features/user-admin/redux/constants.js
Normal file
0
src/features/user-admin/redux/constants.js
Normal file
11
src/features/user-admin/redux/initialState.js
Normal file
11
src/features/user-admin/redux/initialState.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Initial state is the place you define all initial values for the Redux store of the feature.
|
||||||
|
// In the 'standard' way, initialState is defined in reducers: http://redux.js.org/docs/basics/Reducers.html
|
||||||
|
// But when application grows, there will be multiple reducers files, it's not intuitive what data is managed by the whole store.
|
||||||
|
// So Rekit extracts the initial state definition into a separate module so that you can have
|
||||||
|
// a quick view about what data is used for the feature, at any time.
|
||||||
|
|
||||||
|
// NOTE: initialState constant is necessary so that Rekit could auto add initial state when creating async actions.
|
||||||
|
const initialState = {
|
||||||
|
};
|
||||||
|
|
||||||
|
export default initialState;
|
23
src/features/user-admin/redux/reducer.js
Normal file
23
src/features/user-admin/redux/reducer.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// This is the root reducer of the feature. It is used for:
|
||||||
|
// 1. Load reducers from each action in the feature and process them one by one.
|
||||||
|
// Note that this part of code is mainly maintained by Rekit, you usually don't need to edit them.
|
||||||
|
// 2. Write cross-topic reducers. If a reducer is not bound to some specific action.
|
||||||
|
// Then it could be written here.
|
||||||
|
// Learn more from the introduction of this approach:
|
||||||
|
// https://medium.com/@nate_wang/a-new-approach-for-managing-redux-actions-91c26ce8b5da.
|
||||||
|
|
||||||
|
import initialState from './initialState';
|
||||||
|
|
||||||
|
const reducers = [
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function reducer(state = initialState, action) {
|
||||||
|
let newState;
|
||||||
|
switch (action.type) {
|
||||||
|
// Handle cross-topic actions here
|
||||||
|
default:
|
||||||
|
newState = state;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return reducers.reduce((s, r) => r(s, action), newState);
|
||||||
|
}
|
14
src/features/user-admin/route.js
Normal file
14
src/features/user-admin/route.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// This is the JSON way to define React Router rules in a Rekit app.
|
||||||
|
// Learn more from: http://rekit.js.org/docs/routing.html
|
||||||
|
|
||||||
|
import {
|
||||||
|
DefaultPage,
|
||||||
|
} from './';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
path: 'user-admin',
|
||||||
|
name: 'User admin',
|
||||||
|
childRoutes: [
|
||||||
|
{ path: 'default-page', name: 'Default page', component: DefaultPage, isIndex: true },
|
||||||
|
],
|
||||||
|
};
|
2
src/features/user-admin/style.scss
Normal file
2
src/features/user-admin/style.scss
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@import '../../styles/mixins';
|
||||||
|
@import './DefaultPage';
|
@ -2,3 +2,4 @@
|
|||||||
@import './global';
|
@import './global';
|
||||||
@import '../features/home/style';
|
@import '../features/home/style';
|
||||||
@import '../features/common/style';
|
@import '../features/common/style';
|
||||||
|
@import '../features/user-admin/style';
|
||||||
|
19
tests/features/user-admin/DefaultPage.test.js
Normal file
19
tests/features/user-admin/DefaultPage.test.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { shallow } from 'enzyme';
|
||||||
|
import { DefaultPage } from '../../../src/features/user-admin/DefaultPage';
|
||||||
|
|
||||||
|
describe('user-admin/DefaultPage', () => {
|
||||||
|
it('renders node with correct class name', () => {
|
||||||
|
const props = {
|
||||||
|
userAdmin: {},
|
||||||
|
actions: {},
|
||||||
|
};
|
||||||
|
const renderedComponent = shallow(
|
||||||
|
<DefaultPage {...props} />
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
renderedComponent.find('.user-admin-default-page').length
|
||||||
|
).toBe(1);
|
||||||
|
});
|
||||||
|
});
|
14
tests/features/user-admin/redux/reducer.test.js
Normal file
14
tests/features/user-admin/redux/reducer.test.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import reducer from '../../../../src/features/user-admin/redux/reducer';
|
||||||
|
|
||||||
|
describe('user-admin/redux/reducer', () => {
|
||||||
|
it('does nothing if no matched action', () => {
|
||||||
|
const prevState = {};
|
||||||
|
const state = reducer(
|
||||||
|
prevState,
|
||||||
|
{ type: '__UNKNOWN_ACTION_TYPE__' }
|
||||||
|
);
|
||||||
|
expect(state).toBe(prevState);
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: add global reducer test if needed.
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user