@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.
Files changed (82) hide show
  1. package/CHANGELOG.md +13 -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/translations.js +0 -57
  11. package/dist/components/experimental/duo/chat/components/duo_chat_context/constants.js +0 -21
  12. 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
  13. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.js +0 -273
  14. 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
  15. 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
  16. 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
  17. 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
  18. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.js +0 -137
  19. package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.js +0 -163
  20. package/dist/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +0 -308
  21. package/dist/components/experimental/duo/chat/components/duo_chat_context/utils.js +0 -140
  22. package/dist/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.js +0 -109
  23. package/dist/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.js +0 -111
  24. package/dist/components/experimental/duo/chat/components/duo_chat_message/buttons_utils.js +0 -33
  25. package/dist/components/experimental/duo/chat/components/duo_chat_message/constants.js +0 -14
  26. package/dist/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +0 -24
  27. package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +0 -300
  28. package/dist/components/experimental/duo/chat/components/duo_chat_message/insert_code_snippet_element.js +0 -56
  29. package/dist/components/experimental/duo/chat/components/duo_chat_message/utils.js +0 -17
  30. package/dist/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.js +0 -115
  31. package/dist/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.js +0 -72
  32. package/dist/components/experimental/duo/chat/constants.js +0 -35
  33. package/dist/components/experimental/duo/chat/duo_chat.js +0 -553
  34. package/dist/components/experimental/duo/chat/markdown_renderer.js +0 -25
  35. package/dist/components/experimental/duo/chat/mock_data.js +0 -170
  36. package/dist/components/experimental/duo/user_feedback/user_feedback.js +0 -106
  37. package/dist/components/experimental/duo/user_feedback/user_feedback_modal.js +0 -154
  38. package/dist/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.js +0 -106
  39. package/dist/components/experimental/duo/workflow/components/duo_workflow_prompt/duo_workflow_prompt.js +0 -246
  40. package/src/components/experimental/duo/chat/components/duo_chat_context/constants.js +0 -21
  41. 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
  42. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.md +0 -44
  43. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.vue +0 -288
  44. 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
  45. 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
  46. 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
  47. 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
  48. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.vue +0 -170
  49. package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.vue +0 -196
  50. package/src/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +0 -362
  51. package/src/components/experimental/duo/chat/components/duo_chat_context/utils.js +0 -169
  52. package/src/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.md +0 -27
  53. package/src/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.vue +0 -99
  54. package/src/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.md +0 -10
  55. package/src/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.scss +0 -44
  56. package/src/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.vue +0 -112
  57. package/src/components/experimental/duo/chat/components/duo_chat_message/buttons_utils.js +0 -39
  58. package/src/components/experimental/duo/chat/components/duo_chat_message/constants.js +0 -12
  59. package/src/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +0 -24
  60. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.md +0 -69
  61. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.scss +0 -105
  62. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.vue +0 -363
  63. package/src/components/experimental/duo/chat/components/duo_chat_message/insert_code_snippet_element.js +0 -51
  64. package/src/components/experimental/duo/chat/components/duo_chat_message/utils.js +0 -18
  65. package/src/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.md +0 -10
  66. package/src/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.vue +0 -91
  67. package/src/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.md +0 -10
  68. package/src/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.vue +0 -45
  69. package/src/components/experimental/duo/chat/constants.js +0 -37
  70. package/src/components/experimental/duo/chat/duo_chat.md +0 -202
  71. package/src/components/experimental/duo/chat/duo_chat.scss +0 -413
  72. package/src/components/experimental/duo/chat/duo_chat.vue +0 -751
  73. package/src/components/experimental/duo/chat/markdown_renderer.js +0 -29
  74. package/src/components/experimental/duo/chat/mock_data.js +0 -187
  75. package/src/components/experimental/duo/chat/variables.scss +0 -9
  76. package/src/components/experimental/duo/user_feedback/user_feedback.md +0 -90
  77. package/src/components/experimental/duo/user_feedback/user_feedback.vue +0 -95
  78. package/src/components/experimental/duo/user_feedback/user_feedback_modal.vue +0 -167
  79. package/src/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.md +0 -42
  80. package/src/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.vue +0 -96
  81. package/src/components/experimental/duo/workflow/components/duo_workflow_prompt/duo_workflow_prompt.md +0 -46
  82. package/src/components/experimental/duo/workflow/components/duo_workflow_prompt/duo_workflow_prompt.vue +0 -270
