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(replay): move compact and feed recording rows to quill (#127714)

Hayne Ryu17406bfd3f20
diff --git a/frontend/src/scenes/session-recordings/playlist/ItemCheckbox.tsx b/frontend/src/scenes/session-recordings/playlist/ItemCheckbox.tsx
index bfabb9802256..98705546beb9 100644
--- a/frontend/src/scenes/session-recordings/playlist/ItemCheckbox.tsx
+++ b/frontend/src/scenes/session-recordings/playlist/ItemCheckbox.tsx
@@ -1,33 +1,19 @@
-import { useActions, useValues } from 'kea'
-
import { LemonCheckbox } from 'lib/lemon-ui/LemonCheckbox'
import { SessionRecordingType } from '~/types'
-import { MAX_SELECTED_RECORDINGS, sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'
+import { useRecordingSelection } from './useRecordingSelection'
export function ItemCheckbox({ recording }: { recording: SessionRecordingType }): JSX.Element {
- const { selectedRecordingsIds } = useValues(sessionRecordingsPlaylistLogic)
- const { setSelectedRecordingsIds } = useActions(sessionRecordingsPlaylistLogic)
+ const { checked, disabledReason, toggle } = useRecordingSelection(recording)
- const checked = selectedRecordingsIds.some((s) => s === recording.id)
return (
<LemonCheckbox
checked={checked}
data-attr="select-recording"
aria-label="Select recording"
- disabledReason={
- !checked && selectedRecordingsIds.length >= MAX_SELECTED_RECORDINGS
- ? `Cannot select more than ${MAX_SELECTED_RECORDINGS} recordings at once`
- : undefined
- }
- onChange={() => {
- if (checked) {
- setSelectedRecordingsIds(selectedRecordingsIds.filter((r) => r !== recording.id))
- } else {
- setSelectedRecordingsIds([...selectedRecordingsIds, recording.id])
- }
- }}
+ disabledReason={disabledReason}
+ onChange={toggle}
stopPropagation
/>
)
diff --git a/frontend/src/scenes/session-recordings/playlist/QuillItemCheckbox.tsx b/frontend/src/scenes/session-recordings/playlist/QuillItemCheckbox.tsx
new file mode 100644
index 000000000000..adfbc7856ace
--- /dev/null
+++ b/frontend/src/scenes/session-recordings/playlist/QuillItemCheckbox.tsx
@@ -0,0 +1,22 @@
+import { Checkbox } from '@posthog/quill'
+
+import { SessionRecordingType } from '~/types'
+
+import { useRecordingSelection } from './useRecordingSelection'
+
+export function QuillItemCheckbox({ recording }: { recording: SessionRecordingType }): JSX.Element {
+ const { checked, disabledReason, toggle } = useRecordingSelection(recording)
+
+ return (
+ // The row behind the checkbox opens the recording on click, so the click must stop here.
+ <span className="inline-flex" onClick={(e) => e.stopPropagation()}>
+ <Checkbox
+ checked={checked}
+ data-attr="select-recording"
+ aria-label="Select recording"
+ disabledReason={disabledReason}
+ onCheckedChange={toggle}
+ />
+ </span>
+ )
+}
diff --git a/frontend/src/scenes/session-recordings/playlist/QuillUnwatchedIndicator.tsx b/frontend/src/scenes/session-recordings/playlist/QuillUnwatchedIndicator.tsx
new file mode 100644
index 000000000000..01aa31010e3d
--- /dev/null
+++ b/frontend/src/scenes/session-recordings/playlist/QuillUnwatchedIndicator.tsx
@@ -0,0 +1,32 @@
+import { useValues } from 'kea'
+
+import { Dot, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+
+import { unwatchedIndicatorAriaLabel, unwatchedIndicatorTooltip } from './unwatchedIndicatorTooltip'
+
+export function QuillUnwatchedIndicator({ otherViewersCount }: { otherViewersCount: number }): JSX.Element {
+ const { featureFlags } = useValues(featureFlagLogic)
+ const isExcludedFromHideRecordingsMenu = !!featureFlags[FEATURE_FLAGS.REPLAY_EXCLUDE_FROM_HIDE_RECORDINGS_MENU]
+ const watchedByOthers = !isExcludedFromHideRecordingsMenu && otherViewersCount > 0
+
+ return (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <span
+ className="inline-flex"
+ aria-label={unwatchedIndicatorAriaLabel(otherViewersCount, isExcludedFromHideRecordingsMenu)}
+ />
+ }
+ >
+ <Dot variant={watchedByOthers ? 'info' : 'destructive'} />
+ </TooltipTrigger>
+ <TooltipContent>
+ {unwatchedIndicatorTooltip(otherViewersCount, isExcludedFromHideRecordingsMenu)}
+ </TooltipContent>
+ </Tooltip>
+ )
+}
diff --git a/frontend/src/scenes/session-recordings/playlist/RecordingRowStat.tsx b/frontend/src/scenes/session-recordings/playlist/RecordingRowStat.tsx
new file mode 100644
index 000000000000..5dc01214c489
--- /dev/null
+++ b/frontend/src/scenes/session-recordings/playlist/RecordingRowStat.tsx
@@ -0,0 +1,35 @@
+import clsx from 'clsx'
+import { ReactNode } from 'react'
+
+import { Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'
+
+export function RecordingRowStat({
+ icon,
+ value,
+ label,
+ destructive = false,
+}: {
+ icon: ReactNode
+ value: ReactNode
+ label: string
+ destructive?: boolean
+}): JSX.Element {
+ return (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <span
+ className={clsx(
+ 'flex items-center gap-x-0.5 shrink-0',
+ destructive && 'text-destructive-foreground'
+ )}
+ />
+ }
+ >
+ {icon}
+ {value}
+ </TooltipTrigger>
+ <TooltipContent>{label}</TooltipContent>
+ </Tooltip>
+ )
+}
diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreviewCompact.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreviewCompact.tsx
index 64b3fe67ab79..800427a7fff2 100644
--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreviewCompact.tsx
+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreviewCompact.tsx
@@ -3,12 +3,10 @@ import { useValues } from 'kea'
import { memo } from 'react'
import { IconBug, IconCursorClick, IconKeyboard, IconLive } from '@posthog/icons'
-import { LemonTag } from '@posthog/lemon-ui'
+import { Badge, Skeleton, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'
import { PropertyIcon } from 'lib/components/PropertyIcon/PropertyIcon'
import { TZLabel } from 'lib/components/TZLabel'
-import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
-import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { DraggableToNotebook } from 'scenes/notebooks/AddToNotebook/DraggableToNotebook'
import { SimpleTimeLabel } from 'scenes/session-recordings/components/SimpleTimeLabel'
import { TimestampFormat, playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'
@@ -19,11 +17,12 @@ import { SessionRecordingType } from '~/types'
import { asDisplay } from 'products/persons/frontend/person-utils'
import { gatherIconProperties } from './gatherIconProperties'
-import { ItemCheckbox } from './ItemCheckbox'
+import { QuillItemCheckbox } from './QuillItemCheckbox'
+import { QuillUnwatchedIndicator } from './QuillUnwatchedIndicator'
+import { RecordingRowStat } from './RecordingRowStat'
import { sessionRecordingsListPropertiesLogic } from './sessionRecordingsListPropertiesLogic'
import { DEFAULT_RECORDING_FILTERS_ORDER_BY, sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'
import { SortMetric } from './SortMetric'
-import { UnwatchedIndicator } from './UnwatchedIndicator'
export interface SessionRecordingPreviewCompactProps {
recording: SessionRecordingType
@@ -46,6 +45,7 @@ export const SessionRecordingPreviewCompact = memo(
const loading = !recordingProperties && recordingPropertiesLoading
const iconProperties = gatherIconProperties(recordingProperties, recording)
const errorCount = recording.console_error_count ?? 0
+
const tileDetails: { label: string; value: string | undefined }[] = [
{
label: 'Location',
@@ -69,45 +69,47 @@ export const SessionRecordingPreviewCompact = memo(
return (
<DraggableToNotebook href={urls.replaySingle(recording.id)}>
<div
+ data-quill
className={clsx(
- 'SessionRecordingPreview SessionRecordingPreview--compact group flex items-center gap-x-2 overflow-hidden cursor-pointer py-1.5 px-2 text-[11px]',
+ 'SessionRecordingPreview SessionRecordingPreview--compact group flex items-center gap-x-2 overflow-hidden cursor-pointer py-1.5 px-2 text-[11px] text-foreground',
isActive && 'SessionRecordingPreview--active'
)}
>
{selectable && (
- <span className="shrink-0 flex items-center [&_label]:min-h-0">
- <ItemCheckbox recording={recording} />
+ <span className="shrink-0 flex items-center">
+ <QuillItemCheckbox recording={recording} />
</span>
)}
{loading ? (
- <LemonSkeleton className="w-8 h-8 shrink-0 rounded" />
+ <Skeleton className="w-8 h-8 shrink-0 rounded" />
) : (
- <Tooltip
- placement="right"
- title={
- <div className="flex flex-col gap-0.5 text-xs">
- {tileDetails.map(({ label, value }) => (
- <span key={label} className="break-all">
- <span className="text-secondary">{label}: </span>
- {value}
- </span>
- ))}
- </div>
- }
- >
- <div className="grid grid-cols-2 gap-0.5 p-0.5 w-8 h-8 shrink-0 rounded border bg-surface-secondary ph-no-capture">
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <div className="grid grid-cols-2 gap-0.5 p-0.5 w-8 h-8 shrink-0 rounded border border-border bg-muted ph-no-capture" />
+ }
+ >
{iconProperties.map(({ property, value }) => (
<span
key={property}
- className="flex items-center justify-center rounded-sm bg-surface-primary leading-none text-[11px]"
+ className="flex items-center justify-center rounded-sm bg-card leading-none text-[11px]"
>
<PropertyIcon property={property} value={value} />
</span>
))}
- </div>
+ </TooltipTrigger>
+ <TooltipContent side="right">
+ <div className="flex flex-col gap-0.5 text-xs">
+ {tileDetails.map(({ label, value }) => (
+ <span key={label} className="break-all">
+ <span className="text-muted-foreground">{label}: </span>
+ {value}
+ </span>
+ ))}
+ </div>
+ </TooltipContent>
</Tooltip>
)}
-
<div className="grow min-w-0 flex flex-col gap-y-0.5">
<div className="flex items-center gap-x-1.5">
<span
@@ -119,15 +121,19 @@ export const SessionRecordingPreviewCompact = memo(
{asDisplay(recording.person)}
</span>
{recording.matches_filters === false && (
- <Tooltip title="This recording is listed only because it's open. It doesn't match the current filters.">
- <LemonTag type="warning" size="small" className="shrink-0">
+ <Tooltip>
+ <TooltipTrigger render={<Badge variant="warning" className="shrink-0" />}>
Doesn't match filters
- </LemonTag>
+ </TooltipTrigger>
+ <TooltipContent>
+ This recording is listed only because it's open. It doesn't match the current
+ filters.
+ </TooltipContent>
</Tooltip>
)}
{playlistTimestampFormat === TimestampFormat.Relative ? (
<TZLabel
- className="text-secondary shrink-0"
+ className="text-muted-foreground shrink-0"
time={recording.start_time}
placement="right"
/>
@@ -138,27 +144,20 @@ export const SessionRecordingPreviewCompact = memo(
/>
)}
</div>
-
- <div className="flex items-center gap-x-2 text-secondary">
- <Tooltip title="Clicks">
- <span className="flex items-center gap-x-0.5 shrink-0">
- <IconCursorClick />
- {recording.click_count}
- </span>
- </Tooltip>
- <Tooltip title="Key presses">
- <span className="flex items-center gap-x-0.5 shrink-0">
- <IconKeyboard />
- {recording.keypress_count}
- </span>
- </Tooltip>
+ <div className="flex items-center gap-x-2 text-muted-foreground">
+ <RecordingRowStat icon={<IconCursorClick />} value={recording.click_count} label="Clicks" />
+ <RecordingRowStat
+ icon={<IconKeyboard />}
+ value={recording.keypress_count}
+ label="Key presses"
+ />
{errorCount > 0 && order !== 'console_error_count' && (
- <Tooltip title="Console errors">
- <span className="flex items-center gap-x-0.5 shrink-0 text-danger">
- <IconBug />
- {errorCount}
- </span>
- </Tooltip>
+ <RecordingRowStat
+ icon={<IconBug />}
+ value={errorCount}
+ label="Console errors"
+ destructive
+ />
)}
<span className="grow" />
<SortMetric recording={recording} order={order} />
@@ -166,21 +165,25 @@ export const SessionRecordingPreviewCompact = memo(
{isActive && recording.start_url && (
<span
title={`First URL: ${recording.start_url}`}
- className="truncate text-secondary ph-no-capture"
+ className="truncate text-muted-foreground ph-no-capture"
>
{recording.start_url.replace(/https?:\/\//g, '').split(/[?|#]/)[0]}
</span>
)}
</div>
-
<div className="min-w-4 flex flex-col items-center gap-y-1">
{recording.ongoing ? (
- <Tooltip title="This recording is still ongoing - we received data within the last 5 minutes.">
- <IconLive className="animate-[pulse_1s_ease-out_infinite] text-primary-3000" />
+ <Tooltip>
+ <TooltipTrigger render={<span className="inline-flex" />}>
+ <IconLive className="animate-[pulse_1s_ease-out_infinite] text-primary-3000" />
+ </TooltipTrigger>
+ <TooltipContent>
+ This recording is still ongoing - we received data within the last 5 minutes.
+ </TooltipContent>
</Tooltip>
) : null}
{!recording.viewed ? (
- <UnwatchedIndicator otherViewersCount={recording.viewers?.length || 0} />
+ <QuillUnwatchedIndicator otherViewersCount={recording.viewers?.length || 0} />
) : null}
</div>
</div>
diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreviewFeed.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreviewFeed.tsx
index 695cf8610190..98c9bf520313 100644
--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreviewFeed.tsx
+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreviewFeed.tsx
@@ -3,12 +3,10 @@ import { useValues } from 'kea'
import { memo } from 'react'
import { IconBug, IconCursorClick, IconKeyboard, IconLive } from '@posthog/icons'
-import { LemonTag } from '@posthog/lemon-ui'
+import { Badge, Skeleton, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'
import { PropertyIcon } from 'lib/components/PropertyIcon/PropertyIcon'
import { TZLabel } from 'lib/components/TZLabel'
-import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
-import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { DraggableToNotebook } from 'scenes/notebooks/AddToNotebook/DraggableToNotebook'
import { SimpleTimeLabel } from 'scenes/session-recordings/components/SimpleTimeLabel'
import { TimestampFormat, playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'
@@ -19,11 +17,12 @@ import { SessionRecordingType } from '~/types'
import { asDisplay } from 'products/persons/frontend/person-utils'
import { gatherIconProperties } from './gatherIconProperties'
-import { ItemCheckbox } from './ItemCheckbox'
+import { QuillItemCheckbox } from './QuillItemCheckbox'
+import { QuillUnwatchedIndicator } from './QuillUnwatchedIndicator'
+import { RecordingRowStat } from './RecordingRowStat'
import { sessionRecordingsListPropertiesLogic } from './sessionRecordingsListPropertiesLogic'
import { DEFAULT_RECORDING_FILTERS_ORDER_BY, sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'
import { SortMetric } from './SortMetric'
-import { UnwatchedIndicator } from './UnwatchedIndicator'
export interface SessionRecordingPreviewFeedProps {
recording: SessionRecordingType
@@ -53,25 +52,31 @@ export const SessionRecordingPreviewFeed = memo(
return (
<DraggableToNotebook href={urls.replaySingle(recording.id)}>
<div
+ data-quill
className={clsx(
- 'SessionRecordingPreview SessionRecordingPreview--compact group flex items-start gap-x-2 overflow-hidden cursor-pointer py-2 px-2 text-[11px]',
+ 'SessionRecordingPreview SessionRecordingPreview--compact group flex items-start gap-x-2 overflow-hidden cursor-pointer py-2 px-2 text-[11px] text-foreground',
isActive && 'SessionRecordingPreview--active'
)}
>
{selectable && (
- <span className="shrink-0 flex items-center self-center [&_label]:min-h-0">
- <ItemCheckbox recording={recording} />
+ <span className="shrink-0 flex items-center self-center">
+ <QuillItemCheckbox recording={recording} />
</span>
)}
{loading ? (
- <LemonSkeleton className="w-16 h-16 shrink-0 rounded" />
+ <Skeleton className="w-16 h-16 shrink-0 rounded" />
) : (
- <div className="grid grid-cols-2 grid-rows-2 gap-0.5 p-0.5 w-16 h-16 shrink-0 rounded border bg-surface-secondary overflow-hidden ph-no-capture">
+ <div className="grid grid-cols-2 grid-rows-2 gap-0.5 p-0.5 w-16 h-16 shrink-0 rounded border border-border bg-muted overflow-hidden ph-no-capture">
{iconProperties.map(({ property, value, label }) => (
- <Tooltip key={property} title={label}>
- <span className="flex items-center justify-center rounded-sm bg-surface-primary leading-none text-base">
+ <Tooltip key={property}>
+ <TooltipTrigger
+ render={
+ <span className="flex items-center justify-center rounded-sm bg-card leading-none text-base" />
+ }
+ >
<PropertyIcon property={property} value={value} />
- </span>
+ </TooltipTrigger>
+ <TooltipContent>{label}</TooltipContent>
</Tooltip>
))}
</div>
@@ -87,50 +92,56 @@ export const SessionRecordingPreviewFeed = memo(
{asDisplay(recording.person)}
</span>
{upNext && (
- <Tooltip title="Autoplay opens this recording when the current one ends.">
- <LemonTag size="small" className="shrink-0" data-attr="feed-up-next">
+ <Tooltip>
+ <TooltipTrigger render={<Badge className="shrink-0" data-attr="feed-up-next" />}>
Up next
- </LemonTag>
+ </TooltipTrigger>
+ <TooltipContent>
+ Autoplay opens this recording when the current one ends.
+ </TooltipContent>
</Tooltip>
)}
{recording.ongoing && (
- <Tooltip title="This recording is still ongoing - we received data within the last 5 minutes.">
- <IconLive className="shrink-0 mt-0.5 animate-[pulse_1s_ease-out_infinite] text-primary-3000" />
+ <Tooltip>
+ <TooltipTrigger render={<span className="inline-flex shrink-0 mt-0.5" />}>
+ <IconLive className="animate-[pulse_1s_ease-out_infinite] text-primary-3000" />
+ </TooltipTrigger>
+ <TooltipContent>
+ This recording is still ongoing - we received data within the last 5 minutes.
+ </TooltipContent>
</Tooltip>
)}
{!recording.viewed && (
<span className="shrink-0 pt-1">
- <UnwatchedIndicator otherViewersCount={recording.viewers?.length || 0} />
+ <QuillUnwatchedIndicator otherViewersCount={recording.viewers?.length || 0} />
</span>
)}
</div>
{recording.matches_filters === false && (
- <Tooltip title="This recording is listed only because it's open. It doesn't match the current filters.">
- <LemonTag type="warning" size="small" className="self-start">
+ <Tooltip>
+ <TooltipTrigger render={<Badge variant="warning" className="self-start" />}>
Doesn't match filters
- </LemonTag>
+ </TooltipTrigger>
+ <TooltipContent>
+ This recording is listed only because it's open. It doesn't match the current
+ filters.
+ </TooltipContent>
</Tooltip>
)}
- <div className="flex items-center gap-x-2 flex-wrap text-secondary">
- <Tooltip title="Clicks">
- <span className="flex items-center gap-x-0.5 shrink-0">
- <IconCursorClick />
- {recording.click_count}
- </span>
- </Tooltip>
- <Tooltip title="Key presses">
- <span className="flex items-center gap-x-0.5 shrink-0">
- <IconKeyboard />
- {recording.keypress_count}
- </span>
- </Tooltip>
+ <div className="flex items-center gap-x-2 flex-wrap text-muted-foreground">
+ <RecordingRowStat icon={<IconCursorClick />} value={recording.click_count} label="Clicks" />
+ <RecordingRowStat
+ icon={<IconKeyboard />}
+ value={recording.keypress_count}
+ label="Key presses"
+ />
{errorCount > 0 && order !== 'console_error_count' && (
- <Tooltip title="Console errors">
- <span className="flex items-center gap-x-0.5 shrink-0 text-danger">
- <IconBug />
- {errorCount}
- </span>
- </Tooltip>
+ <RecordingRowStat
+ icon={<IconBug />}
+ value={errorCount}
+ label="Console errors"
+ destructive
+ />
)}
{playlistTimestampFormat === TimestampFormat.Relative ? (
<TZLabel className="shrink-0" time={recording.start_time} placement="right" />
@@ -148,7 +159,7 @@ export const SessionRecordingPreviewFeed = memo(
{startUrl && (
<span
title={`First URL: ${recording.start_url}`}
- className="truncate text-secondary ph-no-capture"
+ className="truncate text-muted-foreground ph-no-capture"
>
{startUrl}
</span>
diff --git a/frontend/src/scenes/session-recordings/playlist/UnwatchedIndicator.tsx b/frontend/src/scenes/session-recordings/playlist/UnwatchedIndicator.tsx
index 4c0cc801e5b5..67845ff232c2 100644
--- a/frontend/src/scenes/session-recordings/playlist/UnwatchedIndicator.tsx
+++ b/frontend/src/scenes/session-recordings/playlist/UnwatchedIndicator.tsx
@@ -7,25 +7,14 @@ import { FEATURE_FLAGS } from 'lib/constants'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { unwatchedIndicatorAriaLabel, unwatchedIndicatorTooltip } from './unwatchedIndicatorTooltip'
+
export function UnwatchedIndicator({ otherViewersCount }: { otherViewersCount: number }): JSX.Element {
const { featureFlags } = useValues(featureFlagLogic)
-
- const isExcludedFromHideRecordingsMenu = featureFlags[FEATURE_FLAGS.REPLAY_EXCLUDE_FROM_HIDE_RECORDINGS_MENU]
-
- // If person wished to be excluded from the hide recordings menu, we don't show the tooltip
- const tooltip = isExcludedFromHideRecordingsMenu ? (
- <span>You have not watched this recording yet.</span>
- ) : otherViewersCount ? (
- <span>
- You have not watched this recording yet. {otherViewersCount} other{' '}
- {otherViewersCount === 1 ? 'person has' : 'people have'}.
- </span>
- ) : (
- <span>Nobody has watched this recording yet.</span>
- )
+ const isExcludedFromHideRecordingsMenu = !!featureFlags[FEATURE_FLAGS.REPLAY_EXCLUDE_FROM_HIDE_RECORDINGS_MENU]
return (
- <Tooltip title={tooltip}>
+ <Tooltip title={unwatchedIndicatorTooltip(otherViewersCount, isExcludedFromHideRecordingsMenu)}>
<div
className={clsx(
'UnwatchedIndicator w-2 h-2 rounded-full',
@@ -35,13 +24,7 @@ export function UnwatchedIndicator({ otherViewersCount }: { otherViewersCount: n
? 'UnwatchedIndicator--secondary'
: 'UnwatchedIndicator--primary'
)}
- aria-label={
- isExcludedFromHideRecordingsMenu
- ? 'unwatched-recording-by-you-label'
- : otherViewersCount
- ? 'unwatched-recording-by-you-label'
- : 'unwatched-recording-by-everyone-label'
- }
+ aria-label={unwatchedIndicatorAriaLabel(otherViewersCount, isExcludedFromHideRecordingsMenu)}
/>
</Tooltip>
)
diff --git a/frontend/src/scenes/session-recordings/playlist/unwatchedIndicatorTooltip.tsx b/frontend/src/scenes/session-recordings/playlist/unwatchedIndicatorTooltip.tsx
new file mode 100644
index 000000000000..cc5c254dfe2a
--- /dev/null
+++ b/frontend/src/scenes/session-recordings/playlist/unwatchedIndicatorTooltip.tsx
@@ -0,0 +1,21 @@
+export function unwatchedIndicatorTooltip(otherViewersCount: number, excludedFromHideMenu: boolean): JSX.Element {
+ // If person wished to be excluded from the hide recordings menu, we don't show the tooltip
+ if (excludedFromHideMenu) {
+ return <span>You have not watched this recording yet.</span>
+ }
+ if (otherViewersCount) {
+ return (
+ <span>
+ You have not watched this recording yet. {otherViewersCount} other{' '}
+ {otherViewersCount === 1 ? 'person has' : 'people have'}.
+ </span>
+ )
+ }
+ return <span>Nobody has watched this recording yet.</span>
+}
+
+export function unwatchedIndicatorAriaLabel(otherViewersCount: number, excludedFromHideMenu: boolean): string {
+ return excludedFromHideMenu || otherViewersCount
+ ? 'unwatched-recording-by-you-label'
+ : 'unwatched-recording-by-everyone-label'
+}
diff --git a/frontend/src/scenes/session-recordings/playlist/useRecordingSelection.ts b/frontend/src/scenes/session-recordings/playlist/useRecordingSelection.ts
new file mode 100644
index 000000000000..75484834bf15
--- /dev/null
+++ b/frontend/src/scenes/session-recordings/playlist/useRecordingSelection.ts
@@ -0,0 +1,29 @@
+import { useActions, useValues } from 'kea'
+
+import { SessionRecordingType } from '~/types'
+
+import { MAX_SELECTED_RECORDINGS, sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'
+
+export function useRecordingSelection(recording: SessionRecordingType): {
+ checked: boolean
+ disabledReason: string | undefined
+ toggle: () => void
+} {
+ const { selectedRecordingsIds } = useValues(sessionRecordingsPlaylistLogic)
+ const { setSelectedRecordingsIds } = useActions(sessionRecordingsPlaylistLogic)
+ const checked = selectedRecordingsIds.some((s) => s === recording.id)
+ return {
+ checked,
+ disabledReason:
+ !checked && selectedRecordingsIds.length >= MAX_SELECTED_RECORDINGS
+ ? `Cannot select more than ${MAX_SELECTED_RECORDINGS} recordings at once`
+ : undefined,
+ toggle: () => {
+ if (checked) {
+ setSelectedRecordingsIds(selectedRecordingsIds.filter((r) => r !== recording.id))
+ } else {
+ setSelectedRecordingsIds([...selectedRecordingsIds, recording.id])
+ }
+ },
+ }
+}