@gitlab/ui 77.7.0 → 78.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # [78.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v77.7.0...v78.0.0) (2024-03-05)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlDuoChat:** refactor hasFeedback to rely on props ([97d1664](https://gitlab.com/gitlab-org/gitlab-ui/commit/97d166494f7af33f36779863fedc8084ea3254fe))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * **GlDuoChat:** This commit refactors the
12
+ GlDuoChat Feedback indicator on every message
13
+ to use the information coming in from props
14
+ not from localState.
15
+
1
16
  # [77.7.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v77.6.0...v77.7.0) (2024-03-04)
2
17
 
3
18
 
@@ -86,6 +86,10 @@ var script = {
86
86
  var _this$message$extras;
87
87
  return (_this$message$extras = this.message.extras) === null || _this$message$extras === void 0 ? void 0 : _this$message$extras.sources;
88
88
  },
89
+ hasFeedback() {
90
+ var _this$message$extras2;
91
+ return (_this$message$extras2 = this.message.extras) === null || _this$message$extras2 === void 0 ? void 0 : _this$message$extras2.hasFeedback;
92
+ },
89
93
  messageContent() {
90
94
  if (this.message.errors.length > 0) return this.renderMarkdown(this.message.errors.join('; '));
91
95
  if (this.message.contentHtml) {
@@ -115,7 +119,8 @@ var script = {
115
119
  this.$emit('track-feedback', {
116
120
  ...e,
117
121
  didWhat: this.didWhat,
118
- improveWhat: this.improveWhat
122
+ improveWhat: this.improveWhat,
123
+ message: this.message
119
124
  });
120
125
  }
121
126
  },
@@ -130,7 +135,7 @@ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=
130
135
  'gl-ml-auto gl-bg-blue-100 gl-text-blue-900 gl-rounded-bottom-right-none': _vm.isUserMessage,
131
136
  'gl-rounded-bottom-left-none gl-text-gray-900 gl-bg-white gl-border-1 gl-border-solid gl-border-gray-50':
132
137
  _vm.isAssistantMessage,
133
- }},[_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:"gl-display-flex gl-align-items-flex-end gl-mt-4 duo-chat-message-feedback"},[_c('gl-duo-user-feedback',{attrs:{"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)})],1)]:_vm._e()],2)};
138
+ }},[_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:"gl-display-flex gl-align-items-flex-end gl-mt-4 duo-chat-message-feedback"},[_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)})],1)]:_vm._e()],2)};
134
139
  var __vue_staticRenderFns__ = [];
135
140
 
136
141
  /* style */
@@ -13,6 +13,14 @@ var script = {
13
13
  FeedbackModal
14
14
  },
15
15
  props: {
16
+ /**
17
+ * Whether the message already has gotten feedback
18
+ */
19
+ feedbackReceived: {
20
+ type: Boolean,
21
+ required: false,
22
+ default: false
23
+ },
16
24
  /**
17
25
  * The text to be displayed as the feedback link/button.
18
26
  */
@@ -31,11 +39,6 @@ var script = {
31
39
  default: ''
32
40
  }
33
41
  },
34
- data() {
35
- return {
36
- feedbackReceived: false
37
- };
38
- },
39
42
  computed: {
40
43
  shouldRenderModal() {
41
44
  return !this.feedbackReceived && !this.feedbackLinkUrl;
@@ -48,7 +51,6 @@ var script = {
48
51
  * @param {*} event An event, containing the feedback choices and the extended feedback text.
49
52
  */
50
53
  this.$emit('feedback', event);
51
- this.feedbackReceived = true;
52
54
  }
53
55
  },
54
56
  i18n
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 04 Mar 2024 19:50:55 GMT
3
+ * Generated on Tue, 05 Mar 2024 10:22:05 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 04 Mar 2024 19:50:55 GMT
3
+ * Generated on Tue, 05 Mar 2024 10:22:05 GMT
4
4
  */
5
5
 
6
6
  :root.gl-dark {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 04 Mar 2024 19:50:55 GMT
3
+ * Generated on Tue, 05 Mar 2024 10:22:05 GMT
4
4
  */
5
5
 
6
6
  export const DATA_VIZ_GREEN_50 = "#133a03";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 04 Mar 2024 19:50:55 GMT
3
+ * Generated on Tue, 05 Mar 2024 10:22:05 GMT
4
4
  */
5
5
 
6
6
  export const DATA_VIZ_GREEN_50 = "#ddfab7";
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Mon, 04 Mar 2024 19:50:55 GMT
3
+ // Generated on Tue, 05 Mar 2024 10:22:06 GMT
4
4
 
5
5
  $gl-text-tertiary: #737278 !default;
6
6
  $gl-text-secondary: #89888d !default;
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Mon, 04 Mar 2024 19:50:55 GMT
3
+ // Generated on Tue, 05 Mar 2024 10:22:05 GMT
4
4
 
5
5
  $gl-text-tertiary: #89888d !default;
6
6
  $gl-text-secondary: #737278 !default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "77.7.0",
3
+ "version": "78.0.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -119,6 +119,7 @@ describe('DuoChatMessage', () => {
119
119
  extendedTextFeedback: 'exampleText',
120
120
  didWhat: '',
121
121
  improveWhat: '',
122
+ message: MOCK_RESPONSE_MESSAGE,
122
123
  },
123
124
  ],
