Skip to content
Open
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
11 changes: 9 additions & 2 deletions frontend/src/components/Searchbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,24 @@ const SearchBar = ({
refreshLabel,
onCreateClick,
createlabel,
onCreateDialogUnavailable,
}) => {
const [dialogOpen, setDialogOpen] = useState(false);

const handleOpenDialog = () => setDialogOpen(true);
const handleOpenDialog = () => {
if(onCreateDialogUnavailable) {
onCreateDialogUnavailable();
return ;
}
Comment on lines +37 to +40

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The formatting in this block can be improved for better consistency and adherence to standard JavaScript style guides. Specifically, add a space after the if keyword and remove the extra space before the semicolon in the return statement.

Suggested change
if(onCreateDialogUnavailable) {
onCreateDialogUnavailable();
return ;
}
if (onCreateDialogUnavailable) {
onCreateDialogUnavailable();
return;
}

setDialogOpen(true);
};
const handleCloseDialog = () => setDialogOpen(false);

const handleDialogCreate = async (resourceData) => {
if (onCreateClick) {
await onCreateClick(resourceData);
}
setDialogOpen(false);
setDialogOpen(false);
};

return (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/podgroups/PodGroups.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const PodGroups = () => {
dialogTitle="Create PodGroup"
dialogResourceNameLabel="Name"
dialogResourceType="PodGroup"
onCreateClick={handleCreate}
onCreateDialogUnavailable={handleCreate}
/>
</Box>
<PodGroupsTable
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/pods/Pods.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ const Pods = () => {
const toggleSortDirection = useCallback(() => {
setSortDirection((prev) => (prev === "asc" ? "desc" : "asc"));
}, []);

// For now, no creation dialog
const handleCreate = () => {
alert("Create Pod is not supported yet");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using window.alert() is generally discouraged in modern React applications as it is a blocking UI element and inconsistent with the rest of the application's design. Consider using a non-blocking feedback mechanism like a Snackbar or a Toast component from Material UI.

};

return (
<Box sx={{ bgcolor: "background.default", minHeight: "100vh", p: 3 }}>
Expand All @@ -200,7 +205,7 @@ const Pods = () => {
dialogTitle="Create a Pod"
dialogResourceNameLabel="Pod Name"
dialogResourceType="Pod"
onCreateClick={handleCreatePod}
onCreateDialogUnavailable={handleCreate}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

By switching to onCreateDialogUnavailable, the handleCreatePod function (defined at line 101) is no longer used. If pod creation is intentionally being disabled, this dead code should be removed. However, since CreateDialog already supports the 'Pod' resource type, consider enabling it in Searchbar.jsx instead of using this alert fallback to allow the existing creation logic to function.

/>
</Box>
<PodsTable
Expand Down