@gitlab/ui 90.5.0 → 91.1.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 +20 -0
- package/dist/components/base/path/path.js +2 -15
- package/dist/components/experimental/duo/chat/components/duo_chat_context/constants.js +5 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.js +93 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.js +91 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +121 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +24 -1
- package/dist/components/experimental/duo/chat/mock_data.js +9 -3
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/tailwind.css.map +1 -1
- package/dist/tokens/build/js/tokens.dark.js +13 -1
- package/dist/tokens/build/js/tokens.js +13 -1
- package/dist/tokens/css/tokens.css +12 -0
- package/dist/tokens/css/tokens.dark.css +12 -0
- package/dist/tokens/js/tokens.dark.js +12 -0
- package/dist/tokens/js/tokens.js +12 -0
- package/dist/tokens/json/tokens.dark.json +278 -0
- package/dist/tokens/json/tokens.json +278 -0
- package/dist/tokens/scss/_tokens.dark.scss +12 -0
- package/dist/tokens/scss/_tokens.scss +12 -0
- package/dist/tokens/scss/_tokens_custom_properties.scss +12 -0
- package/dist/utils/constants.js +1 -2
- package/package.json +1 -1
- package/src/components/base/path/path.scss +44 -62
- package/src/components/base/path/path.vue +2 -15
- package/src/components/experimental/duo/chat/components/duo_chat_context/constants.js +3 -0
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.vue +111 -0
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.vue +94 -0
- package/src/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +137 -0
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.md +5 -0
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.vue +43 -0
- package/src/components/experimental/duo/chat/mock_data.js +8 -2
- package/src/tokens/action.tokens.json +86 -0
- package/src/tokens/build/css/tokens.css +12 -0
- package/src/tokens/build/css/tokens.dark.css +12 -0
- package/src/tokens/build/js/tokens.dark.js +12 -0
- package/src/tokens/build/js/tokens.js +12 -0
- package/src/tokens/build/json/tokens.dark.json +278 -0
- package/src/tokens/build/json/tokens.json +278 -0
- package/src/tokens/build/scss/_tokens.dark.scss +12 -0
- package/src/tokens/build/scss/_tokens.scss +12 -0
- package/src/tokens/build/scss/_tokens_custom_properties.scss +12 -0
- package/src/utils/constants.js +0 -2
- package/translations.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# [91.1.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v91.0.0...v91.1.0) (2024-08-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **GlDuoChat:** display attached context in chat messages ([be92188](https://gitlab.com/gitlab-org/gitlab-ui/commit/be92188062f895f5f27117f501d4b31ba52ac598))
|
|
7
|
+
|
|
8
|
+
# [91.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v90.5.0...v91.0.0) (2024-08-29)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Code Refactoring
|
|
12
|
+
|
|
13
|
+
* **Path:** Update to tokens ([f57c5e4](https://gitlab.com/gitlab-org/gitlab-ui/commit/f57c5e48d73f9ccb143ddf60e6b604dd84d129ee))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### BREAKING CHANGES
|
|
17
|
+
|
|
18
|
+
* **Path:** Replace SCSS variables with design tokens for the
|
|
19
|
+
Path component and make some minor design tweaks. Remove theme option.
|
|
20
|
+
|
|
1
21
|
# [90.5.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v90.4.0...v90.5.0) (2024-08-28)
|
|
2
22
|
|
|
3
23
|
|
|
@@ -2,14 +2,13 @@ import iconSpriteInfo from '@gitlab/svgs/dist/icons.json';
|
|
|
2
2
|
import uniqueId from 'lodash/uniqueId';
|
|
3
3
|
import findLast from 'lodash/findLast';
|
|
4
4
|
import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
|
|
5
|
-
import { glThemes } from '../../../utils/constants';
|
|
6
5
|
import GlIcon from '../icon/icon';
|
|
7
6
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
8
7
|
|
|
9
8
|
//
|
|
10
9
|
const BOUNDARY_WIDTH = 40;
|
|
11
10
|
const PATH_ITEM_CLASS = 'gl-path-button';
|
|
12
|
-
const
|
|
11
|
+
const PATH_ACTIVE_ITEM_CLASS = 'gl-path-active-item';
|
|
13
12
|
var script = {
|
|
14
13
|
name: 'GlPath',
|
|
15
14
|
components: {
|
|
@@ -35,15 +34,6 @@ var script = {
|
|
|
35
34
|
required: false,
|
|
36
35
|
default: () => []
|
|
37
36
|
},
|
|
38
|
-
/**
|
|
39
|
-
* The color theme to be used.
|
|
40
|
-
*/
|
|
41
|
-
theme: {
|
|
42
|
-
type: String,
|
|
43
|
-
required: false,
|
|
44
|
-
default: 'indigo',
|
|
45
|
-
validator: theme => glThemes.includes(theme)
|
|
46
|
-
},
|
|
47
37
|
/**
|
|
48
38
|
* The items' background color.
|
|
49
39
|
*/
|
|
@@ -61,9 +51,6 @@ var script = {
|
|
|
61
51
|
};
|
|
62
52
|
},
|
|
63
53
|
computed: {
|
|
64
|
-
activeClass() {
|
|
65
|
-
return `${PATH_ACTIVE_ITEM_PREFIX}-${this.theme}`;
|
|
66
|
-
},
|
|
67
54
|
entireListVisible() {
|
|
68
55
|
return this.width >= this.getScrollWidth();
|
|
69
56
|
},
|
|
@@ -95,7 +82,7 @@ var script = {
|
|
|
95
82
|
},
|
|
96
83
|
methods: {
|
|
97
84
|
pathItemClass(index) {
|
|
98
|
-
return index === this.selectedIndex ? `${PATH_ITEM_CLASS} ${
|
|
85
|
+
return index === this.selectedIndex ? `${PATH_ITEM_CLASS} ${PATH_ACTIVE_ITEM_CLASS}` : PATH_ITEM_CLASS;
|
|
99
86
|
},
|
|
100
87
|
onItemClicked(selectedIndex) {
|
|
101
88
|
this.selectedIndex = selectedIndex;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import GlPopover from '../../../../../../base/popover/popover';
|
|
2
|
+
import { translate } from '../../../../../../../utils/i18n';
|
|
3
|
+
import { CONTEXT_ITEM_TYPE_ISSUE, CONTEXT_ITEM_TYPE_MERGE_REQUEST, CONTEXT_ITEM_TYPE_PROJECT_FILE } from '../constants';
|
|
4
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
5
|
+
|
|
6
|
+
const ID_PREFIXES = {
|
|
7
|
+
issue: '#',
|
|
8
|
+
merge_request: '!'
|
|
9
|
+
};
|
|
10
|
+
var script = {
|
|
11
|
+
name: 'DuoChatContextItemPopover',
|
|
12
|
+
components: {
|
|
13
|
+
GlPopover
|
|
14
|
+
},
|
|
15
|
+
props: {
|
|
16
|
+
item: {
|
|
17
|
+
type: Object,
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
target: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
placement: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'bottom',
|
|
27
|
+
required: false
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
computed: {
|
|
31
|
+
itemInfo() {
|
|
32
|
+
var _this$item$metadata;
|
|
33
|
+
return ((_this$item$metadata = this.item.metadata) === null || _this$item$metadata === void 0 ? void 0 : _this$item$metadata.info) || {};
|
|
34
|
+
},
|
|
35
|
+
id() {
|
|
36
|
+
const isIssuable = this.item.type === CONTEXT_ITEM_TYPE_ISSUE || this.item.type === CONTEXT_ITEM_TYPE_MERGE_REQUEST;
|
|
37
|
+
return isIssuable ? this.itemInfo.iid || '' : null;
|
|
38
|
+
},
|
|
39
|
+
idPrefix() {
|
|
40
|
+
return ID_PREFIXES[this.item.type] || '';
|
|
41
|
+
},
|
|
42
|
+
filePath() {
|
|
43
|
+
return this.item.type === CONTEXT_ITEM_TYPE_PROJECT_FILE ? this.itemInfo.relFilePath || '' : null;
|
|
44
|
+
},
|
|
45
|
+
isEnabled() {
|
|
46
|
+
return this.item.isEnabled !== false;
|
|
47
|
+
},
|
|
48
|
+
disabledMessage() {
|
|
49
|
+
return Array.isArray(this.item.disabledReasons) && this.item.disabledReasons.length > 0 ? this.item.disabledReasons.join(', ') : translate('DuoChatContextItemPopover.DisabledReason', 'This item is disabled');
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
methods: {
|
|
53
|
+
translate
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/* script */
|
|
58
|
+
const __vue_script__ = script;
|
|
59
|
+
|
|
60
|
+
/* template */
|
|
61
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-popover',{attrs:{"target":_vm.target,"triggers":"hover focus","placement":_vm.placement,"title":_vm.item.metadata.name,"custom-class":"gl-duo-chat-item-popover"},scopedSlots:_vm._u([{key:"title",fn:function(){return [_c('span',{staticClass:"gl-text-sm gl-text-gray-500",attrs:{"data-testid":"chat-context-popover-title"}},[_vm._v(_vm._s(_vm.item.metadata.name))])]},proxy:true}])},[_vm._v(" "),_c('div',{staticClass:"gl-p-3"},[_c('div',{staticClass:"gl-mb-2"},[_c('strong',{staticClass:"gl-mr-1"},[_vm._v(_vm._s(_vm.translate('DuoChatContextItemPopover.ProjectLabel', 'Project:')))]),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.itemInfo.project))])]),_vm._v(" "),(_vm.filePath !== null)?_c('div',{staticClass:"gl-mb-2"},[_c('strong',{staticClass:"gl-mr-1"},[_vm._v(_vm._s(_vm.translate('DuoChatContextItemPopover.PathLabel', 'Path:')))]),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.filePath))])]):_vm._e(),_vm._v(" "),(_vm.id !== null)?_c('div',{staticClass:"gl-mb-2"},[_c('strong',{staticClass:"gl-mr-1"},[_vm._v(_vm._s(_vm.translate('DuoChatContextItemPopover.IdLabel', 'ID:')))]),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.idPrefix)+_vm._s(_vm.id))])]):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-mb-2"},[_c('strong',{staticClass:"gl-mr-1"},[_vm._v(_vm._s(_vm.translate('DuoChatContextItemPopover.TypeLabel', 'Type:')))]),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.item.type))])]),_vm._v(" "),(!_vm.isEnabled)?_c('div',{staticClass:"gl-text-red-500",attrs:{"data-testid":"chat-context-popover-disabled"}},[_c('strong',{staticClass:"gl-mr-1"},[_vm._v(_vm._s(_vm.translate('DuoChatContextItemPopover.DisabledMessageLabel', 'Note:')))]),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.disabledMessage))])]):_vm._e()])])};
|
|
62
|
+
var __vue_staticRenderFns__ = [];
|
|
63
|
+
|
|
64
|
+
/* style */
|
|
65
|
+
const __vue_inject_styles__ = undefined;
|
|
66
|
+
/* scoped */
|
|
67
|
+
const __vue_scope_id__ = undefined;
|
|
68
|
+
/* module identifier */
|
|
69
|
+
const __vue_module_identifier__ = undefined;
|
|
70
|
+
/* functional template */
|
|
71
|
+
const __vue_is_functional_template__ = false;
|
|
72
|
+
/* style inject */
|
|
73
|
+
|
|
74
|
+
/* style inject SSR */
|
|
75
|
+
|
|
76
|
+
/* style inject shadow dom */
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
const __vue_component__ = __vue_normalize__(
|
|
81
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
82
|
+
__vue_inject_styles__,
|
|
83
|
+
__vue_script__,
|
|
84
|
+
__vue_scope_id__,
|
|
85
|
+
__vue_is_functional_template__,
|
|
86
|
+
__vue_module_identifier__,
|
|
87
|
+
false,
|
|
88
|
+
undefined,
|
|
89
|
+
undefined,
|
|
90
|
+
undefined
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
export default __vue_component__;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import uniqueId from 'lodash/uniqueId';
|
|
2
|
+
import GlIcon from '../../../../../../base/icon/icon';
|
|
3
|
+
import GlToken from '../../../../../../base/token/token';
|
|
4
|
+
import GlDuoChatContextItemPopover from '../duo_chat_context_item_popover/duo_chat_context_item_popover';
|
|
5
|
+
import { CONTEXT_ITEM_TYPE_PROJECT_FILE, CONTEXT_ITEM_TYPE_ISSUE, CONTEXT_ITEM_TYPE_MERGE_REQUEST } from '../constants';
|
|
6
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
7
|
+
|
|
8
|
+
var script = {
|
|
9
|
+
name: 'GlDuoChatContextItemSelections',
|
|
10
|
+
components: {
|
|
11
|
+
GlIcon,
|
|
12
|
+
GlDuoChatContextItemPopover,
|
|
13
|
+
GlToken
|
|
14
|
+
},
|
|
15
|
+
props: {
|
|
16
|
+
selections: {
|
|
17
|
+
type: Array,
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
title: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
defaultCollapsed: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
required: true
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
data() {
|
|
30
|
+
return {
|
|
31
|
+
isCollapsed: this.defaultCollapsed,
|
|
32
|
+
selectionsId: uniqueId()
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
computed: {
|
|
36
|
+
collapseIconName() {
|
|
37
|
+
return this.isCollapsed ? 'chevron-right' : 'chevron-down';
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
methods: {
|
|
41
|
+
getIconName(type) {
|
|
42
|
+
const iconMap = {
|
|
43
|
+
[CONTEXT_ITEM_TYPE_PROJECT_FILE]: 'document',
|
|
44
|
+
[CONTEXT_ITEM_TYPE_ISSUE]: 'issues',
|
|
45
|
+
[CONTEXT_ITEM_TYPE_MERGE_REQUEST]: 'merge-request'
|
|
46
|
+
};
|
|
47
|
+
return iconMap[type] || 'document';
|
|
48
|
+
},
|
|
49
|
+
toggleCollapse() {
|
|
50
|
+
this.isCollapsed = !this.isCollapsed;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/* script */
|
|
56
|
+
const __vue_script__ = script;
|
|
57
|
+
|
|
58
|
+
/* template */
|
|
59
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-mb-3 gl-flex gl-flex-col"},[_c('button',{staticClass:"gl-flex gl-w-full gl-items-center gl-border-0 gl-bg-transparent gl-p-0 gl-text-left gl-text-xs gl-lowercase gl-text-gray-500",attrs:{"data-testid":"chat-context-selections-title"},on:{"click":_vm.toggleCollapse}},[_c('gl-icon',{attrs:{"name":_vm.collapseIconName,"data-testid":"chat-context-collapse-icon"}}),_vm._v(" "+_vm._s(_vm.title)+"\n ")],1),_vm._v(" "),_c('div',{directives:[{name:"show",rawName:"v-show",value:(!_vm.isCollapsed),expression:"!isCollapsed"}],staticClass:"gl-mt-1 gl-flex gl-grow gl-flex-wrap",attrs:{"data-testid":"chat-context-tokens-wrapper"}},_vm._l((_vm.selections),function(item){return _c('gl-token',{key:item.id,staticClass:"gl-mb-2 gl-mr-2",attrs:{"view-only":true,"variant":"default"}},[_c('div',{staticClass:"gl-flex gl-items-center",attrs:{"id":("context-item-" + (item.id) + "-" + _vm.selectionsId)}},[_c('gl-icon',{staticClass:"gl-mr-1",attrs:{"name":_vm.getIconName(item.type),"size":12}}),_vm._v("\n "+_vm._s(item.metadata.name)+"\n ")],1),_vm._v(" "),_c('gl-duo-chat-context-item-popover',{attrs:{"item":item,"target":("context-item-" + (item.id) + "-" + _vm.selectionsId),"placement":"bottom"}})],1)}),1)])};
|
|
60
|
+
var __vue_staticRenderFns__ = [];
|
|
61
|
+
|
|
62
|
+
/* style */
|
|
63
|
+
const __vue_inject_styles__ = undefined;
|
|
64
|
+
/* scoped */
|
|
65
|
+
const __vue_scope_id__ = undefined;
|
|
66
|
+
/* module identifier */
|
|
67
|
+
const __vue_module_identifier__ = undefined;
|
|
68
|
+
/* functional template */
|
|
69
|
+
const __vue_is_functional_template__ = false;
|
|
70
|
+
/* style inject */
|
|
71
|
+
|
|
72
|
+
/* style inject SSR */
|
|
73
|
+
|
|
74
|
+
/* style inject shadow dom */
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
const __vue_component__ = __vue_normalize__(
|
|
79
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
80
|
+
__vue_inject_styles__,
|
|
81
|
+
__vue_script__,
|
|
82
|
+
__vue_scope_id__,
|
|
83
|
+
__vue_is_functional_template__,
|
|
84
|
+
__vue_module_identifier__,
|
|
85
|
+
false,
|
|
86
|
+
undefined,
|
|
87
|
+
undefined,
|
|
88
|
+
undefined
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
export default __vue_component__;
|
package/dist/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const MOCK_CONTEXT_ITEM_FILE = {
|
|
2
|
+
id: '123e4567-e89b-12d3-a456-426614174000',
|
|
3
|
+
isEnabled: true,
|
|
4
|
+
metadata: {
|
|
5
|
+
name: 'strawberry.ts',
|
|
6
|
+
info: {
|
|
7
|
+
project: 'example/garden',
|
|
8
|
+
relFilePath: 'src/plants/strawberry.ts'
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
type: 'project_file'
|
|
12
|
+
};
|
|
13
|
+
const MOCK_CONTEXT_ITEM_FILE_DISABLED = {
|
|
14
|
+
id: '323e4567-e89b-12d3-a456-426614174002',
|
|
15
|
+
isEnabled: false,
|
|
16
|
+
metadata: {
|
|
17
|
+
name: 'motorbike.cs',
|
|
18
|
+
info: {
|
|
19
|
+
project: 'example/vehicles',
|
|
20
|
+
relFilePath: '/src/VehicleFoo/motorbike.cs'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
type: 'project_file'
|
|
24
|
+
};
|
|
25
|
+
const mockFiles = [MOCK_CONTEXT_ITEM_FILE, {
|
|
26
|
+
id: '223e4567-e89b-12d3-a456-426614174001',
|
|
27
|
+
isEnabled: true,
|
|
28
|
+
metadata: {
|
|
29
|
+
name: 'potato.ts',
|
|
30
|
+
info: {
|
|
31
|
+
project: 'example/garden',
|
|
32
|
+
relFilePath: '/src/plants/potato.ts'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
type: 'project_file'
|
|
36
|
+
}, MOCK_CONTEXT_ITEM_FILE_DISABLED];
|
|
37
|
+
const MOCK_CONTEXT_ITEM_ISSUE = {
|
|
38
|
+
id: '423e4567-e89b-12d3-a456-426614174003',
|
|
39
|
+
isEnabled: true,
|
|
40
|
+
metadata: {
|
|
41
|
+
name: 'Implement watering schedule',
|
|
42
|
+
info: {
|
|
43
|
+
project: 'example/garden',
|
|
44
|
+
iid: 1234
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
type: 'issue'
|
|
48
|
+
};
|
|
49
|
+
const MOCK_CONTEXT_ITEM_ISSUE_DISABLED = {
|
|
50
|
+
id: 'c463fb31-2a4c-4f8e-a609-97230ac48ae5',
|
|
51
|
+
isEnabled: false,
|
|
52
|
+
metadata: {
|
|
53
|
+
name: 'Fix vehicle colours',
|
|
54
|
+
info: {
|
|
55
|
+
project: 'example/vehicle',
|
|
56
|
+
iid: 91011
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
60
|
+
type: 'issue'
|
|
61
|
+
};
|
|
62
|
+
const mockIssues = [MOCK_CONTEXT_ITEM_ISSUE, {
|
|
63
|
+
id: '523e4567-e89b-12d3-a456-426614174004',
|
|
64
|
+
isEnabled: true,
|
|
65
|
+
metadata: {
|
|
66
|
+
name: 'Refactor plant growth rates',
|
|
67
|
+
info: {
|
|
68
|
+
project: 'example/garden',
|
|
69
|
+
iid: 5678
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
type: 'issue'
|
|
73
|
+
}, MOCK_CONTEXT_ITEM_ISSUE_DISABLED];
|
|
74
|
+
const MOCK_CONTEXT_ITEM_MERGE_REQUEST = {
|
|
75
|
+
id: '623e4567-e89b-12d3-a456-426614174005',
|
|
76
|
+
isEnabled: true,
|
|
77
|
+
metadata: {
|
|
78
|
+
name: 'Improve database performance',
|
|
79
|
+
info: {
|
|
80
|
+
project: 'example/garden',
|
|
81
|
+
iid: 1122
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
type: 'merge_request'
|
|
85
|
+
};
|
|
86
|
+
const MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED = {
|
|
87
|
+
id: '4eb665fc-e5e1-49b0-9789-2a16964e461a',
|
|
88
|
+
isEnabled: false,
|
|
89
|
+
metadata: {
|
|
90
|
+
name: 'Fix broken layout at small viewports',
|
|
91
|
+
info: {
|
|
92
|
+
project: 'example/vehicle',
|
|
93
|
+
iid: 5566
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
97
|
+
type: 'merge_request'
|
|
98
|
+
};
|
|
99
|
+
const mockMergeRequests = [MOCK_CONTEXT_ITEM_MERGE_REQUEST, {
|
|
100
|
+
id: '723e4567-e89b-12d3-a456-426614174006',
|
|
101
|
+
isEnabled: false,
|
|
102
|
+
metadata: {
|
|
103
|
+
name: 'Add vehicle registration details',
|
|
104
|
+
info: {
|
|
105
|
+
project: 'example/vehicle',
|
|
106
|
+
iid: 3344
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
110
|
+
type: 'merge_request'
|
|
111
|
+
}, MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED];
|
|
112
|
+
const getMockContextItems = () => {
|
|
113
|
+
const allItems = [...mockFiles, ...mockIssues, ...mockMergeRequests];
|
|
114
|
+
|
|
115
|
+
// put disabled items in the back
|
|
116
|
+
const disabledItems = allItems.filter(item => !item.isEnabled);
|
|
117
|
+
const enabledItems = allItems.filter(item => item.isEnabled);
|
|
118
|
+
return [...enabledItems, ...disabledItems];
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export { MOCK_CONTEXT_ITEM_FILE, MOCK_CONTEXT_ITEM_FILE_DISABLED, MOCK_CONTEXT_ITEM_ISSUE, MOCK_CONTEXT_ITEM_ISSUE_DISABLED, MOCK_CONTEXT_ITEM_MERGE_REQUEST, MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED, getMockContextItems };
|
package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import GlIcon from '../../../../../base/icon/icon';
|
|
2
2
|
import GlLoadingIcon from '../../../../../base/loading_icon/loading_icon';
|
|
3
3
|
import { GlTooltipDirective } from '../../../../../../directives/tooltip';
|
|
4
|
+
import GlDuoChatContextItemSelections from '../duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections';
|
|
4
5
|
import GlDuoUserFeedback from '../../../user_feedback/user_feedback';
|
|
5
6
|
import GlFormGroup from '../../../../../base/form/form_group/form_group';
|
|
6
7
|
import GlFormTextarea from '../../../../../base/form/form_textarea/form_textarea';
|
|
7
8
|
import { SafeHtmlDirective } from '../../../../../../directives/safe_html/safe_html';
|
|
9
|
+
import { translatePlural, sprintf } from '../../../../../../utils/i18n';
|
|
8
10
|
import { MESSAGE_MODEL_ROLES } from '../../constants';
|
|
9
11
|
import DocumentationSources from '../duo_chat_message_sources/duo_chat_message_sources';
|
|
10
12
|
import { renderDuoChatMarkdownPreview } from '../../markdown_renderer';
|
|
@@ -32,6 +34,7 @@ var script = {
|
|
|
32
34
|
},
|
|
33
35
|
components: {
|
|
34
36
|
DocumentationSources,
|
|
37
|
+
GlDuoChatContextItemSelections,
|
|
35
38
|
GlDuoUserFeedback,
|
|
36
39
|
GlFormGroup,
|
|
37
40
|
GlFormTextarea,
|
|
@@ -129,6 +132,26 @@ var script = {
|
|
|
129
132
|
error() {
|
|
130
133
|
var _this$message, _this$message$errors2;
|
|
131
134
|
return Boolean((_this$message = this.message) === null || _this$message === void 0 ? void 0 : (_this$message$errors2 = _this$message.errors) === null || _this$message$errors2 === void 0 ? void 0 : _this$message$errors2.length) && this.message.errors.join('; ');
|
|
135
|
+
},
|
|
136
|
+
selectedContextItems() {
|
|
137
|
+
var _this$message$extras3;
|
|
138
|
+
return ((_this$message$extras3 = this.message.extras) === null || _this$message$extras3 === void 0 ? void 0 : _this$message$extras3.contextItems) || [];
|
|
139
|
+
},
|
|
140
|
+
displaySelectedContextItems() {
|
|
141
|
+
return Boolean(this.selectedContextItems.length);
|
|
142
|
+
},
|
|
143
|
+
selectedContextItemsDefaultCollapsed() {
|
|
144
|
+
return this.isAssistantMessage;
|
|
145
|
+
},
|
|
146
|
+
selectedContextItemsTitle() {
|
|
147
|
+
if (!this.displaySelectedContextItems) return '';
|
|
148
|
+
const count = this.selectedContextItems.length;
|
|
149
|
+
if (this.isUserMessage) {
|
|
150
|
+
return translatePlural('GlDuoChatMessage.SelectedContextItemsTitleUserMessage', 'Included reference', 'Included references')(count);
|
|
151
|
+
}
|
|
152
|
+
return sprintf(translatePlural('GlDuoChatMessage.SelectedContextItemsTitleAssistantMessage', 'Used %{count} included reference', 'Used %{count} included references')(count), {
|
|
153
|
+
count
|
|
154
|
+
});
|
|
132
155
|
}
|
|
133
156
|
},
|
|
134
157
|
beforeCreate() {
|
|
@@ -205,7 +228,7 @@ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=
|
|
|
205
228
|
_vm.isAssistantMessage,
|
|
206
229
|
'gl-bg-white': _vm.isAssistantMessage && !_vm.error,
|
|
207
230
|
'!gl-border-none gl-bg-red-50': _vm.error,
|
|
208
|
-
},on:{"insert-code-snippet":_vm.onInsertCodeSnippet}},[(_vm.error)?_c('gl-icon',{staticClass:"error-icon gl-border gl-mr-3 gl-flex-shrink-0 gl-rounded-full gl-border-red-500 gl-text-red-600",attrs:{"aria-label":_vm.$options.i18n.MESSAGE_ERROR,"name":"status_warning_borderless","size":16,"data-testid":"error"}}):_vm._e(),_vm._v(" "),_c('div',{ref:"content-wrapper",class:{ 'has-error': _vm.error }},[(_vm.error)?_c('div',{directives:[{name:"safe-html",rawName:"v-safe-html:[$options.safeHtmlConfigExtension]",value:(_vm.renderedError),expression:"renderedError",arg:_vm.$options.safeHtmlConfigExtension}],ref:"error-message"}):_c('div',[_c('div',{directives:[{name:"safe-html",rawName:"v-safe-html:[$options.safeHtmlConfigExtension]",value:(_vm.messageContent),expression:"messageContent",arg:_vm.$options.safeHtmlConfigExtension}],ref:"content"}),_vm._v(" "),(_vm.isAssistantMessage)?[(_vm.sources)?_c('documentation-sources',{attrs:{"sources":_vm.sources}}):_vm._e(),_vm._v(" "),_c('div',{staticClass:"duo-chat-message-feedback gl-mt-4 gl-flex gl-items-end"},[(_vm.isChunkAndNotCancelled)?_c('gl-loading-icon',{staticClass:"gl-pt-4",attrs:{"variant":"dots","inline":""}}):_vm._e(),_vm._v(" "),(_vm.isNotChunkOrCancelled)?_c('gl-duo-user-feedback',{attrs:{"feedback-received":_vm.hasFeedback,"modal-title":_vm.$options.i18n.MODAL.TITLE,"modal-alert":_vm.$options.i18n.MODAL.ALERT_TEXT},on:{"feedback":_vm.logEvent},scopedSlots:_vm._u([{key:"feedback-extra-fields",fn:function(){return [_c('gl-form-group',{attrs:{"label":_vm.$options.i18n.MODAL.DID_WHAT,"optional":""}},[_c('gl-form-textarea',{attrs:{"placeholder":_vm.$options.i18n.MODAL.INTERACTION},model:{value:(_vm.didWhat),callback:function ($$v) {_vm.didWhat=$$v;},expression:"didWhat"}})],1),_vm._v(" "),_c('gl-form-group',{attrs:{"label":_vm.$options.i18n.MODAL.IMPROVE_WHAT,"optional":""}},[_c('gl-form-textarea',{attrs:{"placeholder":_vm.$options.i18n.MODAL.BETTER_RESPONSE},model:{value:(_vm.improveWhat),callback:function ($$v) {_vm.improveWhat=$$v;},expression:"improveWhat"}})],1)]},proxy:true}],null,false,419229417)}):_vm._e()],1)]:_vm._e()],2)])],1)};
|
|
231
|
+
},on:{"insert-code-snippet":_vm.onInsertCodeSnippet}},[(_vm.error)?_c('gl-icon',{staticClass:"error-icon gl-border gl-mr-3 gl-flex-shrink-0 gl-rounded-full gl-border-red-500 gl-text-red-600",attrs:{"aria-label":_vm.$options.i18n.MESSAGE_ERROR,"name":"status_warning_borderless","size":16,"data-testid":"error"}}):_vm._e(),_vm._v(" "),_c('div',{ref:"content-wrapper",class:{ 'has-error': _vm.error }},[(_vm.displaySelectedContextItems)?_c('gl-duo-chat-context-item-selections',{staticClass:"gl-mb-3",attrs:{"selections":_vm.selectedContextItems,"title":_vm.selectedContextItemsTitle,"default-collapsed":_vm.selectedContextItemsDefaultCollapsed}}):_vm._e(),_vm._v(" "),(_vm.error)?_c('div',{directives:[{name:"safe-html",rawName:"v-safe-html:[$options.safeHtmlConfigExtension]",value:(_vm.renderedError),expression:"renderedError",arg:_vm.$options.safeHtmlConfigExtension}],ref:"error-message"}):_c('div',[_c('div',{directives:[{name:"safe-html",rawName:"v-safe-html:[$options.safeHtmlConfigExtension]",value:(_vm.messageContent),expression:"messageContent",arg:_vm.$options.safeHtmlConfigExtension}],ref:"content"}),_vm._v(" "),(_vm.isAssistantMessage)?[(_vm.sources)?_c('documentation-sources',{attrs:{"sources":_vm.sources}}):_vm._e(),_vm._v(" "),_c('div',{staticClass:"duo-chat-message-feedback gl-mt-4 gl-flex gl-items-end"},[(_vm.isChunkAndNotCancelled)?_c('gl-loading-icon',{staticClass:"gl-pt-4",attrs:{"variant":"dots","inline":""}}):_vm._e(),_vm._v(" "),(_vm.isNotChunkOrCancelled)?_c('gl-duo-user-feedback',{attrs:{"feedback-received":_vm.hasFeedback,"modal-title":_vm.$options.i18n.MODAL.TITLE,"modal-alert":_vm.$options.i18n.MODAL.ALERT_TEXT},on:{"feedback":_vm.logEvent},scopedSlots:_vm._u([{key:"feedback-extra-fields",fn:function(){return [_c('gl-form-group',{attrs:{"label":_vm.$options.i18n.MODAL.DID_WHAT,"optional":""}},[_c('gl-form-textarea',{attrs:{"placeholder":_vm.$options.i18n.MODAL.INTERACTION},model:{value:(_vm.didWhat),callback:function ($$v) {_vm.didWhat=$$v;},expression:"didWhat"}})],1),_vm._v(" "),_c('gl-form-group',{attrs:{"label":_vm.$options.i18n.MODAL.IMPROVE_WHAT,"optional":""}},[_c('gl-form-textarea',{attrs:{"placeholder":_vm.$options.i18n.MODAL.BETTER_RESPONSE},model:{value:(_vm.improveWhat),callback:function ($$v) {_vm.improveWhat=$$v;},expression:"improveWhat"}})],1)]},proxy:true}],null,false,419229417)}):_vm._e()],1)]:_vm._e()],2)],1)],1)};
|
|
209
232
|
var __vue_staticRenderFns__ = [];
|
|
210
233
|
|
|
211
234
|
/* style */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { setStoryTimeout } from '../../../../utils/test_utils';
|
|
2
2
|
import { InsertCodeSnippetElement } from './components/duo_chat_message/insert_code_snippet_element';
|
|
3
3
|
import { DOCUMENTATION_SOURCE_TYPES, MESSAGE_MODEL_ROLES, CHAT_RESET_MESSAGE, CHAT_CLEAN_MESSAGE } from './constants';
|
|
4
|
+
import { getMockContextItems } from './components/duo_chat_context/mock_context_data';
|
|
4
5
|
|
|
5
6
|
const MOCK_SOURCES = [{
|
|
6
7
|
title: 'GitLab Handbook',
|
|
@@ -23,7 +24,8 @@ const MOCK_RESPONSE_MESSAGE = {
|
|
|
23
24
|
contentHtml: '<p data-sourcepos="1:1-1:56" dir="auto">Here is a simple JavaScript function to sum two numbers:</p>\n<div class="gl-relative markdown-code-block js-markdown-code">\n<pre data-sourcepos="3:1-7:3" data-canonical-lang="js" class="code highlight js-syntax-highlight language-javascript" lang="javascript" v-pre="true"><code><span id="LC1" class="line" lang="javascript"><span class="kd">function</span> <span class="nf">sum</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">b</span><span class="p">)</span> <span class="p">{</span></span>\n<span id="LC2" class="line" lang="javascript"> <span class="k">return</span> <span class="nx">a</span> <span class="o">+</span> <span class="nx">b</span><span class="p">;</span></span>\n<span id="LC3" class="line" lang="javascript"><span class="p">}</span></span></code></pre>\n<copy-code></copy-code>\n<insert-code-snippet></insert-code-snippet>\n</div>\n<p data-sourcepos="9:1-9:10" dir="auto">To use it:</p>\n<div class="gl-relative markdown-code-block js-markdown-code">\n<pre data-sourcepos="11:1-13:3" data-canonical-lang="js" class="code highlight js-syntax-highlight language-javascript" lang="javascript" v-pre="true"><code><span id="LC1" class="line" lang="javascript"><span class="kd">const</span> <span class="nx">result</span> <span class="o">=</span> <span class="nf">sum</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span> <span class="c1">// result = 8</span></span></code></pre>\n<copy-code></copy-code>\n</div>\n<p data-sourcepos="15:1-15:95" dir="auto">This function takes two number parameters, a and b. It returns the sum of adding them together.</p>',
|
|
24
25
|
role: MESSAGE_MODEL_ROLES.assistant,
|
|
25
26
|
extras: {
|
|
26
|
-
sources: MOCK_SOURCES
|
|
27
|
+
sources: MOCK_SOURCES,
|
|
28
|
+
contextItems: getMockContextItems().slice(0, 2)
|
|
27
29
|
},
|
|
28
30
|
requestId: '987',
|
|
29
31
|
errors: [],
|
|
@@ -67,7 +69,9 @@ const MOCK_RESPONSE_MESSAGE_FOR_STREAMING = {
|
|
|
67
69
|
which is rendered while streaming.
|
|
68
70
|
`,
|
|
69
71
|
role: 'assistant',
|
|
70
|
-
extras: {
|
|
72
|
+
extras: {
|
|
73
|
+
contextItems: getMockContextItems().slice(0, 2)
|
|
74
|
+
},
|
|
71
75
|
requestId: '987',
|
|
72
76
|
errors: [],
|
|
73
77
|
timestamp: '2021-04-21T12:00:00.000Z'
|
|
@@ -122,7 +126,9 @@ const MOCK_USER_PROMPT_MESSAGE = {
|
|
|
122
126
|
requestId: '987',
|
|
123
127
|
errors: [],
|
|
124
128
|
timestamp: '2021-04-21T12:00:00.000Z',
|
|
125
|
-
extras:
|
|
129
|
+
extras: {
|
|
130
|
+
contextItems: getMockContextItems().slice(0, 2)
|
|
131
|
+
}
|
|
126
132
|
};
|
|
127
133
|
const renderMarkdown = content => content;
|
|
128
134
|
const renderGFM = el => {
|