Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error counter to menu bar errors Report Button #611

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/components/Controllers/Table/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ export default function Menu() {

const isTableUpdated = store.useStore(store.getIsTableOrResourceUpdated)

console.log('report', report)

return (
<menu.MenuBar fullWidth>
<Box sx={{ width: '100%', display: 'flex', justifyContent: 'space-between' }}>
<Box
sx={{
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
}}
>
<menu.MetadataButton
Expand All @@ -31,6 +34,7 @@ export default function Menu() {
active={panel === 'report'}
onClick={() => store.togglePanel('report')}
color="OKFNCoolGray"
numberErrors={report?.stats.errors}
/>
<menu.SourceButton
disabled={!source?.text}
Expand Down
7 changes: 6 additions & 1 deletion client/components/Parts/Bars/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export interface ButtonProps {
onClick?: () => void
}

interface ErrorsReportProps extends ButtonProps {
numberErrors?: number
}

export function MetadataButton(props: ButtonProps) {
const theme = useTheme()
const onClick = props.onClick || noop
Expand Down Expand Up @@ -83,7 +87,7 @@ export function MetadataButton(props: ButtonProps) {
)
}

export function ReportButton(props: ButtonProps) {
export function ReportButton(props: ErrorsReportProps ) {
const theme = useTheme()
const onClick = props.onClick || noop
useKeyPress(['alt.r'], (event) => {
Expand Down Expand Up @@ -111,6 +115,7 @@ export function ReportButton(props: ButtonProps) {
color: props.enabled ? theme.palette.info.main : undefined,
},
}}
extraInfo={props.numberErrors}
/>
</Box>
)
Expand Down
13 changes: 11 additions & 2 deletions client/components/Parts/Buttons/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import * as React from 'react'
import Typography from '@mui/material/Typography'
import Button, { ButtonProps } from '@mui/material/Button'

import Box from '@mui/material/Box'
interface IconButtonProps extends ButtonProps {
Icon: React.ElementType
label?: string
small?: boolean
extraInfo?: string | number
}

export default function IconButton(props: IconButtonProps) {
const { Icon, label, small, ...others } = props
const { Icon, label, small, extraInfo, ...others } = props

return (
<Button
fullWidth={!props.small}
Expand All @@ -24,6 +26,13 @@ export default function IconButton(props: IconButtonProps) {
) : (
label
)}
{extraInfo ? (
<Box sx={{ padding: '3px 5px', backgroundColor: '#FCF2F2', border: '1px solid #FECBCA', borderRadius: '3px', marginLeft: '5px' }}>
<Typography sx={{ fontSize: '9px', fontWeight: 300, color: (theme) => theme.palette.OKFNRed500.main }}>
{extraInfo}
</Typography>
</Box>
) : null}
</Button>
)
}
Loading