@@ -1,362 +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 {
11
- CONTEXT_ITEM_CATEGORY_DEPENDENCY,
12
- CONTEXT_ITEM_CATEGORY_FILE,
13
- CONTEXT_ITEM_CATEGORY_ISSUE,
14
- CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
15
- CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
16
- } from './constants';
17
-
18
- export const MOCK_CATEGORIES = [
19
- { label: 'Files', value: CONTEXT_ITEM_CATEGORY_FILE, icon: 'document' },
20
- { label: 'Local Git', value: CONTEXT_ITEM_CATEGORY_LOCAL_GIT, icon: 'git' },
21
- { label: 'Issues', value: CONTEXT_ITEM_CATEGORY_ISSUE, icon: 'issues' },
22
- { label: 'Merge Requests', value: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST, icon: 'merge-request' },
23
- { label: 'Dependencies', value: CONTEXT_ITEM_CATEGORY_DEPENDENCY, icon: 'package' },
24
- ];
25
-
26
- export function getMockCategory(categoryValue) {
27
- return MOCK_CATEGORIES.find((cat) => cat.value === categoryValue);
28
- }
29
-
30
- export const MOCK_CONTEXT_FILE_CONTENT = `export function waterPlants() {
31
- console.log('sprinkle');
32
- }`;
33
-
34
- export const MOCK_CONTEXT_FILE_DIFF_CONTENT = `diff --git a/src/plants/strawberry.ts b/src/plants/strawberry.ts
35
- index 1234567..8901234 100644
36
- --- a/src/plants/strawberry.ts
37
- +++ b/src/plants/strawberry.ts
38
- @@ -1,4 +1,4 @@
39
- export const strawberry = {
40
- name: 'Strawberry',
41
- - waterNeeds: 'moderate',
42
- + waterNeeds: 'high',
43
- };`;
44
-
45
- export const MOCK_CONTEXT_ITEM_FILE = {
46
- id: '123e4567-e89b-12d3-a456-426614174000',
47
- category: CONTEXT_ITEM_CATEGORY_FILE,
48
- metadata: {
49
- enabled: true,
50
- title: 'strawberry.ts',
51
- secondaryText: 'src/plants/strawberry.ts',
52
- subTypeLabel: 'Project file',
53
- icon: 'document',
54
- project: 'example/garden',
55
- relativePath: 'src/plants/strawberry.ts',
56
- },
57
- };
58
-
59
- export const MOCK_CONTEXT_ITEM_FILE_DISABLED = {
60
- id: '323e4567-e89b-12d3-a456-426614174002',
61
- category: CONTEXT_ITEM_CATEGORY_FILE,
62
- metadata: {
63
- enabled: false,
64
- title: 'motorbike.cs',
65
- secondaryText: '/src/VehicleFoo/motorbike.cs',
66
- subTypeLabel: 'Project file',
67
- icon: 'document',
68
- project: 'example/vehicles',
69
- relativePath: '/src/VehicleFoo/motorbike.cs',
70
- },
71
- };
72
- const mockFiles = [
73
- MOCK_CONTEXT_ITEM_FILE,
74
- {
75
- id: '223e4567-e89b-12d3-a456-426614174001',
76
- category: CONTEXT_ITEM_CATEGORY_FILE,
77
- metadata: {
78
- enabled: true,
79
- title: 'potato.ts',
80
- secondaryText: '/src/plants/potato.ts',
81
- subTypeLabel: 'Project file',
82
- icon: 'document',
83
- project: 'example/garden',
84
- relativePath: '/src/plants/potato.ts',
85
- },
86
- },
87
- MOCK_CONTEXT_ITEM_FILE_DISABLED,
88
- ];
89
-
90
- export const MOCK_CONTEXT_ITEM_ISSUE = {
91
- id: '423e4567-e89b-12d3-a456-426614174003',
92
- category: CONTEXT_ITEM_CATEGORY_ISSUE,
93
- metadata: {
94
- enabled: true,
95
- title: 'Implement watering schedule',
96
- secondaryText: 'example/garden#1234',
97
- subTypeLabel: 'Issue',
98
- icon: 'issues',
99
- iid: 1234,
100
- },
101
- };
102
- export const MOCK_CONTEXT_ITEM_ISSUE_DISABLED = {
103
- id: 'c463fb31-2a4c-4f8e-a609-97230ac48ae5',
104
- category: CONTEXT_ITEM_CATEGORY_ISSUE,
105
-
106
- metadata: {
107
- enabled: false,
108
- disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
109
- title: `Fix vehicle colours and make them look real nice and colourful won't that be wonderful wow this issue title is really long I sure hope it's gonna wrap OK`,
110
- secondaryText: 'example/vehicle#91011',
111
- subTypeLabel: 'Issue',
112
- icon: 'issues',
113
- iid: 91011,
114
- },
115
- };
116
-
117
- const mockIssues = [
118
- MOCK_CONTEXT_ITEM_ISSUE,
119
- {
120
- id: '523e4567-e89b-12d3-a456-426614174004',
121
- category: CONTEXT_ITEM_CATEGORY_ISSUE,
122
- metadata: {
123
- enabled: true,
124
- title: 'Refactor plant growth rates',
125
- secondaryText: 'example/garden#5678',
126
- subTypeLabel: 'Issue',
127
- icon: 'issues',
128
- iid: 5678,
129
- },
130
- },
131
- MOCK_CONTEXT_ITEM_ISSUE_DISABLED,
132
- ];
133
-
134
- export const MOCK_CONTEXT_ITEM_MERGE_REQUEST = {
135
- id: '623e4567-e89b-12d3-a456-426614174005',
136
- category: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
137
- metadata: {
138
- enabled: true,
139
- title: 'Improve database performance',
140
- secondaryText: 'example/garden!1122',
141
- subTypeLabel: 'Merge request',
142
- icon: 'merge-request',
143
- iid: 1122,
144
- },
145
- };
146
- export const MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED = {
147
- id: '4eb665fc-e5e1-49b0-9789-2a16964e461a',
148
- category: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
149
- metadata: {
150
- enabled: false,
151
- disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
152
- title: 'Fix broken layout at small viewports',
153
- secondaryText: 'example/vehicle!5566',
154
- subTypeLabel: 'Merge request',
155
- icon: 'merge-request',
156
- iid: 5566,
157
- },
158
- };
159
-
160
- const mockMergeRequests = [
161
- MOCK_CONTEXT_ITEM_MERGE_REQUEST,
162
- {
163
- id: '723e4567-e89b-12d3-a456-426614174006',
164
- category: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
165
- metadata: {
166
- enabled: false,
167
- disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
168
- title: 'Add vehicle registration details',
169
- secondaryText: 'example/vehicle!3344',
170
- subTypeLabel: 'Merge request',
171
- icon: 'merge-request',
172
- iid: 3344,
173
- },
174
- },
175
- MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED,
176
- ];
177
-
178
- export const MOCK_CONTEXT_ITEM_GIT_DIFF = {
179
- id: '6d88b466-0c38-48d6-b271-deda47f97cee',
180
- category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
181
- metadata: {
182
- enabled: true,
183
- title: 'Current working changes',
184
- secondaryText: 'main',
185
- subType: 'local_git',
186
- subTypeLabel: 'Local Git repository diff',
187
- icon: 'comparison',
188
- commitId: 'main',
189
- repositoryName: 'example/garden',
190
- gitType: 'diff',
191
- },
192
- };
193
- export const MOCK_CONTEXT_ITEM_GIT_COMMIT = {
194
- id: '20f8caf94cb8f5e5f9dbd1a9ac32702321de201b',
195
- category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
196
- metadata: {
197
- enabled: true,
198
- title: 'fix: some bug fix commit',
199
- secondaryText: '20f8caf94cb8f5e5f9dbd1a9ac32702321de201b',
200
- subType: 'local_git',
201
- subTypeLabel: 'Local Git repository commit',
202
- icon: 'commit',
203
- commitId: '20f8caf94cb8f5e5f9dbd1a9ac32702321de201b',
204
- repositoryName: 'example/garden',
205
- gitType: 'commit',
206
- },
207
- };
208
-
209
- const mockGitItems = [
210
- MOCK_CONTEXT_ITEM_GIT_DIFF,
211
- {
212
- id: 'diff-example/garden',
213
- category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
214
- metadata: {
215
- enabled: true,
216
- title: 'Diff from default branch',
217
- secondaryText: 'main',
218
- subTypeLabel: 'Local Git repository diff',
219
- icon: 'comparison',
220
- commitId: 'main',
221
- repositoryName: 'example/garden',
222
- gitType: 'diff',
223
- },
224
- },
225
- MOCK_CONTEXT_ITEM_GIT_COMMIT,
226
- {
227
- id: '32b9b56b6de75b32909986755fbc470f20fb6fc0',
228
- category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
229
- metadata: {
230
- enabled: true,
231
- title: 'feat: add cool new feature',
232
- secondaryText: '32b9b56b6de75b32909986755fbc470f20fb6fc0',
233
- subTypeLabel: 'Local Git repository commit',
234
- icon: 'commit',
235
- commitId: '32b9b56b6de75b32909986755fbc470f20fb6fc0',
236
- repositoryName: 'example/garden',
237
- gitType: 'commit',
238
- },
239
- },
240
- {
241
- id: '775d7efdce25c1af48c55abcadbefd1f181b92ce',
242
- category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
243
- metadata: {
244
- enabled: true,
245
- title: 'fix: stop foo from bar when baz because customers ding',
246
- secondaryText: '775d7efdce25c1af48c55abcadbefd1f181b92ce',
247
- subTypeLabel: 'Local Git repository commit',
248
- icon: 'commit',
249
- commitId: '775d7efdce25c1af48c55abcadbefd1f181b92ce',
250
- repositoryName: 'example/garden',
251
- gitType: 'commit',
252
- },
253
- },
254
- ];
255
-
256
- export const MOCK_CONTEXT_ITEM_DEPENDENCY = {
257
- id: '823e4567-e89b-12d3-a456-426614174007',
258
- category: CONTEXT_ITEM_CATEGORY_DEPENDENCY,
259
- content: JSON.stringify([
260
- {
261
- javascript: [
262
- '@types/node@16.11.7',
263
- '@vue/compiler-sfc@3.2.37',
264
- 'typescript@4.5.5',
265
- 'vue@3.2.37',
266
- ],
267
- },
268
- ]),
269
- metadata: {
270
- enabled: true,
271
- title: 'example/garden',
272
- secondaryText: 'package.json',
273
- icon: 'package',
274
- subType: 'dependency',
275
- subTypeLabel: 'Project dependencies',
276
- project: 'example/garden',
277
- },
278
- };
279
-
280
- export const MOCK_CONTEXT_ITEM_DEPENDENCY_DISABLED = {
281
- id: '923e4567-e89b-12d3-a456-426614174008',
282
- category: CONTEXT_ITEM_CATEGORY_DEPENDENCY,
283
- content: JSON.stringify([
284
- {
285
- javascript: [
286
- '@types/node@16.11.7',
287
- '@vue/compiler-sfc@3.2.37',
288
- 'typescript@4.5.5',
289
- 'vue@3.2.37',
290
- ],
291
- csharp: ['newtonsoft.json@13.0.1', 'microsoft.net.test.sdk@16.11.0'],
292
- },
293
- ]),
294
- metadata: {
295
- enabled: false,
296
- disabledReasons: ['Dependencies are not available for this project', 'Access restricted'],
297
- title: 'example/vehicle',
298
- secondaryText: 'package.json, vehicle.csproj',
299
- icon: 'package',
300
- subType: 'dependency',
301
- subTypeLabel: 'Project dependencies',
302
- project: 'example/vehicle',
303
- },
304
- };
305
-
306
- const mockDependencies = [
307
- MOCK_CONTEXT_ITEM_DEPENDENCY,
308
- MOCK_CONTEXT_ITEM_DEPENDENCY_DISABLED,
309
- {
310
- id: 'b23e4567-e89b-12d3-a456-426614174010',
311
- category: CONTEXT_ITEM_CATEGORY_DEPENDENCY,
312
- content: JSON.stringify([
313
- {
314
- python: ['django@3.2.9', 'djangorestframework@3.12.4', 'psycopg2@2.9.2', 'celery@5.2.1'],
315
- csharp: ['newtonsoft.json@13.0.1', 'microsoft.net.test.sdk@16.11.0'],
316
- },
317
- ]),
318
- metadata: {
319
- enabled: true,
320
- title: 'example/backend',
321
- secondaryText: 'requirements.txt, some.backend.csproj',
322
- icon: 'package',
323
- subType: 'dependency',
324
- subTypeLabel: 'Project dependencies',
325
- project: 'example/backend',
326
- },
327
- },
328
- {
329
- id: 'c23e4567-e89b-12d3-a456-426614174011',
330
- category: CONTEXT_ITEM_CATEGORY_DEPENDENCY,
331
- content: JSON.stringify([
332
- {
333
- javascript: ['jquery@3.5.1', 'backbone@1.4.0', 'underscore@1.13.1', 'moment@2.29.1'],
334
- },
335
- ]),
336
- metadata: {
337
- enabled: false,
338
- disabledReasons: ['Project is archived'],
339
- title: 'example/legacy',
340
- secondaryText: 'bower.json',
341
- icon: 'package',
342
- subType: 'dependency',
343
- subTypeLabel: 'Project dependencies',
344
- project: 'example/legacy',
345
- },
346
- },
347
- ];
348
-
349
- export const getMockContextItems = () => {
350
- const allItems = [
351
- ...mockFiles,
352
- ...mockGitItems,
353
- ...mockIssues,
354
- ...mockMergeRequests,
355
- ...mockDependencies,
356
- ];
357
-
358
- // put disabled items in the back
359
- const disabledItems = allItems.filter((item) => !item.metadata.enabled);
360
- const enabledItems = allItems.filter((item) => item.metadata.enabled);
361
- return [...enabledItems, ...disabledItems];
362
- };
@@ -1,169 +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 { translate } from '../../../../../../utils/i18n';
11
- import {
12
- CONTEXT_ITEM_CATEGORY_FILE,
13
- CONTEXT_ITEM_CATEGORY_ISSUE,
14
- CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
15
- CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
16
- CONTEXT_ITEM_LOCAL_GIT_COMMIT,
17
- CONTEXT_ITEM_LOCAL_GIT_DIFF,
18
- } from './constants';
19
-
20
- export function categoryValidator(category) {
21
- return Boolean(category && category.value && category.label && category.icon);
22
- }
23
-
24
- export function categoriesValidator(categories) {
25
- return Array.isArray(categories) && categories.every((category) => categoryValidator(category));
26
- }
27
-
28
- function disabledReasonsValidator(disabledReasons) {
29
- return (
30
- disabledReasons === undefined ||
31
- (Array.isArray(disabledReasons) &&
32
- disabledReasons.every((reason) => typeof reason === 'string'))
33
- );
34
- }
35
-
36
- export function contextItemValidator(item) {
37
- return Boolean(
38
- item &&
39
- item.id &&
40
- item.category &&
41
- item.metadata &&
42
- typeof item.metadata === 'object' &&
43
- typeof item.metadata.enabled === 'boolean' &&
44
- disabledReasonsValidator(item.metadata.disabledReasons)
45
- );
46
- }
47
-
48
- export function contextItemsValidator(items) {
49
- return Array.isArray(items) && items.every((item) => contextItemValidator(item));
50
- }
51
-
52
- export function formatIssueId(iid) {
53
- if (!iid) return '';
54
-
55
- return `#${iid}`;
56
- }
57
-
58
- export function formatMergeRequestId(iid) {
59
- if (!iid) return '';
60
-
61
- return `!${iid}`;
62
- }
63
-
64
- export function getContextItemSource(contextItem) {
65
- return contextItem.metadata.repositoryName || contextItem.metadata.project || null;
66
- }
67
-
68
- function getGitItemIcon(contextItem) {
69
- const iconMap = {
70
- [CONTEXT_ITEM_LOCAL_GIT_COMMIT]: 'commit',
71
- [CONTEXT_ITEM_LOCAL_GIT_DIFF]: 'comparison',
72
- };
73
- const { gitType } = contextItem.metadata;
74
- return iconMap[gitType] || null;
75
- }
76
-
77
- /**
78
- * Gets the icon name for a given contextItem.
79
- */
80
- export function getContextItemIcon(contextItem, category = { icon: null }) {
81
- if (contextItem.metadata.icon) {
82
- return contextItem.metadata.icon;
83
- }
84
-
85
- if (contextItem.category === CONTEXT_ITEM_CATEGORY_LOCAL_GIT) {
86
- const gitIcon = getGitItemIcon(contextItem);
87
- if (gitIcon) return gitIcon;
88
- }
89
-
90
- if (category.icon) {
91
- return category.icon;
92
- }
93
-
94
- const iconMap = {
95
- [CONTEXT_ITEM_CATEGORY_FILE]: 'document',
96
- [CONTEXT_ITEM_CATEGORY_ISSUE]: 'issues',
97
- [CONTEXT_ITEM_CATEGORY_MERGE_REQUEST]: 'merge-request',
98
- [CONTEXT_ITEM_CATEGORY_LOCAL_GIT]: 'git',
99
- };
100
-
101
- return iconMap[contextItem.category] || null;
102
- }
103
-
104
- export function getContextItemTypeLabel(contextItem) {
105
- if (contextItem.metadata.subTypeLabel) {
106
- return contextItem.metadata.subTypeLabel;
107
- }
108
-
109
- if (contextItem.category === CONTEXT_ITEM_CATEGORY_LOCAL_GIT) {
110
- switch (contextItem.metadata.gitType) {
111
- case CONTEXT_ITEM_LOCAL_GIT_DIFF:
112
- return translate('DuoChatContextItemTypeLabel.GitDiff', 'Local Git repository diff');
113
- case CONTEXT_ITEM_LOCAL_GIT_COMMIT:
114
- return translate('DuoChatContextItemTypeLabel.GitCommit', 'Local Git repository commit');
115
- default:
116
- return translate('DuoChatContextItemTypeLabel.GitDefault', 'Local Git repository');
117
- }
118
- }
119
-
120
- switch (contextItem.category) {
121
- case CONTEXT_ITEM_CATEGORY_MERGE_REQUEST:
122
- return translate('DuoChatContextItemTypeLabel.MergeRequest', 'Merge request');
123
- case CONTEXT_ITEM_CATEGORY_ISSUE:
124
- return translate('DuoChatContextItemTypeLabel.Issue', 'Issue');
125
- case CONTEXT_ITEM_CATEGORY_FILE:
126
- return translate('DuoChatContextItemTypeLabel.File', 'Project file');
127
- default:
128
- return '';
129
- }
130
- }
131
-
132
- /**
133
- * Gets the secondary text line for a git context item, showing repository and commit ID
134
- */
135
- export function formatGitItemSecondaryText(contextItem) {
136
- const { repositoryName, commitId } = contextItem.metadata;
137
- const separator = commitId ? ' - ' : '';
138
- return `${repositoryName}${separator}${commitId || ''}`;
139
- }
140
-
141
- export function getContextItemSecondaryText(contextItem) {
142
- if (contextItem.metadata.secondaryText) {
143
- return contextItem.metadata.secondaryText;
144
- }
145
-
146
- switch (contextItem.category) {
147
- case CONTEXT_ITEM_CATEGORY_FILE:
148
- return contextItem.metadata.relativePath;
149
- case CONTEXT_ITEM_CATEGORY_ISSUE:
150
- return formatIssueId(contextItem.metadata.iid);
151
- case CONTEXT_ITEM_CATEGORY_MERGE_REQUEST:
152
- return formatMergeRequestId(contextItem.metadata.iid);
153
- case CONTEXT_ITEM_CATEGORY_LOCAL_GIT:
154
- return formatGitItemSecondaryText(contextItem);
155
- default:
156
- return '';
157
- }
158
- }
159
-
160
- /**
161
- * Calculates a new index within a range. If the new index would fall out of bounds, wraps to the start/end of the range.
162
- * @param {number} currentIndex - The starting index.
163
- * @param {number} step - The number of steps to move (positive or negative).
164
- * @param {number} totalLength - The total number of items in the range.
165
- * @returns {number} The new index.
166
- */
167
- export function wrapIndex(currentIndex, step, totalLength) {
168
- return (currentIndex + step + totalLength) % totalLength;
169
- }
@@ -1,27 +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 component that lists messages in a conversation, and presents an optional delimiter to
11
- mark the beginning of the conversation.
12
-
13
- ## Usage
14
-
15
- ```html
16
- <gl-duo-chat-conversation :messages="messages" :show-delimeter="showDelimiter" />
17
- ```
18
-
19
- Translations for newChatLabel can be set via the props as documented or via translation configuration:
20
-
21
- ```js
22
- setConfigs({
23
- translations: {
24
- 'GlDuoWorkflowPrompt.newChat': __('New chat'),
25
- },
26
- });
27
- ```
@@ -1,99 +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 GlDuoChatMessage from '../duo_chat_message/duo_chat_message.vue';
12
- import { translate } from '../../../../../../utils/i18n';
13
-
14
- const i18n = {
15
- CONVERSATION_NEW_CHAT: translate('GlDuoChatConversation.newChat', 'New chat'),
16
- };
17
-
18
- const isMessage = (item) => Boolean(item) && item?.role;
19
-
20
- // eslint-disable-next-line unicorn/no-array-callback-reference
21
- const itemsValidator = (items) => items.every(isMessage);
22
-
23
- export default {
24
- name: 'GlDuoChatConversation',
25
- components: {
26
- GlDuoChatMessage,
27
- },
28
- props: {
29
- /**
30
- * Messages to display
31
- */
32
- messages: {
33
- type: Array,
34
- required: false,
35
- default: () => [],
36
- validator: itemsValidator,
37
- },
38
- canceledRequestIds: {
39
- type: Array,
40
- required: true,
41
- },
42
- /**
43
- * Whether the insertCode feature should be available.
44
- */
45
- enableCodeInsertion: {
46
- type: Boolean,
47
- required: true,
48
- },
49
- /**
50
- * Whether to show the delimiter before this conversation
51
- */
52
- showDelimiter: {
53
- type: Boolean,
54
- required: false,
55
- default: true,
56
- },
57
- },
58
- methods: {
59
- onTrackFeedback(event) {
60
- /**
61
- * Notify listeners about the feedback form submission on a response message.
62
- * @param {*} event An event, containing the feedback choices and the extended feedback text.
63
- */
64
- this.$emit('track-feedback', event);
65
- },
66
- onInsertCodeSnippet(e) {
67
- this.$emit('insert-code-snippet', e);
68
- },
69
- onGetContextItemContent(e) {
70
- this.$emit('get-context-item-content', e);
71
- },
72
- },
73
- i18n,
74
- };
75
- </script>
76
- <template>
77
- <div
78
- :class="['gl-flex gl-flex-col gl-justify-end', { 'insert-code-hidden': !enableCodeInsertion }]"
79
- >
80
- <div
81
- v-if="showDelimiter"
82
- class="gl-my-5 gl-flex gl-items-center gl-gap-4 gl-text-gray-500"
83
- data-testid="conversation-delimiter"
84
- >
85
- <hr class="gl-grow" />
86
- <span>{{ $options.i18n.CONVERSATION_NEW_CHAT }}</span>
87
- <hr class="gl-grow" />
88
- </div>
89
- <gl-duo-chat-message
90
- v-for="(msg, index) in messages"
91
- :key="`${msg.role}-${index}`"
92
- :message="msg"
93
- :is-cancelled="canceledRequestIds.includes(msg.requestId)"
94
- @track-feedback="onTrackFeedback"
95
- @insert-code-snippet="onInsertCodeSnippet"
96
- @get-context-item-content="onGetContextItemContent"
97
- />
98
- </div>
99
- </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 Duo Chat loader. Is shown while waiting for the chat response.