summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-25 12:25:58 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-25 12:25:58 +0000
commit21fb7a5e5b6be5c58845460e3a2f9de0c1cfab8c (patch)
tree0a83af79fb27c52ecfd168ddc24648d45943d952 /app/assets/javascripts
parentc052f86b6b4d2428b62a2baac77aee4cc91fc2b1 (diff)
downloadgitlab-ce-21fb7a5e5b6be5c58845460e3a2f9de0c1cfab8c.tar.gz
Add latest changes from gitlab-org/gitlab@15-8-stable-ee
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/projects/commit/components/branches_dropdown.vue67
-rw-r--r--app/assets/javascripts/projects/commit/components/form_modal.vue13
-rw-r--r--app/assets/javascripts/projects/commit/components/projects_dropdown.vue57
3 files changed, 95 insertions, 42 deletions
diff --git a/app/assets/javascripts/projects/commit/components/branches_dropdown.vue b/app/assets/javascripts/projects/commit/components/branches_dropdown.vue
index a1fc3f1a731..a037e721677 100644
--- a/app/assets/javascripts/projects/commit/components/branches_dropdown.vue
+++ b/app/assets/javascripts/projects/commit/components/branches_dropdown.vue
@@ -1,5 +1,11 @@
<script>
-import { GlCollapsibleListbox } from '@gitlab/ui';
+import {
+ GlDropdown,
+ GlSearchBoxByType,
+ GlDropdownItem,
+ GlDropdownText,
+ GlLoadingIcon,
+} from '@gitlab/ui';
import { mapActions, mapGetters, mapState } from 'vuex';
import {
I18N_NO_RESULTS_MESSAGE,
@@ -10,7 +16,11 @@ import {
export default {
name: 'BranchesDropdown',
components: {
- GlCollapsibleListbox,
+ GlDropdown,
+ GlSearchBoxByType,
+ GlDropdownItem,
+ GlDropdownText,
+ GlLoadingIcon,
},
props: {
value: {
@@ -36,16 +46,13 @@ export default {
},
computed: {
...mapGetters(['joinedBranches']),
- ...mapState(['isFetching']),
+ ...mapState(['isFetching', 'branch', 'branches']),
filteredResults() {
const lowerCasedSearchTerm = this.searchTerm.toLowerCase();
return this.joinedBranches.filter((resultString) =>
resultString.toLowerCase().includes(lowerCasedSearchTerm),
);
},
- listboxItems() {
- return this.filteredResults.map((value) => ({ value, text: value }));
- },
},
watch: {
// Parent component can set the branch value (e.g. when the user selects a different project)
@@ -61,6 +68,10 @@ export default {
...mapActions(['fetchBranches']),
selectBranch(branch) {
this.$emit('selectBranch', branch);
+ this.searchTerm = branch; // enables isSelected to work as expected
+ },
+ isSelected(selectedBranch) {
+ return selectedBranch === this.branch;
},
searchTermChanged(value) {
this.searchTerm = value;
@@ -70,16 +81,36 @@ export default {
};
</script>
<template>
- <gl-collapsible-listbox
- :header-text="$options.i18n.branchHeaderTitle"
- :toggle-text="value"
- :items="listboxItems"
- searchable
- :search-placeholder="$options.i18n.branchSearchPlaceholder"
- :searching="isFetching"
- :selected="value"
- :no-results-text="$options.i18n.noResultsMessage"
- @search="searchTermChanged"
- @select="selectBranch"
- />
+ <gl-dropdown :text="value" :header-text="$options.i18n.branchHeaderTitle">
+ <gl-search-box-by-type
+ :value="searchTerm"
+ trim
+ autocomplete="off"
+ :debounce="250"
+ :placeholder="$options.i18n.branchSearchPlaceholder"
+ data-testid="dropdown-search-box"
+ @input="searchTermChanged"
+ />
+ <gl-dropdown-item
+ v-for="branch in filteredResults"
+ v-show="!isFetching"
+ :key="branch"
+ :name="branch"
+ :is-checked="isSelected(branch)"
+ is-check-item
+ data-testid="dropdown-item"
+ @click="selectBranch(branch)"
+ >
+ {{ branch }}
+ </gl-dropdown-item>
+ <gl-dropdown-text v-show="isFetching" data-testid="dropdown-text-loading-icon">
+ <gl-loading-icon size="sm" class="gl-mx-auto" />
+ </gl-dropdown-text>
+ <gl-dropdown-text
+ v-if="!filteredResults.length && !isFetching"
+ data-testid="empty-result-message"
+ >
+ <span class="gl-text-gray-500">{{ $options.i18n.noResultsMessage }}</span>
+ </gl-dropdown-text>
+ </gl-dropdown>
</template>
diff --git a/app/assets/javascripts/projects/commit/components/form_modal.vue b/app/assets/javascripts/projects/commit/components/form_modal.vue
index b31ba4a100c..1febe8ceaab 100644
--- a/app/assets/javascripts/projects/commit/components/form_modal.vue
+++ b/app/assets/javascripts/projects/commit/components/form_modal.vue
@@ -141,7 +141,11 @@ export default {
:value="targetProjectId"
/>
- <projects-dropdown :value="targetProjectName" @selectProject="setSelectedProject" />
+ <projects-dropdown
+ class="gl-w-half"
+ :value="targetProjectName"
+ @selectProject="setSelectedProject"
+ />
</gl-form-group>
<gl-form-group
@@ -151,7 +155,12 @@ export default {
>
<input id="start_branch" type="hidden" name="start_branch" :value="branch" />
- <branches-dropdown :value="branch" :blanked="isRevert" @selectBranch="setBranch" />
+ <branches-dropdown
+ class="gl-w-half"
+ :value="branch"
+ :blanked="isRevert"
+ @selectBranch="setBranch"
+ />
</gl-form-group>
<gl-form-checkbox
diff --git a/app/assets/javascripts/projects/commit/components/projects_dropdown.vue b/app/assets/javascripts/projects/commit/components/projects_dropdown.vue
index d43f5b99e2c..6288bcdaad0 100644
--- a/app/assets/javascripts/projects/commit/components/projects_dropdown.vue
+++ b/app/assets/javascripts/projects/commit/components/projects_dropdown.vue
@@ -1,5 +1,5 @@
<script>
-import { GlCollapsibleListbox } from '@gitlab/ui';
+import { GlDropdown, GlSearchBoxByType, GlDropdownItem, GlDropdownText } from '@gitlab/ui';
import { mapGetters, mapState } from 'vuex';
import {
I18N_NO_RESULTS_MESSAGE,
@@ -10,7 +10,10 @@ import {
export default {
name: 'ProjectsDropdown',
components: {
- GlCollapsibleListbox,
+ GlDropdown,
+ GlSearchBoxByType,
+ GlDropdownItem,
+ GlDropdownText,
},
props: {
value: {
@@ -38,20 +41,17 @@ export default {
project.name.toLowerCase().includes(lowerCasedFilterTerm),
);
},
- listboxItems() {
- return this.filteredResults.map(({ id, name }) => ({ value: id, text: name }));
- },
selectedProject() {
return this.sortedProjects.find((project) => project.id === this.targetProjectId) || {};
},
},
methods: {
- selectProject(value) {
- this.$emit('selectProject', value);
-
- // when we select a project, we want the dropdown to filter to the selected project
- const project = this.listboxItems.find((x) => x.value === value);
- this.filterTerm = project?.text || '';
+ selectProject(project) {
+ this.$emit('selectProject', project.id);
+ this.filterTerm = project.name; // when we select a project, we want the dropdown to filter to the selected project
+ },
+ isSelected(selectedProject) {
+ return selectedProject === this.selectedProject;
},
filterTermChanged(value) {
this.filterTerm = value;
@@ -60,15 +60,28 @@ export default {
};
</script>
<template>
- <gl-collapsible-listbox
- :header-text="$options.i18n.projectHeaderTitle"
- :items="listboxItems"
- searchable
- :search-placeholder="$options.i18n.projectSearchPlaceholder"
- :selected="selectedProject.id"
- :toggle-text="selectedProject.name"
- :no-results-text="$options.i18n.noResultsMessage"
- @search="filterTermChanged"
- @select="selectProject"
- />
+ <gl-dropdown :text="selectedProject.name" :header-text="$options.i18n.projectHeaderTitle">
+ <gl-search-box-by-type
+ :value="filterTerm"
+ trim
+ autocomplete="off"
+ :placeholder="$options.i18n.projectSearchPlaceholder"
+ data-testid="dropdown-search-box"
+ @input="filterTermChanged"
+ />
+ <gl-dropdown-item
+ v-for="project in filteredResults"
+ :key="project.name"
+ :name="project.name"
+ :is-checked="isSelected(project)"
+ is-check-item
+ data-testid="dropdown-item"
+ @click="selectProject(project)"
+ >
+ {{ project.name }}
+ </gl-dropdown-item>
+ <gl-dropdown-text v-if="!filteredResults.length" data-testid="empty-result-message">
+ <span class="gl-text-gray-500">{{ $options.i18n.noResultsMessage }}</span>
+ </gl-dropdown-text>
+ </gl-dropdown>
</template>