-
Notifications
You must be signed in to change notification settings - Fork 589
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
overridable panel not found component #4522
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { usePluginComponent } from "@fiftyone/plugins"; | ||
import { Typography } from "@mui/material"; | ||
import { PanelProps } from "../types"; | ||
|
||
export default function PanelNotFound(props: PanelNotFoundPropsType) { | ||
const { panelName } = props; | ||
const CustomPanelNotFound = usePluginComponent("PanelNotFound")?.component; | ||
|
||
if (CustomPanelNotFound) { | ||
return <CustomPanelNotFound {...props} />; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems reasonable from a design POV to allow this to be over-ridden...but I'm not sure on the use case. What is the actual use case for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main use case atm is to enable displaying a more appropriate message in teams environment |
||
} | ||
|
||
return ( | ||
<Typography>Panel "{panelName}" no longer exists!</Typography> | ||
); | ||
} | ||
|
||
type PanelNotFoundPropsType = PanelProps & { panelName: string }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New Hook Implementation:
usePluginComponent
The
usePluginComponent
hook provides a mechanism to retrieve a component by name from the active plugins, which aligns with the PR's objectives to enhance the plugin system's flexibility. However, consider using optional chaining to handle potentialnull
orundefined
values gracefully when accessing properties.Committable suggestion