@gitlab/ui 66.18.0 → 66.19.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
+ # [66.19.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v66.18.0...v66.19.0) (2023-09-29)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlDuoUserFeedback:** Added the component ([f9a6f93](https://gitlab.com/gitlab-org/gitlab-ui/commit/f9a6f93fe0b46ba5638d9ad711e062afb7898636))
7
+
1
8
  # [66.18.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v66.17.0...v66.18.0) (2023-09-27)
2
9
 
3
10
 
@@ -0,0 +1,94 @@
1
+ import { GlButton } from '../../../../index';
2
+ import FeedbackModal from './user_feedback_modal';
3
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
4
+
5
+ const i18n = {
6
+ FEEDBACK_LINK_TEXT: 'Give feedback to improve this answer.',
7
+ FEEDBACK_THANKS: 'Thank you for your feedback.'
8
+ };
9
+ var script = {
10
+ name: 'GlDuoUserFeedback',
11
+ components: {
12
+ GlButton,
13
+ FeedbackModal
14
+ },
15
+ props: {
16
+ /**
17
+ * The text to be displayed as the feedback link/button.
18
+ */
19
+ feedbackLinkText: {
20
+ type: String,
21
+ required: false,
22
+ default: i18n.FEEDBACK_LINK_TEXT
23
+ },
24
+ /**
25
+ * The URL of a page to provide more explanations on the experiment. If provided, clicking
26
+ * the feedback link will open a new tab with the URL instead of showing the feedback modal.
27
+ */
28
+ feedbackLinkUrl: {
29
+ type: String,
30
+ required: false,
31
+ default: ''
32
+ }
33
+ },
34
+ data() {
35
+ return {
36
+ feedbackReceived: false
37
+ };
38
+ },
39
+ computed: {
40
+ shouldRenderModal() {
41
+ return !this.feedbackReceived && !this.feedbackLinkUrl;
42
+ }
43
+ },
44
+ methods: {
45
+ notify(event) {
46
+ /**
47
+ * Notify listeners about the feedback form submission.
48
+ * @param {*} event An event, containing the feedback choices and the extended feedback text.
49
+ */
50
+ this.$emit('feedback', event);
51
+ this.feedbackReceived = true;
52
+ }
53
+ },
54
+ i18n
55
+ };
56
+
57
+ /* script */
58
+ const __vue_script__ = script;
59
+
60
+ /* template */
61
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-pt-4"},[_c('div',[(!_vm.feedbackReceived)?_c('gl-button',{attrs:{"variant":"link","target":"_blank","href":_vm.feedbackLinkUrl},on:{"click":function($event){_vm.shouldRenderModal && _vm.$refs.feedbackModal.show();}}},[_vm._v(_vm._s(_vm.feedbackLinkText))]):_c('span',{staticClass:"gl-text-gray-500"},[_vm._v("\n "+_vm._s(_vm.$options.i18n.FEEDBACK_THANKS)+"\n ")])],1),_vm._v(" "),(_vm.shouldRenderModal)?_c('feedback-modal',{ref:"feedbackModal",on:{"feedback-submitted":_vm.notify}}):_vm._e()],1)};
62
+ var __vue_staticRenderFns__ = [];
63
+
64
+ /* style */
65
+ const __vue_inject_styles__ = undefined;
66
+ /* scoped */
67
+ const __vue_scope_id__ = undefined;
68
+ /* module identifier */
69
+ const __vue_module_identifier__ = undefined;
70
+ /* functional template */
71
+ const __vue_is_functional_template__ = false;
72
+ /* style inject */
73
+
74
+ /* style inject SSR */
75
+
76
+ /* style inject shadow dom */
77
+
78
+
79
+
80
+ const __vue_component__ = __vue_normalize__(
81
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
82
+ __vue_inject_styles__,
83
+ __vue_script__,
84
+ __vue_scope_id__,
85
+ __vue_is_functional_template__,
86
+ __vue_module_identifier__,
87
+ false,
88
+ undefined,
89
+ undefined,
90
+ undefined
91
+ );
92
+
93
+ export default __vue_component__;
94
+ export { i18n };
@@ -0,0 +1,121 @@
1
+ import { GlModal, GlFormCheckboxGroup, GlFormGroup, GlFormTextarea } from '../../../../index';
2
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
3
+
4
+ const i18n = {
5
+ MODAL_TITLE: 'Give feedback on AI content',
6
+ MODAL_DESCRIPTION: 'To help improve the quality of the content, send your feedback to GitLab team members.',
7
+ MODAL_OPTIONS_LABEL: 'How was the AI content?',
8
+ MODAL_MORE_LABEL: 'More information',
9
+ MODAL_MORE_PLACEHOLDER: 'How could the content be improved?',
10
+ MODAL_FEEDBACK_OPTIONS: {
11
+ helpful: 'Helpful',
12
+ unhelpful: 'Unhelpful or irrelevant',
13
+ incorrect: 'Factually incorrect',
14
+ long: 'Too long',
15
+ abuse: 'Abusive or offensive',
16
+ other: 'Something else'
17
+ },
18
+ MODAL_ACTIONS: {
19
+ submit: 'Submit',
20
+ cancel: 'Cancel'
21
+ }
22
+ };
23
+ const feedbackOptions = [{
24
+ text: i18n.MODAL_FEEDBACK_OPTIONS.helpful,
25
+ value: 'helpful'
26
+ }, {
27
+ text: i18n.MODAL_FEEDBACK_OPTIONS.unhelpful,
28
+ value: 'unhelpful'
29
+ }, {
30
+ text: i18n.MODAL_FEEDBACK_OPTIONS.incorrect,
31
+ value: 'incorrect'
32
+ }, {
33
+ text: i18n.MODAL_FEEDBACK_OPTIONS.long,
34
+ value: 'long'
35
+ }, {
36
+ text: i18n.MODAL_FEEDBACK_OPTIONS.abuse,
37
+ value: 'abuse'
38
+ }, {
39
+ text: i18n.MODAL_FEEDBACK_OPTIONS.other,
40
+ value: 'other'
41
+ }];
42
+ var script = {
43
+ name: 'DuoChatFeedbackModal',
44
+ components: {
45
+ GlModal,
46
+ GlFormCheckboxGroup,
47
+ GlFormGroup,
48
+ GlFormTextarea
49
+ },
50
+ data() {
51
+ return {
52
+ selectedFeedbackOptions: [],
53
+ extendedFeedback: ''
54
+ };
55
+ },
56
+ methods: {
57
+ show() {
58
+ this.$refs.feedbackModal.show();
59
+ },
60
+ onFeedbackSubmit() {
61
+ if (this.selectedFeedbackOptions.length) {
62
+ this.$emit('feedback-submitted', {
63
+ feedbackChoices: this.selectedFeedbackOptions,
64
+ extendedTextFeedback: this.extendedFeedback
65
+ });
66
+ }
67
+ },
68
+ onFeedbackCanceled() {
69
+ this.$refs.feedbackModal.hide();
70
+ }
71
+ },
72
+ actions: {
73
+ primary: {
74
+ text: i18n.MODAL_ACTIONS.submit
75
+ },
76
+ cancel: {
77
+ text: i18n.MODAL_ACTIONS.cancel
78
+ }
79
+ },
80
+ feedbackOptions,
81
+ i18n
82
+ };
83
+
84
+ /* script */
85
+ const __vue_script__ = script;
86
+
87
+ /* template */
88
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-modal',{ref:"feedbackModal",attrs:{"modal-id":"feedbackModal","title":_vm.$options.i18n.MODAL_TITLE,"action-primary":_vm.$options.actions.primary,"action-cancel":_vm.$options.actions.cancel,"visible":false,"size":"sm"},on:{"primary":_vm.onFeedbackSubmit,"canceled":_vm.onFeedbackCanceled}},[_c('p',[_vm._v(_vm._s(_vm.$options.i18n.MODAL_DESCRIPTION))]),_vm._v(" "),_c('gl-form-group',{attrs:{"label":_vm.$options.i18n.MODAL_OPTIONS_LABEL,"optional":false,"data-testid":"feedback-options"}},[_c('gl-form-checkbox-group',{attrs:{"options":_vm.$options.feedbackOptions},model:{value:(_vm.selectedFeedbackOptions),callback:function ($$v) {_vm.selectedFeedbackOptions=$$v;},expression:"selectedFeedbackOptions"}})],1),_vm._v(" "),_c('gl-form-group',{attrs:{"label":_vm.$options.i18n.MODAL_MORE_LABEL,"optional":""}},[_c('gl-form-textarea',{attrs:{"placeholder":_vm.$options.i18n.MODAL_MORE_PLACEHOLDER},model:{value:(_vm.extendedFeedback),callback:function ($$v) {_vm.extendedFeedback=$$v;},expression:"extendedFeedback"}})],1)],1)};
89
+ var __vue_staticRenderFns__ = [];
90
+
91
+ /* style */
92
+ const __vue_inject_styles__ = undefined;
93
+ /* scoped */
94
+ const __vue_scope_id__ = undefined;
95
+ /* module identifier */
96
+ const __vue_module_identifier__ = undefined;
97
+ /* functional template */
98
+ const __vue_is_functional_template__ = false;
99
+ /* style inject */
100
+
101
+ /* style inject SSR */
102
+
103
+ /* style inject shadow dom */
104
+
105
+
106
+
107
+ const __vue_component__ = __vue_normalize__(
108
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
109
+ __vue_inject_styles__,
110
+ __vue_script__,
111
+ __vue_scope_id__,
112
+ __vue_is_functional_template__,
113
+ __vue_module_identifier__,
114
+ false,
115
+ undefined,
116
+ undefined,
117
+ undefined
118
+ );
119
+
120
+ export default __vue_component__;
121
+ export { feedbackOptions, i18n };
package/dist/index.js CHANGED
@@ -87,6 +87,7 @@ export { default as GlAccordionItem } from './components/base/accordion/accordio
87
87
  export { default as GlCarousel } from './components/base/carousel/carousel';
