Skip to content

Commit

Permalink
feat: Always show discussion tab (#19846)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite authored Jan 18, 2024
1 parent 6f02336 commit aa0cb9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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 { removeProjectIdIfPresent } from 'lib/utils/router-utils'
import { sceneLogic } from 'scenes/sceneLogic'
import { SceneConfig } from 'scenes/sceneTypes'

Expand All @@ -18,10 +19,15 @@ export type ActivityFilters = {
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 pathParts = removeProjectIdIfPresent(router.values.currentLocation.pathname).split('/')
const item_id = pathParts[2]

return { scope: sceneConfig.activityScope, item_id }
// Loose check for the item_id being a number, a short_id (8 chars) or a uuid
if (item_id && (item_id.length === 8 || item_id.length === 36 || !isNaN(parseInt(item_id)))) {
return { scope: sceneConfig.activityScope, item_id }
}

return { scope: sceneConfig.activityScope }
}
return null
}
Expand Down
17 changes: 5 additions & 12 deletions frontend/src/layout/navigation-3000/sidepanel/sidePanelLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { SidePanelTab } from '~/types'

import { sidePanelActivityLogic } from './panels/activity/sidePanelActivityLogic'
import { sidePanelDiscussionLogic } from './panels/discussion/sidePanelDiscussionLogic'
import { sidePanelStatusLogic } from './panels/sidePanelStatusLogic'
import type { sidePanelLogicType } from './sidePanelLogicType'
import { sidePanelStateLogic } from './sidePanelStateLogic'
Expand Down Expand Up @@ -37,8 +36,6 @@ export const sidePanelLogic = kea<sidePanelLogicType>([
// We need to mount this to ensure that marking as read works when the panel closes
sidePanelActivityLogic,
['unreadCount'],
sidePanelDiscussionLogic,
['commentCount', 'commentCountLoading'],
sidePanelStatusLogic,
['status'],
],
Expand Down Expand Up @@ -90,12 +87,12 @@ export const sidePanelLogic = kea<sidePanelLogicType>([
tabs.push(SidePanelTab.Support)
}
tabs.push(SidePanelTab.Activity)
if (isReady && !hasCompletedAllTasks) {
tabs.push(SidePanelTab.Activation)
}
if (featureflags[FEATURE_FLAGS.DISCUSSIONS]) {
tabs.push(SidePanelTab.Discussion)
}
if (isReady && !hasCompletedAllTasks) {
tabs.push(SidePanelTab.Activation)
}
tabs.push(SidePanelTab.FeaturePreviews)
tabs.push(SidePanelTab.Settings)
tabs.push(SidePanelTab.Welcome)
Expand All @@ -109,17 +106,13 @@ export const sidePanelLogic = kea<sidePanelLogicType>([
],

visibleTabs: [
(s) => [s.enabledTabs, s.selectedTab, s.sidePanelOpen, s.commentCount, s.unreadCount, s.status],
(enabledTabs, selectedTab, sidePanelOpen, commentCount, unreadCount, status): SidePanelTab[] => {
(s) => [s.enabledTabs, s.selectedTab, s.sidePanelOpen, s.unreadCount, s.status],
(enabledTabs, selectedTab, sidePanelOpen, unreadCount, status): SidePanelTab[] => {
return enabledTabs.filter((tab) => {
if (tab === selectedTab && sidePanelOpen) {
return true
}

if (tab === SidePanelTab.Discussion) {
return commentCount > 0
}

if (tab === SidePanelTab.Activity && unreadCount) {
return true
}
Expand Down

0 comments on commit aa0cb9c

Please sign in to comment.