Skip to content

Commit

Permalink
Adapt fields to admin v4
Browse files Browse the repository at this point in the history
  • Loading branch information
vcastellm committed Feb 8, 2024
1 parent 0acb306 commit a1e1799
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap"
rel="stylesheet"
/>
<script>window.global = window;</script>
<script>window.DKRON_API_URL = {{.DKRON_API_URL }};
window.DKRON_LEADER = {{.DKRON_LEADER }};
window.DKRON_TOTAL_JOBS = {{.DKRON_TOTAL_JOBS }};
Expand Down
7 changes: 5 additions & 2 deletions ui/src/jobs/EnabledField.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import SuccessIcon from '@mui/icons-material/CheckCircle';
import FailedIcon from '@mui/icons-material/Cancel';
import { Tooltip } from '@mui/material';
import { useRecordContext } from 'react-admin';

const EnabledField = (props: any) => {
if (props.record !== undefined && props.record[props.source] === true) {
const EnabledField = () => {
const record = useRecordContext();

if (record.disabled) {
return <Tooltip title="Disabled"><FailedIcon htmlColor="red" /></Tooltip>
} else {
return <Tooltip title="Enabled"><SuccessIcon htmlColor="green" /></Tooltip>
Expand Down
19 changes: 9 additions & 10 deletions ui/src/jobs/StatusField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import SuccessIcon from '@mui/icons-material/CheckCircle';
import FailedIcon from '@mui/icons-material/Cancel';
import UntriggeredIcon from '@mui/icons-material/Timer';
import { Tooltip } from '@mui/material';
import { useRecordContext } from 'react-admin';

const StatusField = (props: any) => {
if (props.record === undefined) {
return null
const StatusField = () => {
const record = useRecordContext();

if (record.status === 'success') {
return <Tooltip title="Success"><SuccessIcon htmlColor="green" /></Tooltip>
} else if (record.status === 'failed') {
return <Tooltip title="Error"><FailedIcon htmlColor="red" /></Tooltip>
} else {
if (props.record[props.source] === 'success') {
return <Tooltip title="Success"><SuccessIcon htmlColor="green" /></Tooltip>
} else if (props.record[props.source] === 'failed') {
return <Tooltip title="Error"><FailedIcon htmlColor="red" /></Tooltip>
} else {
return <Tooltip title="Waiting to Run"><UntriggeredIcon htmlColor="blue" /></Tooltip>
}
return <Tooltip title="Waiting to Run"><UntriggeredIcon htmlColor="blue" /></Tooltip>
}
};

Expand Down

0 comments on commit a1e1799

Please sign in to comment.