removed „fetched“ prefix from mutation and state
This commit is contained in:
parent
4f001a3abf
commit
f86f94503b
13 changed files with 50 additions and 56 deletions
|
@ -42,8 +42,7 @@ export default {
|
|||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(['selectedProject', 'selectedZone', 'selectedMachineType']),
|
||||
...mapState({ machineTypes: 'fetchedMachineTypes' }),
|
||||
...mapState(['selectedProject', 'selectedZone', 'selectedMachineType', 'machineTypes']),
|
||||
...mapGetters(['hasProject', 'hasZone', 'hasMachineType']),
|
||||
isDisabled() {
|
||||
return !this.selectedProject || !this.selectedZone;
|
||||
|
|
|
@ -45,8 +45,7 @@ export default {
|
|||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(['selectedProject']),
|
||||
...mapState({ projects: 'fetchedProjects' }),
|
||||
...mapState(['selectedProject', 'projects']),
|
||||
...mapGetters(['hasProject']),
|
||||
hasOneProject() {
|
||||
return this.projects.length === 1;
|
||||
|
|
|
@ -42,8 +42,7 @@ export default {
|
|||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(['selectedProject', 'selectedZone']),
|
||||
...mapState({ zones: 'fetchedZones' }),
|
||||
...mapState(['selectedProject', 'selectedZone', 'zones']),
|
||||
...mapGetters(['hasProject']),
|
||||
isDisabled() {
|
||||
return !this.hasProject;
|
||||
|
|
|
@ -29,7 +29,7 @@ export const getProjects = ({ commit }) =>
|
|||
|
||||
return request.then(
|
||||
resp => {
|
||||
commit(types.SET_FETCHED_PROJECTS, resp.result.projects);
|
||||
commit(types.SET_PROJECTS, resp.result.projects);
|
||||
|
||||
resolve();
|
||||
},
|
||||
|
@ -60,7 +60,7 @@ export const getZones = ({ commit, state }) =>
|
|||
|
||||
return request.then(
|
||||
resp => {
|
||||
commit(types.SET_FETCHED_ZONES, resp.result.items);
|
||||
commit(types.SET_ZONES, resp.result.items);
|
||||
|
||||
resolve();
|
||||
},
|
||||
|
@ -90,7 +90,7 @@ export const getMachineTypes = ({ commit, state }) =>
|
|||
|
||||
return request.then(
|
||||
resp => {
|
||||
commit(types.SET_FETCHED_MACHINE_TYPES, resp.result.items);
|
||||
commit(types.SET_MACHINE_TYPES, resp.result.items);
|
||||
|
||||
resolve();
|
||||
},
|
||||
|
|
|
@ -17,8 +17,8 @@ export default new Vuex.Store({
|
|||
},
|
||||
selectedZone: '',
|
||||
selectedMachineType: '',
|
||||
fetchedProjects: [],
|
||||
fetchedZones: [],
|
||||
fetchedMachineTypes: [],
|
||||
projects: [],
|
||||
zones: [],
|
||||
machineTypes: [],
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export const SET_PROJECT = 'SET_PROJECT';
|
||||
export const SET_ZONE = 'SET_ZONE';
|
||||
export const SET_MACHINE_TYPE = 'SET_MACHINE_TYPE';
|
||||
export const SET_FETCHED_PROJECTS = 'SET_FETCHED_PROJECTS';
|
||||
export const SET_FETCHED_ZONES = 'SET_FETCHED_ZONES';
|
||||
export const SET_FETCHED_MACHINE_TYPES = 'SET_FETCHED_MACHINE_TYPES';
|
||||
export const SET_PROJECTS = 'SET_PROJECTS';
|
||||
export const SET_ZONES = 'SET_ZONES';
|
||||
export const SET_MACHINE_TYPES = 'SET_MACHINE_TYPES';
|
||||
|
|
|
@ -10,13 +10,13 @@ export default {
|
|||
[types.SET_MACHINE_TYPE](state, selectedMachineType) {
|
||||
Object.assign(state, { selectedMachineType });
|
||||
},
|
||||
[types.SET_FETCHED_PROJECTS](state, fetchedProjects) {
|
||||
Object.assign(state, { fetchedProjects });
|
||||
[types.SET_PROJECTS](state, projects) {
|
||||
Object.assign(state, { projects });
|
||||
},
|
||||
[types.SET_FETCHED_ZONES](state, fetchedZones) {
|
||||
Object.assign(state, { fetchedZones });
|
||||
[types.SET_ZONES](state, zones) {
|
||||
Object.assign(state, { zones });
|
||||
},
|
||||
[types.SET_FETCHED_MACHINE_TYPES](state, fetchedMachineTypes) {
|
||||
Object.assign(state, { fetchedMachineTypes });
|
||||
[types.SET_MACHINE_TYPES](state, machineTypes) {
|
||||
Object.assign(state, { machineTypes });
|
||||
},
|
||||
};
|
||||
|
|
|
@ -3,8 +3,8 @@ import GkeMachineTypeDropdown from '~/projects/gke_cluster_dropdowns/components/
|
|||
import {
|
||||
SET_PROJECT,
|
||||
SET_ZONE,
|
||||
SET_FETCHED_ZONES,
|
||||
SET_FETCHED_MACHINE_TYPES,
|
||||
SET_ZONES,
|
||||
SET_MACHINE_TYPES,
|
||||
} from '~/projects/gke_cluster_dropdowns/stores/mutation_types';
|
||||
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
||||
|
||||
|
@ -84,7 +84,7 @@ describe('GkeMachineTypeDropdown', () => {
|
|||
describe('form input', () => {
|
||||
it('reflects new value when dropdown item is clicked', done => {
|
||||
expect(vm.$el.querySelector('input').value).toBe('');
|
||||
vm.$store.commit(SET_FETCHED_MACHINE_TYPES, gapiMachineTypesResponseMock.items);
|
||||
vm.$store.commit(SET_MACHINE_TYPES, gapiMachineTypesResponseMock.items);
|
||||
|
||||
vm.$nextTick(() => {
|
||||
vm.$el.querySelector('.dropdown-content button').click();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Vue from 'vue';
|
||||
import GkeProjectIdDropdown from '~/projects/gke_cluster_dropdowns/components/gke_project_id_dropdown.vue';
|
||||
import { SET_FETCHED_PROJECTS } from '~/projects/gke_cluster_dropdowns/stores/mutation_types';
|
||||
import { SET_PROJECTS } from '~/projects/gke_cluster_dropdowns/stores/mutation_types';
|
||||
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
||||
|
||||
import { resetStore } from '../helpers';
|
||||
|
@ -64,7 +64,7 @@ describe('GkeProjectIdDropdown', () => {
|
|||
|
||||
it('returns empty toggle text', done => {
|
||||
vm.$nextTick(() => {
|
||||
vm.$store.commit(SET_FETCHED_PROJECTS, []);
|
||||
vm.$store.commit(SET_PROJECTS, []);
|
||||
vm.setProject(emptyProjectMock);
|
||||
|
||||
vm.$nextTick(() => {
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import Vue from 'vue';
|
||||
import GkeZoneDropdown from '~/projects/gke_cluster_dropdowns/components/gke_zone_dropdown.vue';
|
||||
import {
|
||||
SET_PROJECT,
|
||||
SET_FETCHED_ZONES,
|
||||
} from '~/projects/gke_cluster_dropdowns/stores/mutation_types';
|
||||
import { SET_PROJECT, SET_ZONES } from '~/projects/gke_cluster_dropdowns/stores/mutation_types';
|
||||
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
||||
|
||||
import { resetStore } from '../helpers';
|
||||
|
@ -67,7 +64,7 @@ describe('GkeZoneDropdown', () => {
|
|||
describe('selectItem', () => {
|
||||
it('reflects new value when dropdown item is clicked', done => {
|
||||
expect(vm.$el.querySelector('input').value).toBe('');
|
||||
vm.$store.commit(SET_FETCHED_ZONES, gapiZonesResponseMock.items);
|
||||
vm.$store.commit(SET_ZONES, gapiZonesResponseMock.items);
|
||||
|
||||
vm.$nextTick(() => {
|
||||
vm.$el.querySelector('.dropdown-content button').click();
|
||||
|
|
|
@ -13,9 +13,9 @@ export const resetStore = store => {
|
|||
},
|
||||
selectedZone: '',
|
||||
selectedMachineType: '',
|
||||
fetchedProjects: [],
|
||||
fetchedZones: [],
|
||||
fetchedMachineTypes: [],
|
||||
projects: [],
|
||||
zones: [],
|
||||
machineTypes: [],
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ describe('GCP Cluster Dropdown Store Actions', () => {
|
|||
store
|
||||
.dispatch('getProjects')
|
||||
.then(() => {
|
||||
expect(store.state.fetchedProjects[0].projectId).toEqual(selectedProjectMock.projectId);
|
||||
expect(store.state.fetchedProjects[0].name).toEqual(selectedProjectMock.name);
|
||||
expect(store.state.projects[0].projectId).toEqual(selectedProjectMock.projectId);
|
||||
expect(store.state.projects[0].name).toEqual(selectedProjectMock.name);
|
||||
|
||||
done();
|
||||
})
|
||||
|
@ -70,7 +70,7 @@ describe('GCP Cluster Dropdown Store Actions', () => {
|
|||
store
|
||||
.dispatch('getZones')
|
||||
.then(() => {
|
||||
expect(store.state.fetchedZones[0].name).toEqual(selectedZoneMock);
|
||||
expect(store.state.zones[0].name).toEqual(selectedZoneMock);
|
||||
|
||||
done();
|
||||
})
|
||||
|
@ -83,7 +83,7 @@ describe('GCP Cluster Dropdown Store Actions', () => {
|
|||
store
|
||||
.dispatch('getMachineTypes')
|
||||
.then(() => {
|
||||
expect(store.state.fetchedMachineTypes[0].name).toEqual(selectedMachineTypeMock);
|
||||
expect(store.state.machineTypes[0].name).toEqual(selectedMachineTypeMock);
|
||||
|
||||
done();
|
||||
})
|
||||
|
|
|
@ -52,45 +52,45 @@ describe('GCP Cluster Dropdown Store Mutations', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('SET_FETCHED_PROJECTS', () => {
|
||||
it('should set Google API Projects response as fetchedProjects', () => {
|
||||
describe('SET_PROJECTS', () => {
|
||||
it('should set Google API Projects response as projects', () => {
|
||||
const state = {
|
||||
fetchedProjects: [],
|
||||
projects: [],
|
||||
};
|
||||
|
||||
expect(state.fetchedProjects.length).toEqual(0);
|
||||
expect(state.projects.length).toEqual(0);
|
||||
|
||||
mutations.SET_FETCHED_PROJECTS(state, gapiProjectsResponseMock.projects);
|
||||
mutations.SET_PROJECTS(state, gapiProjectsResponseMock.projects);
|
||||
|
||||
expect(state.fetchedProjects.length).toEqual(gapiProjectsResponseMock.projects.length);
|
||||
expect(state.projects.length).toEqual(gapiProjectsResponseMock.projects.length);
|
||||
});
|
||||
});
|
||||
|
||||
describe('SET_FETCHED_ZONES', () => {
|
||||
it('should set Google API Zones response as fetchedZones', () => {
|
||||
describe('SET_ZONES', () => {
|
||||
it('should set Google API Zones response as zones', () => {
|
||||
const state = {
|
||||
fetchedZones: [],
|
||||
zones: [],
|
||||
};
|
||||
|
||||
expect(state.fetchedZones.length).toEqual(0);
|
||||
expect(state.zones.length).toEqual(0);
|
||||
|
||||
mutations.SET_FETCHED_ZONES(state, gapiZonesResponseMock.items);
|
||||
mutations.SET_ZONES(state, gapiZonesResponseMock.items);
|
||||
|
||||
expect(state.fetchedZones.length).toEqual(gapiZonesResponseMock.items.length);
|
||||
expect(state.zones.length).toEqual(gapiZonesResponseMock.items.length);
|
||||
});
|
||||
});
|
||||
|
||||
describe('SET_FETCHED_MACHINE_TYPES', () => {
|
||||
it('should set Google API Machine Types response as fetchedMachineTypes', () => {
|
||||
describe('SET_MACHINE_TYPES', () => {
|
||||
it('should set Google API Machine Types response as machineTypes', () => {
|
||||
const state = {
|
||||
fetchedMachineTypes: [],
|
||||
machineTypes: [],
|
||||
};
|
||||
|
||||
expect(state.fetchedMachineTypes.length).toEqual(0);
|
||||
expect(state.machineTypes.length).toEqual(0);
|
||||
|
||||
mutations.SET_FETCHED_MACHINE_TYPES(state, gapiMachineTypesResponseMock.items);
|
||||
mutations.SET_MACHINE_TYPES(state, gapiMachineTypesResponseMock.items);
|
||||
|
||||
expect(state.fetchedMachineTypes.length).toEqual(gapiMachineTypesResponseMock.items.length);
|
||||
expect(state.machineTypes.length).toEqual(gapiMachineTypesResponseMock.items.length);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue