Show imported icon only when querying imported ranges (#2892)

This commit updates the imported 'G' icon, so that it appears only when
querying or comparing a range with imported data. By hiding the icon in
all other cases, users will see it only when they can actually click on
it.
pull/2895/head
Vini Brasil 4 years ago committed by GitHub
parent 7d935b79bf
commit eb6baa92a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,6 +17,7 @@ if (container) {
offset: container.dataset.offset,
hasGoals: container.dataset.hasGoals === 'true',
statsBegin: container.dataset.statsBegin,
nativeStatsBegin: container.dataset.nativeStatsBegin,
embedded: container.dataset.embedded,
background: container.dataset.background,
isDbip: container.dataset.isDbip === 'true',

@ -13,6 +13,7 @@ import { IntervalPicker, getStoredInterval, storeInterval } from './interval-pic
import FadeIn from '../../fade-in';
import * as url from '../../util/url'
import classNames from 'classnames';
import { parseNaiveDate, isBefore } from '../../util/date'
const calculateMaximumY = function(dataset) {
const yAxisValues = dataset
@ -284,9 +285,22 @@ class LineGraph extends React.Component {
}
importedNotice() {
const source = this.props.topStatData && this.props.topStatData.imported_source;
if (!this.props.topStatData?.imported_source) return
if (source) {
const isBeforeNativeStats = (date) => {
if (!date) return false
const nativeStatsBegin = parseNaiveDate(this.props.site.nativeStatsBegin)
const parsedDate = parseNaiveDate(date)
return isBefore(parsedDate, nativeStatsBegin, "day")
}
const isQueryingImportedPeriod = isBeforeNativeStats(this.props.topStatData.from)
const isComparingImportedPeriod = isBeforeNativeStats(this.props.topStatData.comparing_from)
if (isQueryingImportedPeriod || isComparingImportedPeriod) {
const source = this.props.topStatData.imported_source
const withImported = this.props.topStatData.with_imported;
const strike = withImported ? "" : " line-through"
const target = url.setQuery('with_imported', !withImported)

@ -65,6 +65,7 @@ defmodule PlausibleWeb.StatsController do
site: site,
has_goals: Plausible.Sites.has_goals?(site),
stats_start_date: stats_start_date,
native_stats_start_date: NaiveDateTime.to_date(site.native_stats_start_at),
title: "Plausible · " <> site.domain,
offer_email_report: offer_email_report,
demo: demo,
@ -296,6 +297,7 @@ defmodule PlausibleWeb.StatsController do
site: shared_link.site,
has_goals: Sites.has_goals?(shared_link.site),
stats_start_date: shared_link.site.stats_start_date,
native_stats_start_date: NaiveDateTime.to_date(shared_link.site.native_stats_start_at),
title: "Plausible · " <> shared_link.site.domain,
offer_email_report: false,
demo: false,

@ -20,6 +20,7 @@
data-has-goals="<%= @has_goals %>"
data-logged-in="<%= !!@conn.assigns[:current_user] %>"
data-stats-begin="<%= @stats_start_date %>"
data-native-stats-begin="<%= @native_stats_start_date %>"
data-shared-link-auth="<%= assigns[:shared_link_auth] %>"
data-embedded="<%= @conn.assigns[:embedded] %>"
data-background="<%= @conn.assigns[:background] %>"

Loading…
Cancel
Save