diff --git a/frontend/src/lib/lemon-ui/LemonWidget/LemonWidget.tsx b/frontend/src/lib/lemon-ui/LemonWidget/LemonWidget.tsx index 8a02b8ac7ba2b..290e6717c1971 100644 --- a/frontend/src/lib/lemon-ui/LemonWidget/LemonWidget.tsx +++ b/frontend/src/lib/lemon-ui/LemonWidget/LemonWidget.tsx @@ -1,47 +1,26 @@ -import { useState } from 'react' import { LemonButton } from '../LemonButton' -import { IconClose, IconUnfoldLess, IconUnfoldMore } from '../icons' +import { IconClose } from '../icons' import './LemonWidget.scss' import clsx from 'clsx' export interface LemonWidgetProps { title: string - collapsible?: boolean onClose?: () => void actions?: React.ReactNode - children: React.ReactChild + children: React.ReactNode + className?: string } -export function LemonWidget({ title, collapsible = true, onClose, actions, children }: LemonWidgetProps): JSX.Element { - const [isExpanded, setIsExpanded] = useState(true) - +export function LemonWidget({ title, onClose, actions, children, className }: LemonWidgetProps): JSX.Element { return ( - +
- {collapsible ? ( - <> - setIsExpanded(!isExpanded)} - size="small" - status="primary-alt" - className="flex-1" - > - {title} - - setIsExpanded(!isExpanded)} - size="small" - icon={isExpanded ? : } - /> - - ) : ( - {title} - )} + {title} {actions} {onClose && } />}
- {isExpanded && {children}} + {children}
) } @@ -55,5 +34,5 @@ const Header = ({ children, className }: { children: React.ReactNode; className? } const Content = ({ children }: { children: React.ReactNode }): JSX.Element => { - return
{children}
+ return
{children}
} diff --git a/frontend/src/scenes/notebooks/Nodes/NodeWrapper.tsx b/frontend/src/scenes/notebooks/Nodes/NodeWrapper.tsx index f9c97954e9a3f..c1d0042c319b7 100644 --- a/frontend/src/scenes/notebooks/Nodes/NodeWrapper.tsx +++ b/frontend/src/scenes/notebooks/Nodes/NodeWrapper.tsx @@ -32,8 +32,8 @@ import { posthogNodePasteRule, useSyncedAttributes } from './utils' import { NotebookNodeAttributes, NotebookNodeViewProps, - NotebookNodeWidget, CustomNotebookNodeAttributes, + NotebookNodeSettings, } from '../Notebook/utils' export interface NodeWrapperProps { @@ -54,7 +54,7 @@ export interface NodeWrapperProps { autoHideMetadata?: boolean /** Expand the node if the component is clicked */ expandOnClick?: boolean - widgets?: NotebookNodeWidget[] + settings?: NotebookNodeSettings } function NodeWrapper({ @@ -74,7 +74,7 @@ function NodeWrapper({ getPos, attributes, updateAttributes, - widgets = [], + settings = null, }: NodeWrapperProps & NotebookNodeViewProps): JSX.Element { const mountedNotebookLogic = useMountedLogic(notebookLogic) const { isEditable, editingNodeId } = useValues(notebookLogic) @@ -91,7 +91,7 @@ function NodeWrapper({ notebookLogic: mountedNotebookLogic, getPos, resizeable: resizeableOrGenerator, - widgets, + settings, startExpanded, } const nodeLogic = useMountedLogic(notebookNodeLogic(nodeLogicProps)) @@ -183,7 +183,7 @@ function NodeWrapper({ {isEditable ? ( <> - {widgets.length > 0 ? ( + {settings ? ( setEditingNodeId( @@ -259,7 +259,7 @@ export type CreatePostHogWidgetNodeOptions Promise | T | null | undefined } attributes: Record> - widgets?: NotebookNodeWidget[] + settings?: NotebookNodeSettings serializedText?: (attributes: NotebookNodeAttributes) => string } diff --git a/frontend/src/scenes/notebooks/Nodes/NotebookNodePlaylist.tsx b/frontend/src/scenes/notebooks/Nodes/NotebookNodePlaylist.tsx index 70700c8228a86..36dbdd4d79d1b 100644 --- a/frontend/src/scenes/notebooks/Nodes/NotebookNodePlaylist.tsx +++ b/frontend/src/scenes/notebooks/Nodes/NotebookNodePlaylist.tsx @@ -166,13 +166,7 @@ export const NotebookNodePlaylist = createPostHogWidgetNode): JSONContent { diff --git a/frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx b/frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx index c357814a37f66..215032ab6ed53 100644 --- a/frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx +++ b/frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx @@ -197,12 +197,7 @@ export const NotebookNodeQuery = createPostHogWidgetNode attrs.query.kind === NodeKind.SavedInsightNode ? urls.insightView(attrs.query.shortId) : undefined, - widgets: [ - { - key: 'settings', - Component: Settings, - }, - ], + settings: Settings, pasteOptions: { find: urls.insightView('(.+)' as InsightShortId), getAttributes: async (match) => { diff --git a/frontend/src/scenes/notebooks/Nodes/NotebookNodeRecording.tsx b/frontend/src/scenes/notebooks/Nodes/NotebookNodeRecording.tsx index 61e26de5e52d1..8652a5df8d032 100644 --- a/frontend/src/scenes/notebooks/Nodes/NotebookNodeRecording.tsx +++ b/frontend/src/scenes/notebooks/Nodes/NotebookNodeRecording.tsx @@ -156,13 +156,7 @@ export const NotebookNodeRecording = createPostHogWidgetNode { return attrs.id }, diff --git a/frontend/src/scenes/notebooks/Nodes/notebookNodeLogic.ts b/frontend/src/scenes/notebooks/Nodes/notebookNodeLogic.ts index d4c637fed3923..f1cc6867a8c66 100644 --- a/frontend/src/scenes/notebooks/Nodes/notebookNodeLogic.ts +++ b/frontend/src/scenes/notebooks/Nodes/notebookNodeLogic.ts @@ -23,7 +23,7 @@ import { NotebookNodeAction, NotebookNodeAttributeProperties, NotebookNodeAttributes, - NotebookNodeWidget, + NotebookNodeSettings, } from '../Notebook/utils' import { NotebookNodeType } from '~/types' import posthog from 'posthog-js' @@ -36,7 +36,7 @@ export type NotebookNodeLogicProps = { notebookLogic: BuiltLogic getPos: () => number resizeable: boolean | ((attributes: CustomNotebookNodeAttributes) => boolean) - widgets: NotebookNodeWidget[] + settings: NotebookNodeSettings messageListeners?: NotebookNodeMessagesListeners startExpanded: boolean } & NotebookNodeAttributeProperties @@ -116,7 +116,7 @@ export const notebookNodeLogic = kea([ selectors({ notebookLogic: [(_, p) => [p.notebookLogic], (notebookLogic) => notebookLogic], nodeAttributes: [(_, p) => [p.attributes], (nodeAttributes) => nodeAttributes], - widgets: [(_, p) => [p.widgets], (widgets) => widgets], + settings: [(_, p) => [p.settings], (settings) => settings], sendMessage: [ (s) => [s.messageListeners], diff --git a/frontend/src/scenes/notebooks/Notebook/Notebook.scss b/frontend/src/scenes/notebooks/Notebook/Notebook.scss index d3f39f3a727e6..ea68bfdbd7cf2 100644 --- a/frontend/src/scenes/notebooks/Notebook/Notebook.scss +++ b/frontend/src/scenes/notebooks/Notebook/Notebook.scss @@ -181,8 +181,8 @@ } } - .NotebookNodeSettings__widgets { - &__content { + .NotebookSidebar__widget { + > .LemonWidget__content { max-height: calc(100vh - 220px); overflow: auto; } diff --git a/frontend/src/scenes/notebooks/Notebook/NotebookHistory.tsx b/frontend/src/scenes/notebooks/Notebook/NotebookHistory.tsx index 66c123ae3819b..5837493dc6c91 100644 --- a/frontend/src/scenes/notebooks/Notebook/NotebookHistory.tsx +++ b/frontend/src/scenes/notebooks/Notebook/NotebookHistory.tsx @@ -106,7 +106,7 @@ export function NotebookHistory(): JSX.Element { } return ( - setShowHistory(false)}> + setShowHistory(false)}>

Below is the history of all persisted changes. You can select any version to view how it was at that diff --git a/frontend/src/scenes/notebooks/Notebook/NotebookSidebar.tsx b/frontend/src/scenes/notebooks/Notebook/NotebookSidebar.tsx index 41a68d8b7ee43..e94cff0b7f9a3 100644 --- a/frontend/src/scenes/notebooks/Notebook/NotebookSidebar.tsx +++ b/frontend/src/scenes/notebooks/Notebook/NotebookSidebar.tsx @@ -29,37 +29,25 @@ export const NotebookSidebar = (): JSX.Element | null => { ) } -const Widgets = ({ logic }: { logic: BuiltLogic }): JSX.Element | null => { +const Widgets = ({ logic }: { logic: BuiltLogic }): JSX.Element => { const { setEditingNodeId } = useActions(notebookLogic) - const { widgets, nodeAttributes } = useValues(logic) + const { settings: Settings, nodeAttributes } = useValues(logic) const { updateAttributes, selectNode } = useActions(logic) return ( -

- {widgets.map(({ key, label, Component }) => ( - - } - size="small" - status="primary" - onClick={() => selectNode()} - /> - setEditingNodeId(null)}> - Done - - - } - > -
- -
-
- ))} -
+ + } size="small" status="primary" onClick={() => selectNode()} /> + setEditingNodeId(null)}> + Done + + + } + > + {Settings ? : null} + ) } diff --git a/frontend/src/scenes/notebooks/Notebook/utils.ts b/frontend/src/scenes/notebooks/Notebook/utils.ts index e0ad5b2396566..d244540fe5673 100644 --- a/frontend/src/scenes/notebooks/Notebook/utils.ts +++ b/frontend/src/scenes/notebooks/Notebook/utils.ts @@ -46,12 +46,9 @@ export type NotebookNodeViewProps = Omit node: NotebookNode } -export type NotebookNodeWidget = { - key: string - label?: string +export type NotebookNodeSettings = // using 'any' here shouldn't be necessary but, I couldn't figure out how to set a generic on the notebookNodeLogic props - Component: ({ attributes, updateAttributes }: NotebookNodeAttributeProperties) => JSX.Element -} + (({ attributes, updateAttributes }: NotebookNodeAttributeProperties) => JSX.Element) | null export type NotebookNodeAction = Pick & { text: string