@gitlab/ui 104.1.2 → 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.
Files changed (84) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/index.css +1 -1
  3. package/dist/index.css.map +1 -1
  4. package/dist/index.js +0 -5
  5. package/dist/tailwind.css +1 -1
  6. package/dist/tailwind.css.map +1 -1
  7. package/package.json +1 -3
  8. package/src/index.js +0 -5
  9. package/src/scss/components.scss +0 -3
  10. package/src/scss/typography.scss +14 -1
  11. package/src/vendor/bootstrap/scss/_reboot.scss +0 -31
  12. package/translations.js +0 -57
  13. package/dist/components/experimental/duo/chat/components/duo_chat_context/constants.js +0 -21
  14. 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
  15. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.js +0 -273
  16. 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
  17. 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
  18. 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
  19. 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
  20. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.js +0 -137
  21. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.js +0 -163
  22. package/dist/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +0 -308
  23. package/dist/components/experimental/duo/chat/components/duo_chat_context/utils.js +0 -140
  24. package/dist/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.js +0 -109
  25. package/dist/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.js +0 -111
  26. package/dist/components/experimental/duo/chat/components/duo_chat_message/buttons_utils.js +0 -33
  27. package/dist/components/experimental/duo/chat/components/duo_chat_message/constants.js +0 -14
  28. package/dist/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +0 -24
  29. package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +0 -300
  30. package/dist/components/experimental/duo/chat/components/duo_chat_message/insert_code_snippet_element.js +0 -56
  31. package/dist/components/experimental/duo/chat/components/duo_chat_message/utils.js +0 -17
  32. package/dist/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.js +0 -115
  33. package/dist/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.js +0 -72
  34. package/dist/components/experimental/duo/chat/constants.js +0 -35
  35. package/dist/components/experimental/duo/chat/duo_chat.js +0 -553
  36. package/dist/components/experimental/duo/chat/markdown_renderer.js +0 -25
  37. package/dist/components/experimental/duo/chat/mock_data.js +0 -170
  38. package/dist/components/experimental/duo/user_feedback/user_feedback.js +0 -106
  39. package/dist/components/experimental/duo/user_feedback/user_feedback_modal.js +0 -154
  40. package/dist/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.js +0 -106
  41. package/dist/components/experimental/duo/workflow/components/duo_workflow_prompt/duo_workflow_prompt.js +0 -246
  42. package/src/components/experimental/duo/chat/components/duo_chat_context/constants.js +0 -21
  43. 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
  44. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.md +0 -44
  45. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.vue +0 -288
  46. 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
  47. 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
  48. 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
  49. 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
  50. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.vue +0 -170
  51. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.vue +0 -196
  52. package/src/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +0 -362
  53. package/src/components/experimental/duo/chat/components/duo_chat_context/utils.js +0 -169
  54. package/src/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.md +0 -27
  55. package/src/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.vue +0 -99
  56. package/src/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.md +0 -10
  57. package/src/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.scss +0 -44
  58. package/src/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.vue +0 -112
  59. package/src/components/experimental/duo/chat/components/duo_chat_message/buttons_utils.js +0 -39
  60. package/src/components/experimental/duo/chat/components/duo_chat_message/constants.js +0 -12
  61. package/src/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +0 -24
  62. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.md +0 -69
  63. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.scss +0 -105
  64. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.vue +0 -363
  65. package/src/components/experimental/duo/chat/components/duo_chat_message/insert_code_snippet_element.js +0 -51
  66. package/src/components/experimental/duo/chat/components/duo_chat_message/utils.js +0 -18
  67. package/src/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.md +0 -10
  68. package/src/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.vue +0 -91
  69. package/src/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.md +0 -10
  70. package/src/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.vue +0 -45
  71. package/src/components/experimental/duo/chat/constants.js +0 -37
  72. package/src/components/experimental/duo/chat/duo_chat.md +0 -202
  73. package/src/components/experimental/duo/chat/duo_chat.scss +0 -413
  74. package/src/components/experimental/duo/chat/duo_chat.vue +0 -751
  75. package/src/components/experimental/duo/chat/markdown_renderer.js +0 -29
  76. package/src/components/experimental/duo/chat/mock_data.js +0 -187
  77. package/src/components/experimental/duo/chat/variables.scss +0 -9
  78. package/src/components/experimental/duo/user_feedback/user_feedback.md +0 -90
  79. package/src/components/experimental/duo/user_feedback/user_feedback.vue +0 -95
  80. package/src/components/experimental/duo/user_feedback/user_feedback_modal.vue +0 -167
  81. package/src/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.md +0 -42
  82. package/src/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.vue +0 -96
  83. package/src/components/experimental/duo/workflow/components/duo_workflow_prompt/duo_workflow_prompt.md +0 -46
  84. package/src/components/experimental/duo/workflow/components/duo_workflow_prompt/duo_workflow_prompt.vue +0 -270
