feat(executions): display execution step id (#1232)

* feat(executions): display execution step id

* refactor: remove conditional components in execution steps

---------

Co-authored-by: Ali BARIN <ali.barin53@gmail.com>
This commit is contained in:
Rıdvan Akca
2023-08-23 22:53:16 +03:00
committed by GitHub
parent fd184239d6
commit a909966562
4 changed files with 82 additions and 26 deletions

View File

@@ -6,6 +6,8 @@ import Tooltip from '@mui/material/Tooltip';
import Typography from '@mui/material/Typography'; import Typography from '@mui/material/Typography';
import type { IExecution } from '@automatisch/types'; import type { IExecution } from '@automatisch/types';
import useFormatMessage from 'hooks/useFormatMessage';
type ExecutionHeaderProps = { type ExecutionHeaderProps = {
execution: IExecution; execution: IExecution;
}; };
@@ -19,13 +21,18 @@ function ExecutionName(props: Pick<IExecution['flow'], 'name'>) {
} }
function ExecutionId(props: Pick<IExecution, 'id'>) { function ExecutionId(props: Pick<IExecution, 'id'>) {
return ( const formatMessage = useFormatMessage();
<Box sx={{ display: 'flex' }}>
<Typography variant="body2"> const id = (
Execution ID:{' '}
<Typography variant="body1" component="span"> <Typography variant="body1" component="span">
{props.id} {props.id}
</Typography> </Typography>
);
return (
<Box sx={{ display: 'flex' }}>
<Typography variant="body2">
{formatMessage('execution.id', { id })}
</Typography> </Typography>
</Box> </Box>
); );

View File

@@ -21,6 +21,7 @@ import {
AppIconStatusIconWrapper, AppIconStatusIconWrapper,
Content, Content,
Header, Header,
Metadata,
Wrapper, Wrapper,
} from './style'; } from './style';
@@ -31,6 +32,24 @@ type ExecutionStepProps = {
executionStep: IExecutionStep; executionStep: IExecutionStep;
}; };
function ExecutionStepId(props: Pick<IExecutionStep, 'id'>) {
const formatMessage = useFormatMessage();
const id = (
<Typography variant="caption" component="span">
{props.id}
</Typography>
);
return (
<Box sx={{ display: 'flex' }} gridArea="id">
<Typography variant="caption" fontWeight="bold">
{formatMessage('executionStep.id', { id })}
</Typography>
</Box>
);
}
function ExecutionStepDate(props: Pick<IExecutionStep, 'createdAt'>) { function ExecutionStepDate(props: Pick<IExecutionStep, 'createdAt'>) {
const formatMessage = useFormatMessage(); const formatMessage = useFormatMessage();
const createdAt = DateTime.fromMillis(parseInt(props.createdAt, 10)); const createdAt = DateTime.fromMillis(parseInt(props.createdAt, 10));
@@ -76,20 +95,22 @@ export default function ExecutionStep(
return ( return (
<Wrapper elevation={1} data-test="execution-step"> <Wrapper elevation={1} data-test="execution-step">
<Header> <Header>
<Stack direction="row" gap={2}> <Stack direction="row" gap={3}>
<AppIconWrapper> <AppIconWrapper>
<AppIconStatusIconWrapper>
<AppIcon url={app?.iconUrl} name={app?.name} /> <AppIcon url={app?.iconUrl} name={app?.name} />
<AppIconStatusIconWrapper>
{validationStatusIcon} {validationStatusIcon}
</AppIconStatusIconWrapper> </AppIconStatusIconWrapper>
</AppIconWrapper> </AppIconWrapper>
<Box flex="1"> <Metadata flex="1">
<ExecutionStepId id={executionStep.step.id} />
<Box flex="1" gridArea="step">
<Typography variant="caption"> <Typography variant="caption">
{isTrigger {isTrigger && formatMessage('flowStep.triggerType')}
? formatMessage('flowStep.triggerType') {isAction && formatMessage('flowStep.actionType')}
: formatMessage('flowStep.actionType')}
</Typography> </Typography>
<Typography variant="body2"> <Typography variant="body2">
@@ -97,9 +118,14 @@ export default function ExecutionStep(
</Typography> </Typography>
</Box> </Box>
<Box alignSelf="flex-end"> <Box
display="flex"
justifyContent={["left", "right"]}
gridArea="date"
>
<ExecutionStepDate createdAt={executionStep.createdAt} /> <ExecutionStepDate createdAt={executionStep.createdAt} />
</Box> </Box>
</Metadata>
</Stack> </Stack>
</Header> </Header>

View File

@@ -1,18 +1,22 @@
import { styled, alpha } from '@mui/material/styles'; import { styled, alpha } from '@mui/material/styles';
import Card from '@mui/material/Card'; import Card from '@mui/material/Card';
import Box from '@mui/material/Box';
export const AppIconWrapper = styled('div')` export const AppIconWrapper = styled('div')`
position: relative; display: flex;
align-items: center;
`; `;
export const AppIconStatusIconWrapper = styled('span')` export const AppIconStatusIconWrapper = styled('span')`
display: inline-flex;
position: relative;
svg {
position: absolute; position: absolute;
right: 0; right: 0;
top: 0; top: 0;
transform: translate(50%, -50%); transform: translate(50%, -50%);
display: inline-flex;
svg {
// to make it distinguishable over an app icon // to make it distinguishable over an app icon
background: white; background: white;
border-radius: 100%; border-radius: 100%;
@@ -31,7 +35,7 @@ type HeaderProps = {
export const Header = styled('div', { export const Header = styled('div', {
shouldForwardProp: (prop) => prop !== 'collapsed', shouldForwardProp: (prop) => prop !== 'collapsed',
})<HeaderProps>` }) <HeaderProps>`
padding: ${({ theme }) => theme.spacing(2)}; padding: ${({ theme }) => theme.spacing(2)};
cursor: ${({ collapsed }) => (collapsed ? 'pointer' : 'unset')}; cursor: ${({ collapsed }) => (collapsed ? 'pointer' : 'unset')};
`; `;
@@ -42,3 +46,20 @@ export const Content = styled('div')`
border-right: none; border-right: none;
padding: ${({ theme }) => theme.spacing(2, 0)}; padding: ${({ theme }) => theme.spacing(2, 0)};
`; `;
export const Metadata = styled(Box)`
display: grid;
grid-template-columns: 1fr auto;
grid-template-rows: auto auto;
grid-template-areas:
"step id"
"step date";
${({ theme }) => theme.breakpoints.down('sm')} {
grid-template-rows: auto auto auto;
grid-template-areas:
"id"
"step"
"date";
}
` as typeof Box;

View File

@@ -86,12 +86,14 @@
"flowEditor.goBack": "Go back to flows", "flowEditor.goBack": "Go back to flows",
"executions.title": "Executions", "executions.title": "Executions",
"executions.noExecutions": "There is no execution data point to show.", "executions.noExecutions": "There is no execution data point to show.",
"execution.id": "Execution ID: {id}",
"execution.updatedAt": "updated {datetime}", "execution.updatedAt": "updated {datetime}",
"execution.test": "Test run", "execution.test": "Test run",
"execution.statusSuccess": "Success", "execution.statusSuccess": "Success",
"execution.statusFailure": "Failure", "execution.statusFailure": "Failure",
"execution.noDataTitle": "No data", "execution.noDataTitle": "No data",
"execution.noDataMessage": "We successfully ran the execution, but there was no new data to process.", "execution.noDataMessage": "We successfully ran the execution, but there was no new data to process.",
"executionStep.id": "ID: {id}",
"executionStep.executedAt": "executed {datetime}", "executionStep.executedAt": "executed {datetime}",
"profileSettings.title": "My Profile", "profileSettings.title": "My Profile",
"profileSettings.fullName": "Full name", "profileSettings.fullName": "Full name",