Skip to content

Commit

Permalink
fix(insights): hide delete series button when there is a single series
Browse files Browse the repository at this point in the history
  • Loading branch information
skoob13 committed Aug 9, 2024
1 parent 6d7124c commit d857cb3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cypress/e2e/trends.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,8 @@ describe('Trends', () => {
cy.get('[data-attr=math-monthly_active-0]').trigger('mouseenter') // Activate warning tooltip
cy.get('.Tooltip').contains('we recommend using "Unique users" here instead').should('exist')
})

it('Does not show delete button on single series insight', () => {
cy.get('[data-attr=delete-prop-filter-0]').should('not.exist')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@ export const actionsAndEventsToSeries = (
return series
}

export const actionsAndEventsCount = ({
actions,
events,
data_warehouse,
new_entity,
}: FilterTypeActionsAndEvents): number => {
return [...(actions || []), ...(events || []), ...(data_warehouse || []), ...(new_entity || [])].length
}

/**
* Converts `hidden_legend_keys` in trends and stickiness insights to an array of hidden indexes.
* Example: `{1: true, 2: false}` will become `[1]`.
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/queries/nodes/InsightViz/TrendsSeries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { FunnelsQuery, LifecycleQuery, StickinessQuery, TrendsQuery } from '~/qu
import { isInsightQueryNode } from '~/queries/utils'
import { FilterType } from '~/types'

import { actionsAndEventsToSeries } from '../InsightQuery/utils/filtersToQueryNode'
import { actionsAndEventsCount, actionsAndEventsToSeries } from '../InsightQuery/utils/filtersToQueryNode'
import { queryNodeToFilter } from '../InsightQuery/utils/queryNodeToFilter'

export function TrendsSeries(): JSX.Element | null {
Expand Down Expand Up @@ -90,6 +90,7 @@ export function TrendsSeries(): JSX.Element | null {
TaxonomicFilterGroupType.Actions,
TaxonomicFilterGroupType.DataWarehouse,
]}
hideDeleteBtn={actionsAndEventsCount(filters as any) === 1}
/>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export function ActionFilterRow({
<LemonButton
key="delete"
icon={<IconTrash />}
// title="Delete graph series"
title="Delete graph series"
data-attr={`delete-prop-filter-${index}`}
noPadding={!enablePopup}
onClick={() => {
Expand Down

0 comments on commit d857cb3

Please sign in to comment.