Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(navigation): configure starred apps from the sidebar (#106330)

Marius Andra54dd59a4e29c
diff --git a/docs/published/handbook/engineering/project-structure.md b/docs/published/handbook/engineering/project-structure.md
index fc366ef1e5db..b4767da13770 100644
--- a/docs/published/handbook/engineering/project-structure.md
+++ b/docs/published/handbook/engineering/project-structure.md
@@ -47,6 +47,11 @@ The PostHog web application, built with React and TypeScript. Uses [Kea](https:/
- `src/queries` – Query builder and data visualization components
- `src/toolbar` – Code for the [PostHog Toolbar](https://posthog.com/docs/user-guides/toolbar)
+The Apps sidebar lives in `src/layout/panel-layout/navbar`.
+App rows show a direct star toggle when starring is their only action; rows with other actions keep starring in their menu.
+The Starred section's menu opens **Configure starred**, a flat app picker that saves star changes immediately.
+Drag starred items in the sidebar to change their order.
+
The app-level terminal lives in `src/scenes/terminal`.
SQL insights appear as editable `.sql` files; their full JSON remains editable under `/posthog/api/insight`.
Saving SQL preserves the insight's other query options, and JSON saves send only changed fields through the existing APIs.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 46a387d35b6c..9036799d5720 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3752,6 +3752,10 @@ snapshots:
hash: v1.k794b7964.419058019497189281c62514ec654c038832e17dae7c5f39f2a6e887f9251340.hwbRml-yka-mE_oa8yhLs9s_8U7QxxX3UseL8snLJMQ
layout-apps-and-files--collapsed--light:
hash: v1.k794b7964.4e69eef40e28d9b063759264639ee685ce796c07a623bd78aabb7cc51a6eea59.EquaH8oP-2UUsgXNQGDkK-ZZWpWsFWL2U-K1tVlOOpM
+ layout-apps-and-files--configure-starred--dark:
+ hash: v1.k794b7964.7ea1d5fd5998bc820a913b3801645a209ef66477fdcd28f34817d937230f5b96.UuvcGy8e7la7mc78dmyQfLOHhofIl9MrVemK7CKqAiI
+ layout-apps-and-files--configure-starred--light:
+ hash: v1.k794b7964.84678e0d51162ed7bb843801328d8b6fe4b9a786133f9b144174e8f6210bda25.6gJKA-yzGIJ1K2L348ofwyKsZ_KrhnxReY8jY8_SVXQ
layout-apps-and-files--dark--dark:
hash: v1.k794b7964.bc8ed5f9038a33b7fb58ab8aeaca459fc01760b9d4a6fb39cf7314d2923f1e07.TYALwAUfZ0I99Cd_fVwcYUPeQLkhkqtrYn2exs2ilw0
layout-apps-and-files--dark--light:
@@ -11509,9 +11513,9 @@ snapshots:
scenes-app-signals-artefactloglist--check-lifecycle-narrow--light:
hash: v1.k794b7964.323182dc2e4da1cc3de88a75d4d027f1d9b561a74752a6e9efda62c307252811.Z7e7sMgVVYTvNNOumDp3_1YmGPVrwuL3MtLQZITadIQ
scenes-app-signals-artefactloglist--narrow--dark:
- hash: v1.k794b7964.a644dd63d1b4c45385ba09aca7fb9c44de2c7a63e14e3387f768e388eb241914.4yhImFvyJvDsS9dA2FmjRwM6gQUIprudK9evKFpc8lU
+ hash: v1.k794b7964.16c8190934d879b7eb46d67ee86637e34003d27e1503dfe0f52cd403f8b7ea0c.zw0vIR4b3_skhadCSU_SQkInLL9Bn0oyVSAXcZddxJo
scenes-app-signals-artefactloglist--narrow--light:
- hash: v1.k794b7964.0082c81649512b1b0e07d085212c0649eb1bffc2bebe7bccb019c5be16574f1c.jZyE3Oj0CjcHUvzkqjwdr71V1q_JwzdmeJ2n5NJYt9Y
+ hash: v1.k794b7964.b544f07f6f96dd129bb05ad8f0847e135cb5ddacfb06f71ca7f6dea8567eeb25.l42DAUVqekLSLPYqQtoKHZtTbqH27PeNMG8swIkku3M
scenes-app-signals-artefactloglist--replacement-lifecycle--dark:
hash: v1.k794b7964.f723b2160bdf85cd5a827fa3dac4c281d75950f47555cdef7fc01f2ef689dfc6.wAOg7AG2Pf4mYO8EjKdD8lFlC1Ulv4MhkXIEMkzfCrg
scenes-app-signals-artefactloglist--replacement-lifecycle--light:
diff --git a/frontend/src/layout/panel-layout/ProjectTree/homeFolderUtils.tsx b/frontend/src/layout/panel-layout/ProjectTree/homeFolderUtils.tsx
index 4209bf97ea81..0df732036e92 100644
--- a/frontend/src/layout/panel-layout/ProjectTree/homeFolderUtils.tsx
+++ b/frontend/src/layout/panel-layout/ProjectTree/homeFolderUtils.tsx
@@ -40,9 +40,16 @@ export function withHomeFolderEmptyState(
<Tooltip
title={
<>
- This folder is public, not private. Everyone in this project can see
- what you put here. Find it at{' '}
- <strong>{splitPath(homeFolder.path).join(' / ')}</strong>.
+ <p className="mb-2">
+ This folder is public, not private. Everyone in this project can
+ see what you put here. Find it at{' '}
+ <strong>{splitPath(homeFolder.path).join(' / ')}</strong>.
+ </p>
+ <p className="mb-0">
+ To add an object to your home folder, right-click the folder or
+ open its … menu. Choose <strong>New</strong>, then select an
+ object type.
+ </p>
</>
}
placement="right"
diff --git a/frontend/src/layout/panel-layout/navbar/AppsAndFiles.stories.tsx b/frontend/src/layout/panel-layout/navbar/AppsAndFiles.stories.tsx
index a8a54ff00bd4..7d729d34673e 100644
--- a/frontend/src/layout/panel-layout/navbar/AppsAndFiles.stories.tsx
+++ b/frontend/src/layout/panel-layout/navbar/AppsAndFiles.stories.tsx
@@ -157,6 +157,14 @@ export default meta
type Story = StoryObj<typeof SidebarStory>
export const Apps: Story = {}
+export const ConfigureStarred: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement)
+ const body = within(canvasElement.ownerDocument.body)
+ await userEvent.click(await canvas.findByLabelText('Starred options'))
+ await userEvent.click(await body.findByText('Configure starred', { exact: true }))
+ },
+}
export const Files: Story = { args: { tab: 'files' } }
export const FilesOptions: Story = {
...Files,
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/ConfigureStarredModal.tsx b/frontend/src/layout/panel-layout/navbar/tabs/ConfigureStarredModal.tsx
new file mode 100644
index 000000000000..17ca7e652c05
--- /dev/null
+++ b/frontend/src/layout/panel-layout/navbar/tabs/ConfigureStarredModal.tsx
@@ -0,0 +1,87 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonButton, LemonModal, LemonSwitch, Spinner } from '@posthog/lemon-ui'
+
+import { Link } from 'lib/lemon-ui/Link'
+
+import { iconForType } from '../../ProjectTree/defaultTree'
+import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'
+import { sidebarToolMeta } from '../../sidebarToolMeta'
+import { appsItemName } from './appsCatalog'
+import { navAppsTabLogic } from './navAppsTabLogic'
+
+export function ConfigureStarredModal(): JSX.Element {
+ const { configureStarredOpen, configurableApps, starredAppIds } = useValues(navAppsTabLogic)
+ const { setConfigureStarredOpen, setAppStarred } = useActions(navAppsTabLogic)
+ const { shortcutDataHasLoaded, shortcutDataLoading } = useValues(projectTreeDataLogic)
+
+ return (
+ <LemonModal
+ title="Configure starred"
+ description="Choose which apps appear in Starred. Changes save automatically."
+ isOpen={configureStarredOpen}
+ onClose={() => setConfigureStarredOpen(false)}
+ width={640}
+ footer={
+ <div className="flex items-center gap-4 w-full">
+ <p className="text-xs text-secondary mb-0 flex-1">
+ Tip: Drag starred items in the sidebar to rearrange them.
+ </p>
+ <LemonButton type="primary" onClick={() => setConfigureStarredOpen(false)}>
+ Done
+ </LemonButton>
+ </div>
+ }
+ >
+ <div className="flex flex-col gap-2 group/colorful-product-icons colorful-product-icons-true">
+ {!shortcutDataHasLoaded ? (
+ <Spinner />
+ ) : (
+ configurableApps.map((item) => {
+ const { description, docsHref } = sidebarToolMeta(item)
+ const label = appsItemName(item)
+ return (
+ <LemonSwitch
+ key={item.path}
+ className="py-2"
+ checked={!!starredAppIds[item.path]}
+ onChange={(starred) => setAppStarred(item.path, starred)}
+ loading={shortcutDataLoading}
+ aria-label={label}
+ bordered
+ fullWidth
+ label={
+ <span className="flex items-center gap-2">
+ <span className="text-lg shrink-0 flex items-center">
+ {iconForType(item.iconType, item.iconColor)}
+ </span>
+ <span className="flex flex-col">
+ <span className="flex items-center gap-2">
+ {label}
+ {docsHref && (
+ <Link
+ to={docsHref}
+ target="_blank"
+ className="text-xs font-normal"
+ onClick={(event) => event.stopPropagation()}
+ >
+ Docs
+ </Link>
+ )}
+ </span>
+ {description && (
+ <span className="text-xs font-normal text-secondary">
+ {description}
+ </span>
+ )}
+ </span>
+ </span>
+ }
+ />
+ )
+ })
+ )}
+ </div>
+ </LemonModal>
+ )
+}
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.test.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.test.tsx
index 8690a33585bc..ff443e64512d 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.test.tsx
+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.test.tsx
@@ -60,36 +60,42 @@ describe('NavAppRow', () => {
const row = container.querySelector<HTMLButtonElement>('[data-attr="nav-apps-item"]')
expect(row?.disabled).toBe(true)
expect(row?.hasAttribute('href')).toBe(false)
- expect(getByLabelText('Open Feature flags menu').getAttribute('aria-disabled')).toBe('true')
+ expect(getByLabelText('Add to starred').getAttribute('aria-disabled')).toBe('true')
})
- it('adds and removes a star through the existing shortcut API', async () => {
- const create = jest.fn(() => [
- 201,
- { id: 'star-test', path: 'Feature flags', type: 'feature_flag', href: '/feature_flags' },
- ])
+ it.each([
+ ['Feature flags', 'feature_flag', '/feature_flags', false],
+ ['Home', 'home', '/', true],
+ ])('adds and removes a star for %s through the shortcut API', async (path, type, href, hasMenu) => {
+ const create = jest.fn(() => [201, { id: 'star-test', path, type, href }])
const remove = jest.fn(() => [204])
useMocks({
post: { '/api/environments/:team_id/file_system_shortcut/': create },
delete: { '/api/environments/:team_id/file_system_shortcut/star-test/': remove },
})
- const { getByLabelText, getByText, findByText } = render(
- <NavAppRow
- item={{ path: 'Feature flags', type: 'feature_flag', iconType: 'feature_flag', href: '/feature_flags' }}
- />
- )
+ const { getByLabelText, queryByLabelText, findByText } = render(<NavAppRow item={{ path, type, href }} />)
await waitFor(() => expect(projectTreeDataLogic.values.shortcutDataLoading).toBe(false))
- fireEvent.click(getByLabelText('Open Feature flags menu'))
- const add = await findByText('Add to starred')
+ const initialPath = router.values.location.pathname
+ const starButton = async (name: string): Promise<HTMLElement> => {
+ if (hasMenu) {
+ fireEvent.click(getByLabelText(`Open ${path} menu`))
+ expect(await findByText('Configure home')).toBeTruthy()
+ return await findByText(name)
+ }
+ expect(queryByLabelText(`Open ${path} menu`)).toBeNull()
+ return getByLabelText(name)
+ }
+ const add = await starButton('Add to starred')
fireEvent.click(add)
fireEvent.click(add)
await waitFor(() => expect(projectTreeDataLogic.values.shortcutData).toHaveLength(1))
expect(create).toHaveBeenCalledTimes(1)
- fireEvent.click(getByLabelText('Open Feature flags menu'))
- fireEvent.click(await findByText('Remove from starred'))
+ const removeButton = await starButton('Remove from starred')
+ fireEvent.click(removeButton)
+ fireEvent.click(removeButton)
await waitFor(() => expect(projectTreeDataLogic.values.shortcutData).toHaveLength(0))
expect(remove).toHaveBeenCalledTimes(1)
- fireEvent.click(getByLabelText('Open Feature flags menu'))
- expect(getByText('Add to starred')).toBeTruthy()
+ expect(await starButton('Add to starred')).toBeTruthy()
+ expect(router.values.location.pathname).toBe(initialPath)
})
})
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.tsx
index 267a28118dc2..007a54f3394e 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.tsx
+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavAppRow.tsx
@@ -48,6 +48,13 @@ export function NavAppRow({ item }: { item: FileSystemImport }): JSX.Element {
const iconType = item.iconType ?? (item.type as FileSystemIconType | undefined)
const hasProductMenu = ['Product analytics', 'Dashboards', 'Session replay'].includes(item.path)
+ const starAction = {
+ label: shortcut ? 'Remove from starred' : 'Add to starred',
+ icon: shortcut ? <IconStarFilled /> : <IconStar />,
+ 'data-attr': 'nav-apps-star',
+ disabledReason: disabledReason || (shortcutDataLoading ? 'Updating starred items' : undefined),
+ onClick: () => (shortcut ? deleteShortcut(shortcut.id) : addShortcutItem(item as FileSystemEntry)),
+ }
const menuItems: LemonMenuItems = [
...(hasProductMenu ? [{ label: () => <NavAppMenu product={item.path} /> }] : []),
...(item.path === 'Home'
@@ -71,15 +78,7 @@ export function NavAppRow({ item }: { item: FileSystemImport }): JSX.Element {
]
: []),
{
- items: [
- {
- label: shortcut ? 'Remove from starred' : 'Add to starred',
- icon: shortcut ? <IconStarFilled /> : <IconStar />,
- 'data-attr': 'nav-apps-star',
- disabledReason: disabledReason || (shortcutDataLoading ? 'Updating starred items' : undefined),
- onClick: () => (shortcut ? deleteShortcut(shortcut.id) : addShortcutItem(item as FileSystemEntry)),
- },
- ],
+ items: [starAction],
},
]
@@ -119,35 +118,48 @@ export function NavAppRow({ item }: { item: FileSystemImport }): JSX.Element {
)}
</Link>
</Tooltip>
- <LemonMenu placement="right-start" items={menuItems}>
+ {menuItems.length === 1 ? (
<LemonButton
size="xsmall"
className="absolute right-0 opacity-0 group-hover/app-row:opacity-100 group-focus-within/app-row:opacity-100"
- icon={
- hasProductMenu ? (
- item.path === 'Product analytics' ? (
- <IconPlusSmall />
+ icon={starAction.icon}
+ tooltip={starAction.label}
+ aria-label={starAction.label}
+ disabledReason={starAction.disabledReason}
+ onClick={starAction.onClick}
+ data-attr={starAction['data-attr']}
+ />
+ ) : (
+ <LemonMenu placement="right-start" items={menuItems}>
+ <LemonButton
+ size="xsmall"
+ className="absolute right-0 opacity-0 group-hover/app-row:opacity-100 group-focus-within/app-row:opacity-100"
+ icon={
+ hasProductMenu ? (
+ item.path === 'Product analytics' ? (
+ <IconPlusSmall />
+ ) : (
+ <IconChevronDown />
+ )
) : (
- <IconChevronDown />
+ <IconEllipsis />
)
- ) : (
- <IconEllipsis />
- )
- }
- tooltip={`Open ${label} menu`}
- aria-label={`Open ${label} menu`}
- disabledReason={disabledReason}
- data-attr={
- item.path === 'Product analytics'
- ? 'flat-nav-tool-menu-insight'
- : item.path === 'Dashboards'
- ? 'flat-nav-tool-menu-dashboards'
- : item.path === 'Session replay'
- ? 'flat-nav-tool-menu-session-replay'
- : 'nav-apps-menu'
- }
- />
- </LemonMenu>
+ }
+ tooltip={`Open ${label} menu`}
+ aria-label={`Open ${label} menu`}
+ disabledReason={disabledReason}
+ data-attr={
+ item.path === 'Product analytics'
+ ? 'flat-nav-tool-menu-insight'
+ : item.path === 'Dashboards'
+ ? 'flat-nav-tool-menu-dashboards'
+ : item.path === 'Session replay'
+ ? 'flat-nav-tool-menu-session-replay'
+ : 'nav-apps-menu'
+ }
+ />
+ </LemonMenu>
+ )}
</div>
)
}
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavAppsMenu.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavAppsMenu.tsx
new file mode 100644
index 000000000000..d3a323c444dd
--- /dev/null
+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavAppsMenu.tsx
@@ -0,0 +1,31 @@
+import { useActions } from 'kea'
+
+import { IconEllipsis, IconGear } from '@posthog/icons'
+import { LemonButton, LemonMenu } from '@posthog/lemon-ui'
+
+import { navAppsTabLogic } from './navAppsTabLogic'
+
+export function NavAppsMenu(): JSX.Element {
+ const { setConfigureStarredOpen } = useActions(navAppsTabLogic)
+
+ return (
+ <LemonMenu
+ placement="bottom-end"
+ items={[
+ {
+ label: 'Configure starred',
+ icon: <IconGear />,
+ onClick: () => setConfigureStarredOpen(true),
+ },
+ ]}
+ >
+ <LemonButton
+ size="xsmall"
+ icon={<IconEllipsis />}
+ tooltip="Starred options"
+ aria-label="Starred options"
+ data-attr="nav-apps-starred-options"
+ />
+ </LemonMenu>
+ )
+}
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/NavTabApps.tsx b/frontend/src/layout/panel-layout/navbar/tabs/NavTabApps.tsx
index 10b54c2fb10f..5bd7c5f115bb 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/NavTabApps.tsx
+++ b/frontend/src/layout/panel-layout/navbar/tabs/NavTabApps.tsx
@@ -7,7 +7,9 @@ import { ScrollableShadows } from 'lib/components/ScrollableShadows/ScrollableSh
import { ProjectTree } from '../../ProjectTree/ProjectTree'
import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'
import { projectTreeLogic } from '../../ProjectTree/projectTreeLogic'
+import { ConfigureStarredModal } from './ConfigureStarredModal'
import { NavAppRow } from './NavAppRow'
+import { NavAppsMenu } from './NavAppsMenu'
import { APPS_STARRED_TREE_KEY, navAppsTabLogic } from './navAppsTabLogic'
import { NavTabSection } from './NavTabSection'
@@ -31,6 +33,7 @@ export function NavTabApps(): JSX.Element {
label="Starred"
dataAttr="nav-apps-starred-toggle"
key={`starred-${!!search.trim()}`}
+ actions={<NavAppsMenu />}
>
{!shortcutDataHasLoaded ? (
<Spinner className="m-2" />
@@ -72,6 +75,7 @@ export function NavTabApps(): JSX.Element {
)}
</NavTabSection>
</ScrollableShadows>
+ <ConfigureStarredModal />
</div>
)
}
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.test.ts b/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.test.ts
index e848e773503d..cc36aded78ca 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.test.ts
+++ b/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.test.ts
@@ -4,6 +4,7 @@ import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { urls } from 'scenes/urls'
+import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
import { ActivityTab } from '~/types'
@@ -15,6 +16,7 @@ import { APPS_STARRED_TREE_KEY, navAppsTabLogic } from './navAppsTabLogic'
describe('navAppsTabLogic', () => {
beforeEach(() => {
+ useMocks({ get: { '/api/environments/:team_id/file_system_shortcut/': { results: [] } } })
initKeaTests()
navAppsTabLogic.mount()
})
@@ -82,6 +84,59 @@ describe('navAppsTabLogic', () => {
])
expect(starredTree.values.searchTerm).toEqual('onboarding')
})
+
+ it('configures app stars without changing files, folders, or existing order', async () => {
+ const app = { id: 'app-star', path: 'Feature flags', type: 'feature_flag', href: '/feature_flags' }
+ const create = jest.fn(() => [201, app])
+ const remove = jest.fn(() => [204])
+ useMocks({
+ post: { '/api/environments/:team_id/file_system_shortcut/': create },
+ delete: { '/api/environments/:team_id/file_system_shortcut/app-star/': remove },
+ })
+ await expectLogic(projectTreeDataLogic).toFinishAllListeners()
+ const existing = [
+ { id: 'folder', path: 'Feature flags', type: 'folder', ref: 'Feature flags' },
+ { id: 'file', path: 'Feature flags', type: 'insight', ref: 'insight-1', href: '/insights/insight-1' },
+ { id: 'analytics', path: 'Product analytics', type: 'product_analytics', href: '/insights' },
+ ]
+ projectTreeDataLogic.actions.loadShortcutsSuccess(existing)
+ navAppsTabLogic.actions.setSearch('no matches')
+ expect(navAppsTabLogic.values.starredAppIds['Feature flags']).toBeUndefined()
+
+ await expectLogic(navAppsTabLogic, () => {
+ navAppsTabLogic.actions.setAppStarred('Feature flags', true)
+ navAppsTabLogic.actions.setAppStarred('Feature flags', true)
+ }).toDispatchActions([projectTreeDataLogic.actionTypes.addShortcutItemSuccess])
+ expect(create).toHaveBeenCalledTimes(1)
+ expect(projectTreeDataLogic.values.shortcutData).toEqual([...existing, app])
+ expect(navAppsTabLogic.values.starredAppIds['Feature flags']).toBe('app-star')
+
+ await expectLogic(navAppsTabLogic, () => {
+ navAppsTabLogic.actions.setAppStarred('Feature flags', false)
+ navAppsTabLogic.actions.setAppStarred('Feature flags', false)
+ }).toDispatchActions([projectTreeDataLogic.actionTypes.deleteShortcutSuccess])
+ expect(remove).toHaveBeenCalledTimes(1)
+ expect(projectTreeDataLogic.values.shortcutData).toEqual(existing)
+ })
+
+ it('keeps a star after a failed removal and allows a retry', async () => {
+ const remove = jest
+ .fn()
+ .mockReturnValueOnce([500, { detail: 'Try again' }])
+ .mockReturnValueOnce([204])
+ useMocks({ delete: { '/api/environments/:team_id/file_system_shortcut/app-star/': remove } })
+ await expectLogic(projectTreeDataLogic).toFinishAllListeners()
+ projectTreeDataLogic.actions.loadShortcutsSuccess([
+ { id: 'app-star', path: 'Feature flags', type: 'feature_flag', href: '/feature_flags' },
+ ])
+
+ await expectLogic(navAppsTabLogic, () => navAppsTabLogic.actions.setAppStarred('Feature flags', false))
+ .toDispatchActions([projectTreeDataLogic.actionTypes.deleteShortcutFailure])
+ .toMatchValues({ starredAppIds: { 'Feature flags': 'app-star' }, shortcutDataLoading: false })
+ await expectLogic(navAppsTabLogic, () => navAppsTabLogic.actions.setAppStarred('Feature flags', false))
+ .toDispatchActions([projectTreeDataLogic.actionTypes.deleteShortcutSuccess])
+ .toMatchValues({ starredAppIds: {}, shortcutDataLoading: false })
+ })
it.each([
['apps', ['Product analytics']],
['files', ['Overview', 'Research']],
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.ts b/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.ts
index 0d12f5237c07..7e51881de1cf 100644
--- a/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.ts
+++ b/frontend/src/layout/panel-layout/navbar/tabs/navAppsTabLogic.ts
@@ -1,15 +1,17 @@
import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { getProductAccessDisabledReason } from 'lib/utils/accessControlUtils'
import { urls } from 'scenes/urls'
-import { FileSystemImport } from '~/queries/schema/schema-general'
+import { FileSystemEntry, FileSystemImport } from '~/queries/schema/schema-general'
import { ActivityTab } from '~/types'
import { getDefaultTreeDataAndPeople, getDefaultTreeProducts } from '../../ProjectTree/defaultTree'
import { projectTreeDataLogic } from '../../ProjectTree/projectTreeDataLogic'
import { projectTreeLogic } from '../../ProjectTree/projectTreeLogic'
-import { AppsItemGroup, groupApps } from './appsCatalog'
+import { joinPath, splitPath } from '../../ProjectTree/utils'
+import { AppsItemGroup, appsItemName, groupApps } from './appsCatalog'
export const APPS_STARRED_TREE_KEY = 'navbar-apps-starred'
@@ -17,13 +19,34 @@ export const APPS_STARRED_TREE_KEY = 'navbar-apps-starred'
export interface navAppsTabLogicValues {
featureFlags: FeatureFlagsSet // featureFlagLogic
groupItems: FileSystemImport[] // projectTreeDataLogic
+ shortcutData: FileSystemEntry[] // projectTreeDataLogic
+ shortcutDataLoading: boolean // projectTreeDataLogic
allItems: FileSystemImport[]
+ configurableApps: FileSystemImport[]
+ configureStarredOpen: boolean
groupedItems: AppsItemGroup[]
search: string
+ starredAppIds: Record<string, string>
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface navAppsTabLogicActions {
+ addShortcutItem: (item: FileSystemEntry) => {
+ item: FileSystemEntry
+ } // projectTreeDataLogic
+ deleteShortcut: (id: string) => {
+ id: string
+ } // projectTreeDataLogic
+ setAppStarred: (
+ appPath: string,
+ starred: boolean
+ ) => {
+ appPath: string
+ starred: boolean
+ }
+ setConfigureStarredOpen: (open: boolean) => {
+ open: boolean
+ }
setSearch: (search: string) => {
search: string
}
@@ -34,6 +57,8 @@ export interface navAppsTabLogicMeta {
__keaTypeGenInternalSelectorTypes: {
allItems: (featureFlags: FeatureFlagsSet, groupItems: FileSystemImport[]) => FileSystemImport[]
groupedItems: (allItems: FileSystemImport[], search: string) => AppsItemGroup[]
+ configurableApps: (allItems: FileSystemImport[]) => FileSystemImport[]
+ starredAppIds: (allItems: FileSystemImport[], shortcutData: FileSystemEntry[]) => Record<string, string>
}
}
@@ -47,11 +72,24 @@ export type navAppsTabLogicType = MakeLogicType<
export const navAppsTabLogic = kea<navAppsTabLogicType>([
path(['layout', 'panel-layout', 'navbar', 'tabs', 'navAppsTabLogic']),
connect(() => ({
- values: [featureFlagLogic, ['featureFlags'], projectTreeDataLogic, ['groupItems']],
+ values: [
+ featureFlagLogic,
+ ['featureFlags'],
+ projectTreeDataLogic,
+ ['groupItems', 'shortcutData', 'shortcutDataLoading'],
+ ],
+ actions: [projectTreeDataLogic, ['addShortcutItem', 'deleteShortcut']],
logic: [projectTreeLogic({ key: APPS_STARRED_TREE_KEY, root: 'shortcuts://', shortcutScope: 'apps' })],
})),
- actions({ setSearch: (search: string) => ({ search }) }),
- reducers({ search: ['', { setSearch: (_, { search }) => search }] }),
+ actions({
+ setSearch: (search: string) => ({ search }),
+ setConfigureStarredOpen: (open: boolean) => ({ open }),
+ setAppStarred: (appPath: string, starred: boolean) => ({ appPath, starred }),
+ }),
+ reducers({
+ search: ['', { setSearch: (_, { search }) => search }],
+ configureStarredOpen: [false, { setConfigureStarredOpen: (_, { open }) => open }],
+ }),
selectors({
allItems: [
(s) => [s.featureFlags, s.groupItems],
@@ -95,8 +133,46 @@ export const navAppsTabLogic = kea<navAppsTabLogicType>([
(s) => [s.allItems, s.search],
(items: FileSystemImport[], search: string): AppsItemGroup[] => groupApps(items, search),
],
+ configurableApps: [
+ (s) => [s.allItems],
+ (items: FileSystemImport[]): FileSystemImport[] =>
+ items
+ .filter((item) => !getProductAccessDisabledReason(item))
+ .sort((a, b) => appsItemName(a).localeCompare(appsItemName(b))),
+ ],
+ starredAppIds: [
+ (s) => [s.allItems, s.shortcutData],
+ (items: FileSystemImport[], shortcuts: FileSystemEntry[]): Record<string, string> => {
+ const ids: Record<string, string> = {}
+ for (const item of items) {
+ const shortcutPath = joinPath(splitPath(item.path).slice(-1))
+ const shortcut = shortcuts.find(
+ (entry) => entry.type !== 'folder' && !entry.ref && entry.path === shortcutPath
+ )
+ if (shortcut) {
+ ids[item.path] = shortcut.id
+ }
+ }
+ return ids
+ },
+ ],
}),
- listeners({
+ listeners(({ actions, values }) => ({
+ setAppStarred: ({ appPath, starred }) => {
+ if (values.shortcutDataLoading) {
+ return
+ }
+ const item = values.configurableApps.find((app) => app.path === appPath)
+ if (!item) {
+ return
+ }
+ const shortcutId = values.starredAppIds[appPath]
+ if (starred && !shortcutId) {
+ actions.addShortcutItem(item as FileSystemEntry)
+ } else if (!starred && shortcutId) {
+ actions.deleteShortcut(shortcutId)
+ }
+ },
setSearch: ({ search }) => {
projectTreeLogic({
key: APPS_STARRED_TREE_KEY,
@@ -104,5 +180,5 @@ export const navAppsTabLogic = kea<navAppsTabLogicType>([
shortcutScope: 'apps',
}).actions.setSearchTerm(search)
},
- }),
+ })),
])