@gitlab/duo-ui 8.2.1 → 8.3.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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [8.3.0](https://gitlab.com/gitlab-org/duo-ui/compare/v8.2.1...v8.3.0) (2025-02-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * add Duo Chat header component ([b120863](https://gitlab.com/gitlab-org/duo-ui/commit/b12086344411a02894ddca77c3be9c7763443ce6))
7
+
1
8
  ## [8.2.1](https://gitlab.com/gitlab-org/duo-ui/compare/v8.2.0...v8.2.1) (2025-02-21)
2
9
 
3
10
 
@@ -0,0 +1,6 @@
1
+ const VIEW_TYPES = {
2
+ CHAT: 'chat',
3
+ LIST: 'list'
4
+ };
5
+
6
+ export { VIEW_TYPES };
@@ -0,0 +1,105 @@
1
+ import { GlButton, GlAlert, GlExperimentBadge, GlSafeHtmlDirective } from '@gitlab/ui';
2
+ import { translate } from '../../../../utils/i18n';
3
+ import { VIEW_TYPES } from './constants';
4
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
5
+
6
+ const i18n = {
7
+ CHAT_BACK_LABEL: translate('DuoChat.chatBackLabel', 'Back to History'),
8
+ CHAT_CLOSE_LABEL: translate('DuoChat.closeChatHeaderLabel', 'Close Chat'),
9
+ CHAT_NEW_LABEL: translate('DuoChat.chatNewLabel', 'New Chat'),
10
+ CHAT_TITLE: translate('DuoChat.chatTitle', 'GitLab Duo Chat')
11
+ };
12
+ var script = {
13
+ name: 'DuoChatHeader',
14
+ components: {
15
+ GlButton,
16
+ GlAlert,
17
+ GlExperimentBadge
18
+ },
19
+ directives: {
20
+ SafeHtml: GlSafeHtmlDirective
21
+ },
22
+ props: {
23
+ title: {
24
+ type: String,
25
+ required: false,
26
+ default: i18n.CHAT_TITLE
27
+ },
28
+ error: {
29
+ type: String,
30
+ required: false,
31
+ default: ''
32
+ },
33
+ isMultithreaded: {
34
+ type: Boolean,
35
+ required: false,
36
+ default: false
37
+ },
38
+ shouldRenderResizable: {
39
+ type: Boolean,
40
+ required: false,
41
+ default: false
42
+ },
43
+ activeThreadId: {
44
+ type: String,
45
+ required: false,
46
+ default: null
47
+ },
48
+ badgeType: {
49
+ type: String,
50
+ required: false,
51
+ default: null
52
+ },
53
+ currentView: {
54
+ type: String,
55
+ required: true
56
+ }
57
+ },
58
+ computed: {
59
+ VIEW_TYPES() {
60
+ return VIEW_TYPES;
61
+ }
62
+ },
63
+ i18n
64
+ };
65
+
66
+ /* script */
67
+ const __vue_script__ = script;
68
+
69
+ /* template */
70
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('header',{staticClass:"duo-chat-drawer-header duo-chat-drawer-header-sticky gl-border-0 gl-bg-default !gl-p-0",class:{
71
+ 'gl-z-200': !_vm.shouldRenderResizable,
72
+ },attrs:{"data-testid":"chat-header"}},[_c('div',{staticClass:"drawer-title gl-flex gl-items-center gl-justify-start gl-p-5"},[(_vm.isMultithreaded && _vm.currentView === _vm.VIEW_TYPES.CHAT)?_c('gl-button',{staticClass:"gl-mr-3",attrs:{"data-testid":"chat-back-button","category":"primary","size":"medium","icon":"go-back","aria-label":_vm.$options.i18n.CHAT_BACK_LABEL},on:{"click":function($event){return _vm.$emit('go-back')}}}):_vm._e(),_vm._v(" "),(_vm.isMultithreaded && (_vm.activeThreadId || _vm.currentView === _vm.VIEW_TYPES.LIST))?_c('gl-button',{staticClass:"gl-mr-3",attrs:{"data-testid":"chat-new-button","category":"primary","size":"medium","icon":"duo-chat-new","aria-label":_vm.$options.i18n.CHAT_NEW_LABEL},on:{"click":function($event){return _vm.$emit('new-chat')}}}):_vm._e(),_vm._v(" "),_c('h3',{staticClass:"gl-my-0 gl-text-size-h2"},[_vm._v(_vm._s(_vm.title))]),_vm._v(" "),(_vm.badgeType)?_c('gl-experiment-badge',{attrs:{"type":_vm.badgeType,"container-id":"chat-component"}}):_vm._e(),_vm._v(" "),_c('gl-button',{staticClass:"gl-ml-auto",attrs:{"category":"tertiary","variant":"default","icon":"close","size":"small","data-testid":"chat-close-button","aria-label":_vm.$options.i18n.CHAT_CLOSE_LABEL},on:{"click":function($event){return _vm.$emit('close')}}})],1),_vm._v(" "),_vm._t("subheader"),_vm._v(" "),(_vm.error)?_c('gl-alert',{key:"error",staticClass:"!gl-pl-9",attrs:{"dismissible":false,"variant":"danger","role":"alert","data-testid":"chat-error"}},[_c('span',{directives:[{name:"safe-html",rawName:"v-safe-html",value:(_vm.error),expression:"error"}]})]):_vm._e()],2)};
73
+ var __vue_staticRenderFns__ = [];
74
+
75
+ /* style */
76
+ const __vue_inject_styles__ = undefined;
77
+ /* scoped */
78
+ const __vue_scope_id__ = undefined;
79
+ /* module identifier */
80
+ const __vue_module_identifier__ = undefined;
81
+ /* functional template */
82
+ const __vue_is_functional_template__ = false;
83
+ /* style inject */
84
+
85
+ /* style inject SSR */
86
+
87
+ /* style inject shadow dom */
88
+
89
+
90
+
91
+ const __vue_component__ = __vue_normalize__(
92
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
93
+ __vue_inject_styles__,
94
+ __vue_script__,
95
+ __vue_scope_id__,
96
+ __vue_is_functional_template__,
97
+ __vue_module_identifier__,
98
+ false,
99
+ undefined,
100
+ undefined,
101
+ undefined
102
+ );
103
+
104
+ export default __vue_component__;
105
+ export { i18n };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/duo-ui",
3
- "version": "8.2.1",
3
+ "version": "8.3.0",
4
4
  "description": "Duo UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -104,7 +104,7 @@
