summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/create_cluster/eks_cluster/store/index.js
blob: 5982fc8a2fd85aee612fce068cd95eff1e017bcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import Vuex from 'vuex';
import * as actions from './actions';
import * as getters from './getters';
import mutations from './mutations';
import state from './state';

import clusterDropdownStore from './cluster_dropdown';

import awsServicesFactory from '../services/aws_services_facade';

const createStore = ({ initialState, apiPaths }) => {
  const awsServices = awsServicesFactory(apiPaths);

  return new Vuex.Store({
    actions,
    getters,
    mutations,
    state: Object.assign(state(), initialState),
    modules: {
      roles: {
        namespaced: true,
        ...clusterDropdownStore(awsServices.fetchRoles),
      },
      regions: {
        namespaced: true,
        ...clusterDropdownStore(awsServices.fetchRegions),
      },
      keyPairs: {
        namespaced: true,
        ...clusterDropdownStore(awsServices.fetchKeyPairs),
      },
      vpcs: {
        namespaced: true,
        ...clusterDropdownStore(awsServices.fetchVpcs),
      },
      subnets: {
        namespaced: true,
        ...clusterDropdownStore(awsServices.fetchSubnets),
      },
      securityGroups: {
        namespaced: true,
        ...clusterDropdownStore(awsServices.fetchSecurityGroups),
      },
      instanceTypes: {
        namespaced: true,
        ...clusterDropdownStore(awsServices.fetchInstanceTypes),
      },
    },
  });
};

export default createStore;