@gitlab/duo-ui 8.3.0 → 8.4.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 +28 -0
- package/dist/components/chat/components/duo_chat_header/duo_chat_header.js +2 -1
- package/dist/components/chat/components/duo_chat_threads/duo_chat_threads.js +96 -0
- package/dist/components/chat/components/duo_chat_threads/duo_chat_threads_empty.js +52 -0
- package/dist/components/chat/duo_chat.js +77 -9
- package/dist/components/chat/mock_data.js +72 -1
- package/dist/tailwind.css +1 -1
- package/dist/tailwind.css.map +1 -1
- package/dist/utils/date.js +27 -0
- package/package.json +1 -1
- package/src/components/chat/components/duo_chat_header/duo_chat_header.vue +2 -1
- package/src/components/chat/components/duo_chat_threads/duo_chat_threads.vue +122 -0
- package/src/components/chat/components/duo_chat_threads/duo_chat_threads_empty.vue +40 -0
- package/src/components/chat/duo_chat.vue +239 -168
- package/src/components/chat/mock_data.js +83 -0
- package/src/utils/date.js +24 -0
- package/translations.js +7 -1
package/package.json
CHANGED
|
@@ -71,6 +71,7 @@ export default {
|
|
|
71
71
|
data-testid="chat-header"
|
|
72
72
|
:class="{
|
|
73
73
|
'gl-z-200': !shouldRenderResizable,
|
|
74
|
+
'gl-z-1': shouldRenderResizable,
|
|
74
75
|
}"
|
|
75
76
|
class="duo-chat-drawer-header duo-chat-drawer-header-sticky gl-border-0 gl-bg-default !gl-p-0"
|
|
76
77
|
>
|
|
@@ -80,7 +81,7 @@ export default {
|
|
|
80
81
|
data-testid="chat-back-button"
|
|
81
82
|
category="primary"
|
|
82
83
|
size="medium"
|
|
83
|
-
icon="
|
|
84
|
+
icon="history"
|
|
84
85
|
class="gl-mr-3"
|
|
85
86
|
:aria-label="$options.i18n.CHAT_BACK_LABEL"
|
|
86
87
|
@click="$emit('go-back')"
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { GlButton, GlIcon } from '@gitlab/ui';
|
|
3
|
+
import { translate } from '../../../../utils/i18n';
|
|
4
|
+
import { formatDate } from '../../../../utils/date';
|
|
5
|
+
import DuoChatThreadsEmpty from './duo_chat_threads_empty.vue';
|
|
6
|
+
|
|
7
|
+
const i18n = {
|
|
8
|
+
CHAT_HISTORY_INFO: translate(
|
|
9
|
+
'DuoChat.chatHistoryInfo',
|
|
10
|
+
'Chats with no activity in the last 30 days are deleted.'
|
|
11
|
+
),
|
|
12
|
+
THREAD_DELETE_LABEL: translate('DuoChat.threadDeleteLabel', 'Delete this thread.'),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
name: 'DuoChatHistory',
|
|
17
|
+
|
|
18
|
+
components: {
|
|
19
|
+
GlButton,
|
|
20
|
+
GlIcon,
|
|
21
|
+
DuoChatThreadsEmpty,
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
props: {
|
|
25
|
+
threads: {
|
|
26
|
+
type: Array,
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
computed: {
|
|
32
|
+
formatDate() {
|
|
33
|
+
return formatDate;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
groupedThreads() {
|
|
37
|
+
return this.threads.reduce((threadsGroupedByDate, thread) => {
|
|
38
|
+
const date = new Date(thread.createdAt);
|
|
39
|
+
const dateKey = date.toISOString().split('T')[0];
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
...threadsGroupedByDate,
|
|
43
|
+
[dateKey]: [...(threadsGroupedByDate[dateKey] || []), thread],
|
|
44
|
+
};
|
|
45
|
+
}, {});
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
hasThreads() {
|
|
49
|
+
return this.threads.length > 0;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
methods: {
|
|
54
|
+
onNewChat() {
|
|
55
|
+
this.$emit('new-chat');
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
onSelectThread(thread) {
|
|
59
|
+
this.$emit('select-thread', thread);
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
onDeleteThread(threadId, event) {
|
|
63
|
+
event.stopPropagation();
|
|
64
|
+
this.$emit('delete-thread', threadId);
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
onClose() {
|
|
68
|
+
this.$emit('close');
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
i18n,
|
|
72
|
+
};
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<template>
|
|
76
|
+
<div class="gl-h-full gl-p-5">
|
|
77
|
+
<div
|
|
78
|
+
data-testid="chat-threads-info-banner"
|
|
79
|
+
class="gl-bg-gray-50 gl-text-gray-500 gl-p-4 gl-mb-5 gl-rounded-base"
|
|
80
|
+
>
|
|
81
|
+
<p class="gl-m-0 gl-flex">
|
|
82
|
+
<gl-icon class="gl-mr-4" name="bulb" />{{ $options.i18n.CHAT_HISTORY_INFO }}
|
|
83
|
+
</p>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<template v-if="hasThreads">
|
|
87
|
+
<div v-for="(threadsForDate, date) in groupedThreads" :key="date">
|
|
88
|
+
<div data-testid="chat-threads-date-header" class="gl-font-bold gl-neutral-900 gl-mb-4">
|
|
89
|
+
{{ formatDate(date) }}
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<div>
|
|
93
|
+
<div
|
|
94
|
+
v-for="thread in threadsForDate"
|
|
95
|
+
:key="thread.id"
|
|
96
|
+
class="gl-flex gl-align-center gl-mb-4"
|
|
97
|
+
>
|
|
98
|
+
<div
|
|
99
|
+
tabindex="0"
|
|
100
|
+
data-testid="chat-threads-thread-box"
|
|
101
|
+
class="thread-box hover:gl-bg-gray-50 focus:gl-bg-gray-50 gl-text-ellipsis gl-overflow-hidden gl-rounded-base gl-cursor-pointer gl-rounded-base gl-p-4 gl-w-full gl-whitespace-nowrap"
|
|
102
|
+
@click="onSelectThread(thread)"
|
|
103
|
+
>
|
|
104
|
+
{{ thread.title || 'Untitled Chat' }}
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<gl-button
|
|
108
|
+
data-testid="chat-threads-delete-thread-button"
|
|
109
|
+
icon="remove"
|
|
110
|
+
category="tertiary"
|
|
111
|
+
class="gl-neutral-900 !gl-p-4"
|
|
112
|
+
size="small"
|
|
113
|
+
:aria-label="$options.i18n.THREAD_DELETE_LABEL"
|
|
114
|
+
@click="$emit('delete-thread', thread.id)"
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</template>
|
|
120
|
+
<duo-chat-threads-empty v-else />
|
|
121
|
+
</div>
|
|
122
|
+
</template>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import ScheduleIllustration from '@gitlab/svgs/dist/illustrations/schedule-md.svg';
|
|
3
|
+
import { translate } from '../../../../utils/i18n';
|
|
4
|
+
|
|
5
|
+
const i18n = {
|
|
6
|
+
EMPTY_HISTORY_TITLE: translate('DuoChat.emptyHistoryTitle', 'See your chat history'),
|
|
7
|
+
EMPTY_HISTORY_COPY: translate(
|
|
8
|
+
'DuoChat.emptyHistoryCopy',
|
|
9
|
+
'Your previous chats will appear here.'
|
|
10
|
+
),
|
|
11
|
+
EMPTY_HISTORY_ALT: translate(
|
|
12
|
+
'DuoChat.emptyHistoryAlt',
|
|
13
|
+
'Clock icon with circular arrow, indicating chat history or time-based functionality'
|
|
14
|
+
),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
name: 'DuoChatHistoryEmpty',
|
|
19
|
+
|
|
20
|
+
i18n,
|
|
21
|
+
ScheduleIllustration,
|
|
22
|
+
};
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<div class="gl-h-full gl-flex gl-flex-col gl-align-center gl-items-center gl-justify-center">
|
|
27
|
+
<img
|
|
28
|
+
:src="$options.ScheduleIllustration"
|
|
29
|
+
:alt="$options.i18n.EMPTY_HISTORY_ALT"
|
|
30
|
+
class="gl-mb-5"
|
|
31
|
+
data-testid="empty-state-illustration"
|
|
32
|
+
/>
|
|
33
|
+
<h3 class="gl-font-bold gl-neutral-900 gl-mb-4" data-testid="empty-state-title">
|
|
34
|
+
{{ $options.i18n.EMPTY_HISTORY_TITLE }}
|
|
35
|
+
</h3>
|
|
36
|
+
<p class="gl-align-center" data-testid="empty-state-description">
|
|
37
|
+
{{ $options.i18n.EMPTY_HISTORY_COPY }}
|
|
38
|
+
</p>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|