Skip to content

Commit

Permalink
Added notice
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Sep 27, 2023
1 parent 16bdffe commit 0907045
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
15 changes: 2 additions & 13 deletions frontend/src/scenes/notebooks/Notebook/Notebook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { EditorFocusPosition } from './utils'
import { NotebookSidebar } from './NotebookSidebar'
import { ErrorBoundary } from '~/layout/ErrorBoundary'
import { LemonButton } from '@posthog/lemon-ui'
import { NotebookHistoryWarning } from './NotebookHistory'

export type NotebookProps = {
shortId: string
Expand Down Expand Up @@ -88,19 +89,7 @@ export function Notebook({ shortId, editable = false, initialAutofocus = null }:
</LemonBanner>
)}

{editable && showHistory ? (
<LemonBanner type="info" className="my-4">
<span className="flex items-center">
<span className="flex-1">
<b>Hello time traveller!</b> You are viewing an older revision of this Notebook. You can
</span>

<LemonButton>Discard</LemonButton>

<LemonButton status="danger">Revert to this version</LemonButton>
</span>
</LemonBanner>
) : null}
<NotebookHistoryWarning />
{notebook.short_id === SCRATCHPAD_NOTEBOOK.short_id ? (
<LemonBanner
type="info"
Expand Down
33 changes: 31 additions & 2 deletions frontend/src/scenes/notebooks/Notebook/NotebookHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useActions, useValues } from 'kea'
import { notebookLogic } from './notebookLogic'
import { ActivityLog } from 'lib/components/ActivityLog/ActivityLog'
import { ActivityScope, HumanizedActivityLogItem } from 'lib/components/ActivityLog/humanizeActivity'
import { LemonButton, LemonWidget, lemonToast } from '@posthog/lemon-ui'
import { LemonBanner, LemonButton, LemonWidget, lemonToast } from '@posthog/lemon-ui'
import { JSONContent } from '@tiptap/core'

export function NotebookHistory(): JSX.Element {
Expand All @@ -16,7 +16,7 @@ export function NotebookHistory(): JSX.Element {
lemonToast.error('Could not revert to this version')
return
}
setPreviewContent(content as JSONContent, true)
setPreviewContent(content as JSONContent)
// setShowHistory(false)
}

Expand All @@ -39,3 +39,32 @@ export function NotebookHistory(): JSX.Element {
</LemonWidget>
)
}

export function NotebookHistoryWarning(): JSX.Element | null {
const { previewContent } = useValues(notebookLogic)
const { clearPreviewContent } = useActions(notebookLogic)

if (!previewContent) {
return null
}
return (
<LemonBanner type="info" className="my-4">
<span className="flex items-center gap-2">
<span className="flex-1">
<b>Hello time traveller!</b>
<br /> You are viewing an older revision of this Notebook. You can choose to revert to this version,
or create a copy of it.
</span>

<span className="flex items-center gap-2">
<LemonButton type="secondary" onClick={() => clearPreviewContent()}>
Cancel
</LemonButton>

<LemonButton type="primary">Revert to this version</LemonButton>
<LemonButton type="primary">Create a copy</LemonButton>
</span>
</span>
</LemonBanner>
)
}

0 comments on commit 0907045

Please sign in to comment.