2021-01-29 00:20:46 +05:30
|
|
|
<script>
|
|
|
|
import { GlAlert, GlBadge, GlKeysetPagination, GlLoadingIcon, GlTab, GlTabs } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { MAX_LIST_COUNT } from '../constants';
|
2021-01-29 00:20:46 +05:30
|
|
|
import getStatesQuery from '../graphql/queries/get_states.query.graphql';
|
|
|
|
import EmptyState from './empty_state.vue';
|
|
|
|
import StatesTable from './states_table.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
apollo: {
|
|
|
|
states: {
|
|
|
|
query: getStatesQuery,
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
projectPath: this.projectPath,
|
|
|
|
...this.cursor,
|
|
|
|
};
|
|
|
|
},
|
2021-03-08 18:12:59 +05:30
|
|
|
update: (data) => data,
|
2021-01-29 00:20:46 +05:30
|
|
|
error() {
|
|
|
|
this.states = null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
EmptyState,
|
|
|
|
GlAlert,
|
|
|
|
GlBadge,
|
|
|
|
GlKeysetPagination,
|
|
|
|
GlLoadingIcon,
|
|
|
|
GlTab,
|
|
|
|
GlTabs,
|
|
|
|
StatesTable,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
emptyStateImage: {
|
|
|
|
required: true,
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
projectPath: {
|
|
|
|
required: true,
|
|
|
|
type: String,
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
terraformAdmin: {
|
|
|
|
required: false,
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-01-29 00:20:46 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
cursor: {
|
|
|
|
first: MAX_LIST_COUNT,
|
|
|
|
after: null,
|
|
|
|
last: null,
|
|
|
|
before: null,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isLoading() {
|
|
|
|
return this.$apollo.queries.states.loading;
|
|
|
|
},
|
|
|
|
pageInfo() {
|
2021-02-22 17:27:13 +05:30
|
|
|
return this.states?.project?.terraformStates?.pageInfo || {};
|
2021-01-29 00:20:46 +05:30
|
|
|
},
|
|
|
|
showPagination() {
|
|
|
|
return this.pageInfo.hasPreviousPage || this.pageInfo.hasNextPage;
|
|
|
|
},
|
|
|
|
statesCount() {
|
2021-02-22 17:27:13 +05:30
|
|
|
return this.states?.project?.terraformStates?.count;
|
2021-01-29 00:20:46 +05:30
|
|
|
},
|
|
|
|
statesList() {
|
2021-02-22 17:27:13 +05:30
|
|
|
return this.states?.project?.terraformStates?.nodes;
|
2021-01-29 00:20:46 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
2021-02-22 17:27:13 +05:30
|
|
|
nextPage(item) {
|
|
|
|
this.cursor = {
|
|
|
|
first: MAX_LIST_COUNT,
|
|
|
|
after: item,
|
|
|
|
last: null,
|
|
|
|
before: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
prevPage(item) {
|
|
|
|
this.cursor = {
|
|
|
|
first: null,
|
|
|
|
after: null,
|
|
|
|
last: MAX_LIST_COUNT,
|
|
|
|
before: item,
|
|
|
|
};
|
2021-01-29 00:20:46 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<section>
|
|
|
|
<gl-tabs>
|
|
|
|
<gl-tab>
|
2021-09-30 23:02:18 +05:30
|
|
|
<template #title>
|
2021-01-29 00:20:46 +05:30
|
|
|
<p class="gl-m-0">
|
|
|
|
{{ s__('Terraform|States') }}
|
|
|
|
<gl-badge v-if="statesCount">{{ statesCount }}</gl-badge>
|
|
|
|
</p>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<gl-loading-icon v-if="isLoading" size="md" class="gl-mt-3" />
|
|
|
|
|
|
|
|
<div v-else-if="statesList">
|
|
|
|
<div v-if="statesCount">
|
2021-02-22 17:27:13 +05:30
|
|
|
<states-table :states="statesList" :terraform-admin="terraformAdmin" />
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
<div v-if="showPagination" class="gl-display-flex gl-justify-content-center gl-mt-5">
|
2021-02-22 17:27:13 +05:30
|
|
|
<gl-keyset-pagination v-bind="pageInfo" @prev="prevPage" @next="nextPage" />
|
2021-01-29 00:20:46 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<empty-state v-else :image="emptyStateImage" />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<gl-alert v-else variant="danger" :dismissible="false">
|
|
|
|
{{ s__('Terraform|An error occurred while loading your Terraform States') }}
|
|
|
|
</gl-alert>
|
|
|
|
</gl-tab>
|
|
|
|
</gl-tabs>
|
|
|
|
</section>
|
|
|
|
</template>
|