@gitlab/ui 104.2.0 → 105.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +0 -5
- package/dist/tailwind.css +1 -1
- package/dist/tailwind.css.map +1 -1
- package/package.json +1 -3
- package/src/index.js +0 -5
- package/src/scss/components.scss +0 -3
- package/translations.js +0 -57
- package/dist/components/experimental/duo/chat/components/duo_chat_context/constants.js +0 -21
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_details_modal/duo_chat_context_item_details_modal.js +0 -159
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.js +0 -273
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_category_items.js +0 -77
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_search_item.js +0 -89
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_search_items.js +0 -147
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_search_items_loading.js +0 -61
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.js +0 -137
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.js +0 -163
- package/dist/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +0 -308
- package/dist/components/experimental/duo/chat/components/duo_chat_context/utils.js +0 -140
- package/dist/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.js +0 -109
- package/dist/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.js +0 -111
- package/dist/components/experimental/duo/chat/components/duo_chat_message/buttons_utils.js +0 -33
- package/dist/components/experimental/duo/chat/components/duo_chat_message/constants.js +0 -14
- package/dist/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +0 -24
- package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +0 -300
- package/dist/components/experimental/duo/chat/components/duo_chat_message/insert_code_snippet_element.js +0 -56
- package/dist/components/experimental/duo/chat/components/duo_chat_message/utils.js +0 -17
- package/dist/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.js +0 -115
- package/dist/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.js +0 -72
- package/dist/components/experimental/duo/chat/constants.js +0 -35
- package/dist/components/experimental/duo/chat/duo_chat.js +0 -553
- package/dist/components/experimental/duo/chat/markdown_renderer.js +0 -25
- package/dist/components/experimental/duo/chat/mock_data.js +0 -170
- package/dist/components/experimental/duo/user_feedback/user_feedback.js +0 -106
- package/dist/components/experimental/duo/user_feedback/user_feedback_modal.js +0 -154
- package/dist/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.js +0 -106
- package/dist/components/experimental/duo/workflow/components/duo_workflow_prompt/duo_workflow_prompt.js +0 -246
- package/src/components/experimental/duo/chat/components/duo_chat_context/constants.js +0 -21
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_details_modal/duo_chat_context_item_details_modal.vue +0 -182
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.md +0 -44
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.vue +0 -288
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_category_items.vue +0 -54
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_search_item.vue +0 -86
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_search_items.vue +0 -168
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_search_items_loading.vue +0 -43
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.vue +0 -170
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.vue +0 -196
- package/src/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +0 -362
- package/src/components/experimental/duo/chat/components/duo_chat_context/utils.js +0 -169
- package/src/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.md +0 -27
- package/src/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.vue +0 -99
- package/src/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.md +0 -10
- package/src/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.scss +0 -44
- package/src/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.vue +0 -112
- package/src/components/experimental/duo/chat/components/duo_chat_message/buttons_utils.js +0 -39
- package/src/components/experimental/duo/chat/components/duo_chat_message/constants.js +0 -12
- package/src/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +0 -24
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.md +0 -69
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.scss +0 -105
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.vue +0 -363
- package/src/components/experimental/duo/chat/components/duo_chat_message/insert_code_snippet_element.js +0 -51
- package/src/components/experimental/duo/chat/components/duo_chat_message/utils.js +0 -18
- package/src/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.md +0 -10
- package/src/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.vue +0 -91
- package/src/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.md +0 -10
- package/src/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.vue +0 -45
- package/src/components/experimental/duo/chat/constants.js +0 -37
- package/src/components/experimental/duo/chat/duo_chat.md +0 -202
- package/src/components/experimental/duo/chat/duo_chat.scss +0 -413
- package/src/components/experimental/duo/chat/duo_chat.vue +0 -751
- package/src/components/experimental/duo/chat/markdown_renderer.js +0 -29
- package/src/components/experimental/duo/chat/mock_data.js +0 -187
- package/src/components/experimental/duo/chat/variables.scss +0 -9
- package/src/components/experimental/duo/user_feedback/user_feedback.md +0 -90
- package/src/components/experimental/duo/user_feedback/user_feedback.vue +0 -95
- package/src/components/experimental/duo/user_feedback/user_feedback_modal.vue +0 -167
- package/src/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.md +0 -42
- package/src/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.vue +0 -96
- package/src/components/experimental/duo/workflow/components/duo_workflow_prompt/duo_workflow_prompt.md +0 -46
- package/src/components/experimental/duo/workflow/components/duo_workflow_prompt/duo_workflow_prompt.vue +0 -270
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/**
|
|
3
|
-
* This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
|
|
4
|
-
*
|
|
5
|
-
* Please use the corresponding component in Duo-UI going forward.
|
|
6
|
-
* All future development and maintenance for Duo components should take place in Duo-UI.
|
|
7
|
-
*
|
|
8
|
-
* For more details, see the migration epic: https://gitlab.com/groups/gitlab-org/-/epics/15344 or reach out to the Duo-Chat team in #g_duo_chat.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import debounce from 'lodash/debounce';
|
|
12
|
-
import { translate } from '../../../../../../../utils/i18n';
|
|
13
|
-
import GlCard from '../../../../../../base/card/card.vue';
|
|
14
|
-
import GlDuoChatContextItemSelections from '../duo_chat_context_item_selections/duo_chat_context_item_selections.vue';
|
|
15
|
-
import { categoriesValidator, contextItemsValidator, wrapIndex } from '../utils';
|
|
16
|
-
import GlDuoChatContextItemMenuCategoryItems from './duo_chat_context_item_menu_category_items.vue';
|
|
17
|
-
import GlDuoChatContextItemMenuSearchItems from './duo_chat_context_item_menu_search_items.vue';
|
|
18
|
-
|
|
19
|
-
const SEARCH_DEBOUNCE_MS = 30;
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
name: 'GlDuoChatContextItemMenu',
|
|
23
|
-
components: {
|
|
24
|
-
GlCard,
|
|
25
|
-
GlDuoChatContextItemMenuCategoryItems,
|
|
26
|
-
GlDuoChatContextItemMenuSearchItems,
|
|
27
|
-
GlDuoChatContextItemSelections,
|
|
28
|
-
},
|
|
29
|
-
props: {
|
|
30
|
-
/**
|
|
31
|
-
* Whether the menu is open.
|
|
32
|
-
*/
|
|
33
|
-
open: {
|
|
34
|
-
type: Boolean,
|
|
35
|
-
required: true,
|
|
36
|
-
},
|
|
37
|
-
/**
|
|
38
|
-
* Array of selected context items.
|
|
39
|
-
*/
|
|
40
|
-
selections: {
|
|
41
|
-
type: Array,
|
|
42
|
-
required: true,
|
|
43
|
-
validator: contextItemsValidator,
|
|
44
|
-
},
|
|
45
|
-
/**
|
|
46
|
-
* Whether the menu is in a loading state.
|
|
47
|
-
*/
|
|
48
|
-
loading: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
required: true,
|
|
51
|
-
},
|
|
52
|
-
/**
|
|
53
|
-
* Error message to display, if any.
|
|
54
|
-
*/
|
|
55
|
-
error: {
|
|
56
|
-
type: [String, null],
|
|
57
|
-
required: false,
|
|
58
|
-
default: null,
|
|
59
|
-
},
|
|
60
|
-
/**
|
|
61
|
-
* Array of available categories for context items.
|
|
62
|
-
*/
|
|
63
|
-
categories: {
|
|
64
|
-
type: Array,
|
|
65
|
-
required: true,
|
|
66
|
-
validator: categoriesValidator,
|
|
67
|
-
},
|
|
68
|
-
/**
|
|
69
|
-
* Array of search results for context items.
|
|
70
|
-
*/
|
|
71
|
-
results: {
|
|
72
|
-
type: Array,
|
|
73
|
-
required: true,
|
|
74
|
-
validator: contextItemsValidator,
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
data() {
|
|
78
|
-
return {
|
|
79
|
-
selectedCategory: null,
|
|
80
|
-
searchQuery: '',
|
|
81
|
-
activeIndex: 0,
|
|
82
|
-
};
|
|
83
|
-
},
|
|
84
|
-
computed: {
|
|
85
|
-
showCategorySelection() {
|
|
86
|
-
return this.open && !this.selectedCategory;
|
|
87
|
-
},
|
|
88
|
-
allResultsAreDisabled() {
|
|
89
|
-
return this.results.every((result) => !result.metadata.enabled);
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
watch: {
|
|
93
|
-
open(isOpen) {
|
|
94
|
-
if (!isOpen) {
|
|
95
|
-
this.resetSelection();
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
searchQuery(query) {
|
|
99
|
-
this.debouncedSearch(query);
|
|
100
|
-
},
|
|
101
|
-
results(newResults) {
|
|
102
|
-
const firstEnabledIndex = newResults.findIndex((result) => result.metadata.enabled);
|
|
103
|
-
this.activeIndex = firstEnabledIndex >= 0 ? firstEnabledIndex : 0;
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
methods: {
|
|
107
|
-
selectCategory(category) {
|
|
108
|
-
this.searchQuery = '';
|
|
109
|
-
this.selectedCategory = category;
|
|
110
|
-
|
|
111
|
-
this.$emit('search', {
|
|
112
|
-
category: category.value,
|
|
113
|
-
query: '',
|
|
114
|
-
});
|
|
115
|
-
},
|
|
116
|
-
debouncedSearch: debounce(function search(query) {
|
|
117
|
-
/**
|
|
118
|
-
* Emitted when a search should be performed.
|
|
119
|
-
* @property {Object} filter
|
|
120
|
-
* @property {string} filter.category - The value of the selected category
|
|
121
|
-
* @property {string} filter.query - The search query
|
|
122
|
-
*/
|
|
123
|
-
this.$emit('search', {
|
|
124
|
-
category: this.selectedCategory.value,
|
|
125
|
-
query,
|
|
126
|
-
});
|
|
127
|
-
}, SEARCH_DEBOUNCE_MS),
|
|
128
|
-
selectItem(item) {
|
|
129
|
-
if (!item.metadata.enabled) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Emitted when a context item is selected.
|
|
135
|
-
* @property {Object} item - The selected context item
|
|
136
|
-
*/
|
|
137
|
-
this.$emit(
|
|
138
|
-
'select',
|
|
139
|
-
this.results.find((result) => result.id === item.id)
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Emitted when the menu should be closed.
|
|
144
|
-
*/
|
|
145
|
-
this.$emit('close');
|
|
146
|
-
this.resetSelection();
|
|
147
|
-
},
|
|
148
|
-
removeItem(item) {
|
|
149
|
-
/**
|
|
150
|
-
* Emitted when a context item should be removed.
|
|
151
|
-
* @property {Object} item - The context item to be removed
|
|
152
|
-
*/
|
|
153
|
-
this.$emit('remove', item);
|
|
154
|
-
},
|
|
155
|
-
resetSelection() {
|
|
156
|
-
this.selectedCategory = null;
|
|
157
|
-
this.searchQuery = '';
|
|
158
|
-
this.activeIndex = 0;
|
|
159
|
-
},
|
|
160
|
-
async scrollActiveItemIntoView() {
|
|
161
|
-
await this.$nextTick();
|
|
162
|
-
|
|
163
|
-
const activeItem = document.getElementById(`dropdown-item-${this.activeIndex}`);
|
|
164
|
-
if (activeItem) {
|
|
165
|
-
activeItem.scrollIntoView({ block: 'nearest', inline: 'start' });
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
handleKeyUp(e) {
|
|
169
|
-
switch (e.key) {
|
|
170
|
-
case 'ArrowDown':
|
|
171
|
-
case 'ArrowUp':
|
|
172
|
-
e.preventDefault();
|
|
173
|
-
this.moveActiveIndex(e.key === 'ArrowDown' ? 1 : -1);
|
|
174
|
-
this.scrollActiveItemIntoView();
|
|
175
|
-
break;
|
|
176
|
-
case 'Enter':
|
|
177
|
-
e.preventDefault();
|
|
178
|
-
if (this.showCategorySelection) {
|
|
179
|
-
this.selectCategory(this.categories[this.activeIndex]);
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
if (!this.results.length) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
this.selectItem(this.results[this.activeIndex]);
|
|
186
|
-
break;
|
|
187
|
-
case 'Escape':
|
|
188
|
-
e.preventDefault();
|
|
189
|
-
if (this.showCategorySelection) {
|
|
190
|
-
this.$emit('close');
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
this.selectedCategory = null;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Emitted when the parent GlDuoChat component should refocus on the main prompt input
|
|
198
|
-
*/
|
|
199
|
-
this.$emit('focus-prompt');
|
|
200
|
-
break;
|
|
201
|
-
default:
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
moveActiveIndex(step) {
|
|
206
|
-
if (this.showCategorySelection) {
|
|
207
|
-
// Categories cannot be disabled, so just loop to the next/prev one
|
|
208
|
-
this.activeIndex = wrapIndex(this.activeIndex, step, this.categories.length);
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Return early if there are no results or all results are disabled
|
|
213
|
-
if (!this.results.length || this.allResultsAreDisabled) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// contextItems CAN be disabled, so loop to next/prev but ensure we don't land on a disabled one
|
|
218
|
-
let newIndex = this.activeIndex;
|
|
219
|
-
do {
|
|
220
|
-
newIndex = wrapIndex(newIndex, step, this.results.length);
|
|
221
|
-
|
|
222
|
-
if (newIndex === this.activeIndex) {
|
|
223
|
-
// If we've looped through all items and found no enabled ones, keep the current index
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
} while (!this.results[newIndex].metadata.enabled);
|
|
227
|
-
|
|
228
|
-
this.activeIndex = newIndex;
|
|
229
|
-
},
|
|
230
|
-
onGetContextItemContent(contextItem) {
|
|
231
|
-
/**
|
|
232
|
-
* Emit get-context-item-content event that tells clients to load the full file content for a selected context item.
|
|
233
|
-
* The fully hydrated context item should be updated in the context item selections.
|
|
234
|
-
* @param {*} event An event containing the context item to hydrate
|
|
235
|
-
*/
|
|
236
|
-
this.$emit('get-context-item-content', { contextItem });
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
i18n: {
|
|
240
|
-
selectedContextItemsTitle: translate(
|
|
241
|
-
'GlDuoChatContextItemMenu.selectedContextItemsTitle',
|
|
242
|
-
'Included references'
|
|
243
|
-
),
|
|
244
|
-
},
|
|
245
|
-
};
|
|
246
|
-
</script>
|
|
247
|
-
|
|
248
|
-
<template>
|
|
249
|
-
<div>
|
|
250
|
-
<gl-duo-chat-context-item-selections
|
|
251
|
-
v-if="selections.length"
|
|
252
|
-
:selections="selections"
|
|
253
|
-
:categories="categories"
|
|
254
|
-
:removable="true"
|
|
255
|
-
:title="$options.i18n.selectedContextItemsTitle"
|
|
256
|
-
:default-collapsed="false"
|
|
257
|
-
class="gl-mb-3"
|
|
258
|
-
@remove="removeItem"
|
|
259
|
-
@get-content="onGetContextItemContent"
|
|
260
|
-
/>
|
|
261
|
-
<gl-card
|
|
262
|
-
v-if="open"
|
|
263
|
-
class="slash-commands !gl-absolute gl-bottom-0 gl-w-full gl-pl-0 gl-shadow-md"
|
|
264
|
-
body-class="!gl-p-2"
|
|
265
|
-
data-testid="context-item-menu"
|
|
266
|
-
>
|
|
267
|
-
<gl-duo-chat-context-item-menu-category-items
|
|
268
|
-
v-if="showCategorySelection"
|
|
269
|
-
:active-index="activeIndex"
|
|
270
|
-
:categories="categories"
|
|
271
|
-
@select="selectCategory"
|
|
272
|
-
@active-index-change="activeIndex = $event"
|
|
273
|
-
/>
|
|
274
|
-
<gl-duo-chat-context-item-menu-search-items
|
|
275
|
-
v-else
|
|
276
|
-
v-model="searchQuery"
|
|
277
|
-
:active-index="activeIndex"
|
|
278
|
-
:category="selectedCategory"
|
|
279
|
-
:loading="loading"
|
|
280
|
-
:error="error"
|
|
281
|
-
:results="results"
|
|
282
|
-
@select="selectItem"
|
|
283
|
-
@keyup="handleKeyUp"
|
|
284
|
-
@active-index-change="activeIndex = $event"
|
|
285
|
-
/>
|
|
286
|
-
</gl-card>
|
|
287
|
-
</div>
|
|
288
|
-
</template>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/**
|
|
3
|
-
* This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
|
|
4
|
-
*
|
|
5
|
-
* Please use the corresponding component in Duo-UI going forward.
|
|
6
|
-
* All future development and maintenance for Duo components should take place in Duo-UI.
|
|
7
|
-
*
|
|
8
|
-
* For more details, see the migration epic: https://gitlab.com/groups/gitlab-org/-/epics/15344 or reach out to the Duo-Chat team in #g_duo_chat.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import GlDropdownItem from '../../../../../../base/dropdown/dropdown_item.vue';
|
|
12
|
-
import GlIcon from '../../../../../../base/icon/icon.vue';
|
|
13
|
-
import { categoriesValidator } from '../utils';
|
|
14
|
-
|
|
15
|
-
export default {
|
|
16
|
-
name: 'GlDuoChatContextItemMenuCategoryItems',
|
|
17
|
-
components: { GlIcon, GlDropdownItem },
|
|
18
|
-
props: {
|
|
19
|
-
categories: {
|
|
20
|
-
type: Array,
|
|
21
|
-
required: true,
|
|
22
|
-
validator: categoriesValidator,
|
|
23
|
-
},
|
|
24
|
-
activeIndex: {
|
|
25
|
-
type: Number,
|
|
26
|
-
required: true,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
methods: {
|
|
30
|
-
selectCategory(category) {
|
|
31
|
-
this.$emit('select', category);
|
|
32
|
-
},
|
|
33
|
-
setActiveIndex(index) {
|
|
34
|
-
this.$emit('active-index-change', index);
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
</script>
|
|
39
|
-
<template>
|
|
40
|
-
<ul class="gl-mb-0 gl-list-none gl-pl-0">
|
|
41
|
-
<gl-dropdown-item
|
|
42
|
-
v-for="(category, index) in categories"
|
|
43
|
-
:key="category.value"
|
|
44
|
-
:class="{ 'active-command': index === activeIndex }"
|
|
45
|
-
data-testid="category-item"
|
|
46
|
-
@click="selectCategory(category)"
|
|
47
|
-
>
|
|
48
|
-
<div class="gl-flex gl-items-center" @mouseenter="setActiveIndex(index)">
|
|
49
|
-
<gl-icon :name="category.icon" class="gl-mr-2" />
|
|
50
|
-
{{ category.label }}
|
|
51
|
-
</div>
|
|
52
|
-
</gl-dropdown-item>
|
|
53
|
-
</ul>
|
|
54
|
-
</template>
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/**
|
|
3
|
-
* This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
|
|
4
|
-
*
|
|
5
|
-
* Please use the corresponding component in Duo-UI going forward.
|
|
6
|
-
* All future development and maintenance for Duo components should take place in Duo-UI.
|
|
7
|
-
*
|
|
8
|
-
* For more details, see the migration epic: https://gitlab.com/groups/gitlab-org/-/epics/15344 or reach out to the Duo-Chat team in #g_duo_chat.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import GlDuoChatContextItemPopover from '../duo_chat_context_item_popover/duo_chat_context_item_popover.vue';
|
|
12
|
-
import GlTruncate from '../../../../../../utilities/truncate/truncate.vue';
|
|
13
|
-
import GlIcon from '../../../../../../base/icon/icon.vue';
|
|
14
|
-
import {
|
|
15
|
-
categoryValidator,
|
|
16
|
-
contextItemValidator,
|
|
17
|
-
getContextItemIcon,
|
|
18
|
-
getContextItemSecondaryText,
|
|
19
|
-
getContextItemSource,
|
|
20
|
-
} from '../utils';
|
|
21
|
-
import GlBadge from '../../../../../../base/badge/badge.vue';
|
|
22
|
-
|
|
23
|
-
export default {
|
|
24
|
-
name: 'GlDuoChatContextItemMenuSearchItem',
|
|
25
|
-
components: { GlBadge, GlTruncate, GlIcon, GlDuoChatContextItemPopover },
|
|
26
|
-
props: {
|
|
27
|
-
category: {
|
|
28
|
-
type: Object,
|
|
29
|
-
required: true,
|
|
30
|
-
validator: categoryValidator,
|
|
31
|
-
},
|
|
32
|
-
contextItem: {
|
|
33
|
-
type: Object,
|
|
34
|
-
required: true,
|
|
35
|
-
validator: contextItemValidator,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
computed: {
|
|
39
|
-
title() {
|
|
40
|
-
return this.contextItem.metadata?.title || '';
|
|
41
|
-
},
|
|
42
|
-
secondaryText() {
|
|
43
|
-
return getContextItemSecondaryText(this.contextItem);
|
|
44
|
-
},
|
|
45
|
-
icon() {
|
|
46
|
-
return getContextItemIcon(this.contextItem, this.category);
|
|
47
|
-
},
|
|
48
|
-
itemSource() {
|
|
49
|
-
return getContextItemSource(this.contextItem);
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
</script>
|
|
54
|
-
<template>
|
|
55
|
-
<div class="gl-flex gl-flex-col">
|
|
56
|
-
<div class="gl-flex gl-items-center">
|
|
57
|
-
<gl-icon :name="icon" class="gl-mr-2 gl-shrink-0" data-testid="category-icon" />
|
|
58
|
-
<gl-truncate :text="title" class="gl-min-w-0" data-testid="item-title" />
|
|
59
|
-
<gl-icon
|
|
60
|
-
:id="`info-icon-${contextItem.id}`"
|
|
61
|
-
name="information-o"
|
|
62
|
-
class="gl-ml-2 gl-shrink-0 gl-cursor-pointer gl-text-secondary"
|
|
63
|
-
:size="12"
|
|
64
|
-
/>
|
|
65
|
-
<gl-duo-chat-context-item-popover
|
|
66
|
-
:context-item="contextItem"
|
|
67
|
-
:target="`info-icon-${contextItem.id}`"
|
|
68
|
-
placement="left"
|
|
69
|
-
/>
|
|
70
|
-
</div>
|
|
71
|
-
<div
|
|
72
|
-
v-if="secondaryText"
|
|
73
|
-
class="gl-align-items-center gl-mt-1 gl-flex gl-shrink-0 gl-whitespace-nowrap gl-text-secondary"
|
|
74
|
-
data-testid="item-secondary-text"
|
|
75
|
-
>
|
|
76
|
-
<gl-badge
|
|
77
|
-
v-if="itemSource"
|
|
78
|
-
variant="neutral"
|
|
79
|
-
class="gl-mr-1"
|
|
80
|
-
data-testid="context-item-source"
|
|
81
|
-
>{{ itemSource }}</gl-badge
|
|
82
|
-
>
|
|
83
|
-
<gl-truncate class="gl-min-w-0" position="middle" :text="secondaryText" />
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
</template>
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/**
|
|
3
|
-
* This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
|
|
4
|
-
*
|
|
5
|
-
* Please use the corresponding component in Duo-UI going forward.
|
|
6
|
-
* All future development and maintenance for Duo components should take place in Duo-UI.
|
|
7
|
-
*
|
|
8
|
-
* For more details, see the migration epic: https://gitlab.com/groups/gitlab-org/-/epics/15344 or reach out to the Duo-Chat team in #g_duo_chat.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import GlDropdownItem from '../../../../../../base/dropdown/dropdown_item.vue';
|
|
12
|
-
import GlFormInput from '../../../../../../base/form/form_input/form_input.vue';
|
|
13
|
-
import GlAlert from '../../../../../../base/alert/alert.vue';
|
|
14
|
-
import { sprintf, translate } from '../../../../../../../utils/i18n';
|
|
15
|
-
import { categoryValidator, contextItemsValidator } from '../utils';
|
|
16
|
-
import GlDuoChatContextItemMenuSearchItemsLoading from './duo_chat_context_item_menu_search_items_loading.vue';
|
|
17
|
-
import GlDuoChatContextItemMenuSearchItem from './duo_chat_context_item_menu_search_item.vue';
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
name: 'GlDuoChatContextItemMenuSearchItems',
|
|
21
|
-
components: {
|
|
22
|
-
GlAlert,
|
|
23
|
-
GlDropdownItem,
|
|
24
|
-
GlDuoChatContextItemMenuSearchItem,
|
|
25
|
-
GlDuoChatContextItemMenuSearchItemsLoading,
|
|
26
|
-
GlFormInput,
|
|
27
|
-
},
|
|
28
|
-
model: {
|
|
29
|
-
prop: 'searchQuery',
|
|
30
|
-
event: 'update:searchQuery',
|
|
31
|
-
},
|
|
32
|
-
props: {
|
|
33
|
-
activeIndex: {
|
|
34
|
-
type: Number,
|
|
35
|
-
required: true,
|
|
36
|
-
},
|
|
37
|
-
searchQuery: {
|
|
38
|
-
type: String,
|
|
39
|
-
required: true,
|
|
40
|
-
},
|
|
41
|
-
category: {
|
|
42
|
-
type: Object,
|
|
43
|
-
required: true,
|
|
44
|
-
validator: categoryValidator,
|
|
45
|
-
},
|
|
46
|
-
loading: {
|
|
47
|
-
type: Boolean,
|
|
48
|
-
required: true,
|
|
49
|
-
},
|
|
50
|
-
error: {
|
|
51
|
-
type: [String, null],
|
|
52
|
-
required: false,
|
|
53
|
-
default: null,
|
|
54
|
-
},
|
|
55
|
-
results: {
|
|
56
|
-
type: Array,
|
|
57
|
-
required: true,
|
|
58
|
-
validator: contextItemsValidator,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
data() {
|
|
62
|
-
return {
|
|
63
|
-
userInitiatedSearch: false,
|
|
64
|
-
numLoadingItems: 3,
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
computed: {
|
|
68
|
-
showEmptyState() {
|
|
69
|
-
return Boolean(
|
|
70
|
-
this.userInitiatedSearch && !this.loading && !this.error && !this.results.length
|
|
71
|
-
);
|
|
72
|
-
},
|
|
73
|
-
searchInputPlaceholder() {
|
|
74
|
-
return sprintf(
|
|
75
|
-
translate('GlDuoChatContextItemMenu.searchInputPlaceholder', 'Search %{categoryLabel}...'),
|
|
76
|
-
{
|
|
77
|
-
categoryLabel: this.category.label.toLowerCase(),
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
watch: {
|
|
83
|
-
searchQuery() {
|
|
84
|
-
this.userInitiatedSearch = true;
|
|
85
|
-
},
|
|
86
|
-
results(results) {
|
|
87
|
-
this.numLoadingItems = Math.max(1, results.length);
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
methods: {
|
|
91
|
-
selectItem(contextItem) {
|
|
92
|
-
this.$emit('select', contextItem);
|
|
93
|
-
this.userInitiatedSearch = false;
|
|
94
|
-
},
|
|
95
|
-
handleKeyUp(e) {
|
|
96
|
-
this.$emit('keyup', e);
|
|
97
|
-
},
|
|
98
|
-
setActiveIndex(index) {
|
|
99
|
-
if (this.results[index]?.metadata.enabled) {
|
|
100
|
-
this.$emit('active-index-change', index);
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
isActiveItem(contextItem, index) {
|
|
104
|
-
return index === this.activeIndex && contextItem.metadata.enabled;
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
i18n: {
|
|
108
|
-
emptyStateMessage: translate('GlDuoChatContextItemMenu.emptyStateMessage', 'No results found'),
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
</script>
|
|
112
|
-
<template>
|
|
113
|
-
<div>
|
|
114
|
-
<div class="gl-max-h-31 gl-overflow-y-scroll">
|
|
115
|
-
<gl-duo-chat-context-item-menu-search-items-loading v-if="loading" :rows="numLoadingItems" />
|
|
116
|
-
<gl-alert
|
|
117
|
-
v-else-if="error"
|
|
118
|
-
variant="danger"
|
|
119
|
-
:dismissible="false"
|
|
120
|
-
class="gl-m-3"
|
|
121
|
-
data-testid="search-results-error"
|
|
122
|
-
>
|
|
123
|
-
{{ error }}
|
|
124
|
-
</gl-alert>
|
|
125
|
-
<div
|
|
126
|
-
v-else-if="showEmptyState"
|
|
127
|
-
class="gl-rounded-base gl-p-3 gl-text-center gl-text-secondary"
|
|
128
|
-
data-testid="search-results-empty-state"
|
|
129
|
-
>
|
|
130
|
-
{{ $options.i18n.emptyStateMessage }}
|
|
131
|
-
</div>
|
|
132
|
-
<ul v-else class="gl-mb-1 gl-list-none gl-flex-row gl-pl-0">
|
|
133
|
-
<gl-dropdown-item
|
|
134
|
-
v-for="(contextItem, index) in results"
|
|
135
|
-
:id="`dropdown-item-${index}`"
|
|
136
|
-
:key="contextItem.id"
|
|
137
|
-
:class="{
|
|
138
|
-
'active-command': isActiveItem(contextItem, index),
|
|
139
|
-
'gl-cursor-not-allowed [&>button]:focus-within:!gl-shadow-none':
|
|
140
|
-
!contextItem.metadata.enabled,
|
|
141
|
-
}"
|
|
142
|
-
:tabindex="!contextItem.metadata.enabled ? -1 : undefined"
|
|
143
|
-
class="duo-chat-context-search-result-item"
|
|
144
|
-
data-testid="search-result-item"
|
|
145
|
-
@click="selectItem(contextItem)"
|
|
146
|
-
>
|
|
147
|
-
<div @mouseenter="setActiveIndex(index)">
|
|
148
|
-
<gl-duo-chat-context-item-menu-search-item
|
|
149
|
-
:context-item="contextItem"
|
|
150
|
-
:category="category"
|
|
151
|
-
:class="{ 'gl-text-secondary': !contextItem.metadata.enabled }"
|
|
152
|
-
data-testid="search-result-item-details"
|
|
153
|
-
/>
|
|
154
|
-
</div>
|
|
155
|
-
</gl-dropdown-item>
|
|
156
|
-
</ul>
|
|
157
|
-
</div>
|
|
158
|
-
<gl-form-input
|
|
159
|
-
ref="contextMenuSearchInput"
|
|
160
|
-
:value="searchQuery"
|
|
161
|
-
:placeholder="searchInputPlaceholder"
|
|
162
|
-
autofocus
|
|
163
|
-
data-testid="context-menu-search-input"
|
|
164
|
-
@input="$emit('update:searchQuery', $event)"
|
|
165
|
-
@keyup="handleKeyUp"
|
|
166
|
-
/>
|
|
167
|
-
</div>
|
|
168
|
-
</template>
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/**
|
|
3
|
-
* This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
|
|
4
|
-
*
|
|
5
|
-
* Please use the corresponding component in Duo-UI going forward.
|
|
6
|
-
* All future development and maintenance for Duo components should take place in Duo-UI.
|
|
7
|
-
*
|
|
8
|
-
* For more details, see the migration epic: https://gitlab.com/groups/gitlab-org/-/epics/15344 or reach out to the Duo-Chat team in #g_duo_chat.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { translate } from '../../../../../../../utils/i18n';
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
name: 'GlDuoChatContextItemMenuSearchItemsLoading',
|
|
15
|
-
props: {
|
|
16
|
-
rows: {
|
|
17
|
-
type: Number,
|
|
18
|
-
required: true,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
i18n: {
|
|
22
|
-
loadingMessage: translate('GlDuoChatContextItemMenu.loadingMessage', 'Loading...'),
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<template>
|
|
28
|
-
<div>
|
|
29
|
-
<div
|
|
30
|
-
v-for="index in rows"
|
|
31
|
-
:key="index"
|
|
32
|
-
class="gl-mx-3 gl-mb-4 gl-pt-3"
|
|
33
|
-
data-testid="search-results-loading"
|
|
34
|
-
>
|
|
35
|
-
<div class="gl-mb-2 gl-flex">
|
|
36
|
-
<div class="gl-animate-skeleton-loader gl-mr-3 gl-h-5 gl-w-5 gl-rounded-base"></div>
|
|
37
|
-
<div class="gl-animate-skeleton-loader gl-h-5 gl-grow gl-rounded-base"></div>
|
|
38
|
-
</div>
|
|
39
|
-
<div class="gl-animate-skeleton-loader gl-h-4 gl-w-1/2 gl-rounded-base"></div>
|
|
40
|
-
</div>
|
|
41
|
-
<span class="gl-sr-only">{{ $options.i18n.loadingMessage }}</span>
|
|
42
|
-
</div>
|
|
43
|
-
</template>
|