Skip to content

Commit

Permalink
some minor changes (elastic#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSh authored and orouz committed Dec 21, 2021
1 parent ddc6a83 commit a013723
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useNavigateToCSPFindings = () => {
return {
navigate: (query: string) =>
history.push({
pathname: '/csp/findings',
pathname: '/findings',
search: new URLSearchParams([['query', query]].filter((p) => !!p[1])).toString(),
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ import {
niceTimeFormatByDay,
AreaSeries,
} from '@elastic/charts';
import { dateValueToTuple } from '../index';
// TODO: find out how to import from the server folder without warnings
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { BenchmarkStats } from '../../../../../server/cloud_posture/types';
import type { BenchmarkStats } from '../../../../common/types';

interface ComplianceTrendChartProps {
data: BenchmarkStats;
}

export const dateValueToTuple = ({ date, value }: { date: number; value: number }) => [date, value];

export const ComplianceTrendChart = ({ data: { postureScore } }: ComplianceTrendChartProps) => {
if (postureScore === undefined) return null;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import { EuiSpacer, EuiTitle } from '@elastic/eui';
import { SummarySection } from './dashboard_sections/summary_section';
import { BenchmarksSection } from './dashboard_sections/benchmarks_section';
import { useCloudPostureStatsApi } from '../../common/api';
import { CspPageTemplate } from '../../components/page_template';

const CompliancePage = () => {
const getStats = useCloudPostureStatsApi();
if (getStats.isLoading) return null;

return (
<>
<EuiTitle>
<h3>{'Summary'}</h3>
</EuiTitle>
<EuiSpacer />
<SummarySection />
<EuiSpacer />
<EuiTitle>
<h3>{'Benchmarks'}</h3>
</EuiTitle>
<EuiSpacer />
<BenchmarksSection />
<EuiSpacer />
</>
);
};

export const ComplianceDashboard = () => (
<CspPageTemplate
pageHeader={{
pageTitle: 'Compliance',
}}
>
<CompliancePage />
</CspPageTemplate>
);
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const BenchmarksSection = () => {
listItems={[
{
title: 'Posture Score',
// TODO: temporary until the type for this are fixed and the score is no longer optional (right now can fail if score equals 0).
description: benchmark.postureScore || 'error',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,4 @@
* 2.0.
*/

import React from 'react';
import { EuiSpacer, EuiTitle } from '@elastic/eui';
import { SummarySection } from './dashboard_sections/summary_section';
import { BenchmarksSection } from './dashboard_sections/benchmarks_section';
import { useCloudPostureStatsApi } from '../../common/api';
import { CspPageTemplate } from '../../components/page_template';

export const dateValueToTuple = ({ date, value }: { date: number; value: number }) => [date, value];

const CompliancePage = () => {
const getStats = useCloudPostureStatsApi();
if (getStats.isLoading) return null;

return (
<>
<EuiTitle>
<h3>{'Summary'}</h3>
</EuiTitle>
<EuiSpacer />
<SummarySection />
<EuiSpacer />
<EuiTitle>
<h3>{'Benchmarks'}</h3>
</EuiTitle>
<EuiSpacer />
<BenchmarksSection />
<EuiSpacer />
</>
);
};

export const ComplianceDashboard = () => (
<CspPageTemplate
pageHeader={{
pageTitle: 'Compliance',
}}
>
<CompliancePage />
</CspPageTemplate>
);
export * from './compliance_dashboard';

0 comments on commit a013723

Please sign in to comment.