88
88
  export { default as GlCarouselSlide } from './components/base/carousel/carousel_slide';
89
89
  export { default as GlExperimentBadge } from './components/experimental/experiment_badge/experiment_badge';
90
+ export { default as GlDuoUserFeedback } from './components/experimental/duo/user_feedback/user_feedback';
90
91
  export { default as GlAnimatedNumber } from './components/utilities/animated_number/animated_number';
91
92
  export { default as GlFriendlyWrap } from './components/utilities/friendly_wrap/friendly_wrap';
92
93
  export { default as GlIntersperse } from './components/utilities/intersperse/intersperse';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 27 Sep 2023 16:04:33 GMT
3
+ * Generated on Fri, 29 Sep 2023 10:00:16 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 27 Sep 2023 16:04:33 GMT
3
+ * Generated on Fri, 29 Sep 2023 10:00:16 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 27 Sep 2023 16:04:33 GMT
3
+ * Generated on Fri, 29 Sep 2023 10:00:16 GMT
4
4
  */
5
5
 
6
6
  export const BLACK = "#fff";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 27 Sep 2023 16:04:33 GMT
3
+ * Generated on Fri, 29 Sep 2023 10:00:16 GMT
4
4
  */
5
5
 
6
6
  export const BLACK = "#000";
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Wed, 27 Sep 2023 16:04:33 GMT
3
+ // Generated on Fri, 29 Sep 2023 10:00:16 GMT
4
4
 
