Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: view diff in edit segment CR #8874

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type React from 'react';
import type { VFC, FC, ReactNode } from 'react';
import type { FC, ReactNode } from 'react';
import { Box, styled, Typography } from '@mui/material';
import type {
ChangeRequestState,
Expand Down Expand Up @@ -52,12 +52,15 @@ const SegmentContainer = styled(Box, {
borderRadius: `0 0 ${theme.shape.borderRadiusLarge}px ${theme.shape.borderRadiusLarge}px`,
}));

export const SegmentChangeDetails: VFC<{
export const SegmentChangeDetails: FC<{
actions?: ReactNode;
change: IChangeRequestUpdateSegment | IChangeRequestDeleteSegment;
changeRequestState: ChangeRequestState;
}> = ({ actions, change, changeRequestState }) => {
const { segment: currentSegment } = useSegment(change.payload.id);
const snapshotSegment = change.payload.snapshot;
const referenceSegment =
changeRequestState === 'Applied' ? snapshotSegment : currentSegment;

return (
<SegmentContainer conflict={change.conflict}>
Expand Down Expand Up @@ -97,7 +100,7 @@ export const SegmentChangeDetails: VFC<{
<SegmentTooltipLink change={change}>
<SegmentDiff
change={change}
currentSegment={currentSegment}
currentSegment={referenceSegment}
/>
</SegmentTooltipLink>
</ChangeItemInfo>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const SegmentDiff: FC<{
<EventDiff
entry={{
preData: omit(currentSegment, ['createdAt', 'createdBy']),
data: changeRequestSegment,
data: omit(changeRequestSegment, ['snapshot']),
}}
/>
</StyledCodeSection>
Expand All @@ -56,9 +56,15 @@ const StyledContainer: FC<{ children?: React.ReactNode }> = styled('div')(
}),
);

const ViewDiff = styled('span')(({ theme }) => ({
color: theme.palette.primary.main,
marginLeft: theme.spacing(1),
}));

const Truncated = styled('div')(() => ({
...textTruncated,
maxWidth: 500,
display: 'flex',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what's the flex doing here? Is it just aligning the items on a row (which used to not be necessary because there was only one item)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, preventing elements from being put one below the other. We prefer a horizontal row similar to strategy changes

}));

export const SegmentTooltipLink: FC<IStrategyTooltipLinkProps> = ({
Expand All @@ -67,17 +73,18 @@ export const SegmentTooltipLink: FC<IStrategyTooltipLinkProps> = ({
}) => (
<StyledContainer>
<Truncated>
<NameWithChangeInfo
previousName={change.name}
newName={change.payload.name}
/>
<TooltipLink
tooltip={children}
tooltipProps={{
maxWidth: 500,
maxHeight: 600,
}}
>
<NameWithChangeInfo
previousName={change.name}
newName={change.payload.name}
/>
<ViewDiff>View Diff</ViewDiff>
</TooltipLink>
</Truncated>
</StyledContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export interface IChangeRequestDeleteSegment {
payload: {
id: number;
name: string;
snapshot?: ISegment;
};
}

Expand Down
Loading