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

refactor(insights): simplify "save as ..." #24024

Merged
merged 6 commits into from
Jul 29, 2024
Merged

Conversation

thmsobrmlr
Copy link
Contributor

@thmsobrmlr thmsobrmlr commented Jul 26, 2024

Problem / Changes

Moves the saveAs action to the insightLogic and passes in the current query, so that we don't need to do the dance where we first use setInsight to update the insight in insightLogic with the current query and then perform the "save as" action on the insightsLogic. Doing this refactor now to get rid of filters in insightDataLogic.

How did you test this code?

Created an insight, made some changes, then used "save as" to save the changed version under another name

Copy link
Contributor

github-actions bot commented Jul 26, 2024

Size Change: 0 B

Total Size: 1.07 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.07 MB

compressed-size-action

Base automatically changed from query-based-set-metadata to master July 26, 2024 16:16
@PostHog PostHog deleted a comment from posthog-bot Jul 26, 2024
@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 (wasn't pushed!)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@thmsobrmlr thmsobrmlr marked this pull request as ready for review July 26, 2024 17:17
@@ -87,7 +89,12 @@ export const insightLogic = kea<insightLogicType>([
insight,
options,
}),
saveAsNamingSuccess: (name: string, redirectToViewMode?: boolean) => ({ name, redirectToViewMode }),
saveAs: (query: Node, redirectToViewMode?: boolean) => ({ query, redirectToViewMode }),
saveAsConfirmation: (name: string, query: Node, redirectToViewMode?: boolean) => ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renaming from saveAsSuccess top saveAsConfirmation. This action is triggered after selecting the desired name in a LemonModal dialog. The Success suffix is usually reserved for kea-loader generated actions.

onSubmit: async ({ insightName }) => actions.saveAsNamingSuccess(insightName, redirectToViewMode),
})
},
saveAsNamingSuccess: ({ name, redirectToViewMode }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This whole thing happening in the listener is what we get rid of here.

@thmsobrmlr thmsobrmlr requested a review from a team July 26, 2024 17:20
@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.

@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.

Copy link
Contributor

@skoob13 skoob13 left a comment

Choose a reason for hiding this comment

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

Thanks for the comments! It works perfectly.

@thmsobrmlr thmsobrmlr merged commit 792674e into master Jul 29, 2024
92 checks passed
@thmsobrmlr thmsobrmlr deleted the refactor-save-as branch July 29, 2024 11:25
silentninja pushed a commit to silentninja/posthog that referenced this pull request Aug 8, 2024
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants