Skip to content

Commit 5a12b24

Browse files
committed
Fix some UI bugs
1 parent 9d1d96a commit 5a12b24

File tree

5 files changed

+74
-49
lines changed

5 files changed

+74
-49
lines changed

UI/src/api/soroban-security-portal/soroban-security-portal-api.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,6 @@ export const getBookmarkByIdCall = async (bookmarkId: number): Promise<Bookmark>
402402
// Rest client
403403
const getRestClient = async (): Promise<RestApi> => {
404404
const accessToken = getAccessToken();
405-
if (!accessToken) {
406-
throw new Error('Authentication required. Please log in again.');
407-
}
408405
const restClient = new RestApi(environment.apiUrl, `Bearer ${accessToken}`);
409406
return restClient;
410407
};

UI/src/features/pages/regular/main-window/components/BookmarkMenu.tsx

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export const BookmarkMenu: FC<BookmarkMenuProps> = ({ bookmarks }) => {
9696
sx: {
9797
maxHeight: 400,
9898
width: 320,
99+
overflowY: 'auto',
99100
zIndex: 1200, // Below app bar but above content
100101
boxShadow: 3,
101102
mt: 0.5, // Small margin below the anchor
@@ -109,50 +110,67 @@ export const BookmarkMenu: FC<BookmarkMenuProps> = ({ bookmarks }) => {
109110
}
110111
}
111112
}}
112-
sx={{
113-
'& .MuiMenu-paper': {
114-
overflow: 'visible',
115-
}
116-
}}
113+
117114
>
118115
<Box sx={{ px: 2, py: 1 }}>
119116
<Typography variant="h6" fontWeight={600}>
120117
Bookmarks
121118
</Typography>
122119
</Box>
123120
<Divider />
124-
{bookmarks.length === 0 ? (
125-
<MenuItem disabled>
126-
<ListItemText
127-
primary="No bookmarks yet"
128-
secondary="Bookmark reports and vulnerabilities"
129-
/>
130-
</MenuItem>
131-
) : (
132-
bookmarks.map((bookmark) => (
133-
<MenuItem
134-
key={bookmark.id}
135-
onClick={() => handleBookmarkClick(bookmark)}
136-
>
137-
<ListItemIcon>
138-
{getBookmarkIcon(bookmark.bookmarkType)}
139-
</ListItemIcon>
121+
<Box
122+
sx={{
123+
maxHeight: 320,
124+
overflowY: 'auto',
125+
'&::-webkit-scrollbar': {
126+
width: '6px',
127+
},
128+
'&::-webkit-scrollbar-track': {
129+
backgroundColor: 'rgba(0,0,0,0.1)',
130+
borderRadius: '3px',
131+
},
132+
'&::-webkit-scrollbar-thumb': {
133+
backgroundColor: 'rgba(0,0,0,0.3)',
134+
borderRadius: '3px',
135+
'&:hover': {
136+
backgroundColor: 'rgba(0,0,0,0.5)',
137+
},
138+
},
139+
}}
140+
>
141+
{bookmarks.length === 0 ? (
142+
<MenuItem disabled>
140143
<ListItemText
141-
primary={bookmark.title}
142-
secondary={getBookmarkTypeLabel(bookmark.bookmarkType)}
143-
slotProps={{
144-
primary: {
145-
noWrap: true,
146-
sx: { fontWeight: 500 }
147-
},
148-
secondary: {
149-
sx: { fontSize: '0.75rem' }
150-
}
151-
}}
144+
primary="No bookmarks yet"
145+
secondary="Bookmark reports and vulnerabilities"
152146
/>
153147
</MenuItem>
154-
))
155-
)}
148+
) : (
149+
bookmarks.map((bookmark) => (
150+
<MenuItem
151+
key={bookmark.id}
152+
onClick={() => handleBookmarkClick(bookmark)}
153+
>
154+
<ListItemIcon>
155+
{getBookmarkIcon(bookmark.bookmarkType)}
156+
</ListItemIcon>
157+
<ListItemText
158+
primary={bookmark.title}
159+
secondary={getBookmarkTypeLabel(bookmark.bookmarkType)}
160+
slotProps={{
161+
primary: {
162+
noWrap: true,
163+
sx: { fontWeight: 500 }
164+
},
165+
secondary: {
166+
sx: { fontSize: '0.75rem' }
167+
}
168+
}}
169+
/>
170+
</MenuItem>
171+
))
172+
)}
173+
</Box>
156174
</Menu>
157175
</>
158176
);

