Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ProjectCard.tsx 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import * as React from 'react';
  21. import { sortBy } from 'lodash';
  22. import { Link } from 'react-router';
  23. import DateFromNow from '../../../components/intl/DateFromNow';
  24. import DateTimeFormatter from '../../../components/intl/DateTimeFormatter';
  25. import HelpTooltip from '../../../components/controls/HelpTooltip';
  26. import Level from '../../../components/ui/Level';
  27. import ProjectLinkIcon from '../../../components/icons-components/ProjectLinkIcon';
  28. import Tooltip from '../../../components/controls/Tooltip';
  29. import { translateWithParameters, translate } from '../../../helpers/l10n';
  30. interface Props {
  31. project: T.MyProject;
  32. }
  33. export default function ProjectCard({ project }: Props) {
  34. const links = sortBy(project.links, 'type');
  35. const { lastAnalysisDate } = project;
  36. return (
  37. <div className="account-project-card clearfix">
  38. <aside className="account-project-side">
  39. {lastAnalysisDate !== undefined ? (
  40. <div className="account-project-analysis">
  41. <DateFromNow date={lastAnalysisDate}>
  42. {fromNow => (
  43. <Tooltip overlay={<DateTimeFormatter date={lastAnalysisDate} />}>
  44. <span>{translateWithParameters('my_account.projects.analyzed_x', fromNow)}</span>
  45. </Tooltip>
  46. )}
  47. </DateFromNow>
  48. </div>
  49. ) : (
  50. <div className="account-project-analysis">
  51. {translate('my_account.projects.never_analyzed')}
  52. </div>
  53. )}
  54. {project.qualityGate !== undefined && (
  55. <div className="account-project-quality-gate">
  56. {project.qualityGate === 'WARN' && (
  57. <HelpTooltip
  58. className="little-spacer-right"
  59. overlay={translate('quality_gates.conditions.warning.tootlip')}
  60. />
  61. )}
  62. <Level level={project.qualityGate} />
  63. </div>
  64. )}
  65. </aside>
  66. <h3 className="account-project-name">
  67. <Link to={{ pathname: '/dashboard', query: { id: project.key } }}>{project.name}</Link>
  68. </h3>
  69. {links.length > 0 && (
  70. <div className="account-project-links">
  71. <ul className="list-inline">
  72. {links.map(link => (
  73. <li key={link.type}>
  74. <a
  75. className="link-with-icon"
  76. href={link.href}
  77. rel="nofollow"
  78. target="_blank"
  79. title={link.name}>
  80. <ProjectLinkIcon type={link.type} />
  81. </a>
  82. </li>
  83. ))}
  84. </ul>
  85. </div>
  86. )}
  87. <div className="account-project-key">{project.key}</div>
  88. {!!project.description && (
  89. <div className="account-project-description">{project.description}</div>
  90. )}
  91. </div>
  92. );
  93. }