diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-gates/components')
6 files changed, 76 insertions, 71 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Details.js b/server/sonar-web/src/main/js/apps/quality-gates/components/Details.js index 8fd787e3030..8f52c7bbe69 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Details.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Details.js @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import React, { Component } from 'react'; +import React from 'react'; import Helmet from 'react-helmet'; import { fetchQualityGate, @@ -29,8 +29,9 @@ import DetailsContent from './DetailsContent'; import RenameView from '../views/rename-view'; import CopyView from '../views/copy-view'; import DeleteView from '../views/delete-view'; +import { getQualityGatesUrl, getQualityGateUrl } from '../../../helpers/urls'; -export default class Details extends Component { +export default class Details extends React.PureComponent { componentDidMount() { this.fetchDetails(); } @@ -62,14 +63,14 @@ export default class Details extends Component { } handleCopyClick() { - const { qualityGate, onCopy } = this.props; + const { qualityGate, onCopy, organization } = this.props; const { router } = this.context; new CopyView({ qualityGate, onCopy: newQualityGate => { onCopy(newQualityGate); - router.push(`/quality_gates/show/${newQualityGate.id}`); + router.push(getQualityGateUrl(newQualityGate.id, organization && organization.key)); } }).render(); } @@ -85,14 +86,13 @@ export default class Details extends Component { } handleDeleteClick() { - const { qualityGate, onDelete } = this.props; + const { qualityGate, onDelete, organization } = this.props; const { router } = this.context; - new DeleteView({ qualityGate, onDelete: qualityGate => { onDelete(qualityGate); - router.replace('/quality_gates'); + router.replace(getQualityGatesUrl(organization && organization.key)); } }).render(); } @@ -115,6 +115,7 @@ export default class Details extends Component { onCopy={this.handleCopyClick.bind(this)} onSetAsDefault={this.handleSetAsDefaultClick.bind(this)} onDelete={this.handleDeleteClick.bind(this)} + organization={this.props.organization} /> <DetailsContent diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js index 3613be4e567..5c826c2c302 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.js @@ -17,12 +17,12 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import React, { Component } from 'react'; +import React from 'react'; import Conditions from './Conditions'; import Projects from './Projects'; import { translate } from '../../../helpers/l10n'; -export default class DetailsContent extends Component { +export default class DetailsContent extends React.PureComponent { render() { const { gate, canEdit, metrics } = this.props; const { onAddCondition, onDeleteCondition, onSaveCondition } = this.props; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js index 4d518e83238..2f6091184d6 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.js @@ -20,62 +20,62 @@ import React from 'react'; import { translate } from '../../../helpers/l10n'; -export default function DetailsHeader({ - qualityGate, - edit, - onRename, - onCopy, - onSetAsDefault, - onDelete -}) { - function handleRenameClick(e) { +export default class DetailsHeader extends React.PureComponent { + handleRenameClick = e => { e.preventDefault(); - onRename(); - } + this.props.onRename(); + }; - function handleCopyClick(e) { + handleCopyClick = e => { e.preventDefault(); - onCopy(); - } + this.props.onCopy(); + }; - function handleSetAsDefaultClick(e) { + handleSetAsDefaultClick = e => { e.preventDefault(); - onSetAsDefault(); - } + this.props.onSetAsDefault(); + }; - function handleDeleteClick(e) { + handleDeleteClick = e => { e.preventDefault(); - onDelete(); - } + this.props.onDelete(); + }; + + render() { + const { qualityGate, edit } = this.props; - return ( - <div className="layout-page-header-panel layout-page-main-header issues-main-header"> - <div className="layout-page-header-panel-inner layout-page-main-header-inner"> - <div className="layout-page-main-inner"> - <h2 className="pull-left"> - {qualityGate.name} - </h2> - {edit && - <div className="pull-right"> - <div className="button-group"> - <button id="quality-gate-rename" onClick={handleRenameClick}> - {translate('rename')} - </button> - <button id="quality-gate-copy" onClick={handleCopyClick}> - {translate('copy')} - </button> - <button id="quality-gate-toggle-default" onClick={handleSetAsDefaultClick}> - {qualityGate.isDefault - ? translate('unset_as_default') - : translate('set_as_default')} - </button> - <button id="quality-gate-delete" className="button-red" onClick={handleDeleteClick}> - {translate('delete')} - </button> - </div> - </div>} + return ( + <div className="layout-page-header-panel layout-page-main-header issues-main-header"> + <div className="layout-page-header-panel-inner layout-page-main-header-inner"> + <div className="layout-page-main-inner"> + <h2 className="pull-left"> + {qualityGate.name} + </h2> + {edit && + <div className="pull-right"> + <div className="button-group"> + <button id="quality-gate-rename" onClick={this.handleRenameClick}> + {translate('rename')} + </button> + <button id="quality-gate-copy" onClick={this.handleCopyClick}> + {translate('copy')} + </button> + <button id="quality-gate-toggle-default" onClick={this.handleSetAsDefaultClick}> + {qualityGate.isDefault + ? translate('unset_as_default') + : translate('set_as_default')} + </button> + <button + id="quality-gate-delete" + className="button-red" + onClick={this.handleDeleteClick}> + {translate('delete')} + </button> + </div> + </div>} + </div> </div> </div> - </div> - ); + ); + } } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/List.js b/server/sonar-web/src/main/js/apps/quality-gates/components/List.js index 9729392a1b8..b6a4d3a8c23 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/List.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/List.js @@ -20,14 +20,15 @@ import React from 'react'; import { Link } from 'react-router'; import { translate } from '../../../helpers/l10n'; +import { getQualityGateUrl } from '../../../helpers/urls'; -export default function List({ qualityGates }) { +export default function List({ organization, qualityGates }) { return ( <div className="list-group"> {qualityGates.map(qualityGate => <Link key={qualityGate.id} - to={`/quality_gates/show/${qualityGate.id}`} + to={getQualityGateUrl(qualityGate.id, organization && organization.key)} activeClassName="active" className="list-group-item" data-id={qualityGate.id}> diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.js b/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.js index a5c96cd7967..33a9c447d13 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.js @@ -17,10 +17,10 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import React, { Component } from 'react'; +import React from 'react'; import ProjectsView from '../views/gate-projects-view'; -export default class Projects extends Component { +export default class Projects extends React.PureComponent { componentDidMount() { this.renderView(); } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js index ff9d95d7bd7..3ac0da688cc 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.js @@ -26,9 +26,14 @@ import { fetchQualityGates as fetchQualityGatesAPI } from '../../../api/quality-gates'; import { translate } from '../../../helpers/l10n'; +import { getQualityGateUrl } from '../../../helpers/urls'; import '../styles.css'; export default class QualityGatesApp extends Component { + static contextTypes = { + router: React.PropTypes.object.isRequired + }; + state = {}; componentDidMount() { @@ -45,37 +50,35 @@ export default class QualityGatesApp extends Component { } handleAdd(qualityGate) { - const { addQualityGate } = this.props; + const { addQualityGate, organization } = this.props; const { router } = this.context; addQualityGate(qualityGate); - router.push(`/quality_gates/show/${qualityGate.id}`); + router.push(getQualityGateUrl(qualityGate.id, organization && organization.key)); } render() { - const { children, qualityGates, edit } = this.props; + const { children, qualityGates, edit, organization } = this.props; const defaultTitle = translate('quality_gates.page'); + const top = organization ? 95 : 30; return ( <div className="layout-page"> <Helmet defaultTitle={defaultTitle} titleTemplate={'%s - ' + defaultTitle} /> <div className="layout-page-side-outer"> - <div className="layout-page-side" style={{ top: 30 }}> + <div className="layout-page-side" style={{ top }}> <div className="layout-page-side-inner"> <div className="layout-page-filters"> <ListHeader canEdit={edit} onAdd={this.handleAdd.bind(this)} /> - {qualityGates && <List qualityGates={qualityGates} />} + {qualityGates && <List organization={organization} qualityGates={qualityGates} />} </div> </div> </div> </div> - {!!qualityGates && children} + {qualityGates != null && + React.Children.map(children, child => React.cloneElement(child, { organization }))} </div> ); } } - -QualityGatesApp.contextTypes = { - router: React.PropTypes.object.isRequired -}; |