Skip to content

Commit

Permalink
Merge pull request #2315 from botpress/ya-bot-switch-adj
Browse files Browse the repository at this point in the history
fix(bots): fixed display of name vs id in switch and import
  • Loading branch information
allardy committed Aug 29, 2019
2 parents bc4e373 + 5dda8a9 commit 62e7661
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bp/core/services/bot-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class BotService {

const newConfigs = <Partial<BotConfig>>{
id: botId,
name: `${originalConfig.name} (${botId})`,
name: botId === originalConfig.name ? originalConfig.name : `${originalConfig.name} (${botId})`,
pipeline_status: {
current_stage: {
id: pipeline && pipeline[0].id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const BotSwitcher = () => {
const toggle = () => setOpen(!isOpen)
const differentBots = bots.filter((bot: BotInfo) => window.BOT_ID !== bot.id)

const getBotDisplayName = bot =>
bots.filter(x => x.name === bot.name).length > 1 ? `${bot.name} (${bot.id})` : bot.name

return (
<Fragment>
<ActionItem
Expand All @@ -43,7 +46,7 @@ const BotSwitcher = () => {
<Dropdown.Menu pullRight onClose={toggle} className={cn(style.langSwitherMenu, style.switchBotMenu)}>
{differentBots.map(bot => (
<li className={style.langItem} key={bot.id}>
<a href={`studio/${bot.id}`}>{bot.name === bot.id ? bot.name : `${bot.name} (${bot.id})`}</a>
<a href={`studio/${bot.id}`}>{getBotDisplayName(bot)}</a>
</li>
))}
{differentBots.length > 0 && <MenuItem divider />}
Expand Down

0 comments on commit 62e7661

Please sign in to comment.