Skip to content

Commit

Permalink
fix(notebooks): handle updates in insight visualization component (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr authored Nov 23, 2023
1 parent c0c0f30 commit b7501b1
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ const DEFAULT_QUERY: QuerySchema = {
},
}

const Component = ({ attributes }: NotebookNodeProps<NotebookNodeQueryAttributes>): JSX.Element | null => {
const Component = ({
attributes,
updateAttributes,
}: NotebookNodeProps<NotebookNodeQueryAttributes>): JSX.Element | null => {
const { query, nodeId } = attributes
const nodeLogic = useMountedLogic(notebookNodeLogic)
const { expanded } = useValues(nodeLogic)
Expand Down Expand Up @@ -86,10 +89,17 @@ const Component = ({ attributes }: NotebookNodeProps<NotebookNodeQueryAttributes
return (
<div className={clsx('flex flex-1 flex-col h-full')}>
<Query
query={modifiedQuery}
// use separate keys for the settings and visualization to avoid conflicts with insightProps
uniqueKey={nodeId + '-component'}
readOnly={true}
query={modifiedQuery}
setQuery={(t) => {
updateAttributes({
query: {
...attributes.query,
source: (t as DataTableNode | InsightVizNode).source,
} as QuerySchema,
})
}}
/>
</div>
)
Expand Down Expand Up @@ -180,10 +190,9 @@ export const Settings = ({
) : (
<div className="p-3">
<Query
query={modifiedQuery}
// use separate keys for the settings and visualization to avoid conflicts with insightProps
uniqueKey={attributes.nodeId + '-settings'}
readOnly={false}
query={modifiedQuery}
setQuery={(t) => {
updateAttributes({
query: {
Expand Down

0 comments on commit b7501b1

Please sign in to comment.