@gitlab/ui 66.20.0 → 66.22.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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 02 Oct 2023 07:10:15 GMT
3
+ * Generated on Tue, 03 Oct 2023 10:22:26 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 02 Oct 2023 07:10:15 GMT
3
+ * Generated on Tue, 03 Oct 2023 10:22:26 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 02 Oct 2023 07:10:15 GMT
3
+ * Generated on Tue, 03 Oct 2023 10:22:26 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 Mon, 02 Oct 2023 07:10:15 GMT
3
+ * Generated on Tue, 03 Oct 2023 10:22:26 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 Mon, 02 Oct 2023 07:10:15 GMT
3
+ // Generated on Tue, 03 Oct 2023 10:22:26 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 Mon, 02 Oct 2023 07:10:15 GMT
3
+ // Generated on Tue, 03 Oct 2023 10:22:26 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.20.0",
3
+ "version": "66.22.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -122,7 +122,7 @@
122
122
  "babel-loader": "^8.0.5",
123
123
  "babel-plugin-require-context-hook": "^1.0.0",
124
124
  "bootstrap": "4.6.2",
125
- "cypress": "13.2.0",
125
+ "cypress": "13.3.0",
126
126
  "cypress-axe": "^1.4.0",
127
127
  "dompurify": "^3.0.0",
128
128
  "emoji-regex": "^10.0.0",
