aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx
blob: 45b0f93ce0fea7670b3e9fe075e8289ba546966e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * SonarQube
 * Copyright (C) 2009-2020 SonarSource SA
 * mailto:info 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 { parseDate } from 'sonar-ui-common/helpers/dates';
import A11ySkipTarget from '../../../app/components/a11y/A11ySkipTarget';
import { ApplicationPeriod } from '../../../types/application';
import { BranchLike } from '../../../types/branch-like';
import { GraphType, MeasureHistory } from '../../../types/project-activity';
import { QualityGateStatus } from '../../../types/quality-gates';
import ActivityPanel from './ActivityPanel';
import { MeasuresPanel } from './MeasuresPanel';
import NoCodeWarning from './NoCodeWarning';
import QualityGatePanel from './QualityGatePanel';

export interface BranchOverviewRendererProps {
  analyses?: T.Analysis[];
  branchLike?: BranchLike;
  component: T.Component;
  graph?: GraphType;
  leakPeriod?: T.Period | ApplicationPeriod;
  loadingHistory?: boolean;
  loadingStatus?: boolean;
  measures?: T.MeasureEnhanced[];
  measuresHistory?: MeasureHistory[];
  metrics?: T.Metric[];
  onGraphChange: (graph: GraphType) => void;
  projectIsEmpty?: boolean;
  qgStatuses?: QualityGateStatus[];
}

export function BranchOverviewRenderer(props: BranchOverviewRendererProps) {
  const {
    analyses,
    branchLike,
    component,
    graph,
    leakPeriod,
    loadingHistory,
    loadingStatus,
    measures,
    measuresHistory = [],
    metrics = [],
    onGraphChange,
    projectIsEmpty,
    qgStatuses
  } = props;

  return (
    <div className="page page-limited">
      <div className="overview">
        <A11ySkipTarget anchor="overview_main" />

        {projectIsEmpty ? (
          <NoCodeWarning branchLike={branchLike} component={component} measures={measures} />
        ) : (
          <div className="display-flex-row">
            <div className="width-25 big-spacer-right">
              <QualityGatePanel
                component={component}
                loading={loadingStatus}
                qgStatuses={qgStatuses}
              />
            </div>

            <div className="flex-1">
              <div className="display-flex-column">
                <MeasuresPanel
                  branchLike={branchLike}
                  component={component}
                  leakPeriod={leakPeriod}
                  loading={loadingStatus}
                  measures={measures}
                />

                <ActivityPanel
                  analyses={analyses}
                  branchLike={branchLike}
                  component={component}
                  graph={graph}
                  leakPeriodDate={leakPeriod && parseDate(leakPeriod.date)}
                  loading={loadingHistory}
                  measuresHistory={measuresHistory}
                  metrics={metrics}
                  onGraphChange={onGraphChange}
                />
              </div>
            </div>
          </div>
        )}
      </div>
    </div>
  );
}

export default React.memo(BranchOverviewRenderer);