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
Léo-Paul Géneau
gitlab-ce
Commits
2e4bea09
Commit
2e4bea09
authored
May 28, 2018
by
Dennis Tang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
overhaul dropdown-dependent states
parent
95a63a88
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
31 deletions
+59
-31
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_machine_type_dropdown.vue
...luster_dropdowns/components/gke_machine_type_dropdown.vue
+20
-6
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_project_id_dropdown.vue
..._cluster_dropdowns/components/gke_project_id_dropdown.vue
+7
-16
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_zone_dropdown.vue
...ts/gke_cluster_dropdowns/components/gke_zone_dropdown.vue
+17
-8
app/assets/javascripts/projects/gke_cluster_dropdowns/store/actions.js
...vascripts/projects/gke_cluster_dropdowns/store/actions.js
+10
-1
app/assets/javascripts/projects/gke_cluster_dropdowns/store/mutation_types.js
...ts/projects/gke_cluster_dropdowns/store/mutation_types.js
+1
-0
app/assets/javascripts/projects/gke_cluster_dropdowns/store/mutations.js
...scripts/projects/gke_cluster_dropdowns/store/mutations.js
+3
-0
app/assets/javascripts/projects/gke_cluster_dropdowns/store/state.js
...javascripts/projects/gke_cluster_dropdowns/store/state.js
+1
-0
No files found.
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_machine_type_dropdown.vue
View file @
2e4bea09
...
@@ -8,14 +8,24 @@ export default {
...
@@ -8,14 +8,24 @@ export default {
name
:
'
GkeMachineTypeDropdown
'
,
name
:
'
GkeMachineTypeDropdown
'
,
mixins
:
[
gkeDropdownMixin
],
mixins
:
[
gkeDropdownMixin
],
computed
:
{
computed
:
{
...
mapState
([
'
projectHasBillingEnabled
'
,
'
selectedZone
'
,
'
selectedMachineType
'
]),
...
mapState
([
'
isValidatingProjectBilling
'
,
'
projectHasBillingEnabled
'
,
'
selectedZone
'
,
'
selectedMachineType
'
,
]),
...
mapState
({
items
:
'
machineTypes
'
}),
...
mapState
({
items
:
'
machineTypes
'
}),
...
mapGetters
([
'
hasZone
'
,
'
hasMachineType
'
]),
...
mapGetters
([
'
hasZone
'
,
'
hasMachineType
'
]),
allDropdownsSelected
()
{
allDropdownsSelected
()
{
return
this
.
projectHasBillingEnabled
&&
this
.
hasZone
&&
this
.
hasMachineType
;
return
this
.
projectHasBillingEnabled
&&
this
.
hasZone
&&
this
.
hasMachineType
;
},
},
isDisabled
()
{
isDisabled
()
{
return
!
this
.
projectHasBillingEnabled
||
!
this
.
selectedZone
;
return
(
this
.
isLoading
||
this
.
isValidatingProjectBilling
||
!
this
.
projectHasBillingEnabled
||
!
this
.
hasZone
);
},
},
toggleText
()
{
toggleText
()
{
if
(
this
.
isLoading
)
{
if
(
this
.
isLoading
)
{
...
@@ -45,11 +55,15 @@ export default {
...
@@ -45,11 +55,15 @@ export default {
},
},
watch
:
{
watch
:
{
selectedZone
()
{
selectedZone
()
{
this
.
hasErrors
=
false
;
if
(
this
.
hasZone
)
{
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
this
.
fetchMachineTypes
()
this
.
fetchMachineTypes
()
.
then
(
this
.
fetchSuccessHandler
)
.
then
(
this
.
fetchSuccessHandler
)
.
catch
(
this
.
fetchFailureHandler
);
.
catch
(
this
.
fetchFailureHandler
);
}
},
},
selectedMachineType
()
{
selectedMachineType
()
{
this
.
enableSubmit
();
this
.
enableSubmit
();
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_project_id_dropdown.vue
View file @
2e4bea09
...
@@ -14,20 +14,17 @@ export default {
...
@@ -14,20 +14,17 @@ export default {
required
:
true
,
required
:
true
,
},
},
},
},
data
()
{
return
{
isValidatingProjectBilling
:
false
,
};
},
computed
:
{
computed
:
{
...
mapState
([
'
selectedProject
'
,
'
projectHasBillingEnabled
'
]),
...
mapState
([
'
selectedProject
'
,
'
isValidatingProjectBilling
'
,
'
projectHasBillingEnabled
'
]),
...
mapState
({
items
:
'
projects
'
}),
...
mapState
({
items
:
'
projects
'
}),
...
mapGetters
([
'
hasProject
'
]),
...
mapGetters
([
'
hasProject
'
]),
hasOneProject
()
{
hasOneProject
()
{
return
this
.
items
&&
this
.
items
.
length
===
1
;
return
this
.
items
&&
this
.
items
.
length
===
1
;
},
},
isDisabled
()
{
isDisabled
()
{
return
this
.
items
&&
this
.
items
.
length
<
2
;
return
(
this
.
isLoading
||
this
.
isValidatingProjectBilling
||
(
this
.
items
&&
this
.
items
.
length
<
2
)
);
},
},
toggleText
()
{
toggleText
()
{
if
(
this
.
isValidatingProjectBilling
)
{
if
(
this
.
isValidatingProjectBilling
)
{
...
@@ -103,17 +100,12 @@ export default {
...
@@ -103,17 +100,12 @@ export default {
},
},
watch
:
{
watch
:
{
selectedProject
()
{
selectedProject
()
{
this
.
isLoading
=
true
;
this
.
setIsValidatingProjectBilling
(
true
);
this
.
isValidatingProjectBilling
=
true
;
this
.
validateProjectBilling
()
this
.
validateProjectBilling
()
.
then
(
this
.
validateProjectBillingSuccessHandler
)
.
then
(
this
.
validateProjectBillingSuccessHandler
)
.
catch
(
this
.
validateProjectBillingFailureHandler
);
.
catch
(
this
.
validateProjectBillingFailureHandler
);
},
},
projectHasBillingEnabled
(
billingEnabled
)
{
this
.
hasErrors
=
!
billingEnabled
;
this
.
isValidatingProjectBilling
=
false
;
},
},
},
created
()
{
created
()
{
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
...
@@ -123,7 +115,7 @@ export default {
...
@@ -123,7 +115,7 @@ export default {
.
catch
(
this
.
fetchFailureHandler
);
.
catch
(
this
.
fetchFailureHandler
);
},
},
methods
:
{
methods
:
{
...
mapActions
([
'
fetchProjects
'
,
'
validateProjectBilling
'
]),
...
mapActions
([
'
fetchProjects
'
,
'
setIsValidatingProjectBilling
'
,
'
validateProjectBilling
'
]),
...
mapActions
({
setItem
:
'
setProject
'
}),
...
mapActions
({
setItem
:
'
setProject
'
}),
fetchSuccessHandler
()
{
fetchSuccessHandler
()
{
if
(
this
.
defaultValue
)
{
if
(
this
.
defaultValue
)
{
...
@@ -140,10 +132,9 @@ export default {
...
@@ -140,10 +132,9 @@ export default {
this
.
hasErrors
=
false
;
this
.
hasErrors
=
false
;
},
},
validateProjectBillingSuccessHandler
()
{
validateProjectBillingSuccessHandler
()
{
this
.
isLoading
=
false
;
this
.
hasErrors
=
!
this
.
projectHasBillingEnabled
;
},
},
validateProjectBillingFailureHandler
(
resp
)
{
validateProjectBillingFailureHandler
(
resp
)
{
this
.
isLoading
=
false
;
this
.
hasErrors
=
true
;
this
.
hasErrors
=
true
;
this
.
gapiError
=
resp
.
result
?
resp
.
result
.
error
.
message
:
resp
;
this
.
gapiError
=
resp
.
result
?
resp
.
result
.
error
.
message
:
resp
;
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_zone_dropdown.vue
View file @
2e4bea09
...
@@ -8,10 +8,16 @@ export default {
...
@@ -8,10 +8,16 @@ export default {
name
:
'
GkeZoneDropdown
'
,
name
:
'
GkeZoneDropdown
'
,
mixins
:
[
gkeDropdownMixin
],
mixins
:
[
gkeDropdownMixin
],
computed
:
{
computed
:
{
...
mapState
([
'
selectedProject
'
,
'
selectedZone
'
,
'
projects
'
,
'
projectHasBillingEnabled
'
]),
...
mapState
([
'
selectedProject
'
,
'
selectedZone
'
,
'
projects
'
,
'
isValidatingProjectBilling
'
,
'
projectHasBillingEnabled
'
,
]),
...
mapState
({
items
:
'
zones
'
}),
...
mapState
({
items
:
'
zones
'
}),
isDisabled
()
{
isDisabled
()
{
return
!
this
.
projectHasBillingEnabled
;
return
this
.
isLoading
||
this
.
isValidatingProjectBilling
||
!
this
.
projectHasBillingEnabled
;
},
},
toggleText
()
{
toggleText
()
{
if
(
this
.
isLoading
)
{
if
(
this
.
isLoading
)
{
...
@@ -34,13 +40,16 @@ export default {
...
@@ -34,13 +40,16 @@ export default {
},
},
},
},
watch
:
{
watch
:
{
projectHasBillingEnabled
(
billingEnabled
)
{
isValidatingProjectBilling
(
isValidating
)
{
if
(
!
billingEnabled
)
return
false
;
this
.
hasErrors
=
false
;
if
(
!
isValidating
&&
this
.
projectHasBillingEnabled
)
{
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
return
this
.
fetchZones
()
this
.
fetchZones
()
.
then
(
this
.
fetchSuccessHandler
)
.
then
(
this
.
fetchSuccessHandler
)
.
catch
(
this
.
fetchFailureHandler
);
.
catch
(
this
.
fetchFailureHandler
);
}
},
},
},
},
methods
:
{
methods
:
{
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/store/actions.js
View file @
2e4bea09
...
@@ -31,6 +31,10 @@ export const setMachineType = ({ commit }, selectedMachineType) => {
...
@@ -31,6 +31,10 @@ export const setMachineType = ({ commit }, selectedMachineType) => {
commit
(
types
.
SET_MACHINE_TYPE
,
selectedMachineType
);
commit
(
types
.
SET_MACHINE_TYPE
,
selectedMachineType
);
};
};
export
const
setIsValidatingProjectBilling
=
({
commit
},
isValidatingProjectBilling
)
=>
{
commit
(
types
.
SET_IS_VALIDATING_PROJECT_BILLING
,
isValidatingProjectBilling
);
};
export
const
fetchProjects
=
({
commit
})
=>
export
const
fetchProjects
=
({
commit
})
=>
gapiResourceListRequest
({
gapiResourceListRequest
({
resource
:
gapi
.
client
.
cloudresourcemanager
.
projects
,
resource
:
gapi
.
client
.
cloudresourcemanager
.
projects
,
...
@@ -40,20 +44,25 @@ export const fetchProjects = ({ commit }) =>
...
@@ -40,20 +44,25 @@ export const fetchProjects = ({ commit }) =>
payloadKey
:
'
projects
'
,
payloadKey
:
'
projects
'
,
});
});
export
const
validateProjectBilling
=
({
commit
,
state
})
=>
export
const
validateProjectBilling
=
({
dispatch
,
commit
,
state
})
=>
new
Promise
((
resolve
,
reject
)
=>
{
new
Promise
((
resolve
,
reject
)
=>
{
const
request
=
gapi
.
client
.
cloudbilling
.
projects
.
getBillingInfo
({
const
request
=
gapi
.
client
.
cloudbilling
.
projects
.
getBillingInfo
({
name
:
`projects/
${
state
.
selectedProject
.
projectId
}
`
,
name
:
`projects/
${
state
.
selectedProject
.
projectId
}
`
,
});
});
commit
(
types
.
SET_ZONE
,
''
);
commit
(
types
.
SET_MACHINE_TYPE
,
''
);
return
request
.
then
(
return
request
.
then
(
resp
=>
{
resp
=>
{
const
{
billingEnabled
}
=
resp
.
result
;
const
{
billingEnabled
}
=
resp
.
result
;
commit
(
types
.
SET_PROJECT_BILLING_STATUS
,
!!
billingEnabled
);
commit
(
types
.
SET_PROJECT_BILLING_STATUS
,
!!
billingEnabled
);
dispatch
(
'
setIsValidatingProjectBilling
'
,
false
);
resolve
();
resolve
();
},
},
resp
=>
{
resp
=>
{
dispatch
(
'
setIsValidatingProjectBilling
'
,
false
);
reject
(
resp
);
reject
(
resp
);
},
},
);
);
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/store/mutation_types.js
View file @
2e4bea09
export
const
SET_PROJECT
=
'
SET_PROJECT
'
;
export
const
SET_PROJECT
=
'
SET_PROJECT
'
;
export
const
SET_PROJECT_BILLING_STATUS
=
'
SET_PROJECT_BILLING_STATUS
'
;
export
const
SET_PROJECT_BILLING_STATUS
=
'
SET_PROJECT_BILLING_STATUS
'
;
export
const
SET_IS_VALIDATING_PROJECT_BILLING
=
'
SET_IS_VALIDATING_PROJECT_BILLING
'
;
export
const
SET_ZONE
=
'
SET_ZONE
'
;
export
const
SET_ZONE
=
'
SET_ZONE
'
;
export
const
SET_MACHINE_TYPE
=
'
SET_MACHINE_TYPE
'
;
export
const
SET_MACHINE_TYPE
=
'
SET_MACHINE_TYPE
'
;
export
const
SET_PROJECTS
=
'
SET_PROJECTS
'
;
export
const
SET_PROJECTS
=
'
SET_PROJECTS
'
;
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/store/mutations.js
View file @
2e4bea09
...
@@ -4,6 +4,9 @@ export default {
...
@@ -4,6 +4,9 @@ export default {
[
types
.
SET_PROJECT
](
state
,
selectedProject
)
{
[
types
.
SET_PROJECT
](
state
,
selectedProject
)
{
Object
.
assign
(
state
,
{
selectedProject
});
Object
.
assign
(
state
,
{
selectedProject
});
},
},
[
types
.
SET_IS_VALIDATING_PROJECT_BILLING
](
state
,
isValidatingProjectBilling
)
{
Object
.
assign
(
state
,
{
isValidatingProjectBilling
});
},
[
types
.
SET_PROJECT_BILLING_STATUS
](
state
,
projectHasBillingEnabled
)
{
[
types
.
SET_PROJECT_BILLING_STATUS
](
state
,
projectHasBillingEnabled
)
{
Object
.
assign
(
state
,
{
projectHasBillingEnabled
});
Object
.
assign
(
state
,
{
projectHasBillingEnabled
});
},
},
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/store/state.js
View file @
2e4bea09
...
@@ -5,6 +5,7 @@ export default () => ({
...
@@ -5,6 +5,7 @@ export default () => ({
},
},
selectedZone
:
''
,
selectedZone
:
''
,
selectedMachineType
:
''
,
selectedMachineType
:
''
,
isValidatingProjectBilling
:
null
,
projectHasBillingEnabled
:
null
,
projectHasBillingEnabled
:
null
,
projects
:
[],
projects
:
[],
zones
:
[],
zones
:
[],
...
...
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