summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/terraform/components/terraform_list.vue
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/terraform/components/terraform_list.vue')
-rw-r--r--app/assets/javascripts/terraform/components/terraform_list.vue58
1 files changed, 26 insertions, 32 deletions
diff --git a/app/assets/javascripts/terraform/components/terraform_list.vue b/app/assets/javascripts/terraform/components/terraform_list.vue
index f614bdc8d43..26a0bfe5fa5 100644
--- a/app/assets/javascripts/terraform/components/terraform_list.vue
+++ b/app/assets/javascripts/terraform/components/terraform_list.vue
@@ -15,13 +15,7 @@ export default {
...this.cursor,
};
},
- update: data => {
- return {
- count: data?.project?.terraformStates?.count,
- list: data?.project?.terraformStates?.nodes,
- pageInfo: data?.project?.terraformStates?.pageInfo,
- };
- },
+ update: data => data,
error() {
this.states = null;
},
@@ -46,6 +40,11 @@ export default {
required: true,
type: String,
},
+ terraformAdmin: {
+ required: false,
+ type: Boolean,
+ default: false,
+ },
},
data() {
return {
@@ -62,35 +61,34 @@ export default {
return this.$apollo.queries.states.loading;
},
pageInfo() {
- return this.states?.pageInfo || {};
+ return this.states?.project?.terraformStates?.pageInfo || {};
},
showPagination() {
return this.pageInfo.hasPreviousPage || this.pageInfo.hasNextPage;
},
statesCount() {
- return this.states?.count;
+ return this.states?.project?.terraformStates?.count;
},
statesList() {
- return this.states?.list;
+ return this.states?.project?.terraformStates?.nodes;
},
},
methods: {
- updatePagination(item) {
- if (item === this.pageInfo.endCursor) {
- this.cursor = {
- first: MAX_LIST_COUNT,
- after: item,
- last: null,
- before: null,
- };
- } else {
- this.cursor = {
- first: null,
- after: null,
- last: MAX_LIST_COUNT,
- before: item,
- };
- }
+ 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,
+ };
},
},
};
@@ -111,14 +109,10 @@ export default {
<div v-else-if="statesList">
<div v-if="statesCount">
- <states-table :states="statesList" />
+ <states-table :states="statesList" :terraform-admin="terraformAdmin" />
<div v-if="showPagination" class="gl-display-flex gl-justify-content-center gl-mt-5">
- <gl-keyset-pagination
- v-bind="pageInfo"
- @prev="updatePagination"
- @next="updatePagination"
- />
+ <gl-keyset-pagination v-bind="pageInfo" @prev="prevPage" @next="nextPage" />
</div>
</div>