Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(actions): actions dropdown shows action metadata
- Loading branch information
1 parent
1b5f643
commit 21af29d
Showing
5 changed files
with
92 additions
and
17 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
52 changes: 52 additions & 0 deletions
52
...ges/core/botpress/src/web/views/FlowBuilder/sidePanel/properties/SelectActionDropdown.jsx
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,52 @@ | ||
import React, { Component } from 'react' | ||
import Select from 'react-select' | ||
import _ from 'lodash' | ||
import classnames from 'classnames' | ||
import Highlighter from 'react-highlight-words' | ||
|
||
const style = require('./actionDropdown.scss') | ||
|
||
export default class SelectActionDropdown extends Component { | ||
renderOption = option => { | ||
const highlight = txt => <Highlighter searchWords={[this._inputValue]} textToHighlight={txt} /> | ||
|
||
if (option.metadata) { | ||
const category = option.metadata.category ? ( | ||
<span className={style.category}>{highlight(option.metadata.category)} –</span> | ||
) : null | ||
const title = option.metadata.title ? ( | ||
<span className={style.title}>{highlight(option.metadata.title)}</span> | ||
) : null | ||
|
||
return ( | ||
<div> | ||
<span> | ||
{category} | ||
{title} | ||
<span className={style.name}>–> {highlight(option.label)}</span> | ||
</span> | ||
</div> | ||
) | ||
} | ||
|
||
return highlight(option.label) | ||
} | ||
|
||
render() { | ||
const options = this.props.options.map(x => ({ | ||
label: x.name, | ||
value: x.name, | ||
metadata: x.metadata | ||
})) | ||
|
||
return ( | ||
<Select | ||
onInputChange={inputValue => (this._inputValue = inputValue)} | ||
onChange={this.props.onChange} | ||
options={options} | ||
value={this.props.value} | ||
optionRenderer={this.renderOption} | ||
/> | ||
) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/core/botpress/src/web/views/FlowBuilder/sidePanel/properties/actionDropdown.scss
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,13 @@ | ||
.category { | ||
font-weight: bold; | ||
margin-right: 5px; | ||
} | ||
|
||
.title { | ||
margin-right: 5px; | ||
} | ||
|
||
.name { | ||
color: grey; | ||
font-size: 90%; | ||
} |
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