Skip to content

Commit

Permalink
Release/0.7.1 (#93)
Browse files Browse the repository at this point in the history
* Support for angular-ui-router 1.0.0-beta.1 (#64)

* Support to ui-router 1.0.0-beta.1
- onStateNotFound action was removed
- evt parameter was removed from onStateChangeStart and onStateChangeError
- example using redux-devtools

* The router listener was simplified

* fixed incorrect params being passed in router middleware on  STATE_CHANGE_SUCCESS

* fix #66 missing parameters passed on transition onStart. Add tests for router-listener (#67)

* Fixed the prev state and params in the redux router state getting set… (#68)

* Fixed the prev state and params in the redux router state getting set to the current state and params by changing the way that the STATE_CHANGE_SUCCESS handler in the middleware accesses the previous state and params.

* added options to the state change start action payload for middle wares etc.

* Add `href` property to the router state object (#51)

* Add `href` property to the router state object

Adding `href` to the router state object gives access to the
`$state.href` function in React code. This allows the creation
of urls for states, which is critical when a component links to
another part of the app and should be crawlable by a crawler.

* Update licenser test

Include `href` payload key in tests

* Fix tests and lint (#70)

* Fix tests for `onStart` and `onError`

Adds a stub for the new options param added in commit
994b8d0

* Fix lint error

* Restrict to node v6 and higher (#75)

* Added MIT license (#79)

* Added stateChangeFinish action to ensure state changes are set in the… (#80)

* Added stateChangeFinish action to ensure state changes are set in the app state before components are instantiated

* added and fixed tests

* updated ui-router to 1.0-beta.3

* missing test

* fixed test

* upgraded ui-router to 1.0.0-rc1 and fixed node engine bug

* upgraded ui-router to 1.0.0-rc1 and fixed node engine bug

* 0.7.0-rc.1

* Expose state activation actions as injectable factory (#81)

* Expose state activation actions as a factory

* Integrate default state activation actions

wrap state activation actions into factory

* Create state-activation-actions.test.js

* Update function name

* added the state activation actions as injectable factory

* 0.7.1-rc.1

* Fixed up example

* bumped patch release

* Upgraded to new ui-router package name
  • Loading branch information
hally9k authored Jun 4, 2017
1 parent 06b9431 commit a56da69
Show file tree
Hide file tree
Showing 30 changed files with 1,680 additions and 991 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["es2015"]
"presets": ["es2015", "stage-0"]
}
35 changes: 35 additions & 0 deletions example/devTools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createDevTools} from 'redux-devtools';
import { render } from 'react-dom';
import LogMonitor from 'redux-devtools-log-monitor';
import DockMonitor from 'redux-devtools-dock-monitor';
import SliderMonitor from 'redux-slider-monitor';
import React from 'react'
import { Provider } from 'react-redux';

const DevTools = createDevTools(
<DockMonitor toggleVisibilityKey='ctrl-h'
changePositionKey='ctrl-q'
changeMonitorKey='ctrl-m'>
<LogMonitor theme='tomorrow' />
<SliderMonitor keyboardEnabled />
</DockMonitor>
);

export function runDevTools($ngRedux, $rootScope) {
render(
<Provider store={$ngRedux}>
<div>
<DevTools />
</div>
</Provider>,
document.getElementById('devTools')
);

//Hack to reflect state changes when disabling/enabling actions via the monitor
$ngRedux.subscribe(_ => {
setTimeout($rootScope.$apply.bind($rootScope), 100);
});
}

export default DevTools;

1 change: 1 addition & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</head>
<body>
<main ui-view="main"></main>
<div id="devTools"></div>
</body>
<script src="/static/bundle.js"></script>
</html>
115 changes: 57 additions & 58 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
import angular from 'angular';
import uiRouter from 'angular-ui-router';
import uiRouter from '@uirouter/angularjs';

import ngRedux from 'ng-redux';
import {combineReducers} from 'redux';
import { combineReducers } from 'redux';
import thunk from 'redux-thunk';
import createLogger from 'redux-logger';
import { default as DevTools, runDevTools } from './devTools';

import ngReduxRouter from '../src';

import {
router,
stateGo,
stateReload,
stateTransitionTo
}
from '../src';
import { router, stateGo, stateReload, stateTransitionTo } from '../src';

const routerActions = {
stateGo,
stateReload,
stateTransitionTo
stateTransitionTo,
};

export default angular
.module('demoApp', [
uiRouter,
ngRedux,
ngReduxRouter
])
.module('demoApp', [uiRouter, ngRedux, ngReduxRouter])
.config(($urlRouterProvider, $stateProvider) => {
$urlRouterProvider.otherwise('/app');

Expand Down Expand Up @@ -60,21 +51,24 @@ export default angular

$ngRedux.connect(state => {
return {
globalState: state
globalState: state,
};
})($scope)
}
}
}
})($scope);
},
},
},
})
.state('app.child1', {
url: '/child1?hello?optional',
views: {
child: {
controller: ($scope, $ngRedux) => {
let disconnect = $ngRedux.connect((state) => state, routerActions)($scope);
const disconnect = $ngRedux.connect(
state => state,
routerActions
)($scope);

$scope.$on('$destroy', disconnect)
$scope.$on('$destroy', disconnect);
},
template: `
<div class="child-view">
Expand All @@ -83,18 +77,21 @@ export default angular
<button ng-click="stateTransitionTo('app.child2')">stateTransitionTo View 2</button>
<button ng-click="stateTransitionTo('app.child3', {id: '4'})">stateTransitionTo View 3, ID: 4</button>
</div>
`
}
}
`,
},
},
})
.state('app.child2', {
url: '/child2',
views: {
child: {
controller: ($scope, $ngRedux) => {
let disconnect = $ngRedux.connect((state) => state, routerActions)($scope);
const disconnect = $ngRedux.connect(
state => state,
routerActions
)($scope);

$scope.$on('$destroy', disconnect)
$scope.$on('$destroy', disconnect);
},
template: `
<div class="child-view">
Expand All @@ -103,22 +100,25 @@ export default angular
<button ng-click="stateReload('app.child1')">$state.reload</button>
<button ng-click="stateGo('app.child1',{hello: 'world', optional: true})">$state.go to View 1 with Params</button>
</div>
`
}
}
`,
},
},
})
.state('app.child3', {
url: '/child3?id',
params: {
hello: 'world'
hello: 'world',
},
reloadOnSearch: false,
views: {
child: {
controller: ($scope, $ngRedux) => {
let disconnect = $ngRedux.connect((state) => state, routerActions)($scope);
const disconnect = $ngRedux.connect(
state => state,
routerActions
)($scope);

$scope.$on('$destroy', disconnect)
$scope.$on('$destroy', disconnect);
},
template: `
<div class="child-view">
Expand All @@ -128,9 +128,9 @@ export default angular
<button ng-click="stateGo('app.child3', {id: '2'})">$state.go View 3, ID: 2</button>
<button ng-click="stateGo('app.child3', {id: '3'})">$state.go View 3, ID: 3</button>
</div>
`
}
}
`,
},
},
})
.state('app.child4', {
url: '/child4',
Expand All @@ -142,42 +142,41 @@ export default angular
<h2>Child View 4</h2>
<div>This state is prohibited. You should've been redirected to the root.</div>
</div>
`
}
}
})
`,
},
},
});
})
.config(($ngReduxProvider) => {
.config($ngReduxProvider => {
const logger = createLogger({
level: 'info',
collapsed: true
collapsed: true,
});

const reducers = combineReducers({
router
router,
});

$ngReduxProvider.createStoreWith(reducers, ['ngUiRouterMiddleware', logger, thunk]);
})
.run(($rootScope, $state, $ngRedux, $urlRouter) => {
const middlewares = ['ngUiRouterMiddleware', thunk, logger];
const enhancers = [DevTools.instrument()];

$ngReduxProvider.createStoreWith(reducers, middlewares, enhancers);
})
.run(runDevTools)
.run(($transitions, $state, $ngRedux) => {
// If save something to the store, dispatch will force state change update
console.log('will do dispatch');
$ngRedux.dispatch({type: 'SOME_ACTION'});
$ngRedux.dispatch({ type: 'SOME_ACTION' });
console.log('did dispatch');

$rootScope.$on('$stateChangeStart', function(evt, to, params) {
if (to.prohibited) {
evt.preventDefault();
const matchCriteria = { to: state => state.prohibited };

$transitions.onBefore(matchCriteria, $transition$ => {
if ($transition$.to().prohibited) {
console.log('prohibited state change cancelled');
$state.go('app');
return $state.target('app', { location: 'replace' });
}
});

console.log('$stateChangeStart callback is ready');
console.log('enable $urlRouter listening');

$urlRouter.sync();
$urlRouter.listen();
})
.name;
console.log('$transitions.onBefore callback is ready');
}).name;
15 changes: 11 additions & 4 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"babel-core": "6.13.1",
"babel-loader": "6.2.4",
"babel-core": "6.5.2",
"react": "^15.3.0",
"react-dom": "^15.3.0",
"redux-batched-updates": "0.1.0",
"redux-devtools-dock-monitor": "^1.1.1",
"redux-devtools-log-monitor": "^1.0.11",
"redux-slider-monitor": "^1.0.7",
"webpack": "1.13.1",
"webpack-dev-server": "1.14.1"
},
"license": "MIT",
"dependencies": {
"@uirouter/angularjs": "^1.0.3",
"angular": "^1.5.1",
"angular-ui-router": "0.4.2",
"ng-redux": "^3.3.3",
"react-redux": "^4.4.5",
"redux": "^3.5.2",
"redux-devtools": "^3.3.1",
"redux-logger": "2.6.1",
"redux-thunk": "2.1.0"
},
"engines" : {
"node" : ">=6.0.0"
"engines": {
"node": ">=6.0.0"
}
}
17 changes: 8 additions & 9 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/dev-server',
'./index'
'./index',
//Remove the following line to remove devTools
'./devTools.js'
],
output: {
path: path.join(__dirname, 'dist'),
Expand All @@ -17,17 +19,14 @@ module.exports = {
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
resolve: {
extensions: ['', '.js'],
alias: {
'react': path.join(__dirname, '..', '..', 'node_modules', 'react')
}
},
module: {
loaders: [{
test: /\.js$/,
loaders: ['babel'],
exclude: /node_modules/
loader: 'babel',
exclude: /node_modules/,
query: {
presets: ['es2015', 'stage-0', 'react']
}
}, {
test: /\.css?$/,
loaders: ['style', 'raw'],
Expand Down
Loading

0 comments on commit a56da69

Please sign in to comment.