diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-08-28 11:43:35 +0200 |
---|---|---|
committer | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-09-12 11:34:54 +0200 |
commit | 25140ec8ed74cc5ea5f50f05325f0d4a7f8753fd (patch) | |
tree | 3bfcb2944b2a6150eef40638db25004322cbfd98 /server/sonar-web/src/main/js/components/common/BranchStatus.tsx | |
parent | 030370cf6255d1185ecb3deeaab7de1fe76e058b (diff) | |
download | sonarqube-25140ec8ed74cc5ea5f50f05325f0d4a7f8753fd.tar.gz sonarqube-25140ec8ed74cc5ea5f50f05325f0d4a7f8753fd.zip |
SONAR-9756 Build UI for branch management (#2433)
Diffstat (limited to 'server/sonar-web/src/main/js/components/common/BranchStatus.tsx')
-rw-r--r-- | server/sonar-web/src/main/js/components/common/BranchStatus.tsx | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/components/common/BranchStatus.tsx b/server/sonar-web/src/main/js/components/common/BranchStatus.tsx new file mode 100644 index 00000000000..ae36462f6f5 --- /dev/null +++ b/server/sonar-web/src/main/js/components/common/BranchStatus.tsx @@ -0,0 +1,82 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import * as React from 'react'; +import * as classNames from 'classnames'; +import { Branch } from '../../app/types'; +import Level from '../ui/Level'; +import BugIcon from '../icons-components/BugIcon'; +import CodeSmellIcon from '../icons-components/CodeSmellIcon'; +import VulnerabilityIcon from '../icons-components/VulnerabilityIcon'; +import { isShortLivingBranch } from '../../helpers/branches'; +import './BranchStatus.css'; + +interface Props { + branch: Branch; + concise?: boolean; +} + +export default function BranchStatus({ branch, concise = false }: Props) { + if (isShortLivingBranch(branch)) { + if (!branch.status) { + return null; + } + + const totalIssues = + branch.status.bugs + branch.status.vulnerabilities + branch.status.codeSmells; + + return ( + <ul className="list-inline branch-status"> + <li> + <i + className={classNames('branch-status-indicator', { + 'is-failed': totalIssues > 0, + 'is-passed': totalIssues === 0 + })} + /> + </li> + {concise && + <li> + {totalIssues} + </li>} + {!concise && + <li> + {branch.status.bugs} + <BugIcon className="little-spacer-left" /> + </li>} + {!concise && + <li> + {branch.status.vulnerabilities} + <VulnerabilityIcon className="little-spacer-left" /> + </li>} + {!concise && + <li> + {branch.status.codeSmells} + <CodeSmellIcon className="little-spacer-left" /> + </li>} + </ul> + ); + } else { + if (!branch.status) { + return null; + } + + return <Level level={branch.status.qualityGateStatus} small={true} />; + } +} |