124
125
  ]);
@@ -92,6 +92,9 @@ export default {
92
92
  sources() {
93
93
  return this.message.extras?.sources;
94
94
  },
95
+ hasFeedback() {
96
+ return this.message.extras?.hasFeedback;
97
+ },
95
98
  messageContent() {
96
99
  if (this.message.errors.length > 0)
97
100
  return this.renderMarkdown(this.message.errors.join('; '));
@@ -125,6 +128,7 @@ export default {
125
128
  ...e,
126
129
  didWhat: this.didWhat,
127
130
  improveWhat: this.improveWhat,
131
+ message: this.message,
128
132
  });
129
133
  },
130
134
  },
@@ -147,6 +151,7 @@ export default {
147
151
 
148
152
  <div class="gl-display-flex gl-align-items-flex-end gl-mt-4 duo-chat-message-feedback">
149
153
  <gl-duo-user-feedback
154
+ :feedback-received="hasFeedback"
150
155
  :modal-title="$options.i18n.MODAL.TITLE"
151
156
  :modal-alert="$options.i18n.MODAL.ALERT_TEXT"
152
157
  @feedback="logEvent"
@@ -1,4 +1,3 @@
1
- import { nextTick } from 'vue';
2
1
  import { shallowMount } from '@vue/test-utils';
3
2
  import GlButton from '../../../base/button/button.vue';
4
3
  import FeedbackModal from './user_feedback_modal.vue';
@@ -65,27 +64,23 @@ describe('UserFeedback', () => {
65
64
  });
66
65
 
67
66
  describe('event handling', () => {
68
- beforeEach(() => {
69
- createComponent();
70
- });
71
-
72
67
  const passedFeedback = { feedbackOptions: ['helpful'], extendedFeedback: 'Foo bar' };
73
68
 
74
69
  it('emits the event, containing the form data, when modal emits', () => {
70
+ createComponent();
75
71
  findModal().vm.$emit('feedback-submitted', passedFeedback);
76
72
  expect(wrapper.emitted('feedback')).toHaveLength(1);
77
73
  });
78
74
 
79
75
  it('renders the thank you text instead of a button', async () => {
80
- findModal().vm.$emit('feedback-submitted', passedFeedback);
81
- await nextTick();
76
+ createComponent({ props: { feedbackReceived: true } });
77
+
82
78
  expect(findButton().exists()).toBe(false);
83
79
  expect(wrapper.text()).toContain(i18n.FEEDBACK_THANKS);
84
80
  });
85
81
 
86
82
  it('does not render the modal after feedback submitted', async () => {
87
- findModal().vm.$emit('feedback-submitted', passedFeedback);
88
- await nextTick();
83
+ createComponent({ props: { feedbackReceived: true } });
89
84
  expect(findModal().exists()).toBe(false);
90
85
  });
91
86
  });
@@ -14,6 +14,14 @@ export default {
14
14
  FeedbackModal,
15
15
  },
16
16
  props: {
17
+ /**
18
+ * Whether the message already has gotten feedback
19
+ */
20
+ feedbackReceived: {
21
+ type: Boolean,
22
+ required: false,
23
+ default: false,
24
+ },
17
25
  /**
18
26
  * The text to be displayed as the feedback link/button.
19
27
  */
@@ -32,11 +40,6 @@ export default {
32
40
  default: '',
33
41
  },
34
42
  },
35
- data() {
36
- return {
37
- feedbackReceived: false,
38
- };
39
- },
40
43
  computed: {
41
44
  shouldRenderModal() {
42
45
  return !this.feedbackReceived && !this.feedbackLinkUrl;
@@ -49,7 +52,6 @@ export default {
49
52
  * @param {*} event An event, containing the feedback choices and the extended feedback text.
50
53
  */
51
54
  this.$emit('feedback', event);
52
- this.feedbackReceived = true;
53
55
  },
54
56
  },
55
57
  i18n,