@gitlab/ui 66.16.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 +21 -0
- package/dist/components/base/modal/modal.js +1 -1
- package/dist/components/experimental/duo/user_feedback/user_feedback.js +94 -0
- package/dist/components/experimental/duo/user_feedback/user_feedback_modal.js +121 -0
- package/dist/components/regions/empty_state/empty_state.js +2 -2
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +1 -0
- package/dist/tokens/css/tokens.css +1 -1
- package/dist/tokens/css/tokens.dark.css +1 -1
- package/dist/tokens/js/tokens.dark.js +1 -1
- package/dist/tokens/js/tokens.js +1 -1
- package/dist/tokens/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +1 -1
- package/package.json +14 -14
- package/src/components/base/modal/modal.scss +1 -3
- package/src/components/base/modal/modal.spec.js +2 -2
- package/src/components/base/modal/modal.vue +2 -2
- package/src/components/experimental/duo/user_feedback/user_feedback.md +40 -0
- package/src/components/experimental/duo/user_feedback/user_feedback.spec.js +80 -0
- package/src/components/experimental/duo/user_feedback/user_feedback.stories.js +48 -0
- package/src/components/experimental/duo/user_feedback/user_feedback.vue +76 -0
- package/src/components/experimental/duo/user_feedback/user_feedback_modal.spec.js +61 -0
- package/src/components/experimental/duo/user_feedback/user_feedback_modal.vue +124 -0
- package/src/components/regions/empty_state/empty_state.scss +3 -0
- package/src/components/regions/empty_state/empty_state.spec.js +11 -1
- package/src/components/regions/empty_state/empty_state.vue +60 -59
- package/src/index.js +1 -0
- package/src/scss/components.scss +1 -0
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';
|
package/dist/tokens/js/tokens.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "66.
|
|
3
|
+
"version": "66.19.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -98,18 +98,18 @@
|
|
|
98
98
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
99
99
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
100
100
|
"@rollup/plugin-replace": "^2.3.2",
|
|
101
|
-
"@storybook/addon-a11y": "7.4.
|
|
102
|
-
"@storybook/addon-docs": "7.4.
|
|
103
|
-
"@storybook/addon-essentials": "7.4.
|
|
104
|
-
"@storybook/addon-storyshots": "7.4.
|
|
105
|
-
"@storybook/addon-storyshots-puppeteer": "7.4.
|
|
106
|
-
"@storybook/addon-viewport": "7.4.
|
|
107
|
-
"@storybook/builder-webpack5": "7.4.
|
|
108
|
-
"@storybook/theming": "7.4.
|
|
109
|
-
"@storybook/vue": "7.4.
|
|
110
|
-
"@storybook/vue-webpack5": "7.4.
|
|
111
|
-
"@storybook/vue3": "7.4.
|
|
112
|
-
"@storybook/vue3-webpack5": "7.4.
|
|
101
|
+
"@storybook/addon-a11y": "7.4.5",
|
|
102
|
+
"@storybook/addon-docs": "7.4.5",
|
|
103
|
+
"@storybook/addon-essentials": "7.4.5",
|
|
104
|
+
"@storybook/addon-storyshots": "7.4.5",
|
|
105
|
+
"@storybook/addon-storyshots-puppeteer": "7.4.5",
|
|
106
|
+
"@storybook/addon-viewport": "7.4.5",
|
|
107
|
+
"@storybook/builder-webpack5": "7.4.5",
|
|
108
|
+
"@storybook/theming": "7.4.5",
|
|
109
|
+
"@storybook/vue": "7.4.5",
|
|
110
|
+
"@storybook/vue-webpack5": "7.4.5",
|
|
111
|
+
"@storybook/vue3": "7.4.5",
|
|
112
|
+
"@storybook/vue3-webpack5": "7.4.5",
|
|
113
113
|
"@vue/compat": "^3.2.40",
|
|
114
114
|
"@vue/compiler-sfc": "^3.2.40",
|
|
115
115
|
"@vue/test-utils": "1.3.0",
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
"sass-loader": "^10.2.0",
|
|
161
161
|
"sass-true": "^6.1.0",
|
|
162
162
|
"start-server-and-test": "^1.10.6",
|
|
163
|
-
"storybook": "7.4.
|
|
163
|
+
"storybook": "7.4.5",
|
|
164
164
|
"storybook-dark-mode": "3.0.1",
|
|
165
165
|
"style-dictionary": "^3.8.0",
|
|
166
166
|
"stylelint": "15.10.2",
|
|
@@ -85,7 +85,7 @@ describe('Modal component', () => {
|
|
|
85
85
|
createComponent({
|
|
86
86
|
slots: { 'modal-header': slot },
|
|
87
87
|
});
|
|
88
|
-
const defaultHeader = wrapper.find('
|
|
88
|
+
const defaultHeader = wrapper.find('h2.modal-title');
|
|
89
89
|
const customHeader = wrapper.find('h4.custom-title');
|
|
90
90
|
|
|
91
91
|
expect(defaultHeader.exists()).toBe(false);
|
|
@@ -98,7 +98,7 @@ describe('Modal component', () => {
|
|
|
98
98
|
createComponent({
|
|
99
99
|
slots: { 'modal-title': slot },
|
|
100
100
|
});
|
|
101
|
-
const defaultHeader = wrapper.find('
|
|
101
|
+
const defaultHeader = wrapper.find('h2.modal-title');
|
|
102
102
|
const customTitle = defaultHeader.find('h4.custom-title');
|
|
103
103
|
|
|
104
104
|
expect(defaultHeader.exists()).toBe(true);
|
|
@@ -206,10 +206,10 @@ export default {
|
|
|
206
206
|
<template #modal-header>
|
|
207
207
|
<!-- @slot Entire modal header container contents (including the close button on the top right corner) -->
|
|
208
208
|
<slot name="modal-header">
|
|
209
|
-
<
|
|
209
|
+
<h2 class="modal-title">
|
|
210
210
|
<!-- @slot Modal title. If modal-header slot is used, this slot will not be shown. -->
|
|
211
211
|
<slot name="modal-title">{{ title }}</slot>
|
|
212
|
-
</
|
|
212
|
+
</h2>
|
|
213
213
|
</slot>
|
|
214
214
|
<!-- @slot Content of Modal header close button. If modal-header slot is used, this slot will not be shown. -->
|
|
215
215
|
<close-button ref="close-button" :label="dismissLabel" @click="close" />
|
|
@@ -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>
|
|
@@ -249,8 +249,18 @@ describe('empty state component', () => {
|
|
|
249
249
|
describe('with custom content class', () => {
|
|
250
250
|
const findContentContainer = () => component.find('[data-testid="gl-empty-state-content"]');
|
|
251
251
|
const customContentClass = 'gl-p-0';
|
|
252
|
-
const expectedDefaultContentClasses = [
|
|
252
|
+
const expectedDefaultContentClasses = [
|
|
253
|
+
'gl-empty-state-content',
|
|
254
|
+
'gl-mx-auto',
|
|
255
|
+
'gl-my-0',
|
|
256
|
+
'gl-m-auto',
|
|
257
|
+
'gl-p-5',
|
|
258
|
+
customContentClass,
|
|
259
|
+
];
|
|
253
260
|
const expectedCompactContentClasses = [
|
|
261
|
+
'gl-empty-state-content',
|
|
262
|
+
'gl-mx-auto',
|
|
263
|
+
'gl-my-0',
|
|
254
264
|
'gl-flex-grow-1',
|
|
255
265
|
'gl-flex-basis-0',
|
|
256
266
|
'gl-px-4',
|