Skip to content

Commit

Permalink
feat: home tab of replay doesn't need to be called recent (#24763)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
pauldambra and github-actions[bot] authored Sep 3, 2024
1 parent acb2587 commit 842f11e
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 23 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const dataManagementSidebarLogic = kea<dataManagementSidebarLogicType>([
menuItems: [
{
label: 'View recordings',
to: urls.replay(ReplayTabs.Recent, {
to: urls.replay(ReplayTabs.Home, {
filter_group: {
type: FilterLogicalOperator.And,
values: [
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/actions/ActionEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function ActionEdit({ action: loadedAction, id }: ActionEditLogicProps):
{id ? (
<LemonButton
type="secondary"
to={urls.replay(ReplayTabs.Recent, {
to={urls.replay(ReplayTabs.Home, {
filter_group: {
type: FilterLogicalOperator.And,
values: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export function ActionsTable(): JSX.Element {
Duplicate
</LemonButton>
<LemonButton
to={urls.replay(ReplayTabs.Recent, {
to={urls.replay(ReplayTabs.Home, {
filter_group: {
type: FilterLogicalOperator.And,
values: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function DefinitionView(props: DefinitionLogicProps = {}): JSX.Element {
{isEvent && (
<LemonButton
type="secondary"
to={urls.replay(ReplayTabs.Recent, {
to={urls.replay(ReplayTabs.Home, {
filter_group: {
type: FilterLogicalOperator.And,
values: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function EventDefinitionsTable(): JSX.Element {
overlay={
<>
<LemonButton
to={urls.replay(ReplayTabs.Recent, {
to={urls.replay(ReplayTabs.Home, {
filter_group: {
type: FilterLogicalOperator.And,
values: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ function PersonsTableByFilter({ recordingsFilters, properties }: PersonsTableByF
<div className="absolute top-0 right-0 z-10">
<LemonButton
key="view-opt-in-session-recordings"
to={urls.replay(ReplayTabs.Recent, recordingsFilters)}
to={urls.replay(ReplayTabs.Home, recordingsFilters)}
type="secondary"
>
View recordings
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/feature-flags/FeatureFlag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ export function FeatureFlag({ id }: { id?: string } = {}): JSX.Element {
overlay={
<>
<LemonButton
to={urls.replay(ReplayTabs.Recent, recordingFilterForFlag)}
to={urls.replay(ReplayTabs.Home, recordingFilterForFlag)}
fullWidth
>
View Recordings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const NotebookNodePlaylist = createPostHogWidgetNode<NotebookNodePlaylist
},
},
pasteOptions: {
find: urls.replay(ReplayTabs.Recent) + '(.*)',
find: urls.replay(ReplayTabs.Home) + '(.*)',
getAttributes: async (match) => {
const url = new URL(match[0])
const stringifiedFilters = url.searchParams.get('filters')
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/scenes/scenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export const sceneConfigurations: Record<Scene, SceneConfig> = {
},
}

// NOTE: These redirects will fully replace the URL. If you want to keep support for query and hash params then you should use the above `preserveParams` function.
// NOTE: These redirects will fully replace the URL. If you want to keep support for query and hash params then you should use a function (not string) redirect
export const redirects: Record<
string,
string | ((params: Params, searchParams: Params, hashParams: Params) => string)
Expand Down Expand Up @@ -428,6 +428,9 @@ export const redirects: Record<
return urls.replay()
},
'/replay': urls.replay(),
'/replay/recent': (_params, searchParams) => {
return urls.replay(undefined, searchParams.filters, searchParams.sessionRecordingId)
},
'/settings': urls.settings(),
'/project/settings': urls.settings('project'),
'/organization/settings': urls.settings('organization'),
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/scenes/session-recordings/SessionRecordings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { humanFriendlyTabName, sessionReplaySceneLogic } from './sessionReplaySc

function Header(): JSX.Element {
const { guardAvailableFeature } = useValues(upgradeModalLogic)
const playlistsLogic = savedSessionRecordingPlaylistsLogic({ tab: ReplayTabs.Recent })
const playlistsLogic = savedSessionRecordingPlaylistsLogic({ tab: ReplayTabs.Home })
const { playlists } = useValues(playlistsLogic)
const { tab } = useValues(sessionReplaySceneLogic)
const { currentTeam } = useValues(teamLogic)
Expand All @@ -54,7 +54,7 @@ function Header(): JSX.Element {
<PageHeader
buttons={
<>
{tab === ReplayTabs.Recent && !recordingsDisabled && (
{tab === ReplayTabs.Home && !recordingsDisabled && (
<>
<LemonMenu
items={[
Expand Down Expand Up @@ -184,7 +184,7 @@ function MainPanel(): JSX.Element {

{!tab ? (
<Spinner />
) : tab === ReplayTabs.Recent ? (
) : tab === ReplayTabs.Home ? (
<div className="SessionRecordingPlaylistHeightWrapper">
<SessionRecordingsPlaylist updateSearchParams />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function SessionRecordingsPlaylist(props: SessionRecordingPlaylistLogicPr
)}
<Playlist
data-attr="session-recordings-playlist"
notebooksHref={urls.replay(ReplayTabs.Recent, filters)}
notebooksHref={urls.replay(ReplayTabs.Home, filters)}
title="Recordings"
embedded={!!notebookNode}
sections={sections}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { savedSessionRecordingPlaylistsLogic } from './savedSessionRecordingPlay

export function SavedSessionRecordingPlaylistsEmptyState(): JSX.Element {
const { guardAvailableFeature } = useValues(upgradeModalLogic)
const playlistsLogic = savedSessionRecordingPlaylistsLogic({ tab: ReplayTabs.Recent })
const playlistsLogic = savedSessionRecordingPlaylistsLogic({ tab: ReplayTabs.Home })
const { playlists, loadPlaylistsFailed } = useValues(playlistsLogic)
return loadPlaylistsFailed ? (
<LemonBanner type="error">Error while trying to load playlist.</LemonBanner>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import type { sessionReplaySceneLogicType } from './sessionReplaySceneLogicType'

export const humanFriendlyTabName = (tab: ReplayTabs): string => {
switch (tab) {
case ReplayTabs.Recent:
return 'Recent recordings'
case ReplayTabs.Home:
return 'Recordings'
case ReplayTabs.Playlists:
return 'Playlists'
default:
Expand All @@ -30,11 +30,11 @@ export const sessionReplaySceneLogic = kea<sessionReplaySceneLogicType>([
values: [featureFlagLogic, ['featureFlags']],
}),
actions({
setTab: (tab: ReplayTabs = ReplayTabs.Recent) => ({ tab }),
setTab: (tab: ReplayTabs = ReplayTabs.Home) => ({ tab }),
}),
reducers(() => ({
tab: [
ReplayTabs.Recent as ReplayTabs,
ReplayTabs.Home as ReplayTabs,
{
setTab: (_, { tab }) => tab,
},
Expand All @@ -59,7 +59,7 @@ export const sessionReplaySceneLogic = kea<sessionReplaySceneLogicType>([
(s) => [s.tab],
(tab): Breadcrumb[] => {
const breadcrumbs: Breadcrumb[] = []
if (tab !== ReplayTabs.Recent) {
if (tab !== ReplayTabs.Home) {
breadcrumbs.push({
key: Scene.Replay,
name: 'Replay',
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/scenes/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ export const urls = {
savedInsights: (tab?: string): string => `/insights${tab ? `?tab=${tab}` : ''}`,
webAnalytics: (): string => `/web`,

replay: (tab?: ReplayTabs, filters?: Partial<RecordingUniversalFilters>): string =>
combineUrl(tab ? `/replay/${tab}` : '/replay/recent', filters ? { filters } : {}).url,
replay: (tab?: ReplayTabs, filters?: Partial<RecordingUniversalFilters>, sessionRecordingId?: string): string =>
combineUrl(tab ? `/replay/${tab}` : '/replay/home', {
...(filters ? { filters } : {}),
...(sessionRecordingId ? { sessionRecordingId } : {}),
}).url,
replayPlaylist: (id: string): string => `/replay/playlists/${id}`,
replaySingle: (id: string): string => `/replay/${id}`,
replayFilePlayback: (): string => '/replay/file-playback',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function WebAnalyticsRecordingsTile({ tile }: { tile: ReplayTile }): JSX.
buttonText: 'Learn more',
buttonTo: 'https://posthog.com/docs/user-guides/recordings',
}
const to = items.length > 0 ? urls.replay(ReplayTabs.Recent, replayFilters) : urls.replay()
const to = items.length > 0 ? urls.replay(ReplayTabs.Home, replayFilters) : urls.replay()
return (
<>
<SessionPlayerModal />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ export enum SavedInsightsTabs {
}

export enum ReplayTabs {
Recent = 'recent',
Home = 'home',
Playlists = 'playlists',
Errors = 'errors',
}
Expand Down

0 comments on commit 842f11e

Please sign in to comment.