Merge pull request #409 from automatisch/issue-380

feat: add flow app icons and relative date in execution row
This commit is contained in:
Ömer Faruk Aydın
2022-08-07 16:23:00 +03:00
committed by GitHub
5 changed files with 39 additions and 8 deletions

View File

@@ -13,7 +13,11 @@ const getExecutions = async (
) => {
const executions = context.currentUser
.$relatedQuery('executions')
.withGraphFetched('flow')
.withGraphFetched({
flow: {
steps: true
}
})
.orderBy('created_at', 'desc');
return paginate(executions, params.limit, params.offset);

View File

@@ -6,26 +6,34 @@ import Stack from '@mui/material/Stack';
import CardActionArea from '@mui/material/CardActionArea';
import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos';
import { DateTime } from 'luxon';
import type { IExecution } from '@automatisch/types';
import * as URLS from 'config/urls';
import { CardContent, Typography } from './style';
import useFormatMessage from 'hooks/useFormatMessage';
import FlowAppIcons from 'components/FlowAppIcons';
import { Apps, CardContent, Typography } from './style';
type ExecutionRowProps = {
execution: IExecution;
}
const getHumanlyDate = (timestamp: number) => DateTime.fromMillis(timestamp).toLocaleString(DateTime.DATETIME_MED);
export default function ExecutionRow(props: ExecutionRowProps): React.ReactElement {
const formatMessage = useFormatMessage();
const { execution } = props;
const { flow } = execution;
const createdAt = DateTime.fromMillis(parseInt(execution.createdAt, 10));
const relativeCreatedAt = createdAt.toRelative();
return (
<Link to={URLS.EXECUTION(execution.id)}>
<Card sx={{ mb: 1 }}>
<CardActionArea>
<CardContent>
<Apps direction="row" gap={1} sx={{gridArea:"apps"}}>
<FlowAppIcons steps={flow.steps} />
</Apps>
<Stack
justifyContent="center"
alignItems="flex-start"
@@ -36,7 +44,7 @@ export default function ExecutionRow(props: ExecutionRowProps): React.ReactEleme
</Typography>
<Typography variant="caption" noWrap>
{getHumanlyDate(parseInt(execution.createdAt, 10))}
{formatMessage('execution.executedAt', { datetime: relativeCreatedAt })}
</Typography>
</Stack>

View File

@@ -1,15 +1,30 @@
import { styled } from '@mui/material/styles';
import MuiCardContent from '@mui/material/CardContent';
import MuiStack from '@mui/material/Stack';
import MuiTypography from '@mui/material/Typography';
export const CardContent = styled(MuiCardContent)(({ theme }) => ({
display: 'grid',
gridTemplateRows: 'auto',
gridTemplateColumns: '1fr auto',
gridColumnGap: theme.spacing(2),
gridTemplateColumns: 'calc(30px * 3 + 8px * 2) minmax(0, auto) min-content',
gridGap: theme.spacing(2),
gridTemplateAreas: `
"apps title menu"
`,
alignItems: 'center',
[theme.breakpoints.down('sm')]: {
gridTemplateAreas: `
"apps menu"
"title menu"
`,
gridTemplateColumns: 'minmax(0, auto) min-content',
gridTemplateRows: 'auto auto',
}
}));
export const Apps = styled(MuiStack)(() => ({
gridArea: 'apps',
}));
export const Typography = styled(MuiTypography)(() => ({
display: 'inline-block',

View File

@@ -17,6 +17,9 @@ export const GET_EXECUTIONS = gql`
id
name
active
steps {
iconUrl
}
}
}
}

View File

@@ -48,6 +48,7 @@
"flows.create": "Create flow",
"flows.title": "Flows",
"executions.title": "Executions",
"execution.executedAt": "executed {datetime}",
"profileSettings.title": "My Profile",
"profileSettings.email": "Email",
"profileSettings.updateEmail": "Update email",