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

feat(insights): Add edit button for dashboard filters #21841

Merged
merged 23 commits into from Apr 30, 2024

Conversation

webjunkie
Copy link
Contributor

@webjunkie webjunkie commented Apr 25, 2024

Problem

I read about some confusion that adjusting the filters saves the insight for everyone in the team immediately.

Changes

  • disable filters and put an edit button

Apr-25-2024 14-22-43

Does this work well for both Cloud and self-hosted?

n/a

How did you test this code?

  • tbd

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

4 snapshot changes in total. 0 added, 4 modified, 0 deleted:

  • chromium: 0 added, 4 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

github-actions bot commented Apr 25, 2024

Size Change: +524 B (0%)

Total Size: 1.05 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 1.05 MB +524 B (0%)

compressed-size-action

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@webjunkie
Copy link
Contributor Author

@mariusandra and @Twixes is this something that would make sense?

@mariusandra
Copy link
Collaborator

In general, improving this makes sense, but I'd change the flow here:

  • I expected that when I change the filters, the dashboard would update automatically, just not save each insight
  • Then I could press "save" to persist the changes, or "cancel" (or "reset") to reset them.

Is it easy to add a "soft apply" on filter change?

Also, do we want to show if any filters are applied? A visually easy way to do it would be a red notification bubble/dot with the number of filters inside.

2024-04-25 12 56 11

@webjunkie
Copy link
Contributor Author

Thanks for the input!

the dashboard would update automatically, just not save each insight

Yeah this soft apply or preview is exactly the problem.. we don't have it. It saves the whole dashboard and only this applies the filters to all insights and then you can recalculate them to see them.
So even "hey let's update and then roll back" would mean that meanwhile someone else opening the dashboard somewhere else would see your changes.

Not sure what to make of it. Maybe we make all insights grey when you adjust the filters until you save or cancel? 🙈

A visually easy way to do it would be a red notification bubble

Good idea. And that also leads me to the realization that now with my change you don't see what this dashboard's filter and time is.

@webjunkie
Copy link
Contributor Author

webjunkie commented Apr 25, 2024

New idea:

Show filters as disabled. Show insights as stale while editing filters.

Apr-25-2024 14-22-43

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@webjunkie webjunkie requested a review from a team April 26, 2024 07:37
@Twixes Twixes force-pushed the fix/dashboard-logic-insights branch from 31526a6 to 16e9855 Compare April 26, 2024 13:06
Base automatically changed from fix/dashboard-logic-insights to master April 29, 2024 06:25
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Collaborator

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this new option is good enough to try UX-wise. Code wise, I think the "stale" insight card state is no longer needed (adding dead code 🤔), and I also think a bit of state management could move from React to the Kea layer... possibly?

Comment on lines 31 to 74
const [editMode, setEditMode] = useState(false)
const [tempDates, setTempDates] = useState<Dates>({
dateFrom: dashboardFilters?.date_from,
dateTo: dashboardFilters?.date_to,
})
const [tempProperties, setTempProperties] = useState<AnyPropertyFilter[] | undefined>(
dashboard?.filters.properties ?? undefined
)

useEffect(() => {
const hasPendingChanges =
tempDates.dateFrom !== dashboardFilters?.date_from ||
tempDates.dateTo !== dashboardFilters?.date_to ||
JSON.stringify(tempProperties) !== JSON.stringify(dashboard?.filters.properties)
if (onPendingChanges) {
onPendingChanges(hasPendingChanges)
}
}, [tempDates, tempProperties])

const handleSave: () => void = () => {
if (!canEditDashboard) {
return
}
setDates(tempDates.dateFrom ?? null, tempDates.dateTo ?? null)
if (tempProperties) {
setProperties(tempProperties)
}
if (onPendingChanges) {
onPendingChanges(false)
}
setEditMode(false)
}

const handleCancel: () => void = () => {
setTempDates({
dateFrom: dashboardFilters?.date_from,
dateTo: dashboardFilters?.date_to,
})
setTempProperties(dashboard?.filters.properties ?? undefined)
setEditMode(false)
if (onPendingChanges) {
onPendingChanges(false)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it could be a logic. We do try to avoid react state as much as possible

@webjunkie
Copy link
Contributor Author

I think the "stale" insight card state is no longer needed (adding dead code 🤔)

Not sure I follow. I made it undead, added the stale. It shows up when you change filters so you don't wonder why nothing is happening. Do you mean this?

# Conflicts:
#	frontend/__snapshots__/posthog-3000-navigation--navigation-3000--dark.png
#	frontend/__snapshots__/posthog-3000-navigation--navigation-3000--light.png
#	frontend/__snapshots__/posthog-3000-navigation--navigation-base--dark.png
#	frontend/__snapshots__/posthog-3000-navigation--navigation-base--light.png
@mariusandra
Copy link
Collaborator

I think the "stale" insight card state is no longer needed (adding dead code 🤔)

Not sure I follow. I made it undead, added the stale. It shows up when you change filters so you don't wonder why nothing is happening. Do you mean this?

Ignore me then 😬

@webjunkie webjunkie enabled auto-merge (squash) April 30, 2024 11:26
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@webjunkie webjunkie merged commit a63217b into master Apr 30, 2024
103 checks passed
@webjunkie webjunkie deleted the feature/dashboard-edit-switch branch April 30, 2024 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants