Skip to content

Commit

Permalink
remove reload_on_navigation modal panel option
Browse files Browse the repository at this point in the history
  • Loading branch information
sashankaryal committed Oct 31, 2024
1 parent 5eac141 commit dc01277
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 31 deletions.
1 change: 0 additions & 1 deletion app/packages/operators/src/Panel/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default function registerPanel(ctx: ExecutionContext) {
panelOptions: {
allowDuplicates: ctx.params.allow_duplicates,
helpMarkdown: ctx.params.help_markdown,
reloadOnNavigation: ctx.params.reload_on_navigation,
surfaces: ctx.params.surfaces,
},
});
Expand Down
6 changes: 0 additions & 6 deletions app/packages/plugins/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,6 @@ type PanelOptions = {
* Content displayed on the right side of the label in the panel title bar.
*/
TabIndicator?: React.ComponentType;

/**
* If true, the plugin will be remounted when the user navigates to a different sample or group.
* This is only applicable to plugins that are in a modal.
*/
reloadOnNavigation?: boolean;
};

type PluginComponentProps<T> = T & {
Expand Down
14 changes: 3 additions & 11 deletions app/packages/spaces/src/components/Panel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CenteredStack, scrollable } from "@fiftyone/components";
import * as fos from "@fiftyone/state";
import React, { useEffect } from "react";
import { useRecoilValue, useSetRecoilState } from "recoil";
import { useSetRecoilState } from "recoil";
import { PANEL_LOADING_TIMEOUT } from "../constants";
import { PanelContext } from "../contexts";
import { useReactivePanel } from "../hooks";
Expand All @@ -20,8 +20,6 @@ function Panel(props: PanelProps) {
const setPanelIdToScope = useSetRecoilState(panelIdToScopeAtom);
const scope = isModalPanel ? "modal" : "grid";

const thisModalUniqueId = useRecoilValue(fos.currentModalUniqueId);

useEffect(() => {
setPanelIdToScope((ids) => ({ ...ids, [node.id]: scope }));
}, [scope, setPanelIdToScope, node.id]);
Expand All @@ -42,9 +40,7 @@ function Panel(props: PanelProps) {
);
}

const { component: Component, panelOptions } = panel;

const shouldKeyComponent = isModalPanel && panelOptions?.reloadOnNavigation;
const { component: Component } = panel;

return (
<StyledPanel
Expand All @@ -55,11 +51,7 @@ function Panel(props: PanelProps) {
ref={dimensions.ref}
>
<PanelContext.Provider value={{ node, scope }}>
<Component
key={shouldKeyComponent ? thisModalUniqueId : panelName}
panelNode={node}
dimensions={dimensions}
/>
<Component panelNode={node} dimensions={dimensions} />
</PanelContext.Provider>
</StyledPanel>
);
Expand Down
7 changes: 1 addition & 6 deletions fiftyone/operators/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ def register_panel(
light_icon=None,
dark_icon=None,
surfaces="grid",
reload_on_navigation=False,
on_load=None,
on_unload=None,
on_change=None,
Expand Down Expand Up @@ -333,10 +332,7 @@ def register_panel(
is in dark mode
surfaces ('grid'): surfaces in which to show the panel. Must be
one of 'grid', 'modal', or 'grid modal'
reload_on_navigation (False): whether to reload the panel when the
user navigates to a new page. This is only applicable to panels
that are not shown in a modal
on_load (None): an operator to invoke when the panel is loaded
on_load (None): an operator to invoke when the panel is loaded
on_unload (None): an operator to invoke when the panel is unloaded
on_change (None): an operator to invoke when the panel state
changes
Expand Down Expand Up @@ -367,7 +363,6 @@ def register_panel(
"light_icon": light_icon,
"dark_icon": dark_icon,
"surfaces": surfaces,
"reload_on_navigation": reload_on_navigation,
"on_load": on_load,
"on_unload": on_unload,
"on_change": on_change,
Expand Down
7 changes: 0 additions & 7 deletions fiftyone/operators/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ class PanelConfig(OperatorConfig):
in dark mode
allow_multiple (False): whether to allow multiple instances of the
panel to be opened
reload_on_navigation (False): whether to reload the panel when the
user navigates to a new page. This is only applicable to panels
that are not shown in a modal
surfaces ("grid"): the surfaces on which the panel can be displayed
help_markdown (None): a markdown string to display in the panel's help
tooltip
Expand All @@ -46,7 +43,6 @@ def __init__(
dark_icon=None,
allow_multiple=False,
surfaces: PANEL_SURFACE = "grid",
reload_on_navigation=False,
**kwargs
):
super().__init__(name)
Expand All @@ -59,7 +55,6 @@ def __init__(
self.allow_multiple = allow_multiple
self.unlisted = True
self.on_startup = True
self.reload_on_navigation = reload_on_navigation
self.surfaces = surfaces
self.kwargs = kwargs # unused, placeholder for future extensibility

Expand All @@ -74,7 +69,6 @@ def to_json(self):
"allow_multiple": self.allow_multiple,
"on_startup": self.on_startup,
"unlisted": self.unlisted,
"reload_on_navigation": self.reload_on_navigation,
"surfaces": self.surfaces,
}

Expand Down Expand Up @@ -114,7 +108,6 @@ def on_startup(self, ctx):
"dark_icon": self.config.dark_icon,
"light_icon": self.config.light_icon,
"surfaces": self.config.surfaces,
"reload_on_navigation": self.config.reload_on_navigation,
}
methods = ["on_load", "on_unload", "on_change"]
ctx_change_events = [
Expand Down

0 comments on commit dc01277

Please sign in to comment.