Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporarily bring back individual refresh in dashboard items #3708

Merged
merged 1 commit into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions frontend/src/scenes/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { DashboardHeader } from 'scenes/dashboard/DashboardHeader'
import { DashboardItems } from 'scenes/dashboard/DashboardItems'
import { dashboardsModel } from '~/models/dashboardsModel'
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
import { CalendarOutlined, ReloadOutlined } from '@ant-design/icons'
import dayjs from 'dayjs'
import { CalendarOutlined } from '@ant-design/icons'
import { Button } from 'antd'
import './Dashboard.scss'
import { useKeyboardHotkeys } from '../../lib/hooks/useKeyboardHotkeys'
Expand All @@ -28,11 +27,9 @@ export function Dashboard({ id, shareToken }: Props): JSX.Element {
}

function DashboardView(): JSX.Element {
const { dashboard, itemsLoading, items, lastRefreshed, filters: dashboardFilters, dashboardMode } = useValues(
dashboardLogic
)
const { dashboard, itemsLoading, items, filters: dashboardFilters, dashboardMode } = useValues(dashboardLogic)
const { dashboardsLoading } = useValues(dashboardsModel)
const { refreshAllDashboardItems, setDashboardMode, addGraph, setDates } = useActions(dashboardLogic)
const { setDashboardMode, addGraph, setDates } = useActions(dashboardLogic)

useKeyboardHotkeys(
dashboardMode === DashboardMode.Public
Expand Down Expand Up @@ -89,6 +86,7 @@ function DashboardView(): JSX.Element {
{items && items.length ? (
<div>
<div className="dashboard-items-actions">
{/* :TODO: Bring this back when addressing https://github.com/PostHog/posthog/issues/3609
<div className="left-item">
Last updated <b>{lastRefreshed ? dayjs(lastRefreshed).fromNow() : 'a while ago'}</b>
{dashboardMode !== DashboardMode.Public && (
Expand All @@ -97,6 +95,7 @@ function DashboardView(): JSX.Element {
</Button>
)}
</div>
*/}
{dashboardMode !== DashboardMode.Public && (
<DateFilter
defaultValue="Custom"
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/scenes/dashboard/DashboardItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
DeliveredProcedureOutlined,
BarChartOutlined,
SaveOutlined,
ReloadOutlined,
} from '@ant-design/icons'
import { dashboardColorNames, dashboardColors } from 'lib/colors'
import { useLongPress } from 'lib/hooks/useLongPress'
Expand Down Expand Up @@ -214,6 +215,7 @@ export function DashboardItem({
preventLoading,
}

const { loadResults } = useActions(logicFromInsight(item.filters.insight, logicProps))
const { results, resultsLoading } = useValues(logicFromInsight(item.filters.insight, logicProps))
const previousLoading = usePrevious(resultsLoading)

Expand Down Expand Up @@ -293,6 +295,20 @@ export function DashboardItem({
/>
</Tooltip>
))}
{/* :TODO: Remove individual refresh when addressing https://github.com/PostHog/posthog/issues/3609 */}
<Tooltip
title={
<i>
Last updated:{' '}
{item.last_refresh ? dayjs(item.last_refresh).fromNow() : 'recently'}
</i>
}
>
<ReloadOutlined
style={{ cursor: 'pointer', marginTop: -3 }}
onClick={() => loadResults(true)}
/>
</Tooltip>
<Dropdown
placement="bottomRight"
trigger={['click']}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/scenes/dashboard/dashboardLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,9 @@ export const dashboardLogic = kea({
api.update(`api/insight/${id}`, { color })
},
refreshAllDashboardItems: async (_, breakpoint) => {
await breakpoint(200)
await breakpoint(100)
dashboardItemsModel.actions.refreshAllDashboardItems({})

eventUsageLogic.actions.reportDashboardRefreshed(values.lastRefreshed)
},
updateAndRefreshDashboard: async (_, breakpoint) => {
Expand Down