@gitlab/ui 76.1.0 → 77.1.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +38 -3
  3. package/dist/components/experimental/duo/chat/duo_chat.js +1 -1
  4. package/dist/components/experimental/duo/user_feedback/user_feedback_modal.js +42 -25
  5. package/dist/index.css.map +1 -1
  6. package/dist/tokens/css/tokens.css +1 -1
  7. package/dist/tokens/css/tokens.dark.css +1 -1
  8. package/dist/tokens/js/tokens.dark.js +1 -1
  9. package/dist/tokens/js/tokens.js +1 -1
  10. package/dist/tokens/scss/_tokens.dark.scss +1 -1
  11. package/dist/tokens/scss/_tokens.scss +1 -1
  12. package/dist/utility_classes.css +1 -1
  13. package/dist/utility_classes.css.map +1 -1
  14. package/package.json +2 -2
  15. package/src/components/base/alert/alert.scss +7 -7
  16. package/src/components/base/badge/badge.scss +1 -1
  17. package/src/components/base/banner/banner.scss +3 -3
  18. package/src/components/base/button/button.scss +2 -2
  19. package/src/components/base/card/card.scss +1 -1
  20. package/src/components/base/datepicker/datepicker.scss +5 -5
  21. package/src/components/base/drawer/drawer.scss +10 -10
  22. package/src/components/base/dropdown/dropdown_item.scss +1 -1
  23. package/src/components/base/filtered_search/filtered_search_suggestion_list.scss +1 -1
  24. package/src/components/base/form/form_checkbox/form_checkbox.scss +3 -3
  25. package/src/components/base/label/label.scss +1 -1
  26. package/src/components/base/loading_icon/loading_icon.scss +1 -1
  27. package/src/components/base/modal/modal.scss +1 -1
  28. package/src/components/base/new_dropdowns/dropdown.scss +1 -1
  29. package/src/components/base/new_dropdowns/dropdown_item.scss +1 -1
  30. package/src/components/base/new_dropdowns/listbox/listbox.scss +3 -3
  31. package/src/components/base/path/path.scss +8 -8
  32. package/src/components/base/search_box_by_click/search_box_by_click.scss +7 -7
  33. package/src/components/base/search_box_by_type/search_box_by_type.scss +5 -5
  34. package/src/components/base/tabs/tabs/tabs.scss +5 -5
  35. package/src/components/base/toast/toast.scss +5 -5
  36. package/src/components/base/toggle/toggle.scss +4 -4
  37. package/src/components/charts/heatmap/heatmap.scss +1 -1
  38. package/src/components/charts/legend/legend.scss +3 -3
  39. package/src/components/charts/tooltip/tooltip.scss +1 -1
  40. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.scss +3 -3
  41. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.spec.js +15 -3
  42. package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.vue +53 -1
  43. package/src/components/experimental/duo/chat/duo_chat.vue +2 -2
  44. package/src/components/experimental/duo/user_feedback/user_feedback.md +0 -5
  45. package/src/components/experimental/duo/user_feedback/user_feedback.spec.js +12 -4
  46. package/src/components/experimental/duo/user_feedback/user_feedback_modal.spec.js +49 -12
  47. package/src/components/experimental/duo/user_feedback/user_feedback_modal.vue +48 -31
  48. package/src/scss/tailwind.css +1 -0
  49. package/src/scss/utilities.scss +24 -430
  50. package/src/scss/utility-mixins/{appearance.scss → deprecated.scss} +9 -0
  51. package/src/scss/utility-mixins/index.scss +3 -2
  52. package/src/scss/utility-mixins/position.scss +0 -223
@@ -1,5 +1,7 @@
1
1
  <script>
2
2
  import GlDuoUserFeedback from '../../../user_feedback/user_feedback.vue';
