Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"presets": [
["env", { "modules": false } ]
["env", { "modules": false } ],
"es2015",
]
}
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"root": true,
"installedESLint": true,
"env": {
"browser": true,
"jquery": true
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 5,
"sourceType": "script",
"sourceType": "module",
"ecmaFeatures": {
"globalReturn": false,
"impliedStrict": false
Expand Down
7 changes: 7 additions & 0 deletions app/javascript/demo/actions/counter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const increment = () => (
{ type: 'INCREMENT' }
);

export const decrement = () => (
{ type: 'DECREMENT' }
);
21 changes: 21 additions & 0 deletions app/javascript/demo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import store from './store';
import * as counterAction from './actions/counter';

ManageIQ.redux = {};
ManageIQ.redux.store = store;

// render the current state to the screen.
const valueEl = document.getElementById('reduxDemo');

const render = () => {
valueEl.innerHTML = store.getState().counter.toString();
};

render();

// re-render on any store change
store.subscribe(render);

store.dispatch(counterAction.increment());
store.dispatch(counterAction.increment());
store.dispatch(counterAction.decrement());
10 changes: 10 additions & 0 deletions app/javascript/demo/reducers/counter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default (state = 0, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1;
case 'DECREMENT':
return state - 1;
default:
return state;
}
};
6 changes: 6 additions & 0 deletions app/javascript/demo/reducers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { combineReducers } from 'redux';
import counter from './counter';

export default combineReducers({
counter,
});
9 changes: 9 additions & 0 deletions app/javascript/demo/store/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createStore } from 'redux';
import reducers from '../reducers';

let store = createStore(
reducers,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
);

export default store;
1 change: 1 addition & 0 deletions app/javascript/packs/redux.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('../demo');
2 changes: 2 additions & 0 deletions app/views/layouts/_header.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
= render :partial => 'layouts/about_modal'
#reduxDemo{style: "float: right; background-color:#3f9c35; font-size:22px;", class: 'card-pf'}
%nav.navbar.navbar-pf-vertical#notification-app{'ng-controller' => "headerController as vm"}
.navbar-header
%button{:type => "button", :class => "navbar-toggle"}
Expand Down Expand Up @@ -40,6 +41,7 @@
= render :partial => "layouts/notifications_drawer"
= render :partial => "layouts/toast_list"

= javascript_pack_tag 'manageiq-ui-classic/redux'
:javascript
miq_bootstrap('#notification-app', 'miq.notifications');

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"@angular/core": "~4.0.3",
"@angular/platform-browser": "~4.0.3",
"@angular/platform-browser-dynamic": "~4.0.3",
"babel-preset-es2015": "^6.24.1",
"core-js": "~2.4.1",
"redux": "^3.7.2",
"rxjs": "~5.3.0",
"ui-select": "0.19.8",
"zone.js": "~0.8.5"
Expand Down