Skip to content

Commit

Permalink
fix missing action when returning from dashboard (#2884)
Browse files Browse the repository at this point in the history
  • Loading branch information
EDsCODE authored Jan 8, 2021
1 parent 95c9a4e commit 11a7388
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 7 additions & 3 deletions frontend/src/scenes/insights/InsightTabs/RetentionTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function RetentionTab(): JSX.Element {
const returningNode = useRef<HTMLElement>(null)
const [open, setOpen] = useState<boolean>(false)
const [returningOpen, setReturningOpen] = useState<boolean>(false)
const { filters } = useValues(retentionTableLogic({ dashboardItemId: null }))
const { filters, actionsLookup } = useValues(retentionTableLogic({ dashboardItemId: null }))
const { setFilters } = useActions(retentionTableLogic({ dashboardItemId: null }))

const entityLogic = entityFilterLogic({
Expand Down Expand Up @@ -74,7 +74,9 @@ export function RetentionTab(): JSX.Element {
onClick={(): void => setOpen(!open)}
style={{ marginRight: 8 }}
>
{filters.target_entity?.name || 'Select action'}
{filters.target_entity?.name ||
(filters.target_entity.id && actionsLookup[filters.target_entity.id]) ||
'Select action'}
<DownOutlined className="text-muted" style={{ marginRight: '-6px' }} />
</Button>
<Select
Expand Down Expand Up @@ -109,7 +111,9 @@ export function RetentionTab(): JSX.Element {
data-attr="retention-returning-action"
onClick={(): void => setReturningOpen(!returningOpen)}
>
{filters.returning_entity?.name || 'Select action'}
{filters.returning_entity?.name ||
(filters.returning_entity.id && actionsLookup[filters.returning_entity.id]) ||
'Select action'}
<DownOutlined className="text-muted" style={{ marginRight: '-6px' }} />
</Button>
<ActionFilterDropdown
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/scenes/retention/retentionTableLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { insightHistoryLogic } from 'scenes/insights/InsightHistoryPanel/insight
import { Moment } from 'moment'
import { retentionTableLogicType } from 'types/scenes/retention/retentionTableLogicType'
import { ACTIONS_LINE_GRAPH_LINEAR, ACTIONS_TABLE } from 'lib/constants'
import { actionsModel } from '~/models'
import { ActionType } from '~/types'

export const dateOptions = ['Hour', 'Day', 'Week', 'Month']

Expand Down Expand Up @@ -75,6 +77,7 @@ export const retentionTableLogic = kea<retentionTableLogicType<Moment>>({
}),
connect: {
actions: [insightLogic, ['setAllFilters'], insightHistoryLogic, ['createInsight']],
values: [actionsModel, ['actions']],
},
actions: () => ({
setFilters: (filters) => ({ filters }),
Expand Down Expand Up @@ -110,6 +113,12 @@ export const retentionTableLogic = kea<retentionTableLogicType<Moment>>({
},
],
}),
selectors: {
actionsLookup: [
(selectors) => [selectors.actions],
(actions: ActionType[]) => Object.assign({}, ...actions.map((action) => ({ [action.id]: action.name }))),
],
},
events: ({ actions, props }) => ({
afterMount: () => props.dashboardItemId && actions.loadResults(),
}),
Expand Down

0 comments on commit 11a7388

Please sign in to comment.