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

fix(projects): reload organization after project creation #18198

Merged
merged 3 commits into from
Oct 27, 2023

Conversation

jurajmajerik
Copy link
Contributor

Problem

When project A is created, it is set to CurrentProjectButton. If project B is created immediately after (without reloading the page), project B is now set to CurrentProjectButton. Because we're not reloading the list of projects, it appears that project A disappeared/was overwritten.

Internal ticket: https://posthoghelp.zendesk.com/agent/tickets/6745

Changes

After project creation, reload the current organization (and thus the list of projects).

How did you test this code?

👀

@@ -31,6 +32,7 @@ export function CreateProjectModal({
const handleSubmit = (): void => {
createTeam({ name, is_demo: false })
reportProjectCreationSubmitted(currentOrganization?.teams ? currentOrganization.teams.length : 0, name.length)
loadCurrentOrganization()
Copy link
Member

@Twixes Twixes Oct 27, 2023

Choose a reason for hiding this comment

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

Currently this is a race condition, because we are calling the non-blocking version of createTeam earlier. We could use useAsyncActions(organizationLogic) for it instead, and then call await createTeam(...) in this function, so that by the time we call loadCurrentOrganization(), we're sure that the new project actually exists by now.

However, this code basically connects two logics – it really belongs in the logics. This way if we ever call createTeam anywhere else, we won't have to remember about loadCurrentOrganization().
Let's call loadCurrentOrganization via a listener in teamLogic. Specifically, it should be a createTeamSuccess listener (every Kea loader action has *Success and *Failure companions, which are fired when loading finishes).

@jurajmajerik jurajmajerik requested a review from Twixes October 27, 2023 13:17
@posthog-bot
Copy link
Contributor

posthog-bot commented Oct 27, 2023

It looks like the code of hogql-parser has changed since last push, but its version stayed the same at 1.0.0. 👀
Make sure to resolve this in hogql_parser/setup.py before merging!

@jurajmajerik: clang-format made some formatting changes here

@Twixes Twixes merged commit b93a7e5 into master Oct 27, 2023
74 of 75 checks passed
@Twixes Twixes deleted the projects/fix-projectswitcher-reload branch October 27, 2023 13:38
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