diff --git a/frontend/__snapshots__/scenes-app-sidepanels--side-panel-docs.png b/frontend/__snapshots__/scenes-app-sidepanels--side-panel-docs.png index 9b49dc8cb9b3c..ea0c9a913953f 100644 Binary files a/frontend/__snapshots__/scenes-app-sidepanels--side-panel-docs.png and b/frontend/__snapshots__/scenes-app-sidepanels--side-panel-docs.png differ diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/SidePanelDocs.tsx b/frontend/src/layout/navigation-3000/sidepanel/panels/SidePanelDocs.tsx index 97996e828271f..daaece9502404 100644 --- a/frontend/src/layout/navigation-3000/sidepanel/panels/SidePanelDocs.tsx +++ b/frontend/src/layout/navigation-3000/sidepanel/panels/SidePanelDocs.tsx @@ -1,4 +1,4 @@ -import { IconExternal } from '@posthog/icons' +import { IconExternal, IconHome } from '@posthog/icons' import { LemonButton, LemonSelect, LemonSkeleton } from '@posthog/lemon-ui' import clsx from 'clsx' import { useActions, useValues } from 'kea' @@ -28,29 +28,6 @@ function SidePanelDocsSkeleton(): JSX.Element { ) } -function Menu({ - menu, - activeMenuName, - onChange, -}: { - menu: Menu[] - activeMenuName: string | null - onChange: (newValue: string | null) => void -}): JSX.Element { - return ( -
- ({ label: name, value: name }))} - /> -
- ) -} - export const SidePanelDocs = (): JSX.Element => { const { iframeSrc, currentUrl } = useValues(sidePanelDocsLogic) const { updatePath, unmountIframe, closeSidePanel, handleExternalUrl } = useActions(sidePanelDocsLogic) @@ -131,7 +108,33 @@ export const SidePanelDocs = (): JSX.Element => { return ( <> - {menu && } + } + type="secondary" + onClick={() => { + ref.current?.contentWindow?.postMessage( + { + type: 'navigate', + url: '/docs', + }, + '*' + ) + }} + /> + + {menu && ( + ({ label: name, value: name }))} + /> + )} + +
} diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/sidePanelDocsLogic.ts b/frontend/src/layout/navigation-3000/sidepanel/panels/sidePanelDocsLogic.ts index fa81eaedc2f32..ae109ee3586ea 100644 --- a/frontend/src/layout/navigation-3000/sidepanel/panels/sidePanelDocsLogic.ts +++ b/frontend/src/layout/navigation-3000/sidepanel/panels/sidePanelDocsLogic.ts @@ -1,7 +1,6 @@ -import { actions, connect, kea, listeners, path, reducers, selectors } from 'kea' +import { actions, afterMount, beforeUnmount, connect, kea, listeners, path, reducers, selectors } from 'kea' import { router } from 'kea-router' - -import { SidePanelTab } from '~/types' +import { sceneLogic } from 'scenes/sceneLogic' import { sidePanelStateLogic } from '../sidePanelStateLogic' import type { sidePanelDocsLogicType } from './sidePanelDocsLogicType' @@ -26,10 +25,10 @@ export const sidePanelDocsLogic = kea([ path(['scenes', 'navigation', 'sidepanel', 'sidePanelDocsLogic']), connect({ actions: [sidePanelStateLogic, ['openSidePanel', 'closeSidePanel']], + values: [sceneLogic, ['sceneConfig']], }), actions({ - openDocsPage: (urlOrPath: string) => ({ urlOrPath }), updatePath: (path: string) => ({ path }), setInitialPath: (path: string) => ({ path }), unmountIframe: true, @@ -68,9 +67,11 @@ export const sidePanelDocsLogic = kea([ }), listeners(({ actions, values }) => ({ - openDocsPage: ({ urlOrPath }) => { - actions.setInitialPath(getPathFromUrl(urlOrPath)) - actions.openSidePanel(SidePanelTab.Docs) + openSidePanel: ({ options }) => { + if (options) { + const initialPath = getPathFromUrl(options) + actions.setInitialPath(initialPath) + } }, unmountIframe: () => { @@ -82,4 +83,14 @@ export const sidePanelDocsLogic = kea([ router.actions.push(getPathFromUrl(urlOrPath)) }, })), + + afterMount(({ actions, values }) => { + if (values.sceneConfig?.defaultDocsPath) { + actions.setInitialPath(values.sceneConfig?.defaultDocsPath) + } + }), + + beforeUnmount(({ actions, values }) => { + actions.setInitialPath(values.currentPath ?? '/docs') + }), ]) diff --git a/frontend/src/lib/lemon-ui/Link/Link.tsx b/frontend/src/lib/lemon-ui/Link/Link.tsx index 9cb0a3fe770de..0289c79e8b69f 100644 --- a/frontend/src/lib/lemon-ui/Link/Link.tsx +++ b/frontend/src/lib/lemon-ui/Link/Link.tsx @@ -86,7 +86,7 @@ export const Link: React.FC> = Reac // NOTE: Temporarily disabled - owner @corywatilo // const is3000 = useFeatureFlag('POSTHOG_3000', 'test') - // const { openDocsPage } = useActions(sidePanelDocsLogic) + // const { openSidePanel } = useActions(sidePanelStateLogic) const onClick = (event: React.MouseEvent): void => { if (event.metaKey || event.ctrlKey) { @@ -104,7 +104,7 @@ export const Link: React.FC> = Reac // NOTE: Temporarily disabled - owner @corywatilo // if (typeof to === 'string' && is3000 && isPostHogComDocs(to)) { // event.preventDefault() - // openDocsPage(to) + // openSidePanel(SidePanelTab.Docs, to) // return // } diff --git a/frontend/src/scenes/sceneTypes.ts b/frontend/src/scenes/sceneTypes.ts index 7ce70ef4647df..4604a64a697da 100644 --- a/frontend/src/scenes/sceneTypes.ts +++ b/frontend/src/scenes/sceneTypes.ts @@ -133,4 +133,7 @@ export interface SceneConfig { organizationBased?: boolean /** Route requires project access (used e.g. by breadcrumbs). `true` implies also `organizationBased` */ projectBased?: boolean + + /** Default docs path - what the docs side panel will open by default if this scene is active */ + defaultDocsPath?: string } diff --git a/frontend/src/scenes/scenes.ts b/frontend/src/scenes/scenes.ts index d5546d7b8d2c5..4ebd425f741f0 100644 --- a/frontend/src/scenes/scenes.ts +++ b/frontend/src/scenes/scenes.ts @@ -46,38 +46,48 @@ export const sceneConfigurations: Record = { [Scene.Dashboards]: { projectBased: true, name: 'Dashboards', + defaultDocsPath: '/docs/product-analytics/dashboards', }, [Scene.Dashboard]: { projectBased: true, + defaultDocsPath: '/docs/product-analytics/dashboards', }, + [Scene.Insight]: { projectBased: true, name: 'Insights', + defaultDocsPath: '/docs/product-analytics/insights', }, [Scene.WebAnalytics]: { projectBased: true, name: 'Web analytics', layout: 'app-container', + defaultDocsPath: '/docs/web-analytics', }, [Scene.Cohort]: { projectBased: true, name: 'Cohort', + defaultDocsPath: '/docs/data/cohorts', }, [Scene.Events]: { projectBased: true, name: 'Event explorer', + defaultDocsPath: '/docs/data/events', }, [Scene.BatchExports]: { projectBased: true, name: 'Batch exports', + defaultDocsPath: '/docs/cdp/batch-exports', }, [Scene.BatchExportEdit]: { projectBased: true, name: 'Edit batch export', + defaultDocsPath: '/docs/cdp/batch-exports', }, [Scene.BatchExport]: { projectBased: true, name: 'Batch export', + defaultDocsPath: '/docs/cdp/batch-exports', }, [Scene.DataManagement]: { projectBased: true, @@ -86,6 +96,7 @@ export const sceneConfigurations: Record = { [Scene.EventDefinition]: { projectBased: true, name: 'Data management', + defaultDocsPath: '/docs/data/events', }, [Scene.PropertyDefinition]: { projectBased: true, @@ -94,111 +105,139 @@ export const sceneConfigurations: Record = { [Scene.Replay]: { projectBased: true, name: 'Session replay', + defaultDocsPath: '/docs/session-replay', }, [Scene.ReplaySingle]: { projectBased: true, name: 'Replay recording', + defaultDocsPath: '/docs/session-replay', }, [Scene.ReplayPlaylist]: { projectBased: true, name: 'Replay playlist', + defaultDocsPath: '/docs/session-replay', }, [Scene.Person]: { projectBased: true, name: 'Person', + defaultDocsPath: '/docs/session-replay', }, [Scene.PersonsManagement]: { projectBased: true, name: 'People & groups', + defaultDocsPath: '/docs/data/persons', }, [Scene.Action]: { projectBased: true, name: 'Action', + defaultDocsPath: '/docs/data/actions', }, [Scene.Group]: { projectBased: true, name: 'People & groups', + defaultDocsPath: '/docs/product-analytics/group-analytics', }, [Scene.Pipeline]: { projectBased: true, name: 'Pipeline', + defaultDocsPath: '/docs/cdp', }, [Scene.PipelineApp]: { projectBased: true, name: 'Pipeline app', + defaultDocsPath: '/docs/cdp', }, [Scene.Experiments]: { projectBased: true, name: 'A/B testing', + defaultDocsPath: '/docs/experiments', }, [Scene.Experiment]: { projectBased: true, name: 'Experiment', + defaultDocsPath: '/docs/experiments/creating-an-experiment', }, [Scene.FeatureFlags]: { projectBased: true, name: 'Feature flags', + defaultDocsPath: '/docs/feature-flags', }, [Scene.FeatureFlag]: { projectBased: true, + defaultDocsPath: '/docs/feature-flags/creating-feature-flags', }, [Scene.Surveys]: { projectBased: true, name: 'Surveys', + defaultDocsPath: '/docs/feature-flags/creating-feature-flags', }, [Scene.Survey]: { projectBased: true, name: 'Survey', + defaultDocsPath: '/docs/surveys', }, [Scene.SurveyTemplates]: { projectBased: true, name: 'New survey', + defaultDocsPath: '/docs/surveys/creating-surveys', }, [Scene.DataWarehouse]: { projectBased: true, name: 'Data warehouse', + defaultDocsPath: '/docs/feature-flags/creating-feature-flags', }, [Scene.DataWarehousePosthog]: { projectBased: true, name: 'Data warehouse', + defaultDocsPath: '/docs/data-warehouse', }, [Scene.DataWarehouseExternal]: { projectBased: true, name: 'Data warehouse', + defaultDocsPath: '/docs/data-warehouse/setup', }, [Scene.DataWarehouseSavedQueries]: { projectBased: true, name: 'Data warehouse', + defaultDocsPath: '/docs/data-warehouse/view', }, [Scene.DataWarehouseSettings]: { projectBased: true, name: 'Data warehouse settings', + defaultDocsPath: '/docs/data-warehouse', }, [Scene.DataWarehouseTable]: { projectBased: true, name: 'Data warehouse table', + defaultDocsPath: '/docs/data-warehouse', }, [Scene.EarlyAccessFeatures]: { projectBased: true, + defaultDocsPath: '/docs/data-warehouse', }, [Scene.EarlyAccessFeature]: { projectBased: true, + defaultDocsPath: '/docs/feature-flags/early-access-feature-management', }, [Scene.Apps]: { projectBased: true, name: 'Apps', + defaultDocsPath: '/docs/cdp', }, [Scene.FrontendAppScene]: { projectBased: true, name: 'App', + defaultDocsPath: '/docs/cdp', }, [Scene.AppMetrics]: { projectBased: true, name: 'Apps', + defaultDocsPath: '/docs/cdp', }, [Scene.SavedInsights]: { projectBased: true, name: 'Product analytics', + defaultDocsPath: '/docs/product-analytics', }, [Scene.ProjectHomepage]: { projectBased: true, @@ -218,6 +257,7 @@ export const sceneConfigurations: Record = { [Scene.ToolbarLaunch]: { projectBased: true, name: 'Launch toolbar', + defaultDocsPath: '/docs/toolbar', }, [Scene.Site]: { projectBased: true, @@ -227,14 +267,17 @@ export const sceneConfigurations: Record = { // Organization-based routes [Scene.OrganizationCreateFirst]: { name: 'Organization creation', + defaultDocsPath: '/docs/data/organizations-and-projects', }, [Scene.OrganizationCreationConfirm]: { name: 'Confirm organization creation', onlyUnauthenticated: true, + defaultDocsPath: '/docs/data/organizations-and-projects', }, [Scene.ProjectCreateFirst]: { name: 'Project creation', organizationBased: true, + defaultDocsPath: '/docs/data/organizations-and-projects', }, // Onboarding/setup routes [Scene.Login]: { @@ -274,6 +317,7 @@ export const sceneConfigurations: Record = { [Scene.Billing]: { hideProjectNotice: true, organizationBased: true, + defaultDocsPath: '/pricing', }, [Scene.Unsubscribe]: { allowUnauthenticated: true, @@ -295,15 +339,18 @@ export const sceneConfigurations: Record = { hideProjectNotice: true, // Currently doesn't render well... name: 'Notebook', layout: 'app-raw', + defaultDocsPath: '/blog/introducing-notebooks', }, [Scene.Notebooks]: { projectBased: true, name: 'Notebooks', + defaultDocsPath: '/blog/introducing-notebooks', }, [Scene.Canvas]: { projectBased: true, name: 'Canvas', layout: 'app-raw', + defaultDocsPath: '/blog/introducing-notebooks', }, [Scene.Settings]: { projectBased: true,