Skip to content

Commit c89d18a

Browse files
authored
refactor: simplify LogEntry component and enhance log message display (#446)
* refactor: simplify LogEntry component and enhance log message display - Removed unnecessary hover state management from LogEntry component. - Updated log message styling to support multiline display with a maximum of three lines. - Adjusted layout for log action buttons to improve alignment and user experience. Signed-off-by: Akila-I <akila.99g@gmail.com> * feat: add info color palette to openChoreoTheme - Introduced a new color palette for info states, including light, main, and dark shades. - This enhancement improves the theme's versatility for displaying informational messages. Signed-off-by: Akila-I <akila.99g@gmail.com> --------- Signed-off-by: Akila-I <akila.99g@gmail.com>
1 parent 1306d45 commit c89d18a

3 files changed

Lines changed: 46 additions & 24 deletions

File tree

packages/design-system/src/theme/openChoreoTheme.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ const colors = {
1313
main: '#6b7280', // Darker gray for better contrast
1414
dark: '#374151', // Darker for better readability
1515
},
16+
info: {
17+
light: '#dbeafe',
18+
main: '#3b82f6',
19+
dark: '#1d4ed8',
20+
},
1621
error: {
1722
light: '#fef2f2',
1823
main: '#ef4444',

plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.tsx

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,12 @@ export const LogEntry: FC<LogEntryProps> = ({
3030
}) => {
3131
const classes = useLogEntryStyles();
3232
const [expanded, setExpanded] = useState(false);
33-
const [isHovered, setIsHovered] = useState(false);
3433
const [copySuccess, setCopySuccess] = useState(false);
3534

3635
const handleRowClick = () => {
3736
setExpanded(!expanded);
3837
};
3938

40-
const handleMouseEnter = () => {
41-
setIsHovered(true);
42-
};
43-
44-
const handleMouseLeave = () => {
45-
setIsHovered(false);
46-
};
47-
4839
const handleCopyLog = async (event: MouseEvent<HTMLButtonElement>) => {
4940
event.stopPropagation();
5041

@@ -90,8 +81,6 @@ export const LogEntry: FC<LogEntryProps> = ({
9081
<TableRow
9182
className={`${classes.logRow} ${expanded ? classes.expandedRow : ''}`}
9283
onClick={handleRowClick}
93-
onMouseEnter={handleMouseEnter}
94-
onMouseLeave={handleMouseLeave}
9584
>
9685
{selectedFields.map(field => {
9786
if (field === LogEntryField.Timestamp) {
@@ -126,15 +115,19 @@ export const LogEntry: FC<LogEntryProps> = ({
126115

127116
return (
128117
<TableCell key={field} className={classes.logCell}>
129-
<Box display="flex" alignItems="center">
130-
<Typography
131-
className={`${classes.logMessage} ${
132-
expanded ? classes.expandedLogMessage : ''
133-
}`}
118+
<Box className={classes.logCellContent}>
119+
<Box className={classes.logTextContainer}>
120+
<Typography
121+
className={`${classes.logMessage} ${
122+
expanded ? classes.expandedLogMessage : ''
123+
}`}
124+
>
125+
{log.log}
126+
</Typography>
127+
</Box>
128+
<Box
129+
className={`${classes.logActionColumn} ${classes.hoverActionButton}`}
134130
>
135-
{log.log}
136-
</Typography>
137-
{isHovered && (
138131
<Tooltip title={copySuccess ? 'Copied!' : 'Copy log message'}>
139132
<IconButton
140133
className={classes.copyButton}
@@ -144,7 +137,7 @@ export const LogEntry: FC<LogEntryProps> = ({
144137
<FileCopyOutlined fontSize="inherit" />
145138
</IconButton>
146139
</Tooltip>
147-
)}
140+
</Box>
148141
</Box>
149142
</TableCell>
150143
);

plugins/openchoreo-observability/src/components/RuntimeLogs/styles.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,41 @@ export const useLogEntryStyles = makeStyles(theme => ({
129129
wordBreak: 'break-word',
130130
overflow: 'hidden',
131131
textOverflow: 'ellipsis',
132-
whiteSpace: 'nowrap',
132+
whiteSpace: 'pre-wrap',
133+
display: '-webkit-box',
134+
WebkitLineClamp: 3,
135+
WebkitBoxOrient: 'vertical',
133136
maxWidth: '100%',
134137
},
135138
expandedLogMessage: {
136139
whiteSpace: 'pre-wrap',
137140
overflow: 'visible',
141+
display: 'block',
142+
WebkitLineClamp: 'unset' as any,
143+
WebkitBoxOrient: 'unset' as any,
138144
},
139145
logCell: {
140146
overflow: 'hidden',
141-
textOverflow: 'ellipsis',
147+
textOverflow: 'clip',
148+
whiteSpace: 'normal',
149+
},
150+
logCellContent: {
151+
display: 'flex',
152+
alignItems: 'flex-start',
153+
width: '100%',
154+
},
155+
logTextContainer: {
156+
flex: 1,
157+
minWidth: 0,
158+
},
159+
logActionColumn: {
160+
width: theme.spacing(3),
161+
minWidth: theme.spacing(3),
162+
display: 'flex',
163+
justifyContent: 'center',
164+
alignItems: 'flex-start',
165+
flexShrink: 0,
166+
marginLeft: theme.spacing(1),
142167
},
143168
containerCell: {
144169
fontSize: '0.75rem',
@@ -195,8 +220,7 @@ export const useLogEntryStyles = makeStyles(theme => ({
195220
color: theme.palette.text.secondary,
196221
},
197222
copyButton: {
198-
padding: 0,
199-
marginLeft: theme.spacing(1),
223+
marginTop: theme.spacing(1),
200224
},
201225
fullLogMessage: {
202226
fontFamily: 'monospace',

0 commit comments

Comments
 (0)