@@ -35,7 +35,7 @@ export const WithPopovers = (args, { argTypes }) => ({
35
35
  <template #default="{ pathItem, pathId }">
36
36
  <gl-popover triggers="hover" placement="bottom" :target="pathId">
37
37
  <template #title>
38
- <strong>{{ pathItem.title }}</strong>
38
+ {{ pathItem.title }}
39
39
  </template>
40
40
  {{ pathItem.metric }}
41
41
  </gl-popover>
@@ -63,10 +63,8 @@ $gl-popover-max-width: $grid-size * 35;
63
63
  }
64
64
 
65
65
  .popover-header {
66
+ @include gl-heading-scale-200;
66
67
  @include gl-bg-white;
67
- @include gl-font-sm;
68
- @include gl-font-weight-bold;
69
- @include gl-m-0;
70
68
  @include gl-border-bottom-0;
71
69
  @include gl-pb-0;
72
70
  }
@@ -0,0 +1 @@
1
+ A simple component to list documentation sources for a documentation-related AI response messages.
@@ -0,0 +1,92 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import { GlIcon, GlLink } from '../../../../../../index';
3
+ import { DOCUMENTATION_SOURCE_TYPES } from '../../constants';
4
+ import GlDuoChatMessageSources from './duo_chat_message_sources.vue';
5
+
6
+ const dummySourceBase = {
7
+ title: 'Foo',
8
+ source_type: DOCUMENTATION_SOURCE_TYPES.HANDBOOK.value,
9
+ stage: 'foo-stage',
10
+ group: 'bar-group',
11
+ date: new Date('December 31, 2020 23:59:59'),
12
+ author: 'Gregor Samsa',
13
+ };
14
+
15
+ describe('Duo Chat Message Sources', () => {
16
+ let wrapper;
17
+
18
+ const findListItems = () => wrapper.findAll('[data-testid="source-list-item"]');
19
+ const findSourceIcons = () => wrapper.findAllComponents(GlIcon);
20
+ const findSourceTitles = () => wrapper.findAllComponents(GlLink);
21
+
22
+ const createComponent = ({ propsData = {} } = {}) => {
23
+ wrapper = shallowMount(GlDuoChatMessageSources, {
24
+ propsData,
25
+ });
26
+ };
27
+
28
+ it('does not render anything if sources is an empty Array', () => {
29
+ createComponent({
30
+ propsData: {
31
+ sources: [],
32
+ },
33
+ });
34
+ expect(wrapper.text()).toBe('');
35
+ });
36
+
37
+ it('renders sources passed down as a prop', () => {
38
+ createComponent({
39
+ propsData: {
40
+ sources: [
41
+ dummySourceBase,
42
+ {
43
+ ...dummySourceBase,
44
+ title: 'Bar',
45
+ },
46
+ ],
47
+ },
48
+ });
49
+ expect(findListItems().length).toBe(2);
50
+ });
51
+
52
+ it.each`
53
+ type | expectedIcon
54
+ ${DOCUMENTATION_SOURCE_TYPES.HANDBOOK.value} | ${DOCUMENTATION_SOURCE_TYPES.HANDBOOK.icon}
55
+ ${DOCUMENTATION_SOURCE_TYPES.DOC.value} | ${DOCUMENTATION_SOURCE_TYPES.DOC.icon}
56
+ ${DOCUMENTATION_SOURCE_TYPES.BLOG.value} | ${DOCUMENTATION_SOURCE_TYPES.BLOG.icon}
57
+ ${'foo'} | ${'document'}
58
+ `('renders the correct icon for $type type', ({ type, expectedIcon } = {}) => {
59
+ createComponent({
60
+ propsData: {
61
+ sources: [
62
+ {
63
+ ...dummySourceBase,
64
+ source_type: type,
65
+ },
66
+ ],
67
+ },
68
+ });
69
+ expect(findSourceIcons().at(0).props('name')).toBe(expectedIcon);
70
+ });
71
+
72
+ it.each`
73
+ sourceExtension | expectedTitle
74
+ ${{ title: 'Foo' }} | ${'Foo'}
75
+ ${{ source_type: DOCUMENTATION_SOURCE_TYPES.DOC.value }} | ${`${dummySourceBase.stage} / ${dummySourceBase.group}`}
76
+ ${{ source_type: DOCUMENTATION_SOURCE_TYPES.BLOG.value }} | ${`${dummySourceBase.date} / ${dummySourceBase.author}`}
77
+ ${{}} | ${'Source'}
78
+ `('renders the correct title for $sourceExtension', ({ sourceExtension, expectedTitle } = {}) => {
79
+ createComponent({
80
+ propsData: {
81
+ sources: [
82
+ {
83
+ ...dummySourceBase,
84
+ title: '',
85
+ ...sourceExtension,
86
+ },
87
+ ],
88
+ },
89
+ });
90
+ expect(findSourceTitles().at(0).text()).toBe(expectedTitle);
91
+ });
92
+ });
@@ -0,0 +1,32 @@
1
+ import { MOCK_RESPONSE_MESSAGE } from '../../mock_data';
2
+ import GlDuoChatMessageSources from './duo_chat_message_sources.vue';
3
+ import readme from './duo_chat_message_sources.md';
4
+
5
+ const generateProps = ({ sources = [] } = {}) => ({
6
+ sources,
7
+ });
8
+
9
+ const Template = (args, { argTypes }) => ({
10
+ components: { GlDuoChatMessageSources },
11
+ props: Object.keys(argTypes),
12
+ template: `
13
+ <gl-duo-chat-message-sources :sources="sources" />
14
+ `,
15
+ });
16
+
17
+ export const Default = Template.bind({});
18
+ Default.args = generateProps({
19
+ sources: MOCK_RESPONSE_MESSAGE.extras.sources,
20
+ });
21
+
22
+ export default {
23
+ title: 'experimental/duo/chat/duo_chat_message_sources',
24
+ component: GlDuoChatMessageSources,
25
+ parameters: {
26
+ docs: {
27
+ description: {
28
+ component: readme,
29
+ },
30
+ },
31
+ },
32
+ };
@@ -0,0 +1,80 @@
1
+ <script>
2
+ import { GlIcon, GlLink } from '../../../../../../index';
3
+ import { DOCUMENTATION_SOURCE_TYPES } from '../../constants';
4
+
5
+ export const i18n = {
6
+ MESSAGE_SOURCE: 'Source',
7
+ MESSAGE_SOURCES: 'Sources',
8
+ };
9
+
10
+ export default {
11
+ name: 'GlDuoChatMessageSources',
12
+ components: {
13
+ GlIcon,
14
+ GlLink,
15
+ },
16
+ props: {
17
+ /**
18
+ * The Array of the message sources.
19
+ */
20
+ sources: {
21
+ type: Array,
22
+ required: true,
23
+ },
24
+ },
25
+ computed: {
26
+ sourceLabel() {
27
+ return this.sources.length > 1 ? i18n.MESSAGE_SOURCES : i18n.MESSAGE_SOURCES;
28
+ },
29
+ },
30
+ methods: {
31
+ getSourceIcon(sourceType) {
32
+ const currentSourceType = Object.values(DOCUMENTATION_SOURCE_TYPES).find(
33
+ ({ value }) => value === sourceType
34
+ );
35
+
36
+ return currentSourceType?.icon || 'document';
37
+ },
38
+ getSourceTitle({ title, source_type: sourceType, stage, group, date, author }) {
39
+ if (title) {
40
+ return title;
41
+ }
42
+
43
+ if (sourceType === DOCUMENTATION_SOURCE_TYPES.DOC.value) {
44
+ if (stage && group) {
45
+ return `${stage} / ${group}`;
46
+ }
47
+ }
48
+
49
+ if (sourceType === DOCUMENTATION_SOURCE_TYPES.BLOG.value) {
50
+ if (date && author) {
51
+ return `${date} / ${author}`;
52
+ }
53
+ }
54
+
55
+ return i18n.MESSAGE_SOURCE;
56
+ },
57
+ },
58
+ };
59
+ </script>
60
+ <template>
61
+ <div class="gl-mt-4 gl-mr-3 gl-text-gray-600" data-testid="duo-chat-message-sources">
62
+ <span v-if="sources.length">{{ sourceLabel }}:</span>
63
+
64
+ <ul class="gl-list-style-none gl-p-0 gl-m-0">
65
+ <li
66
+ v-for="(source, index) in sources"
67
+ :key="index"
68
+ class="gl-display-flex gl-pt-3 gl-align-items-center"
69
+ data-testid="source-list-item"
70
+ >
71
+ <gl-icon
72
+ v-if="source.source_type"
73
+ :name="getSourceIcon(source.source_type)"
74
+ class="gl-flex-shrink-0 gl-mr-2"
75
+ />
76
+ <gl-link :href="source.source_url">{{ getSourceTitle(source) }}</gl-link>
77
+ </li>
78
+ </ul>
79
+ </div>
80
+ </template>
@@ -0,0 +1,20 @@
1
+ export const DOCUMENTATION_SOURCE_TYPES = {
2
+ HANDBOOK: {
3
+ value: 'handbook',
4
+ icon: 'book',
5
+ },
6
+ DOC: {
7
+ value: 'doc',
8
+ icon: 'documents',
9
+ },
10
+ BLOG: {
11
+ value: 'blog',
12
+ icon: 'list-bulleted',
13
+ },
14
+ };
15
+
16
+ export const MESSAGE_MODEL_ROLES = {
17
+ user: 'user',
18
+ system: 'system',
19
+ assistant: 'assistant',
20
+ };
@@ -0,0 +1,34 @@
1
+ import { DOCUMENTATION_SOURCE_TYPES, MESSAGE_MODEL_ROLES } from './constants';
2
+
3
+ const MOCK_SOURCES = [
4
+ {
5
+ title: 'GitLab Handbook',
6
+ source_type: DOCUMENTATION_SOURCE_TYPES.HANDBOOK.value,
7
+ source_url: '/handbook/',
8
+ },
9
+ {
10
+ stage: 'Mock Stage',
11
+ group: 'Mock Group',
12
+ source_type: DOCUMENTATION_SOURCE_TYPES.DOC.value,
13
+ source_url: '/company/team/',
14
+ },
15
+ {
16
+ date: '2023-04-21',
17
+ author: 'Test User',
18
+ source_type: DOCUMENTATION_SOURCE_TYPES.BLOG.value,
19
+ source_url: '/blog/',
20
+ },
21
+ ];
22
+
23
+ export const MOCK_RESPONSE_MESSAGE = {
24
+ id: '123',
25
+ content: '_Duo Chat message_ comming from AI',
26
+ contentHtml: '<p><em>Duo Chat message</em> comming from AI</p>',
27
+ role: MESSAGE_MODEL_ROLES.assistant,
28
+ extras: {
29
+ sources: MOCK_SOURCES,
30
+ },
31
+ requestId: '987',
32
+ errors: [],
33
+ timestamp: '2021-04-21T12:00:00.000Z',
34
+ };