debian-mirror-gitlab/app/assets/javascripts/clusters/components/crossplane_provider_stack.vue

94 lines
2.2 KiB
Vue
Raw Normal View History

2019-12-26 22:10:19 +05:30
<script>
2021-01-03 14:25:43 +05:30
import { GlDropdown, GlDropdownItem, GlIcon } from '@gitlab/ui';
2019-12-26 22:10:19 +05:30
import { s__ } from '../../locale';
export default {
name: 'CrossplaneProviderStack',
components: {
2021-01-03 14:25:43 +05:30
GlDropdown,
GlDropdownItem,
2020-01-01 13:55:28 +05:30
GlIcon,
2019-12-26 22:10:19 +05:30
},
props: {
stacks: {
type: Array,
required: false,
default: () => [
{
name: s__('Google Cloud Platform'),
code: 'gcp',
},
{
name: s__('Amazon Web Services'),
code: 'aws',
},
{
name: s__('Microsoft Azure'),
code: 'azure',
},
{
name: s__('Rook'),
code: 'rook',
},
],
},
crossplane: {
type: Object,
required: true,
},
},
computed: {
dropdownText() {
const result = this.stacks.reduce((map, obj) => {
// eslint-disable-next-line no-param-reassign
map[obj.code] = obj.name;
return map;
}, {});
const { stack } = this.crossplane;
if (stack !== '') {
return result[stack];
}
return s__('Select Stack');
},
validationError() {
return this.crossplane.validationError;
},
},
methods: {
selectStack(stack) {
this.$emit('set', stack);
},
},
};
</script>
<template>
<div>
<label>
{{ s__('ClusterIntegration|Enabled stack') }}
</label>
2021-01-03 14:25:43 +05:30
<gl-dropdown
2019-12-26 22:10:19 +05:30
:disabled="crossplane.installed"
:text="dropdownText"
toggle-class="dropdown-menu-toggle gl-field-error-outline"
class="w-100"
:class="{ 'gl-show-field-errors': validationError }"
>
2021-01-03 14:25:43 +05:30
<gl-dropdown-item v-for="stack in stacks" :key="stack.code" @click="selectStack(stack)">
2019-12-26 22:10:19 +05:30
<span class="ml-1">{{ stack.name }}</span>
2021-01-03 14:25:43 +05:30
</gl-dropdown-item>
</gl-dropdown>
2019-12-26 22:10:19 +05:30
<span v-if="validationError" class="gl-field-error">{{ validationError }}</span>
<p class="form-text text-muted">
{{ s__(`You must select a stack for configuring your cloud provider. Learn more about`) }}
<a
href="https://crossplane.io/docs/master/stacks-guide.html"
target="_blank"
rel="noopener noreferrer"
2020-01-01 13:55:28 +05:30
>{{ __('Crossplane') }}
<gl-icon name="external-link" class="vertical-align-middle" />
</a>
2019-12-26 22:10:19 +05:30
</p>
</div>
</template>