@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,246 +0,0 @@
|
|
|
1
|
-
import GlDuoWorkflowPanel from '../duo_workflow_panel/duo_workflow_panel';
|
|
2
|
-
import GlButton from '../../../../../base/button/button';
|
|
3
|
-
import GlFormGroup from '../../../../../base/form/form_group/form_group';
|
|
4
|
-
import GlFormTextarea from '../../../../../base/form/form_textarea/form_textarea';
|
|
5
|
-
import GlFormInput from '../../../../../base/form/form_input/form_input';
|
|
6
|
-
import { translate } from '../../../../../../utils/i18n';
|
|
7
|
-
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
|
|
11
|
-
*
|
|
12
|
-
* Please use the corresponding component in Duo-UI going forward.
|
|
13
|
-
* All future development and maintenance for Duo components should take place in Duo-UI.
|
|
14
|
-
*
|
|
15
|
-
* 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.
|
|
16
|
-
*/
|
|
17
|
-
var script = {
|
|
18
|
-
name: 'GlDuoWorkflowPrompt',
|
|
19
|
-
components: {
|
|
20
|
-
GlDuoWorkflowPanel,
|
|
21
|
-
GlButton,
|
|
22
|
-
GlFormGroup,
|
|
23
|
-
GlFormInput,
|
|
24
|
-
GlFormTextarea
|
|
25
|
-
},
|
|
26
|
-
props: {
|
|
27
|
-
/**
|
|
28
|
-
* The prompt the user has entered
|
|
29
|
-
*/
|
|
30
|
-
prompt: {
|
|
31
|
-
type: String,
|
|
32
|
-
required: false,
|
|
33
|
-
default: ''
|
|
34
|
-
},
|
|
35
|
-
/**
|
|
36
|
-
* The image to run the workflow in
|
|
37
|
-
*/
|
|
38
|
-
image: {
|
|
39
|
-
type: String,
|
|
40
|
-
required: false,
|
|
41
|
-
default: ''
|
|
42
|
-
},
|
|
43
|
-
/**
|
|
44
|
-
* The text for the title of the panel
|
|
45
|
-
*/
|
|
46
|
-
title: {
|
|
47
|
-
type: String,
|
|
48
|
-
required: false,
|
|
49
|
-
default: translate('GlDuoWorkflowPrompt.title', 'Goal')
|
|
50
|
-
},
|
|
51
|
-
/**
|
|
52
|
-
* The summary of the ongoing workflow plan
|
|
53
|
-
*/
|
|
54
|
-
summary: {
|
|
55
|
-
type: String,
|
|
56
|
-
required: false,
|
|
57
|
-
default: ''
|
|
58
|
-
},
|
|
59
|
-
/**
|
|
60
|
-
* Whether or not the panel is loading
|
|
61
|
-
*/
|
|
62
|
-
loading: {
|
|
63
|
-
type: Boolean,
|
|
64
|
-
required: false,
|
|
65
|
-
default: false
|
|
66
|
-
},
|
|
67
|
-
/**
|
|
68
|
-
* The label of the prompt text area
|
|
69
|
-
*
|
|
70
|
-
* See `GlFormGroup` for text placement.
|
|
71
|
-
*/
|
|
72
|
-
promptLabel: {
|
|
73
|
-
type: String,
|
|
74
|
-
required: false,
|
|
75
|
-
default: translate('GlDuoWorkflowPrompt.promptLabel', 'Description')
|
|
76
|
-
},
|
|
77
|
-
/**
|
|
78
|
-
* The label description of the prompt text area
|
|
79
|
-
*
|
|
80
|
-
* See `GlFormGroup` for text placement.
|
|
81
|
-
*/
|
|
82
|
-
promptLabelDescription: {
|
|
83
|
-
type: String,
|
|
84
|
-
required: false,
|
|
85
|
-
default: translate('GlDuoWorkflowPrompt.promptLabelDescription', 'What would you like to do and how.')
|
|
86
|
-
},
|
|
87
|
-
/**
|
|
88
|
-
* The description of the prompt text area
|
|
89
|
-
*
|
|
90
|
-
* See `GlFormGroup` for text placement.
|
|
91
|
-
*/
|
|
92
|
-
promptDescription: {
|
|
93
|
-
type: String,
|
|
94
|
-
required: false,
|
|
95
|
-
default: translate('GlDuoWorkflowPrompt.promptDescription', 'Be specific and include any requirements.')
|
|
96
|
-
},
|
|
97
|
-
/**
|
|
98
|
-
* The HTML ID of the textarea for the prompt
|
|
99
|
-
*/
|
|
100
|
-
promptId: {
|
|
101
|
-
type: String,
|
|
102
|
-
required: false,
|
|
103
|
-
default: 'duo-workflow-prompt'
|
|
104
|
-
},
|
|
105
|
-
/**
|
|
106
|
-
* The label of the image input
|
|
107
|
-
*/
|
|
108
|
-
imageLabel: {
|
|
109
|
-
type: String,
|
|
110
|
-
required: false,
|
|
111
|
-
default: translate('GlDuoWorkflowPrompt.imageLabel', 'Image')
|
|
112
|
-
},
|
|
113
|
-
/**
|
|
114
|
-
* The label description of the image input
|
|
115
|
-
*
|
|
116
|
-
* See `GlFormGroup` for text placement.
|
|
117
|
-
*/
|
|
118
|
-
imageLabelDescription: {
|
|
119
|
-
type: String,
|
|
120
|
-
required: false,
|
|
121
|
-
default: translate('GlDuoWorkflowPrompt.imageLabelDescription', 'The container image to run the workflow in.')
|
|
122
|
-
},
|
|
123
|
-
/**
|
|
124
|
-
* The description of the image input
|
|
125
|
-
*
|
|
126
|
-
* See `GlFormGroup` for text placement.
|
|
127
|
-
*/
|
|
128
|
-
imageDescription: {
|
|
129
|
-
type: String,
|
|
130
|
-
required: false,
|
|
131
|
-
default: translate('GlDuoWorkflowPrompt.imageDescription', 'It should have any tools necessary for the workflow installed.')
|
|
132
|
-
},
|
|
133
|
-
/**
|
|
134
|
-
* The ID of the image input
|
|
135
|
-
*/
|
|
136
|
-
imageId: {
|
|
137
|
-
type: String,
|
|
138
|
-
required: false,
|
|
139
|
-
default: 'duo-workflow-image'
|
|
140
|
-
},
|
|
141
|
-
/**
|
|
142
|
-
* The text for the confirmation button. This button emits a `confirm` event.
|
|
143
|
-
*/
|
|
144
|
-
confirmButtonText: {
|
|
145
|
-
type: String,
|
|
146
|
-
required: false,
|
|
147
|
-
default: translate('GlDuoWorkflowPrompt.confirmButtonText', 'Generate plan')
|
|
148
|
-
},
|
|
149
|
-
/**
|
|
150
|
-
* The text for the cancellation button. This button emits a `cancel` event.
|
|
151
|
-
*/
|
|
152
|
-
cancelButtonText: {
|
|
153
|
-
type: String,
|
|
154
|
-
required: false,
|
|
155
|
-
default: translate('GlDuoWorkflowPrompt.cancelButtonText', 'Cancel')
|
|
156
|
-
},
|
|
157
|
-
/**
|
|
158
|
-
* The text used as the title and aria-label for the button when the collapse is collapsed
|
|
159
|
-
*
|
|
160
|
-
* See `GlDuoWorkflowPanel`
|
|
161
|
-
*/
|
|
162
|
-
expandPanelButtonTitle: {
|
|
163
|
-
type: String,
|
|
164
|
-
required: false,
|
|
165
|
-
default: ''
|
|
166
|
-
},
|
|
167
|
-
/**
|
|
168
|
-
* The text used as the title and aria-label for the button when the collapse is expanded
|
|
169
|
-
*
|
|
170
|
-
* See `GlDuoWorkflowPanel`
|
|
171
|
-
*/
|
|
172
|
-
collapsePanelButtonTitle: {
|
|
173
|
-
type: String,
|
|
174
|
-
required: false,
|
|
175
|
-
default: ''
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
methods: {
|
|
179
|
-
emitChange(prompt) {
|
|
180
|
-
/**
|
|
181
|
-
* Notify listeners about prompt change
|
|
182
|
-
* @param {string} prompt The newly entered prompt
|
|
183
|
-
*/
|
|
184
|
-
this.$emit('update:prompt', prompt);
|
|
185
|
-
},
|
|
186
|
-
emitImage(image) {
|
|
187
|
-
/**
|
|
188
|
-
* Notify listeners about image change
|
|
189
|
-
* @param {string} image The newly entered image
|
|
190
|
-
*/
|
|
191
|
-
this.$emit('update:image', image);
|
|
192
|
-
},
|
|
193
|
-
clickConfirm(event) {
|
|
194
|
-
/**
|
|
195
|
-
* Notify listeners about prompt submission
|
|
196
|
-
* @param {*} event A click event
|
|
197
|
-
*/
|
|
198
|
-
this.$emit('confirm', event);
|
|
199
|
-
},
|
|
200
|
-
clickCancel(event) {
|
|
201
|
-
/**
|
|
202
|
-
* Notify listeners about prompt submission cancellation.
|
|
203
|
-
* @param {*} event A click event
|
|
204
|
-
*/
|
|
205
|
-
this.$emit('cancel', event);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
/* script */
|
|
211
|
-
const __vue_script__ = script;
|
|
212
|
-
|
|
213
|
-
/* template */
|
|
214
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-duo-workflow-panel',{attrs:{"header-icon":"issue-type-objective","expand-panel-button-title":_vm.expandPanelButtonTitle,"collapse-panel-button-title":_vm.collapsePanelButtonTitle},scopedSlots:_vm._u([{key:"title",fn:function(){return [_vm._v(_vm._s(_vm.title))]},proxy:true},{key:"subtitle",fn:function(){return [_vm._v(_vm._s(_vm.summary))]},proxy:true},{key:"content",fn:function(){return [_c('gl-form-group',{attrs:{"label":_vm.promptLabel,"label-for":_vm.promptId,"label-description":_vm.promptLabelDescription,"description":_vm.promptDescription}},[_c('gl-form-textarea',{attrs:{"id":_vm.promptId,"value":_vm.prompt,"disable":_vm.loading,"no-resize":false},on:{"input":_vm.emitChange}})],1),_vm._v(" "),_c('gl-form-group',{attrs:{"label":_vm.imageLabel,"label-for":_vm.imageId,"label-description":_vm.imageLabelDescription,"description":_vm.imageDescription}},[_c('gl-form-input',{attrs:{"id":_vm.imageId,"value":_vm.image,"disable":_vm.loading},on:{"input":_vm.emitImage}})],1),_vm._v(" "),_c('div',{staticClass:"gl-flex gl-gap-3"},[_c('gl-button',{attrs:{"variant":"confirm","data-test-id":"duo-workflow-prompt-confirm","loading":_vm.loading},on:{"click":_vm.clickConfirm}},[_vm._v(_vm._s(_vm.confirmButtonText))]),_vm._v(" "),_c('gl-button',{attrs:{"data-test-id":"duo-workflow-prompt-cancel"},on:{"click":_vm.clickCancel}},[_vm._v(_vm._s(_vm.cancelButtonText))])],1)]},proxy:true}])})};
|
|
215
|
-
var __vue_staticRenderFns__ = [];
|
|
216
|
-
|
|
217
|
-
/* style */
|
|
218
|
-
const __vue_inject_styles__ = undefined;
|
|
219
|
-
/* scoped */
|
|
220
|
-
const __vue_scope_id__ = undefined;
|
|
221
|
-
/* module identifier */
|
|
222
|
-
const __vue_module_identifier__ = undefined;
|
|
223
|
-
/* functional template */
|
|
224
|
-
const __vue_is_functional_template__ = false;
|
|
225
|
-
/* style inject */
|
|
226
|
-
|
|
227
|
-
/* style inject SSR */
|
|
228
|
-
|
|
229
|
-
/* style inject shadow dom */
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const __vue_component__ = __vue_normalize__(
|
|
234
|
-
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
235
|
-
__vue_inject_styles__,
|
|
236
|
-
__vue_script__,
|
|
237
|
-
__vue_scope_id__,
|
|
238
|
-
__vue_is_functional_template__,
|
|
239
|
-
__vue_module_identifier__,
|
|
240
|
-
false,
|
|
241
|
-
undefined,
|
|
242
|
-
undefined,
|
|
243
|
-
undefined
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
export default __vue_component__;
|
|
@@ -1,21 +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 CONTEXT_ITEM_CATEGORY_ISSUE = 'issue';
|
|
11
|
-
export const CONTEXT_ITEM_CATEGORY_MERGE_REQUEST = 'merge_request';
|
|
12
|
-
export const CONTEXT_ITEM_CATEGORY_FILE = 'file';
|
|
13
|
-
export const CONTEXT_ITEM_CATEGORY_LOCAL_GIT = 'local_git';
|
|
14
|
-
export const CONTEXT_ITEM_CATEGORY_DEPENDENCY = 'dependency';
|
|
15
|
-
|
|
16
|
-
export const CONTEXT_ITEM_LOCAL_GIT_COMMIT = 'commit';
|
|
17
|
-
export const CONTEXT_ITEM_LOCAL_GIT_DIFF = 'diff';
|
|
18
|
-
|
|
19
|
-
export const LANGUAGE_IDENTIFIER_PREFIX = 'language-';
|
|
20
|
-
export const LANGUAGE_IDENTIFIER_DIFF = 'language-diff';
|
|
21
|
-
export const LANGUAGE_IDENTIFIER_PLAINTEXT = 'language-plaintext';
|
|
@@ -1,182 +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 { nextTick } from 'vue';
|
|
12
|
-
import { contextItemValidator } from '../utils';
|
|
13
|
-
import GlModal from '../../../../../../base/modal/modal.vue';
|
|
14
|
-
import { SafeHtmlDirective as SafeHtml } from '../../../../../../../directives/safe_html/safe_html';
|
|
15
|
-
import GlSkeletonLoader from '../../../../../../base/skeleton_loader/skeleton_loader.vue';
|
|
16
|
-
import { translate } from '../../../../../../../utils/i18n';
|
|
17
|
-
import {
|
|
18
|
-
CONTEXT_ITEM_CATEGORY_DEPENDENCY,
|
|
19
|
-
CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
|
|
20
|
-
LANGUAGE_IDENTIFIER_DIFF,
|
|
21
|
-
LANGUAGE_IDENTIFIER_PLAINTEXT,
|
|
22
|
-
LANGUAGE_IDENTIFIER_PREFIX,
|
|
23
|
-
} from '../constants';
|
|
24
|
-
import GlAlert from '../../../../../../base/alert/alert.vue';
|
|
25
|
-
|
|
26
|
-
export default {
|
|
27
|
-
name: 'GlDuoChatContextItemDetailsModal',
|
|
28
|
-
components: {
|
|
29
|
-
GlAlert,
|
|
30
|
-
GlSkeletonLoader,
|
|
31
|
-
GlModal,
|
|
32
|
-
},
|
|
33
|
-
directives: {
|
|
34
|
-
SafeHtml,
|
|
35
|
-
},
|
|
36
|
-
inject: {
|
|
37
|
-
renderGFM: {
|
|
38
|
-
from: 'renderGFM',
|
|
39
|
-
default: () => (element) => {
|
|
40
|
-
element.classList.add('duo-chat-markdown', 'duo-chat-compact-markdown');
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
props: {
|
|
45
|
-
/**
|
|
46
|
-
* Context items to preview. If it has no `content`, the loading state will be displayed.
|
|
47
|
-
*/
|
|
48
|
-
contextItem: {
|
|
49
|
-
type: Object,
|
|
50
|
-
required: true,
|
|
51
|
-
validator: contextItemValidator,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
data() {
|
|
55
|
-
return {
|
|
56
|
-
contentErrorIsVisible: false,
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
computed: {
|
|
60
|
-
isLoadingContent() {
|
|
61
|
-
return this.contextItem.content === undefined;
|
|
62
|
-
},
|
|
63
|
-
languageIdentifierClass() {
|
|
64
|
-
if (this.contextItem.category === CONTEXT_ITEM_CATEGORY_LOCAL_GIT) {
|
|
65
|
-
return LANGUAGE_IDENTIFIER_DIFF;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const fileExtension = this.contextItem.metadata?.relativePath?.split('.').at(-1);
|
|
69
|
-
if (fileExtension && fileExtension !== this.contextItem.metadata?.relativePath) {
|
|
70
|
-
return `${LANGUAGE_IDENTIFIER_PREFIX}${fileExtension}`;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return LANGUAGE_IDENTIFIER_PLAINTEXT;
|
|
74
|
-
},
|
|
75
|
-
title() {
|
|
76
|
-
return (
|
|
77
|
-
this.contextItem.metadata?.title ||
|
|
78
|
-
this.contextItem.metadata?.relativePath ||
|
|
79
|
-
translate('GlDuoChatContextItemDetailsModal.title', 'Preview')
|
|
80
|
-
);
|
|
81
|
-
},
|
|
82
|
-
isDependencies() {
|
|
83
|
-
return this.contextItem.category === CONTEXT_ITEM_CATEGORY_DEPENDENCY;
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
watch: {
|
|
87
|
-
contextItem: {
|
|
88
|
-
async handler(newVal, oldVal) {
|
|
89
|
-
// Dependency items contain structured data as content, not code/markdown.
|
|
90
|
-
// So skip running this content through GFM, we'll parse and render it here in the component.
|
|
91
|
-
if (newVal.category === CONTEXT_ITEM_CATEGORY_DEPENDENCY) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const isUnchangedOrEmptyContent = !newVal?.content || newVal?.content === oldVal?.content;
|
|
96
|
-
if (isUnchangedOrEmptyContent) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
await nextTick();
|
|
101
|
-
await this.hydrateContentWithGFM();
|
|
102
|
-
},
|
|
103
|
-
immediate: true,
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
methods: {
|
|
107
|
-
async hydrateContentWithGFM() {
|
|
108
|
-
await nextTick();
|
|
109
|
-
|
|
110
|
-
if (this.$refs.content) {
|
|
111
|
-
this.renderGFM(this.$refs.content);
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
parseDependencies() {
|
|
115
|
-
if (this.contextItem.category !== CONTEXT_ITEM_CATEGORY_DEPENDENCY) {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
if (!this.contextItem.content) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
try {
|
|
123
|
-
return JSON.parse(this.contextItem.content);
|
|
124
|
-
} catch (error) {
|
|
125
|
-
this.contentErrorIsVisible = true;
|
|
126
|
-
return {};
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
onModalVisibilityChange(isVisible) {
|
|
130
|
-
if (!isVisible) {
|
|
131
|
-
this.$emit('close');
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
CONTENT_ERROR_MESSAGE: translate(
|
|
136
|
-
'GlDuoChatContextItemDetailsModal.contentErrorMessage',
|
|
137
|
-
'Item content could not be displayed.'
|
|
138
|
-
),
|
|
139
|
-
};
|
|
140
|
-
</script>
|
|
141
|
-
|
|
142
|
-
<template>
|
|
143
|
-
<gl-modal
|
|
144
|
-
modal-id="context-item-details-modal"
|
|
145
|
-
:title="title"
|
|
146
|
-
:visible="true"
|
|
147
|
-
:scrollable="true"
|
|
148
|
-
hide-footer
|
|
149
|
-
size="lg"
|
|
150
|
-
@change="onModalVisibilityChange"
|
|
151
|
-
>
|
|
152
|
-
<gl-skeleton-loader v-if="isLoadingContent" />
|
|
153
|
-
<gl-alert
|
|
154
|
-
v-else-if="contentErrorIsVisible"
|
|
155
|
-
variant="danger"
|
|
156
|
-
:dismissible="false"
|
|
157
|
-
data-testid="content-error-alert"
|
|
158
|
-
>
|
|
159
|
-
{{ $options.CONTENT_ERROR_MESSAGE }}
|
|
160
|
-
</gl-alert>
|
|
161
|
-
<div v-else-if="isDependencies" data-testid="context-item-content">
|
|
162
|
-
<p>Project dependencies from {{ contextItem.metadata.secondaryText }}</p>
|
|
163
|
-
<div v-for="(matches, index) in parseDependencies()" :key="index">
|
|
164
|
-
<div v-for="(dependencies, language) in matches" :key="language">
|
|
165
|
-
<h3 class="gl-heading-4 gl-mb-2">{{ language }}</h3>
|
|
166
|
-
<ul class="gl-pl-6">
|
|
167
|
-
<li v-for="dependency in dependencies" :key="dependency" class="">
|
|
168
|
-
{{ dependency }}
|
|
169
|
-
</li>
|
|
170
|
-
</ul>
|
|
171
|
-
</div>
|
|
172
|
-
</div>
|
|
173
|
-
</div>
|
|
174
|
-
<div v-else ref="content" data-testid="context-item-content">
|
|
175
|
-
<pre
|
|
176
|
-
v-safe-html="contextItem.content"
|
|
177
|
-
class="code js-syntax-highlight gl-p-3"
|
|
178
|
-
:class="languageIdentifierClass"
|
|
179
|
-
></pre>
|
|
180
|
-
</div>
|
|
181
|
-
</gl-modal>
|
|
182
|
-
</template>
|
|
@@ -1,44 +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
|
-
Allows selecting and removing context items for the conversation.
|
|
11
|
-
|
|
12
|
-
**Note:**
|
|
13
|
-
Keyboard events don't work properly in this story (independently of the main GlDuoChat
|
|
14
|
-
component)- test in the main `GlDuoChat` interactive story with the /include command.
|
|
15
|
-
|
|
16
|
-
## AIContextItem type
|
|
17
|
-
|
|
18
|
-
The component expects items with specific display properties:
|
|
19
|
-
|
|
20
|
-
```typescript
|
|
21
|
-
export type AIContextItem = {
|
|
22
|
-
id: string;
|
|
23
|
-
category: 'file' | 'snippet' | 'issue' | 'merge_request' | 'dependency';
|
|
24
|
-
|
|
25
|
-
content?: string; // some categories allow loading/displaying content in the details-modal
|
|
26
|
-
|
|
27
|
-
metadata: {
|
|
28
|
-
icon: string; // should be a valid gitlab-ui icon name
|
|
29
|
-
title: string;
|
|
30
|
-
secondaryText: string;
|
|
31
|
-
subTypeLabel: string;
|
|
32
|
-
|
|
33
|
-
// Additional properties some categories have to help differentiate results
|
|
34
|
-
project?: string;
|
|
35
|
-
repositoryName?: string;
|
|
36
|
-
|
|
37
|
-
// items may be disabled, e.g. if they belong to a non-Duo-enabled project
|
|
38
|
-
enabled: boolean;
|
|
39
|
-
disabledReasons?: string[];
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
For the editor extensions, these types are defined [in the language server](https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/blob/main/src/common/ai_context_management/index.ts)
|