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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
2ea263ea
Commit
2ea263ea
authored
May 06, 2018
by
Dennis Tang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring!
parent
28a45b02
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
96 deletions
+106
-96
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_machine_type_dropdown.vue
...luster_dropdowns/components/gke_machine_type_dropdown.vue
+32
-40
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_project_id_dropdown.vue
..._cluster_dropdowns/components/gke_project_id_dropdown.vue
+34
-18
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_zone_dropdown.vue
...ts/gke_cluster_dropdowns/components/gke_zone_dropdown.vue
+29
-34
app/assets/javascripts/projects/gke_cluster_dropdowns/index.js
...ssets/javascripts/projects/gke_cluster_dropdowns/index.js
+5
-1
app/assets/javascripts/projects/gke_cluster_dropdowns/stores/getters.js
...ascripts/projects/gke_cluster_dropdowns/stores/getters.js
+3
-0
app/assets/stylesheets/pages/clusters.scss
app/assets/stylesheets/pages/clusters.scss
+1
-1
app/views/projects/clusters/gcp/_form.html.haml
app/views/projects/clusters/gcp/_form.html.haml
+2
-2
No files found.
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_machine_type_dropdown.vue
View file @
2ea263ea
<
script
>
<
script
>
import
_
from
'
underscore
'
;
import
Flash
from
'
~/flash
'
;
import
Flash
from
'
~/flash
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
,
sprintf
}
from
'
~/locale
'
;
import
{
mapActions
}
from
'
vuex
'
;
import
{
map
State
,
mapGetters
,
map
Actions
}
from
'
vuex
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
LoadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
LoadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
DropdownSearchInput
from
'
~/vue_shared/components/dropdown/dropdown_search_input.vue
'
;
import
DropdownSearchInput
from
'
~/vue_shared/components/dropdown/dropdown_search_input.vue
'
;
...
@@ -10,7 +11,6 @@ import DropdownHiddenInput from '~/vue_shared/components/dropdown/dropdown_hidde
...
@@ -10,7 +11,6 @@ import DropdownHiddenInput from '~/vue_shared/components/dropdown/dropdown_hidde
import
eventHub
from
'
../eventhub
'
;
import
eventHub
from
'
../eventhub
'
;
import
store
from
'
../stores
'
;
import
store
from
'
../stores
'
;
import
DropdownButton
from
'
./dropdown_button.vue
'
;
import
DropdownButton
from
'
./dropdown_button.vue
'
;
// TODO: Fall back to default us-central1-a or first option
export
default
{
export
default
{
name
:
'
GkeMachineTypeDropdown
'
,
name
:
'
GkeMachineTypeDropdown
'
,
...
@@ -35,40 +35,43 @@ export default {
...
@@ -35,40 +35,43 @@ export default {
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
inputValue
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
},
},
data
()
{
data
()
{
return
{
return
{
isLoading
:
false
,
isLoading
:
false
,
hasErrors
:
false
,
hasErrors
:
false
,
searchQuery
:
''
,
searchQuery
:
''
,
selectedItem
:
''
,
items
:
[],
items
:
[],
};
};
},
},
computed
:
{
computed
:
{
...
mapState
([
'
selectedProject
'
,
'
selectedZone
'
,
'
selectedMachineType
'
]),
...
mapGetters
([
'
hasProject
'
,
'
hasZone
'
]),
isDisabled
()
{
isDisabled
()
{
return
(
return
!
this
.
selectedProject
||
!
this
.
selectedZone
;
this
.
$store
.
state
.
selectedProject
.
length
===
0
||
this
.
$store
.
state
.
selectedZone
.
length
===
0
);
},
},
r
esults
()
{
searchR
esults
()
{
return
this
.
items
.
filter
(
item
=>
item
.
name
.
toLowerCase
().
indexOf
(
this
.
searchQuery
)
>
-
1
);
return
this
.
items
.
filter
(
item
=>
item
.
name
.
toLowerCase
().
indexOf
(
this
.
searchQuery
)
>
-
1
);
},
},
toggleText
()
{
toggleText
()
{
if
(
this
.
$store
.
state
.
selectedMachineType
)
{
return
this
.
$store
.
state
.
selectedMachineType
;
}
if
(
this
.
isLoading
)
{
if
(
this
.
isLoading
)
{
return
s__
(
'
ClusterIntegration|Fetching machine types
'
);
return
s__
(
'
ClusterIntegration|Fetching machine types
'
);
}
}
if
(
!
this
.
$store
.
state
.
selectedProject
)
{
if
(
this
.
selectedMachineType
)
{
return
this
.
selectedMachineType
;
}
if
(
!
this
.
hasProject
&&
!
this
.
hasZone
)
{
return
s__
(
'
ClusterIntegration|Select project and zone to choose machine type.
'
);
return
s__
(
'
ClusterIntegration|Select project and zone to choose machine type.
'
);
}
}
return
this
.
$store
.
state
.
selected
Zone
return
this
.
has
Zone
?
s__
(
'
ClusterIntegration|Select machine type
'
)
?
s__
(
'
ClusterIntegration|Select machine type
'
)
:
s__
(
'
ClusterIntegration|Select zone to choose machine type
'
);
:
s__
(
'
ClusterIntegration|Select zone to choose machine type
'
);
},
},
...
@@ -85,34 +88,22 @@ export default {
...
@@ -85,34 +88,22 @@ export default {
fetchItems
()
{
fetchItems
()
{
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
const
request
=
this
.
service
.
machineTypes
.
list
({
const
request
=
this
.
service
.
machineTypes
.
list
({
project
:
this
.
$store
.
state
.
selectedProject
.
projectId
,
project
:
this
.
selectedProject
.
projectId
,
zone
:
this
.
$store
.
state
.
selectedZone
,
zone
:
this
.
selectedZone
,
});
});
return
request
.
then
(
return
request
.
then
(
resp
=>
{
resp
=>
{
let
machineTypeToSelect
;
this
.
items
=
resp
.
result
.
items
;
this
.
items
=
resp
.
result
.
items
;
// Cause error
if
(
this
.
inputValue
)
{
// this.items = data;
machineTypeToSelect
=
_
.
find
(
this
.
items
,
item
=>
item
.
name
===
this
.
inputValue
);
this
.
setMachineType
(
machineTypeToSelect
.
name
);
// Single state
// this.items = [
// {
// create_time: '2018-01-16T15:55:02.992Z',
// lifecycle_state: 'ACTIVE',
// name: 'NaturalInterface',
// item_id: 'naturalinterface-192315',
// item_number: 840816084083,
// },
// ];
if
(
this
.
items
.
length
===
1
)
{
this
.
isDisabled
=
true
;
this
.
setMachineType
(
this
.
items
[
0
].
name
);
}
}
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
this
.
hasErrors
=
false
;
},
},
()
=>
{
()
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
...
@@ -120,9 +111,10 @@ export default {
...
@@ -120,9 +111,10 @@ export default {
if
(
resp
.
result
.
error
)
{
if
(
resp
.
result
.
error
)
{
Flash
(
Flash
(
`
${
s__
(
sprintf
(
'
ClusterIntegration|An error occured while trying to fetch zone machine types:
'
,
'
ClusterIntegration|An error occured while trying to fetch zone machine types: %{error}
'
,
)}
${
resp
.
result
.
error
.
message
}
`
,
{
error
:
resp
.
result
.
error
.
message
},
),
);
);
}
}
},
},
...
@@ -130,7 +122,7 @@ export default {
...
@@ -130,7 +122,7 @@ export default {
);
);
},
},
enableSubmit
()
{
enableSubmit
()
{
document
.
querySelector
(
'
input[type=submit]
'
).
removeAttribute
(
'
disabled
'
);
document
.
querySelector
(
'
.js-gke-cluster-creation-submit
'
).
removeAttribute
(
'
disabled
'
);
},
},
},
},
};
};
...
@@ -143,7 +135,7 @@ export default {
...
@@ -143,7 +135,7 @@ export default {
>
>
<dropdown-hidden-input
<dropdown-hidden-input
:name=
"fieldName"
:name=
"fieldName"
:value=
"
$store.state.
selectedMachineType"
:value=
"selectedMachineType"
/>
/>
<dropdown-button
<dropdown-button
:class=
"
{ 'gl-field-error-outline': hasErrors }"
:class=
"
{ 'gl-field-error-outline': hasErrors }"
...
@@ -159,7 +151,7 @@ export default {
...
@@ -159,7 +151,7 @@ export default {
<div
class=
"dropdown-content"
>
<div
class=
"dropdown-content"
>
<ul>
<ul>
<li
<li
v-for=
"result in
r
esults"
v-for=
"result in
searchR
esults"
:key=
"result.id"
:key=
"result.id"
>
>
<a
<a
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_project_id_dropdown.vue
View file @
2ea263ea
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
Flash
from
'
~/flash
'
;
import
Flash
from
'
~/flash
'
;
import
{
s__
,
sprintf
}
from
'
~/locale
'
;
import
{
s__
,
sprintf
}
from
'
~/locale
'
;
import
{
mapActions
}
from
'
vuex
'
;
import
{
map
State
,
mapGetters
,
map
Actions
}
from
'
vuex
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
LoadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
LoadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
DropdownSearchInput
from
'
~/vue_shared/components/dropdown/dropdown_search_input.vue
'
;
import
DropdownSearchInput
from
'
~/vue_shared/components/dropdown/dropdown_search_input.vue
'
;
...
@@ -39,32 +39,38 @@ export default {
...
@@ -39,32 +39,38 @@ export default {
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
inputValue
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
},
},
data
()
{
data
()
{
return
{
return
{
isLoading
:
true
,
isLoading
:
true
,
hasErrors
:
false
,
hasErrors
:
false
,
searchQuery
:
''
,
searchQuery
:
''
,
selectedItem
:
''
,
items
:
[],
items
:
[],
};
};
},
},
computed
:
{
computed
:
{
...
mapState
([
'
selectedProject
'
]),
...
mapGetters
([
'
hasProject
'
]),
isDisabled
()
{
isDisabled
()
{
return
this
.
items
.
length
<
2
;
return
this
.
items
.
length
<
2
;
},
},
r
esults
()
{
searchR
esults
()
{
return
this
.
items
.
filter
(
item
=>
item
.
name
.
toLowerCase
().
indexOf
(
this
.
searchQuery
)
>
-
1
);
return
this
.
items
.
filter
(
item
=>
item
.
name
.
toLowerCase
().
indexOf
(
this
.
searchQuery
)
>
-
1
);
},
},
toggleText
()
{
toggleText
()
{
if
(
this
.
$store
.
state
.
selectedProject
.
name
)
{
return
this
.
$store
.
state
.
selectedProject
.
name
;
}
if
(
this
.
isLoading
)
{
if
(
this
.
isLoading
)
{
return
s__
(
'
ClusterIntegration|Fetching projects
'
);
return
s__
(
'
ClusterIntegration|Fetching projects
'
);
}
}
if
(
this
.
hasProject
)
{
return
this
.
selectedProject
.
name
;
}
return
this
.
items
.
length
return
this
.
items
.
length
?
s__
(
'
ClusterIntegration|Select project
'
)
?
s__
(
'
ClusterIntegration|Select project
'
)
:
s__
(
'
ClusterIntegration|No projects found
'
);
:
s__
(
'
ClusterIntegration|No projects found
'
);
...
@@ -105,24 +111,34 @@ export default {
...
@@ -105,24 +111,34 @@ export default {
return
request
.
then
(
return
request
.
then
(
resp
=>
{
resp
=>
{
let
projectToSelect
;
this
.
items
=
resp
.
result
.
projects
;
this
.
items
=
resp
.
result
.
projects
;
this
.
isLoading
=
false
;
if
(
this
.
inputValue
)
{
if
(
this
.
items
.
length
===
1
)
{
projectToSelect
=
_
.
find
(
this
.
items
,
item
=>
item
.
projectId
===
this
.
inputValue
);
this
.
setProject
(
this
.
items
[
0
]);
this
.
setProject
(
projectToSelect
);
}
else
if
(
this
.
items
.
length
===
1
)
{
projectToSelect
=
this
.
items
[
0
];
this
.
setProject
(
projectToSelect
);
}
}
this
.
isLoading
=
false
;
this
.
hasErrors
=
false
;
},
},
resp
=>
{
resp
=>
{
this
.
isLoading
=
false
;
this
.
hasErrors
=
true
;
if
(
resp
.
result
.
error
)
{
if
(
resp
.
result
.
error
)
{
Flash
(
Flash
(
`
${
s__
(
'
ClusterIntegration|An error occured while trying to fetch your projects:
'
)}
${
sprintf
(
resp
.
result
.
error
.
message
'
ClusterIntegration|An error occured while trying to fetch your projects: %{error}
'
,
}
`
,
{
error
:
resp
.
result
.
error
.
message
,
},
),
);
);
}
}
this
.
isLoading
=
false
;
this
.
hasErrors
=
true
;
},
},
this
,
this
,
);
);
...
@@ -139,7 +155,7 @@ export default {
...
@@ -139,7 +155,7 @@ export default {
>
>
<dropdown-hidden-input
<dropdown-hidden-input
:name=
"fieldName"
:name=
"fieldName"
:value=
"
$store.state.
selectedProject.projectId"
:value=
"selectedProject.projectId"
/>
/>
<dropdown-button
<dropdown-button
:class=
"
{ 'gl-field-error-outline': hasErrors }"
:class=
"
{ 'gl-field-error-outline': hasErrors }"
...
@@ -155,7 +171,7 @@ export default {
...
@@ -155,7 +171,7 @@ export default {
<div
class=
"dropdown-content"
>
<div
class=
"dropdown-content"
>
<ul>
<ul>
<li
<li
v-for=
"result in
r
esults"
v-for=
"result in
searchR
esults"
:key=
"result.project_number"
:key=
"result.project_number"
>
>
<a
<a
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/components/gke_zone_dropdown.vue
View file @
2ea263ea
<
script
>
<
script
>
import
_
from
'
underscore
'
;
import
Flash
from
'
~/flash
'
;
import
Flash
from
'
~/flash
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
,
sprintf
}
from
'
~/locale
'
;
import
{
mapActions
}
from
'
vuex
'
;
import
{
map
State
,
mapGetters
,
map
Actions
}
from
'
vuex
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
LoadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
LoadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
DropdownSearchInput
from
'
~/vue_shared/components/dropdown/dropdown_search_input.vue
'
;
import
DropdownSearchInput
from
'
~/vue_shared/components/dropdown/dropdown_search_input.vue
'
;
...
@@ -10,7 +11,6 @@ import DropdownHiddenInput from '~/vue_shared/components/dropdown/dropdown_hidde
...
@@ -10,7 +11,6 @@ import DropdownHiddenInput from '~/vue_shared/components/dropdown/dropdown_hidde
import
eventHub
from
'
../eventhub
'
;
import
eventHub
from
'
../eventhub
'
;
import
store
from
'
../stores
'
;
import
store
from
'
../stores
'
;
import
DropdownButton
from
'
./dropdown_button.vue
'
;
import
DropdownButton
from
'
./dropdown_button.vue
'
;
// TODO: Fall back to default us-central1-a or first option
export
default
{
export
default
{
name
:
'
GkeZoneDropdown
'
,
name
:
'
GkeZoneDropdown
'
,
...
@@ -35,33 +35,39 @@ export default {
...
@@ -35,33 +35,39 @@ export default {
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
inputValue
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
},
},
data
()
{
data
()
{
return
{
return
{
isLoading
:
false
,
isLoading
:
false
,
hasErrors
:
false
,
hasErrors
:
false
,
searchQuery
:
''
,
searchQuery
:
''
,
selectedItem
:
''
,
items
:
[],
items
:
[],
};
};
},
},
computed
:
{
computed
:
{
...
mapState
([
'
selectedProject
'
,
'
selectedZone
'
]),
...
mapGetters
([
'
hasProject
'
]),
isDisabled
()
{
isDisabled
()
{
return
this
.
$store
.
state
.
selectedProject
.
projectId
.
length
===
0
;
return
!
this
.
hasProject
;
},
},
r
esults
()
{
searchR
esults
()
{
return
this
.
items
.
filter
(
item
=>
item
.
name
.
toLowerCase
().
indexOf
(
this
.
searchQuery
)
>
-
1
);
return
this
.
items
.
filter
(
item
=>
item
.
name
.
toLowerCase
().
indexOf
(
this
.
searchQuery
)
>
-
1
);
},
},
toggleText
()
{
toggleText
()
{
if
(
this
.
$store
.
state
.
selectedZone
)
{
return
this
.
$store
.
state
.
selectedZone
;
}
if
(
this
.
isLoading
)
{
if
(
this
.
isLoading
)
{
return
s__
(
'
ClusterIntegration|Fetching zones
'
);
return
s__
(
'
ClusterIntegration|Fetching zones
'
);
}
}
return
this
.
$store
.
state
.
selectedProject
if
(
this
.
selectedZone
)
{
return
this
.
selectedZone
;
}
return
this
.
$store
.
state
.
selectedProject
.
projectId
.
length
?
s__
(
'
ClusterIntegration|Select zone
'
)
?
s__
(
'
ClusterIntegration|Select zone
'
)
:
s__
(
'
ClusterIntegration|Select project to choose zone
'
);
:
s__
(
'
ClusterIntegration|Select project to choose zone
'
);
},
},
...
@@ -77,33 +83,21 @@ export default {
...
@@ -77,33 +83,21 @@ export default {
fetchItems
()
{
fetchItems
()
{
this
.
isLoading
=
true
;
this
.
isLoading
=
true
;
const
request
=
this
.
service
.
zones
.
list
({
const
request
=
this
.
service
.
zones
.
list
({
project
:
this
.
$store
.
state
.
selectedProject
.
projectId
,
project
:
this
.
selectedProject
.
projectId
,
});
});
return
request
.
then
(
return
request
.
then
(
resp
=>
{
resp
=>
{
let
zoneToSelect
;
this
.
items
=
resp
.
result
.
items
;
this
.
items
=
resp
.
result
.
items
;
// Cause error
if
(
this
.
inputValue
)
{
// this.items = data;
zoneToSelect
=
_
.
find
(
this
.
items
,
item
=>
item
.
name
===
this
.
inputValue
);
this
.
setZone
(
zoneToSelect
.
name
);
// Single state
// this.items = [
// {
// create_time: '2018-01-16T15:55:02.992Z',
// lifecycle_state: 'ACTIVE',
// name: 'NaturalInterface',
// item_id: 'naturalinterface-192315',
// item_number: 840816084083,
// },
// ];
if
(
this
.
items
.
length
===
1
)
{
this
.
isDisabled
=
true
;
this
.
setZone
(
this
.
items
[
0
].
name
);
}
}
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
this
.
hasErrors
=
false
;
},
},
resp
=>
{
resp
=>
{
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
...
@@ -111,9 +105,10 @@ export default {
...
@@ -111,9 +105,10 @@ export default {
if
(
resp
.
result
.
error
)
{
if
(
resp
.
result
.
error
)
{
Flash
(
Flash
(
`
${
s__
(
'
ClusterIntegration|An error occured while trying to fetch project zones:
'
)}
${
sprintf
(
resp
.
result
.
error
.
message
'
ClusterIntegration|An error occured while trying to fetch project zones: %{error}
'
,
}
`
,
{
error
:
resp
.
result
.
error
.
message
},
),
);
);
}
}
},
},
...
@@ -131,7 +126,7 @@ export default {
...
@@ -131,7 +126,7 @@ export default {
>
>
<dropdown-hidden-input
<dropdown-hidden-input
:name=
"fieldName"
:name=
"fieldName"
:value=
"
$store.state.
selectedZone"
:value=
"selectedZone"
/>
/>
<dropdown-button
<dropdown-button
:class=
"
{ 'gl-field-error-outline': hasErrors }"
:class=
"
{ 'gl-field-error-outline': hasErrors }"
...
@@ -147,7 +142,7 @@ export default {
...
@@ -147,7 +142,7 @@ export default {
<div
class=
"dropdown-content"
>
<div
class=
"dropdown-content"
>
<ul>
<ul>
<li
<li
v-for=
"result in
r
esults"
v-for=
"result in
searchR
esults"
:key=
"result.id"
:key=
"result.id"
>
>
<a
<a
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/index.js
View file @
2ea263ea
...
@@ -24,6 +24,7 @@ const mountGkeProjectIdDropdown = () => {
...
@@ -24,6 +24,7 @@ const mountGkeProjectIdDropdown = () => {
service
:
gapi
.
client
.
cloudresourcemanager
,
service
:
gapi
.
client
.
cloudresourcemanager
,
fieldName
:
hiddenInput
.
getAttribute
(
'
name
'
),
fieldName
:
hiddenInput
.
getAttribute
(
'
name
'
),
fieldId
:
hiddenInput
.
getAttribute
(
'
id
'
),
fieldId
:
hiddenInput
.
getAttribute
(
'
id
'
),
inputValue
:
hiddenInput
.
value
,
},
},
}),
}),
});
});
...
@@ -46,6 +47,7 @@ const mountGkeZoneDropdown = () => {
...
@@ -46,6 +47,7 @@ const mountGkeZoneDropdown = () => {
service
:
gapi
.
client
.
compute
,
service
:
gapi
.
client
.
compute
,
fieldName
:
hiddenInput
.
getAttribute
(
'
name
'
),
fieldName
:
hiddenInput
.
getAttribute
(
'
name
'
),
fieldId
:
hiddenInput
.
getAttribute
(
'
id
'
),
fieldId
:
hiddenInput
.
getAttribute
(
'
id
'
),
inputValue
:
hiddenInput
.
value
,
},
},
}),
}),
});
});
...
@@ -68,6 +70,7 @@ const mountGkeMachineTypeDropdown = () => {
...
@@ -68,6 +70,7 @@ const mountGkeMachineTypeDropdown = () => {
service
:
gapi
.
client
.
compute
,
service
:
gapi
.
client
.
compute
,
fieldName
:
hiddenInput
.
getAttribute
(
'
name
'
),
fieldName
:
hiddenInput
.
getAttribute
(
'
name
'
),
fieldId
:
hiddenInput
.
getAttribute
(
'
id
'
),
fieldId
:
hiddenInput
.
getAttribute
(
'
id
'
),
inputValue
:
hiddenInput
.
value
,
},
},
}),
}),
});
});
...
@@ -78,9 +81,10 @@ const gkeDropdownErrorHandler = () => {
...
@@ -78,9 +81,10 @@ const gkeDropdownErrorHandler = () => {
};
};
const
initializeGapiClient
=
()
=>
{
const
initializeGapiClient
=
()
=>
{
const
el
=
document
.
getElementById
(
'
new_cluster
'
);
const
el
=
document
.
querySelector
(
'
.js-gke-cluster-creation
'
);
gapi
.
client
.
setToken
({
access_token
:
el
.
dataset
.
token
});
gapi
.
client
.
setToken
({
access_token
:
el
.
dataset
.
token
});
delete
el
.
dataset
.
token
;
gapi
.
client
gapi
.
client
.
load
(
CONSTANTS
.
GCP_API_CLOUD_RESOURCE_MANAGER_ENDPOINT
)
.
load
(
CONSTANTS
.
GCP_API_CLOUD_RESOURCE_MANAGER_ENDPOINT
)
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/stores/getters.js
View file @
2ea263ea
export
const
hasProject
=
state
=>
!!
state
.
selectedProject
.
projectId
;
export
const
hasZone
=
state
=>
!!
state
.
selectedZone
;
export
const
hasMachineType
=
state
=>
!!
state
.
selectedMachineType
;
app/assets/stylesheets/pages/clusters.scss
View file @
2ea263ea
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
}
}
}
}
#new_cluster
{
.js-gke-cluster-creation
{
.dropdown-menu-toggle
{
.dropdown-menu-toggle
{
.loading-container
{
.loading-container
{
.fa
{
.fa
{
...
...
app/views/projects/clusters/gcp/_form.html.haml
View file @
2ea263ea
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
-
link_to_help_page
=
link_to
(
s_
(
'ClusterIntegration|help page'
),
help_page_path
(
'user/project/clusters/index'
),
target:
'_blank'
,
rel:
'noopener noreferrer'
)
-
link_to_help_page
=
link_to
(
s_
(
'ClusterIntegration|help page'
),
help_page_path
(
'user/project/clusters/index'
),
target:
'_blank'
,
rel:
'noopener noreferrer'
)
=
s_
(
'ClusterIntegration|Read our %{link_to_help_page} on Kubernetes cluster integration.'
).
html_safe
%
{
link_to_help_page:
link_to_help_page
}
=
s_
(
'ClusterIntegration|Read our %{link_to_help_page} on Kubernetes cluster integration.'
).
html_safe
%
{
link_to_help_page:
link_to_help_page
}
=
form_for
@cluster
,
html:
{
class:
'prepend-top-20'
,
data:
{
token:
@token_in_session
}
},
url:
gcp_namespace_project_clusters_path
(
@project
.
namespace
,
@project
),
as: :cluster
do
|
field
|
=
form_for
@cluster
,
html:
{
class:
'
js-gke-cluster-creation
prepend-top-20'
,
data:
{
token:
@token_in_session
}
},
url:
gcp_namespace_project_clusters_path
(
@project
.
namespace
,
@project
),
as: :cluster
do
|
field
|
=
form_errors
(
@cluster
)
=
form_errors
(
@cluster
)
.form-group
.form-group
=
field
.
label
:name
,
s_
(
'ClusterIntegration|Kubernetes cluster name'
)
=
field
.
label
:name
,
s_
(
'ClusterIntegration|Kubernetes cluster name'
)
...
@@ -51,4 +51,4 @@
...
@@ -51,4 +51,4 @@
=
icon
(
'chevron-down'
)
=
icon
(
'chevron-down'
)
.form-group
.form-group
=
field
.
submit
s_
(
'ClusterIntegration|Create Kubernetes cluster'
),
class:
'btn btn-success'
,
disabled:
true
=
field
.
submit
s_
(
'ClusterIntegration|Create Kubernetes cluster'
),
class:
'
js-gke-cluster-creation-submit
btn btn-success'
,
disabled:
true
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