@gitlab/ui 72.12.0 → 72.12.1
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 +7 -0
- package/dist/charts.js +14 -0
- package/dist/components/base/accordion/accordion.js +73 -0
- package/dist/components/base/accordion/accordion_item.js +133 -0
- package/dist/components/base/alert/alert.js +222 -0
- package/dist/components/base/avatar/avatar.js +160 -0
- package/dist/components/base/avatar_labeled/avatar_labeled.js +107 -0
- package/dist/components/base/avatar_link/avatar_link.js +47 -0
- package/dist/components/base/avatars_inline/avatars_inline.js +119 -0
- package/dist/components/base/badge/badge.js +105 -0
- package/dist/components/base/banner/banner.js +139 -0
- package/dist/components/base/breadcrumb/breadcrumb.js +122 -0
- package/dist/components/base/breadcrumb/breadcrumb_item.js +73 -0
- package/dist/components/base/broadcast_message/broadcast_message.js +112 -0
- package/dist/components/base/broadcast_message/constants.js +5 -0
- package/dist/components/base/button/button.js +151 -0
- package/dist/components/base/button_group/button_group.js +47 -0
- package/dist/components/base/card/card.js +71 -0
- package/dist/components/base/carousel/carousel.js +48 -0
- package/dist/components/base/carousel/carousel_slide.js +47 -0
- package/dist/components/base/collapse/collapse.js +59 -0
- package/dist/components/base/datepicker/datepicker.js +386 -0
- package/dist/components/base/daterange_picker/daterange_picker.js +288 -0
- package/dist/components/base/drawer/drawer.js +127 -0
- package/dist/components/base/dropdown/dropdown.js +261 -0
- package/dist/components/base/dropdown/dropdown_divider.js +48 -0
- package/dist/components/base/dropdown/dropdown_form.js +48 -0
- package/dist/components/base/dropdown/dropdown_item.js +131 -0
- package/dist/components/base/dropdown/dropdown_section_header.js +48 -0
- package/dist/components/base/dropdown/dropdown_text.js +48 -0
- package/dist/components/base/filtered_search/common_story_options.js +14 -0
- package/dist/components/base/filtered_search/filtered_search.js +388 -0
- package/dist/components/base/filtered_search/filtered_search_suggestion.js +89 -0
- package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +138 -0
- package/dist/components/base/filtered_search/filtered_search_term.js +203 -0
- package/dist/components/base/filtered_search/filtered_search_token.js +384 -0
- package/dist/components/base/filtered_search/filtered_search_token_segment.js +420 -0
- package/dist/components/base/filtered_search/filtered_search_utils.js +242 -0
- package/dist/components/base/form/form.js +49 -0
- package/dist/components/base/form/form_checkbox/form_checkbox.js +78 -0
- package/dist/components/base/form/form_checkbox/form_checkbox_group.js +60 -0
- package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +79 -0
- package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +138 -0
- package/dist/components/base/form/form_checkbox_tree/models/constants.js +12 -0
- package/dist/components/base/form/form_checkbox_tree/models/node.js +51 -0
- package/dist/components/base/form/form_checkbox_tree/models/tree.js +199 -0
- package/dist/components/base/form/form_combobox/constants.js +55 -0
- package/dist/components/base/form/form_combobox/form_combobox.js +230 -0
- package/dist/components/base/form/form_date/form_date.js +143 -0
- package/dist/components/base/form/form_fields/form_field_validator.js +93 -0
- package/dist/components/base/form/form_fields/form_fields.js +214 -0
- package/dist/components/base/form/form_fields/mappers.js +13 -0
- package/dist/components/base/form/form_fields/validators.js +48 -0
- package/dist/components/base/form/form_group/form_group.js +97 -0
- package/dist/components/base/form/form_input/form_input.js +121 -0
- package/dist/components/base/form/form_input_group/form_input_group.js +108 -0
- package/dist/components/base/form/form_input_group/form_input_group_mixin.js +41 -0
- package/dist/components/base/form/form_radio/form_radio.js +65 -0
- package/dist/components/base/form/form_radio_group/form_radio_group.js +78 -0
- package/dist/components/base/form/form_select/constants.js +12 -0
- package/dist/components/base/form/form_select/form_select.js +82 -0
- package/dist/components/base/form/form_text/form_text.js +38 -0
- package/dist/components/base/form/form_textarea/form_textarea.js +112 -0
- package/dist/components/base/form/input_group_text/input_group_text.js +48 -0
- package/dist/components/base/icon/icon.js +111 -0
- package/dist/components/base/infinite_scroll/infinite_scroll.js +197 -0
- package/dist/components/base/keyset_pagination/keyset_pagination.js +151 -0
- package/dist/components/base/label/label.js +163 -0
- package/dist/components/base/link/link.js +50 -0
- package/dist/components/base/loading_icon/loading_icon.js +111 -0
- package/dist/components/base/markdown/markdown.js +52 -0
- package/dist/components/base/modal/modal.js +204 -0
- package/dist/components/base/nav/nav.js +48 -0
- package/dist/components/base/nav/nav_item.js +48 -0
- package/dist/components/base/nav/nav_item_dropdown.js +62 -0
- package/dist/components/base/navbar/navbar.js +48 -0
- package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +453 -0
- package/dist/components/base/new_dropdowns/base_dropdown/constants.js +4 -0
- package/dist/components/base/new_dropdowns/constants.js +21 -0
- package/dist/components/base/new_dropdowns/disclosure/constants.js +8 -0
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown.js +370 -0
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_group.js +110 -0
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_item.js +143 -0
- package/dist/components/base/new_dropdowns/disclosure/mock_data.js +147 -0
- package/dist/components/base/new_dropdowns/disclosure/utils.js +39 -0
- package/dist/components/base/new_dropdowns/listbox/listbox.js +767 -0
- package/dist/components/base/new_dropdowns/listbox/listbox_group.js +58 -0
- package/dist/components/base/new_dropdowns/listbox/listbox_item.js +91 -0
- package/dist/components/base/new_dropdowns/listbox/listbox_search_input.js +93 -0
- package/dist/components/base/new_dropdowns/listbox/mock_data.js +118 -0
- package/dist/components/base/new_dropdowns/listbox/utils.js +34 -0
- package/dist/components/base/paginated_list/paginated_list.js +180 -0
- package/dist/components/base/pagination/pagination.js +399 -0
- package/dist/components/base/path/data.js +34 -0
- package/dist/components/base/path/path.js +189 -0
- package/dist/components/base/popover/popover.js +110 -0
- package/dist/components/base/progress_bar/progress_bar.js +48 -0
- package/dist/components/base/search_box_by_click/search_box_by_click.js +235 -0
- package/dist/components/base/search_box_by_type/search_box_by_type.js +167 -0
- package/dist/components/base/segmented_control/segmented_control.js +109 -0
- package/dist/components/base/skeleton_loader/skeleton_loader.js +224 -0
- package/dist/components/base/sorting/sorting.js +171 -0
- package/dist/components/base/sorting/sorting_item.js +109 -0
- package/dist/components/base/table/constants.js +5 -0
- package/dist/components/base/table/table.js +89 -0
- package/dist/components/base/table_lite/table_lite.js +72 -0
- package/dist/components/base/tabs/constants.js +3 -0
- package/dist/components/base/tabs/tab/tab.js +83 -0
- package/dist/components/base/tabs/tabs/scrollable_tabs.js +143 -0
- package/dist/components/base/tabs/tabs/tabs.js +224 -0
- package/dist/components/base/toast/toast.js +82 -0
- package/dist/components/base/toggle/toggle.js +180 -0
- package/dist/components/base/token/token.js +85 -0
- package/dist/components/base/token_selector/helpers.js +5 -0
- package/dist/components/base/token_selector/token_container.js +165 -0
- package/dist/components/base/token_selector/token_selector.js +403 -0
- package/dist/components/base/token_selector/token_selector_dropdown.js +199 -0
- package/dist/components/base/tooltip/tooltip.js +55 -0
- package/dist/components/charts/area/area.js +311 -0
- package/dist/components/charts/bar/bar.js +253 -0
- package/dist/components/charts/chart/chart.js +215 -0
- package/dist/components/charts/column/column.js +226 -0
- package/dist/components/charts/discrete_scatter/discrete_scatter.js +203 -0
- package/dist/components/charts/gauge/gauge.js +208 -0
- package/dist/components/charts/heatmap/heatmap.js +295 -0
- package/dist/components/charts/heatmap/index.js +2 -0
- package/dist/components/charts/legend/legend.js +228 -0
- package/dist/components/charts/line/line.js +308 -0
- package/dist/components/charts/series_label/series_label.js +100 -0
- package/dist/components/charts/single_stat/single_stat.js +152 -0
- package/dist/components/charts/sparkline/sparkline.js +261 -0
- package/dist/components/charts/stacked_column/stacked_column.js +335 -0
- package/dist/components/charts/tooltip/tooltip.js +251 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.js +83 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.js +100 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +35 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +115 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.js +104 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.js +64 -0
- package/dist/components/experimental/duo/chat/constants.js +23 -0
- package/dist/components/experimental/duo/chat/duo_chat.js +359 -0
- package/dist/components/experimental/duo/chat/mock_data.js +83 -0
- package/dist/components/experimental/duo/user_feedback/user_feedback.js +94 -0
- package/dist/components/experimental/duo/user_feedback/user_feedback_modal.js +124 -0
- package/dist/components/experimental/experiment_badge/constants.js +4 -0
- package/dist/components/experimental/experiment_badge/experiment_badge.js +107 -0
- package/dist/components/mixins/button_mixin.js +11 -0
- package/dist/components/mixins/safe_link_mixin.js +30 -0
- package/dist/components/mixins/tooltip_mixin.js +21 -0
- package/dist/components/regions/dashboard_skeleton/dashboard_skeleton.js +53 -0
- package/dist/components/regions/empty_state/empty_state.js +154 -0
- package/dist/components/shared_components/charts/tooltip_default_format.js +53 -0
- package/dist/components/shared_components/clear_icon_button/clear_icon_button.js +64 -0
- package/dist/components/shared_components/close_button/close_button.js +54 -0
- package/dist/components/utilities/animated_number/animated_number.js +131 -0
- package/dist/components/utilities/friendly_wrap/friendly_wrap.js +75 -0
- package/dist/components/utilities/intersection_observer/intersection_observer.js +88 -0
- package/dist/components/utilities/intersperse/intersperse.js +86 -0
- package/dist/components/utilities/sprintf/sprintf.js +172 -0
- package/dist/components/utilities/truncate/constants.js +7 -0
- package/dist/components/utilities/truncate/truncate.js +111 -0
- package/dist/components/utilities/truncate_text/constants.js +7 -0
- package/dist/components/utilities/truncate_text/truncate_text.js +146 -0
- package/dist/config.js +86 -0
- package/dist/directives/collapse_toggle.js +1 -0
- package/dist/directives/hover_load/hover_load.js +45 -0
- package/dist/directives/modal.js +1 -0
- package/dist/directives/outside/get_event_like_time_stamp.js +33 -0
- package/dist/directives/outside/outside.js +106 -0
- package/dist/directives/resize_observer/resize_observer.js +51 -0
- package/dist/directives/safe_html/constants.js +6 -0
- package/dist/directives/safe_html/safe_html.js +39 -0
- package/dist/directives/safe_link/mock_data.js +10 -0
- package/dist/directives/safe_link/safe_link.js +65 -0
- package/dist/directives/tooltip.js +1 -0
- package/dist/index.css +7 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +105 -0
- package/dist/tokens/common_story_options.js +54 -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/dist/utils/breakpoints.js +20 -0
- package/dist/utils/charts/config.js +556 -0
- package/dist/utils/charts/constants.js +63 -0
- package/dist/utils/charts/mock_data.js +211 -0
- package/dist/utils/charts/story_config.js +42 -0
- package/dist/utils/charts/theme.js +192 -0
- package/dist/utils/charts/utils.js +54 -0
- package/dist/utils/constants.js +288 -0
- package/dist/utils/data_utils.js +21 -0
- package/dist/utils/datetime_utility.js +61 -0
- package/dist/utils/i18n.js +15 -0
- package/dist/utils/is_slot_empty.js +38 -0
- package/dist/utils/number_utils.js +124 -0
- package/dist/utils/stories_constants.js +29 -0
- package/dist/utils/stories_utils.js +13 -0
- package/dist/utils/story_decorators/container.js +16 -0
- package/dist/utils/string_utils.js +69 -0
- package/dist/utils/svgs/svg_paths.js +7 -0
- package/dist/utils/test_utils.js +33 -0
- package/dist/utils/use_fake_date.js +29 -0
- package/dist/utils/use_mock_intersection_observer.js +108 -0
- package/dist/utils/utils.js +197 -0
- package/dist/utils.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import throttle from 'lodash/throttle';
|
|
2
|
+
import emptySvg from '@gitlab/svgs/dist/illustrations/empty-state/empty-activity-md.svg';
|
|
3
|
+
import GlDropdownItem from '../../../base/dropdown/dropdown_item';
|
|
4
|
+
import GlCard from '../../../base/card/card';
|
|
5
|
+
import GlEmptyState from '../../../regions/empty_state/empty_state';
|
|
6
|
+
import GlButton from '../../../base/button/button';
|
|
7
|
+
import GlAlert from '../../../base/alert/alert';
|
|
8
|
+
import GlFormInputGroup from '../../../base/form/form_input_group/form_input_group';
|
|
9
|
+
import GlFormTextarea from '../../../base/form/form_textarea/form_textarea';
|
|
10
|
+
import GlForm from '../../../base/form/form';
|
|
11
|
+
import GlFormText from '../../../base/form/form_text/form_text';
|
|
12
|
+
import GlExperimentBadge from '../../experiment_badge/experiment_badge';
|
|
13
|
+
import { badgeTypes, badgeTypeValidator } from '../../experiment_badge/constants';
|
|
14
|
+
import { SafeHtmlDirective } from '../../../../directives/safe_html/safe_html';
|
|
15
|
+
import GlDuoChatLoader from './components/duo_chat_loader/duo_chat_loader';
|
|
16
|
+
import GlDuoChatPredefinedPrompts from './components/duo_chat_predefined_prompts/duo_chat_predefined_prompts';
|
|
17
|
+
import GlDuoChatConversation from './components/duo_chat_conversation/duo_chat_conversation';
|
|
18
|
+
import { CHAT_RESET_MESSAGE } from './constants';
|
|
19
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
20
|
+
|
|
21
|
+
const i18n = {
|
|
22
|
+
CHAT_DEFAULT_TITLE: 'GitLab Duo Chat',
|
|
23
|
+
CHAT_CLOSE_LABEL: 'Close the Code Explanation',
|
|
24
|
+
CHAT_LEGAL_GENERATED_BY_AI: 'Responses generated by AI',
|
|
25
|
+
CHAT_EMPTY_STATE_TITLE: 'Ask a question',
|
|
26
|
+
CHAT_EMPTY_STATE_DESC: 'AI generated explanations will appear here.',
|
|
27
|
+
CHAT_PROMPT_PLACEHOLDER_DEFAULT: 'GitLab Duo Chat',
|
|
28
|
+
CHAT_PROMPT_PLACEHOLDER_WITH_COMMANDS: 'Type "/" for slash commands',
|
|
29
|
+
CHAT_SUBMIT_LABEL: 'Send chat message.',
|
|
30
|
+
CHAT_LEGAL_DISCLAIMER: "May provide inappropriate responses not representative of GitLab's views. Do not input personal data.",
|
|
31
|
+
CHAT_DEFAULT_PREDEFINED_PROMPTS: ['How do I change my password in GitLab?', 'How do I fork a project?', 'How do I clone a repository?', 'How do I create a template?']
|
|
32
|
+
};
|
|
33
|
+
const slashCommands = [{
|
|
34
|
+
name: '/reset',
|
|
35
|
+
shouldSubmit: true,
|
|
36
|
+
description: 'Reset conversation, ignore the previous messages.'
|
|
37
|
+
}, {
|
|
38
|
+
name: '/tests',
|
|
39
|
+
shouldSubmit: false,
|
|
40
|
+
description: 'Write tests for the selected snippet.'
|
|
41
|
+
}, {
|
|
42
|
+
name: '/refactor',
|
|
43
|
+
shouldSubmit: false,
|
|
44
|
+
description: 'Refactor the selected snippet.'
|
|
45
|
+
}, {
|
|
46
|
+
name: '/explain',
|
|
47
|
+
shouldSubmit: false,
|
|
48
|
+
description: 'Explain the selected snippet.'
|
|
49
|
+
}];
|
|
50
|
+
const isMessage = item => Boolean(item) && (item === null || item === void 0 ? void 0 : item.role);
|
|
51
|
+
|
|
52
|
+
// eslint-disable-next-line unicorn/no-array-callback-reference
|
|
53
|
+
const itemsValidator = items => items.every(isMessage);
|
|
54
|
+
var script = {
|
|
55
|
+
name: 'GlDuoChat',
|
|
56
|
+
components: {
|
|
57
|
+
GlEmptyState,
|
|
58
|
+
GlButton,
|
|
59
|
+
GlAlert,
|
|
60
|
+
GlFormInputGroup,
|
|
61
|
+
GlFormTextarea,
|
|
62
|
+
GlForm,
|
|
63
|
+
GlFormText,
|
|
64
|
+
GlExperimentBadge,
|
|
65
|
+
GlDuoChatLoader,
|
|
66
|
+
GlDuoChatPredefinedPrompts,
|
|
67
|
+
GlDuoChatConversation,
|
|
68
|
+
GlCard,
|
|
69
|
+
GlDropdownItem
|
|
70
|
+
},
|
|
71
|
+
directives: {
|
|
72
|
+
SafeHtml: SafeHtmlDirective
|
|
73
|
+
},
|
|
74
|
+
props: {
|
|
75
|
+
/**
|
|
76
|
+
* The title of the chat/feature.
|
|
77
|
+
*/
|
|
78
|
+
title: {
|
|
79
|
+
type: String,
|
|
80
|
+
required: false,
|
|
81
|
+
default: i18n.CHAT_DEFAULT_TITLE
|
|
82
|
+
},
|
|
83
|
+
/**
|
|
84
|
+
* Array of messages to display in the chat.
|
|
85
|
+
*/
|
|
86
|
+
messages: {
|
|
87
|
+
type: Array,
|
|
88
|
+
required: false,
|
|
89
|
+
default: () => [],
|
|
90
|
+
validator: itemsValidator
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* A non-recoverable error message to display in the chat.
|
|
94
|
+
*/
|
|
95
|
+
error: {
|
|
96
|
+
type: String,
|
|
97
|
+
required: false,
|
|
98
|
+
default: ''
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* Whether the chat is currently fetching a response from AI.
|
|
102
|
+
*/
|
|
103
|
+
isLoading: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
required: false,
|
|
106
|
+
default: false
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* Whether the conversational interfaces should be enabled.
|
|
110
|
+
*/
|
|
111
|
+
isChatAvailable: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
required: false,
|
|
114
|
+
default: true
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* Array of predefined prompts to display in the chat to start a conversation.
|
|
118
|
+
*/
|
|
119
|
+
predefinedPrompts: {
|
|
120
|
+
type: Array,
|
|
121
|
+
required: false,
|
|
122
|
+
default: () => i18n.CHAT_DEFAULT_PREDEFINED_PROMPTS
|
|
123
|
+
},
|
|
124
|
+
/**
|
|
125
|
+
* URL to the help page. This is passed down to the `GlExperimentBadge` component.
|
|
126
|
+
*/
|
|
127
|
+
badgeHelpPageUrl: {
|
|
128
|
+
type: String,
|
|
129
|
+
required: false,
|
|
130
|
+
default: ''
|
|
131
|
+
},
|
|
132
|
+
/**
|
|
133
|
+
* The type of the badge. This is passed down to the `GlExperimentBadge` component. Refer that component for more information.
|
|
134
|
+
*/
|
|
135
|
+
badgeType: {
|
|
136
|
+
type: String,
|
|
137
|
+
required: false,
|
|
138
|
+
default: badgeTypes[0],
|
|
139
|
+
validator: badgeTypeValidator
|
|
140
|
+
},
|
|
141
|
+
/**
|
|
142
|
+
* The current tool's name to display in the loading message while waiting for a response from AI. Refer the `GlDuoChatLoader` component for more information.
|
|
143
|
+
*/
|
|
144
|
+
toolName: {
|
|
145
|
+
type: String,
|
|
146
|
+
required: false,
|
|
147
|
+
default: i18n.CHAT_DEFAULT_TITLE
|
|
148
|
+
},
|
|
149
|
+
/**
|
|
150
|
+
* Whether the slash commands should be available to user when typing the prompt.
|
|
151
|
+
*/
|
|
152
|
+
withSlashCommands: {
|
|
153
|
+
type: Boolean,
|
|
154
|
+
required: false,
|
|
155
|
+
default: false
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
data() {
|
|
159
|
+
return {
|
|
160
|
+
isHidden: false,
|
|
161
|
+
prompt: '',
|
|
162
|
+
scrolledToBottom: true,
|
|
163
|
+
activeCommandIndex: 0
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
computed: {
|
|
167
|
+
hasMessages() {
|
|
168
|
+
var _this$messages;
|
|
169
|
+
return ((_this$messages = this.messages) === null || _this$messages === void 0 ? void 0 : _this$messages.length) > 0;
|
|
170
|
+
},
|
|
171
|
+
conversations() {
|
|
172
|
+
if (!this.hasMessages) return [];
|
|
173
|
+
return this.messages.reduce((acc, message) => {
|
|
174
|
+
if (message.content === CHAT_RESET_MESSAGE) {
|
|
175
|
+
acc.push([]);
|
|
176
|
+
} else {
|
|
177
|
+
acc[acc.length - 1].push(message);
|
|
178
|
+
}
|
|
179
|
+
return acc;
|
|
180
|
+
}, [[]]);
|
|
181
|
+
},
|
|
182
|
+
resetDisabled() {
|
|
183
|
+
if (this.isLoading || !this.hasMessages) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
const lastMessage = this.messages[this.messages.length - 1];
|
|
187
|
+
return lastMessage.content === CHAT_RESET_MESSAGE;
|
|
188
|
+
},
|
|
189
|
+
filteredSlashCommands() {
|
|
190
|
+
const caseInsensitivePrompt = this.prompt.toLowerCase();
|
|
191
|
+
return slashCommands.filter(c => c.name.toLowerCase().startsWith(caseInsensitivePrompt));
|
|
192
|
+
},
|
|
193
|
+
shouldShowSlashCommands() {
|
|
194
|
+
if (!this.withSlashCommands) return false;
|
|
195
|
+
const caseInsensitivePrompt = this.prompt.toLowerCase();
|
|
196
|
+
const startsWithSlash = caseInsensitivePrompt.startsWith('/');
|
|
197
|
+
const startsWithSlashCommand = slashCommands.some(c => caseInsensitivePrompt.startsWith(c.name));
|
|
198
|
+
return startsWithSlash && this.filteredSlashCommands.length && !startsWithSlashCommand;
|
|
199
|
+
},
|
|
200
|
+
inputPlaceholder() {
|
|
201
|
+
return this.withSlashCommands ? i18n.CHAT_PROMPT_PLACEHOLDER_WITH_COMMANDS : i18n.CHAT_PROMPT_PLACEHOLDER_DEFAULT;
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
watch: {
|
|
205
|
+
isLoading() {
|
|
206
|
+
this.isHidden = false;
|
|
207
|
+
this.scrollToBottom();
|
|
208
|
+
},
|
|
209
|
+
messages() {
|
|
210
|
+
this.prompt = '';
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
created() {
|
|
214
|
+
this.handleScrollingTrottled = throttle(this.handleScrolling, 200); // Assume a 200ms throttle for example
|
|
215
|
+
},
|
|
216
|
+
mounted() {
|
|
217
|
+
this.scrollToBottom();
|
|
218
|
+
},
|
|
219
|
+
methods: {
|
|
220
|
+
hideChat() {
|
|
221
|
+
this.isHidden = true;
|
|
222
|
+
/**
|
|
223
|
+
* Emitted when clicking the cross in the title and the chat gets closed.
|
|
224
|
+
*/
|
|
225
|
+
this.$emit('chat-hidden');
|
|
226
|
+
},
|
|
227
|
+
sendChatPrompt() {
|
|
228
|
+
if (this.prompt) {
|
|
229
|
+
if (this.prompt === CHAT_RESET_MESSAGE && this.resetDisabled) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Emitted when a new user prompt should be sent out.
|
|
234
|
+
*
|
|
235
|
+
* @param {String} prompt The user prompt to send.
|
|
236
|
+
*/
|
|
237
|
+
this.$emit('send-chat-prompt', this.prompt);
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
sendPredefinedPrompt(prompt) {
|
|
241
|
+
this.prompt = prompt;
|
|
242
|
+
this.sendChatPrompt();
|
|
243
|
+
},
|
|
244
|
+
handleScrolling() {
|
|
245
|
+
const {
|
|
246
|
+
scrollTop,
|
|
247
|
+
offsetHeight,
|
|
248
|
+
scrollHeight
|
|
249
|
+
} = this.$refs.drawer;
|
|
250
|
+
this.scrolledToBottom = scrollTop + offsetHeight >= scrollHeight;
|
|
251
|
+
},
|
|
252
|
+
async scrollToBottom() {
|
|
253
|
+
await this.$nextTick();
|
|
254
|
+
if (this.$refs.drawer) {
|
|
255
|
+
this.$refs.drawer.scrollTop = this.$refs.drawer.scrollHeight;
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
onTrackFeedback(event) {
|
|
259
|
+
/**
|
|
260
|
+
* Notify listeners about the feedback form submission on a response message.
|
|
261
|
+
* @param {*} event An event, containing the feedback choices and the extended feedback text.
|
|
262
|
+
*/
|
|
263
|
+
this.$emit('track-feedback', event);
|
|
264
|
+
},
|
|
265
|
+
onInputKeyup(e) {
|
|
266
|
+
const {
|
|
267
|
+
metaKey,
|
|
268
|
+
ctrlKey,
|
|
269
|
+
altKey,
|
|
270
|
+
shiftKey
|
|
271
|
+
} = e;
|
|
272
|
+
if (this.shouldShowSlashCommands) {
|
|
273
|
+
e.preventDefault();
|
|
274
|
+
if (e.key === 'Enter') {
|
|
275
|
+
this.selectSlashCommand(this.activeCommandIndex);
|
|
276
|
+
} else if (e.key === 'ArrowUp') {
|
|
277
|
+
this.prevCommand();
|
|
278
|
+
} else if (e.key === 'ArrowDown') {
|
|
279
|
+
this.nextCommand();
|
|
280
|
+
} else {
|
|
281
|
+
this.activeCommandIndex = 0;
|
|
282
|
+
}
|
|
283
|
+
} else if (e.key === 'Enter' && !(metaKey || ctrlKey || altKey || shiftKey)) {
|
|
284
|
+
e.preventDefault();
|
|
285
|
+
this.sendChatPrompt();
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
prevCommand() {
|
|
289
|
+
this.activeCommandIndex -= 1;
|
|
290
|
+
this.wrapCommandIndex();
|
|
291
|
+
},
|
|
292
|
+
nextCommand() {
|
|
293
|
+
this.activeCommandIndex += 1;
|
|
294
|
+
this.wrapCommandIndex();
|
|
295
|
+
},
|
|
296
|
+
wrapCommandIndex() {
|
|
297
|
+
if (this.activeCommandIndex < 0) {
|
|
298
|
+
this.activeCommandIndex = this.filteredSlashCommands.length - 1;
|
|
299
|
+
} else if (this.activeCommandIndex >= this.filteredSlashCommands.length) {
|
|
300
|
+
this.activeCommandIndex = 0;
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
selectSlashCommand(index) {
|
|
304
|
+
const command = this.filteredSlashCommands[index];
|
|
305
|
+
if (command.shouldSubmit) {
|
|
306
|
+
this.prompt = command.name;
|
|
307
|
+
this.sendChatPrompt();
|
|
308
|
+
} else {
|
|
309
|
+
this.prompt = `${command.name} `;
|
|
310
|
+
this.$refs.prompt.$el.focus();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
i18n,
|
|
315
|
+
emptySvg
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
/* script */
|
|
319
|
+
const __vue_script__ = script;
|
|
320
|
+
|
|
321
|
+
/* template */
|
|
322
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (!_vm.isHidden)?_c('aside',{ref:"drawer",staticClass:"markdown-code-block gl-drawer gl-drawer-default gl-max-h-full gl-bottom-0 gl-shadow-none gl-border-l gl-border-t duo-chat",attrs:{"id":"chat-component","role":"complementary","data-testid":"chat-component"},on:{"scroll":_vm.handleScrollingTrottled}},[_c('header',{staticClass:"gl-drawer-header gl-drawer-header-sticky gl-z-index-200 gl-p-0! gl-border-b-0"},[_c('div',{staticClass:"drawer-title gl-display-flex gl-justify-content-start gl-align-items-center gl-p-5"},[_c('h3',{staticClass:"gl-my-0 gl-font-size-h2"},[_vm._v(_vm._s(_vm.title))]),_vm._v(" "),_c('gl-experiment-badge',{attrs:{"help-page-url":_vm.badgeHelpPageUrl,"type":_vm.badgeType,"container-id":"chat-component"}}),_vm._v(" "),_c('gl-button',{staticClass:"gl-p-0! 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":_vm.hideChat}})],1),_vm._v(" "),_c('gl-alert',{staticClass:"gl-text-center gl-border-t gl-p-4 gl-text-gray-700 gl-bg-gray-50 legal-warning gl-max-w-full",attrs:{"dismissible":false,"variant":"tip","show-icon":false,"role":"alert","data-testid":"chat-legal-warning"}},[_vm._v(_vm._s(_vm.$options.i18n.CHAT_LEGAL_GENERATED_BY_AI))]),_vm._v(" "),_vm._t("subheader")],2),_vm._v(" "),_c('div',{staticClass:"gl-drawer-body gl-display-flex gl-flex-direction-column"},[_vm._t("hero"),_vm._v(" "),(_vm.error)?_c('gl-alert',{key:"error",staticClass:"gl-mb-0 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(),_vm._v(" "),_c('section',{staticClass:"gl-display-flex gl-flex-direction-column gl-justify-content-end gl-flex-grow-1 gl-border-b-0 gl-bg-gray-10"},[_c('transition-group',{staticClass:"gl-display-flex gl-flex-direction-column gl-justify-content-end",class:[
|
|
323
|
+
{
|
|
324
|
+
'gl-h-full': !_vm.hasMessages,
|
|
325
|
+
'gl-h-auto': _vm.hasMessages,
|
|
326
|
+
} ],attrs:{"tag":"div","name":"message"}},[_vm._l((_vm.conversations),function(conversation,index){return _c('gl-duo-chat-conversation',{key:("conversation-" + index),attrs:{"messages":conversation,"show-delimiter":index > 0},on:{"track-feedback":_vm.onTrackFeedback}})}),_vm._v(" "),(!_vm.hasMessages && !_vm.isLoading)?[_c('div',{key:"empty-state",staticClass:"gl-display-flex gl-flex-grow-1 gl-mr-auto gl-ml-auto"},[_c('gl-empty-state',{staticClass:"gl-align-self-center",attrs:{"svg-path":_vm.$options.emptySvg,"svg-height":145,"title":_vm.$options.i18n.CHAT_EMPTY_STATE_TITLE,"description":_vm.$options.i18n.CHAT_EMPTY_STATE_DESC}})],1),_vm._v(" "),_c('gl-duo-chat-predefined-prompts',{key:"predefined-prompts",attrs:{"prompts":_vm.predefinedPrompts},on:{"click":_vm.sendPredefinedPrompt}})]:_vm._e()],2),_vm._v(" "),_c('transition',{attrs:{"name":"loader"}},[(_vm.isLoading)?_c('gl-duo-chat-loader',{staticClass:"gl-px-0!",attrs:{"tool-name":_vm.toolName}}):_vm._e()],1)],1)],2),_vm._v(" "),(_vm.isChatAvailable)?_c('footer',{staticClass:"gl-drawer-footer gl-drawer-footer-sticky gl-p-5 gl-border-t gl-bg-gray-10",class:{ 'gl-drawer-body-scrim-on-footer': !_vm.scrolledToBottom },attrs:{"data-testid":"chat-footer"}},[_c('gl-form',{attrs:{"data-testid":"chat-prompt-form"},on:{"submit":function($event){$event.stopPropagation();$event.preventDefault();return _vm.sendChatPrompt.apply(null, arguments)}}},[_c('gl-form-input-group',{scopedSlots:_vm._u([{key:"append",fn:function(){return [_c('gl-button',{staticClass:"gl-absolute! gl-bottom-2 gl-right-2 gl-rounded-base!",attrs:{"icon":"paper-airplane","category":"primary","variant":"confirm","type":"submit","aria-label":_vm.$options.i18n.CHAT_SUBMIT_LABEL,"disabled":_vm.isLoading}})]},proxy:true}],null,false,2232229068)},[_c('div',{staticClass:"duo-chat-input gl-flex-grow-1 gl-vertical-align-top gl-max-w-full gl-min-h-8 gl-inset-border-1-gray-400 gl-rounded-base gl-bg-white",attrs:{"data-value":_vm.prompt}},[(_vm.shouldShowSlashCommands)?_c('gl-card',{ref:"commands",staticClass:"slash-commands gl-absolute! gl-translate-y-n100 gl-list-style-none gl-pl-0 gl-w-full gl-shadow-md",attrs:{"body-class":"gl-p-2!"}},_vm._l((_vm.filteredSlashCommands),function(command,index){return _c('gl-dropdown-item',{key:command.name,class:{ 'active-command': index === _vm.activeCommandIndex },on:{"click":function($event){return _vm.selectSlashCommand(index)}},nativeOn:{"mouseenter":function($event){_vm.activeCommandIndex = index;}}},[_c('span',{staticClass:"gl-display-flex gl-justify-content-space-between"},[_c('span',{staticClass:"gl-display-block"},[_vm._v(_vm._s(command.name))]),_vm._v(" "),_c('small',{staticClass:"gl-text-gray-500 gl-font-style-italic gl-text-right gl-pl-3"},[_vm._v(_vm._s(command.description))])])])}),1):_vm._e(),_vm._v(" "),_c('gl-form-textarea',{ref:"prompt",staticClass:"gl-absolute gl-h-full! gl-py-4! gl-bg-transparent! gl-rounded-top-right-none gl-rounded-bottom-right-none gl-shadow-none!",class:{ 'gl-text-truncate': !_vm.prompt },attrs:{"data-testid":"chat-prompt-input","placeholder":_vm.inputPlaceholder,"disabled":_vm.isLoading,"autofocus":""},nativeOn:{"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }if($event.ctrlKey||$event.shiftKey||$event.altKey||$event.metaKey){ return null; }$event.preventDefault();},"keyup":function($event){return _vm.onInputKeyup.apply(null, arguments)}},model:{value:(_vm.prompt),callback:function ($$v) {_vm.prompt=$$v;},expression:"prompt"}})],1)]),_vm._v(" "),_c('gl-form-text',{staticClass:"gl-text-gray-400 gl-line-height-20 gl-mt-3",attrs:{"data-testid":"chat-legal-disclaimer"}},[_vm._v(_vm._s(_vm.$options.i18n.CHAT_LEGAL_DISCLAIMER))])],1)],1):_vm._e()]):_vm._e()};
|
|
327
|
+
var __vue_staticRenderFns__ = [];
|
|
328
|
+
|
|
329
|
+
/* style */
|
|
330
|
+
const __vue_inject_styles__ = undefined;
|
|
331
|
+
/* scoped */
|
|
332
|
+
const __vue_scope_id__ = undefined;
|
|
333
|
+
/* module identifier */
|
|
334
|
+
const __vue_module_identifier__ = undefined;
|
|
335
|
+
/* functional template */
|
|
336
|
+
const __vue_is_functional_template__ = false;
|
|
337
|
+
/* style inject */
|
|
338
|
+
|
|
339
|
+
/* style inject SSR */
|
|
340
|
+
|
|
341
|
+
/* style inject shadow dom */
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
const __vue_component__ = __vue_normalize__(
|
|
346
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
347
|
+
__vue_inject_styles__,
|
|
348
|
+
__vue_script__,
|
|
349
|
+
__vue_scope_id__,
|
|
350
|
+
__vue_is_functional_template__,
|
|
351
|
+
__vue_module_identifier__,
|
|
352
|
+
false,
|
|
353
|
+
undefined,
|
|
354
|
+
undefined,
|
|
355
|
+
undefined
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
export default __vue_component__;
|
|
359
|
+
export { i18n, slashCommands };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { DOCUMENTATION_SOURCE_TYPES, MESSAGE_MODEL_ROLES } from './constants';
|
|
2
|
+
|
|
3
|
+
const MOCK_SOURCES = [{
|
|
4
|
+
title: 'GitLab Handbook',
|
|
5
|
+
source_type: DOCUMENTATION_SOURCE_TYPES.HANDBOOK.value,
|
|
6
|
+
source_url: '/handbook/'
|
|
7
|
+
}, {
|
|
8
|
+
stage: 'Mock Stage',
|
|
9
|
+
group: 'Mock Group',
|
|
10
|
+
source_type: DOCUMENTATION_SOURCE_TYPES.DOC.value,
|
|
11
|
+
source_url: '/company/team/'
|
|
12
|
+
}, {
|
|
13
|
+
date: '2023-04-21',
|
|
14
|
+
author: 'Test User',
|
|
15
|
+
source_type: DOCUMENTATION_SOURCE_TYPES.BLOG.value,
|
|
16
|
+
source_url: '/blog/'
|
|
17
|
+
}];
|
|
18
|
+
const MOCK_RESPONSE_MESSAGE = {
|
|
19
|
+
id: '123',
|
|
20
|
+
content: 'Here is a simple JavaScript function to sum two numbers:\n\n ```js\n function sum(a, b) {\n return a + b;\n }\n ```\n \n To use it:\n \n ```js\n const result = sum(5, 3); // result = 8\n ```\n \n This function takes two number parameters, a and b. It returns the sum of adding them together.\n',
|
|
21
|
+
contentHtml: '<p data-sourcepos="1:1-1:56" dir="auto">Here is a simple JavaScript function to sum two numbers:</p>\n<div class="gl-relative markdown-code-block js-markdown-code">\n<pre data-sourcepos="3:1-7:3" data-canonical-lang="js" class="code highlight js-syntax-highlight language-javascript" lang="javascript" v-pre="true"><code><span id="LC1" class="line" lang="javascript"><span class="kd">function</span> <span class="nf">sum</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">b</span><span class="p">)</span> <span class="p">{</span></span>\n<span id="LC2" class="line" lang="javascript"> <span class="k">return</span> <span class="nx">a</span> <span class="o">+</span> <span class="nx">b</span><span class="p">;</span></span>\n<span id="LC3" class="line" lang="javascript"><span class="p">}</span></span></code></pre>\n<copy-code></copy-code>\n</div>\n<p data-sourcepos="9:1-9:10" dir="auto">To use it:</p>\n<div class="gl-relative markdown-code-block js-markdown-code">\n<pre data-sourcepos="11:1-13:3" data-canonical-lang="js" class="code highlight js-syntax-highlight language-javascript" lang="javascript" v-pre="true"><code><span id="LC1" class="line" lang="javascript"><span class="kd">const</span> <span class="nx">result</span> <span class="o">=</span> <span class="nf">sum</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span> <span class="c1">// result = 8</span></span></code></pre>\n<copy-code></copy-code>\n</div>\n<p data-sourcepos="15:1-15:95" dir="auto">This function takes two number parameters, a and b. It returns the sum of adding them together.</p>',
|
|
22
|
+
role: MESSAGE_MODEL_ROLES.assistant,
|
|
23
|
+
extras: {
|
|
24
|
+
sources: MOCK_SOURCES
|
|
25
|
+
},
|
|
26
|
+
requestId: '987',
|
|
27
|
+
errors: [],
|
|
28
|
+
timestamp: '2021-04-21T12:00:00.000Z'
|
|
29
|
+
};
|
|
30
|
+
const MOCK_RESPONSE_MESSAGE_FOR_STREAMING = {
|
|
31
|
+
id: '123',
|
|
32
|
+
content: `To change your password in GitLab:
|
|
33
|
+
|
|
34
|
+
Log in to your GitLab account.
|
|
35
|
+
Select your avatar in the top right corner and choose Edit profile.
|
|
36
|
+
On the left sidebar, select Password.
|
|
37
|
+
Enter your current password in the Current password field.
|
|
38
|
+
Enter your new password in the New password and Password confirmation fields.
|
|
39
|
+
Select Save password.
|
|
40
|
+
If you don't know your current password, select the I forgot my password link to reset it.
|
|
41
|
+
|
|
42
|
+
GitLab enforces password requirements when you choose a new password.`,
|
|
43
|
+
contentHtml: '',
|
|
44
|
+
role: 'assistant',
|
|
45
|
+
extras: {},
|
|
46
|
+
requestId: '987',
|
|
47
|
+
errors: [],
|
|
48
|
+
timestamp: '2021-04-21T12:00:00.000Z'
|
|
49
|
+
};
|
|
50
|
+
const generateMockResponseChunks = requestId => {
|
|
51
|
+
const chunks = [];
|
|
52
|
+
const chunkSize = 5;
|
|
53
|
+
const chunkCount = Math.ceil(MOCK_RESPONSE_MESSAGE_FOR_STREAMING.content.length / chunkSize);
|
|
54
|
+
for (let i = 0; i < chunkCount; i += 1) {
|
|
55
|
+
const chunk = {
|
|
56
|
+
...MOCK_RESPONSE_MESSAGE_FOR_STREAMING,
|
|
57
|
+
requestId,
|
|
58
|
+
content: MOCK_RESPONSE_MESSAGE_FOR_STREAMING.content.substring(i * chunkSize, (i + 1) * chunkSize),
|
|
59
|
+
chunkId: i
|
|
60
|
+
};
|
|
61
|
+
chunks.push(chunk);
|
|
62
|
+
}
|
|
63
|
+
return chunks;
|
|
64
|
+
};
|
|
65
|
+
const MOCK_USER_PROMPT_MESSAGE = {
|
|
66
|
+
id: '456',
|
|
67
|
+
content: 'How to create a new template?',
|
|
68
|
+
contentHtml: '',
|
|
69
|
+
role: MESSAGE_MODEL_ROLES.user,
|
|
70
|
+
requestId: '987',
|
|
71
|
+
errors: [],
|
|
72
|
+
timestamp: '2021-04-21T12:00:00.000Z',
|
|
73
|
+
extras: null
|
|
74
|
+
};
|
|
75
|
+
const renderMarkdown = content => content;
|
|
76
|
+
const renderGFM = el => {
|
|
77
|
+
const codeBlock = el.querySelectorAll('.markdown-code-block');
|
|
78
|
+
codeBlock.forEach(block => {
|
|
79
|
+
block === null || block === void 0 ? void 0 : block.classList.add('gl-markdown', 'gl-compact-markdown');
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export { MOCK_RESPONSE_MESSAGE, MOCK_RESPONSE_MESSAGE_FOR_STREAMING, MOCK_USER_PROMPT_MESSAGE, generateMockResponseChunks, renderGFM, renderMarkdown };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import GlButton from '../../../base/button/button';
|
|
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,"button-text-classes":"gl-white-space-normal! gl-text-left"},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},scopedSlots:_vm._u([{key:"feedback-extra-fields",fn:function(){return [_vm._t("feedback-extra-fields")]},proxy:true}],null,true)}):_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,124 @@
|
|
|
1
|
+
import GlModal from '../../../base/modal/modal';
|
|
2
|
+
import GlFormGroup from '../../../base/form/form_group/form_group';
|
|
3
|
+
import GlFormTextarea from '../../../base/form/form_textarea/form_textarea';
|
|
4
|
+
import GlFormCheckboxGroup from '../../../base/form/form_checkbox/form_checkbox_group';
|
|
5
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
6
|
+
|
|
7
|
+
const i18n = {
|
|
8
|
+
MODAL_TITLE: 'Give feedback on AI content',
|
|
9
|
+
MODAL_DESCRIPTION: 'To help improve the quality of the content, send your feedback to GitLab team members.',
|
|
10
|
+
MODAL_OPTIONS_LABEL: 'How was the AI content?',
|
|
11
|
+
MODAL_MORE_LABEL: 'More information',
|
|
12
|
+
MODAL_MORE_PLACEHOLDER: 'How could the content be improved?',
|
|
13
|
+
MODAL_FEEDBACK_OPTIONS: {
|
|
14
|
+
helpful: 'Helpful',
|
|
15
|
+
unhelpful: 'Unhelpful or irrelevant',
|
|
16
|
+
incorrect: 'Factually incorrect',
|
|
17
|
+
long: 'Too long',
|
|
18
|
+
abuse: 'Abusive or offensive',
|
|
19
|
+
other: 'Something else'
|
|
20
|
+
},
|
|
21
|
+
MODAL_ACTIONS: {
|
|
22
|
+
submit: 'Submit',
|
|
23
|
+
cancel: 'Cancel'
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const feedbackOptions = [{
|
|
27
|
+
text: i18n.MODAL_FEEDBACK_OPTIONS.helpful,
|
|
28
|
+
value: 'helpful'
|
|
29
|
+
}, {
|
|
30
|
+
text: i18n.MODAL_FEEDBACK_OPTIONS.unhelpful,
|
|
31
|
+
value: 'unhelpful'
|
|
32
|
+
}, {
|
|
33
|
+
text: i18n.MODAL_FEEDBACK_OPTIONS.incorrect,
|
|
34
|
+
value: 'incorrect'
|
|
35
|
+
}, {
|
|
36
|
+
text: i18n.MODAL_FEEDBACK_OPTIONS.long,
|
|
37
|
+
value: 'long'
|
|
38
|
+
}, {
|
|
39
|
+
text: i18n.MODAL_FEEDBACK_OPTIONS.abuse,
|
|
40
|
+
value: 'abuse'
|
|
41
|
+
}, {
|
|
42
|
+
text: i18n.MODAL_FEEDBACK_OPTIONS.other,
|
|
43
|
+
value: 'other'
|
|
44
|
+
}];
|
|
45
|
+
var script = {
|
|
46
|
+
name: 'DuoChatFeedbackModal',
|
|
47
|
+
components: {
|
|
48
|
+
GlModal,
|
|
49
|
+
GlFormCheckboxGroup,
|
|
50
|
+
GlFormGroup,
|
|
51
|
+
GlFormTextarea
|
|
52
|
+
},
|
|
53
|
+
data() {
|
|
54
|
+
return {
|
|
55
|
+
selectedFeedbackOptions: [],
|
|
56
|
+
extendedFeedback: ''
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
methods: {
|
|
60
|
+
show() {
|
|
61
|
+
this.$refs.feedbackModal.show();
|
|
62
|
+
},
|
|
63
|
+
onFeedbackSubmit() {
|
|
64
|
+
if (this.selectedFeedbackOptions.length) {
|
|
65
|
+
this.$emit('feedback-submitted', {
|
|
66
|
+
feedbackChoices: this.selectedFeedbackOptions,
|
|
67
|
+
extendedTextFeedback: this.extendedFeedback
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
onFeedbackCanceled() {
|
|
72
|
+
this.$refs.feedbackModal.hide();
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
actions: {
|
|
76
|
+
primary: {
|
|
77
|
+
text: i18n.MODAL_ACTIONS.submit
|
|
78
|
+
},
|
|
79
|
+
cancel: {
|
|
80
|
+
text: i18n.MODAL_ACTIONS.cancel
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
feedbackOptions,
|
|
84
|
+
i18n
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/* script */
|
|
88
|
+
const __vue_script__ = script;
|
|
89
|
+
|
|
90
|
+
/* template */
|
|
91
|
+
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(" "),_vm._t("feedback-extra-fields",function(){return [_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)]})],2)};
|
|
92
|
+
var __vue_staticRenderFns__ = [];
|
|
93
|
+
|
|
94
|
+
/* style */
|
|
95
|
+
const __vue_inject_styles__ = undefined;
|
|
96
|
+
/* scoped */
|
|
97
|
+
const __vue_scope_id__ = undefined;
|
|
98
|
+
/* module identifier */
|
|
99
|
+
const __vue_module_identifier__ = undefined;
|
|
100
|
+
/* functional template */
|
|
101
|
+
const __vue_is_functional_template__ = false;
|
|
102
|
+
/* style inject */
|
|
103
|
+
|
|
104
|
+
/* style inject SSR */
|
|
105
|
+
|
|
106
|
+
/* style inject shadow dom */
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
const __vue_component__ = __vue_normalize__(
|
|
111
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
112
|
+
__vue_inject_styles__,
|
|
113
|
+
__vue_script__,
|
|
114
|
+
__vue_scope_id__,
|
|
115
|
+
__vue_is_functional_template__,
|
|
116
|
+
__vue_module_identifier__,
|
|
117
|
+
false,
|
|
118
|
+
undefined,
|
|
119
|
+
undefined,
|
|
120
|
+
undefined
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
export default __vue_component__;
|
|
124
|
+
export { feedbackOptions, i18n };
|