Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-25 03:10:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-25 03:10:49 +0300
commit4f79a3041736aadda887ebec4178731eb8681cff (patch)
tree57b76f5fccfe112eedc64916ac2719b917616299 /app/assets/javascripts/google_cloud
parent1f3baf00bfdff196b43ade455d8268ce10ff13aa (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/google_cloud')
-rw-r--r--app/assets/javascripts/google_cloud/components/errors/gcp_error.vue29
-rw-r--r--app/assets/javascripts/google_cloud/components/errors/no_gcp_projects.vue26
-rw-r--r--app/assets/javascripts/google_cloud/components/screens/app.vue (renamed from app/assets/javascripts/google_cloud/components/app.vue)8
-rw-r--r--app/assets/javascripts/google_cloud/components/screens/service_accounts_form.vue81
-rw-r--r--app/assets/javascripts/google_cloud/components/service_accounts_list.vue (renamed from app/assets/javascripts/google_cloud/components/service_accounts.vue)0
-rw-r--r--app/assets/javascripts/google_cloud/index.js37
6 files changed, 173 insertions, 8 deletions
diff --git a/app/assets/javascripts/google_cloud/components/errors/gcp_error.vue b/app/assets/javascripts/google_cloud/components/errors/gcp_error.vue
new file mode 100644
index 00000000000..90aa0e1ae68
--- /dev/null
+++ b/app/assets/javascripts/google_cloud/components/errors/gcp_error.vue
@@ -0,0 +1,29 @@
+<script>
+import { GlAlert } from '@gitlab/ui';
+import { __ } from '~/locale';
+
+export default {
+ components: { GlAlert },
+ props: {
+ error: {
+ type: String,
+ required: true,
+ },
+ },
+ i18n: {
+ title: __('Google Cloud project misconfigured'),
+ description: __(
+ 'GitLab and Google Cloud configuration seems to be incomplete. This probably can be fixed by your GitLab administration team. You may share these logs with them:',
+ ),
+ },
+};
+</script>
+
+<template>
+ <gl-alert :dismissible="false" variant="warning" :title="$options.i18n.title">
+ {{ $options.i18n.description }}
+ <blockquote>
+ <code>{{ error }}</code>
+ </blockquote>
+ </gl-alert>
+</template>
diff --git a/app/assets/javascripts/google_cloud/components/errors/no_gcp_projects.vue b/app/assets/javascripts/google_cloud/components/errors/no_gcp_projects.vue
new file mode 100644
index 00000000000..da229ac3f0e
--- /dev/null
+++ b/app/assets/javascripts/google_cloud/components/errors/no_gcp_projects.vue
@@ -0,0 +1,26 @@
+<script>
+import { GlAlert, GlButton } from '@gitlab/ui';
+import { __ } from '~/locale';
+
+export default {
+ components: { GlAlert, GlButton },
+ i18n: {
+ title: __('Google Cloud project required'),
+ description: __(
+ 'You do not have any Google Cloud projects. Please create a Google Cloud project and then reload this page.',
+ ),
+ createLabel: __('Create Google Cloud project'),
+ },
+};
+</script>
+
+<template>
+ <gl-alert :dismissible="false" variant="warning" :title="$options.i18n.title">
+ {{ $options.i18n.description }}
+ <template #actions>
+ <gl-button href="https://console.cloud.google.com/projectcreate" target="_blank">
+ {{ $options.i18n.createLabel }}
+ </gl-button>
+ </template>
+ </gl-alert>
+</template>
diff --git a/app/assets/javascripts/google_cloud/components/app.vue b/app/assets/javascripts/google_cloud/components/screens/app.vue
index 1e5be9df019..52c9b478916 100644
--- a/app/assets/javascripts/google_cloud/components/app.vue
+++ b/app/assets/javascripts/google_cloud/components/screens/app.vue
@@ -1,10 +1,10 @@
<script>
import { GlTab, GlTabs } from '@gitlab/ui';
-import IncubationBanner from './incubation_banner.vue';
-import ServiceAccounts from './service_accounts.vue';
+import IncubationBanner from '../incubation_banner.vue';
+import ServiceAccountsList from '../service_accounts_list.vue';
export default {
- components: { GlTab, GlTabs, IncubationBanner, ServiceAccounts },
+ components: { GlTab, GlTabs, IncubationBanner, ServiceAccountsList },
props: {
serviceAccounts: {
type: Array,
@@ -36,7 +36,7 @@ export default {
/>
<gl-tabs>
<gl-tab :title="__('Configuration')">
- <service-accounts
+ <service-accounts-list
class="gl-mx-3"
:list="serviceAccounts"
:create-url="createServiceAccountUrl"
diff --git a/app/assets/javascripts/google_cloud/components/screens/service_accounts_form.vue b/app/assets/javascripts/google_cloud/components/screens/service_accounts_form.vue
new file mode 100644
index 00000000000..6aead296918
--- /dev/null
+++ b/app/assets/javascripts/google_cloud/components/screens/service_accounts_form.vue
@@ -0,0 +1,81 @@
+<script>
+import { GlButton, GlFormGroup, GlFormSelect } from '@gitlab/ui';
+import { __ } from '~/locale';
+import IncubationBanner from '../incubation_banner.vue';
+
+export default {
+ components: { GlButton, GlFormGroup, GlFormSelect, IncubationBanner },
+ props: {
+ gcpProjects: { required: true, type: Array },
+ environments: { required: true, type: Array },
+ cancelPath: { required: true, type: String },
+ },
+ methods: {
+ feedbackUrl(template) {
+ return `https://gitlab.com/gitlab-org/incubation-engineering/five-minute-production/meta/-/issues/new?issuable_template=${template}`;
+ },
+ },
+ i18n: {
+ title: __('Create service account'),
+ gcpProjectLabel: __('Google Cloud project'),
+ gcpProjectDescription: __(
+ 'New service account is generated for the selected Google Cloud project',
+ ),
+ environmentLabel: __('Environment'),
+ environmentDescription: __('Generated service account is linked to the selected environment'),
+ submitLabel: __('Create service account'),
+ cancelLabel: __('Cancel'),
+ },
+};
+</script>
+
+<template>
+ <div>
+ <incubation-banner
+ :share-feedback-url="feedbackUrl('general_feedback')"
+ :report-bug-url="feedbackUrl('report_bug')"
+ :feature-request-url="feedbackUrl('feature_request')"
+ />
+ <header class="gl-my-5 gl-border-b-1 gl-border-b-gray-100 gl-border-b-solid">
+ <h2 class="gl-font-size-h1">{{ $options.i18n.title }}</h2>
+ </header>
+ <gl-form-group
+ label-for="gcp_project"
+ :label="$options.i18n.gcpProjectLabel"
+ :description="$options.i18n.gcpProjectDescription"
+ >
+ <gl-form-select id="gcp_project" name="gcp_project" required>
+ <option
+ v-for="gcpProject in gcpProjects"
+ :key="gcpProject.project_id"
+ :value="gcpProject.project_id"
+ >
+ {{ gcpProject.name }}
+ </option>
+ </gl-form-select>
+ </gl-form-group>
+ <gl-form-group
+ label-for="environment"
+ :label="$options.i18n.environmentLabel"
+ :description="$options.i18n.environmentDescription"
+ >
+ <gl-form-select id="environment" name="environment" required>
+ <option value="*">{{ __('All') }}</option>
+ <option
+ v-for="environment in environments"
+ :key="environment.name"
+ :value="environment.name"
+ >
+ {{ environment.name }}
+ </option>
+ </gl-form-select>
+ </gl-form-group>
+
+ <div class="form-actions row">
+ <gl-button type="submit" category="primary" variant="confirm">
+ {{ $options.i18n.submitLabel }}
+ </gl-button>
+ <gl-button class="gl-ml-1" :href="cancelPath">{{ $options.i18n.cancelLabel }}</gl-button>
+ </div>
+ </div>
+</template>
diff --git a/app/assets/javascripts/google_cloud/components/service_accounts.vue b/app/assets/javascripts/google_cloud/components/service_accounts_list.vue
index b70b25a5dc3..b70b25a5dc3 100644
--- a/app/assets/javascripts/google_cloud/components/service_accounts.vue
+++ b/app/assets/javascripts/google_cloud/components/service_accounts_list.vue
diff --git a/app/assets/javascripts/google_cloud/index.js b/app/assets/javascripts/google_cloud/index.js
index a156a632e9a..ba67877e005 100644
--- a/app/assets/javascripts/google_cloud/index.js
+++ b/app/assets/javascripts/google_cloud/index.js
@@ -1,11 +1,40 @@
import Vue from 'vue';
-import App from './components/app.vue';
+import { __ } from '~/locale';
+import App from './components/screens/app.vue';
+import ServiceAccountsForm from './components/screens/service_accounts_form.vue';
+import ErrorNoGcpProjects from './components/errors/no_gcp_projects.vue';
+import ErrorGcpError from './components/errors/gcp_error.vue';
const elementRenderer = (element, props = {}) => (createElement) =>
createElement(element, { props });
+const rootComponentMap = [
+ {
+ root: '#js-google-cloud-error-no-gcp-projects',
+ component: ErrorNoGcpProjects,
+ },
+ {
+ root: '#js-google-cloud-error-gcp-error',
+ component: ErrorGcpError,
+ },
+ {
+ root: '#js-google-cloud-service-accounts',
+ component: ServiceAccountsForm,
+ },
+ {
+ root: '#js-google-cloud',
+ component: App,
+ },
+];
+
export default () => {
- const root = document.querySelector('#js-google-cloud');
- const props = JSON.parse(root.getAttribute('data'));
- return new Vue({ el: root, render: elementRenderer(App, props) });
+ for (let i = 0; i < rootComponentMap.length; i += 1) {
+ const { root, component } = rootComponentMap[i];
+ const element = document.querySelector(root);
+ if (element) {
+ const props = JSON.parse(element.getAttribute('data'));
+ return new Vue({ el: root, render: elementRenderer(component, props) });
+ }
+ }
+ throw new Error(__('Unknown root'));
};