3
+ import GlFormGroup from '../../../../../base/form/form_group/form_group.vue';
4
+ import GlFormTextarea from '../../../../../base/form/form_textarea/form_textarea.vue';
3
5
  import { SafeHtmlDirective as SafeHtml } from '../../../../../../directives/safe_html/safe_html';
4
6
  import { MESSAGE_MODEL_ROLES } from '../../constants';
5
7
  import DocumentationSources from '../duo_chat_message_sources/duo_chat_message_sources.vue';
@@ -7,6 +9,18 @@ import DocumentationSources from '../duo_chat_message_sources/duo_chat_message_s
7
9
  import { renderDuoChatMarkdownPreview } from '../../markdown_renderer';
8
10
  import { CopyCodeElement } from './copy_code_element';
9
11
 
12
+ export const i18n = {
13
+ MODAL: {
14
+ TITLE: 'Give feedback on GitLab Duo Chat',
15
+ ALERT_TEXT:
16
+ 'GitLab team members cannot view your conversation. Please be as descriptive as possible.',
17
+ DID_WHAT: 'What were you doing?',
18
+ INTERACTION: 'The situation in which you interacted with GitLab Duo Chat.',
19
+ IMPROVE_WHAT: 'How could the response be improved?',
20
+ BETTER_RESPONSE: 'How the response might better meet your needs.',
21
+ },
22
+ };
23
+
10
24
  const concatUntilEmpty = (arr) => {
11
25
  if (!arr) return '';
12
26
 
@@ -25,10 +39,18 @@ export default {
25
39
  components: {
26
40
  DocumentationSources,
27
41
  GlDuoUserFeedback,
42
+ GlFormGroup,
43
+ GlFormTextarea,
28
44
  },
29
45
  directives: {
30
46
  SafeHtml,
31
47
  },
48
+ provide() {
49
+ return {
50
+ modalTitle: i18n.MODAL.TITLE,
51
+ modalAlertText: i18n.MODAL.ALERT_TEXT,
52
+ };
53
+ },
32
54
  inject: {
33
55
  // Note, we likely might move away from Provide/Inject for this
34
56
  // and only ship the versions that are currently in the default
@@ -54,6 +76,12 @@ export default {
54
76
  required: true,
55
77
  },
56
78
  },
79
+ data() {
80
+ return {
81
+ didWhat: '',
82
+ improveWhat: '',
83
+ };
84
+ },
57
85
  computed: {
58
86
  isAssistantMessage() {
59
87
  return this.message.role.toLowerCase() === MESSAGE_MODEL_ROLES.assistant;
@@ -92,7 +120,15 @@ export default {
92
120
  this.renderGFM(this.$refs.content);
93
121
  }
94
122
  },
123
+ logEvent(e) {
124
+ this.$emit('track-feedback', {
125
+ ...e,
126
+ didWhat: this.didWhat,
127
+ improveWhat: this.improveWhat,
128
+ });
129
+ },
95
130
  },
131
+ i18n,
96
132
  };
97
133
  </script>
98
134
  <template>
@@ -110,7 +146,23 @@ export default {
110
146
  <documentation-sources v-if="sources" :sources="sources" />
111
147
 
112
148
  <div class="gl-display-flex gl-align-items-flex-end gl-mt-4 duo-chat-message-feedback">
113
- <gl-duo-user-feedback @feedback="$emit('track-feedback', $event)" />
149
+ <gl-duo-user-feedback
150
+ :modal-title="$options.i18n.MODAL.TITLE"
151
+ :modal-alert="$options.i18n.MODAL.ALERT_TEXT"
152
+ @feedback="logEvent"
153
+ >
154
+ <template #feedback-extra-fields>
155
+ <gl-form-group :label="$options.i18n.MODAL.DID_WHAT" optional>
156
+ <gl-form-textarea v-model="didWhat" :placeholder="$options.i18n.MODAL.INTERACTION" />
157
+ </gl-form-group>
158
+ <gl-form-group :label="$options.i18n.MODAL.IMPROVE_WHAT" optional>
159
+ <gl-form-textarea
160
+ v-model="improveWhat"
161
+ :placeholder="$options.i18n.MODAL.BETTER_RESPONSE"
162
+ />
163
+ </gl-form-group>
164
+ </template>
165
+ </gl-duo-user-feedback>
114
166
  </div>
115
167
  </template>
116
168
  </div>
@@ -467,7 +467,7 @@ export default {
467
467
  <gl-card
468
468
  v-if="shouldShowSlashCommands"
469
469
  ref="commands"
470
- class="slash-commands gl-absolute! gl-translate-y-n100 gl-list-style-none gl-pl-0 gl-w-full gl-shadow-md"
470
+ class="slash-commands !gl-absolute gl-translate-y-n100 gl-list-style-none gl-pl-0 gl-w-full gl-shadow-md"
471
471
  body-class="gl-p-2!"
472
472
  >
473
473
  <gl-dropdown-item
@@ -504,7 +504,7 @@ export default {
504
504
  icon="paper-airplane"
505
505
  category="primary"
506
506
  variant="confirm"
507
- class="gl-absolute! gl-bottom-2 gl-right-2 gl-rounded-base!"
507
+ class="!gl-absolute gl-bottom-2 gl-right-2 gl-rounded-base!"
508
508
  type="submit"
509
509
  :aria-label="$options.i18n.CHAT_SUBMIT_LABEL"
510
510
  :disabled="isLoading"
@@ -58,11 +58,6 @@ you must copy the textarea field from the `DuoChatFeedbackModal` component into
58
58
  @feedback="logEvent"
59
59
  >
60
60
  <template #feedback-extra-fields>
61
- <div class="gl-mb-5">
62
- <gl-alert variant="info" :dismissible="false">
63
- GitLab team members can not see your conversation. Please be as descriptive as possible.
64
- </gl-alert>
65
- </div>
66
61
  <gl-form-group label="What were you doing?" optional>
67
62
  <gl-form-textarea
68
63
  placeholder="The situation in which you interacted with GitLab Duo Chat."
@@ -31,11 +31,11 @@ describe('UserFeedback', () => {
31
31
  const findButton = () => wrapper.findComponent(GlButton);
32
32
  const findModal = () => wrapper.findComponent(FeedbackModal);
33
33
 
34
- beforeEach(() => {
35
- createComponent();
36
- });
37
-
38
34
  describe('rendering with no feedback registered', () => {
35
+ beforeEach(() => {
36
+ createComponent();
37
+ });
38
+
39
39
  it('renders a button to provide feedback', () => {
40
40
  expect(findButton().exists()).toBe(true);
41
41
  });
@@ -65,6 +65,10 @@ describe('UserFeedback', () => {
65
65
  });
66
66
 
67
67
  describe('event handling', () => {
68
+ beforeEach(() => {
69
+ createComponent();
70
+ });
71
+
68
72
  const passedFeedback = { feedbackOptions: ['helpful'], extendedFeedback: 'Foo bar' };
69
73
 
70
74
  it('emits the event, containing the form data, when modal emits', () => {
@@ -87,6 +91,10 @@ describe('UserFeedback', () => {
87
91
  });
88
92
 
89
93
  describe('slots', () => {
94
+ beforeEach(() => {
95
+ createComponent();
96
+ });
97
+
90
98
  it('renders the `feedback-extra-fields` slot', () => {
91
99
  expect(wrapper.findComponent(DummyComponent).exists()).toBe(false);
92
100
  wrapper.destroy();
@@ -1,5 +1,6 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
2
  import GlModal from '../../../base/modal/modal.vue';
3
+ import GlAlert from '../../../base/alert/alert.vue';
3
4
  import GlFormCheckbox from '../../../base/form/form_checkbox/form_checkbox.vue';
4
5
  import GlFormCheckboxGroup from '../../../base/form/form_checkbox/form_checkbox_group.vue';
5
6
  import GlFormTextarea from '../../../base/form/form_textarea/form_textarea.vue';
@@ -11,7 +12,6 @@ const DummyComponent = {
11
12
 
12
13
  describe('FeedbackModal', () => {
13
14
  let wrapper;
14
-
15
15
  const findModal = () => wrapper.findComponent(GlModal);
16
16
  const findOptions = () => wrapper.findComponent('[data-testid="feedback-options"]');
17
17
  const findOptionsCheckboxes = () => findOptions().findAllComponents(GlFormCheckbox);
@@ -29,26 +29,33 @@ describe('FeedbackModal', () => {
29
29
  GlModal,
30
30
  GlFormCheckboxGroup,
31
31
  },
32
+ provide: options.injections,
32
33
  });
33
34
  };
34
35
 
35
- beforeEach(() => {
36
- createComponent();
37
- });
36
+ describe('inputs', () => {
37
+ beforeEach(() => {
38
+ createComponent();
39
+ });
38
40
 
39
- it('renders the feedback options', () => {
40
- const checkboxes = findOptionsCheckboxes();
41
- feedbackOptions.forEach((option, index) => {
42
- expect(checkboxes.at(index).text()).toBe(option.text);
43
- expect(checkboxes.at(index).attributes('value')).toBe(option.value);
41
+ it('renders the feedback options', () => {
42
+ const checkboxes = findOptionsCheckboxes();
43
+ feedbackOptions.forEach((option, index) => {
44
+ expect(checkboxes.at(index).text()).toBe(option.text);
45
+ expect(checkboxes.at(index).attributes('value')).toBe(option.value);
46
+ });
44
47
  });
45
- });
46
48
 
47
- it('renders the textarea field for additional feedback', () => {
48
- expect(findTextarea().exists()).toBe(true);
49
+ it('renders the textarea field for additional feedback', () => {
50
+ expect(findTextarea().exists()).toBe(true);
51
+ });
49
52
  });
50
53
 
51
54
  describe('interaction', () => {
55
+ beforeEach(() => {
56
+ createComponent();
57
+ });
58
+
52
59
  it('emits the feedback event when the submit button is clicked', () => {
53
60
  selectOption();
54
61
  findModal().vm.$emit('primary');
@@ -68,6 +75,10 @@ describe('FeedbackModal', () => {
68
75
  });
69
76
 
70
77
  describe('slots', () => {
78
+ beforeEach(() => {
79
+ createComponent();
80
+ });
81
+
71
82
  it('renders the `feedback-extra-fields` slot with default content', () => {
72
83
  expect(wrapper.findComponent(DummyComponent).exists()).toBe(false);
73
84
  expect(findTextarea().exists()).toBe(true);
@@ -78,4 +89,30 @@ describe('FeedbackModal', () => {
78
89
  expect(findTextarea().exists()).toBe(false);
79
90
  });
80
91
  });
92
+
93
+ describe('injections', () => {
94
+ it('should pass modalTitle when set as injection', () => {
95
+ const customTitle = 'Custom Feedback Title';
96
+ createComponent({ injections: { modalTitle: customTitle } });
97
+ expect(findModal().props('title')).toBe(customTitle);
98
+ });
99
+
100
+ it('should pass modalTitle default when injection not set', () => {
101
+ createComponent();
102
+ expect(findModal().props('title')).toBe('Give feedback on GitLab Duo');
103
+ });
104
+
105
+ it('should pass modalAlert when set as injection', () => {
106
+ const customAlert = 'Custom Alert Message';
107
+ createComponent({ injections: { modalAlert: customAlert } });
108
+ expect(wrapper.findComponent(GlAlert).text()).toBe(customAlert);
109
+ });
110
+
111
+ it('should render modalAlert default when injection not set', () => {
112
+ createComponent();
113
+ expect(wrapper.findComponent(GlAlert).text()).toBe(
114
+ 'GitLab team members cannot see the AI content. Please be as descriptive as possible.'
115
+ );
116
+ });
117
+ });
81
118
  });
@@ -1,53 +1,61 @@
1
1
  <script>
2
2
  import GlModal from '../../../base/modal/modal.vue';
3
+ import GlAlert from '../../../base/alert/alert.vue';
3
4
  import GlFormGroup from '../../../base/form/form_group/form_group.vue';
4
5
  import GlFormTextarea from '../../../base/form/form_textarea/form_textarea.vue';
5
6
  import GlFormCheckboxGroup from '../../../base/form/form_checkbox/form_checkbox_group.vue';
6
7
 
7
8
  export const i18n = {
8
- MODAL_TITLE: 'Give feedback on AI content',
9
- MODAL_DESCRIPTION:
10
- 'To help improve the quality of the content, send your feedback to GitLab team members.',
11
- MODAL_OPTIONS_LABEL: 'How was the AI content?',
12
- MODAL_MORE_LABEL: 'More information',
13
- MODAL_MORE_PLACEHOLDER: 'How could the content be improved?',
14
- MODAL_FEEDBACK_OPTIONS: {
15
- helpful: 'Helpful',
16
- unhelpful: 'Unhelpful or irrelevant',
17
- incorrect: 'Factually incorrect',
18
- long: 'Too long',
19
- abuse: 'Abusive or offensive',
20
- other: 'Something else',
21
- },
22
- MODAL_ACTIONS: {
23
- submit: 'Submit',
24
- cancel: 'Cancel',
9
+ MODAL: {
10
+ TITLE: 'Give feedback on GitLab Duo',
11
+ DESCRIPTION: 'To help improve GitLab Duo, send your feeback to GitLab team members.',
12
+ ALERT: 'GitLab team members cannot see the AI content. Please be as descriptive as possible.',
13
+ OPTIONS_LABEL: 'How could the AI content be improved?',
14
+ SITUATION_DESCRIPTION_LABEL: 'What were you doing?',
15
+ SITUATION_DESCRIPTION_PLACEHOLDER:
16
+ 'The situation in which you interacted with GitLab Duo Chat.',
17
+ IMPROVEMENT_SUGGESTION_LABEL: 'How could the response be improved?',
18
+ IMPROVEMENT_SUGGESTION_PLACEHOLDER: 'How the response might better meet your needs.',
19
+ MORE_LABEL: 'More information',
20
+ MORE_PLACEHOLDER: 'How could the content be improved?',
21
+ FEEDBACK_OPTIONS: {
22
+ helpful: 'Helpful',
23
+ unhelpful: 'Unhelpful or irrelevant',
24
+ incorrect: 'Factually incorrect',
25
+ long: 'Too long',
26
+ abuse: 'Abusive or offensive',
27
+ other: 'Something else',
28
+ },
29
+ ACTIONS: {
30
+ submit: 'Submit',
31
+ cancel: 'Cancel',
32
+ },
25
33
  },
26
34
  };
27
35
 
28
36
  export const feedbackOptions = [
29
37
  {
30
- text: i18n.MODAL_FEEDBACK_OPTIONS.helpful,
38
+ text: i18n.MODAL.FEEDBACK_OPTIONS.helpful,
31
39
  value: 'helpful',
32
40
  },
33
41
  {
34
- text: i18n.MODAL_FEEDBACK_OPTIONS.unhelpful,
42
+ text: i18n.MODAL.FEEDBACK_OPTIONS.unhelpful,
35
43
  value: 'unhelpful',
36
44
  },
37
45
  {
38
- text: i18n.MODAL_FEEDBACK_OPTIONS.incorrect,
46
+ text: i18n.MODAL.FEEDBACK_OPTIONS.incorrect,
39
47
  value: 'incorrect',
40
48
  },
41
49
  {
42
- text: i18n.MODAL_FEEDBACK_OPTIONS.long,
50
+ text: i18n.MODAL.FEEDBACK_OPTIONS.long,
43
51
  value: 'long',
44
52
  },
45
53
  {
46
- text: i18n.MODAL_FEEDBACK_OPTIONS.abuse,
54
+ text: i18n.MODAL.FEEDBACK_OPTIONS.abuse,
47
55
  value: 'abuse',
48
56
  },
49
57
  {
50
- text: i18n.MODAL_FEEDBACK_OPTIONS.other,
58
+ text: i18n.MODAL.FEEDBACK_OPTIONS.other,
51
59
  value: 'other',
52
60
  },
53
61
  ];
@@ -56,10 +64,19 @@ export default {
56
64
  name: 'DuoChatFeedbackModal',
57
65
  components: {
58
66
  GlModal,
67
+ GlAlert,
59
68
  GlFormCheckboxGroup,
60
69
  GlFormGroup,
61
70
  GlFormTextarea,
62
71
  },
72
+ inject: {
73
+ modalTitle: {
74
+ default: i18n.MODAL.TITLE,
75
+ },
76
+ modalAlert: {
77
+ default: i18n.MODAL.ALERT,
78
+ },
79
+ },
63
80
  data() {
64
81
  return {
65
82
  selectedFeedbackOptions: [],
@@ -84,10 +101,10 @@ export default {
84
101
  },
85
102
  actions: {
86
103
  primary: {
87
- text: i18n.MODAL_ACTIONS.submit,
104
+ text: i18n.MODAL.ACTIONS.submit,
88
105
  },
89
106
  cancel: {
90
- text: i18n.MODAL_ACTIONS.cancel,
107
+ text: i18n.MODAL.ACTIONS.cancel,
91
108
  },
92
109
  },
93
110
  feedbackOptions,
@@ -98,7 +115,7 @@ export default {
98
115
  <gl-modal
99
116
  ref="feedbackModal"
100
117
  modal-id="feedbackModal"
101
- :title="$options.i18n.MODAL_TITLE"
118
+ :title="modalTitle"
102
119
  :action-primary="$options.actions.primary"
103
120
  :action-cancel="$options.actions.cancel"
104
121
  :visible="false"
@@ -106,9 +123,9 @@ export default {
106
123
  @primary="onFeedbackSubmit"
107
124
  @canceled="onFeedbackCanceled"
108
125
  >
109
- <p>{{ $options.i18n.MODAL_DESCRIPTION }}</p>
126
+ <p>{{ $options.i18n.MODAL.DESCRIPTION }}</p>
110
127
  <gl-form-group
111
- :label="$options.i18n.MODAL_OPTIONS_LABEL"
128
+ :label="$options.i18n.MODAL.OPTIONS_LABEL"
112
129
  :optional="false"
113
130
  data-testid="feedback-options"
114
131
  >
@@ -117,13 +134,13 @@ export default {
117
134
  :options="$options.feedbackOptions"
118
135
  />
119
136
  </gl-form-group>
120
-
137
+ <gl-alert class="gl-mb-5" :dismissible="false">{{ modalAlert }}</gl-alert>
121
138
  <!-- @slot The addition Feedback form fields. -->
122
139
  <slot name="feedback-extra-fields">
123
- <gl-form-group :label="$options.i18n.MODAL_MORE_LABEL" optional>
140
+ <gl-form-group :label="$options.i18n.MODAL.MORE_LABEL" optional>
124
141
  <gl-form-textarea
125
142
  v-model="extendedFeedback"
126
- :placeholder="$options.i18n.MODAL_MORE_PLACEHOLDER"
143
+ :placeholder="$options.i18n.MODAL.MORE_PLACEHOLDER"
127
144
  />
128
145
  </gl-form-group>
129
146
  </slot>
@@ -0,0 +1 @@
1
+ @tailwind utilities;