@@ -1,363 +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 throttle from 'lodash/throttle';
12
- import GlIcon from '../../../../../base/icon/icon.vue';
13
- import GlAnimatedLoaderIcon from '../../../../../base/animated_icon/animated_loader_icon.vue';
14
- import { GlTooltipDirective } from '../../../../../../directives/tooltip';
15
- import GlDuoChatContextItemSelections from '../duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.vue';
16
- import GlDuoUserFeedback from '../../../user_feedback/user_feedback.vue';
17
- import GlFormGroup from '../../../../../base/form/form_group/form_group.vue';
18
- import GlFormTextarea from '../../../../../base/form/form_textarea/form_textarea.vue';
19
- import { SafeHtmlDirective as SafeHtml } from '../../../../../../directives/safe_html/safe_html';
20
- import { MESSAGE_MODEL_ROLES, SELECTED_CONTEXT_ITEMS_DEFAULT_COLLAPSED } from '../../constants';
21
- import { sprintf, translate, translatePlural } from '../../../../../../utils/i18n';
22
- import DocumentationSources from '../duo_chat_message_sources/duo_chat_message_sources.vue';
23
- // eslint-disable-next-line no-restricted-imports
24
- import { renderDuoChatMarkdownPreview } from '../../markdown_renderer';
25
- import { CopyCodeElement } from './copy_code_element';
26
- import { InsertCodeSnippetElement } from './insert_code_snippet_element';
27
- import { concatUntilEmpty } from './utils';
28
- import {
29
- DUO_CODE_SCRIM_BOTTOM_CLASS,
30
- DUO_CODE_SCRIM_OFFSET,
31
- DUO_CODE_SCRIM_TOP_CLASS,
32
- } from './constants';
33
-
34
- export const i18n = {
35
- MODAL: {
36
- TITLE: translate('GlDuoChatMessage.modalTitle', 'Give feedback on GitLab Duo Chat'),
37
- ALERT_TEXT: translate(
38
- 'GlDuoChatMessage.modalAlertText',
39
- 'GitLab team members cannot view your conversation. Please be as descriptive as possible.'
40
- ),
41
- DID_WHAT: translate('GlDuoChatMessage.modalDidWhat', 'What were you doing?'),
42
- INTERACTION: translate(
43
- 'GlDuoChatMessage.modalInteraction',
44
- 'The situation in which you interacted with GitLab Duo Chat.'
45
- ),
46
- IMPROVE_WHAT: translate(
47
- 'GlDuoChatMessage.modalImproveWhat',
48
- 'How could the response be improved?'
49
- ),
50
- BETTER_RESPONSE: translate(
51
- 'GlDuoChatMessage.modalBetterResponse',
52
- 'How the response might better meet your needs.'
53
- ),
54
- MESSAGE_ERROR: translate('GlDuoChatMessage.modalMessageError', 'Error sending the message'),
55
- },
56
- };
57
-
58
- export default {
59
- name: 'GlDuoChatMessage',
60
- i18n,
61
- safeHtmlConfigExtension: {
62
- ADD_TAGS: ['copy-code', 'insert-code-snippet'],
63
- },
64
- components: {
65
- DocumentationSources,
66
- GlDuoChatContextItemSelections,
67
- GlDuoUserFeedback,
68
- GlFormGroup,
69
- GlFormTextarea,
70
- GlIcon,
71
- GlAnimatedLoaderIcon,
72
- },
73
- directives: {
74
- SafeHtml,
75
- GlTooltip: GlTooltipDirective,
76
- },
77
- provide() {
78
- return {
79
- modalTitle: i18n.MODAL.TITLE,
80
- modalAlertText: i18n.MODAL.ALERT_TEXT,
81
- };
82
- },
83
- inject: {
84
- // Note, we likely might move away from Provide/Inject for this
85
- // and only ship the versions that are currently in the default
86
- // See https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/3953#note_1762834219
87
- // for more context.
88
- renderGFM: {
89
- from: 'renderGFM',
90
- default: () => (element) => {
91
- element.classList.add('duo-chat-markdown', 'duo-chat-compact-markdown');
92
- },
93
- },
94
- renderMarkdown: {
95
- from: 'renderMarkdown',
96
- default: () => renderDuoChatMarkdownPreview,
97
- },
98
- },
99
- props: {
100
- /**
101
- * A message object
102
- */
103
- message: {
104
- type: Object,
105
- required: true,
106
- },
107
- isCancelled: {
108
- type: Boolean,
109
- required: true,
110
- },
111
- },
112
- data() {
113
- return {
114
- didWhat: '',
115
- improveWhat: '',
116
- messageWatcher: null, // imperatively set up watcher on message
117
- messageChunks: [],
118
- selectedContextItemsDefaultCollapsed: SELECTED_CONTEXT_ITEMS_DEFAULT_COLLAPSED,
119
- };
120
- },
121
- computed: {
122
- isChunk() {
123
- return typeof this.message.chunkId === 'number';
124
- },
125
- isNotChunkOrCancelled() {
126
- return !this.isChunk || this.isCancelled;
127
- },
128
- isChunkAndNotCancelled() {
129
- return this.isChunk && !this.isCancelled;
130
- },
131
- isAssistantMessage() {
132
- return this.message.role.toLowerCase() === MESSAGE_MODEL_ROLES.assistant;
133
- },
134
- isUserMessage() {
135
- return this.message.role.toLowerCase() === MESSAGE_MODEL_ROLES.user;
136
- },
137
- sources() {
138
- return this.message.extras?.sources;
139
- },
140
- hasFeedback() {
141
- return this.message.extras?.hasFeedback;
142
- },
143
- defaultContent() {
144
- if (this.message.contentHtml) {
145
- return this.message.contentHtml;
146
- }
147
-
148
- return this.renderMarkdown(this.message.content);
149
- },
150
- messageContent() {
151
- if (this.isAssistantMessage && this.isChunk) {
152
- return this.renderMarkdown(concatUntilEmpty(this.messageChunks));
153
- }
154
-
155
- return this.defaultContent || this.renderMarkdown(concatUntilEmpty(this.message.chunks));
156
- },
157
- renderedError() {
158
- return this.renderMarkdown(this.message.errors?.join('; ') || '');
159
- },
160
- error() {
161
- return Boolean(this.message?.errors?.length) && this.message.errors.join('; ');
162
- },
163
- selectedContextItems() {
164
- return this.message.extras?.contextItems || [];
165
- },
166
- displaySelectedContextItems() {
167
- return Boolean(this.selectedContextItems.length);
168
- },
169
- selectedContextItemsTitle() {
170
- if (!this.displaySelectedContextItems) return '';
171
-
172
- const count = this.selectedContextItems.length;
173
-
174
- if (this.isUserMessage) {
175
- return translatePlural(
176
- 'GlDuoChatMessage.SelectedContextItemsTitleUserMessage',
177
- 'Included reference',
178
- 'Included references'
179
- )(count);
180
- }
181
-
182
- return sprintf(
183
- translatePlural(
184
- 'GlDuoChatMessage.SelectedContextItemsTitleAssistantMessage',
185
- 'Used %{count} included reference',
186
- 'Used %{count} included references'
187
- )(count),
188
- {
189
- count,
190
- }
191
- );
192
- },
193
- },
194
- beforeCreate() {
195
- if (!customElements.get('copy-code')) {
196
- customElements.define('copy-code', CopyCodeElement);
197
- }
198
- if (!customElements.get('insert-code-snippet')) {
199
- customElements.define('insert-code-snippet', InsertCodeSnippetElement);
200
- }
201
- },
202
- mounted() {
203
- if (this.isAssistantMessage) {
204
- // The watcher has to be created imperatively here
205
- // to give an opportunity to remove it after
206
- // the complete message has arrived
207
- this.messageWatcher = this.$watch('message', this.manageMessageUpdate);
208
- }
209
- this.setChunks();
210
- this.hydrateContentWithGFM();
211
- },
212
- updated() {
213
- this.hydrateContentWithGFM();
214
- },
215
- methods: {
216
- setChunks() {
217
- if (this.isChunk) {
218
- const { chunkId, content } = this.message;
219
- this.$set(this.messageChunks, chunkId - 1, content);
220
- } else {
221
- this.messageChunks = [];
222
- }
223
- },
224
- stopWatchingMessage() {
225
- if (this.messageWatcher) {
226
- this.messageWatcher(); // Stop watching the message prop
227
- this.messageWatcher = null; // Ensure the watcher can't be stopped multiple times
228
- }
229
- },
230
- hydrateContentWithGFM() {
231
- if (!this.isChunk && this.$refs.content) {
232
- this.$nextTick(this.renderGFM(this.$refs.content));
233
- }
234
- this.detectScrollableCodeBlocks();
235
- },
236
- logEvent(e) {
237
- this.$emit('track-feedback', {
238
- ...e,
239
- didWhat: this.didWhat,
240
- improveWhat: this.improveWhat,
241
- message: this.message,
242
- });
243
- },
244
- manageMessageUpdate() {
245
- this.setChunks();
246
- if (!this.isChunk) {
247
- this.stopWatchingMessage();
248
- }
249
- },
250
- onInsertCodeSnippet(e) {
251
- this.$emit('insert-code-snippet', e);
252
- },
253
- onGetContextItemContent(contextItem) {
254
- this.$emit('get-context-item-content', {
255
- messageId: this.message.id,
256
- contextItem,
257
- });
258
- },
259
- detectScrollableCodeBlocks() {
260
- const codeBlocks = document.querySelectorAll('.duo-chat-message pre');
261
- codeBlocks.forEach((e) => {
262
- if (e.scrollHeight > e.offsetHeight) {
263
- e.classList.add(DUO_CODE_SCRIM_BOTTOM_CLASS);
264
- e.addEventListener(
265
- 'scroll',
266
- throttle(() => this.toggleScrolling(e), 200)
267
- );
268
- }
269
- });
270
- },
271
- toggleScrolling(e) {
272
- if (e.scrollHeight - e.scrollTop <= e.offsetHeight + DUO_CODE_SCRIM_OFFSET) {
273
- e.classList.remove(DUO_CODE_SCRIM_BOTTOM_CLASS);
274
- } else {
275
- e.classList.add(DUO_CODE_SCRIM_BOTTOM_CLASS);
276
- }
277
- if (e.scrollTop > DUO_CODE_SCRIM_OFFSET) {
278
- e.classList.add(DUO_CODE_SCRIM_TOP_CLASS);
279
- } else {
280
- e.classList.remove(DUO_CODE_SCRIM_TOP_CLASS);
281
- }
282
- },
283
- },
284
- };
285
- </script>
286
- <template>
287
- <div
288
- class="duo-chat-message gl-border gl-border-transparent gl-p-4 gl-leading-20 gl-break-anywhere"
289
- :class="{
290
- 'gl-ml-auto gl-rounded-br-none gl-bg-blue-100 gl-text-blue-900': isUserMessage,
291
- 'gl-rounded-bl-none gl-border-1 gl-border-solid gl-border-gray-50 gl-text-default':
292
- isAssistantMessage,
293
- 'gl-bg-subtle': isAssistantMessage && !error,
294
- 'duo-chat-message-with-error gl-bg-red-50': error,
295
- }"
296
- @insert-code-snippet="onInsertCodeSnippet"
297
- >
298
- <gl-icon
299
- v-if="error"
300
- :aria-label="$options.i18n.MESSAGE_ERROR"
301
- name="status_warning_borderless"
302
- :size="16"
303
- class="error-icon gl-border gl-mr-3 gl-shrink-0 gl-rounded-full gl-border-red-500 gl-text-red-600"
304
- data-testid="error"
305
- />
306
- <div ref="content-wrapper" :class="{ 'has-error': error }">
307
- <gl-duo-chat-context-item-selections
308
- v-if="displaySelectedContextItems && isAssistantMessage"
309
- :selections="selectedContextItems"
310
- :title="selectedContextItemsTitle"
311
- :default-collapsed="selectedContextItemsDefaultCollapsed"
312
- variant="assistant"
313
- @get-content="onGetContextItemContent"
314
- />
315
- <div
316
- v-if="error"
317
- ref="error-message"
318
- v-safe-html:[$options.safeHtmlConfigExtension]="renderedError"
319
- ></div>
320
- <div v-else>
321
- <div ref="content" v-safe-html:[$options.safeHtmlConfigExtension]="messageContent"></div>
322
-
323
- <template v-if="isAssistantMessage">
324
- <documentation-sources v-if="sources" :sources="sources" />
325
-
326
- <div class="duo-chat-message-feedback gl-mt-4 gl-flex gl-items-end">
327
- <gl-animated-loader-icon v-if="isChunkAndNotCancelled" :is-on="true" />
328
- <gl-duo-user-feedback
329
- v-if="isNotChunkOrCancelled"
330
- :feedback-received="hasFeedback"
331
- :modal-title="$options.i18n.MODAL.TITLE"
332
- :modal-alert="$options.i18n.MODAL.ALERT_TEXT"
333
- @feedback="logEvent"
334
- >
335
- <template #feedback-extra-fields>
336
- <gl-form-group :label="$options.i18n.MODAL.DID_WHAT" optional>
337
- <gl-form-textarea
338
- v-model="didWhat"
339
- :placeholder="$options.i18n.MODAL.INTERACTION"
340
- />
341
- </gl-form-group>
342
- <gl-form-group :label="$options.i18n.MODAL.IMPROVE_WHAT" optional>
343
- <gl-form-textarea
344
- v-model="improveWhat"
345
- :placeholder="$options.i18n.MODAL.BETTER_RESPONSE"
346
- />
347
- </gl-form-group>
348
- </template>
349
- </gl-duo-user-feedback>
350
- </div>
351
- </template>
352
- </div>
353
- <gl-duo-chat-context-item-selections
354
- v-if="displaySelectedContextItems && isUserMessage"
355
- :selections="selectedContextItems"
356
- :title="selectedContextItemsTitle"
357
- :default-collapsed="selectedContextItemsDefaultCollapsed"
358
- variant="user"
359
- @get-content="onGetContextItemContent"
360
- />
361
- </div>
362
- </div>
363
- </template>
@@ -1,51 +0,0 @@
1
- /**
2
- * This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
3
- *
4
- * Please use the corresponding component in Duo-UI going forward.
5
- * All future development and maintenance for Duo components should take place in Duo-UI.
6
- *
7
- * 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.
8
- */
9
-
10
- import { createButton } from './buttons_utils';
11
-
12
- const CODE_MARKDOWN_CLASS = 'js-markdown-code';
13
-
14
- export class InsertCodeSnippetElement extends HTMLElement {
15
- #actionButton;
16
-
17
- #codeBlock;
18
-
19
- constructor(codeBlock) {
20
- super();
21
- this.#actionButton = createButton();
22
-
23
- // we handle two possible cases here:
24
- // 1. we use constructor parameter if the element is created in Javscript and inserted in the document
25
- // 2. we find the wrapping element containing code if the element is received from the server
26
- this.#codeBlock = codeBlock ?? this.closest(`.${CODE_MARKDOWN_CLASS}`);
27
- }
28
-
29
- #handleClick = () => {
30
- if (this.#codeBlock) {
31
- this.#codeBlock.dispatchEvent(
32
- new CustomEvent('insert-code-snippet', {
33
- bubbles: true,
34
- cancelable: true,
35
- detail: {
36
- code: this.#codeBlock.textContent.trim(),
37
- },
38
- })
39
- );
40
- }
41
- };
42
-
43
- connectedCallback() {
44
- this.appendChild(this.#actionButton);
45
- this.#actionButton.addEventListener('click', this.#handleClick);
46
- }
47
-
48
- disconnectedCallback() {
49
- this.#actionButton.removeEventListener('click', this.#handleClick);
50
- }
51
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
3
- *
4
- * Please use the corresponding component in Duo-UI going forward.
5
- * All future development and maintenance for Duo components should take place in Duo-UI.
6
- *
7
- * 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.
8
- */
9
-
10
- export const concatUntilEmpty = (arr) => {
11
- if (!arr) return '';
12
-
13
- let end = arr.findIndex((el) => !el);
14
-
15
- if (end < 0) end = arr.length;
16
-
17
- return arr.slice(0, end).join('');
18
- };
@@ -1,10 +0,0 @@
1
- <!--
2
- This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
3
-
4
- Please use the corresponding component in Duo-UI going forward.
5
- All future development and maintenance for Duo components should take place in Duo-UI.
6
-
7
- 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.
8
- -->
9
-
10
- A simple component to list documentation sources for a documentation-related AI response messages.
@@ -1,91 +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 { translatePlural } from '../../../../../../utils/i18n';
12
- import GlIcon from '../../../../../base/icon/icon.vue';
13
- import GlLink from '../../../../../base/link/link.vue';
14
- import { DOCUMENTATION_SOURCE_TYPES } from '../../constants';
15
-
16
- export const i18n = {
17
- MESSAGE_SOURCE: (count = 1) =>
18
- translatePlural('GlDuoChatMessageSources.messageSources', 'Source', 'Sources')(count),
19
- };
20
-
21
- export default {
22
- name: 'GlDuoChatMessageSources',
23
- components: {
24
- GlIcon,
25
- GlLink,
26
- },
27
- props: {
28
- /**
29
- * The Array of the message sources.
30
- */
31
- sources: {
32
- type: Array,
33
- required: true,
34
- },
35
- },
36
- computed: {
37
- sourceLabel() {
38
- return i18n.MESSAGE_SOURCE(this.sources.length);
39
- },
40
- },
41
- methods: {
42
- getSourceIcon(sourceType) {
43
- const currentSourceType = Object.values(DOCUMENTATION_SOURCE_TYPES).find(
44
- ({ value }) => value === sourceType
45
- );
46
-
47
- return currentSourceType?.icon || 'document';
48
- },
49
- getSourceTitle({ title, source_type: sourceType, stage, group, date, author }) {
50
- if (title) {
51
- return title;
52
- }
53
-
54
- if (sourceType === DOCUMENTATION_SOURCE_TYPES.DOC.value) {
55
- if (stage && group) {
56
- return `${stage} / ${group}`;
57
- }
58
- }
59
-
60
- if (sourceType === DOCUMENTATION_SOURCE_TYPES.BLOG.value) {
61
- if (date && author) {
62
- return `${date} / ${author}`;
63
- }
64
- }
65
-
66
- return this.sourceLabel;
67
- },
68
- },
69
- };
70
- </script>
71
- <template>
72
- <div class="gl-mr-3 gl-mt-4 gl-text-gray-600" data-testid="duo-chat-message-sources">
73
- <span v-if="sources.length">{{ sourceLabel }}:</span>
74
-
75
- <ul class="gl-m-0 gl-list-none gl-p-0">
76
- <li
77
- v-for="(source, index) in sources"
78
- :key="index"
79
- class="gl-flex gl-items-center gl-pt-3"
80
- data-testid="source-list-item"
81
- >
82
- <gl-icon
83
- v-if="source.source_type"
84
- :name="getSourceIcon(source.source_type)"
85
- class="gl-mr-2 gl-shrink-0"
86
- />
87
- <gl-link :href="source.source_url">{{ getSourceTitle(source) }}</gl-link>
88
- </li>
89
- </ul>
90
- </div>
91
- </template>
@@ -1,10 +0,0 @@
1
- <!--
2
- This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
3
-
4
- Please use the corresponding component in Duo-UI going forward.
5
- All future development and maintenance for Duo components should take place in Duo-UI.
6
-
7
- 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.
8
- -->
9
-
10
- The component is a simple list of strings representing possible prompts to AI.
@@ -1,45 +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 GlButton from '../../../../../base/button/button.vue';
12
-
13
- export default {
14
- name: 'GlDuoChatPredefinedPrompts',
15
- components: {
16
- GlButton,
17
- },
18
- props: {
19
- /**
20
- * Array of predefined prompts to display. Every prompt should be a string which will be converted into a prompt when clicked.
21
- */
22
- prompts: {
23
- type: Array,
24
- required: true,
25
- },
26
- },
27
- methods: {
28
- handleClick(prompt) {
29
- /**
30
- * Emits the prompt string that was clicked.
31
- */
32
- this.$emit('click', prompt);
33
- },
34
- },
35
- };
36
- </script>
37
- <template>
38
- <div class="gl-text-right">
39
- <div v-for="(prompt, index) in prompts" :key="`question-${index}`" class="gl-mt-3">
40
- <gl-button category="secondary" variant="confirm" @click="handleClick(prompt)"
41
- ><span class="gl-whitespace-normal">{{ prompt }}</span></gl-button
42
- >
43
- </div>
44
- </div>
45
- </template>
@@ -1,37 +0,0 @@
1
- /**
2
- * This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
3
- *
4
- * Please use the corresponding component in Duo-UI going forward.
5
- * All future development and maintenance for Duo components should take place in Duo-UI.
6
- *
7
- * 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.
8
- */
9
-
10
- export const CHAT_RESET_MESSAGE = '/reset';
11
- export const CHAT_CLEAR_MESSAGE = '/clear';
12
- export const CHAT_INCLUDE_MESSAGE = '/include';
13
-
14
- export const LOADING_TRANSITION_DURATION = 7500;
15
-
16
- export const DOCUMENTATION_SOURCE_TYPES = {
17
- HANDBOOK: {
18
- value: 'handbook',
19
- icon: 'book',
20
- },
21
- DOC: {
22
- value: 'doc',
23
- icon: 'documents',
24
- },
25
- BLOG: {
26
- value: 'blog',
27
- icon: 'list-bulleted',
28
- },
29
- };
30
-
31
- export const MESSAGE_MODEL_ROLES = {
32
- user: 'user',
33
- system: 'system',
34
- assistant: 'assistant',
35
- };
36
-
37
- export const SELECTED_CONTEXT_ITEMS_DEFAULT_COLLAPSED = true;