@gitlab/ui 94.4.2 → 94.5.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 +7 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_context/constants.js +4 -1
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_search_item.js +10 -3
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.js +12 -21
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.js +5 -11
- package/dist/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +60 -3
- package/dist/components/experimental/duo/chat/components/duo_chat_context/utils.js +71 -1
- 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/package.json +3 -3
- package/src/components/base/avatar_labeled/avatar_labeled.scss +1 -1
- package/src/components/base/breadcrumb/breadcrumb.scss +2 -2
- package/src/components/base/broadcast_message/broadcast_message.scss +1 -1
- package/src/components/base/button/button.scss +6 -6
- package/src/components/base/datepicker/datepicker.scss +7 -7
- package/src/components/base/daterange_picker/daterange_picker.scss +2 -2
- package/src/components/base/drawer/drawer.scss +3 -3
- package/src/components/base/dropdown/dropdown.scss +2 -2
- package/src/components/base/dropdown/dropdown_item.scss +4 -4
- package/src/components/base/filtered_search/filtered_search_suggestion_list.scss +1 -1
- package/src/components/base/filtered_search/filtered_search_term.scss +1 -1
- package/src/components/base/filtered_search/filtered_search_token.scss +3 -3
- package/src/components/base/filtered_search/filtered_search_token_segment.scss +2 -2
- package/src/components/base/form/form_checkbox/form_checkbox.scss +4 -4
- package/src/components/base/form/form_input/form_input.scss +3 -3
- package/src/components/base/form/form_select/form_select.scss +3 -3
- package/src/components/base/label/label.scss +4 -4
- package/src/components/base/loading_icon/loading_icon.scss +1 -1
- package/src/components/base/markdown/markdown.scss +3 -3
- package/src/components/base/markdown/markdown_typescale_demo.html +4 -4
- package/src/components/base/modal/modal.scss +1 -1
- package/src/components/base/new_dropdowns/dropdown.scss +3 -3
- package/src/components/base/new_dropdowns/dropdown_item.scss +2 -2
- package/src/components/base/pagination/pagination.scss +1 -1
- package/src/components/base/path/path.scss +3 -3
- package/src/components/base/popover/popover.scss +1 -1
- package/src/components/base/search_box_by_type/search_box_by_type.scss +1 -1
- package/src/components/base/segmented_control/segmented_control.scss +3 -3
- package/src/components/base/skeleton_loader/skeleton_loader.scss +1 -1
- package/src/components/base/tabs/tabs/tabs.scss +4 -4
- package/src/components/base/toast/toast.scss +1 -1
- package/src/components/base/toggle/toggle.scss +3 -3
- package/src/components/charts/heatmap/heatmap.scss +1 -1
- package/src/components/charts/legend/legend.scss +2 -2
- package/src/components/charts/tooltip/tooltip.scss +1 -1
- package/src/components/experimental/duo/chat/components/duo_chat_context/constants.js +4 -0
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_search_item.vue +19 -6
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.vue +33 -31
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.vue +16 -18
- package/src/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +64 -1
- package/src/components/experimental/duo/chat/components/duo_chat_context/utils.js +75 -0
- package/src/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.scss +4 -4
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.scss +2 -2
- package/src/components/experimental/duo/chat/duo_chat.scss +4 -4
- package/src/components/shared_components/clear_icon_button/clear_icon_button.scss +1 -1
- package/src/scss/typescale/_index.scss +2 -2
- package/translations.js +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [94.5.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v94.4.2...v94.5.0) (2024-10-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* support "local git" Duo Chat pinned context category ([127691f](https://gitlab.com/gitlab-org/gitlab-ui/commit/127691f786b076d2f20b44d4030ab2f526e8bf3a))
|
|
7
|
+
|
|
1
8
|
## [94.4.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v94.4.1...v94.4.2) (2024-09-27)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const CONTEXT_ITEM_CATEGORY_ISSUE = 'issue';
|
|
2
2
|
const CONTEXT_ITEM_CATEGORY_MERGE_REQUEST = 'merge_request';
|
|
3
3
|
const CONTEXT_ITEM_CATEGORY_FILE = 'file';
|
|
4
|
+
const CONTEXT_ITEM_CATEGORY_LOCAL_GIT = 'local_git';
|
|
5
|
+
const CONTEXT_ITEM_LOCAL_GIT_COMMIT = 'commit';
|
|
6
|
+
const CONTEXT_ITEM_LOCAL_GIT_DIFF = 'diff';
|
|
4
7
|
|
|
5
|
-
export { CONTEXT_ITEM_CATEGORY_FILE, CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST };
|
|
8
|
+
export { CONTEXT_ITEM_CATEGORY_FILE, CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_LOCAL_GIT, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST, CONTEXT_ITEM_LOCAL_GIT_COMMIT, CONTEXT_ITEM_LOCAL_GIT_DIFF };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import GlDuoChatContextItemPopover from '../duo_chat_context_item_popover/duo_chat_context_item_popover';
|
|
2
|
+
import GlTruncate from '../../../../../../utilities/truncate/truncate';
|
|
2
3
|
import GlIcon from '../../../../../../base/icon/icon';
|
|
3
|
-
import { categoryValidator, contextItemValidator, formatMergeRequestId, formatIssueId } from '../utils';
|
|
4
|
-
import { CONTEXT_ITEM_CATEGORY_MERGE_REQUEST, CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_FILE } from '../constants';
|
|
4
|
+
import { categoryValidator, contextItemValidator, formatGitItemSecondaryText, formatMergeRequestId, formatIssueId, getContextItemIcon } from '../utils';
|
|
5
|
+
import { CONTEXT_ITEM_CATEGORY_LOCAL_GIT, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST, CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_FILE } from '../constants';
|
|
5
6
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
6
7
|
|
|
7
8
|
var script = {
|
|
8
9
|
name: 'GlDuoChatContextItemMenuSearchItem',
|
|
9
10
|
components: {
|
|
11
|
+
GlTruncate,
|
|
10
12
|
GlIcon,
|
|
11
13
|
GlDuoChatContextItemPopover
|
|
12
14
|
},
|
|
@@ -35,9 +37,14 @@ var script = {
|
|
|
35
37
|
return formatIssueId(this.contextItem.metadata.iid);
|
|
36
38
|
case CONTEXT_ITEM_CATEGORY_MERGE_REQUEST:
|
|
37
39
|
return formatMergeRequestId(this.contextItem.metadata.iid);
|
|
40
|
+
case CONTEXT_ITEM_CATEGORY_LOCAL_GIT:
|
|
41
|
+
return formatGitItemSecondaryText(this.contextItem);
|
|
38
42
|
default:
|
|
39
43
|
return '';
|
|
40
44
|
}
|
|
45
|
+
},
|
|
46
|
+
icon() {
|
|
47
|
+
return getContextItemIcon(this.contextItem, this.category);
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
};
|
|
@@ -46,7 +53,7 @@ var script = {
|
|
|
46
53
|
const __vue_script__ = script;
|
|
47
54
|
|
|
48
55
|
/* template */
|
|
49
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-flex gl-flex-col"},[_c('div',{staticClass:"gl-flex gl-items-center"},[_c('gl-icon',{staticClass:"gl-mr-2 gl-shrink-0",attrs:{"name":_vm.
|
|
56
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-flex gl-flex-col"},[_c('div',{staticClass:"gl-flex gl-items-center"},[_c('gl-icon',{staticClass:"gl-mr-2 gl-shrink-0",attrs:{"name":_vm.icon,"data-testid":"category-icon"}}),_vm._v(" "),_c('gl-truncate',{staticClass:"gl-min-w-0",attrs:{"text":_vm.title,"data-testid":"item-title"}}),_vm._v(" "),_c('gl-icon',{staticClass:"gl-ml-2 gl-shrink-0 gl-cursor-pointer gl-text-secondary",attrs:{"id":("info-icon-" + (_vm.contextItem.id)),"name":"information-o","size":12}}),_vm._v(" "),_c('gl-duo-chat-context-item-popover',{attrs:{"context-item":_vm.contextItem,"target":("info-icon-" + (_vm.contextItem.id)),"placement":"left"}})],1),_vm._v(" "),(_vm.secondaryText)?_c('div',{staticClass:"gl-mt-1 gl-shrink-0 gl-whitespace-nowrap gl-text-secondary",attrs:{"data-testid":"item-secondary-text"}},[_c('gl-truncate',{attrs:{"text":_vm.secondaryText}})],1):_vm._e()])};
|
|
50
57
|
var __vue_staticRenderFns__ = [];
|
|
51
58
|
|
|
52
59
|
/* style */
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import GlAlert from '../../../../../../base/alert/alert';
|
|
2
2
|
import GlIcon from '../../../../../../base/icon/icon';
|
|
3
|
+
import GlPopover from '../../../../../../base/popover/popover';
|
|
4
|
+
import GlTruncate from '../../../../../../utilities/truncate/truncate';
|
|
3
5
|
import { translate } from '../../../../../../../utils/i18n';
|
|
4
|
-
import { CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST, CONTEXT_ITEM_CATEGORY_FILE } from '../constants';
|
|
5
|
-
import { formatMergeRequestId, formatIssueId } from '../utils';
|
|
6
|
-
import GlAlert from '../../../../../../base/alert/alert';
|
|
6
|
+
import { CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST, CONTEXT_ITEM_CATEGORY_FILE, CONTEXT_ITEM_CATEGORY_LOCAL_GIT } from '../constants';
|
|
7
|
+
import { formatMergeRequestId, formatIssueId, formatGitItemSecondaryText, getContextItemIcon, getContextItemTypeLabel } from '../utils';
|
|
7
8
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
8
9
|
|
|
9
10
|
var script = {
|
|
10
11
|
name: 'DuoChatContextItemPopover',
|
|
11
12
|
components: {
|
|
13
|
+
GlTruncate,
|
|
12
14
|
GlAlert,
|
|
13
15
|
GlIcon,
|
|
14
16
|
GlPopover
|
|
@@ -62,6 +64,9 @@ var script = {
|
|
|
62
64
|
var _this$filePath;
|
|
63
65
|
return (_this$filePath = this.filePath) === null || _this$filePath === void 0 ? void 0 : _this$filePath.split('/');
|
|
64
66
|
},
|
|
67
|
+
gitDetails() {
|
|
68
|
+
return this.contextItem.category === CONTEXT_ITEM_CATEGORY_LOCAL_GIT ? formatGitItemSecondaryText(this.contextItem) : null;
|
|
69
|
+
},
|
|
65
70
|
isEnabled() {
|
|
66
71
|
return this.contextItem.metadata.enabled !== false;
|
|
67
72
|
},
|
|
@@ -69,24 +74,10 @@ var script = {
|
|
|
69
74
|
return Array.isArray(this.contextItem.metadata.disabledReasons) && this.contextItem.metadata.disabledReasons.length > 0 ? this.contextItem.metadata.disabledReasons.join(', ') : translate('DuoChatContextItemPopover.DisabledReason', 'This item is disabled');
|
|
70
75
|
},
|
|
71
76
|
iconName() {
|
|
72
|
-
|
|
73
|
-
case 'merge_request':
|
|
74
|
-
return 'merge-request';
|
|
75
|
-
case 'issue':
|
|
76
|
-
return 'issues';
|
|
77
|
-
default:
|
|
78
|
-
return 'project';
|
|
79
|
-
}
|
|
77
|
+
return getContextItemIcon(this.contextItem);
|
|
80
78
|
},
|
|
81
79
|
itemTypeLabel() {
|
|
82
|
-
|
|
83
|
-
case 'merge_request':
|
|
84
|
-
return translate('DuoChatContextItemPopover.MergeRequest', 'Merge request');
|
|
85
|
-
case 'issue':
|
|
86
|
-
return translate('DuoChatContextItemPopover.Issue', 'Issue');
|
|
87
|
-
default:
|
|
88
|
-
return translate('DuoChatContextItemPopover.File', 'Project file');
|
|
89
|
-
}
|
|
80
|
+
return getContextItemTypeLabel(this.contextItem);
|
|
90
81
|
}
|
|
91
82
|
},
|
|
92
83
|
methods: {
|
|
@@ -98,7 +89,7 @@ var script = {
|
|
|
98
89
|
const __vue_script__ = script;
|
|
99
90
|
|
|
100
91
|
/* template */
|
|
101
|
-
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.title,"custom-class":"gl-duo-chat-item-popover"},scopedSlots:_vm._u([{key:"title",fn:function(){return [_c('div',[_c('div',{staticClass:"gl-heading-3 gl-mb-1 gl-mt-2 gl-leading-1",attrs:{"data-testid":"chat-context-popover-title"}},[_vm._v("\n "+_vm._s(_vm.
|
|
92
|
+
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.title,"custom-class":"gl-duo-chat-item-popover"},scopedSlots:_vm._u([{key:"title",fn:function(){return [_c('div',[_c('div',{staticClass:"gl-heading-3 gl-mb-1 gl-mt-2 gl-leading-1",attrs:{"data-testid":"chat-context-popover-title"}},[_vm._v("\n "+_vm._s(_vm.title)+"\n ")]),_vm._v(" "),(_vm.itemTypeLabel)?_c('div',{staticClass:"gl-font-normal gl-text-subtle"},[_vm._v(_vm._s(_vm.itemTypeLabel))]):_vm._e()])]},proxy:true}])},[_vm._v(" "),_c('div',[(_vm.filePath)?_c('div',[_c('gl-icon',{attrs:{"name":"document","size":12,"variant":"subtle"}}),_vm._v(" "),_c('span',{staticClass:"gl-break-all"},[_vm._v(_vm._s(_vm.contextItem.metadata.project))]),_vm._v(" "),_vm._l((_vm.filePathArray),function(pathPart,index){return _c('span',{key:pathPart,staticClass:"gl-break-all"},[_vm._v(_vm._s(pathPart)+_vm._s(index + 1 < _vm.filePathArray.length ? '/' : ''))])})],2):(_vm.gitDetails)?_c('div',{staticClass:"gl-flex gl-items-center",attrs:{"data-testid":"git-details"}},[_c('gl-icon',{staticClass:"gl-mr-1 gl-shrink-0",attrs:{"name":_vm.iconName,"size":12,"variant":"subtle"}}),_vm._v(" "),_c('gl-truncate',{staticClass:"gl-min-w-0",attrs:{"text":_vm.gitDetails}})],1):_c('div',[(_vm.iconName)?_c('gl-icon',{attrs:{"name":_vm.iconName,"size":12,"variant":"subtle"}}):_vm._e(),_vm._v(" "),_c('span',{staticClass:"gl-break-all"},[_vm._v(_vm._s(_vm.contextItem.metadata.project))]),_vm._v(" "),(_vm.id)?_c('span',{staticClass:"gl-break-all"},[_vm._v(_vm._s(_vm.formattedId))]):_vm._e()],1),_vm._v(" "),(!_vm.isEnabled)?_c('gl-alert',{staticClass:"gl-mb-1 gl-mt-3 gl-p-4 gl-text-sm",attrs:{"variant":"danger","data-testid":"chat-context-popover-disabled","dismissible":false,"show-icon":false}},[_vm._v("\n "+_vm._s(_vm.disabledMessage)+"\n ")]):_vm._e()],1)])};
|
|
102
93
|
var __vue_staticRenderFns__ = [];
|
|
103
94
|
|
|
104
95
|
/* style */
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import uniqueId from 'lodash/uniqueId';
|
|
2
2
|
import GlIcon from '../../../../../../base/icon/icon';
|
|
3
3
|
import GlToken from '../../../../../../base/token/token';
|
|
4
|
+
import GlTruncate from '../../../../../../utilities/truncate/truncate';
|
|
4
5
|
import GlDuoChatContextItemPopover from '../duo_chat_context_item_popover/duo_chat_context_item_popover';
|
|
5
|
-
import {
|
|
6
|
-
import { contextItemsValidator } from '../utils';
|
|
6
|
+
import { contextItemsValidator, getContextItemIcon } from '../utils';
|
|
7
7
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
8
8
|
|
|
9
9
|
var script = {
|
|
10
10
|
name: 'GlDuoChatContextItemSelections',
|
|
11
11
|
components: {
|
|
12
|
+
GlTruncate,
|
|
12
13
|
GlIcon,
|
|
13
14
|
GlDuoChatContextItemPopover,
|
|
14
15
|
GlToken
|
|
@@ -74,14 +75,7 @@ var script = {
|
|
|
74
75
|
}
|
|
75
76
|
},
|
|
76
77
|
methods: {
|
|
77
|
-
|
|
78
|
-
const iconMap = {
|
|
79
|
-
[CONTEXT_ITEM_CATEGORY_FILE]: 'document',
|
|
80
|
-
[CONTEXT_ITEM_CATEGORY_ISSUE]: 'issues',
|
|
81
|
-
[CONTEXT_ITEM_CATEGORY_MERGE_REQUEST]: 'merge-request'
|
|
82
|
-
};
|
|
83
|
-
return iconMap[category] || 'document';
|
|
84
|
-
},
|
|
78
|
+
getContextItemIcon,
|
|
85
79
|
toggleCollapse() {
|
|
86
80
|
this.isCollapsed = !this.isCollapsed;
|
|
87
81
|
},
|
|
@@ -99,7 +93,7 @@ var script = {
|
|
|
99
93
|
const __vue_script__ = script;
|
|
100
94
|
|
|
101
95
|
/* template */
|
|
102
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-flex gl-flex-col",class:_vm.variantClasses},[_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-inherit",attrs:{"data-testid":"chat-context-selections-title","type":"button"},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",class:_vm.tokenVariantClasses,attrs:{"id":("context-item-" + (item.id) + "-" + _vm.selectionsId + "-token"),"view-only":!_vm.removable,"variant":"default"},on:{"close":function($event){return _vm.onRemoveItem(item)}}},[_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.
|
|
96
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-flex gl-flex-col",class:_vm.variantClasses},[_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-inherit",attrs:{"data-testid":"chat-context-selections-title","type":"button"},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 gl-max-w-full",class:_vm.tokenVariantClasses,attrs:{"id":("context-item-" + (item.id) + "-" + _vm.selectionsId + "-token"),"view-only":!_vm.removable,"variant":"default"},on:{"close":function($event){return _vm.onRemoveItem(item)}}},[_c('div',{staticClass:"gl-flex gl-min-w-0 gl-items-center",attrs:{"id":("context-item-" + (item.id) + "-" + _vm.selectionsId)}},[(_vm.getContextItemIcon(item))?_c('gl-icon',{staticClass:"gl-mr-1",attrs:{"name":_vm.getContextItemIcon(item),"size":12}}):_vm._e(),_vm._v(" "),_c('gl-truncate',{attrs:{"text":item.metadata.title,"position":"middle"}})],1),_vm._v(" "),_c('gl-duo-chat-context-item-popover',{attrs:{"context-item":item,"target":("context-item-" + (item.id) + "-" + _vm.selectionsId + "-token"),"placement":"bottom"}})],1)}),1)])};
|
|
103
97
|
var __vue_staticRenderFns__ = [];
|
|
104
98
|
|
|
105
99
|
/* style */
|
package/dist/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { CONTEXT_ITEM_CATEGORY_FILE, CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST } from './constants';
|
|
1
|
+
import { CONTEXT_ITEM_CATEGORY_FILE, CONTEXT_ITEM_CATEGORY_LOCAL_GIT, CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST } from './constants';
|
|
2
2
|
|
|
3
3
|
const MOCK_CATEGORIES = [{
|
|
4
4
|
label: 'Files',
|
|
5
5
|
value: CONTEXT_ITEM_CATEGORY_FILE,
|
|
6
6
|
icon: 'document'
|
|
7
|
+
}, {
|
|
8
|
+
label: 'Local Git',
|
|
9
|
+
value: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
|
|
10
|
+
icon: 'git'
|
|
7
11
|
}, {
|
|
8
12
|
label: 'Issues',
|
|
9
13
|
value: CONTEXT_ITEM_CATEGORY_ISSUE,
|
|
@@ -109,8 +113,61 @@ const mockMergeRequests = [MOCK_CONTEXT_ITEM_MERGE_REQUEST, {
|
|
|
109
113
|
iid: 3344
|
|
110
114
|
}
|
|
111
115
|
}, MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED];
|
|
116
|
+
const MOCK_CONTEXT_ITEM_GIT_DIFF = {
|
|
117
|
+
id: '6d88b466-0c38-48d6-b271-deda47f97cee',
|
|
118
|
+
category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
|
|
119
|
+
metadata: {
|
|
120
|
+
enabled: true,
|
|
121
|
+
title: 'Current working changes',
|
|
122
|
+
commitId: 'main',
|
|
123
|
+
repositoryName: 'example/garden',
|
|
124
|
+
gitType: 'diff'
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const MOCK_CONTEXT_ITEM_GIT_COMMIT = {
|
|
128
|
+
id: '20f8caf94cb8f5e5f9dbd1a9ac32702321de201b',
|
|
129
|
+
category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
|
|
130
|
+
metadata: {
|
|
131
|
+
enabled: true,
|
|
132
|
+
title: 'fix: some bug fix commit',
|
|
133
|
+
commitId: '20f8caf94cb8f5e5f9dbd1a9ac32702321de201b',
|
|
134
|
+
repositoryName: 'example/garden',
|
|
135
|
+
gitType: 'commit'
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const mockGitItems = [MOCK_CONTEXT_ITEM_GIT_DIFF, {
|
|
139
|
+
id: 'diff-example/garden',
|
|
140
|
+
category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
|
|
141
|
+
metadata: {
|
|
142
|
+
enabled: true,
|
|
143
|
+
title: 'Diff from default branch',
|
|
144
|
+
commitId: 'main',
|
|
145
|
+
repositoryName: 'example/garden',
|
|
146
|
+
gitType: 'diff'
|
|
147
|
+
}
|
|
148
|
+
}, MOCK_CONTEXT_ITEM_GIT_COMMIT, {
|
|
149
|
+
id: '32b9b56b6de75b32909986755fbc470f20fb6fc0',
|
|
150
|
+
category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
|
|
151
|
+
metadata: {
|
|
152
|
+
enabled: true,
|
|
153
|
+
title: 'feat: add cool new feature',
|
|
154
|
+
commitId: '32b9b56b6de75b32909986755fbc470f20fb6fc0',
|
|
155
|
+
repositoryName: 'example/garden',
|
|
156
|
+
gitType: 'commit'
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
159
|
+
id: '775d7efdce25c1af48c55abcadbefd1f181b92ce',
|
|
160
|
+
category: CONTEXT_ITEM_CATEGORY_LOCAL_GIT,
|
|
161
|
+
metadata: {
|
|
162
|
+
enabled: true,
|
|
163
|
+
title: 'fix: stop foo from bar when baz because customers ding',
|
|
164
|
+
commitId: '775d7efdce25c1af48c55abcadbefd1f181b92ce',
|
|
165
|
+
repositoryName: 'example/garden',
|
|
166
|
+
gitType: 'commit'
|
|
167
|
+
}
|
|
168
|
+
}];
|
|
112
169
|
const getMockContextItems = () => {
|
|
113
|
-
const allItems = [...mockFiles, ...mockIssues, ...mockMergeRequests];
|
|
170
|
+
const allItems = [...mockFiles, ...mockGitItems, ...mockIssues, ...mockMergeRequests];
|
|
114
171
|
|
|
115
172
|
// put disabled items in the back
|
|
116
173
|
const disabledItems = allItems.filter(item => !item.metadata.enabled);
|
|
@@ -118,4 +175,4 @@ const getMockContextItems = () => {
|
|
|
118
175
|
return [...enabledItems, ...disabledItems];
|
|
119
176
|
};
|
|
120
177
|
|
|
121
|
-
export { MOCK_CATEGORIES, 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, getMockCategory, getMockContextItems };
|
|
178
|
+
export { MOCK_CATEGORIES, MOCK_CONTEXT_ITEM_FILE, MOCK_CONTEXT_ITEM_FILE_DISABLED, MOCK_CONTEXT_ITEM_GIT_COMMIT, MOCK_CONTEXT_ITEM_GIT_DIFF, MOCK_CONTEXT_ITEM_ISSUE, MOCK_CONTEXT_ITEM_ISSUE_DISABLED, MOCK_CONTEXT_ITEM_MERGE_REQUEST, MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED, getMockCategory, getMockContextItems };
|
|
@@ -1,3 +1,6 @@
|
|
|
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
|
+
|
|
1
4
|
function categoryValidator(category) {
|
|
2
5
|
return Boolean(category && category.value && category.label && category.icon);
|
|
3
6
|
}
|
|
@@ -21,6 +24,73 @@ function formatMergeRequestId(iid) {
|
|
|
21
24
|
if (!iid) return '';
|
|
22
25
|
return `!${iid}`;
|
|
23
26
|
}
|
|
27
|
+
function getGitItemIcon(contextItem) {
|
|
28
|
+
const iconMap = {
|
|
29
|
+
[CONTEXT_ITEM_LOCAL_GIT_COMMIT]: 'commit',
|
|
30
|
+
[CONTEXT_ITEM_LOCAL_GIT_DIFF]: 'comparison'
|
|
31
|
+
};
|
|
32
|
+
const {
|
|
33
|
+
gitType
|
|
34
|
+
} = contextItem.metadata;
|
|
35
|
+
return iconMap[gitType] || null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Gets the icon name for a given contextItem.
|
|
40
|
+
*/
|
|
41
|
+
function getContextItemIcon(contextItem) {
|
|
42
|
+
let category = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
43
|
+
icon: null
|
|
44
|
+
};
|
|
45
|
+
if (contextItem.category === CONTEXT_ITEM_CATEGORY_LOCAL_GIT) {
|
|
46
|
+
const gitIcon = getGitItemIcon(contextItem);
|
|
47
|
+
if (gitIcon) return gitIcon;
|
|
48
|
+
}
|
|
49
|
+
if (category.icon) {
|
|
50
|
+
return category.icon;
|
|
51
|
+
}
|
|
52
|
+
const iconMap = {
|
|
53
|
+
[CONTEXT_ITEM_CATEGORY_FILE]: 'document',
|
|
54
|
+
[CONTEXT_ITEM_CATEGORY_ISSUE]: 'issues',
|
|
55
|
+
[CONTEXT_ITEM_CATEGORY_MERGE_REQUEST]: 'merge-request',
|
|
56
|
+
[CONTEXT_ITEM_CATEGORY_LOCAL_GIT]: 'git'
|
|
57
|
+
};
|
|
58
|
+
return iconMap[contextItem.category] || null;
|
|
59
|
+
}
|
|
60
|
+
function getContextItemTypeLabel(contextItem) {
|
|
61
|
+
if (contextItem.category === CONTEXT_ITEM_CATEGORY_LOCAL_GIT) {
|
|
62
|
+
switch (contextItem.metadata.gitType) {
|
|
63
|
+
case CONTEXT_ITEM_LOCAL_GIT_DIFF:
|
|
64
|
+
return translate('DuoChatContextItemTypeLabel.GitDiff', 'Local Git repository diff');
|
|
65
|
+
case CONTEXT_ITEM_LOCAL_GIT_COMMIT:
|
|
66
|
+
return translate('DuoChatContextItemTypeLabel.GitCommit', 'Local Git repository commit');
|
|
67
|
+
default:
|
|
68
|
+
return translate('DuoChatContextItemTypeLabel.GitDefault', 'Local Git repository');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
switch (contextItem.category) {
|
|
72
|
+
case CONTEXT_ITEM_CATEGORY_MERGE_REQUEST:
|
|
73
|
+
return translate('DuoChatContextItemTypeLabel.MergeRequest', 'Merge request');
|
|
74
|
+
case CONTEXT_ITEM_CATEGORY_ISSUE:
|
|
75
|
+
return translate('DuoChatContextItemTypeLabel.Issue', 'Issue');
|
|
76
|
+
case CONTEXT_ITEM_CATEGORY_FILE:
|
|
77
|
+
return translate('DuoChatContextItemTypeLabel.File', 'Project file');
|
|
78
|
+
default:
|
|
79
|
+
return '';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Gets the secondary text line for a git context item, showing repository and commit ID
|
|
85
|
+
*/
|
|
86
|
+
function formatGitItemSecondaryText(contextItem) {
|
|
87
|
+
const {
|
|
88
|
+
repositoryName,
|
|
89
|
+
commitId
|
|
90
|
+
} = contextItem.metadata;
|
|
91
|
+
const separator = commitId ? ' - ' : '';
|
|
92
|
+
return `${repositoryName}${separator}${commitId || ''}`;
|
|
93
|
+
}
|
|
24
94
|
|
|
25
95
|
/**
|
|
26
96
|
* Calculates a new index within a range. If the new index would fall out of bounds, wraps to the start/end of the range.
|
|
@@ -33,4 +103,4 @@ function wrapIndex(currentIndex, step, totalLength) {
|
|
|
33
103
|
return (currentIndex + step + totalLength) % totalLength;
|
|
34
104
|
}
|
|
35
105
|
|
|
36
|
-
export { categoriesValidator, categoryValidator, contextItemValidator, contextItemsValidator, formatIssueId, formatMergeRequestId, wrapIndex };
|
|
106
|
+
export { categoriesValidator, categoryValidator, contextItemValidator, contextItemsValidator, formatGitItemSecondaryText, formatIssueId, formatMergeRequestId, getContextItemIcon, getContextItemTypeLabel, wrapIndex };
|