From 4488d338f4739fa6866287d76925e812b9b083d9 Mon Sep 17 00:00:00 2001 From: Niklas Granander Date: Tue, 6 Jul 2021 16:40:48 +0200 Subject: [PATCH] Create StatusMatrix and StatusCell components Signed-off-by: Niklas Granander --- .../OverviewComponent/OverviewComponent.tsx | 8 ++- .../StatusMatrixComponent.tsx | 57 +++++++++++++++++++ .../components/StatusMatrixComponent/index.ts | 16 ++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.tsx create mode 100644 plugins/xcmetrics/src/components/StatusMatrixComponent/index.ts diff --git a/plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.tsx b/plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.tsx index 18e65dd318..bf2a0b845c 100644 --- a/plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.tsx +++ b/plugins/xcmetrics/src/components/OverviewComponent/OverviewComponent.tsx @@ -31,6 +31,7 @@ import { useAsync } from 'react-use'; import { Alert } from '@material-ui/lab'; import { Duration } from 'luxon'; import { Chip } from '@material-ui/core'; +import { StatusMatrixComponent } from '../StatusMatrixComponent'; const formatStatus = (status: BuildStatus, warningCount: number) => { const statusIcons = { @@ -113,7 +114,12 @@ export const OverviewComponent = () => { options={{ paging: false, search: false }} data={builds} columns={columns} - title="Latest Builds" + title={ + <> + Latest Builds + + + } /> ); diff --git a/plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.tsx b/plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.tsx new file mode 100644 index 0000000000..65d8c7af7a --- /dev/null +++ b/plugins/xcmetrics/src/components/StatusMatrixComponent/StatusMatrixComponent.tsx @@ -0,0 +1,57 @@ +/* + * Copyright 2021 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { makeStyles } from '@material-ui/core'; +import React from 'react'; +import { BackstageTheme } from '@backstage/theme'; +import { BuildStatus } from '../../api'; + +const useStyles = makeStyles(theme => ({ + root: { + marginTop: 8, + }, + cell: (props: { status?: BuildStatus }) => { + const statusBackgrounds: { [key in BuildStatus]: string } = { + succeeded: theme.palette.success.main, + failed: theme.palette.error.main, + stopped: theme.palette.warning.main, + }; + + return { + width: 12, + height: 12, + margin: '0 4px 4px 0', + float: 'left', + backgroundColor: statusBackgrounds[props.status!], + }; + }, +})); + +const StatusCell = ({ status }: { status: BuildStatus }) => { + const classes = useStyles({ status }); + return
; +}; + +export const StatusMatrixComponent = () => { + const classes = useStyles(); + + return ( +
+ {[...Array(240).keys()].map(() => ( + + ))} +
+ ); +}; diff --git a/plugins/xcmetrics/src/components/StatusMatrixComponent/index.ts b/plugins/xcmetrics/src/components/StatusMatrixComponent/index.ts new file mode 100644 index 0000000000..623fa9dfb3 --- /dev/null +++ b/plugins/xcmetrics/src/components/StatusMatrixComponent/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2021 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export * from './StatusMatrixComponent';