Skip to content

Commit

Permalink
Fixing issue with ids for selenium (mattermost#5859)
Browse files Browse the repository at this point in the history
* Fixing issue with ids for selenium

* removing comment
  • Loading branch information
coreyhulen committed Mar 24, 2017
1 parent ca1e711 commit 1e4ff97
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/setting_item_max.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default class SettingItemMax extends React.Component {
{clientError}
{submit}
<a
id={this.props.title + 'Cancel'}
id={Utils.createSafeId(this.props.title.toString() + 'Cancel')}
className='btn btn-sm'
href='#'
onClick={this.props.updateSection}
Expand Down
5 changes: 3 additions & 2 deletions components/setting_item_min.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// See License.txt for license information.

import {FormattedMessage} from 'react-intl';
import * as Utils from 'utils/utils.jsx';

import React from 'react';

Expand All @@ -12,7 +13,7 @@ export default class SettingItemMin extends React.Component {
editButton = (
<li className='col-xs-12 col-sm-3 section-edit'>
<a
id={this.props.title}
id={Utils.createSafeId(this.props.title.toString() + 'Edit')}
className='theme'
href='#'
onClick={this.props.updateSection}
Expand All @@ -35,7 +36,7 @@ export default class SettingItemMin extends React.Component {
<li className='col-xs-12 col-sm-9 section-title'>{this.props.title}</li>
{editButton}
<li
id={this.props.title + 'Desc'}
id={Utils.createSafeId(this.props.title.toString() + 'Desc')}
className='col-xs-12 section-describe'
>
{this.props.describe}
Expand Down
8 changes: 8 additions & 0 deletions utils/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ export function isMac() {
return navigator.platform.toUpperCase().indexOf('MAC') >= 0;
}

export function createSafeId(str) {
if (str === null) {
return null;
}

return str.replace(' ', '_');
}

export function cmdOrCtrlPressed(e) {
return (isMac() && e.metaKey) || (!isMac() && e.ctrlKey && !e.altKey);
}
Expand Down

0 comments on commit 1e4ff97

Please sign in to comment.