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
e754fafa
Commit
e754fafa
authored
May 06, 2018
by
Dennis Tang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revisions
parent
eece2a1c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
115 deletions
+121
-115
app/assets/javascripts/pages/projects/clusters/gcp/new/index.js
...sets/javascripts/pages/projects/clusters/gcp/new/index.js
+2
-114
app/assets/javascripts/projects/gke_cluster_dropdowns/components/dropdown_button.vue
...ects/gke_cluster_dropdowns/components/dropdown_button.vue
+0
-1
app/assets/javascripts/projects/gke_cluster_dropdowns/constants.js
...s/javascripts/projects/gke_cluster_dropdowns/constants.js
+9
-0
app/assets/javascripts/projects/gke_cluster_dropdowns/index.js
...ssets/javascripts/projects/gke_cluster_dropdowns/index.js
+110
-0
No files found.
app/assets/javascripts/pages/projects/clusters/gcp/new/index.js
View file @
e754fafa
/* global gapi */
import
initGkeDropdowns
from
'
~/projects/gke_cluster_dropdowns
'
;
import
Vue
from
'
vue
'
;
import
Flash
from
'
~/flash
'
;
import
{
s__
}
from
'
~/locale
'
;
import
GkeProjectIdDropdown
from
'
~/projects/gke_cluster_dropdowns/components/gke_project_id_dropdown.vue
'
;
import
GkeZoneDropdown
from
'
~/projects/gke_cluster_dropdowns/components/gke_zone_dropdown.vue
'
;
import
GkeMachineTypeDropdown
from
'
~/projects/gke_cluster_dropdowns/components/gke_machine_type_dropdown.vue
'
;
const
GCP_API_ERROR
=
'
ClusterIntegration|An error occurred when trying to contact the Google Cloud API. Please try again later.
'
;
function
mountGkeProjectIdDropdown
()
{
const
el
=
document
.
getElementById
(
'
js-gcp-project-id-dropdown-entry-point
'
);
const
hiddenInput
=
el
.
querySelector
(
'
input
'
);
if
(
!
el
)
return
;
// debugger;
// eslint-disable-next-line no-new
new
Vue
({
el
,
components
:
{
GkeProjectIdDropdown
,
},
render
:
createElement
=>
createElement
(
'
gke-project-id-dropdown
'
,
{
props
:
{
docsUrl
:
el
.
dataset
.
docsurl
,
service
:
gapi
.
client
.
cloudresourcemanager
,
fieldName
:
hiddenInput
.
getAttribute
(
'
name
'
),
fieldId
:
hiddenInput
.
getAttribute
(
'
id
'
),
},
}),
});
}
function
mountGkeZoneDropdown
()
{
const
el
=
document
.
getElementById
(
'
js-gcp-zone-dropdown-entry-point
'
);
const
hiddenInput
=
el
.
querySelector
(
'
input
'
);
if
(
!
el
)
return
;
// debugger;
// eslint-disable-next-line no-new
new
Vue
({
el
,
components
:
{
GkeZoneDropdown
,
},
render
:
createElement
=>
createElement
(
'
gke-zone-dropdown
'
,
{
props
:
{
service
:
gapi
.
client
.
compute
,
fieldName
:
hiddenInput
.
getAttribute
(
'
name
'
),
fieldId
:
hiddenInput
.
getAttribute
(
'
id
'
),
},
}),
});
}
function
mountGkeMachineTypeDropdown
()
{
const
el
=
document
.
getElementById
(
'
js-gcp-machine-type-dropdown-entry-point
'
);
const
hiddenInput
=
el
.
querySelector
(
'
input
'
);
if
(
!
el
)
return
;
// debugger;
// eslint-disable-next-line no-new
new
Vue
({
el
,
components
:
{
GkeMachineTypeDropdown
,
},
render
:
createElement
=>
createElement
(
'
gke-machine-type-dropdown
'
,
{
props
:
{
service
:
gapi
.
client
.
compute
,
fieldName
:
hiddenInput
.
getAttribute
(
'
name
'
),
fieldId
:
hiddenInput
.
getAttribute
(
'
id
'
),
},
}),
});
}
function
initializeGapiClient
()
{
const
el
=
document
.
getElementById
(
'
new_cluster
'
);
gapi
.
client
.
setToken
({
access_token
:
el
.
dataset
.
token
});
gapi
.
client
.
load
(
'
https://www.googleapis.com/discovery/v1/apis/cloudresourcemanager/v1/rest
'
)
.
then
(()
=>
{
mountGkeProjectIdDropdown
();
})
.
catch
(()
=>
{
Flash
(
s__
(
GCP_API_ERROR
));
});
gapi
.
client
.
load
(
'
https://www.googleapis.com/discovery/v1/apis/compute/v1/rest
'
)
.
then
(()
=>
{
mountGkeZoneDropdown
();
mountGkeMachineTypeDropdown
();
})
.
catch
(()
=>
{
Flash
(
s__
(
GCP_API_ERROR
));
});
}
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
if
(
typeof
gapi
===
'
undefined
'
)
{
initGkeDropdowns
();
Flash
(
s__
(
GCP_API_ERROR
));
return
false
;
}
gapi
.
load
(
'
client
'
,
initializeGapiClient
);
});
});
app/assets/javascripts/projects/gke_cluster_dropdowns/components/dropdown_button.vue
View file @
e754fafa
...
@@ -23,7 +23,6 @@ export default {
...
@@ -23,7 +23,6 @@ export default {
default
:
__
(
'
Select
'
),
default
:
__
(
'
Select
'
),
},
},
},
},
computed
:
{},
};
};
</
script
>
</
script
>
...
...
app/assets/javascripts/projects/gke_cluster_dropdowns/constants.js
0 → 100644
View file @
e754fafa
import
{
s__
}
from
'
~/locale
'
;
export
const
GCP_API_ERROR
=
s__
(
'
ClusterIntegration|An error occurred when trying to contact the Google Cloud API. Please try again later.
'
,
);
export
const
GCP_API_CLOUD_RESOURCE_MANAGER_ENDPOINT
=
'
https://www.googleapis.com/discovery/v1/apis/cloudresourcemanager/v1/rest
'
;
export
const
GCP_API_COMPUTE_ENDPOINT
=
'
https://www.googleapis.com/discovery/v1/apis/compute/v1/rest
'
;
app/assets/javascripts/projects/gke_cluster_dropdowns/index.js
0 → 100644
View file @
e754fafa
/* global gapi */
import
Vue
from
'
vue
'
;
import
Flash
from
'
~/flash
'
;
import
GkeProjectIdDropdown
from
'
./components/gke_project_id_dropdown.vue
'
;
import
GkeZoneDropdown
from
'
./components/gke_zone_dropdown.vue
'
;
import
GkeMachineTypeDropdown
from
'
./components/gke_machine_type_dropdown.vue
'
;
import
*
as
CONSTANTS
from
'
./constants
'
;
const
mountGkeProjectIdDropdown
=
()
=>
{
const
el
=
document
.
querySelector
(
'
.js-gcp-project-id-dropdown-entry-point
'
);
const
hiddenInput
=
el
.
querySelector
(
'
input
'
);
if
(
!
el
)
return
false
;
return
new
Vue
({
el
,
components
:
{
GkeProjectIdDropdown
,
},
render
:
createElement
=>
createElement
(
'
gke-project-id-dropdown
'
,
{
props
:
{
docsUrl
:
el
.
dataset
.
docsurl
,
service
:
gapi
.
client
.
cloudresourcemanager
,
fieldName
:
hiddenInput
.
getAttribute
(
'
name
'
),
fieldId
:
hiddenInput
.
getAttribute
(
'
id
'
),
},
}),
});
};
const
mountGkeZoneDropdown
=
()
=>
{
const
el
=
document
.
querySelector
(
'
.js-gcp-zone-dropdown-entry-point
'
);
const
hiddenInput
=
el
.
querySelector
(
'
input
'
);
if
(
!
el
)
return
false
;
return
new
Vue
({
el
,
components
:
{
GkeZoneDropdown
,
},
render
:
createElement
=>
createElement
(
'
gke-zone-dropdown
'
,
{
props
:
{
service
:
gapi
.
client
.
compute
,
fieldName
:
hiddenInput
.
getAttribute
(
'
name
'
),
fieldId
:
hiddenInput
.
getAttribute
(
'
id
'
),
},
}),
});
};
const
mountGkeMachineTypeDropdown
=
()
=>
{
const
el
=
document
.
querySelector
(
'
.js-gcp-machine-type-dropdown-entry-point
'
);
const
hiddenInput
=
el
.
querySelector
(
'
input
'
);
if
(
!
el
)
return
false
;
return
new
Vue
({
el
,
components
:
{
GkeMachineTypeDropdown
,
},
render
:
createElement
=>
createElement
(
'
gke-machine-type-dropdown
'
,
{
props
:
{
service
:
gapi
.
client
.
compute
,
fieldName
:
hiddenInput
.
getAttribute
(
'
name
'
),
fieldId
:
hiddenInput
.
getAttribute
(
'
id
'
),
},
}),
});
};
const
gkeDropdownErrorHandler
=
()
=>
{
Flash
(
CONSTANTS
.
GCP_API_ERROR
);
};
const
initializeGapiClient
=
()
=>
{
const
el
=
document
.
getElementById
(
'
new_cluster
'
);
gapi
.
client
.
setToken
({
access_token
:
el
.
dataset
.
token
});
gapi
.
client
.
load
(
CONSTANTS
.
GCP_API_CLOUD_RESOURCE_MANAGER_ENDPOINT
)
.
then
(()
=>
{
mountGkeProjectIdDropdown
();
})
.
catch
(
gkeDropdownErrorHandler
);
gapi
.
client
.
load
(
CONSTANTS
.
GCP_API_COMPUTE_ENDPOINT
)
.
then
(()
=>
{
mountGkeZoneDropdown
();
mountGkeMachineTypeDropdown
();
})
.
catch
(
gkeDropdownErrorHandler
);
};
const
initGkeDropdowns
=
()
=>
{
if
(
typeof
gapi
===
'
undefined
'
)
{
gkeDropdownErrorHandler
();
return
false
;
}
return
gapi
.
load
(
'
client
'
,
initializeGapiClient
);
};
export
default
initGkeDropdowns
;
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