5
5
  $red-950: #fff4f3;
6
6
  $red-900: #fcf1ef;
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Wed, 27 Sep 2023 16:04:33 GMT
3
+ // Generated on Fri, 29 Sep 2023 10:00:16 GMT
4
4
 
5
5
  $gl-line-height-52: 3.25rem;
6
6
  $gl-line-height-44: 2.75rem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "66.18.0",
3
+ "version": "66.19.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,40 @@
1
+ The main entry point component for gathering the user feedback for the AI features.
2
+
3
+ The component consists of a textual button and a connected modal with the actual form, emitting
4
+ the form data on submission.
5
+
6
+ ## Custom button text
7
+
8
+ The component allows to customize the button text, presented to the user.
9
+
10
+ ```html
11
+ <gl-user-feedback feedback-link-text="Leave your custom feedback" />
12
+ ```
13
+
14
+ ## Linking to a separate feedback form
15
+
16
+ The main goal of this component is to provide the advanced feedback form. However, it might not
17
+ be necessary for all consumers. In such a case, the component allows to bypass the default
18
+ form and link to an external feedback page/form.
19
+
20
+ ```html
21
+ <gl-user-feedback feedback-link-url="https://gitlab.com" />
22
+ ```
23
+
24
+ ## Listening to the feedback form submission
25
+
26
+ This component emits the `feedback` event with all the options selected in the feedback form.
27
+
28
+ ```html
29
+ <gl-user-feedback @feedback="myEventTracker" />
30
+ ```
31
+
32
+ The returned event contains two props (`feedbackChoices` and `extendedTextFeedback`) coming from
33
+ the underlying `FeedbackModal` component. Here's the example of a possible event:
34
+
35
+ ```json
36
+ {
37
+ "feedbackChoices": ["unhelpful", "long"],
38
+ "extendedTextFeedback": "The answer was too long to understand"
39
+ }
40
+ ```
@@ -0,0 +1,80 @@
1
+ import { nextTick } from 'vue';
2
+ import { shallowMount } from '@vue/test-utils';
3
+ import { GlButton } from '../../../../index';
4
+ import DuoChatFeedbackModal from './user_feedback_modal.vue';
5
+ import UserFeedback, { i18n } from './user_feedback.vue';
6
+
7
+ describe('UserFeedback', () => {
8
+ let wrapper;
9
+ const eventName = 'test_event_name';
10
+
11
+ const createComponent = ({ props, data = {} } = {}) => {
12
+ wrapper = shallowMount(UserFeedback, {
13
+ data() {
14
+ return data;
15
+ },
16
+ propsData: {
17
+ eventName,
18
+ ...props,
19
+ },
20
+ });
21
+ };
22
+
23
+ const findButton = () => wrapper.findComponent(GlButton);
24
+ const findModal = () => wrapper.findComponent(DuoChatFeedbackModal);
25
+
26
+ beforeEach(() => {
27
+ createComponent();
28
+ });
29
+
30
+ describe('rendering with no feedback registered', () => {
31
+ it('renders a button to provide feedback', () => {
32
+ expect(findButton().exists()).toBe(true);
33
+ });
34
+
35
+ it('renders the feedback modal', () => {
36
+ expect(findModal().exists()).toBe(true);
37
+ });
38
+ });
39
+
40
+ it.each`
41
+ feedbackLinkText | expectedButtonText
42
+ ${'Foo'} | ${'Foo'}
43
+ ${undefined} | ${i18n.FEEDBACK_LINK_TEXT}
44
+ `(
45
+ 'renders "$expectedButtonText" as button text when "$feedbackLinkText" is passed as the feedback link text',
46
+ ({ feedbackLinkText, expectedButtonText } = {}) => {
47
+ createComponent({ props: { feedbackLinkText } });
48
+ expect(findButton().text()).toBe(expectedButtonText);
49
+ }
50
+ );
51
+
52
+ it('does not render the modal if custom URL is passed for the feedback link', () => {
53
+ const feedbackLinkUrl = 'https://example.com';
54
+ createComponent({ props: { feedbackLinkUrl } });
55
+ expect(findButton().attributes('href')).toBe(feedbackLinkUrl);
56
+ expect(findModal().exists()).toBe(false);
57
+ });
58
+
59
+ describe('event handling', () => {
60
+ const passedFeedback = { feedbackOptions: ['helpful'], extendedFeedback: 'Foo bar' };
61
+
62
+ it('emits the event, containing the form data, when modal emits', () => {
63
+ findModal().vm.$emit('feedback-submitted', passedFeedback);
64
+ expect(wrapper.emitted('feedback')).toHaveLength(1);
65
+ });
66
+
67
+ it('renders the thank you text instead of a button', async () => {
68
+ findModal().vm.$emit('feedback-submitted', passedFeedback);
69
+ await nextTick();
70
+ expect(findButton().exists()).toBe(false);
71
+ expect(wrapper.text()).toContain(i18n.FEEDBACK_THANKS);
72
+ });
73
+
74
+ it('does not render the modal after feedback submitted', async () => {
75
+ findModal().vm.$emit('feedback-submitted', passedFeedback);
76
+ await nextTick();
77
+ expect(findModal().exists()).toBe(false);
78
+ });
79
+ });
80
+ });
@@ -0,0 +1,48 @@
1
+ import GlUserFeedback from './user_feedback.vue';
2
+ import readme from './user_feedback.md';
3
+
4
+ const generateProps = ({ feedbackLinkText, feedbackLinkUrl } = {}) => ({
5
+ feedbackLinkText,
6
+ feedbackLinkUrl,
7
+ });
8
+
9
+ const Template = (args, { argTypes }) => ({
10
+ components: { GlUserFeedback },
11
+ props: Object.keys(argTypes),
12
+ data() {
13
+ return {
14
+ eventOutput: '',
15
+ };
16
+ },
17
+ methods: {
18
+ logEvent(event) {
19
+ this.eventOutput = JSON.stringify(event);
20
+ },
21
+ },
22
+ template: `
23
+ <div>
24
+ <gl-user-feedback
25
+ :feedback-link-text="feedbackLinkText"
26
+ :feedback-link-url="feedbackLinkUrl"
27
+ @feedback="logEvent"/>
28
+ <p v-if="eventOutput"><code>{{ eventOutput }}</code></p>
29
+ </div>
30
+ `,
31
+ });
32
+
33
+ export const Default = Template.bind({});
34
+ Default.args = generateProps();
35
+
36
+ export default {
37
+ title: 'experimental/duo/user-feedback',
38
+ component: GlUserFeedback,
39
+ parameters: {
40
+ storyshots: { disable: true },
41
+ docs: {
42
+ description: {
43
+ component: readme,
44
+ },
45
+ },
46
+ },
47
+ argTypes: {},
48
+ };
@@ -0,0 +1,76 @@
1
+ <script>
2
+ import { GlButton } from '../../../../index';
3
+ import FeedbackModal from './user_feedback_modal.vue';
4
+
5
+ export const i18n = {
6
+ FEEDBACK_LINK_TEXT: 'Give feedback to improve this answer.',
7
+ FEEDBACK_THANKS: 'Thank you for your feedback.',
8
+ };
9
+
10
+ export default {
11
+ name: 'GlDuoUserFeedback',
12
+ components: {
13
+ GlButton,
14
+ FeedbackModal,
15
+ },
16
+ props: {
17
+ /**
18
+ * The text to be displayed as the feedback link/button.
19
+ */
20
+ feedbackLinkText: {
21
+ type: String,
22
+ required: false,
23
+ default: i18n.FEEDBACK_LINK_TEXT,
24
+ },
25
+ /**
26
+ * The URL of a page to provide more explanations on the experiment. If provided, clicking
27
+ * the feedback link will open a new tab with the URL instead of showing the feedback modal.
28
+ */
29
+ feedbackLinkUrl: {
30
+ type: String,
31
+ required: false,
32
+ default: '',
33
+ },
34
+ },
35
+ data() {
36
+ return {
37
+ feedbackReceived: false,
38
+ };
39
+ },
40
+ computed: {
41
+ shouldRenderModal() {
42
+ return !this.feedbackReceived && !this.feedbackLinkUrl;
43
+ },
44
+ },
45
+ methods: {
46
+ notify(event) {
47
+ /**
48
+ * Notify listeners about the feedback form submission.
49
+ * @param {*} event An event, containing the feedback choices and the extended feedback text.
50
+ */
51
+ this.$emit('feedback', event);
52
+ this.feedbackReceived = true;
53
+ },
54
+ },
55
+ i18n,
56
+ };
57
+ </script>
58
+
59
+ <template>
60
+ <div class="gl-pt-4">
61
+ <div>
62
+ <gl-button
63
+ v-if="!feedbackReceived"
64
+ variant="link"
65
+ target="_blank"
66
+ :href="feedbackLinkUrl"
67
+ @click="shouldRenderModal && $refs.feedbackModal.show()"
68
+ >{{ feedbackLinkText }}</gl-button
69
+ >
70
+ <span v-else class="gl-text-gray-500">
71
+ {{ $options.i18n.FEEDBACK_THANKS }}
72
+ </span>
73
+ </div>
74
+ <feedback-modal v-if="shouldRenderModal" ref="feedbackModal" @feedback-submitted="notify" />
75
+ </div>
76
+ </template>
@@ -0,0 +1,61 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import { GlModal, GlFormCheckboxGroup, GlFormCheckbox, GlFormTextarea } from '../../../../index';
3
+ import FeedbackModal, { feedbackOptions } from './user_feedback_modal.vue';
4
+
5
+ describe('FeedbackModal', () => {
6
+ let wrapper;
7
+
8
+ const findModal = () => wrapper.findComponent(GlModal);
9
+ const findOptions = () => wrapper.findComponent('[data-testid="feedback-options"]');
10
+ const findOptionsCheckboxes = () => findOptions().findAllComponents(GlFormCheckbox);
11
+ const findTextarea = () => wrapper.findComponent(GlFormTextarea);
12
+ const selectOption = (index = 0) => {
13
+ wrapper
14
+ .findAllComponents(GlFormCheckboxGroup)
15
+ .at(index)
16
+ .vm.$emit('input', [feedbackOptions[index].value]);
17
+ };
18
+ const createComponent = () => {
19
+ wrapper = shallowMount(FeedbackModal, {
20
+ stubs: {
21
+ GlModal,
22
+ GlFormCheckboxGroup,
23
+ },
24
+ });
25
+ };
26
+
27
+ beforeEach(() => {
28
+ createComponent();
29
+ });
30
+
31
+ it('renders the feedback options', () => {
32
+ const checkboxes = findOptionsCheckboxes();
33
+ feedbackOptions.forEach((option, index) => {
34
+ expect(checkboxes.at(index).text()).toBe(option.text);
35
+ expect(checkboxes.at(index).attributes('value')).toBe(option.value);
36
+ });
37
+ });
38
+
39
+ it('renders the textarea field for additional feedback', () => {
40
+ expect(findTextarea().exists()).toBe(true);
41
+ });
42
+
43
+ describe('interaction', () => {
44
+ it('emits the feedback event when the submit button is clicked', () => {
45
+ selectOption();
46
+ findModal().vm.$emit('primary');
47
+ expect(wrapper.emitted('feedback-submitted')).toEqual([
48
+ [
49
+ {
50
+ feedbackChoices: [feedbackOptions[0].value],
51
+ extendedTextFeedback: '',
52
+ },
53
+ ],
54
+ ]);
55
+ });
56
+ it('does not emit event if there is no option selected', () => {
57
+ findModal().vm.$emit('primary');
58
+ expect(wrapper.emitted('feedback-submitted')).toBeUndefined();
59
+ });
60
+ });
61
+ });
@@ -0,0 +1,124 @@
1
+ <script>
2
+ import { GlModal, GlFormCheckboxGroup, GlFormGroup, GlFormTextarea } from '../../../../index';
3
+
4
+ export const i18n = {
5
+ MODAL_TITLE: 'Give feedback on AI content',
6
+ MODAL_DESCRIPTION:
7
+ 'To help improve the quality of the content, send your feedback to GitLab team members.',
8
+ MODAL_OPTIONS_LABEL: 'How was the AI content?',
9
+ MODAL_MORE_LABEL: 'More information',
10
+ MODAL_MORE_PLACEHOLDER: 'How could the content be improved?',
11
+ MODAL_FEEDBACK_OPTIONS: {
12
+ helpful: 'Helpful',
13
+ unhelpful: 'Unhelpful or irrelevant',
14
+ incorrect: 'Factually incorrect',
15
+ long: 'Too long',
16
+ abuse: 'Abusive or offensive',
17
+ other: 'Something else',
18
+ },
19
+ MODAL_ACTIONS: {
20
+ submit: 'Submit',
21
+ cancel: 'Cancel',
22
+ },
23
+ };
24
+
25
+ export const feedbackOptions = [
26
+ {
27
+ text: i18n.MODAL_FEEDBACK_OPTIONS.helpful,
28
+ value: 'helpful',
29
+ },
30
+ {
31
+ text: i18n.MODAL_FEEDBACK_OPTIONS.unhelpful,
32
+ value: 'unhelpful',
33
+ },
34
+ {
35
+ text: i18n.MODAL_FEEDBACK_OPTIONS.incorrect,
36
+ value: 'incorrect',
37
+ },
38
+ {
39
+ text: i18n.MODAL_FEEDBACK_OPTIONS.long,
40
+ value: 'long',
41
+ },
42
+ {
43
+ text: i18n.MODAL_FEEDBACK_OPTIONS.abuse,
44
+ value: 'abuse',
45
+ },
46
+ {
47
+ text: i18n.MODAL_FEEDBACK_OPTIONS.other,
48
+ value: 'other',
49
+ },
50
+ ];
51
+
52
+ export default {
53
+ name: 'DuoChatFeedbackModal',
54
+ components: {
55
+ GlModal,
56
+ GlFormCheckboxGroup,
57
+ GlFormGroup,
58
+ GlFormTextarea,
59
+ },
60
+ data() {
61
+ return {
62
+ selectedFeedbackOptions: [],
63
+ extendedFeedback: '',
64
+ };
65
+ },
66
+ methods: {
67
+ show() {
68
+ this.$refs.feedbackModal.show();
69
+ },
70
+ onFeedbackSubmit() {
71
+ if (this.selectedFeedbackOptions.length) {
72
+ this.$emit('feedback-submitted', {
73
+ feedbackChoices: this.selectedFeedbackOptions,
74
+ extendedTextFeedback: this.extendedFeedback,
75
+ });
76
+ }
77
+ },
78
+ onFeedbackCanceled() {
79
+ this.$refs.feedbackModal.hide();
80
+ },
81
+ },
82
+ actions: {
83
+ primary: {
84
+ text: i18n.MODAL_ACTIONS.submit,
85
+ },
86
+ cancel: {
87
+ text: i18n.MODAL_ACTIONS.cancel,
88
+ },
89
+ },
90
+ feedbackOptions,
91
+ i18n,
92
+ };
93
+ </script>
94
+ <template>
95
+ <gl-modal
96
+ ref="feedbackModal"
97
+ modal-id="feedbackModal"
98
+ :title="$options.i18n.MODAL_TITLE"
99
+ :action-primary="$options.actions.primary"
100
+ :action-cancel="$options.actions.cancel"
101
+ :visible="false"
102
+ size="sm"
103
+ @primary="onFeedbackSubmit"
104
+ @canceled="onFeedbackCanceled"
105
+ >
106
+ <p>{{ $options.i18n.MODAL_DESCRIPTION }}</p>
107
+ <gl-form-group
108
+ :label="$options.i18n.MODAL_OPTIONS_LABEL"
109
+ :optional="false"
110
+ data-testid="feedback-options"
111
+ >
112
+ <gl-form-checkbox-group
113
+ v-model="selectedFeedbackOptions"
114
+ :options="$options.feedbackOptions"
115
+ />
116
+ </gl-form-group>
117
+ <gl-form-group :label="$options.i18n.MODAL_MORE_LABEL" optional>
118
+ <gl-form-textarea
119
+ v-model="extendedFeedback"
120
+ :placeholder="$options.i18n.MODAL_MORE_PLACEHOLDER"
121
+ />
122
+ </gl-form-group>
123
+ </gl-modal>
124
+ </template>
package/src/index.js CHANGED
@@ -98,6 +98,7 @@ export { default as GlCarouselSlide } from './components/base/carousel/carousel_
98
98
 
99
99
  // Experimental
100
100
  export { default as GlExperimentBadge } from './components/experimental/experiment_badge/experiment_badge.vue';
101
+ export { default as GlDuoUserFeedback } from './components/experimental/duo/user_feedback/user_feedback.vue';
101
102
 
102
103
  // Utilities
103
104
  export { default as GlAnimatedNumber } from './components/utilities/animated_number/animated_number.vue';