Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
2b903ece
Commit
2b903ece
authored
May 14, 2018
by
Dennis Tang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename vuex actions as per best practices
parent
3acc649d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
27 deletions
+27
-27
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_machine_type_dropdown.vue
...luster_dropdowns/components/gke_machine_type_dropdown.vue
+2
-2
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_project_id_dropdown.vue
..._cluster_dropdowns/components/gke_project_id_dropdown.vue
+2
-2
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_zone_dropdown.vue
...ts/gke_cluster_dropdowns/components/gke_zone_dropdown.vue
+2
-2
app/assets/javascripts/projects/gke_cluster_dropdowns/store/actions.js
...vascripts/projects/gke_cluster_dropdowns/store/actions.js
+15
-15
spec/javascripts/projects/gke_cluster_dropdowns/stores/actions_spec.js
...pts/projects/gke_cluster_dropdowns/stores/actions_spec.js
+6
-6
No files found.
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_machine_type_dropdown.vue
View file @
2b903ece
...
@@ -47,7 +47,7 @@ export default {
...
@@ -47,7 +47,7 @@ export default {
selectedZone
()
{
selectedZone
()
{
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
this
.
get
MachineTypes
()
this
.
fetch
MachineTypes
()
.
then
(
this
.
fetchSuccessHandler
)
.
then
(
this
.
fetchSuccessHandler
)
.
catch
(
this
.
fetchFailureHandler
);
.
catch
(
this
.
fetchFailureHandler
);
},
},
...
@@ -56,7 +56,7 @@ export default {
...
@@ -56,7 +56,7 @@ export default {
},
},
},
},
methods
:
{
methods
:
{
...
mapActions
([
'
get
MachineTypes
'
]),
...
mapActions
([
'
fetch
MachineTypes
'
]),
...
mapActions
({
setItem
:
'
setMachineType
'
}),
...
mapActions
({
setItem
:
'
setMachineType
'
}),
enableSubmit
()
{
enableSubmit
()
{
if
(
this
.
allDropdownsSelected
)
{
if
(
this
.
allDropdownsSelected
)
{
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_project_id_dropdown.vue
View file @
2b903ece
...
@@ -76,12 +76,12 @@ export default {
...
@@ -76,12 +76,12 @@ export default {
created
()
{
created
()
{
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
this
.
get
Projects
()
this
.
fetch
Projects
()
.
then
(
this
.
fetchSuccessHandler
)
.
then
(
this
.
fetchSuccessHandler
)
.
catch
(
this
.
fetchFailureHandler
);
.
catch
(
this
.
fetchFailureHandler
);
},
},
methods
:
{
methods
:
{
...
mapActions
([
'
get
Projects
'
]),
...
mapActions
([
'
fetch
Projects
'
]),
...
mapActions
({
setItem
:
'
setProject
'
}),
...
mapActions
({
setItem
:
'
setProject
'
}),
fetchSuccessHandler
()
{
fetchSuccessHandler
()
{
if
(
this
.
defaultValue
)
{
if
(
this
.
defaultValue
)
{
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_zone_dropdown.vue
View file @
2b903ece
...
@@ -38,13 +38,13 @@ export default {
...
@@ -38,13 +38,13 @@ export default {
selectedProject
()
{
selectedProject
()
{
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
this
.
get
Zones
()
this
.
fetch
Zones
()
.
then
(
this
.
fetchSuccessHandler
)
.
then
(
this
.
fetchSuccessHandler
)
.
catch
(
this
.
fetchFailureHandler
);
.
catch
(
this
.
fetchFailureHandler
);
},
},
},
},
methods
:
{
methods
:
{
...
mapActions
([
'
get
Zones
'
]),
...
mapActions
([
'
fetch
Zones
'
]),
...
mapActions
({
setItem
:
'
setZone
'
}),
...
mapActions
({
setItem
:
'
setZone
'
}),
},
},
};
};
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/store/actions.js
View file @
2b903ece
/* global gapi */
/* global gapi */
import
*
as
types
from
'
./mutation_types
'
;
import
*
as
types
from
'
./mutation_types
'
;
export
const
setProject
=
({
commit
},
selectedProject
)
=>
{
commit
(
types
.
SET_PROJECT
,
selectedProject
);
};
export
const
setZone
=
({
commit
},
selectedZone
)
=>
{
commit
(
types
.
SET_ZONE
,
selectedZone
);
};
export
const
setMachineType
=
({
commit
},
selectedMachineType
)
=>
{
commit
(
types
.
SET_MACHINE_TYPE
,
selectedMachineType
);
};
const
gapiRequest
=
({
service
,
params
,
commit
,
mutation
,
payloadKey
})
=>
const
gapiRequest
=
({
service
,
params
,
commit
,
mutation
,
payloadKey
})
=>
new
Promise
((
resolve
,
reject
)
=>
{
new
Promise
((
resolve
,
reject
)
=>
{
const
request
=
service
.
list
(
params
);
const
request
=
service
.
list
(
params
);
...
@@ -31,7 +19,19 @@ const gapiRequest = ({ service, params, commit, mutation, payloadKey }) =>
...
@@ -31,7 +19,19 @@ const gapiRequest = ({ service, params, commit, mutation, payloadKey }) =>
);
);
});
});
export
const
getProjects
=
({
commit
})
=>
export
const
setProject
=
({
commit
},
selectedProject
)
=>
{
commit
(
types
.
SET_PROJECT
,
selectedProject
);
};
export
const
setZone
=
({
commit
},
selectedZone
)
=>
{
commit
(
types
.
SET_ZONE
,
selectedZone
);
};
export
const
setMachineType
=
({
commit
},
selectedMachineType
)
=>
{
commit
(
types
.
SET_MACHINE_TYPE
,
selectedMachineType
);
};
export
const
fetchProjects
=
({
commit
})
=>
gapiRequest
({
gapiRequest
({
service
:
gapi
.
client
.
cloudresourcemanager
.
projects
,
service
:
gapi
.
client
.
cloudresourcemanager
.
projects
,
params
:
{},
params
:
{},
...
@@ -40,7 +40,7 @@ export const getProjects = ({ commit }) =>
...
@@ -40,7 +40,7 @@ export const getProjects = ({ commit }) =>
payloadKey
:
'
projects
'
,
payloadKey
:
'
projects
'
,
});
});
export
const
get
Zones
=
({
commit
,
state
})
=>
export
const
fetch
Zones
=
({
commit
,
state
})
=>
gapiRequest
({
gapiRequest
({
service
:
gapi
.
client
.
compute
.
zones
,
service
:
gapi
.
client
.
compute
.
zones
,
params
:
{
params
:
{
...
@@ -51,7 +51,7 @@ export const getZones = ({ commit, state }) =>
...
@@ -51,7 +51,7 @@ export const getZones = ({ commit, state }) =>
payloadKey
:
'
items
'
,
payloadKey
:
'
items
'
,
});
});
export
const
get
MachineTypes
=
({
commit
,
state
})
=>
export
const
fetch
MachineTypes
=
({
commit
,
state
})
=>
gapiRequest
({
gapiRequest
({
service
:
gapi
.
client
.
compute
.
machineTypes
,
service
:
gapi
.
client
.
compute
.
machineTypes
,
params
:
{
params
:
{
...
...
spec/javascripts/projects/gke_cluster_dropdowns/stores/actions_spec.js
View file @
2b903ece
...
@@ -51,10 +51,10 @@ describe('GCP Cluster Dropdown Store Actions', () => {
...
@@ -51,10 +51,10 @@ describe('GCP Cluster Dropdown Store Actions', () => {
describe
(
'
async fetch methods
'
,
()
=>
{
describe
(
'
async fetch methods
'
,
()
=>
{
window
.
gapi
=
gapi
();
window
.
gapi
=
gapi
();
describe
(
'
get
Projects
'
,
()
=>
{
describe
(
'
fetch
Projects
'
,
()
=>
{
it
(
'
fetches projects from Google API
'
,
done
=>
{
it
(
'
fetches projects from Google API
'
,
done
=>
{
store
store
.
dispatch
(
'
get
Projects
'
)
.
dispatch
(
'
fetch
Projects
'
)
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
store
.
state
.
projects
[
0
].
projectId
).
toEqual
(
selectedProjectMock
.
projectId
);
expect
(
store
.
state
.
projects
[
0
].
projectId
).
toEqual
(
selectedProjectMock
.
projectId
);
expect
(
store
.
state
.
projects
[
0
].
name
).
toEqual
(
selectedProjectMock
.
name
);
expect
(
store
.
state
.
projects
[
0
].
name
).
toEqual
(
selectedProjectMock
.
name
);
...
@@ -65,10 +65,10 @@ describe('GCP Cluster Dropdown Store Actions', () => {
...
@@ -65,10 +65,10 @@ describe('GCP Cluster Dropdown Store Actions', () => {
});
});
});
});
describe
(
'
get
Zones
'
,
()
=>
{
describe
(
'
fetch
Zones
'
,
()
=>
{
it
(
'
fetches zones from Google API
'
,
done
=>
{
it
(
'
fetches zones from Google API
'
,
done
=>
{
store
store
.
dispatch
(
'
get
Zones
'
)
.
dispatch
(
'
fetch
Zones
'
)
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
store
.
state
.
zones
[
0
].
name
).
toEqual
(
selectedZoneMock
);
expect
(
store
.
state
.
zones
[
0
].
name
).
toEqual
(
selectedZoneMock
);
...
@@ -78,10 +78,10 @@ describe('GCP Cluster Dropdown Store Actions', () => {
...
@@ -78,10 +78,10 @@ describe('GCP Cluster Dropdown Store Actions', () => {
});
});
});
});
describe
(
'
get
MachineTypes
'
,
()
=>
{
describe
(
'
fetch
MachineTypes
'
,
()
=>
{
it
(
'
fetches machine types from Google API
'
,
done
=>
{
it
(
'
fetches machine types from Google API
'
,
done
=>
{
store
store
.
dispatch
(
'
get
MachineTypes
'
)
.
dispatch
(
'
fetch
MachineTypes
'
)
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
store
.
state
.
machineTypes
[
0
].
name
).
toEqual
(
selectedMachineTypeMock
);
expect
(
store
.
state
.
machineTypes
[
0
].
name
).
toEqual
(
selectedMachineTypeMock
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment