Skip to content
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

feat: add saved insight to notebook #17551

Merged
merged 17 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 23 additions & 2 deletions frontend/src/scenes/insights/InsightPageHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { EditableField } from 'lib/components/EditableField/EditableField'

import { AvailableFeature, ExporterFormat, InsightLogicProps, InsightModel, InsightShortId, ItemMode } from '~/types'
import {
AvailableFeature,
ExporterFormat,
InsightLogicProps,
InsightModel,
InsightShortId,
ItemMode,
NotebookNodeType,
} from '~/types'
import { IconLock } from 'lib/lemon-ui/icons'
import { More } from 'lib/lemon-ui/LemonButton/More'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
Expand Down Expand Up @@ -33,6 +41,8 @@ import { summarizeInsight } from 'scenes/insights/summarizeInsight'
import { AddToDashboardModal } from 'lib/components/AddToDashboard/AddToDashboardModal'
import { useState } from 'react'
import { NewDashboardModal } from 'scenes/dashboard/NewDashboardModal'
import { NotebookSelectButton } from 'scenes/notebooks/NotebookSelectButton/NotebookSelectButton'
import { NodeKind } from '~/queries/schema'

export function InsightPageHeader({ insightLogicProps }: { insightLogicProps: InsightLogicProps }): JSX.Element {
// insightSceneLogic
Expand Down Expand Up @@ -246,7 +256,18 @@ export function InsightPageHeader({ insightLogicProps }: { insightLogicProps: In
</LemonButton>
)}
{insightMode !== ItemMode.Edit && hasDashboardItemId && (
<AddToDashboard insight={insight} setOpenModal={setAddToDashboardModalOpenModal} />
<>
<NotebookSelectButton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine "for now" but probably we want to come up with some combined button for adding an insight to either a dashboard or a notebook as otherwise that header could become a bit cramped

resource={{
attrs: {
query: { kind: NodeKind.SavedInsightNode, shortId: insight.short_id },
},
type: NotebookNodeType.Query,
}}
type="secondary"
/>
<AddToDashboard insight={insight} setOpenModal={setAddToDashboardModalOpenModal} />
</>
)}

{insightMode !== ItemMode.Edit ? (
Expand Down
1 change: 1 addition & 0 deletions frontend/src/scenes/insights/Insights.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const meta: Meta = {
'/api/projects/:team_id/persons/retention': sampleRetentionPeopleResponse,
'/api/projects/:team_id/persons/properties': samplePersonProperties,
'/api/projects/:team_id/groups_types': [],
'/api/projects/:team_id/notebooks?contains=query': {},
},
post: {
'/api/projects/:team_id/cohorts/': { id: 1 },
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.