renderReportBody()

in widgets/time-tracking-report/src/app/content.js [108:183]


  renderReportBody() {
    const {report, dashboardApi, isIssueView, lastDayOfWeek} = this.props;

    if (
      ReportModel.isReportCalculation(report) ||
      ReportModel.isCalculationRequired(report)
    ) {
      const fromPercentsCoefficient = 0.01;
      const progress = Math.max(report.status.progress || 0, 0);
      const progressValue = progress * fromPercentsCoefficient;

      return (
        <div className="report-widget__progress">
          <div>{i18n('Calculating...')}</div>
          <ProgressBar
            className="report-widget__progress-bar"
            value={progressValue}
          />
        </div>
      );
    }

    if (ReportModel.isReportError(report)) {
      return this.renderReportError(report.status.errorMessage);
    }

    if (ReportModel.isTooBigReportDataError(report)) {
      return this.renderReportError(
        i18n('The report cannot be calculated: the filters in the report settings return too many issues')
      );
    }

    if (ReportModel.isNoReportDataError(report)) {
      return this.renderReportError(i18n('There aren\'t any issues that match the filters in the report settings'));
    }

    const columnsLegend = TimeTrackingReportModel.getColumnsLegend(report);
    const columnsHeader =
      TimeTrackingReportModel.getColumnsHeader(report, lastDayOfWeek);

    const generalGroups =
      TimeTrackingReportModel.getGeneralGroupedLines(report, isIssueView);
    const detailedGroups =
      TimeTrackingReportModel.getDetailedGroupedLines(report, isIssueView);
    const totalSpentTime = TimeTrackingReportModel.getTotalSpentTime(report);

    return (
      <TimeTable
        grouping={report.grouping}
        fetchHub={dashboardApi.fetchHub}
        fetchYouTrack={this.fetchYouTrack}
        presentationControlsPanel={
          <TimeTableSettingsToolbar
            youTrack={this.props.youTrack}
            dashboardApi={this.props.dashboardApi}
            onChangeYAxis={this.props.onChangeYAxis}
            onChangeReportGrouping={this.props.onChangeReportGrouping}
            grouping={report.grouping}
            projects={report.projects}
            isIssueView={isIssueView}
            disabled={!report.editable}
          />
        }

        columnsLegend={columnsLegend}
        columnsHeader={columnsHeader}
        generalGroups={generalGroups}
        detailedGroups={detailedGroups}
        totalSpentTime={totalSpentTime}
        isIssueView={isIssueView}
        homeUrl={this.props.youTrack.homeUrl}
        withDetails={this.props.withDetails}
        onChangeDetailsVisibility={this.props.onChangeDetailsVisibility}
      />
    );
  }