You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ProjectActivityAppRenderer.tsx 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 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 styled from '@emotion/styled';
  21. import {
  22. LargeCenteredLayout,
  23. PageContentFontWrapper,
  24. themeBorder,
  25. themeColor,
  26. } from 'design-system';
  27. import * as React from 'react';
  28. import { Helmet } from 'react-helmet-async';
  29. import A11ySkipTarget from '../../../components/a11y/A11ySkipTarget';
  30. import Suggestions from '../../../components/embed-docs-modal/Suggestions';
  31. import { translate } from '../../../helpers/l10n';
  32. import { ComponentQualifier } from '../../../types/component';
  33. import { MeasureHistory, ParsedAnalysis } from '../../../types/project-activity';
  34. import { Component, Metric } from '../../../types/types';
  35. import { Query } from '../utils';
  36. import ProjectActivityAnalysesList from './ProjectActivityAnalysesList';
  37. import ProjectActivityGraphs from './ProjectActivityGraphs';
  38. import ProjectActivityPageFilters from './ProjectActivityPageFilters';
  39. interface Props {
  40. analyses: ParsedAnalysis[];
  41. analysesLoading: boolean;
  42. graphLoading: boolean;
  43. leakPeriodDate?: Date;
  44. initializing: boolean;
  45. project: Pick<Component, 'configuration' | 'key' | 'leakPeriodDate' | 'qualifier'>;
  46. metrics: Metric[];
  47. measuresHistory: MeasureHistory[];
  48. query: Query;
  49. onUpdateQuery: (changes: Partial<Query>) => void;
  50. }
  51. export default function ProjectActivityAppRenderer(props: Props) {
  52. const {
  53. analyses,
  54. measuresHistory,
  55. query,
  56. leakPeriodDate,
  57. analysesLoading,
  58. initializing,
  59. graphLoading,
  60. metrics,
  61. project,
  62. } = props;
  63. const { configuration, qualifier } = props.project;
  64. const canAdmin =
  65. (qualifier === ComponentQualifier.Project || qualifier === ComponentQualifier.Application) &&
  66. configuration?.showHistory;
  67. const canDeleteAnalyses = configuration?.showHistory;
  68. return (
  69. <main className="sw-p-5" id="project-activity">
  70. <Suggestions suggestions="project_activity" />
  71. <Helmet defer={false} title={translate('project_activity.page')} />
  72. <A11ySkipTarget anchor="activity_main" />
  73. <LargeCenteredLayout>
  74. <PageContentFontWrapper>
  75. <ProjectActivityPageFilters
  76. category={query.category}
  77. from={query.from}
  78. project={props.project}
  79. to={query.to}
  80. updateQuery={props.onUpdateQuery}
  81. />
  82. <div className="sw-grid sw-grid-cols-12 sw-gap-x-12">
  83. <StyledWrapper className="sw-col-span-4 sw-rounded-1">
  84. <ProjectActivityAnalysesList
  85. analyses={analyses}
  86. analysesLoading={analysesLoading}
  87. canAdmin={canAdmin}
  88. canDeleteAnalyses={canDeleteAnalyses}
  89. initializing={initializing}
  90. leakPeriodDate={leakPeriodDate}
  91. project={project}
  92. query={query}
  93. onUpdateQuery={props.onUpdateQuery}
  94. />
  95. </StyledWrapper>
  96. <StyledWrapper className="sw-col-span-8 sw-rounded-1">
  97. <ProjectActivityGraphs
  98. analyses={analyses}
  99. leakPeriodDate={leakPeriodDate}
  100. loading={graphLoading}
  101. measuresHistory={measuresHistory}
  102. metrics={metrics}
  103. project={project.key}
  104. query={query}
  105. updateQuery={props.onUpdateQuery}
  106. />
  107. </StyledWrapper>
  108. </div>
  109. </PageContentFontWrapper>
  110. </LargeCenteredLayout>
  111. </main>
  112. );
  113. }
  114. const StyledWrapper = styled.div`
  115. border: ${themeBorder('default', 'filterbarBorder')};
  116. background-color: ${themeColor('backgroundSecondary')};
  117. `;