您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2018 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 * as PropTypes from 'prop-types';
  22. import MetaKey from './MetaKey';
  23. import MetaOrganizationKey from './MetaOrganizationKey';
  24. import MetaLinks from './MetaLinks';
  25. import MetaQualityGate from './MetaQualityGate';
  26. import MetaQualityProfiles from './MetaQualityProfiles';
  27. import MetaSize from './MetaSize';
  28. import MetaTags from './MetaTags';
  29. import BadgesModal from '../badges/BadgesModal';
  30. import AnalysesList from '../events/AnalysesList';
  31. import { Visibility, Component, Metric, BranchLike } from '../../../app/types';
  32. import { History } from '../../../api/time-machine';
  33. import { translate } from '../../../helpers/l10n';
  34. import { MeasureEnhanced } from '../../../helpers/measures';
  35. interface Props {
  36. branchLike?: BranchLike;
  37. component: Component;
  38. history?: History;
  39. measures: MeasureEnhanced[];
  40. metrics: { [key: string]: Metric };
  41. onComponentChange: (changes: {}) => void;
  42. }
  43. export default class Meta extends React.PureComponent<Props> {
  44. static contextTypes = {
  45. onSonarCloud: PropTypes.bool,
  46. organizationsEnabled: PropTypes.bool
  47. };
  48. render() {
  49. const { onSonarCloud, organizationsEnabled } = this.context;
  50. const { branchLike, component, metrics } = this.props;
  51. const { qualifier, description, qualityProfiles, qualityGate, visibility } = component;
  52. const isProject = qualifier === 'TRK';
  53. const isPrivate = visibility === Visibility.Private;
  54. return (
  55. <div className="overview-meta">
  56. <div className="overview-meta-card">
  57. <h4 className="overview-meta-header">
  58. {translate('overview.about_this_project', qualifier)}
  59. </h4>
  60. {description !== undefined && <p className="overview-meta-description">{description}</p>}
  61. {isProject && (
  62. <MetaTags component={component} onComponentChange={this.props.onComponentChange} />
  63. )}
  64. <MetaSize branchLike={branchLike} component={component} measures={this.props.measures} />
  65. </div>
  66. <AnalysesList
  67. branchLike={branchLike}
  68. component={component}
  69. history={this.props.history}
  70. metrics={metrics}
  71. qualifier={component.qualifier}
  72. />
  73. {isProject && (
  74. <div className="overview-meta-card">
  75. {qualityGate && (
  76. <MetaQualityGate
  77. organization={organizationsEnabled ? component.organization : undefined}
  78. qualityGate={qualityGate}
  79. />
  80. )}
  81. {qualityProfiles &&
  82. qualityProfiles.length > 0 && (
  83. <MetaQualityProfiles
  84. headerClassName={qualityGate ? 'big-spacer-top' : undefined}
  85. organization={organizationsEnabled ? component.organization : undefined}
  86. profiles={qualityProfiles}
  87. />
  88. )}
  89. </div>
  90. )}
  91. {isProject && <MetaLinks component={component} />}
  92. <div className="overview-meta-card">
  93. <MetaKey componentKey={component.key} qualifier={component.qualifier} />
  94. {organizationsEnabled && <MetaOrganizationKey organization={component.organization} />}
  95. </div>
  96. {!isPrivate && (
  97. <BadgesModal
  98. branchLike={branchLike}
  99. metrics={metrics}
  100. onSonarCloud={onSonarCloud}
  101. project={component.key}
  102. qualifier={component.qualifier}
  103. />
  104. )}
  105. </div>
  106. );
  107. }
  108. }