Skip to content

Commit

Permalink
fix(studio): missing translations show up red
Browse files Browse the repository at this point in the history
  • Loading branch information
slvnperron committed Jul 14, 2019
1 parent e84334b commit e981590
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/testing/src/backend/api.ts
Expand Up @@ -70,7 +70,7 @@ export default async (bp: typeof sdk, testByBot: TestByBot) => {
const rendered = elements.map(element => {
return {
id: `#!${element.id}`,
preview: element.previews.en
preview: element.previews.en // TODO: Use the bot's default language instead of hardcoded english
}
})

Expand Down
13 changes: 12 additions & 1 deletion src/bp/ui-studio/src/web/views/Content/List.tsx
@@ -1,4 +1,5 @@
import { AnchorButton, Button, Divider, InputGroup, Position, Tooltip } from '@blueprintjs/core'
import classnames from 'classnames'
import _ from 'lodash'
import moment from 'moment'
import React, { Component } from 'react'
Expand All @@ -7,6 +8,8 @@ import 'react-table/react-table.css'
import { LeftToolbarButtons, Toolbar } from '~/components/Shared/Interface'
import withLanguage from '~/components/Util/withLanguage'

import style from './style.scss'

class ListView extends Component<Props, State> {
private debouncedHandleSearch

Expand Down Expand Up @@ -195,7 +198,15 @@ class ListView extends Component<Props, State> {
Header: 'Preview',
accessor: 'previews',
filterable: false,
Cell: x => x.original.previews && x.original.previews[this.props.contentLang]
Cell: x => {
const preview = x.original.previews && x.original.previews[this.props.contentLang]
const className = classnames({ [style.missingTranslation]: preview.startsWith('(missing translation) ') })
return (
<React.Fragment>
<span className={className}>{preview}</span>
</React.Fragment>
)
}
},
{
Header: 'Modified On',
Expand Down
4 changes: 4 additions & 0 deletions src/bp/ui-studio/src/web/views/Content/style.scss
Expand Up @@ -3,6 +3,10 @@
height: 100%;
}

.missingTranslation {
color: red;
}

.modal {
.cancel {
position: absolute;
Expand Down
1 change: 1 addition & 0 deletions src/bp/ui-studio/src/web/views/Content/style.scss.d.ts
Expand Up @@ -3,6 +3,7 @@
interface CssExports {
'cancel': string;
'content': string;
'missingTranslation': string;
'modal': string;
}
declare var cssExports: CssExports;
Expand Down
8 changes: 6 additions & 2 deletions src/bp/ui-studio/src/web/views/FlowBuilder/common/action.jsx
Expand Up @@ -88,14 +88,18 @@ class ActionItem extends Component {
return '{' + stripDots(x) + '}'
})

const className = classnames(style.name, {
[style.missingTranslation]: preview && preview.startsWith('(missing translation) ')
})

const mustached = restoreDots(Mustache.render(htmlTpl, vars))

const html = { __html: mustached }

return (
<div className={classnames(this.props.className, style['action-item'], style['msg'])}>
<div className={classnames(this.props.className, style['action-item'], style.msg)}>
<span className={style.icon}>💬</span>
<span className={style.name} dangerouslySetInnerHTML={html} />
<span className={className} dangerouslySetInnerHTML={html} />
{this.props.children}
</div>
)
Expand Down
4 changes: 4 additions & 0 deletions src/bp/ui-studio/src/web/views/FlowBuilder/common/style.scss
Expand Up @@ -5,6 +5,10 @@

&.msg {
color: #1cbd57;

.missingTranslation {
color: red;
}
}

&.condition {
Expand Down
Expand Up @@ -7,6 +7,7 @@ interface CssExports {
'editableInput': string;
'fn': string;
'icon': string;
'missingTranslation': string;
'msg': string;
'name': string;
}
Expand Down

0 comments on commit e981590

Please sign in to comment.