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: display potential conflicts in existing change requests #5521

Merged
merged 6 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Expand Up @@ -13,6 +13,7 @@ import { VariantPatch } from './VariantPatch/VariantPatch';
import { EnvironmentStrategyExecutionOrder } from './EnvironmentStrategyExecutionOrder/EnvironmentStrategyExecutionOrder';
import { ArchiveFeatureChange } from './ArchiveFeatureChange';
import { DependencyChange } from './DependencyChange';
import { Link } from 'react-router-dom';

const StyledSingleChangeBox = styled(Box, {
shouldForwardProp: (prop: string) => !prop.startsWith('$'),
Expand Down Expand Up @@ -56,6 +57,15 @@ const StyledAlert = styled(Alert)(({ theme }) => ({
},
}));

const InlineList = styled('ul')(({ theme }) => ({
display: 'inline',
padding: 0,
li: { display: 'inline' },
'li + li::before': {
content: '", "',
},
}));

export const FeatureChange: FC<{
actions: ReactNode;
index: number;
Expand All @@ -68,12 +78,17 @@ export const FeatureChange: FC<{
? feature.changes.length + 1
: feature.changes.length;

console.log('working with conflicts', change.scheduleConflicts);

return (
<StyledSingleChangeBox
key={objectId(change)}
$hasConflict={Boolean(change.conflict)}
$hasConflict={Boolean(change.conflict || change.scheduleConflicts)}
$isInConflictFeature={Boolean(feature.conflict)}
$isAfterWarning={Boolean(feature.changes[index - 1]?.conflict)}
$isAfterWarning={Boolean(
feature.changes[index - 1]?.conflict ||
feature.changes[index - 1]?.scheduleConflicts,
)}
$isLast={index + 1 === lastIndex}
>
<ConditionallyRender
Expand All @@ -86,6 +101,41 @@ export const FeatureChange: FC<{
}
/>

<ConditionallyRender
condition={Boolean(change.scheduleConflicts)}
show={
<StyledAlert severity='warning'>
<strong>Potential conflict!</strong> This change would
create conflicts with the following scheduled change
request(s):{' '}
<InlineList>
{(
change.scheduleConflicts ?? {
changeRequests: [],
}
).changeRequests.map(({ id, title }) => {
const text = title
? `#${id} (${title})`
: `#${id}`;
return (
<li key={id}>
<Link
to={`/projects/${changeRequest.project}/change-requests/${id}`}
target='_blank'
rel='noopener noreferrer'
title={`Change request ${id}`}
>
{text}
</Link>
</li>
);
})}
.
</InlineList>
</StyledAlert>
}
/>

<Box sx={(theme) => ({ padding: theme.spacing(3) })}>
{(change.action === 'addDependency' ||
change.action === 'deleteDependency') && (
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/component/changeRequest/changeRequest.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export interface IChangeRequestChangeBase {
conflict?: string;
createdBy?: Pick<IUser, 'id' | 'username' | 'imageUrl'>;
createdAt?: Date;
scheduleConflicts?: {
changeRequests: { id: number; title: string | null }[];
};
}

export type ChangeRequestState =
Expand Down
Loading