2017-10-04 20:27:55 +03:00
|
|
|
import { reduxBatch } from '@manaflair/redux-batch';
|
2018-01-17 21:10:39 +02:00
|
|
|
import { createStore, combineReducers, compose } from 'redux';
|
2017-09-20 12:30:53 +03:00
|
|
|
import { reducer as formReducer } from 'redux-form';
|
2018-01-17 21:10:39 +02:00
|
|
|
import { ApolloClient } from 'apollo-client';
|
|
|
|
import { HttpLink } from 'apollo-link-http';
|
|
|
|
import { InMemoryCache } from 'apollo-cache-inmemory';
|
2017-11-09 13:27:32 +02:00
|
|
|
import { reducer as valuesReducer } from 'react-redux-values';
|
2018-01-24 04:11:33 +02:00
|
|
|
import paramCase from 'param-case';
|
2017-09-20 12:30:53 +03:00
|
|
|
|
2018-01-17 21:10:39 +02:00
|
|
|
const {
|
|
|
|
REACT_APP_GQL_PORT = 443,
|
|
|
|
REACT_APP_GQL_PROTOCOL = 'https',
|
|
|
|
REACT_APP_GQL_HOSTNAME = window.location.hostname
|
|
|
|
} = process.env;
|
2017-09-20 12:30:53 +03:00
|
|
|
|
|
|
|
export const client = new ApolloClient({
|
2018-01-17 21:10:39 +02:00
|
|
|
cache: new InMemoryCache(),
|
|
|
|
link: new HttpLink({
|
|
|
|
uri: `${REACT_APP_GQL_PROTOCOL}://${REACT_APP_GQL_HOSTNAME}:${REACT_APP_GQL_PORT}/graphql`
|
2017-09-20 12:30:53 +03:00
|
|
|
})
|
|
|
|
});
|
|
|
|
|
2018-01-17 21:10:39 +02:00
|
|
|
const initialState = {
|
|
|
|
ui: {
|
|
|
|
sections: {
|
2018-01-24 04:11:33 +02:00
|
|
|
instances: [
|
|
|
|
'Summary',
|
|
|
|
'CNS & DNS',
|
|
|
|
'Snapshots',
|
|
|
|
'Tags',
|
|
|
|
'Metadata',
|
|
|
|
'Networks'
|
|
|
|
].map(name => ({
|
|
|
|
pathname: paramCase(name),
|
|
|
|
name
|
|
|
|
}))
|
2018-01-17 21:10:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-09-20 12:30:53 +03:00
|
|
|
export const store = createStore(
|
|
|
|
combineReducers({
|
2017-11-09 13:27:32 +02:00
|
|
|
values: valuesReducer,
|
2017-09-20 12:30:53 +03:00
|
|
|
form: formReducer,
|
2018-01-17 21:10:39 +02:00
|
|
|
ui: (state = {}) => state
|
2017-09-20 12:30:53 +03:00
|
|
|
}),
|
2018-01-17 21:10:39 +02:00
|
|
|
initialState,
|
2017-09-20 12:30:53 +03:00
|
|
|
compose(
|
2017-10-04 20:27:55 +03:00
|
|
|
reduxBatch,
|
2017-09-20 12:30:53 +03:00
|
|
|
// If you are using the devToolsExtension, you can add it here also
|
|
|
|
// eslint-disable-next-line no-negated-condition
|
2018-01-17 21:10:39 +02:00
|
|
|
typeof window.__REDUX_DEVTOOLS_EXTENSION__ !== 'undefined'
|
|
|
|
? window.__REDUX_DEVTOOLS_EXTENSION__()
|
2017-09-20 12:30:53 +03:00
|
|
|
: f => f
|
|
|
|
)
|
|
|
|
);
|