Commit 0a37ac11 authored by Darby Frey's avatar Darby Frey

Adding pagination and loading spinner to secure files table

parent bddbdc7c
...@@ -958,10 +958,10 @@ const Api = { ...@@ -958,10 +958,10 @@ const Api = {
return axios.get(url, { params: { per_page: DEFAULT_PER_PAGE, ...params } }); return axios.get(url, { params: { per_page: DEFAULT_PER_PAGE, ...params } });
}, },
projectSecureFiles(projectId){ projectSecureFiles(projectId, options = {}){
const url = Api.buildUrl(this.secureFilesPath).replace(':project_id', projectId); const url = Api.buildUrl(this.secureFilesPath).replace(':project_id', projectId);
return axios.get(url); return axios.get(url, { params: { per_page: DEFAULT_PER_PAGE, ...options } });
}, },
async updateNotificationSettings(projectId, groupId, data = {}) { async updateNotificationSettings(projectId, groupId, data = {}) {
......
<script> <script>
import { GlTable, GlButton, GlIcon } from '@gitlab/ui'; import Api, { DEFAULT_PER_PAGE } from '~/api';
import Api from '~/api'; import { GlButton, GlIcon, GlLink, GlLoadingIcon, GlPagination, GlTable } from '@gitlab/ui';
import { helpPagePath } from '~/helpers/help_page_helper';
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
export default { export default {
props: { inject: ['projectId'],
projectId: { docsLink: helpPagePath('ci/secure_files/index'),
type: String, DEFAULT_PER_PAGE,
required: true, i18n: {
pagination: {
next: __('Next'),
prev: __('Prev'),
}, },
}, },
data() { data() {
return { return {
page: 1,
totalItems: 0,
loading: false,
projectSecureFiles: [], projectSecureFiles: [],
}; };
}, },
fields: [ fields: [
{ {
key: 'name', key: 'name',
label: s__('ciSecureFiles|Filename'), label: s__('Filename'),
}, },
{ {
key: 'permissions', key: 'permissions',
label: s__('ciSecureFiles|Permissions'), label: s__('Permissions'),
tdClass: 'text-plain', tdClass: 'text-plain',
}, },
{ {
key: 'created_at', key: 'created_at',
label: s__('ciSecureFiles|Created'), label: s__('Created'),
}, },
], ],
components: { components: {
GlTable,
GlButton, GlButton,
GlIcon, GlIcon,
GlLink,
GlLoadingIcon,
GlPagination,
GlTable,
helpPagePath,
TimeagoTooltip, TimeagoTooltip,
}, },
computed: { computed: {
...@@ -45,10 +56,23 @@ export default { ...@@ -45,10 +56,23 @@ export default {
created() { created() {
this.getProjectSecureFiles(); this.getProjectSecureFiles();
}, },
watch: {
page(newPage) {
this.getProjectSecureFiles(newPage);
},
},
methods: { methods: {
async getProjectSecureFiles(){ async getProjectSecureFiles(page){
const response = await Api.projectSecureFiles(this.projectId) this.loading = true;
const response = await Api.projectSecureFiles(this.projectId, {page: page})
if (this.totalItems === 0) {
this.totalItems = parseInt(response.headers?.['x-total'], 10) || 0;
}
this.projectSecureFiles = response.data this.projectSecureFiles = response.data
this.loading = false;
} }
} }
}; };
...@@ -57,15 +81,16 @@ export default { ...@@ -57,15 +81,16 @@ export default {
<template> <template>
<div> <div>
<h2 data-testid="title" class="gl-font-size-h1 gl-mt-3 gl-mb-0">Secure Files</h2> <h1 data-testid="title" class="gl-font-size-h1 gl-mt-3 gl-mb-0">Secure Files</h1>
<p> <p>
<span data-testid="info-message" class="gl-mr-2"> <span data-testid="info-message" class="gl-mr-2">
Use Secure Files to store files used by your pipelines such as Android keystores, or Apple provisioning profiles and signing certificates. <a href="" rel="noopener" target="_blank" class="gl-link">More information</a> Use Secure Files to store files used by your pipelines such as Android keystores, or Apple provisioning profiles and signing certificates. <gl-link :href="$options.docsLink" target="_blank">More information</gl-link>
</span> </span>
</p> </p>
<gl-table <gl-table
:busy="loading"
:fields="fields" :fields="fields"
:items="this.projectSecureFiles" :items="this.projectSecureFiles"
tbody-tr-class="js-ci-secure-files-row" tbody-tr-class="js-ci-secure-files-row"
...@@ -78,6 +103,10 @@ export default { ...@@ -78,6 +103,10 @@ export default {
sort-icon-left sort-icon-left
no-sort-reset no-sort-reset
> >
<template #table-busy>
<gl-loading-icon size="lg" class="gl-my-5" />
</template>
<template #cell(name)="{ item }"> <template #cell(name)="{ item }">
{{item.name}} {{item.name}}
</template> </template>
...@@ -91,5 +120,14 @@ export default { ...@@ -91,5 +120,14 @@ export default {
</template> </template>
</gl-table> </gl-table>
<gl-pagination
v-if="!loading"
v-model="page"
:per-page="$options.DEFAULT_PER_PAGE"
:total-items="totalItems"
:next-text="$options.i18n.pagination.next"
:prev-text="$options.i18n.pagination.prev"
align="center"
/>
</div> </div>
</template> </template>
...@@ -7,10 +7,11 @@ export const initCiSecureFiles = ( selector = '#js-ci-secure-files') => { ...@@ -7,10 +7,11 @@ export const initCiSecureFiles = ( selector = '#js-ci-secure-files') => {
return new Vue({ return new Vue({
el: containerEl, el: containerEl,
provide: {
projectId
},
render(createElement) { render(createElement) {
return createElement(SecureFilesList, { return createElement(SecureFilesList);
props: { projectId: projectId },
});
}, },
}); });
}; };
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
- content_for :prefetch_asset_tags do - content_for :prefetch_asset_tags do
- webpack_preload_asset_tag('monaco') - webpack_preload_asset_tag('monaco')
#js-ci-secure-files{ data: { project_id: @project.id } } #js-ci-secure-files{ data: { project_id: @project.id } }
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment