Skip to content

Commit 36ad95e

Browse files
committed
Add issues and suggestions display to ExpertChatMessage component with icon support
1 parent d333c23 commit 36ad95e

1 file changed

Lines changed: 63 additions & 14 deletions

File tree

frontend/src/components/expert/ExpertChatMessage.vue

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,34 @@
77
<!-- Regular text content (for chat messages) -->
88
<!-- eslint-disable-next-line vue/no-v-html -->
99
<div v-if="!hasRichContent" class="message-text" v-html="formattedContent" />
10+
11+
<div v-if="hasIssues" class="issues">
12+
<h4><exclamation-icon class="ff-icon" /> Issues</h4>
13+
<ul>
14+
<li v-for="issue in issues" :key="issue">{{ sanitize(issue) }}</li>
15+
</ul>
16+
</div>
17+
18+
<div v-if="hasSuggestions" class="suggestions">
19+
<h4><information-circle-icon class="ff-icon" /> Suggestions</h4>
20+
<ul>
21+
<li v-for="suggestion in suggestions" :key="suggestion">{{ sanitize(suggestion) }}</li>
22+
</ul>
23+
</div>
1024
</div>
1125
</div>
1226
</template>
1327

1428
<script>
29+
import { ExclamationIcon, InformationCircleIcon } from '@heroicons/vue/solid'
1530
import { marked } from 'marked'
31+
import { h, render } from 'vue'
1632
1733
import { sanitize } from '../../composables/String.js'
1834
1935
export default {
2036
name: 'ExpertChatMessage',
37+
components: { ExclamationIcon, InformationCircleIcon },
2138
props: {
2239
message: {
2340
type: Object,
@@ -55,16 +72,16 @@ export default {
5572
// Convert markdown to HTML
5673
const content = []
5774
content.push(this.message.content || '')
58-
if (this.message.resources?.issues?.length > 0) {
59-
content.push('\n\n')
60-
content.push('**Issues:**')
61-
content.push(this.message.resources.issues.map(issue => `\n- ${this.sanitize(issue)}`).join(''))
62-
}
63-
if (this.message.resources?.suggestions?.length > 0) {
64-
content.push('\n\n')
65-
content.push('**Suggestions:**')
66-
content.push(this.message.resources.suggestions.map(suggestion => `\n- ${this.sanitize(suggestion)}`).join(''))
67-
}
75+
// if (this.message.resources?.issues?.length > 0) {
76+
// content.push('\n\n')
77+
// content.push('**Issues:**')
78+
// content.push(this.message.resources.issues.map(issue => `\n- ${this.sanitize(issue)}`).join(''))
79+
// }
80+
// if (this.message.resources?.suggestions?.length > 0) {
81+
// content.push('\n\n')
82+
// content.push('**Suggestions:**')
83+
// content.push(this.message.resources.suggestions.map(suggestion => `\n- ${this.sanitize(suggestion)}`).join(''))
84+
// }
6885
const html = marked(content.join('\n'), {
6986
breaks: true,
7087
gfm: true
@@ -79,16 +96,24 @@ export default {
7996
})
8097
},
8198
issues () {
82-
return this.resources.issues
99+
return this.message.resources.issues
83100
},
84101
suggestions () {
85-
return this.resources.suggestions
102+
return this.message.resources.suggestions
86103
},
87104
hasIssues () {
88-
return (this.resources.issues && this.resources.issues.length > 0)
105+
return (this.message.resources?.issues && this.message.resources?.issues.length > 0)
89106
},
90107
hasSuggestions () {
91-
return (this.resources.suggestions && this.resources.suggestions.length > 0)
108+
return (this.message.resources?.suggestions && this.message.resources?.suggestions.length > 0)
109+
}
110+
},
111+
methods: {
112+
renderIconToHtml (component) {
113+
const vnode = h(component, { class: 'inline-block w-5 h-5 mr-1 align-text-bottom' })
114+
const container = document.createElement('div')
115+
render(vnode, container)
116+
return container.innerHTML
92117
}
93118
}
94119
}
@@ -120,6 +145,30 @@ export default {
120145
border-radius: 0.5rem;
121146
border-bottom-left-radius: 0.125rem;
122147
}
148+
149+
.issues, .suggestions {
150+
margin-top: 1.25rem;
151+
h4 {
152+
font-weight: bold;
153+
display: flex;
154+
align-items: center;
155+
gap: 5px;
156+
color: $ff-grey-600;
157+
158+
.ff-icon {
159+
color: $ff-grey-500;
160+
}
161+
}
162+
163+
ul {
164+
list-style: disc;
165+
padding-left: 1.4rem;
166+
167+
li {
168+
margin-top: .5rem;
169+
}
170+
}
171+
}
123172
}
124173
125174
&.message-system {

0 commit comments

Comments
 (0)