diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2017-01-18 14:13:02 +0100 |
---|---|---|
committer | Stas Vilchik <stas-vilchik@users.noreply.github.com> | 2017-01-24 09:25:53 +0100 |
commit | fdffb1a9e22c4fb9e97ce6f6ded76fff720a440d (patch) | |
tree | 31d07ea4693ca4a92b272c53e01d2a36fe0740a5 /server | |
parent | d758d6bf03f5cd4ba5b9e55f7370a8dd95e4747a (diff) | |
download | sonarqube-fdffb1a9e22c4fb9e97ce6f6ded76fff720a440d.tar.gz sonarqube-fdffb1a9e22c4fb9e97ce6f6ded76fff720a440d.zip |
SONAR-8629 Display organization on the Background Tasks page
Diffstat (limited to 'server')
3 files changed, 48 insertions, 26 deletions
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js index 45be61d8a9c..f2c479b3fb3 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js @@ -21,6 +21,7 @@ import React from 'react'; import shallowCompare from 'react-addons-shallow-compare'; import debounce from 'lodash/debounce'; +import uniq from 'lodash/uniq'; import { connect } from 'react-redux'; import { DEFAULT_FILTERS, DEBOUNCE_DELAY, STATUSES, CURRENTS } from './../constants'; import Header from './Header'; @@ -33,10 +34,12 @@ import { updateTask, mapFiltersToParameters } from '../utils'; import { Task } from '../types'; import { getComponent } from '../../../store/rootReducer'; import '../background-tasks.css'; +import { fetchOrganizations } from '../../../store/rootActions'; type Props = { component: Object, - location: Object + location: Object, + fetchOrganizations: (Array<string>) => string }; type State = { @@ -125,6 +128,9 @@ class BackgroundTasksApp extends React.Component { const pendingCount = status.pending; const failingCount = status.failing; + const organizations = uniq(tasks.map(task => task.organization).filter(o => o)); + this.props.fetchOrganizations(organizations); + this.setState({ tasks, pendingCount, @@ -245,4 +251,6 @@ const mapStateToProps = (state, ownProps) => ({ component: ownProps.location.query.id ? getComponent(state, ownProps.location.query.id) : undefined }); -export default connect(mapStateToProps)(BackgroundTasksApp); +const mapDispatchToProps = { fetchOrganizations }; + +export default connect(mapStateToProps, mapDispatchToProps)(BackgroundTasksApp); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.js b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.js index 628f5f2f644..a99eea3658f 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.js @@ -17,38 +17,49 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - /* @flow */ +/* @flow */ import React from 'react'; import { Link } from 'react-router'; import TaskType from './TaskType'; import QualifierIcon from '../../../components/shared/qualifier-icon'; +import Organization from '../../../components/shared/Organization'; import { Task } from '../types'; -const TaskComponent = ({ task, types }: { task: Task, types: string[] }) => { - if (!task.componentKey) { +export default class TaskComponent extends React.Component { + props: { + task: Task, + types: Array<string> + }; + + render () { + const { task, types } = this.props; + + if (!task.componentKey) { + return ( + <td> + <span className="note">{task.id}</span> + {types.length > 1 && ( + <TaskType task={task}/> + )} + </td> + ); + } + return ( <td> - <span className="note">{task.id}</span> + {task.organization != null && ( + <Organization organizationKey={task.organization}/> + )} + <Link to={{ pathname: '/dashboard', query: { id: task.componentKey } }} className="link-with-icon"> + <span className="little-spacer-right"> + <QualifierIcon qualifier={task.componentQualifier}/> + </span> + <span>{task.componentName}</span> + </Link> {types.length > 1 && ( <TaskType task={task}/> )} </td> ); } - - return ( - <td> - <Link to={{ pathname: '/dashboard', query: { id: task.componentKey } }} className="link-with-icon"> - <span className="little-spacer-right"> - <QualifierIcon qualifier={task.componentQualifier}/> - </span> - <span>{task.componentName}</span> - </Link> - {types.length > 1 && ( - <TaskType task={task}/> - )} - </td> - ); -}; - -export default TaskComponent; +} diff --git a/server/sonar-web/src/main/js/components/shared/Organization.js b/server/sonar-web/src/main/js/components/shared/Organization.js index 716ab38023d..d323a249325 100644 --- a/server/sonar-web/src/main/js/components/shared/Organization.js +++ b/server/sonar-web/src/main/js/components/shared/Organization.js @@ -39,14 +39,17 @@ class Organization extends React.Component { props: Props; render () { - const { organization: org, shouldBeDisplayed } = this.props; + const { organization, shouldBeDisplayed } = this.props; - if (!shouldBeDisplayed || !org) { + if (!shouldBeDisplayed || !organization) { return null; } return ( - <span>{org.name}<span> / </span></span> + <span> + {organization.name} + <span> / </span> + </span> ); } } |