-
Notifications
You must be signed in to change notification settings - Fork 552
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
post merge fixes and spaces tweaks #4475
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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||||||||
import { useState, useEffect, useRef } from "react"; | ||||||||||||
import { useState, useEffect, useRef, useCallback, useMemo } from "react"; | ||||||||||||
import { useRecoilValue } from "recoil"; | ||||||||||||
import { merge, isEqual } from "lodash"; | ||||||||||||
|
||||||||||||
|
@@ -13,17 +13,17 @@ import { | |||||||||||
|
||||||||||||
export interface CustomPanelProps { | ||||||||||||
panelId: string; | ||||||||||||
onLoad?: Function; | ||||||||||||
onChange?: Function; | ||||||||||||
onUnLoad?: Function; | ||||||||||||
onChangeCtx?: Function; | ||||||||||||
onViewChange?: Function; | ||||||||||||
onChangeView?: Function; | ||||||||||||
onChangeDataset?: Function; | ||||||||||||
onChangeCurrentSample?: Function; | ||||||||||||
onChangeSelected?: Function; | ||||||||||||
onChangeSelectedLabels?: Function; | ||||||||||||
onChangeExtendedSelection?: Function; | ||||||||||||
onLoad?: string; | ||||||||||||
onChange?: string; | ||||||||||||
onUnLoad?: string; | ||||||||||||
onChangeCtx?: string; | ||||||||||||
onViewChange?: string; | ||||||||||||
onChangeView?: string; | ||||||||||||
onChangeDataset?: string; | ||||||||||||
onChangeCurrentSample?: string; | ||||||||||||
onChangeSelected?: string; | ||||||||||||
onChangeSelectedLabels?: string; | ||||||||||||
onChangeExtendedSelection?: string; | ||||||||||||
dimensions: { | ||||||||||||
bounds: { | ||||||||||||
height?: number; | ||||||||||||
|
@@ -54,7 +54,7 @@ function useCtxChangePanelEvent(panelId, value, operator) { | |||||||||||
|
||||||||||||
export function useCustomPanelHooks(props: CustomPanelProps): CustomPanelHooks { | ||||||||||||
const { panelId } = props; | ||||||||||||
const [panelState, setPanelState] = usePanelState(null, panelId); | ||||||||||||
const [panelState] = usePanelState(null, panelId); | ||||||||||||
const [panelStateLocal, setPanelStateLocal] = usePanelState( | ||||||||||||
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. Ensure proper usage of The - executeOperator(props.onLoad, { panel_id: panelId, panel_state: panelState?.state });
+ executeOperator(props.onLoad, { panel_id: panelId, panel_state: panelState?.state }, {}); Also applies to: 78-85, 113-130, 138-151 Committable suggestion
Suggested change
|
||||||||||||
null, | ||||||||||||
panelId, | ||||||||||||
|
@@ -75,14 +75,14 @@ export function useCustomPanelHooks(props: CustomPanelProps): CustomPanelHooks { | |||||||||||
}); | ||||||||||||
const ctx = useGlobalExecutionContext(); | ||||||||||||
|
||||||||||||
function onLoad() { | ||||||||||||
const onLoad = useCallback(() => { | ||||||||||||
if (props.onLoad) { | ||||||||||||
executeOperator(props.onLoad, { | ||||||||||||
panel_id: panelId, | ||||||||||||
panel_state: panelState?.state, | ||||||||||||
}); | ||||||||||||
} | ||||||||||||
} | ||||||||||||
}, [props.onLoad, panelId, panelState?.state]); | ||||||||||||
useCtxChangePanelEvent(panelId, ctx._currentContext, props.onChangeCtx); | ||||||||||||
useCtxChangePanelEvent(panelId, ctx.view, props.onChangeView); | ||||||||||||
useCtxChangePanelEvent(panelId, ctx.viewName, props.onChangeView); | ||||||||||||
|
@@ -105,34 +105,50 @@ export function useCustomPanelHooks(props: CustomPanelProps): CustomPanelHooks { | |||||||||||
ctx.selectedLabels, | ||||||||||||
props.onChangeSelectedLabels | ||||||||||||
); | ||||||||||||
const isLoaded = useMemo(() => { | ||||||||||||
return panelStateLocal?.loaded; | ||||||||||||
}, [panelStateLocal?.loaded]); | ||||||||||||
|
||||||||||||
useEffect(() => { | ||||||||||||
if (props.onLoad && !panelState?.loaded) { | ||||||||||||
executeOperator(props.onLoad, { panel_id: panelId }, (result) => { | ||||||||||||
const { error: onLoadError } = result; | ||||||||||||
setPanelState((s) => ({ ...s, onLoadError, loaded: true })); | ||||||||||||
}); | ||||||||||||
if (props.onLoad && !isLoaded) { | ||||||||||||
executeOperator( | ||||||||||||
props.onLoad, | ||||||||||||
{ panel_id: panelId }, | ||||||||||||
{ | ||||||||||||
callback(result) { | ||||||||||||
const { error: onLoadError } = result; | ||||||||||||
setPanelStateLocal((s) => ({ ...s, onLoadError, loaded: true })); | ||||||||||||
}, | ||||||||||||
} | ||||||||||||
); | ||||||||||||
} | ||||||||||||
|
||||||||||||
return () => { | ||||||||||||
if (props.onUnLoad) | ||||||||||||
executeOperator(props.onUnLoad, { panel_id: panelId }); | ||||||||||||
}; | ||||||||||||
}, [panelId, props.onLoad, props.onUnLoad]); | ||||||||||||
}, [panelId, props.onLoad, props.onUnLoad, isLoaded, setPanelStateLocal]); | ||||||||||||
|
||||||||||||
// Trigger panel "onLoad" operator when panel state changes externally | ||||||||||||
useEffect(() => { | ||||||||||||
if ( | ||||||||||||
lastPanelLoadState.current?.count !== panelsStateUpdatesCount && | ||||||||||||
!isEqual(lastPanelLoadState.current?.state, panelState) | ||||||||||||
) { | ||||||||||||
setPanelStateLocal({}); | ||||||||||||
onLoad(); | ||||||||||||
} | ||||||||||||
lastPanelLoadState.current = { | ||||||||||||
count: panelsStateUpdatesCount, | ||||||||||||
state: panelState, | ||||||||||||
}; | ||||||||||||
}, [panelsStateUpdatesCount, panelState, panelId, props.onLoad]); | ||||||||||||
}, [ | ||||||||||||
panelsStateUpdatesCount, | ||||||||||||
panelState, | ||||||||||||
panelId, | ||||||||||||
onLoad, | ||||||||||||
setPanelStateLocal, | ||||||||||||
]); | ||||||||||||
|
||||||||||||
useEffect(() => { | ||||||||||||
if (props.onViewChange) | ||||||||||||
|
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.
Tip
Codebase Verification
The script output shows multiple instances of
executeOperator
being called across various files. However, not all calls include the optionaloptions
parameter, which is necessary to match the updated function signature.Instances that need attention:
app/packages/operators/src/useCustomPanelHooks.ts
(Lines: 80, 111, 125, 145, 153)app/packages/operators/src/usePanelEvent.ts
(Line: 32)app/packages/operators/src/built-in-operators.ts
(Lines: 728, 786)app/packages/operators/src/operators.ts
(Lines: 434, 537)These lines should be reviewed and updated to ensure they include the optional
options
parameter as per the new function signature.Analysis chain
Update to
executeOperator
Function Signature and LogicThe update to the
executeOperator
function to include an optionaloptions
parameter and the renaming ofparams
tocomputedParams
within the function body aligns with the PR objectives to make the third parameter explicitly for options. This change enhances the function's flexibility and clarity in handling operator execution options.However, ensure that all calls to
executeOperator
throughout the codebase are updated to reflect this new signature to avoid runtime errors.Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 73
Script:
Length of output: 3333
Script:
Length of output: 20060