Skip to content

Commit dee3d57

Browse files
committed
feat: display diff severity levels and HTTP methods in OASDiff style
- Add colored level labels (breaking/warn/info) to diff list items and dialog - Show HTTP method and path in "at METHOD /path" format - Pass level and operation props through component hierarchy
1 parent 141d68e commit dee3d57

File tree

3 files changed

+125
-20
lines changed

3 files changed

+125
-20
lines changed

src/features/sidebar/view/internal/diffbar/components/DiffDialog.tsx

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,25 @@ import {
1313
import { softPaperSx } from "@/common/theme/theme"
1414
import MonoQuotedText from "./MonoQuotedText"
1515

16+
type Level = 1 | 2 | 3
17+
18+
const getLevelConfig = (level: Level) => {
19+
switch (level) {
20+
case 3:
21+
return { label: "breaking", color: "#e88388" }
22+
case 2:
23+
return { label: "warn", color: "#dbab79" }
24+
case 1:
25+
default:
26+
return { label: "info", color: "#66c2cd" }
27+
}
28+
}
29+
1630
interface ChangeDetails {
1731
path?: string
1832
text?: string | React.ReactNode
33+
level?: number
34+
operation?: string
1935
}
2036

2137
const DiffDialog = ({
@@ -27,6 +43,8 @@ const DiffDialog = ({
2743
change: ChangeDetails | null
2844
onClose: () => void
2945
}) => {
46+
const levelConfig = getLevelConfig((change?.level ?? 1) as Level)
47+
3048
return (
3149
<Dialog
3250
open={!!open}
@@ -43,28 +61,58 @@ const DiffDialog = ({
4361
>
4462
<DialogTitle>Change Details</DialogTitle>
4563
<DialogContent>
46-
{change?.path && (
47-
<Box sx={{ mb: 2 }}>
48-
<Typography sx={{ mb: 1, fontWeight: 600 }}>Path:</Typography>
64+
<Box sx={{ mb: 2 }}>
65+
<Box sx={{ display: "flex", alignItems: "center", gap: 1, mb: 1 }}>
4966
<Typography
50-
variant="body0"
67+
component="span"
5168
sx={{
52-
p: 1,
5369
fontFamily: "Segoe UI Mono, monospace",
5470
fontWeight: 700,
55-
wordBreak: "break-word",
56-
overflowWrap: "anywhere",
71+
fontSize: "0.85rem",
72+
color: levelConfig.color,
73+
textTransform: "lowercase",
5774
}}
5875
>
59-
{change.path}
76+
{levelConfig.label}
6077
</Typography>
78+
{change?.operation && change?.path && (
79+
<Typography
80+
component="span"
81+
sx={{
82+
fontFamily: "Segoe UI Mono, monospace",
83+
fontSize: "0.85rem",
84+
color: "text.secondary",
85+
}}
86+
>
87+
at{" "}
88+
<Box
89+
component="span"
90+
sx={{ fontWeight: 600, color: "text.primary" }}
91+
>
92+
{change.operation}
93+
</Box>{" "}
94+
<Box component="span" sx={{ wordBreak: "break-word" }}>
95+
{change.path}
96+
</Box>
97+
</Typography>
98+
)}
99+
{!change?.operation && change?.path && (
100+
<Typography
101+
component="span"
102+
sx={{
103+
fontFamily: "Segoe UI Mono, monospace",
104+
fontSize: "0.85rem",
105+
color: "text.secondary",
106+
wordBreak: "break-word",
107+
}}
108+
>
109+
{change.path}
110+
</Typography>
111+
)}
61112
</Box>
62-
)}
113+
</Box>
63114
{change?.text && (
64115
<Box>
65-
<Typography sx={{ mb: 1, fontWeight: 600 }}>
66-
Description:
67-
</Typography>
68116
<Typography variant="body0" sx={{ wordBreak: "break-word" }}>
69117
{typeof change.text === "string" ? (
70118
<MonoQuotedText text={change.text} />

src/features/sidebar/view/internal/diffbar/components/DiffListItem.tsx

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,37 @@ import { Box, Typography, ListItem, ListItemButton, Stack } from "@mui/material"
44
import MenuItemHover from "@/common/ui/MenuItemHover"
55
import MonoQuotedText from "./MonoQuotedText"
66

7+
type Level = 1 | 2 | 3
8+
9+
const getLevelConfig = (level: Level) => {
10+
switch (level) {
11+
case 3:
12+
return { label: "breaking", color: "#e88388" }
13+
case 2:
14+
return { label: "warn", color: "#dbab79" }
15+
case 1:
16+
default:
17+
return { label: "info", color: "#66c2cd" }
18+
}
19+
}
20+
721
const DiffListItem = ({
822
path,
923
text,
24+
level,
25+
operation,
1026
selected,
1127
onClick,
1228
}: {
1329
path?: string
1430
text?: string
31+
level?: number
32+
operation?: string
1533
selected: boolean
1634
onClick: () => void
1735
}) => {
36+
const levelConfig = getLevelConfig((level ?? 1) as Level)
37+
1838
return (
1939
<ListItem disableGutters disablePadding>
2040
<ListItemButton
@@ -31,26 +51,61 @@ const DiffListItem = ({
3151
flexDirection: "column",
3252
minWidth: 0,
3353
flex: 1,
34-
gap: 1.25,
54+
gap: 0.75,
3555
}}
3656
>
37-
{path && (
57+
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
3858
<Typography
39-
variant="body0"
59+
component="span"
4060
sx={{
4161
fontFamily: "Segoe UI Mono, monospace",
4262
fontWeight: 700,
43-
letterSpacing: 0.1,
44-
wordBreak: "break-word",
63+
fontSize: "0.75rem",
64+
color: levelConfig.color,
65+
textTransform: "lowercase",
4566
}}
4667
>
47-
{path}
68+
{levelConfig.label}
4869
</Typography>
49-
)}
70+
{operation && path && (
71+
<Typography
72+
component="span"
73+
sx={{
74+
fontFamily: "Segoe UI Mono, monospace",
75+
fontSize: "0.8rem",
76+
color: "text.secondary",
77+
}}
78+
>
79+
at{" "}
80+
<Box
81+
component="span"
82+
sx={{ fontWeight: 600, color: "text.primary" }}
83+
>
84+
{operation}
85+
</Box>{" "}
86+
<Box component="span" sx={{ wordBreak: "break-word" }}>
87+
{path}
88+
</Box>
89+
</Typography>
90+
)}
91+
{!operation && path && (
92+
<Typography
93+
component="span"
94+
sx={{
95+
fontFamily: "Segoe UI Mono, monospace",
96+
fontSize: "0.8rem",
97+
color: "text.secondary",
98+
wordBreak: "break-word",
99+
}}
100+
>
101+
{path}
102+
</Typography>
103+
)}
104+
</Box>
50105
{text && (
51106
<Typography
52107
variant="body0"
53-
sx={{ wordBreak: "break-word" }}
108+
sx={{ wordBreak: "break-word", pl: 0.5 }}
54109
>
55110
<MonoQuotedText text={text} />
56111
</Typography>

src/features/sidebar/view/internal/diffbar/components/PopulatedDiffList.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const PopulatedDiffList = ({
2626
key={change.id}
2727
path={change?.path}
2828
text={change?.text}
29+
level={change?.level}
30+
operation={change?.operation}
2931
selected={selectedChange === i}
3032
onClick={() => onClick(i)}
3133
/>

0 commit comments

Comments
 (0)