This repository has been archived by the owner on Oct 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add search to event log pages (#1205)
* feat: add search to event log pages * refactor: redesign event log pages * refactor: convert makeStyles to styled components
- Loading branch information
Showing
25 changed files
with
399 additions
and
437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import EventDiff from 'component/events/EventDiff/EventDiff'; | ||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; | ||
import { IEvent } from 'interfaces/event'; | ||
import { useLocationSettings } from 'hooks/useLocationSettings'; | ||
import { formatDateYMDHMS } from 'utils/formatDate'; | ||
import { Link } from 'react-router-dom'; | ||
import { styled } from '@mui/material'; | ||
|
||
interface IEventCardProps { | ||
entry: IEvent; | ||
} | ||
|
||
const StyledDefinitionTerm = styled('dt')(({ theme }) => ({ | ||
color: theme.palette.text.secondary, | ||
})); | ||
|
||
const StyledChangesTitle = styled('strong')(({ theme }) => ({ | ||
fontWeight: 'inherit', | ||
color: theme.palette.text.secondary, | ||
})); | ||
|
||
const StyledContainerListItem = styled('li')(({ theme }) => ({ | ||
display: 'grid', | ||
backgroundColor: theme.palette.neutral.light, | ||
borderRadius: theme.shape.borderRadiusLarge, | ||
padding: theme.spacing(0.5), | ||
[theme.breakpoints.up('md')]: { | ||
gridTemplateColumns: 'auto minmax(0, 1fr)', | ||
}, | ||
|
||
'& dl': { | ||
display: 'grid', | ||
gridTemplateColumns: 'auto 1fr', | ||
alignContent: 'start', | ||
gap: theme.spacing(1), | ||
padding: theme.spacing(2), | ||
[theme.breakpoints.up('md')]: { | ||
padding: theme.spacing(4), | ||
}, | ||
}, | ||
})); | ||
|
||
const StyledCodeSection = styled('div')(({ theme }) => ({ | ||
backgroundColor: 'white', | ||
overflowX: 'auto', | ||
padding: theme.spacing(2), | ||
borderBottomLeftRadius: theme.shape.borderRadiusLarge, | ||
borderBottomRightRadius: theme.shape.borderRadiusLarge, | ||
[theme.breakpoints.up('md')]: { | ||
padding: theme.spacing(4), | ||
borderRadius: 0, | ||
borderTopRightRadius: theme.shape.borderRadiusLarge, | ||
borderBottomRightRadius: theme.shape.borderRadiusLarge, | ||
}, | ||
|
||
'& code': { | ||
wordWrap: 'break-word', | ||
whiteSpace: 'pre-wrap', | ||
fontFamily: 'monospace', | ||
lineHeight: 1.5, | ||
fontSize: theme.fontSizes.smallBody, | ||
}, | ||
})); | ||
|
||
const EventCard = ({ entry }: IEventCardProps) => { | ||
const { locationSettings } = useLocationSettings(); | ||
|
||
const createdAtFormatted = formatDateYMDHMS( | ||
entry.createdAt, | ||
locationSettings.locale | ||
); | ||
|
||
return ( | ||
<StyledContainerListItem> | ||
<dl> | ||
<StyledDefinitionTerm>Event id:</StyledDefinitionTerm> | ||
<dd>{entry.id}</dd> | ||
<StyledDefinitionTerm>Changed at:</StyledDefinitionTerm> | ||
<dd>{createdAtFormatted}</dd> | ||
<StyledDefinitionTerm>Event:</StyledDefinitionTerm> | ||
<dd>{entry.type}</dd> | ||
<StyledDefinitionTerm>Changed by:</StyledDefinitionTerm> | ||
<dd title={entry.createdBy}>{entry.createdBy}</dd> | ||
<ConditionallyRender | ||
condition={Boolean(entry.project)} | ||
show={ | ||
<> | ||
<StyledDefinitionTerm> | ||
Project: | ||
</StyledDefinitionTerm> | ||
<dd> | ||
<Link to={`/projects/${entry.project}`}> | ||
{entry.project} | ||
</Link> | ||
</dd> | ||
</> | ||
} | ||
/> | ||
<ConditionallyRender | ||
condition={Boolean(entry.featureName)} | ||
show={ | ||
<> | ||
<StyledDefinitionTerm> | ||
Feature: | ||
</StyledDefinitionTerm> | ||
<dd> | ||
<Link | ||
to={`/projects/${entry.project}/features/${entry.featureName}`} | ||
> | ||
{entry.featureName} | ||
</Link> | ||
</dd> | ||
</> | ||
} | ||
/> | ||
</dl> | ||
<ConditionallyRender | ||
condition={entry.data || entry.preData} | ||
show={ | ||
<StyledCodeSection> | ||
<StyledChangesTitle>Changes:</StyledChangesTitle> | ||
<EventDiff entry={entry} /> | ||
</StyledCodeSection> | ||
} | ||
/> | ||
</StyledContainerListItem> | ||
); | ||
}; | ||
|
||
export default EventCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.