diff --git a/cypress/e2e/notebooks.cy.ts b/cypress/e2e/notebooks.cy.ts index dfb50b2e50050..d44555d42294e 100644 --- a/cypress/e2e/notebooks.cy.ts +++ b/cypress/e2e/notebooks.cy.ts @@ -34,7 +34,7 @@ describe('Notebooks', () => { }) it('Insertion suggestions can be dismissed', () => { - cy.visit(urls.notebookEdit('h11RoiwV')) + cy.visit(urls.notebook('h11RoiwV')) cy.get('.NotebookEditor').type('{enter}') cy.get('.NotebookRecordingTimestamp--preview').should('exist') diff --git a/frontend/src/models/notebooksModel.ts b/frontend/src/models/notebooksModel.ts index 6ac02bae2e24f..ec6957e38f0c4 100644 --- a/frontend/src/models/notebooksModel.ts +++ b/frontend/src/models/notebooksModel.ts @@ -40,7 +40,7 @@ export const openNotebook = async ( if (popoverLogic?.values.visibility === 'visible') { popoverLogic?.actions.selectNotebook(notebookId) } else { - router.actions.push(urls.notebookEdit(notebookId)) + router.actions.push(urls.notebook(notebookId)) } popoverLogic?.actions.setInitialAutofocus(focus) diff --git a/frontend/src/scenes/notebooks/Notebook/NotebookPopover.tsx b/frontend/src/scenes/notebooks/Notebook/NotebookPopover.tsx index 9a13bef4e9dc0..7d9f53cb42bd4 100644 --- a/frontend/src/scenes/notebooks/Notebook/NotebookPopover.tsx +++ b/frontend/src/scenes/notebooks/Notebook/NotebookPopover.tsx @@ -45,7 +45,7 @@ export function NotebookPopover(): JSX.Element { } }, [ref.current]) - const isEditable = visibility !== 'hidden' && !notebook?.is_template + const editable = visibility !== 'hidden' && !notebook?.is_template return (
)} diff --git a/frontend/src/scenes/notebooks/NotebookScene.tsx b/frontend/src/scenes/notebooks/NotebookScene.tsx index 99bbea23881d1..fc46050a2300a 100644 --- a/frontend/src/scenes/notebooks/NotebookScene.tsx +++ b/frontend/src/scenes/notebooks/NotebookScene.tsx @@ -4,7 +4,6 @@ import { notebookLogic } from './Notebook/notebookLogic' import { Notebook } from './Notebook/Notebook' import { NotFound } from 'lib/components/NotFound' import { NotebookSceneLogicProps, notebookSceneLogic } from './notebookSceneLogic' -import { NotebookMode } from '~/types' import { LemonButton, LemonTag } from '@posthog/lemon-ui' import { notebookPopoverLogic } from './Notebook/notebookPopoverLogic' import { NotebookExpandButton, NotebookSyncInfo } from './Notebook/NotebookMeta' @@ -32,8 +31,7 @@ export const scene: SceneExport = { } export function NotebookScene(): JSX.Element { - const { notebookId, mode } = useValues(notebookSceneLogic) - const { setNotebookMode } = useActions(notebookSceneLogic) + const { notebookId } = useValues(notebookSceneLogic) const { notebook, notebookLoading, conflictWarningVisible } = useValues(notebookLogic({ shortId: notebookId })) const { exportJSON } = useActions(notebookLogic({ shortId: notebookId })) const { selectNotebook, setVisibility } = useActions(notebookPopoverLogic) @@ -65,13 +63,13 @@ export function NotebookScene(): JSX.Element { ) } - const editEnabled = !notebook?.is_template + const isTemplate = notebook?.is_template return (
- {notebook?.is_template && TEMPLATE} + {isTemplate && TEMPLATE}
@@ -89,7 +87,7 @@ export function NotebookScene(): JSX.Element { exportJSON() }, }, - editEnabled && { + !isTemplate && { label: 'Delete', icon: , status: 'danger', @@ -135,32 +133,10 @@ export function NotebookScene(): JSX.Element { > Pin to side - - {!editEnabled ? null : mode === NotebookMode.Edit ? ( - <> - setNotebookMode(NotebookMode.View)} - > - Done - - - ) : ( - <> - setNotebookMode(NotebookMode.Edit)} - > - Edit - - - )}
- +
) } diff --git a/frontend/src/scenes/notebooks/notebookSceneLogic.ts b/frontend/src/scenes/notebooks/notebookSceneLogic.ts index a3f34d7cf9bab..3129323a931fe 100644 --- a/frontend/src/scenes/notebooks/notebookSceneLogic.ts +++ b/frontend/src/scenes/notebooks/notebookSceneLogic.ts @@ -1,6 +1,5 @@ -import { actions, afterMount, connect, kea, key, path, props, reducers, selectors } from 'kea' -import { Breadcrumb, NotebookMode } from '~/types' -import { actionToUrl, urlToAction } from 'kea-router' +import { afterMount, connect, kea, key, path, props, selectors } from 'kea' +import { Breadcrumb } from '~/types' import type { notebookSceneLogicType } from './notebookSceneLogicType' import { notebookLogic } from './Notebook/notebookLogic' @@ -17,17 +16,6 @@ export const notebookSceneLogic = kea([ values: [notebookLogic(props), ['notebook', 'notebookLoading']], actions: [notebookLogic(props), ['loadNotebook']], })), - actions({ - setNotebookMode: (mode: NotebookMode) => ({ mode }), - }), - reducers({ - mode: [ - NotebookMode.View as NotebookMode, - { - setNotebookMode: (_, { mode }) => mode, - }, - ], - }), selectors(() => ({ notebookId: [() => [(_, props) => props], (props): string => props.shortId], @@ -48,26 +36,6 @@ export const notebookSceneLogic = kea([ ], ], })), - urlToAction(({ props, actions, values }) => ({ - [`/notebooks/${props.shortId}(/:mode)`]: ( - { mode } // url params - ) => { - const newMode = mode === 'edit' ? NotebookMode.Edit : NotebookMode.View - - if (newMode !== values.mode) { - actions.setNotebookMode(newMode) - } - }, - })), - actionToUrl(({ values, props }) => { - return { - setNotebookMode: () => { - return values.mode === NotebookMode.View - ? urls.notebook(props.shortId) - : urls.notebookEdit(props.shortId) - }, - } - }), afterMount(({ actions }) => { actions.loadNotebook() diff --git a/frontend/src/scenes/scenes.ts b/frontend/src/scenes/scenes.ts index 356d9a9a06cc6..ca37ff7676737 100644 --- a/frontend/src/scenes/scenes.ts +++ b/frontend/src/scenes/scenes.ts @@ -481,5 +481,4 @@ export const routes: Record = { [urls.feedback()]: Scene.Feedback, [urls.feedback() + '/*']: Scene.Feedback, [urls.notebook(':shortId')]: Scene.Notebook, - [urls.notebookEdit(':shortId')]: Scene.Notebook, } diff --git a/frontend/src/scenes/urls.ts b/frontend/src/scenes/urls.ts index 2450187f8303d..d933d06f4e196 100644 --- a/frontend/src/scenes/urls.ts +++ b/frontend/src/scenes/urls.ts @@ -185,5 +185,4 @@ export const urls = { tab: 'notebooks', }).url, notebook: (shortId: string): string => `/notebooks/${shortId}`, - notebookEdit: (shortId: string): string => `/notebooks/${shortId}/edit`, } diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 1529ff3146f9d..ea538a209b40f 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -3021,11 +3021,6 @@ export type NotebookType = NotebookListItemType & { version: number } -export enum NotebookMode { - View = 'view', - Edit = 'edit', -} - export enum NotebookNodeType { Insight = 'ph-insight', Query = 'ph-query',