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-05-19 18:44:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /app/assets/javascripts/jira_connect
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/assets/javascripts/jira_connect')
-rw-r--r--app/assets/javascripts/jira_connect/components/groups_list.vue32
-rw-r--r--app/assets/javascripts/jira_connect/constants.js3
2 files changed, 25 insertions, 10 deletions
diff --git a/app/assets/javascripts/jira_connect/components/groups_list.vue b/app/assets/javascripts/jira_connect/components/groups_list.vue
index 275ff820419..d764f778a9d 100644
--- a/app/assets/javascripts/jira_connect/components/groups_list.vue
+++ b/app/assets/javascripts/jira_connect/components/groups_list.vue
@@ -1,7 +1,7 @@
<script>
import { GlLoadingIcon, GlPagination, GlAlert, GlSearchBoxByType } from '@gitlab/ui';
import { fetchGroups } from '~/jira_connect/api';
-import { defaultPerPage } from '~/jira_connect/constants';
+import { DEFAULT_GROUPS_PER_PAGE, MINIMUM_SEARCH_TERM_LENGTH } from '~/jira_connect/constants';
import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils';
import { s__ } from '~/locale';
import GroupsListItem from './groups_list_item.vue';
@@ -25,24 +25,33 @@ export default {
isLoadingInitial: true,
isLoadingMore: false,
page: 1,
- perPage: defaultPerPage,
totalItems: 0,
errorMessage: null,
+ searchTerm: '',
};
},
+ computed: {
+ showPagination() {
+ return this.totalItems > this.$options.DEFAULT_GROUPS_PER_PAGE && this.groups.length > 0;
+ },
+ },
mounted() {
return this.loadGroups().finally(() => {
this.isLoadingInitial = false;
});
},
methods: {
- loadGroups({ searchTerm } = {}) {
- this.isLoadingMore = true;
+ loadGroups() {
+ // fetchGroups returns no results for search terms 0 < {length} < 3.
+ // The desired UX is to return the unfiltered results for searches {length} < 3.
+ // Here, we set the search to an empty string if {length} < 3
+ const search = this.searchTerm?.length < MINIMUM_SEARCH_TERM_LENGTH ? '' : this.searchTerm;
+ this.isLoadingMore = true;
return fetchGroups(this.groupsPath, {
page: this.page,
- perPage: this.perPage,
- search: searchTerm,
+ perPage: this.$options.DEFAULT_GROUPS_PER_PAGE,
+ search,
})
.then((response) => {
const { page, total } = parseIntPagination(normalizeHeaders(response.headers));
@@ -58,9 +67,14 @@ export default {
});
},
onGroupSearch(searchTerm) {
- return this.loadGroups({ searchTerm });
+ // keep a copy of the search term for pagination
+ this.searchTerm = searchTerm;
+ // reset the current page
+ this.page = 1;
+ return this.loadGroups();
},
},
+ DEFAULT_GROUPS_PER_PAGE,
};
</script>
@@ -102,10 +116,10 @@ export default {
<div class="gl-display-flex gl-justify-content-center gl-mt-5">
<gl-pagination
- v-if="totalItems > perPage && groups.length > 0"
+ v-if="showPagination"
v-model="page"
class="gl-mb-0"
- :per-page="perPage"
+ :per-page="$options.DEFAULT_GROUPS_PER_PAGE"
:total-items="totalItems"
@input="loadGroups"
/>
diff --git a/app/assets/javascripts/jira_connect/constants.js b/app/assets/javascripts/jira_connect/constants.js
index 63b79581a1b..8dff83eabb5 100644
--- a/app/assets/javascripts/jira_connect/constants.js
+++ b/app/assets/javascripts/jira_connect/constants.js
@@ -1,2 +1,3 @@
-export const defaultPerPage = 10;
+export const DEFAULT_GROUPS_PER_PAGE = 10;
export const ALERT_LOCALSTORAGE_KEY = 'gitlab_alert';
+export const MINIMUM_SEARCH_TERM_LENGTH = 3;