-
Notifications
You must be signed in to change notification settings - Fork 83
Support debug log context in FF Expert #6726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f780e36
593586d
1a85ac6
c62b07e
6333326
79d3aad
8fad707
f07e143
bacbc41
9a0949d
3569720
a24fc73
c94518c
f93555c
1ea2fa0
38572f6
f467099
e7781ab
35c09a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,98 @@ | ||||||
| <template> | ||||||
| <ContextChip | ||||||
| class="flow-selection-button" | ||||||
| :modelValue="modelValue" | ||||||
| @toggle="toggleSelection" | ||||||
| > | ||||||
| <template #text> | ||||||
| <span>Debug</span> | ||||||
| <span class="counter italic" :title="selectionTitle">( {{ selectedCounter }} {{ pluralize('log', selectedCounter) }} )</span> | ||||||
| </template> | ||||||
| </ContextChip> | ||||||
| </template> | ||||||
|
|
||||||
| <script> | ||||||
| import { mapActions, mapState } from 'vuex' | ||||||
|
|
||||||
| import { pluralize } from '../../../composables/String.js' | ||||||
|
|
||||||
| import ContextChip from './ContextChip/index.vue' | ||||||
|
|
||||||
| export default { | ||||||
| name: 'IncludeDebugContextButton', | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| components: { | ||||||
| ContextChip | ||||||
| }, | ||||||
| props: { | ||||||
| modelValue: { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. passing modelValues is not needed in the case of context chips, their rendering logic is already determined in the parent they're used in with the v-if directives. This prop is also not passed when the component is used. model values are useful when the parent component need to watch over the data passed to child components and it mutates, which we're not doing Not a blocker, I will revisit the context chips as part of the refactoring task. |
||||||
| type: Boolean, | ||||||
| required: false, | ||||||
| default: true | ||||||
| } | ||||||
| }, | ||||||
| emits: ['update:modelValue'], | ||||||
| computed: { | ||||||
| ...mapState('product/assistant', ['debugLog']), | ||||||
| selectedCounter () { | ||||||
| return this.debugLog.length | ||||||
| }, | ||||||
| selectionTitle () { | ||||||
| const map = {} | ||||||
| this.debugLog.forEach(n => { | ||||||
| map[n.type] = (map[n.type] ?? 0) + 1 | ||||||
| }) | ||||||
|
|
||||||
| const tipBuilder = (logEntry, index) => { | ||||||
| logEntry = logEntry || {} | ||||||
| const level = logEntry.level || '' | ||||||
| const nonDebugLevel = level !== 'debug' ? level : '' | ||||||
| const topic = logEntry.metadata?.topic || '' | ||||||
| const name = logEntry.source?.name || logEntry.source?.id || logEntry.metadata?.path || '' | ||||||
| const format = logEntry.metadata?.format || '' | ||||||
| const type = logEntry.source?.type || '' | ||||||
| const property = logEntry.metadata?.property || '' | ||||||
| const strBuilder = [] | ||||||
| if (name) strBuilder.push(`node: ${name}`) | ||||||
| if (topic) strBuilder.push(`topic: ${topic}`) | ||||||
| if (nonDebugLevel) { | ||||||
| if (type) { | ||||||
| strBuilder.push(`${type} : (${nonDebugLevel})`) | ||||||
| } | ||||||
| } | ||||||
| if (property) { | ||||||
| if (format) { | ||||||
| strBuilder.push(`property: ${property} ${format}`) | ||||||
| } else { | ||||||
| strBuilder.push(`property: ${property}`) | ||||||
| } | ||||||
| } | ||||||
| return `${index + 1}: ${strBuilder.join(', ')}` | ||||||
| } | ||||||
|
|
||||||
| const list = this.debugLog.map(tipBuilder).join('\n') | ||||||
|
|
||||||
| return `Selected Logs: \n${list}` | ||||||
| } | ||||||
| }, | ||||||
| methods: { | ||||||
| ...mapActions('product/assistant', ['resetDebugLogContext']), | ||||||
| pluralize, | ||||||
| toggleSelection () { | ||||||
| this.$emit('update:modelValue', !this.modelValue) | ||||||
| this.resetDebugLogContext() | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| </script> | ||||||
|
|
||||||
| <style lang="scss"> | ||||||
| .flow-selection-button { | ||||||
| .text { | ||||||
| .counter { | ||||||
| color: $ff-grey-500; | ||||||
| margin-left: 4px; | ||||||
| font-size: $ff-funit-xs; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| </style> | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this component is a wrapper over the default chip, my feeling is that it's a chip too, not a button