Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1881 from botpress/fl_history_flag_msg
feat(history): Allow user to flag and unflag messages
- Loading branch information
Showing
15 changed files
with
601 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as sdk from 'botpress/sdk' | ||
|
||
export interface ConversationInfo { | ||
id: string | ||
count: number | ||
} | ||
|
||
export interface MessageGroup { | ||
isFlagged: boolean | ||
userMessage: sdk.IO.IncomingEvent | ||
botMessages: sdk.IO.OutgoingEvent[] | ||
} | ||
|
||
export interface QueryFilters { | ||
flag: boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React from 'react' | ||
import style from './style.scss' | ||
import { MdSearch } from 'react-icons/md' | ||
import { IoMdFlag } from 'react-icons/io' | ||
import classnames from 'classnames' | ||
|
||
export class MessageGroup extends React.Component { | ||
componentWillUnmount() { | ||
this.props.handleSelection(false, this.props.group.userMessage) | ||
} | ||
|
||
handleSelection() { | ||
const newState = !this.props.isSelected | ||
this.props.handleSelection(newState, this.props.group) | ||
} | ||
|
||
render() { | ||
if (!this.props.group.userMessage) { | ||
return null | ||
} | ||
return ( | ||
<div className={style['message-group']}> | ||
<div className={style['message-group-header']}> | ||
{this.props.group.userMessage.decision && ( | ||
<div className={style['message-group-explanation']}> | ||
<div className={style['message-group-confidence']}>{`${Math.round( | ||
this.props.group.userMessage.decision.confidence * 10000 | ||
) / 100}% decision:`}</div> | ||
<div className={style['message-group-decision']}>{` ${ | ||
this.props.group.userMessage.decision.sourceDetails | ||
}`}</div> | ||
</div> | ||
)} | ||
<div className={style['message-group-flag']}> | ||
{this.props.group.isFlagged && <IoMdFlag />} | ||
<input type="checkbox" checked={this.props.isSelected} onChange={() => this.handleSelection()} /> | ||
<div | ||
className={style['message-inspect']} | ||
onClick={() => this.props.focusMessage(this.props.group.userMessage)} | ||
> | ||
<MdSearch /> | ||
</div> | ||
</div> | ||
</div> | ||
<div className={style['message-sender']}>User:</div> | ||
{ | ||
<div className={classnames(style['message-elements'], style['message-incomming'])}> | ||
{this.props.group.userMessage.preview} | ||
</div> | ||
} | ||
<div className={style['message-sender']}>Bot:</div> | ||
{this.props.group.botMessages.map(m => { | ||
return ( | ||
<div | ||
className={classnames( | ||
style['message-elements'], | ||
m.direction === 'outgoing' ? style['message-outgoing'] : style['message-incomming'] | ||
)} | ||
key={`${m.id}: ${m.direction}`} | ||
value={m.id} | ||
> | ||
{m.preview} | ||
</div> | ||
) | ||
})} | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react' | ||
import style from './style.scss' | ||
|
||
import { GoX } from 'react-icons/go' | ||
|
||
import classnames from 'classnames' | ||
import inspectorTheme from './inspectortheme' | ||
import JSONTree from 'react-json-tree' | ||
|
||
export function MessageInspector(props) { | ||
return ( | ||
<div | ||
className={classnames(style['message-inspector'], { | ||
[style['message-inspector-hidden']]: props.inspectorIsShown | ||
})} | ||
> | ||
<div className={style['quit-inspector']} onClick={props.closeInspector}> | ||
<GoX /> | ||
</div> | ||
{props.focusedMessage && ( | ||
<JSONTree theme={inspectorTheme} data={props.focusedMessage} invertTheme={false} hideRoot={true} /> | ||
)} | ||
</div> | ||
) | ||
} |
Oops, something went wrong.