104
104
  "@gitlab/eslint-plugin": "20.3.0",
105
105
  "@gitlab/fonts": "^1.3.0",
106
106
  "@gitlab/stylelint-config": "6.2.2",
107
- "@gitlab/svgs": "3.117.0",
107
+ "@gitlab/svgs": "^3.0.0",
108
108
  "@gitlab/ui": "latest",
109
109
  "@jest/test-sequencer": "^29.7.0",
110
110
  "@rollup/plugin-commonjs": "^11.1.0",
@@ -0,0 +1,4 @@
1
+ export const VIEW_TYPES = {
2
+ CHAT: 'chat',
3
+ LIST: 'list',
4
+ };
@@ -0,0 +1,127 @@
1
+ <script>
2
+ import { GlButton, GlAlert, GlExperimentBadge, GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui';
3
+ import { translate } from '../../../../utils/i18n';
4
+ import { VIEW_TYPES } from './constants';
5
+
6
+ export const i18n = {
7
+ CHAT_BACK_LABEL: translate('DuoChat.chatBackLabel', 'Back to History'),
8
+ CHAT_CLOSE_LABEL: translate('DuoChat.closeChatHeaderLabel', 'Close Chat'),
9
+ CHAT_NEW_LABEL: translate('DuoChat.chatNewLabel', 'New Chat'),
10
+ CHAT_TITLE: translate('DuoChat.chatTitle', 'GitLab Duo Chat'),
11
+ };
12
+
13
+ export default {
14
+ name: 'DuoChatHeader',
15
+
16
+ components: {
17
+ GlButton,
18
+ GlAlert,
19
+ GlExperimentBadge,
20
+ },
21
+ directives: {
22
+ SafeHtml,
23
+ },
24
+ props: {
25
+ title: {
26
+ type: String,
27
+ required: false,
28
+ default: i18n.CHAT_TITLE,
29
+ },
30
+ error: {
31
+ type: String,
32
+ required: false,
33
+ default: '',
34
+ },
35
+ isMultithreaded: {
36
+ type: Boolean,
37
+ required: false,
38
+ default: false,
39
+ },
40
+ shouldRenderResizable: {
41
+ type: Boolean,
42
+ required: false,
43
+ default: false,
44
+ },
45
+ activeThreadId: {
46
+ type: String,
47
+ required: false,
48
+ default: null,
49
+ },
50
+ badgeType: {
51
+ type: String,
52
+ required: false,
53
+ default: null,
54
+ },
55
+ currentView: {
56
+ type: String,
57
+ required: true,
58
+ },
59
+ },
60
+ computed: {
61
+ VIEW_TYPES() {
62
+ return VIEW_TYPES;
63
+ },
64
+ },
65
+ i18n,
66
+ };
67
+ </script>
68
+
69
+ <template>
70
+ <header
71
+ data-testid="chat-header"
72
+ :class="{
73
+ 'gl-z-200': !shouldRenderResizable,
74
+ }"
75
+ class="duo-chat-drawer-header duo-chat-drawer-header-sticky gl-border-0 gl-bg-default !gl-p-0"
76
+ >
77
+ <div class="drawer-title gl-flex gl-items-center gl-justify-start gl-p-5">
78
+ <gl-button
79
+ v-if="isMultithreaded && currentView === VIEW_TYPES.CHAT"
80
+ data-testid="chat-back-button"
81
+ category="primary"
82
+ size="medium"
83
+ icon="go-back"
84
+ class="gl-mr-3"
85
+ :aria-label="$options.i18n.CHAT_BACK_LABEL"
86
+ @click="$emit('go-back')"
87
+ />
88
+ <gl-button
89
+ v-if="isMultithreaded && (activeThreadId || currentView === VIEW_TYPES.LIST)"
90
+ data-testid="chat-new-button"
91
+ category="primary"
92
+ size="medium"
93
+ icon="duo-chat-new"
94
+ class="gl-mr-3"
95
+ :aria-label="$options.i18n.CHAT_NEW_LABEL"
96
+ @click="$emit('new-chat')"
97
+ />
98
+
99
+ <h3 class="gl-my-0 gl-text-size-h2">{{ title }}</h3>
100
+ <gl-experiment-badge v-if="badgeType" :type="badgeType" container-id="chat-component" />
101
+ <gl-button
102
+ category="tertiary"
103
+ variant="default"
104
+ icon="close"
105
+ size="small"
106
+ class="gl-ml-auto"
107
+ data-testid="chat-close-button"
108
+ :aria-label="$options.i18n.CHAT_CLOSE_LABEL"
109
+ @click="$emit('close')"
110
+ />
111
+ </div>
112
+
113
+ <slot name="subheader"></slot>
114
+
115
+ <gl-alert
116
+ v-if="error"
117
+ key="error"
118
+ :dismissible="false"
119
+ variant="danger"
120
+ class="!gl-pl-9"
121
+ role="alert"
122
+ data-testid="chat-error"
123
+ >
124
+ <span v-safe-html="error"></span>
125
+ </gl-alert>
126
+ </header>
127
+ </template>
package/translations.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable import/no-default-export */
2
2
  export default {
3
+ 'DuoChat.chatBackLabel': 'Back to History',
3
4
  'DuoChat.chatCancelLabel': 'Cancel',
4
5
  'DuoChat.chatCloseLabel': 'Close the Code Explanation',
5
6
  'DuoChat.chatDefaultPredefinedPromptsChangePassword': 'How do I change my password in GitLab?',
@@ -9,9 +10,12 @@ export default {
9
10
  'DuoChat.chatDefaultTitle': 'GitLab Duo Chat',
10
11
  'DuoChat.chatEmptyStateTitle':
11
12
  '👋 I am GitLab Duo Chat, your personal AI-powered assistant. How can I help you today?',
13
+ 'DuoChat.chatNewLabel': 'New Chat',
12
14
  'DuoChat.chatPromptPlaceholderDefault': 'GitLab Duo Chat',
13
15
  'DuoChat.chatPromptPlaceholderWithCommands': 'Type /help to learn more',
14
16
  'DuoChat.chatSubmitLabel': 'Send chat message.',
17
+ 'DuoChat.chatTitle': 'GitLab Duo Chat',
18
+ 'DuoChat.closeChatHeaderLabel': 'Close Chat',
15
19
  'DuoChatContextItemDetailsModal.contentErrorMessage': 'Item content could not be displayed.',
16
20
  'DuoChatContextItemDetailsModal.title': 'Preview',
17
21
  'DuoChatContextItemMenu.emptyStateMessage': 'No results found',