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>2023-01-26 21:07:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-26 21:07:51 +0300
commitcea01cb81787f0d2c119b287a5833f2e267324bc (patch)
treeca37d57c1ec57ef2fa475e6489c4c107cce89dbc /app/assets/javascripts/vue_shared
parentee24c7d68f57a67754a5d1e2ea99f688029d14bd (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/vue_shared')
-rw-r--r--app/assets/javascripts/vue_shared/components/entity_select/entity_select.vue3
-rw-r--r--app/assets/javascripts/vue_shared/components/entity_select/init_project_selects.js20
-rw-r--r--app/assets/javascripts/vue_shared/components/entity_select/project_select.vue75
3 files changed, 85 insertions, 13 deletions
diff --git a/app/assets/javascripts/vue_shared/components/entity_select/entity_select.vue b/app/assets/javascripts/vue_shared/components/entity_select/entity_select.vue
index 42a37eef1eb..45c50dce8ce 100644
--- a/app/assets/javascripts/vue_shared/components/entity_select/entity_select.vue
+++ b/app/assets/javascripts/vue_shared/components/entity_select/entity_select.vue
@@ -170,6 +170,9 @@ export default {
<template>
<gl-form-group :label="label">
<slot name="error"></slot>
+ <template v-if="Boolean($scopedSlots.label)" #label>
+ <slot name="label"></slot>
+ </template>
<gl-collapsible-listbox
ref="listbox"
v-model="selected"
diff --git a/app/assets/javascripts/vue_shared/components/entity_select/init_project_selects.js b/app/assets/javascripts/vue_shared/components/entity_select/init_project_selects.js
index eee90b0f4f7..1afbeda74c4 100644
--- a/app/assets/javascripts/vue_shared/components/entity_select/init_project_selects.js
+++ b/app/assets/javascripts/vue_shared/components/entity_select/init_project_selects.js
@@ -11,8 +11,18 @@ export const initProjectSelects = () => {
}
document.querySelectorAll(SELECTOR).forEach((el) => {
- const { label, inputName, inputId, groupId, selected: initialSelection } = el.dataset;
- const clearable = parseBoolean(el.dataset.clearable);
+ const {
+ label,
+ inputName,
+ inputId,
+ groupId,
+ userId,
+ orderBy,
+ selected: initialSelection,
+ } = el.dataset;
+ const includeSubgroups = parseBoolean(el.dataset.includeSubgroups);
+ const membership = parseBoolean(el.dataset.membership);
+ const hasHtmlLabel = parseBoolean(el.dataset.hasHtmlLabel);
return new Vue({
el,
@@ -21,11 +31,15 @@ export const initProjectSelects = () => {
return createElement(ProjectSelect, {
props: {
label,
+ hasHtmlLabel,
inputName,
inputId,
groupId,
+ userId,
+ orderBy,
+ includeSubgroups,
+ membership,
initialSelection,
- clearable,
},
});
},
diff --git a/app/assets/javascripts/vue_shared/components/entity_select/project_select.vue b/app/assets/javascripts/vue_shared/components/entity_select/project_select.vue
index c71fb713f1c..393991d746e 100644
--- a/app/assets/javascripts/vue_shared/components/entity_select/project_select.vue
+++ b/app/assets/javascripts/vue_shared/components/entity_select/project_select.vue
@@ -2,6 +2,7 @@
import { GlAlert } from '@gitlab/ui';
import * as Sentry from '@sentry/browser';
import Api from '~/api';
+import SafeHtml from '~/vue_shared/directives/safe_html';
import {
PROJECT_TOGGLE_TEXT,
PROJECT_HEADER_TEXT,
@@ -15,11 +16,19 @@ export default {
GlAlert,
EntitySelector,
},
+ directives: {
+ SafeHtml,
+ },
props: {
label: {
type: String,
required: true,
},
+ hasHtmlLabel: {
+ type: Boolean,
+ required: false,
+ default: false,
+ },
inputName: {
type: String,
required: true,
@@ -30,18 +39,34 @@ export default {
},
groupId: {
type: String,
- required: true,
+ required: false,
+ default: null,
},
- initialSelection: {
+ userId: {
type: String,
required: false,
default: null,
},
- clearable: {
+ includeSubgroups: {
type: Boolean,
required: false,
default: false,
},
+ membership: {
+ type: Boolean,
+ required: false,
+ default: false,
+ },
+ orderBy: {
+ type: String,
+ required: false,
+ default: 'similarity',
+ },
+ initialSelection: {
+ type: String,
+ required: false,
+ default: null,
+ },
},
data() {
return {
@@ -52,12 +77,39 @@ export default {
async fetchProjects(searchString = '') {
let projects = [];
try {
- const { data = [] } = await Api.groupProjects(this.groupId, searchString, {
- with_shared: true,
- include_subgroups: false,
- order_by: 'similarity',
- simple: true,
- });
+ const { data = [] } = await (() => {
+ const commonParams = {
+ order_by: this.orderBy,
+ simple: true,
+ };
+
+ if (this.groupId) {
+ return Api.groupProjects(this.groupId, searchString, {
+ ...commonParams,
+ with_shared: true,
+ include_subgroups: this.includeSubgroups,
+ simple: true,
+ });
+ }
+ // Note: the whole userId handling supports a single project selector that is slated for
+ // removal. Once we have deleted app/views/clusters/clusters/_advanced_settings.html.haml,
+ // we should be able to clean this up.
+ if (this.userId) {
+ return Api.userProjects(
+ this.userId,
+ searchString,
+ {
+ with_shared: true,
+ include_subgroups: this.includeSubgroups,
+ },
+ (res) => ({ data: res }),
+ );
+ }
+ return Api.projects(searchString, {
+ ...commonParams,
+ membership: this.membership,
+ });
+ })();
projects = data.map((item) => ({
text: item.name_with_namespace || item.name,
value: String(item.id),
@@ -98,12 +150,15 @@ export default {
:input-name="inputName"
:input-id="inputId"
:initial-selection="initialSelection"
- :clearable="clearable"
:header-text="$options.i18n.selectProject"
:default-toggle-text="$options.i18n.searchForProject"
:fetch-items="fetchProjects"
:fetch-initial-selection-text="fetchProjectName"
+ clearable
>
+ <template v-if="hasHtmlLabel" #label>
+ <span v-safe-html="label"></span>
+ </template>
<template #error>
<gl-alert v-if="errorMessage" class="gl-mb-3" variant="danger" @dismiss="dismissError">{{
errorMessage