Skip to content

Commit c5410a0

Browse files
authored
Merge pull request #6607 from FlowFuse/6564_suggestions-and-issues-styling
Add issues and suggestions display to `ExpertChatMessage` component with icon support
2 parents 4164996 + b36db27 commit c5410a0

1 file changed

Lines changed: 45 additions & 14 deletions

File tree

frontend/src/components/expert/ExpertChatMessage.vue

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,33 @@
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'
1631
1732
import { sanitize } from '../../composables/String.js'
1833
1934
export default {
2035
name: 'ExpertChatMessage',
36+
components: { ExclamationIcon, InformationCircleIcon },
2137
props: {
2238
message: {
2339
type: Object,
@@ -55,16 +71,7 @@ export default {
5571
// Convert markdown to HTML
5672
const content = []
5773
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-
}
74+
6875
const html = marked(content.join('\n'), {
6976
breaks: true,
7077
gfm: true
@@ -79,16 +86,16 @@ export default {
7986
})
8087
},
8188
issues () {
82-
return this.resources.issues
89+
return this.message.resources.issues
8390
},
8491
suggestions () {
85-
return this.resources.suggestions
92+
return this.message.resources.suggestions
8693
},
8794
hasIssues () {
88-
return (this.resources.issues && this.resources.issues.length > 0)
95+
return (this.message.resources?.issues && this.message.resources?.issues.length > 0)
8996
},
9097
hasSuggestions () {
91-
return (this.resources.suggestions && this.resources.suggestions.length > 0)
98+
return (this.message.resources?.suggestions && this.message.resources?.suggestions.length > 0)
9299
}
93100
}
94101
}
@@ -120,6 +127,30 @@ export default {
120127
border-radius: 0.5rem;
121128
border-bottom-left-radius: 0.125rem;
122129
}
130+
131+
.issues, .suggestions {
132+
margin-top: 1.25rem;
133+
h4 {
134+
font-weight: bold;
135+
display: flex;
136+
align-items: center;
137+
gap: 5px;
138+
color: $ff-grey-600;
139+
140+
.ff-icon {
141+
color: $ff-grey-500;
142+
}
143+
}
144+
145+
ul {
146+
list-style: disc;
147+
padding-left: 1.4rem;
148+
149+
li {
150+
margin-top: .5rem;
151+
}
152+
}
153+
}
123154
}
124155
125156
&.message-system {

0 commit comments

Comments
 (0)