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: Discussions panel #19272

Merged
merged 172 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
86b00cf
changed color theme ui (wip)
corywatilo Dec 6, 2023
fe315a9
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 6, 2023
2851218
Added comments api
benjackwhite Dec 12, 2023
4ecb8dc
Fixed up tests
benjackwhite Dec 12, 2023
6d8345a
Update query snapshots
github-actions[bot] Dec 12, 2023
6ab8724
Fixes
benjackwhite Dec 12, 2023
a2c391d
Fixes
benjackwhite Dec 15, 2023
148b941
Added stories
benjackwhite Dec 15, 2023
85ad7e4
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 15, 2023
a8a7734
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 15, 2023
373c978
Fixes
benjackwhite Dec 15, 2023
fd22eab
feat: comments frontend (#19303)
daibhin Dec 15, 2023
c154f6d
Merge branch 'master' into feat/comments-2
benjackwhite Dec 15, 2023
35f531c
Fix
benjackwhite Dec 18, 2023
b9d53f3
Fixed up button styles
benjackwhite Dec 18, 2023
46a1070
Fix up
benjackwhite Dec 18, 2023
fad3ee8
Fix
benjackwhite Dec 18, 2023
6f50423
fix: Change clearable lemonselect to use sideaction
benjackwhite Dec 18, 2023
a1ef69b
Fix
benjackwhite Dec 18, 2023
986bd45
Merge branch 'master' into fix/select-button-gap
benjackwhite Dec 18, 2023
c207b66
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 18, 2023
3c6af92
Merge branch 'feat/scrollable-component' into feat/comments-2
benjackwhite Dec 18, 2023
05d37f0
Fix
benjackwhite Dec 18, 2023
be21dd0
Fixes
benjackwhite Dec 18, 2023
53dd609
Fixed up lemonbuttonwithsideaction wrapping
benjackwhite Dec 18, 2023
0143584
Merge branch 'fix/select-button-gap' of github.com:PostHog/posthog in…
benjackwhite Dec 18, 2023
40cdf81
Update query snapshots
github-actions[bot] Dec 18, 2023
12f0ba4
render comment marks
daibhin Dec 15, 2023
caec26a
cleanup approach
daibhin Dec 18, 2023
2d2bf4e
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
71514c4
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 18, 2023
de03b05
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 18, 2023
7e5b83c
Update query snapshots
github-actions[bot] Dec 18, 2023
4665f22
remove mark if input blurred
daibhin Dec 18, 2023
8ea9fa2
autofocus input
daibhin Dec 18, 2023
62bd258
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
79289f3
Merge branch 'feat/comments-2' of github.com:PostHog/posthog into fea…
benjackwhite Dec 18, 2023
e784157
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
a1d8e10
Fixes
benjackwhite Dec 18, 2023
e3780af
remove mark if comment deleted
daibhin Dec 18, 2023
10fa781
rerun migration
daibhin Dec 18, 2023
9f8d5ac
Merge branch 'master' into feat/comments-2
daibhin Dec 18, 2023
e959b62
fix migration conflicts
daibhin Dec 18, 2023
60a3622
Merge branch 'feat/comments-2' of github.com:PostHog/posthog into fea…
benjackwhite Dec 18, 2023
0cca64e
add comment id to mark
daibhin Dec 18, 2023
af0cc6e
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
99271d8
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
650081f
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
89ff8ea
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
9727913
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
a3ca247
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
c8c056c
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
da86794
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
ef62f8b
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
a3f1aff
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
33f1a91
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 18, 2023
3882d8e
Merge branch 'feat/comments-2' of github.com:PostHog/posthog into fea…
benjackwhite Dec 19, 2023
2f4e531
Don't load comments straight away
benjackwhite Dec 19, 2023
43424a6
Fixes
benjackwhite Dec 19, 2023
69b0357
Swap to callback approach
benjackwhite Dec 19, 2023
16cab07
Fixed up context
benjackwhite Dec 19, 2023
056b852
Fixed highlighting of relevant comment
benjackwhite Dec 19, 2023
a6d8065
Added regexes
benjackwhite Dec 19, 2023
772a11a
Some fixes
benjackwhite Dec 19, 2023
4df28de
Merge
benjackwhite Dec 19, 2023
1238dd4
Fix migrations
benjackwhite Dec 19, 2023
1d575eb
Update UI snapshots for `webkit` (2)
github-actions[bot] Dec 19, 2023
82a7b69
Merge branch 'master' into fix/select-button-gap
benjackwhite Dec 19, 2023
d33d7f0
Fix
benjackwhite Dec 19, 2023
9d01380
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 19, 2023
8a45d43
Merge branch 'fix/select-button-gap' into feat/comments-2
benjackwhite Dec 19, 2023
3677612
Fixes
benjackwhite Dec 19, 2023
afc9a60
Update query snapshots
github-actions[bot] Dec 19, 2023
a6e2476
Update query snapshots
github-actions[bot] Dec 19, 2023
4aab86f
Fixes
benjackwhite Dec 20, 2023
262b7f4
add flag to discussion insertion
daibhin Dec 20, 2023
02a1c33
remove deleted comment mark
daibhin Dec 20, 2023
5c87255
show comments on nodes
daibhin Dec 20, 2023
fc05af2
hide new comment button if selection within comment
daibhin Dec 20, 2023
5231d04
remove mark if cancel pressed
daibhin Dec 20, 2023
229eab0
cleanup
daibhin Dec 21, 2023
1110fd0
Merge branch 'master' into feat/comments-2
daibhin Dec 21, 2023
fcf5342
reset snapshot
daibhin Dec 21, 2023
eded370
fix tiptap flush sync error
daibhin Dec 21, 2023
b72b5ae
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 21, 2023
1205f36
Added activity scopes
benjackwhite Dec 21, 2023
14c2ef3
Merge branches 'feat/comments-2' and 'feat/comments-2' of github.com:…
benjackwhite Dec 21, 2023
a8fd951
Move to segmented button
benjackwhite Dec 21, 2023
06b84e8
Merge branch 'feat/move-web-to-segmented-button' into feat/comments-2
benjackwhite Dec 21, 2023
b0c1105
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 21, 2023
cf5b280
Fixes
benjackwhite Dec 21, 2023
8ac6d44
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 21, 2023
d83b09f
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 21, 2023
ff817d6
Merge branch 'feat/comments-2' of github.com:PostHog/posthog into fea…
benjackwhite Dec 21, 2023
1d442c8
Fixed up filter select
benjackwhite Dec 21, 2023
6054d04
Fixes
benjackwhite Dec 21, 2023
3d9a815
Fix
benjackwhite Dec 21, 2023
5e8a0fe
Fixes
benjackwhite Dec 21, 2023
db63441
Fixed up activity dropdown
benjackwhite Dec 21, 2023
128eea1
Fixes
benjackwhite Dec 21, 2023
4c56951
Fixes
benjackwhite Dec 21, 2023
47eb8f9
Merge branch 'master' into feat/comments-2
benjackwhite Dec 21, 2023
ff1c602
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 21, 2023
afe3eaa
reset selection
daibhin Dec 21, 2023
7a3489f
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 21, 2023
f1a1be7
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 21, 2023
046ea28
Fixes
benjackwhite Dec 21, 2023
3257819
Merge branch 'feat/comments-2' of github.com:PostHog/posthog into fea…
benjackwhite Dec 21, 2023
18b45eb
More work to get activity working
benjackwhite Dec 22, 2023
7d4bdad
cleanup
daibhin Dec 22, 2023
61c0081
Fixe option in activity dropdown
benjackwhite Dec 22, 2023
c332b1d
Swap notebooks activity to use short_id
benjackwhite Dec 22, 2023
888fce5
Fix scenes
benjackwhite Dec 22, 2023
eb0a7f1
Added new selector like we have for breadcrumbs
benjackwhite Dec 22, 2023
cc28254
Add missing scopes
benjackwhite Dec 22, 2023
589b90f
Fix
benjackwhite Dec 22, 2023
ea567a2
Update UI snapshots for `chromium` (1)
github-actions[bot] Dec 22, 2023
7d4dc24
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
8620c85
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
4560067
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
368666a
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
54ff0b5
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
621b4bd
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
2ad9ec6
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
876af2f
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
88cd873
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
591f528
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
3d60d2e
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
32cf563
Update query snapshots
github-actions[bot] Dec 22, 2023
561ada8
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
97da005
Update query snapshots
github-actions[bot] Dec 22, 2023
00199e3
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
073ae2e
Update UI snapshots for `chromium` (2)
github-actions[bot] Dec 22, 2023
f1229d5
Merge branch 'master' into feat/comments-2
benjackwhite Jan 2, 2024
1fbe5ba
fix
benjackwhite Jan 2, 2024
fac5189
Update UI snapshots for `chromium` (1)
github-actions[bot] Jan 2, 2024
3d66034
Update UI snapshots for `chromium` (1)
github-actions[bot] Jan 2, 2024
cbabab3
Fixes
benjackwhite Jan 2, 2024
48512b5
Fixed up notebook ID system
benjackwhite Jan 2, 2024
13ae65d
Fix
benjackwhite Jan 2, 2024
7f2d80e
Fixes
benjackwhite Jan 2, 2024
de3edd9
Fix api
benjackwhite Jan 2, 2024
6092a73
Update query snapshots
github-actions[bot] Jan 2, 2024
3cac70d
Fixes
benjackwhite Jan 2, 2024
d15a6ac
Fixes
benjackwhite Jan 2, 2024
a3a41c6
fix
benjackwhite Jan 2, 2024
2d5ceef
Fixes
benjackwhite Jan 2, 2024
f618c19
Fix
benjackwhite Jan 2, 2024
3b39b03
Corrected scope
benjackwhite Jan 2, 2024
767561b
Fixed source comment
benjackwhite Jan 2, 2024
11cf2a3
Fixed up API
benjackwhite Jan 2, 2024
1e32544
Fixed up minimal comment display
benjackwhite Jan 2, 2024
f24fc33
Fixes and added comments to important changes
benjackwhite Jan 2, 2024
b2b7dec
Fix
benjackwhite Jan 2, 2024
70a4096
Update UI snapshots for `chromium` (2)
github-actions[bot] Jan 2, 2024
633d9ea
Fixes
benjackwhite Jan 2, 2024
a2050b8
Merge branch 'feat/comments-2' of github.com:PostHog/posthog into fea…
benjackwhite Jan 2, 2024
524c245
Fix
benjackwhite Jan 2, 2024
aeaf016
Fix
benjackwhite Jan 2, 2024
ed8ff15
Fixed up a bunch of issues around possible optional detail
benjackwhite Jan 2, 2024
3e0de81
Revert "Fixed up a bunch of issues around possible optional detail"
benjackwhite Jan 2, 2024
9b7139f
Fix up check
benjackwhite Jan 2, 2024
c0a6750
Remove todos
benjackwhite Jan 2, 2024
0a9f036
Fix up
benjackwhite Jan 2, 2024
c7d3138
Fix
benjackwhite Jan 2, 2024
af63ae8
Fix
benjackwhite Jan 2, 2024
5e7fae4
Fix test
benjackwhite Jan 2, 2024
b33f167
Fix up ID changes
benjackwhite Jan 2, 2024
b225efe
Fixes
benjackwhite Jan 2, 2024
0335a92
Merge branch 'master' into feat/comments-2
benjackwhite Jan 2, 2024
b24c25f
Fixes
benjackwhite Jan 2, 2024
380d2f6
Update frontend/src/layout/navigation-3000/sidepanel/panels/activity/…
benjackwhite Jan 2, 2024
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
Binary file modified frontend/__snapshots__/scenes-other-toolbar--actions--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-other-toolbar--actions--light.png
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.
6 changes: 6 additions & 0 deletions frontend/src/layout/navigation-3000/sidepanel/SidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { NotebookPanel } from 'scenes/notebooks/NotebookPanel/NotebookPanel'
import { SidePanelTab } from '~/types'

import { SidePanelActivity, SidePanelActivityIcon } from './panels/activity/SidePanelActivity'
import { SidePanelDiscussion, SidePanelDiscussionIcon } from './panels/discussion/SidePanelDiscussion'
import { SidePanelActivation, SidePanelActivationIcon } from './panels/SidePanelActivation'
import { SidePanelDocs } from './panels/SidePanelDocs'
import { SidePanelFeaturePreviews } from './panels/SidePanelFeaturePreviews'
Expand Down Expand Up @@ -60,6 +61,11 @@ export const SIDE_PANEL_TABS: Record<SidePanelTab, { label: string; Icon: any; C
Icon: SidePanelActivityIcon,
Content: SidePanelActivity,
},
[SidePanelTab.Discussion]: {
label: 'Discussion',
Icon: SidePanelDiscussionIcon,
Content: SidePanelDiscussion,
},
[SidePanelTab.Welcome]: {
label: "What's new?",
Icon: IconConfetti,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
import { IconNotification } from '@posthog/icons'
import { LemonBanner, LemonButton, LemonSkeleton, LemonTabs, Link, Spinner } from '@posthog/lemon-ui'
import {
LemonBanner,
LemonButton,
LemonSelect,
LemonSelectOption,
LemonSkeleton,
LemonSwitch,
LemonTabs,
Link,
Spinner,
} from '@posthog/lemon-ui'
import { useActions, useValues } from 'kea'
import { ActivityLogRow } from 'lib/components/ActivityLog/ActivityLog'
import { humanizeScope } from 'lib/components/ActivityLog/humanizeActivity'
import { MemberSelect } from 'lib/components/MemberSelect'
import { ScrollableShadows } from 'lib/components/ScrollableShadows/ScrollableShadows'
import { usePageVisibility } from 'lib/hooks/usePageVisibility'
import { IconWithCount } from 'lib/lemon-ui/icons'
import { useEffect, useRef } from 'react'
import { urls } from 'scenes/urls'

import {
notificationsLogic,
sidePanelActivityLogic,
SidePanelActivityTab,
} from '~/layout/navigation-3000/sidepanel/panels/activity/notificationsLogic'
} from '~/layout/navigation-3000/sidepanel/panels/activity/sidePanelActivityLogic'
import { ActivityScope } from '~/types'

import { SidePanelPaneHeader } from '../../components/SidePanelPaneHeader'

const SCROLL_TRIGGER_OFFSET = 100

export const SidePanelActivityIcon = (props: { className?: string }): JSX.Element => {
const { unreadCount } = useValues(notificationsLogic)
const { unreadCount } = useValues(sidePanelActivityLogic)

return (
<IconWithCount count={unreadCount} {...props}>
Expand All @@ -36,9 +50,19 @@ export const SidePanelActivity = (): JSX.Element => {
allActivityHasNext,
importantChangesLoading,
hasUnread,
} = useValues(notificationsLogic)
const { togglePolling, setActiveTab, maybeLoadOlderActivity, markAllAsRead, loadImportantChanges } =
useActions(notificationsLogic)
filters,
filtersForCurrentPage,
showDetails,
} = useValues(sidePanelActivityLogic)
const {
togglePolling,
setActiveTab,
maybeLoadOlderActivity,
markAllAsRead,
loadImportantChanges,
setFilters,
toggleShowDetails,
} = useActions(sidePanelActivityLogic)

usePageVisibility((pageIsVisible) => {
togglePolling(pageIsVisible)
Expand Down Expand Up @@ -67,12 +91,37 @@ export const SidePanelActivity = (): JSX.Element => {
lastScrollPositionRef.current = e.currentTarget.scrollTop
}

const scopeMenuOptions: LemonSelectOption<ActivityScope | null>[] = [
{ value: null, label: 'All activity' },
...Object.values(ActivityScope).map((x) => ({
value: x,
label: humanizeScope(x),
})),
]

const activeScopeMenuOption = filters?.scope ? filters.scope + `${filters.item_id ?? ''}` : null

// Add a special option for the current page context if we have one
if (filtersForCurrentPage?.scope && filtersForCurrentPage?.item_id) {
scopeMenuOptions.unshift({
value: `${filtersForCurrentPage.scope}${filtersForCurrentPage.item_id ?? ''}` as any,
label: `This ${humanizeScope(filtersForCurrentPage.scope, true)}`,
})
}

const toggleExtendedDescription = (
<>
<LemonSwitch bordered label="Show details" checked={showDetails} onChange={toggleShowDetails} />
</>
)

return (
<div className="flex flex-col overflow-hidden">
<div className="flex flex-col overflow-hidden flex-1">
<SidePanelPaneHeader title="Activity" />
<div className="flex flex-col overflow-hidden">
<div className="flex flex-col overflow-hidden flex-1">
<div className="shrink-0 mx-2">
<LemonTabs
inline
activeKey={activeTab as SidePanelActivityTab}
onChange={(key) => setActiveTab(key)}
tabs={[
Expand All @@ -88,69 +137,132 @@ export const SidePanelActivity = (): JSX.Element => {
/>
</div>

<div className="flex-1 overflow-y-auto px-2">
{/* Controls */}
<div className="shrink-0 space-y-2 p-2">
{activeTab === SidePanelActivityTab.Unread ? (
<div className="flex-1 overflow-y-auto space-y-px">
<LemonBanner type="info" className="mb-2">
<>
<LemonBanner type="info" dismissKey="notifications-introduction">
Notifications shows you changes others make to{' '}
<Link to={urls.savedInsights('history')}>Insights</Link> and{' '}
<Link to={urls.featureFlags('history')}>Feature Flags</Link> that you created. Come join{' '}
<Link to={'https://posthog.com/community'}>our community forum</Link> and tell us what
else should be here!
</LemonBanner>

{hasUnread ? (
<div className="flex justify-end mb-2">
<div className="flex items-center justify-between gap-2">
{toggleExtendedDescription}
{hasUnread ? (
<LemonButton type="secondary" onClick={() => markAllAsRead()}>
Mark all as read
</LemonButton>
</div>
) : null}

{importantChangesLoading && !hasNotifications ? (
<LemonSkeleton className="my-2 h-12" repeat={10} fade />
) : hasNotifications ? (
notifications.map((logItem, index) => (
<ActivityLogRow logItem={logItem} key={index} showExtendedDescription={false} />
))
) : (
<p>You're all caught up!</p>
)}
) : null}
</div>
</>
) : activeTab === SidePanelActivityTab.All ? (
<div className="flex items-center justify-between gap-2">
<div className="flex items-center gap-2">
{toggleExtendedDescription}
{allActivityResponseLoading ? <Spinner textColored /> : null}
</div>

<div className="flex items-center gap-2">
<span>Filter for activity on:</span>
<LemonSelect
size="small"
options={scopeMenuOptions}
placeholder="All activity"
value={(activeScopeMenuOption as ActivityScope) ?? undefined}
onChange={(value) =>
setFilters({
...filters,
scope: value ?? undefined,
item_id: undefined,
})
}
dropdownMatchSelectWidth={false}
/>

<span>by</span>
<MemberSelect
value={filters?.user ?? null}
onChange={(user) =>
setFilters({
...filters,
user: user?.id ?? undefined,
})
}
/>
</div>
</div>
) : (
<div className="flex-1 overflow-y-auto space-y-px" ref={contentRef} onScroll={handleScroll}>
{allActivityResponseLoading && !allActivity.length ? (
<LemonSkeleton className="my-2 h-12" repeat={10} fade />
) : allActivity.length ? (
<>
{allActivity.map((logItem, index) => (
<ActivityLogRow logItem={logItem} key={index} showExtendedDescription={false} />
))}

<div className="m-4 h-10 flex items-center justify-center gap-2 text-muted-alt">
{allActivityResponseLoading ? (
<>
<Spinner textColored /> Loading older activity
</>
) : allActivityHasNext ? (
<LemonButton
type="secondary"
fullWidth
center
onClick={() => maybeLoadOlderActivity()}
>
Load more
) : null}
</div>

<div className="flex flex-col flex-1 overflow-hidden" ref={contentRef} onScroll={handleScroll}>
<ScrollableShadows direction="vertical" innerClassName="p-2 space-y-px">
{activeTab === SidePanelActivityTab.Unread ? (
<>
{importantChangesLoading && !hasNotifications ? (
<LemonSkeleton className="my-2 h-12" repeat={10} fade />
) : hasNotifications ? (
notifications.map((logItem, index) => (
<ActivityLogRow
logItem={logItem}
key={index}
showExtendedDescription={showDetails}
/>
))
) : (
<div className="border rounded text-center border-dashed p-6 text-muted-alt">
You're all caught up!
</div>
)}
</>
) : activeTab === SidePanelActivityTab.All ? (
<>
{allActivityResponseLoading && !allActivity.length ? (
<LemonSkeleton className="my-2 h-12" repeat={10} fade />
) : allActivity.length ? (
<>
{allActivity.map((logItem, index) => (
<ActivityLogRow
logItem={logItem}
key={index}
showExtendedDescription={showDetails}
/>
))}

<div className="m-4 h-10 flex items-center justify-center gap-2 text-muted-alt">
{allActivityResponseLoading ? (
<>
<Spinner textColored /> Loading older activity
</>
) : allActivityHasNext ? (
<LemonButton
type="secondary"
fullWidth
center
onClick={() => maybeLoadOlderActivity()}
>
Load more
</LemonButton>
) : (
'No more results'
)}
</div>
</>
) : (
<div className="border rounded text-center border-dashed p-6 flex flex-col gap-2 items-center">
<span>No activity yet</span>
{filters ? (
<LemonButton type="secondary" onClick={() => setFilters(null)}>
Clear filters
</LemonButton>
) : (
'No more results'
)}
) : null}
</div>
</>
) : (
<p>You're all caught up!</p>
)}
</div>
)}
)}
</>
) : null}
</ScrollableShadows>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { connect, kea, path, selectors } from 'kea'
import { router } from 'kea-router'
import { objectsEqual } from 'kea-test-utils'
import { ActivityLogItem } from 'lib/components/ActivityLog/humanizeActivity'
import { sceneLogic } from 'scenes/sceneLogic'
import { SceneConfig } from 'scenes/sceneTypes'

import { ActivityScope, UserBasicType } from '~/types'

import type { activityForSceneLogicType } from './activityForSceneLogicType'

export type ActivityFilters = {
scope?: ActivityScope
item_id?: ActivityLogItem['item_id']
user?: UserBasicType['id']
}

export const activityFiltersForScene = (sceneConfig: SceneConfig | null): ActivityFilters | null => {
if (sceneConfig?.activityScope) {
// NOTE: - HACKY, we are just parsing the item_id from the url optimistically...
const pathParts = router.values.currentLocation.pathname.split('/')
const item_id = pathParts[2]

return { scope: sceneConfig.activityScope, item_id }
}
return null
}

export const activityForSceneLogic = kea<activityForSceneLogicType>([
path(['scenes', 'navigation', 'sidepanel', 'activityForSceneLogic']),
connect({
values: [sceneLogic, ['sceneConfig']],
}),
selectors({
sceneActivityFilters: [
(s) => [
// Similar to "breadcrumbs"
(state, props) => {
const activeSceneLogic = sceneLogic.selectors.activeSceneLogic(state, props)
const sceneConfig = s.sceneConfig(state, props)
if (activeSceneLogic && 'activityFilters' in activeSceneLogic.selectors) {
const activeLoadedScene = sceneLogic.selectors.activeLoadedScene(state, props)
return activeSceneLogic.selectors.activityFilters(
state,
activeLoadedScene?.paramsToProps?.(activeLoadedScene?.sceneParams) || props
)
} else {
return activityFiltersForScene(sceneConfig)
}
},
],
(filters): ActivityFilters | null => filters,
{ equalityCheck: objectsEqual },
],
}),
])
Loading
Loading