Fixing cancel ids for selenium (#5896)

* Fixing ids for selenium

* Fixing ids

* Fixing prop
Этот коммит содержится в:
Corey Hulen
2017-03-27 18:12:24 -07:00
коммит произвёл GitHub
родитель 022627f940
Коммит ca8b8d1245
3 изменённых файлов: 15 добавлений и 5 удалений

Просмотреть файл

@@ -87,8 +87,10 @@ export default class SettingItemMax extends React.Component {
} }
let title; let title;
let titleProp = 'unknownTitle';
if (this.props.title) { if (this.props.title) {
title = <li className='col-sm-12 section-title'>{this.props.title}</li>; title = <li className='col-sm-12 section-title'>{this.props.title}</li>;
titleProp = this.props.title;
} }
return ( return (
@@ -107,7 +109,7 @@ export default class SettingItemMax extends React.Component {
{clientError} {clientError}
{submit} {submit}
<a <a
id={Utils.createSafeId(this.props.title.toString() + 'Cancel')} id={Utils.createSafeId(titleProp) + 'Cancel'}
className='btn btn-sm' className='btn btn-sm'
href='#' href='#'
onClick={this.props.updateSection} onClick={this.props.updateSection}

Просмотреть файл

@@ -13,7 +13,7 @@ export default class SettingItemMin extends React.Component {
editButton = ( editButton = (
<li className='col-xs-12 col-sm-3 section-edit'> <li className='col-xs-12 col-sm-3 section-edit'>
<a <a
id={Utils.createSafeId(this.props.title.toString() + 'Edit')} id={Utils.createSafeId(this.props.title) + 'Edit'}
className='theme' className='theme'
href='#' href='#'
onClick={this.props.updateSection} onClick={this.props.updateSection}
@@ -36,7 +36,7 @@ export default class SettingItemMin extends React.Component {
<li className='col-xs-12 col-sm-9 section-title'>{this.props.title}</li> <li className='col-xs-12 col-sm-9 section-title'>{this.props.title}</li>
{editButton} {editButton}
<li <li
id={Utils.createSafeId(this.props.title.toString() + 'Desc')} id={Utils.createSafeId(this.props.title) + 'Desc'}
className='col-xs-12 section-describe' className='col-xs-12 section-describe'
> >
{this.props.describe} {this.props.describe}

Просмотреть файл

@@ -31,11 +31,19 @@ export function isMac() {
return navigator.platform.toUpperCase().indexOf('MAC') >= 0; return navigator.platform.toUpperCase().indexOf('MAC') >= 0;
} }
export function createSafeId(str) { export function createSafeId(prop) {
if (str === null) { if (prop === null) {
return null; return null;
} }
var str = '';
if (prop.props && prop.props.defaultMessage) {
str = prop.props.defaultMessage;
} else {
str = prop.toString();
}
return str.replace(new RegExp(' ', 'g'), '_'); return str.replace(new RegExp(' ', 'g'), '_');
} }