Release breakdown_comparisons_ui flag (#4774)
This commit is contained in:
parent
dac9e3a0f0
commit
af5eb720db
|
|
@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
|
|||
## Unreleased
|
||||
|
||||
### Added
|
||||
- Dashboard shows comparisons for all reports
|
||||
|
||||
### Removed
|
||||
### Changed
|
||||
### Fixed
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ export function parseSiteFromDataset(dataset: DOMStringMap): PlausibleSite {
|
|||
|
||||
type FeatureFlags = {
|
||||
channels?: boolean
|
||||
breakdown_comparisons_ui?: boolean
|
||||
saved_segments?: boolean
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,8 @@ export default function BreakdownModal<TListItem extends { name: string }>({
|
|||
orderByDictionary,
|
||||
toggleSortByMetric,
|
||||
renderIcon,
|
||||
getExternalLinkURL
|
||||
getExternalLinkURL,
|
||||
meta
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,8 @@
|
|||
/** @format */
|
||||
|
||||
import React from 'react'
|
||||
import {
|
||||
render as libraryRender,
|
||||
screen,
|
||||
fireEvent,
|
||||
waitFor
|
||||
} from '@testing-library/react'
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react'
|
||||
import MetricValue from './metric-value'
|
||||
import SiteContextProvider, { PlausibleSite } from '../../site-context'
|
||||
|
||||
jest.mock('@heroicons/react/24/solid', () => ({
|
||||
ArrowUpRightIcon: () => <>↑</>,
|
||||
|
|
@ -254,13 +248,6 @@ function valueProps<T>(
|
|||
} as any /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
||||
}
|
||||
|
||||
function render(ui: React.ReactNode) {
|
||||
const site = {
|
||||
flags: { breakdown_comparisons_ui: true }
|
||||
} as unknown as PlausibleSite
|
||||
libraryRender(<SiteContextProvider site={site}>{ui}</SiteContextProvider>)
|
||||
}
|
||||
|
||||
async function renderWithTooltip(ui: React.ReactNode) {
|
||||
render(ui)
|
||||
await waitForTooltip()
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import {
|
|||
} from './metric-formatter'
|
||||
import { BreakdownResultMeta, DashboardQuery } from '../../query'
|
||||
import { useQueryContext } from '../../query-context'
|
||||
import { PlausibleSite, useSiteContext } from '../../site-context'
|
||||
|
||||
type MetricValues = Record<Metric, ValueType>
|
||||
|
||||
|
|
@ -19,15 +18,11 @@ type ListItem = MetricValues & {
|
|||
comparison: MetricValues & { change: Record<Metric, number> }
|
||||
}
|
||||
|
||||
function valueRenderProps(
|
||||
listItem: ListItem,
|
||||
metric: Metric,
|
||||
site: PlausibleSite
|
||||
) {
|
||||
function valueRenderProps(listItem: ListItem, metric: Metric) {
|
||||
const value = listItem[metric]
|
||||
|
||||
let comparison = null
|
||||
if (site.flags.breakdown_comparisons_ui && listItem.comparison) {
|
||||
if (listItem.comparison) {
|
||||
comparison = {
|
||||
value: listItem.comparison[metric],
|
||||
change: listItem.comparison.change[metric]
|
||||
|
|
@ -45,12 +40,11 @@ export default function MetricValue(props: {
|
|||
meta: BreakdownResultMeta
|
||||
}) {
|
||||
const { query } = useQueryContext()
|
||||
const site = useSiteContext()
|
||||
|
||||
const { metric, listItem } = props
|
||||
const { value, comparison } = useMemo(
|
||||
() => valueRenderProps(listItem, metric, site),
|
||||
[listItem, metric, site]
|
||||
() => valueRenderProps(listItem, metric),
|
||||
[listItem, metric]
|
||||
)
|
||||
const metricLabel = useMemo(() => props.renderLabel(query), [query, props])
|
||||
const shortFormatter = props.formatter ?? MetricFormatterShort[metric]
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ defmodule PlausibleWeb.StatsController do
|
|||
|
||||
defp get_flags(user, site),
|
||||
do:
|
||||
[:channels, :breakdown_comparisons_ui, :saved_segments]
|
||||
[:channels, :saved_segments]
|
||||
|> Enum.map(fn flag ->
|
||||
{flag, FunWithFlags.enabled?(flag, for: user) || FunWithFlags.enabled?(flag, for: site)}
|
||||
end)
|
||||
|
|
|
|||
Loading…
Reference in New Issue