@gitlab/ui 92.3.0 → 92.4.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 +14 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_context/constants.js +4 -4
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.js +4 -4
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_search_item.js +8 -8
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_search_items.js +5 -4
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.js +15 -16
- package/dist/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.js +7 -7
- package/dist/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +63 -81
- package/dist/components/experimental/duo/chat/components/duo_chat_context/utils.js +1 -1
- package/dist/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.js +9 -11
- package/package.json +3 -3
- package/src/components/experimental/duo/chat/components/duo_chat_context/constants.js +3 -3
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu.vue +4 -4
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_search_item.vue +10 -10
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_menu/duo_chat_context_item_menu_search_items.vue +6 -5
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_popover/duo_chat_context_item_popover.vue +24 -24
- package/src/components/experimental/duo/chat/components/duo_chat_context/duo_chat_context_item_selections/duo_chat_context_item_selections.vue +10 -10
- package/src/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js +57 -74
- package/src/components/experimental/duo/chat/components/duo_chat_context/utils.js +5 -3
- package/src/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.md +7 -3
- package/src/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.vue +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [92.4.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v92.3.1...v92.4.0) (2024-09-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **DuoWorkflowPanel:** Add Duo panel isExpanded prop ([5916cd1](https://gitlab.com/gitlab-org/gitlab-ui/commit/5916cd18ac361baab554b2b2a64cbdbb62cb59a6))
|
|
7
|
+
|
|
8
|
+
## [92.3.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v92.3.0...v92.3.1) (2024-09-13)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update context-items-menu components with updated schema ([afff4cb](https://gitlab.com/gitlab-org/gitlab-ui/commit/afff4cbed8b0d1fea836938a7e6b6d22ee92981a))
|
|
14
|
+
|
|
1
15
|
# [92.3.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v92.2.0...v92.3.0) (2024-09-12)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
const CONTEXT_ITEM_CATEGORY_ISSUE = 'issue';
|
|
2
|
+
const CONTEXT_ITEM_CATEGORY_MERGE_REQUEST = 'merge_request';
|
|
3
|
+
const CONTEXT_ITEM_CATEGORY_FILE = 'file';
|
|
4
4
|
|
|
5
|
-
export {
|
|
5
|
+
export { CONTEXT_ITEM_CATEGORY_FILE, CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST };
|
|
@@ -76,7 +76,7 @@ var script = {
|
|
|
76
76
|
return this.open && !this.selectedCategory;
|
|
77
77
|
},
|
|
78
78
|
allResultsAreDisabled() {
|
|
79
|
-
return this.results.every(result => !result.
|
|
79
|
+
return this.results.every(result => !result.metadata.enabled);
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
watch: {
|
|
@@ -89,7 +89,7 @@ var script = {
|
|
|
89
89
|
this.debouncedSearch(query);
|
|
90
90
|
},
|
|
91
91
|
results(newResults) {
|
|
92
|
-
const firstEnabledIndex = newResults.findIndex(result => result.
|
|
92
|
+
const firstEnabledIndex = newResults.findIndex(result => result.metadata.enabled);
|
|
93
93
|
this.activeIndex = firstEnabledIndex >= 0 ? firstEnabledIndex : 0;
|
|
94
94
|
}
|
|
95
95
|
},
|
|
@@ -115,7 +115,7 @@ var script = {
|
|
|
115
115
|
});
|
|
116
116
|
}, SEARCH_DEBOUNCE_MS),
|
|
117
117
|
selectItem(item) {
|
|
118
|
-
if (!item.
|
|
118
|
+
if (!item.metadata.enabled) {
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -207,7 +207,7 @@ var script = {
|
|
|
207
207
|
// If we've looped through all items and found no enabled ones, keep the current index
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
|
-
} while (!this.results[newIndex].
|
|
210
|
+
} while (!this.results[newIndex].metadata.enabled);
|
|
211
211
|
this.activeIndex = newIndex;
|
|
212
212
|
}
|
|
213
213
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import GlDuoChatContextItemPopover from '../duo_chat_context_item_popover/duo_chat_context_item_popover';
|
|
2
2
|
import GlIcon from '../../../../../../base/icon/icon';
|
|
3
3
|
import { categoryValidator, contextItemValidator, formatMergeRequestId, formatIssueId } from '../utils';
|
|
4
|
-
import {
|
|
4
|
+
import { CONTEXT_ITEM_CATEGORY_MERGE_REQUEST, CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_FILE } from '../constants';
|
|
5
5
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
6
6
|
|
|
7
7
|
var script = {
|
|
@@ -25,16 +25,16 @@ var script = {
|
|
|
25
25
|
computed: {
|
|
26
26
|
title() {
|
|
27
27
|
var _this$contextItem$met;
|
|
28
|
-
return ((_this$contextItem$met = this.contextItem.metadata) === null || _this$contextItem$met === void 0 ? void 0 : _this$contextItem$met.
|
|
28
|
+
return ((_this$contextItem$met = this.contextItem.metadata) === null || _this$contextItem$met === void 0 ? void 0 : _this$contextItem$met.title) || '';
|
|
29
29
|
},
|
|
30
30
|
secondaryText() {
|
|
31
31
|
switch (this.category.value) {
|
|
32
|
-
case
|
|
33
|
-
return this.contextItem.metadata.
|
|
34
|
-
case
|
|
35
|
-
return formatIssueId(this.contextItem.metadata.
|
|
36
|
-
case
|
|
37
|
-
return formatMergeRequestId(this.contextItem.metadata.
|
|
32
|
+
case CONTEXT_ITEM_CATEGORY_FILE:
|
|
33
|
+
return this.contextItem.metadata.relativePath;
|
|
34
|
+
case CONTEXT_ITEM_CATEGORY_ISSUE:
|
|
35
|
+
return formatIssueId(this.contextItem.metadata.iid);
|
|
36
|
+
case CONTEXT_ITEM_CATEGORY_MERGE_REQUEST:
|
|
37
|
+
return formatMergeRequestId(this.contextItem.metadata.iid);
|
|
38
38
|
default:
|
|
39
39
|
return '';
|
|
40
40
|
}
|
|
@@ -83,12 +83,12 @@ var script = {
|
|
|
83
83
|
},
|
|
84
84
|
setActiveIndex(index) {
|
|
85
85
|
var _this$results$index;
|
|
86
|
-
if ((_this$results$index = this.results[index]) !== null && _this$results$index !== void 0 && _this$results$index.
|
|
86
|
+
if ((_this$results$index = this.results[index]) !== null && _this$results$index !== void 0 && _this$results$index.metadata.enabled) {
|
|
87
87
|
this.$emit('active-index-change', index);
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
isActiveItem(contextItem, index) {
|
|
91
|
-
return index === this.activeIndex && contextItem.
|
|
91
|
+
return index === this.activeIndex && contextItem.metadata.enabled;
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
i18n: {
|
|
@@ -102,8 +102,9 @@ const __vue_script__ = script;
|
|
|
102
102
|
/* template */
|
|
103
103
|
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('div',{staticClass:"gl-max-h-31 gl-overflow-y-scroll"},[(_vm.loading)?_c('gl-duo-chat-context-item-menu-search-items-loading',{attrs:{"rows":_vm.numLoadingItems}}):(_vm.error)?_c('gl-alert',{staticClass:"gl-m-3",attrs:{"variant":"danger","dismissible":false,"data-testid":"search-results-error"}},[_vm._v("\n "+_vm._s(_vm.error)+"\n ")]):(_vm.showEmptyState)?_c('div',{staticClass:"gl-rounded-base gl-p-3 gl-text-center gl-text-secondary",attrs:{"data-testid":"search-results-empty-state"}},[_vm._v("\n "+_vm._s(_vm.$options.i18n.emptyStateMessage)+"\n ")]):_c('ul',{staticClass:"gl-mb-1 gl-list-none gl-flex-row gl-pl-0"},_vm._l((_vm.results),function(contextItem,index){return _c('gl-dropdown-item',{key:contextItem.id,staticClass:"duo-chat-context-search-result-item",class:{
|
|
104
104
|
'active-command': _vm.isActiveItem(contextItem, index),
|
|
105
|
-
'gl-cursor-not-allowed [&>button]:focus-within:!gl-shadow-none':
|
|
106
|
-
|
|
105
|
+
'gl-cursor-not-allowed [&>button]:focus-within:!gl-shadow-none':
|
|
106
|
+
!contextItem.metadata.enabled,
|
|
107
|
+
},attrs:{"id":("dropdown-item-" + index),"tabindex":!contextItem.metadata.enabled ? -1 : undefined,"data-testid":"search-result-item"},on:{"click":function($event){return _vm.selectItem(contextItem)}}},[_c('div',{on:{"mouseenter":function($event){return _vm.setActiveIndex(index)}}},[_c('gl-duo-chat-context-item-menu-search-item',{class:{ 'gl-text-secondary': !contextItem.metadata.enabled },attrs:{"context-item":contextItem,"category":_vm.category,"data-testid":"search-result-item-details"}})],1)])}),1)],1),_vm._v(" "),_c('gl-form-input',{ref:"contextMenuSearchInput",attrs:{"value":_vm.searchQuery,"placeholder":_vm.searchInputPlaceholder,"autofocus":"","data-testid":"context-menu-search-input"},on:{"input":function($event){return _vm.$emit('update:searchQuery', $event)},"keyup":_vm.handleKeyUp}})],1)};
|
|
107
108
|
var __vue_staticRenderFns__ = [];
|
|
108
109
|
|
|
109
110
|
/* style */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import GlPopover from '../../../../../../base/popover/popover';
|
|
2
2
|
import GlIcon from '../../../../../../base/icon/icon';
|
|
3
3
|
import { translate } from '../../../../../../../utils/i18n';
|
|
4
|
-
import {
|
|
4
|
+
import { CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST, CONTEXT_ITEM_CATEGORY_FILE } from '../constants';
|
|
5
5
|
import { formatMergeRequestId, formatIssueId } from '../utils';
|
|
6
6
|
import GlAlert from '../../../../../../base/alert/alert';
|
|
7
7
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
@@ -38,39 +38,38 @@ var script = {
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
computed: {
|
|
41
|
-
itemInfo() {
|
|
42
|
-
var _this$contextItem$met;
|
|
43
|
-
return ((_this$contextItem$met = this.contextItem.metadata) === null || _this$contextItem$met === void 0 ? void 0 : _this$contextItem$met.info) || {};
|
|
44
|
-
},
|
|
45
41
|
id() {
|
|
46
|
-
const isIssuable = this.contextItem.
|
|
47
|
-
return isIssuable ? this.
|
|
42
|
+
const isIssuable = this.contextItem.category === CONTEXT_ITEM_CATEGORY_ISSUE || this.contextItem.category === CONTEXT_ITEM_CATEGORY_MERGE_REQUEST;
|
|
43
|
+
return isIssuable ? this.contextItem.metadata.iid : null;
|
|
48
44
|
},
|
|
49
45
|
formattedId() {
|
|
50
|
-
switch (this.contextItem.
|
|
51
|
-
case
|
|
46
|
+
switch (this.contextItem.category) {
|
|
47
|
+
case CONTEXT_ITEM_CATEGORY_ISSUE:
|
|
52
48
|
return formatIssueId(this.id);
|
|
53
|
-
case
|
|
49
|
+
case CONTEXT_ITEM_CATEGORY_MERGE_REQUEST:
|
|
54
50
|
return formatMergeRequestId(this.id);
|
|
55
51
|
default:
|
|
56
52
|
return '';
|
|
57
53
|
}
|
|
58
54
|
},
|
|
55
|
+
title() {
|
|
56
|
+
return this.contextItem.metadata.title || '';
|
|
57
|
+
},
|
|
59
58
|
filePath() {
|
|
60
|
-
return this.contextItem.
|
|
59
|
+
return this.contextItem.category === CONTEXT_ITEM_CATEGORY_FILE ? this.contextItem.metadata.relativePath || '' : null;
|
|
61
60
|
},
|
|
62
61
|
filePathArray() {
|
|
63
62
|
var _this$filePath;
|
|
64
63
|
return (_this$filePath = this.filePath) === null || _this$filePath === void 0 ? void 0 : _this$filePath.split('/');
|
|
65
64
|
},
|
|
66
65
|
isEnabled() {
|
|
67
|
-
return this.contextItem.
|
|
66
|
+
return this.contextItem.metadata.enabled !== false;
|
|
68
67
|
},
|
|
69
68
|
disabledMessage() {
|
|
70
|
-
return Array.isArray(this.contextItem.disabledReasons) && this.contextItem.disabledReasons.length > 0 ? this.contextItem.disabledReasons.join(', ') : translate('DuoChatContextItemPopover.DisabledReason', 'This item is disabled');
|
|
69
|
+
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');
|
|
71
70
|
},
|
|
72
71
|
iconName() {
|
|
73
|
-
switch (this.contextItem.
|
|
72
|
+
switch (this.contextItem.category) {
|
|
74
73
|
case 'merge_request':
|
|
75
74
|
return 'merge-request';
|
|
76
75
|
case 'issue':
|
|
@@ -80,7 +79,7 @@ var script = {
|
|
|
80
79
|
}
|
|
81
80
|
},
|
|
82
81
|
itemTypeLabel() {
|
|
83
|
-
switch (this.contextItem.
|
|
82
|
+
switch (this.contextItem.category) {
|
|
84
83
|
case 'merge_request':
|
|
85
84
|
return translate('DuoChatContextItemPopover.MergeRequest', 'Merge request');
|
|
86
85
|
case 'issue':
|
|
@@ -99,7 +98,7 @@ var script = {
|
|
|
99
98
|
const __vue_script__ = script;
|
|
100
99
|
|
|
101
100
|
/* template */
|
|
102
|
-
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.
|
|
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.contextItem.metadata.title)+"\n ")]),_vm._v(" "),_c('div',{staticClass:"gl-font-normal gl-text-subtle"},[_vm._v(_vm._s(_vm.itemTypeLabel))])])]},proxy:true}])},[_vm._v(" "),_c('div',[(_vm.filePath !== null)?_c('div',{staticClass:"gl-flex gl-flex-wrap gl-items-center"},[_c('gl-icon',{staticClass:"gl-mr-1",attrs:{"name":"document","size":12,"variant":"subtle"}}),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.contextItem.metadata.project))]),_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._e(),_vm._v(" "),(_vm.filePath === null)?_c('div',{staticClass:"gl-flex gl-flex-wrap gl-items-center gl-leading-1 gl-text-subtle"},[_c('gl-icon',{staticClass:"gl-mr-1",attrs:{"name":_vm.iconName,"size":12,"variant":"subtle"}}),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.contextItem.metadata.project))]),(_vm.id !== null)?_c('span',[_vm._v(_vm._s(_vm.formattedId))]):_vm._e()],1):_vm._e(),_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)])};
|
|
103
102
|
var __vue_staticRenderFns__ = [];
|
|
104
103
|
|
|
105
104
|
/* style */
|
|
@@ -2,7 +2,7 @@ import uniqueId from 'lodash/uniqueId';
|
|
|
2
2
|
import GlIcon from '../../../../../../base/icon/icon';
|
|
3
3
|
import GlToken from '../../../../../../base/token/token';
|
|
4
4
|
import GlDuoChatContextItemPopover from '../duo_chat_context_item_popover/duo_chat_context_item_popover';
|
|
5
|
-
import {
|
|
5
|
+
import { CONTEXT_ITEM_CATEGORY_FILE, CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST } from '../constants';
|
|
6
6
|
import { contextItemsValidator } from '../utils';
|
|
7
7
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
8
8
|
|
|
@@ -74,13 +74,13 @@ var script = {
|
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
76
|
methods: {
|
|
77
|
-
getIconName(
|
|
77
|
+
getIconName(category) {
|
|
78
78
|
const iconMap = {
|
|
79
|
-
[
|
|
80
|
-
[
|
|
81
|
-
[
|
|
79
|
+
[CONTEXT_ITEM_CATEGORY_FILE]: 'document',
|
|
80
|
+
[CONTEXT_ITEM_CATEGORY_ISSUE]: 'issues',
|
|
81
|
+
[CONTEXT_ITEM_CATEGORY_MERGE_REQUEST]: 'merge-request'
|
|
82
82
|
};
|
|
83
|
-
return iconMap[
|
|
83
|
+
return iconMap[category] || 'document';
|
|
84
84
|
},
|
|
85
85
|
toggleCollapse() {
|
|
86
86
|
this.isCollapsed = !this.isCollapsed;
|
|
@@ -99,7 +99,7 @@ var script = {
|
|
|
99
99
|
const __vue_script__ = script;
|
|
100
100
|
|
|
101
101
|
/* 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.getIconName(item.
|
|
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.getIconName(item.category),"size":12}}),_vm._v("\n "+_vm._s(item.metadata.title)+"\n ")],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
103
|
var __vue_staticRenderFns__ = [];
|
|
104
104
|
|
|
105
105
|
/* style */
|
package/dist/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CONTEXT_ITEM_CATEGORY_FILE, CONTEXT_ITEM_CATEGORY_ISSUE, CONTEXT_ITEM_CATEGORY_MERGE_REQUEST } from './constants';
|
|
2
2
|
|
|
3
3
|
const MOCK_CATEGORIES = [{
|
|
4
4
|
label: 'Files',
|
|
5
|
-
value:
|
|
5
|
+
value: CONTEXT_ITEM_CATEGORY_FILE,
|
|
6
6
|
icon: 'document'
|
|
7
7
|
}, {
|
|
8
8
|
label: 'Issues',
|
|
9
|
-
value:
|
|
9
|
+
value: CONTEXT_ITEM_CATEGORY_ISSUE,
|
|
10
10
|
icon: 'issues'
|
|
11
11
|
}, {
|
|
12
12
|
label: 'Merge Requests',
|
|
13
|
-
value:
|
|
13
|
+
value: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
|
|
14
14
|
icon: 'merge-request'
|
|
15
15
|
}];
|
|
16
16
|
function getMockCategory(categoryValue) {
|
|
@@ -18,121 +18,103 @@ function getMockCategory(categoryValue) {
|
|
|
18
18
|
}
|
|
19
19
|
const MOCK_CONTEXT_ITEM_FILE = {
|
|
20
20
|
id: '123e4567-e89b-12d3-a456-426614174000',
|
|
21
|
-
|
|
21
|
+
category: CONTEXT_ITEM_CATEGORY_FILE,
|
|
22
22
|
metadata: {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
type: CONTEXT_ITEM_TYPE_PROJECT_FILE
|
|
23
|
+
enabled: true,
|
|
24
|
+
title: 'strawberry.ts',
|
|
25
|
+
project: 'example/garden',
|
|
26
|
+
relativePath: 'src/plants/strawberry.ts'
|
|
27
|
+
}
|
|
30
28
|
};
|
|
31
29
|
const MOCK_CONTEXT_ITEM_FILE_DISABLED = {
|
|
32
30
|
id: '323e4567-e89b-12d3-a456-426614174002',
|
|
33
|
-
|
|
31
|
+
category: CONTEXT_ITEM_CATEGORY_FILE,
|
|
34
32
|
metadata: {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
type: CONTEXT_ITEM_TYPE_PROJECT_FILE
|
|
33
|
+
enabled: false,
|
|
34
|
+
title: 'motorbike.cs',
|
|
35
|
+
project: 'example/vehicles',
|
|
36
|
+
relativePath: '/src/VehicleFoo/motorbike.cs'
|
|
37
|
+
}
|
|
42
38
|
};
|
|
43
39
|
const mockFiles = [MOCK_CONTEXT_ITEM_FILE, {
|
|
44
40
|
id: '223e4567-e89b-12d3-a456-426614174001',
|
|
45
|
-
|
|
41
|
+
category: CONTEXT_ITEM_CATEGORY_FILE,
|
|
46
42
|
metadata: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
type: CONTEXT_ITEM_TYPE_PROJECT_FILE
|
|
43
|
+
enabled: true,
|
|
44
|
+
title: 'potato.ts',
|
|
45
|
+
project: 'example/garden',
|
|
46
|
+
relativePath: '/src/plants/potato.ts'
|
|
47
|
+
}
|
|
54
48
|
}, MOCK_CONTEXT_ITEM_FILE_DISABLED];
|
|
55
49
|
const MOCK_CONTEXT_ITEM_ISSUE = {
|
|
56
50
|
id: '423e4567-e89b-12d3-a456-426614174003',
|
|
57
|
-
|
|
51
|
+
category: CONTEXT_ITEM_CATEGORY_ISSUE,
|
|
58
52
|
metadata: {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
type: CONTEXT_ITEM_TYPE_ISSUE
|
|
53
|
+
enabled: true,
|
|
54
|
+
title: 'Implement watering schedule',
|
|
55
|
+
project: 'example/garden',
|
|
56
|
+
iid: 1234
|
|
57
|
+
}
|
|
66
58
|
};
|
|
67
59
|
const MOCK_CONTEXT_ITEM_ISSUE_DISABLED = {
|
|
68
60
|
id: 'c463fb31-2a4c-4f8e-a609-97230ac48ae5',
|
|
69
|
-
|
|
61
|
+
category: CONTEXT_ITEM_CATEGORY_ISSUE,
|
|
70
62
|
metadata: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
78
|
-
type: CONTEXT_ITEM_TYPE_ISSUE
|
|
63
|
+
enabled: false,
|
|
64
|
+
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
65
|
+
title: `Fix vehicle colours and make them look real nice and colourful won't that be wonderful wow this issue title is really long I sure hope it's gonna wrap OK`,
|
|
66
|
+
project: 'example/vehicle',
|
|
67
|
+
iid: 91011
|
|
68
|
+
}
|
|
79
69
|
};
|
|
80
70
|
const mockIssues = [MOCK_CONTEXT_ITEM_ISSUE, {
|
|
81
71
|
id: '523e4567-e89b-12d3-a456-426614174004',
|
|
82
|
-
|
|
72
|
+
category: CONTEXT_ITEM_CATEGORY_ISSUE,
|
|
83
73
|
metadata: {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
type: CONTEXT_ITEM_TYPE_ISSUE
|
|
74
|
+
enabled: true,
|
|
75
|
+
title: 'Refactor plant growth rates',
|
|
76
|
+
project: 'example/garden',
|
|
77
|
+
iid: 5678
|
|
78
|
+
}
|
|
91
79
|
}, MOCK_CONTEXT_ITEM_ISSUE_DISABLED];
|
|
92
80
|
const MOCK_CONTEXT_ITEM_MERGE_REQUEST = {
|
|
93
81
|
id: '623e4567-e89b-12d3-a456-426614174005',
|
|
94
|
-
|
|
82
|
+
category: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
|
|
95
83
|
metadata: {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
type: CONTEXT_ITEM_TYPE_MERGE_REQUEST
|
|
84
|
+
enabled: true,
|
|
85
|
+
title: 'Improve database performance',
|
|
86
|
+
project: 'example/garden',
|
|
87
|
+
iid: 1122
|
|
88
|
+
}
|
|
103
89
|
};
|
|
104
90
|
const MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED = {
|
|
105
91
|
id: '4eb665fc-e5e1-49b0-9789-2a16964e461a',
|
|
106
|
-
|
|
92
|
+
category: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
|
|
107
93
|
metadata: {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
115
|
-
type: CONTEXT_ITEM_TYPE_MERGE_REQUEST
|
|
94
|
+
enabled: false,
|
|
95
|
+
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
96
|
+
title: 'Fix broken layout at small viewports',
|
|
97
|
+
project: 'example/vehicle',
|
|
98
|
+
iid: 5566
|
|
99
|
+
}
|
|
116
100
|
};
|
|
117
101
|
const mockMergeRequests = [MOCK_CONTEXT_ITEM_MERGE_REQUEST, {
|
|
118
102
|
id: '723e4567-e89b-12d3-a456-426614174006',
|
|
119
|
-
|
|
103
|
+
category: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
|
|
120
104
|
metadata: {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
128
|
-
type: CONTEXT_ITEM_TYPE_MERGE_REQUEST
|
|
105
|
+
enabled: false,
|
|
106
|
+
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
107
|
+
title: 'Add vehicle registration details',
|
|
108
|
+
project: 'example/vehicle',
|
|
109
|
+
iid: 3344
|
|
110
|
+
}
|
|
129
111
|
}, MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED];
|
|
130
112
|
const getMockContextItems = () => {
|
|
131
113
|
const allItems = [...mockFiles, ...mockIssues, ...mockMergeRequests];
|
|
132
114
|
|
|
133
115
|
// put disabled items in the back
|
|
134
|
-
const disabledItems = allItems.filter(item => !item.
|
|
135
|
-
const enabledItems = allItems.filter(item => item.
|
|
116
|
+
const disabledItems = allItems.filter(item => !item.metadata.enabled);
|
|
117
|
+
const enabledItems = allItems.filter(item => item.metadata.enabled);
|
|
136
118
|
return [...enabledItems, ...disabledItems];
|
|
137
119
|
};
|
|
138
120
|
|
|
@@ -8,7 +8,7 @@ function disabledReasonsValidator(disabledReasons) {
|
|
|
8
8
|
return disabledReasons === undefined || Array.isArray(disabledReasons) && disabledReasons.every(reason => typeof reason === 'string');
|
|
9
9
|
}
|
|
10
10
|
function contextItemValidator(item) {
|
|
11
|
-
return Boolean(item && item.id && item.
|
|
11
|
+
return Boolean(item && item.id && item.category && item.metadata && typeof item.metadata === 'object' && typeof item.metadata.enabled === 'boolean' && disabledReasonsValidator(item.metadata.disabledReasons));
|
|
12
12
|
}
|
|
13
13
|
function contextItemsValidator(items) {
|
|
14
14
|
return Array.isArray(items) && items.every(item => contextItemValidator(item));
|
|
@@ -39,13 +39,16 @@ var script = {
|
|
|
39
39
|
type: String,
|
|
40
40
|
required: false,
|
|
41
41
|
default: translate('GlDuoWorkflowPanel.collapseButtonTitle', 'Collapse')
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* Whether the panel is expanded or not
|
|
45
|
+
*/
|
|
46
|
+
expanded: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
required: false,
|
|
49
|
+
default: true
|
|
42
50
|
}
|
|
43
51
|
},
|
|
44
|
-
data() {
|
|
45
|
-
return {
|
|
46
|
-
expanded: true
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
52
|
computed: {
|
|
50
53
|
buttonIcon() {
|
|
51
54
|
return this.expanded ? 'chevron-up' : 'chevron-down';
|
|
@@ -53,11 +56,6 @@ var script = {
|
|
|
53
56
|
buttonTitle() {
|
|
54
57
|
return this.expanded ? this.collapsePanelButtonTitle : this.expandPanelButtonTitle;
|
|
55
58
|
}
|
|
56
|
-
},
|
|
57
|
-
methods: {
|
|
58
|
-
toggleExpanded() {
|
|
59
|
-
this.expanded = !this.expanded;
|
|
60
|
-
}
|
|
61
59
|
}
|
|
62
60
|
};
|
|
63
61
|
|
|
@@ -65,7 +63,7 @@ var script = {
|
|
|
65
63
|
const __vue_script__ = script;
|
|
66
64
|
|
|
67
65
|
/* template */
|
|
68
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('div',{staticClass:"gl-flex gl-flex-nowrap gl-items-center"},[(_vm.headerIcon)?_c('gl-icon',{staticClass:"gl-mr-3",attrs:{"name":_vm.headerIcon,"size":24}}):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-flex gl-flex-grow gl-items-baseline"},[_c('h2',{staticClass:"gl-mb-0"},[_vm._t("title")],2),_vm._v(" "),_c('small',{staticClass:"gl-ml-3"},[_vm._t("subtitle")],2)]),_vm._v(" "),_c('gl-button',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip"}],attrs:{"category":"tertiary","icon":_vm.buttonIcon,"title":_vm.buttonTitle,"aria-label":_vm.buttonTitle},on:{"click":_vm
|
|
66
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('div',{staticClass:"gl-flex gl-flex-nowrap gl-items-center"},[(_vm.headerIcon)?_c('gl-icon',{staticClass:"gl-mr-3",attrs:{"name":_vm.headerIcon,"size":24}}):_vm._e(),_vm._v(" "),_c('div',{staticClass:"gl-flex gl-flex-grow gl-items-baseline"},[_c('h2',{staticClass:"gl-mb-0"},[_vm._t("title")],2),_vm._v(" "),_c('small',{staticClass:"gl-ml-3"},[_vm._t("subtitle")],2)]),_vm._v(" "),_c('gl-button',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip"}],attrs:{"category":"tertiary","icon":_vm.buttonIcon,"title":_vm.buttonTitle,"aria-label":_vm.buttonTitle},on:{"click":function($event){return _vm.$emit('toggle-panel')}}})],1),_vm._v(" "),_c('gl-collapse',{attrs:{"visible":_vm.expanded}},[_c('div',{staticClass:"gl-ml-7 gl-mt-4 gl-flex-grow"},[_vm._t("content")],2)])],1)};
|
|
69
67
|
var __vue_staticRenderFns__ = [];
|
|
70
68
|
|
|
71
69
|
/* style */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "92.
|
|
3
|
+
"version": "92.4.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -113,8 +113,8 @@
|
|
|
113
113
|
"@cypress/grep": "^4.0.1",
|
|
114
114
|
"@gitlab/eslint-plugin": "20.2.1",
|
|
115
115
|
"@gitlab/fonts": "^1.3.0",
|
|
116
|
-
"@gitlab/stylelint-config": "6.2.
|
|
117
|
-
"@gitlab/svgs": "3.
|
|
116
|
+
"@gitlab/stylelint-config": "6.2.2",
|
|
117
|
+
"@gitlab/svgs": "3.115.0",
|
|
118
118
|
"@jest/test-sequencer": "^29.7.0",
|
|
119
119
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
120
120
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const
|
|
2
|
-
export const
|
|
3
|
-
export const
|
|
1
|
+
export const CONTEXT_ITEM_CATEGORY_ISSUE = 'issue';
|
|
2
|
+
export const CONTEXT_ITEM_CATEGORY_MERGE_REQUEST = 'merge_request';
|
|
3
|
+
export const CONTEXT_ITEM_CATEGORY_FILE = 'file';
|
|
@@ -77,7 +77,7 @@ export default {
|
|
|
77
77
|
return this.open && !this.selectedCategory;
|
|
78
78
|
},
|
|
79
79
|
allResultsAreDisabled() {
|
|
80
|
-
return this.results.every((result) => !result.
|
|
80
|
+
return this.results.every((result) => !result.metadata.enabled);
|
|
81
81
|
},
|
|
82
82
|
},
|
|
83
83
|
watch: {
|
|
@@ -90,7 +90,7 @@ export default {
|
|
|
90
90
|
this.debouncedSearch(query);
|
|
91
91
|
},
|
|
92
92
|
results(newResults) {
|
|
93
|
-
const firstEnabledIndex = newResults.findIndex((result) => result.
|
|
93
|
+
const firstEnabledIndex = newResults.findIndex((result) => result.metadata.enabled);
|
|
94
94
|
this.activeIndex = firstEnabledIndex >= 0 ? firstEnabledIndex : 0;
|
|
95
95
|
},
|
|
96
96
|
},
|
|
@@ -117,7 +117,7 @@ export default {
|
|
|
117
117
|
});
|
|
118
118
|
}, SEARCH_DEBOUNCE_MS),
|
|
119
119
|
selectItem(item) {
|
|
120
|
-
if (!item.
|
|
120
|
+
if (!item.metadata.enabled) {
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -214,7 +214,7 @@ export default {
|
|
|
214
214
|
// If we've looped through all items and found no enabled ones, keep the current index
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
|
-
} while (!this.results[newIndex].
|
|
217
|
+
} while (!this.results[newIndex].metadata.enabled);
|
|
218
218
|
|
|
219
219
|
this.activeIndex = newIndex;
|
|
220
220
|
},
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
formatMergeRequestId,
|
|
9
9
|
} from '../utils';
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
CONTEXT_ITEM_CATEGORY_ISSUE,
|
|
12
|
+
CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
|
|
13
|
+
CONTEXT_ITEM_CATEGORY_FILE,
|
|
14
14
|
} from '../constants';
|
|
15
15
|
|
|
16
16
|
export default {
|
|
@@ -30,16 +30,16 @@ export default {
|
|
|
30
30
|
},
|
|
31
31
|
computed: {
|
|
32
32
|
title() {
|
|
33
|
-
return this.contextItem.metadata?.
|
|
33
|
+
return this.contextItem.metadata?.title || '';
|
|
34
34
|
},
|
|
35
35
|
secondaryText() {
|
|
36
36
|
switch (this.category.value) {
|
|
37
|
-
case
|
|
38
|
-
return this.contextItem.metadata.
|
|
39
|
-
case
|
|
40
|
-
return formatIssueId(this.contextItem.metadata.
|
|
41
|
-
case
|
|
42
|
-
return formatMergeRequestId(this.contextItem.metadata.
|
|
37
|
+
case CONTEXT_ITEM_CATEGORY_FILE:
|
|
38
|
+
return this.contextItem.metadata.relativePath;
|
|
39
|
+
case CONTEXT_ITEM_CATEGORY_ISSUE:
|
|
40
|
+
return formatIssueId(this.contextItem.metadata.iid);
|
|
41
|
+
case CONTEXT_ITEM_CATEGORY_MERGE_REQUEST:
|
|
42
|
+
return formatMergeRequestId(this.contextItem.metadata.iid);
|
|
43
43
|
default:
|
|
44
44
|
return '';
|
|
45
45
|
}
|
|
@@ -87,12 +87,12 @@ export default {
|
|
|
87
87
|
this.$emit('keyup', e);
|
|
88
88
|
},
|
|
89
89
|
setActiveIndex(index) {
|
|
90
|
-
if (this.results[index]?.
|
|
90
|
+
if (this.results[index]?.metadata.enabled) {
|
|
91
91
|
this.$emit('active-index-change', index);
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
isActiveItem(contextItem, index) {
|
|
95
|
-
return index === this.activeIndex && contextItem.
|
|
95
|
+
return index === this.activeIndex && contextItem.metadata.enabled;
|
|
96
96
|
},
|
|
97
97
|
},
|
|
98
98
|
i18n: {
|
|
@@ -127,9 +127,10 @@ export default {
|
|
|
127
127
|
:key="contextItem.id"
|
|
128
128
|
:class="{
|
|
129
129
|
'active-command': isActiveItem(contextItem, index),
|
|
130
|
-
'gl-cursor-not-allowed [&>button]:focus-within:!gl-shadow-none':
|
|
130
|
+
'gl-cursor-not-allowed [&>button]:focus-within:!gl-shadow-none':
|
|
131
|
+
!contextItem.metadata.enabled,
|
|
131
132
|
}"
|
|
132
|
-
:tabindex="!contextItem.
|
|
133
|
+
:tabindex="!contextItem.metadata.enabled ? -1 : undefined"
|
|
133
134
|
class="duo-chat-context-search-result-item"
|
|
134
135
|
data-testid="search-result-item"
|
|
135
136
|
@click="selectItem(contextItem)"
|
|
@@ -138,7 +139,7 @@ export default {
|
|
|
138
139
|
<gl-duo-chat-context-item-menu-search-item
|
|
139
140
|
:context-item="contextItem"
|
|
140
141
|
:category="category"
|
|
141
|
-
:class="{ 'gl-text-secondary': !contextItem.
|
|
142
|
+
:class="{ 'gl-text-secondary': !contextItem.metadata.enabled }"
|
|
142
143
|
data-testid="search-result-item-details"
|
|
143
144
|
/>
|
|
144
145
|
</div>
|
|
@@ -3,9 +3,9 @@ import GlPopover from '../../../../../../base/popover/popover.vue';
|
|
|
3
3
|
import GlIcon from '../../../../../../base/icon/icon.vue';
|
|
4
4
|
import { translate } from '../../../../../../../utils/i18n';
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
CONTEXT_ITEM_CATEGORY_ISSUE,
|
|
7
|
+
CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
|
|
8
|
+
CONTEXT_ITEM_CATEGORY_FILE,
|
|
9
9
|
} from '../constants';
|
|
10
10
|
import { formatIssueId, formatMergeRequestId } from '../utils';
|
|
11
11
|
import GlAlert from '../../../../../../base/alert/alert.vue';
|
|
@@ -42,44 +42,44 @@ export default {
|
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
44
|
computed: {
|
|
45
|
-
itemInfo() {
|
|
46
|
-
return this.contextItem.metadata?.info || {};
|
|
47
|
-
},
|
|
48
45
|
id() {
|
|
49
46
|
const isIssuable =
|
|
50
|
-
this.contextItem.
|
|
51
|
-
this.contextItem.
|
|
52
|
-
return isIssuable ? this.
|
|
47
|
+
this.contextItem.category === CONTEXT_ITEM_CATEGORY_ISSUE ||
|
|
48
|
+
this.contextItem.category === CONTEXT_ITEM_CATEGORY_MERGE_REQUEST;
|
|
49
|
+
return isIssuable ? this.contextItem.metadata.iid : null;
|
|
53
50
|
},
|
|
54
51
|
formattedId() {
|
|
55
|
-
switch (this.contextItem.
|
|
56
|
-
case
|
|
52
|
+
switch (this.contextItem.category) {
|
|
53
|
+
case CONTEXT_ITEM_CATEGORY_ISSUE:
|
|
57
54
|
return formatIssueId(this.id);
|
|
58
|
-
case
|
|
55
|
+
case CONTEXT_ITEM_CATEGORY_MERGE_REQUEST:
|
|
59
56
|
return formatMergeRequestId(this.id);
|
|
60
57
|
default:
|
|
61
58
|
return '';
|
|
62
59
|
}
|
|
63
60
|
},
|
|
61
|
+
title() {
|
|
62
|
+
return this.contextItem.metadata.title || '';
|
|
63
|
+
},
|
|
64
64
|
filePath() {
|
|
65
|
-
return this.contextItem.
|
|
66
|
-
? this.
|
|
65
|
+
return this.contextItem.category === CONTEXT_ITEM_CATEGORY_FILE
|
|
66
|
+
? this.contextItem.metadata.relativePath || ''
|
|
67
67
|
: null;
|
|
68
68
|
},
|
|
69
69
|
filePathArray() {
|
|
70
70
|
return this.filePath?.split('/');
|
|
71
71
|
},
|
|
72
72
|
isEnabled() {
|
|
73
|
-
return this.contextItem.
|
|
73
|
+
return this.contextItem.metadata.enabled !== false;
|
|
74
74
|
},
|
|
75
75
|
disabledMessage() {
|
|
76
|
-
return Array.isArray(this.contextItem.disabledReasons) &&
|
|
77
|
-
this.contextItem.disabledReasons.length > 0
|
|
78
|
-
? this.contextItem.disabledReasons.join(', ')
|
|
76
|
+
return Array.isArray(this.contextItem.metadata.disabledReasons) &&
|
|
77
|
+
this.contextItem.metadata.disabledReasons.length > 0
|
|
78
|
+
? this.contextItem.metadata.disabledReasons.join(', ')
|
|
79
79
|
: translate('DuoChatContextItemPopover.DisabledReason', 'This item is disabled');
|
|
80
80
|
},
|
|
81
81
|
iconName() {
|
|
82
|
-
switch (this.contextItem.
|
|
82
|
+
switch (this.contextItem.category) {
|
|
83
83
|
case 'merge_request':
|
|
84
84
|
return 'merge-request';
|
|
85
85
|
case 'issue':
|
|
@@ -89,7 +89,7 @@ export default {
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
itemTypeLabel() {
|
|
92
|
-
switch (this.contextItem.
|
|
92
|
+
switch (this.contextItem.category) {
|
|
93
93
|
case 'merge_request':
|
|
94
94
|
return translate('DuoChatContextItemPopover.MergeRequest', 'Merge request');
|
|
95
95
|
case 'issue':
|
|
@@ -109,7 +109,7 @@ export default {
|
|
|
109
109
|
:target="target"
|
|
110
110
|
triggers="hover focus"
|
|
111
111
|
:placement="placement"
|
|
112
|
-
:title="
|
|
112
|
+
:title="title"
|
|
113
113
|
custom-class="gl-duo-chat-item-popover"
|
|
114
114
|
>
|
|
115
115
|
<template #title>
|
|
@@ -118,7 +118,7 @@ export default {
|
|
|
118
118
|
class="gl-heading-3 gl-mb-1 gl-mt-2 gl-leading-1"
|
|
119
119
|
data-testid="chat-context-popover-title"
|
|
120
120
|
>
|
|
121
|
-
{{ contextItem.metadata.
|
|
121
|
+
{{ contextItem.metadata.title }}
|
|
122
122
|
</div>
|
|
123
123
|
<div class="gl-font-normal gl-text-subtle">{{ itemTypeLabel }}</div>
|
|
124
124
|
</div>
|
|
@@ -126,7 +126,7 @@ export default {
|
|
|
126
126
|
<div>
|
|
127
127
|
<div v-if="filePath !== null" class="gl-flex gl-flex-wrap gl-items-center">
|
|
128
128
|
<gl-icon name="document" :size="12" variant="subtle" class="gl-mr-1" />
|
|
129
|
-
<span>{{
|
|
129
|
+
<span>{{ contextItem.metadata.project }}</span
|
|
130
130
|
><span v-for="(pathPart, index) in filePathArray" :key="pathPart" class="gl-break-all"
|
|
131
131
|
>{{ pathPart }}{{ index + 1 < filePathArray.length ? '/' : '' }}</span
|
|
132
132
|
>
|
|
@@ -138,7 +138,7 @@ export default {
|
|
|
138
138
|
>
|
|
139
139
|
<gl-icon :name="iconName" :size="12" variant="subtle" class="gl-mr-1" />
|
|
140
140
|
|
|
141
|
-
<span>{{
|
|
141
|
+
<span>{{ contextItem.metadata.project }}</span
|
|
142
142
|
><span v-if="id !== null">{{ formattedId }}</span>
|
|
143
143
|
</div>
|
|
144
144
|
<gl-alert
|
|
@@ -4,9 +4,9 @@ import GlIcon from '../../../../../../base/icon/icon.vue';
|
|
|
4
4
|
import GlToken from '../../../../../../base/token/token.vue';
|
|
5
5
|
import GlDuoChatContextItemPopover from '../duo_chat_context_item_popover/duo_chat_context_item_popover.vue';
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
CONTEXT_ITEM_CATEGORY_ISSUE,
|
|
8
|
+
CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
|
|
9
|
+
CONTEXT_ITEM_CATEGORY_FILE,
|
|
10
10
|
} from '../constants';
|
|
11
11
|
import { contextItemsValidator } from '../utils';
|
|
12
12
|
|
|
@@ -78,13 +78,13 @@ export default {
|
|
|
78
78
|
},
|
|
79
79
|
},
|
|
80
80
|
methods: {
|
|
81
|
-
getIconName(
|
|
81
|
+
getIconName(category) {
|
|
82
82
|
const iconMap = {
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
83
|
+
[CONTEXT_ITEM_CATEGORY_FILE]: 'document',
|
|
84
|
+
[CONTEXT_ITEM_CATEGORY_ISSUE]: 'issues',
|
|
85
|
+
[CONTEXT_ITEM_CATEGORY_MERGE_REQUEST]: 'merge-request',
|
|
86
86
|
};
|
|
87
|
-
return iconMap[
|
|
87
|
+
return iconMap[category] || 'document';
|
|
88
88
|
},
|
|
89
89
|
toggleCollapse() {
|
|
90
90
|
this.isCollapsed = !this.isCollapsed;
|
|
@@ -127,8 +127,8 @@ export default {
|
|
|
127
127
|
@close="onRemoveItem(item)"
|
|
128
128
|
>
|
|
129
129
|
<div :id="`context-item-${item.id}-${selectionsId}`" class="gl-flex gl-items-center">
|
|
130
|
-
<gl-icon :name="getIconName(item.
|
|
131
|
-
{{ item.metadata.
|
|
130
|
+
<gl-icon :name="getIconName(item.category)" :size="12" class="gl-mr-1" />
|
|
131
|
+
{{ item.metadata.title }}
|
|
132
132
|
</div>
|
|
133
133
|
<gl-duo-chat-context-item-popover
|
|
134
134
|
:context-item="item"
|
package/src/components/experimental/duo/chat/components/duo_chat_context/mock_context_data.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
CONTEXT_ITEM_CATEGORY_ISSUE,
|
|
3
|
+
CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
|
|
4
|
+
CONTEXT_ITEM_CATEGORY_FILE,
|
|
5
5
|
} from './constants';
|
|
6
6
|
|
|
7
7
|
export const MOCK_CATEGORIES = [
|
|
8
|
-
{ label: 'Files', value:
|
|
9
|
-
{ label: 'Issues', value:
|
|
10
|
-
{ label: 'Merge Requests', value:
|
|
8
|
+
{ label: 'Files', value: CONTEXT_ITEM_CATEGORY_FILE, icon: 'document' },
|
|
9
|
+
{ label: 'Issues', value: CONTEXT_ITEM_CATEGORY_ISSUE, icon: 'issues' },
|
|
10
|
+
{ label: 'Merge Requests', value: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST, icon: 'merge-request' },
|
|
11
11
|
];
|
|
12
12
|
|
|
13
13
|
export function getMockCategory(categoryValue) {
|
|
@@ -16,129 +16,112 @@ export function getMockCategory(categoryValue) {
|
|
|
16
16
|
|
|
17
17
|
export const MOCK_CONTEXT_ITEM_FILE = {
|
|
18
18
|
id: '123e4567-e89b-12d3-a456-426614174000',
|
|
19
|
-
|
|
19
|
+
category: CONTEXT_ITEM_CATEGORY_FILE,
|
|
20
20
|
metadata: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
21
|
+
enabled: true,
|
|
22
|
+
title: 'strawberry.ts',
|
|
23
|
+
project: 'example/garden',
|
|
24
|
+
relativePath: 'src/plants/strawberry.ts',
|
|
26
25
|
},
|
|
27
|
-
type: CONTEXT_ITEM_TYPE_PROJECT_FILE,
|
|
28
26
|
};
|
|
29
27
|
|
|
30
28
|
export const MOCK_CONTEXT_ITEM_FILE_DISABLED = {
|
|
31
29
|
id: '323e4567-e89b-12d3-a456-426614174002',
|
|
32
|
-
|
|
30
|
+
category: CONTEXT_ITEM_CATEGORY_FILE,
|
|
33
31
|
metadata: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
32
|
+
enabled: false,
|
|
33
|
+
title: 'motorbike.cs',
|
|
34
|
+
project: 'example/vehicles',
|
|
35
|
+
relativePath: '/src/VehicleFoo/motorbike.cs',
|
|
39
36
|
},
|
|
40
|
-
type: CONTEXT_ITEM_TYPE_PROJECT_FILE,
|
|
41
37
|
};
|
|
42
38
|
const mockFiles = [
|
|
43
39
|
MOCK_CONTEXT_ITEM_FILE,
|
|
44
40
|
{
|
|
45
41
|
id: '223e4567-e89b-12d3-a456-426614174001',
|
|
46
|
-
|
|
42
|
+
category: CONTEXT_ITEM_CATEGORY_FILE,
|
|
47
43
|
metadata: {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
},
|
|
44
|
+
enabled: true,
|
|
45
|
+
title: 'potato.ts',
|
|
46
|
+
project: 'example/garden',
|
|
47
|
+
relativePath: '/src/plants/potato.ts',
|
|
53
48
|
},
|
|
54
|
-
type: CONTEXT_ITEM_TYPE_PROJECT_FILE,
|
|
55
49
|
},
|
|
56
50
|
MOCK_CONTEXT_ITEM_FILE_DISABLED,
|
|
57
51
|
];
|
|
58
52
|
|
|
59
53
|
export const MOCK_CONTEXT_ITEM_ISSUE = {
|
|
60
54
|
id: '423e4567-e89b-12d3-a456-426614174003',
|
|
61
|
-
|
|
55
|
+
category: CONTEXT_ITEM_CATEGORY_ISSUE,
|
|
62
56
|
metadata: {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
},
|
|
57
|
+
enabled: true,
|
|
58
|
+
title: 'Implement watering schedule',
|
|
59
|
+
project: 'example/garden',
|
|
60
|
+
iid: 1234,
|
|
68
61
|
},
|
|
69
|
-
type: CONTEXT_ITEM_TYPE_ISSUE,
|
|
70
62
|
};
|
|
71
63
|
export const MOCK_CONTEXT_ITEM_ISSUE_DISABLED = {
|
|
72
64
|
id: 'c463fb31-2a4c-4f8e-a609-97230ac48ae5',
|
|
73
|
-
|
|
65
|
+
category: CONTEXT_ITEM_CATEGORY_ISSUE,
|
|
66
|
+
|
|
74
67
|
metadata: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
enabled: false,
|
|
69
|
+
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
70
|
+
title: `Fix vehicle colours and make them look real nice and colourful won't that be wonderful wow this issue title is really long I sure hope it's gonna wrap OK`,
|
|
71
|
+
project: 'example/vehicle',
|
|
72
|
+
iid: 91011,
|
|
80
73
|
},
|
|
81
|
-
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
82
|
-
type: CONTEXT_ITEM_TYPE_ISSUE,
|
|
83
74
|
};
|
|
84
75
|
|
|
85
76
|
const mockIssues = [
|
|
86
77
|
MOCK_CONTEXT_ITEM_ISSUE,
|
|
87
78
|
{
|
|
88
79
|
id: '523e4567-e89b-12d3-a456-426614174004',
|
|
89
|
-
|
|
80
|
+
category: CONTEXT_ITEM_CATEGORY_ISSUE,
|
|
90
81
|
metadata: {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
},
|
|
82
|
+
enabled: true,
|
|
83
|
+
title: 'Refactor plant growth rates',
|
|
84
|
+
project: 'example/garden',
|
|
85
|
+
iid: 5678,
|
|
96
86
|
},
|
|
97
|
-
type: CONTEXT_ITEM_TYPE_ISSUE,
|
|
98
87
|
},
|
|
99
88
|
MOCK_CONTEXT_ITEM_ISSUE_DISABLED,
|
|
100
89
|
];
|
|
101
90
|
|
|
102
91
|
export const MOCK_CONTEXT_ITEM_MERGE_REQUEST = {
|
|
103
92
|
id: '623e4567-e89b-12d3-a456-426614174005',
|
|
104
|
-
|
|
93
|
+
category: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
|
|
105
94
|
metadata: {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
},
|
|
95
|
+
enabled: true,
|
|
96
|
+
title: 'Improve database performance',
|
|
97
|
+
project: 'example/garden',
|
|
98
|
+
iid: 1122,
|
|
111
99
|
},
|
|
112
|
-
type: CONTEXT_ITEM_TYPE_MERGE_REQUEST,
|
|
113
100
|
};
|
|
114
101
|
export const MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED = {
|
|
115
102
|
id: '4eb665fc-e5e1-49b0-9789-2a16964e461a',
|
|
116
|
-
|
|
103
|
+
category: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
|
|
117
104
|
metadata: {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
105
|
+
enabled: false,
|
|
106
|
+
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
107
|
+
title: 'Fix broken layout at small viewports',
|
|
108
|
+
project: 'example/vehicle',
|
|
109
|
+
iid: 5566,
|
|
123
110
|
},
|
|
124
|
-
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
125
|
-
type: CONTEXT_ITEM_TYPE_MERGE_REQUEST,
|
|
126
111
|
};
|
|
127
112
|
|
|
128
113
|
const mockMergeRequests = [
|
|
129
114
|
MOCK_CONTEXT_ITEM_MERGE_REQUEST,
|
|
130
115
|
{
|
|
131
116
|
id: '723e4567-e89b-12d3-a456-426614174006',
|
|
132
|
-
|
|
117
|
+
category: CONTEXT_ITEM_CATEGORY_MERGE_REQUEST,
|
|
133
118
|
metadata: {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
119
|
+
enabled: false,
|
|
120
|
+
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
121
|
+
title: 'Add vehicle registration details',
|
|
122
|
+
project: 'example/vehicle',
|
|
123
|
+
iid: 3344,
|
|
139
124
|
},
|
|
140
|
-
disabledReasons: ['This foo is not available to bar', 'Lorem something something wow?'],
|
|
141
|
-
type: CONTEXT_ITEM_TYPE_MERGE_REQUEST,
|
|
142
125
|
},
|
|
143
126
|
MOCK_CONTEXT_ITEM_MERGE_REQUEST_DISABLED,
|
|
144
127
|
];
|
|
@@ -147,7 +130,7 @@ export const getMockContextItems = () => {
|
|
|
147
130
|
const allItems = [...mockFiles, ...mockIssues, ...mockMergeRequests];
|
|
148
131
|
|
|
149
132
|
// put disabled items in the back
|
|
150
|
-
const disabledItems = allItems.filter((item) => !item.
|
|
151
|
-
const enabledItems = allItems.filter((item) => item.
|
|
133
|
+
const disabledItems = allItems.filter((item) => !item.metadata.enabled);
|
|
134
|
+
const enabledItems = allItems.filter((item) => item.metadata.enabled);
|
|
152
135
|
return [...enabledItems, ...disabledItems];
|
|
153
136
|
};
|
|
@@ -18,9 +18,11 @@ export function contextItemValidator(item) {
|
|
|
18
18
|
return Boolean(
|
|
19
19
|
item &&
|
|
20
20
|
item.id &&
|
|
21
|
-
item.
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
item.category &&
|
|
22
|
+
item.metadata &&
|
|
23
|
+
typeof item.metadata === 'object' &&
|
|
24
|
+
typeof item.metadata.enabled === 'boolean' &&
|
|
25
|
+
disabledReasonsValidator(item.metadata.disabledReasons)
|
|
24
26
|
);
|
|
25
27
|
}
|
|
26
28
|
|
package/src/components/experimental/duo/workflow/components/duo_workflow_panel/duo_workflow_panel.md
CHANGED
|
@@ -5,13 +5,17 @@ and WebUI.
|
|
|
5
5
|
|
|
6
6
|
To use this component, import it and fill out the available slots:
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
- `title`: the main title for the panel
|
|
9
|
+
- `subtitle`: the small text adjacent to the title
|
|
10
|
+
- `content`: the content of the panel, hidden away when the collapse is toggled
|
|
11
11
|
|
|
12
12
|
Also provide an icon via the `headerIcon` prop. This icon is displayed adjacent
|
|
13
13
|
to the title.
|
|
14
14
|
|
|
15
|
+
You can pass `expanded` prop set to `false` if you need a section to be
|
|
16
|
+
collapsed by default. You can also listen to `toggle-panel` event to know
|
|
17
|
+
when the expanded state changed.
|
|
18
|
+
|
|
15
19
|
Translations for the title of the single button can be provided either via the
|
|
16
20
|
props `expandButtonTitle` and `collapseTitleButton` or via the translation
|
|
17
21
|
configuration:
|
|
@@ -34,9 +34,14 @@ export default {
|
|
|
34
34
|
required: false,
|
|
35
35
|
default: translate('GlDuoWorkflowPanel.collapseButtonTitle', 'Collapse'),
|
|
36
36
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Whether the panel is expanded or not
|
|
39
|
+
*/
|
|
40
|
+
expanded: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
required: false,
|
|
43
|
+
default: true,
|
|
44
|
+
},
|
|
40
45
|
},
|
|
41
46
|
computed: {
|
|
42
47
|
buttonIcon() {
|
|
@@ -46,11 +51,6 @@ export default {
|
|
|
46
51
|
return this.expanded ? this.collapsePanelButtonTitle : this.expandPanelButtonTitle;
|
|
47
52
|
},
|
|
48
53
|
},
|
|
49
|
-
methods: {
|
|
50
|
-
toggleExpanded() {
|
|
51
|
-
this.expanded = !this.expanded;
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
54
|
};
|
|
55
55
|
</script>
|
|
56
56
|
<template>
|
|
@@ -74,7 +74,7 @@ export default {
|
|
|
74
74
|
:icon="buttonIcon"
|
|
75
75
|
:title="buttonTitle"
|
|
76
76
|
:aria-label="buttonTitle"
|
|
77
|
-
@click="
|
|
77
|
+
@click="$emit('toggle-panel')"
|
|
78
78
|
/>
|
|
79
79
|
</div>
|
|
80
80
|
<gl-collapse :visible="expanded">
|