UI/src/features/pages/regular/report-details/report-details.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,14 @@ export const ReportDetails: FC = () => {
209209
</Typography>
210210
)}
211211
</Box>
212-
<BookmarkButton
213-
itemId={report.id ?? 0}
214-
bookmarkType={BookmarkType.Report}
215-
isBookmarked={isBookmarked(report.id ?? 0, BookmarkType.Report)}
216-
onToggle={toggleBookmark}
217-
/>
212+
{auth.isAuthenticated && (
213+
<BookmarkButton
214+
itemId={report.id ?? 0}
215+
bookmarkType={BookmarkType.Report}
216+
isBookmarked={isBookmarked(report.id ?? 0, BookmarkType.Report)}
217+
onToggle={toggleBookmark}
218+
/>
219+
)}
218220
</Box>
219221

220222
<Stack direction="row" spacing={2} sx={{ mb: 2, flexWrap: 'wrap', gap: 1 }}>

UI/src/features/pages/regular/vulnerabilities/vulnerability-card.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { MarkdownView } from "../../../../components/MarkdownView";
1010
import { Bookmark } from "@mui/icons-material";
1111
import { useBookmarks } from "../../../../contexts/BookmarkContext";
1212
import { BookmarkType } from "../../../../api/soroban-security-portal/models/bookmark";
13+
import { useAuth } from "react-oidc-context";
1314

1415
interface VulnerabilityCardProps {
1516
selectedVulnerability: any;
@@ -32,6 +33,7 @@ export const VulnerabilityCard: FC<VulnerabilityCardProps> = ({
3233
}) => {
3334
const { theme, themeMode } = useTheme();
3435
const navigate = useNavigate();
36+
const auth = useAuth();
3537
const [modalOpened, setModalOpened] = useState(isModal);
3638
const { isBookmarked, toggleBookmark } = useBookmarks();
3739

@@ -105,6 +107,7 @@ export const VulnerabilityCard: FC<VulnerabilityCardProps> = ({
105107
<Typography variant='h6' sx={{ fontWeight: 600, flexGrow: 1, textTransform: 'uppercase' }}>
106108
{selectedVulnerability.title}
107109
</Typography>
110+
{auth.isAuthenticated && (
108111
<IconButton
109112
size="large"
110113
onClick={() => toggleBookmark(selectedVulnerability.id, BookmarkType.Vulnerability)}
@@ -118,6 +121,7 @@ export const VulnerabilityCard: FC<VulnerabilityCardProps> = ({
118121
>
119122
<Bookmark fontSize="inherit" />
120123
</IconButton>
124+
)}
121125
<IconButton
122126
size="large"
123127
title="Details"

UI/src/features/pages/regular/vulnerability-details/vulnerability-details.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ import { MarkdownView } from '../../../../components/MarkdownView';
3434
import { BookmarkButton } from '../../../../components/BookmarkButton';
3535
import { BookmarkType } from '../../../../api/soroban-security-portal/models/bookmark';
3636
import { useBookmarks } from '../../../../contexts/BookmarkContext';
37+
import { useAuth } from 'react-oidc-context';
3738

3839
export const VulnerabilityDetails: FC = () => {
3940
const navigate = useNavigate();
4041
const theme = useTheme();
42+
const auth = useAuth();
4143
const { themeMode } = useAppTheme();
4244
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
4345

@@ -145,12 +147,14 @@ export const VulnerabilityDetails: FC = () => {
145147
{vulnerability.severity} Vulnerability • ID #{vulnerabilityId}
146148
</Typography>
147149
</Box>
148-
<BookmarkButton
149-
itemId={vulnerabilityId}
150-
bookmarkType={BookmarkType.Vulnerability}
151-
isBookmarked={isBookmarked(vulnerabilityId, BookmarkType.Vulnerability)}
152-
onToggle={toggleBookmark}
153-
/>
150+
{auth.isAuthenticated && (
151+
<BookmarkButton
152+
itemId={vulnerabilityId}
153+
bookmarkType={BookmarkType.Vulnerability}
154+
isBookmarked={isBookmarked(vulnerabilityId, BookmarkType.Vulnerability)}
155+
onToggle={toggleBookmark}
156+
/>
157+
)}
154158
</Box>
155159

156160
<Stack direction="row" spacing={2} sx={{ mb: 2, flexWrap: 'wrap', gap: 1 }}>

0 commit comments

Comments
 (0)