mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
chore: event timeline grouping
This commit is contained in:
parent
c9bd071c07
commit
0580991942
@ -10,12 +10,17 @@ import {
|
|||||||
type TimeSpanOption,
|
type TimeSpanOption,
|
||||||
timeSpanOptions,
|
timeSpanOptions,
|
||||||
} from './EventTimelineHeader/EventTimelineHeader';
|
} from './EventTimelineHeader/EventTimelineHeader';
|
||||||
|
import type { ISignal } from 'interfaces/signal';
|
||||||
|
|
||||||
export type EnrichedEvent = EventSchema & {
|
export type EnrichedEvent = EventSchema & {
|
||||||
label: string;
|
label: string;
|
||||||
summary: string;
|
summary: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type TimelineEvent = EnrichedEvent | ISignal;
|
||||||
|
|
||||||
|
export type TimelineEventGroup = TimelineEvent[];
|
||||||
|
|
||||||
const StyledRow = styled('div')({
|
const StyledRow = styled('div')({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
@ -8,7 +8,8 @@ import FlagOutlinedIcon from '@mui/icons-material/FlagOutlined';
|
|||||||
import ExtensionOutlinedIcon from '@mui/icons-material/ExtensionOutlined';
|
import ExtensionOutlinedIcon from '@mui/icons-material/ExtensionOutlined';
|
||||||
import SegmentsIcon from '@mui/icons-material/DonutLargeOutlined';
|
import SegmentsIcon from '@mui/icons-material/DonutLargeOutlined';
|
||||||
import QuestionMarkIcon from '@mui/icons-material/QuestionMark';
|
import QuestionMarkIcon from '@mui/icons-material/QuestionMark';
|
||||||
import type { EnrichedEvent } from '../EventTimeline';
|
import type { TimelineEvent, TimelineEventGroup } from '../EventTimeline';
|
||||||
|
import type { ISignal } from 'interfaces/signal';
|
||||||
|
|
||||||
type DefaultEventVariant = 'secondary';
|
type DefaultEventVariant = 'secondary';
|
||||||
type CustomEventVariant = 'success' | 'neutral';
|
type CustomEventVariant = 'success' | 'neutral';
|
||||||
@ -77,16 +78,30 @@ const customEventVariants: Partial<
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface IEventTimelineEventProps {
|
interface IEventTimelineEventProps {
|
||||||
event: EnrichedEvent;
|
event: TimelineEvent | TimelineEventGroup;
|
||||||
startDate: Date;
|
startDate: Date;
|
||||||
endDate: Date;
|
endDate: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isSignal = (
|
||||||
|
event: TimelineEvent | TimelineEventGroup,
|
||||||
|
): event is ISignal => {
|
||||||
|
return !Array.isArray(event) && 'source' in event;
|
||||||
|
};
|
||||||
|
|
||||||
export const EventTimelineEvent = ({
|
export const EventTimelineEvent = ({
|
||||||
event,
|
event,
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
}: IEventTimelineEventProps) => {
|
}: IEventTimelineEventProps) => {
|
||||||
|
if (Array.isArray(event)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSignal(event)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const timelineDuration = endDate.getTime() - startDate.getTime();
|
const timelineDuration = endDate.getTime() - startDate.getTime();
|
||||||
const eventTime = new Date(event.createdAt).getTime();
|
const eventTime = new Date(event.createdAt).getTime();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user