@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,140 +0,0 @@
|
|
|
1
|
-
import { translate } from '../../../../../../utils/i18n';
|
|
2
|
-
import { CONTEXT_ITEM_CATEGORY_LOCAL_GIT, CONTEXT_ITEM_LOCAL_GIT_COMMIT, CONTEXT_ITEM_LOCAL_GIT_DIFF, CONTEXT_ITEM_CATEGORY_FILE, CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST } from './constants';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
|
|
6
|
-
*
|
|
7
|
-
* Please use the corresponding component in Duo-UI going forward.
|
|
8
|
-
* All future development and maintenance for Duo components should take place in Duo-UI.
|
|
9
|
-
*
|
|
10
|
-
* 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.
|
|
11
|
-
*/
|
|
12
|
-
function categoryValidator(category) {
|
|
13
|
-
return Boolean(category && category.value && category.label && category.icon);
|
|
14
|
-
}
|
|
15
|
-
function categoriesValidator(categories) {
|
|
16
|
-
return Array.isArray(categories) && categories.every(category => categoryValidator(category));
|
|
17
|
-
}
|
|
18
|
-
function disabledReasonsValidator(disabledReasons) {
|
|
19
|
-
return disabledReasons === undefined || Array.isArray(disabledReasons) && disabledReasons.every(reason => typeof reason === 'string');
|
|
20
|
-
}
|
|
21
|
-
function contextItemValidator(item) {
|
|
22
|
-
return Boolean(item && item.id && item.category && item.metadata && typeof item.metadata === 'object' && typeof item.metadata.enabled === 'boolean' && disabledReasonsValidator(item.metadata.disabledReasons));
|
|
23
|
-
}
|
|
24
|
-
function contextItemsValidator(items) {
|
|
25
|
-
return Array.isArray(items) && items.every(item => contextItemValidator(item));
|
|
26
|
-
}
|
|
27
|
-
function formatIssueId(iid) {
|
|
28
|
-
if (!iid) return '';
|
|
29
|
-
return `#${iid}`;
|
|
30
|
-
}
|
|
31
|
-
function formatMergeRequestId(iid) {
|
|
32
|
-
if (!iid) return '';
|
|
33
|
-
return `!${iid}`;
|
|
34
|
-
}
|
|
35
|
-
function getContextItemSource(contextItem) {
|
|
36
|
-
return contextItem.metadata.repositoryName || contextItem.metadata.project || null;
|
|
37
|
-
}
|
|
38
|
-
function getGitItemIcon(contextItem) {
|
|
39
|
-
const iconMap = {
|
|
40
|
-
[CONTEXT_ITEM_LOCAL_GIT_COMMIT]: 'commit',
|
|
41
|
-
[CONTEXT_ITEM_LOCAL_GIT_DIFF]: 'comparison'
|
|
42
|
-
};
|
|
43
|
-
const {
|
|
44
|
-
gitType
|
|
45
|
-
} = contextItem.metadata;
|
|
46
|
-
return iconMap[gitType] || null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Gets the icon name for a given contextItem.
|
|
51
|
-
*/
|
|
52
|
-
function getContextItemIcon(contextItem) {
|
|
53
|
-
let category = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
54
|
-
icon: null
|
|
55
|
-
};
|
|
56
|
-
if (contextItem.metadata.icon) {
|
|
57
|
-
return contextItem.metadata.icon;
|
|
58
|
-
}
|
|
59
|
-
if (contextItem.category === CONTEXT_ITEM_CATEGORY_LOCAL_GIT) {
|
|
60
|
-
const gitIcon = getGitItemIcon(contextItem);
|
|
61
|
-
if (gitIcon) return gitIcon;
|
|
62
|
-
}
|
|
63
|
-
if (category.icon) {
|
|
64
|
-
return category.icon;
|
|
65
|
-
}
|
|
66
|
-
const iconMap = {
|
|
67
|
-
[CONTEXT_ITEM_CATEGORY_FILE]: 'document',
|
|
68
|
-
[CONTEXT_ITEM_CATEGORY_ISSUE]: 'issues',
|
|
69
|
-
[CONTEXT_ITEM_CATEGORY_MERGE_REQUEST]: 'merge-request',
|
|
70
|
-
[CONTEXT_ITEM_CATEGORY_LOCAL_GIT]: 'git'
|
|
71
|
-
};
|
|
72
|
-
return iconMap[contextItem.category] || null;
|
|
73
|
-
}
|
|
74
|
-
function getContextItemTypeLabel(contextItem) {
|
|
75
|
-
if (contextItem.metadata.subTypeLabel) {
|
|
76
|
-
return contextItem.metadata.subTypeLabel;
|
|
77
|
-
}
|
|
78
|
-
if (contextItem.category === CONTEXT_ITEM_CATEGORY_LOCAL_GIT) {
|
|
79
|
-
switch (contextItem.metadata.gitType) {
|
|
80
|
-
case CONTEXT_ITEM_LOCAL_GIT_DIFF:
|
|
81
|
-
return translate('DuoChatContextItemTypeLabel.GitDiff', 'Local Git repository diff');
|
|
82
|
-
case CONTEXT_ITEM_LOCAL_GIT_COMMIT:
|
|
83
|
-
return translate('DuoChatContextItemTypeLabel.GitCommit', 'Local Git repository commit');
|
|
84
|
-
default:
|
|
85
|
-
return translate('DuoChatContextItemTypeLabel.GitDefault', 'Local Git repository');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
switch (contextItem.category) {
|
|
89
|
-
case CONTEXT_ITEM_CATEGORY_MERGE_REQUEST:
|
|
90
|
-
return translate('DuoChatContextItemTypeLabel.MergeRequest', 'Merge request');
|
|
91
|
-
case CONTEXT_ITEM_CATEGORY_ISSUE:
|
|
92
|
-
return translate('DuoChatContextItemTypeLabel.Issue', 'Issue');
|
|
93
|
-
case CONTEXT_ITEM_CATEGORY_FILE:
|
|
94
|
-
return translate('DuoChatContextItemTypeLabel.File', 'Project file');
|
|
95
|
-
default:
|
|
96
|
-
return '';
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Gets the secondary text line for a git context item, showing repository and commit ID
|
|
102
|
-
*/
|
|
103
|
-
function formatGitItemSecondaryText(contextItem) {
|
|
104
|
-
const {
|
|
105
|
-
repositoryName,
|
|
106
|
-
commitId
|
|
107
|
-
} = contextItem.metadata;
|
|
108
|
-
const separator = commitId ? ' - ' : '';
|
|
109
|
-
return `${repositoryName}${separator}${commitId || ''}`;
|
|
110
|
-
}
|
|
111
|
-
function getContextItemSecondaryText(contextItem) {
|
|
112
|
-
if (contextItem.metadata.secondaryText) {
|
|
113
|
-
return contextItem.metadata.secondaryText;
|
|
114
|
-
}
|
|
115
|
-
switch (contextItem.category) {
|
|
116
|
-
case CONTEXT_ITEM_CATEGORY_FILE:
|
|
117
|
-
return contextItem.metadata.relativePath;
|
|
118
|
-
case CONTEXT_ITEM_CATEGORY_ISSUE:
|
|
119
|
-
return formatIssueId(contextItem.metadata.iid);
|
|
120
|
-
case CONTEXT_ITEM_CATEGORY_MERGE_REQUEST:
|
|
121
|
-
return formatMergeRequestId(contextItem.metadata.iid);
|
|
122
|
-
case CONTEXT_ITEM_CATEGORY_LOCAL_GIT:
|
|
123
|
-
return formatGitItemSecondaryText(contextItem);
|
|
124
|
-
default:
|
|
125
|
-
return '';
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Calculates a new index within a range. If the new index would fall out of bounds, wraps to the start/end of the range.
|
|
131
|
-
* @param {number} currentIndex - The starting index.
|
|
132
|
-
* @param {number} step - The number of steps to move (positive or negative).
|
|
133
|
-
* @param {number} totalLength - The total number of items in the range.
|
|
134
|
-
* @returns {number} The new index.
|
|
135
|
-
*/
|
|
136
|
-
function wrapIndex(currentIndex, step, totalLength) {
|
|
137
|
-
return (currentIndex + step + totalLength) % totalLength;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export { categoriesValidator, categoryValidator, contextItemValidator, contextItemsValidator, formatGitItemSecondaryText, formatIssueId, formatMergeRequestId, getContextItemIcon, getContextItemSecondaryText, getContextItemSource, getContextItemTypeLabel, wrapIndex };
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import GlDuoChatMessage from '../duo_chat_message/duo_chat_message';
|
|
2
|
-
import { translate } from '../../../../../../utils/i18n';
|
|
3
|
-
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
|
|
7
|
-
*
|
|
8
|
-
* Please use the corresponding component in Duo-UI going forward.
|
|
9
|
-
* All future development and maintenance for Duo components should take place in Duo-UI.
|
|
10
|
-
*
|
|
11
|
-
* 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.
|
|
12
|
-
*/
|
|
13
|
-
const i18n = {
|
|
14
|
-
CONVERSATION_NEW_CHAT: translate('GlDuoChatConversation.newChat', 'New chat')
|
|
15
|
-
};
|
|
16
|
-
const isMessage = item => Boolean(item) && (item === null || item === void 0 ? void 0 : item.role);
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line unicorn/no-array-callback-reference
|
|
19
|
-
const itemsValidator = items => items.every(isMessage);
|
|
20
|
-
var script = {
|
|
21
|
-
name: 'GlDuoChatConversation',
|
|
22
|
-
components: {
|
|
23
|
-
GlDuoChatMessage
|
|
24
|
-
},
|
|
25
|
-
props: {
|
|
26
|
-
/**
|
|
27
|
-
* Messages to display
|
|
28
|
-
*/
|
|
29
|
-
messages: {
|
|
30
|
-
type: Array,
|
|
31
|
-
required: false,
|
|
32
|
-
default: () => [],
|
|
33
|
-
validator: itemsValidator
|
|
34
|
-
},
|
|
35
|
-
canceledRequestIds: {
|
|
36
|
-
type: Array,
|
|
37
|
-
required: true
|
|
38
|
-
},
|
|
39
|
-
/**
|
|
40
|
-
* Whether the insertCode feature should be available.
|
|
41
|
-
*/
|
|
42
|
-
enableCodeInsertion: {
|
|
43
|
-
type: Boolean,
|
|
44
|
-
required: true
|
|
45
|
-
},
|
|
46
|
-
/**
|
|
47
|
-
* Whether to show the delimiter before this conversation
|
|
48
|
-
*/
|
|
49
|
-
showDelimiter: {
|
|
50
|
-
type: Boolean,
|
|
51
|
-
required: false,
|
|
52
|
-
default: true
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
methods: {
|
|
56
|
-
onTrackFeedback(event) {
|
|
57
|
-
/**
|
|
58
|
-
* Notify listeners about the feedback form submission on a response message.
|
|
59
|
-
* @param {*} event An event, containing the feedback choices and the extended feedback text.
|
|
60
|
-
*/
|
|
61
|
-
this.$emit('track-feedback', event);
|
|
62
|
-
},
|
|
63
|
-
onInsertCodeSnippet(e) {
|
|
64
|
-
this.$emit('insert-code-snippet', e);
|
|
65
|
-
},
|
|
66
|
-
onGetContextItemContent(e) {
|
|
67
|
-
this.$emit('get-context-item-content', e);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
i18n
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/* script */
|
|
74
|
-
const __vue_script__ = script;
|
|
75
|
-
|
|
76
|
-
/* template */
|
|
77
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:['gl-flex gl-flex-col gl-justify-end', { 'insert-code-hidden': !_vm.enableCodeInsertion }]},[(_vm.showDelimiter)?_c('div',{staticClass:"gl-my-5 gl-flex gl-items-center gl-gap-4 gl-text-gray-500",attrs:{"data-testid":"conversation-delimiter"}},[_c('hr',{staticClass:"gl-grow"}),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.$options.i18n.CONVERSATION_NEW_CHAT))]),_vm._v(" "),_c('hr',{staticClass:"gl-grow"})]):_vm._e(),_vm._v(" "),_vm._l((_vm.messages),function(msg,index){return _c('gl-duo-chat-message',{key:((msg.role) + "-" + index),attrs:{"message":msg,"is-cancelled":_vm.canceledRequestIds.includes(msg.requestId)},on:{"track-feedback":_vm.onTrackFeedback,"insert-code-snippet":_vm.onInsertCodeSnippet,"get-context-item-content":_vm.onGetContextItemContent}})})],2)};
|
|
78
|
-
var __vue_staticRenderFns__ = [];
|
|
79
|
-
|
|
80
|
-
/* style */
|
|
81
|
-
const __vue_inject_styles__ = undefined;
|
|
82
|
-
/* scoped */
|
|
83
|
-
const __vue_scope_id__ = undefined;
|
|
84
|
-
/* module identifier */
|
|
85
|
-
const __vue_module_identifier__ = undefined;
|
|
86
|
-
/* functional template */
|
|
87
|
-
const __vue_is_functional_template__ = false;
|
|
88
|
-
/* style inject */
|
|
89
|
-
|
|
90
|
-
/* style inject SSR */
|
|
91
|
-
|
|
92
|
-
/* style inject shadow dom */
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const __vue_component__ = __vue_normalize__(
|
|
97
|
-
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
98
|
-
__vue_inject_styles__,
|
|
99
|
-
__vue_script__,
|
|
100
|
-
__vue_scope_id__,
|
|
101
|
-
__vue_is_functional_template__,
|
|
102
|
-
__vue_module_identifier__,
|
|
103
|
-
false,
|
|
104
|
-
undefined,
|
|
105
|
-
undefined,
|
|
106
|
-
undefined
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
export default __vue_component__;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { translate } from '../../../../../../utils/i18n';
|
|
2
|
-
import GlSprintf from '../../../../../utilities/sprintf/sprintf';
|
|
3
|
-
import GlAnimatedLoaderIcon from '../../../../../base/animated_icon/animated_loader_icon';
|
|
4
|
-
import { LOADING_TRANSITION_DURATION } from '../../constants';
|
|
5
|
-
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
|
|
9
|
-
*
|
|
10
|
-
* Please use the corresponding component in Duo-UI going forward.
|
|
11
|
-
* All future development and maintenance for Duo components should take place in Duo-UI.
|
|
12
|
-
*
|
|
13
|
-
* 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.
|
|
14
|
-
*/
|
|
15
|
-
const i18n = {
|
|
16
|
-
LOADER_LOADING_MESSAGE: translate('GlDuoChatLoader.loaderLoadingMessage', '%{tool} is %{transition} an answer'),
|
|
17
|
-
LOADER_LOADING_TRANSITIONS: [translate('GlDuoChatLoader.loaderLoadingTransitionsFinding', 'finding'), translate('GlDuoChatLoader.loaderLoadingTransitionsWorkingOn', 'working on'), translate('GlDuoChatLoader.loaderLoadingTransitionsGenerating', 'generating'), translate('GlDuoChatLoader.loaderLoadingTransitionsProducing', 'producing')],
|
|
18
|
-
GITLAB_DUO: translate('GlDuoChatLoader.gitlabDuo', 'GitLab Duo')
|
|
19
|
-
};
|
|
20
|
-
var script = {
|
|
21
|
-
name: 'GlDuoChatLoader',
|
|
22
|
-
components: {
|
|
23
|
-
GlSprintf,
|
|
24
|
-
GlAnimatedLoaderIcon
|
|
25
|
-
},
|
|
26
|
-
i18n,
|
|
27
|
-
props: {
|
|
28
|
-
/**
|
|
29
|
-
* The message containing the name of the current AI tool working on the answer.
|
|
30
|
-
*/
|
|
31
|
-
toolName: {
|
|
32
|
-
type: String,
|
|
33
|
-
required: false,
|
|
34
|
-
default: i18n.GITLAB_DUO
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
data() {
|
|
38
|
-
return {
|
|
39
|
-
loadingSequence: 0,
|
|
40
|
-
timeout: null
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
beforeDestroy() {
|
|
44
|
-
clearTimeout(this.timeout);
|
|
45
|
-
},
|
|
46
|
-
mounted() {
|
|
47
|
-
this.computeTransitionWidth();
|
|
48
|
-
this.enter();
|
|
49
|
-
},
|
|
50
|
-
methods: {
|
|
51
|
-
computeTransitionWidth() {
|
|
52
|
-
const container = this.$refs.transition;
|
|
53
|
-
const active = this.$refs.currentTransition[0]; // There's only one `currentTransition` ref at a time, but refs in v-for loops are always Arrays
|
|
54
|
-
const {
|
|
55
|
-
width,
|
|
56
|
-
height
|
|
57
|
-
} = active.getBoundingClientRect();
|
|
58
|
-
container.$el.style.width = `${width}px`;
|
|
59
|
-
container.$el.style.height = `${height}px`;
|
|
60
|
-
},
|
|
61
|
-
enter() {
|
|
62
|
-
clearTimeout(this.timeout);
|
|
63
|
-
this.timeout = setTimeout(() => {
|
|
64
|
-
this.loadingSequence = (this.loadingSequence + 1) % this.$options.i18n.LOADER_LOADING_TRANSITIONS.length;
|
|
65
|
-
this.enter();
|
|
66
|
-
}, LOADING_TRANSITION_DURATION);
|
|
67
|
-
},
|
|
68
|
-
isCurrentTransition(index) {
|
|
69
|
-
return index === this.loadingSequence;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/* script */
|
|
75
|
-
const __vue_script__ = script;
|
|
76
|
-
|
|
77
|
-
/* template */
|
|
78
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"duo-chat-loader gl-mt-5 gl-flex gl-items-center gl-gap-3"},[_c('gl-animated-loader-icon',{attrs:{"is-on":true}}),_vm._v(" "),_c('div',[_c('gl-sprintf',{attrs:{"message":_vm.$options.i18n.LOADER_LOADING_MESSAGE},scopedSlots:_vm._u([{key:"tool",fn:function(){return [_c('strong',{attrs:{"data-testid":"tool"}},[_vm._v(_vm._s(_vm.toolName))])]},proxy:true},{key:"transition",fn:function(){return [_c('transition-group',{ref:"transition",staticClass:"transition gl-relative gl-inline-block gl-align-bottom",attrs:{"name":"text"},on:{"after-leave":_vm.computeTransitionWidth}},_vm._l((_vm.$options.i18n.LOADER_LOADING_TRANSITIONS),function(message,index){return _c('span',{directives:[{name:"show",rawName:"v-show",value:(_vm.isCurrentTransition(index)),expression:"isCurrentTransition(index)"}],key:message,ref:_vm.isCurrentTransition(index) ? 'currentTransition' : '',refInFor:true,staticClass:"gl-absolute gl-bottom-0 gl-left-0 gl-whitespace-nowrap",attrs:{"data-testid":_vm.isCurrentTransition(index) ? 'current-transition' : ''}},[_vm._v(_vm._s(message))])}),0)]},proxy:true}])})],1)],1)};
|
|
79
|
-
var __vue_staticRenderFns__ = [];
|
|
80
|
-
|
|
81
|
-
/* style */
|
|
82
|
-
const __vue_inject_styles__ = undefined;
|
|
83
|
-
/* scoped */
|
|
84
|
-
const __vue_scope_id__ = undefined;
|
|
85
|
-
/* module identifier */
|
|
86
|
-
const __vue_module_identifier__ = undefined;
|
|
87
|
-
/* functional template */
|
|
88
|
-
const __vue_is_functional_template__ = false;
|
|
89
|
-
/* style inject */
|
|
90
|
-
|
|
91
|
-
/* style inject SSR */
|
|
92
|
-
|
|
93
|
-
/* style inject shadow dom */
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const __vue_component__ = __vue_normalize__(
|
|
98
|
-
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
99
|
-
__vue_inject_styles__,
|
|
100
|
-
__vue_script__,
|
|
101
|
-
__vue_scope_id__,
|
|
102
|
-
__vue_is_functional_template__,
|
|
103
|
-
__vue_module_identifier__,
|
|
104
|
-
false,
|
|
105
|
-
undefined,
|
|
106
|
-
undefined,
|
|
107
|
-
undefined
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
export default __vue_component__;
|
|
111
|
-
export { i18n };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import iconsPath from '@gitlab/svgs/dist/icons.svg';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
|
|
5
|
-
*
|
|
6
|
-
* Please use the corresponding component in Duo-UI going forward.
|
|
7
|
-
* All future development and maintenance for Duo components should take place in Duo-UI.
|
|
8
|
-
*
|
|
9
|
-
* 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.
|
|
10
|
-
*/
|
|
11
|
-
const createButton = function () {
|
|
12
|
-
let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Insert the code snippet';
|
|
13
|
-
let iconId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'insert';
|
|
14
|
-
const button = document.createElement('button');
|
|
15
|
-
button.type = 'button';
|
|
16
|
-
button.classList.add('btn', 'btn-default', 'btn-md', 'gl-button', 'btn-default-secondary', 'btn-icon');
|
|
17
|
-
button.dataset.title = title;
|
|
18
|
-
|
|
19
|
-
// Create an SVG element with the correct namespace
|
|
20
|
-
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
21
|
-
svg.setAttribute('role', 'img');
|
|
22
|
-
svg.setAttribute('aria-hidden', 'true');
|
|
23
|
-
svg.classList.add('gl-button-icon', 'gl-icon', 's16');
|
|
24
|
-
|
|
25
|
-
// Create a 'use' element with the correct namespace
|
|
26
|
-
const use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
|
|
27
|
-
use.setAttribute('href', `${iconsPath}#${iconId}`);
|
|
28
|
-
svg.appendChild(use);
|
|
29
|
-
button.appendChild(svg);
|
|
30
|
-
return button;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export { createButton };
|
|
@@ -1,14 +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
|
-
const DUO_CODE_SCRIM_TOP_CLASS = 'scrim-top';
|
|
11
|
-
const DUO_CODE_SCRIM_BOTTOM_CLASS = 'scrim-bottom';
|
|
12
|
-
const DUO_CODE_SCRIM_OFFSET = 16;
|
|
13
|
-
|
|
14
|
-
export { DUO_CODE_SCRIM_BOTTOM_CLASS, DUO_CODE_SCRIM_OFFSET, DUO_CODE_SCRIM_TOP_CLASS };
|
package/dist/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { createButton } from './buttons_utils';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This component has been migrated to the Duo-UI library (https://gitlab.com/gitlab-org/duo-ui).
|
|
5
|
-
*
|
|
6
|
-
* Please use the corresponding component in Duo-UI going forward.
|
|
7
|
-
* All future development and maintenance for Duo components should take place in Duo-UI.
|
|
8
|
-
*
|
|
9
|
-
* 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.
|
|
10
|
-
*/
|
|
11
|
-
class CopyCodeElement extends HTMLElement {
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
const btn = createButton('Copy to clipboard', 'copy-to-clipboard');
|
|
15
|
-
const wrapper = this.parentNode;
|
|
16
|
-
this.appendChild(btn);
|
|
17
|
-
btn.addEventListener('click', async () => {
|
|
18
|
-
const textToCopy = wrapper.innerText;
|
|
19
|
-
await navigator.clipboard.writeText(textToCopy);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { CopyCodeElement };
|