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

ref(stores): Make ProjectsStore useLegacyStore compatible #29247

Conversation

evanpurkhiser
Copy link
Member

No description provided.

Copy link
Member

@matejminar matejminar left a comment

Choose a reason for hiding this comment

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

lgtm

@github-actions
Copy link
Contributor

github-actions bot commented Oct 12, 2021

size-limit report

Path Base Size (9c49b7e) Current Size Change
src/sentry/static/sentry/dist/entrypoints/app.js 52.83 KB 52.84 KB +0.01% 🔺
src/sentry/static/sentry/dist/entrypoints/sentry.css 70.9 KB 70.9 KB 0%

@davidhollin
Copy link

LGTM

@davidhollin
Copy link

LGTM

Actually, nit, but consider providing a brief description here so we know what this change actually does

Also removes the withProjectsSpecified HoC.

There's a very marginal performance regression here since the HoC
handled only re-rendering when the specified projects changed.

This isn't a huge concern, since projects rarely are changing anyway.
project => project.isMember
);
const specifiedProjects = specificProjectSlugs
? projects.filter(project => specificProjectSlugs.includes(project.slug))
Copy link
Member Author

Choose a reason for hiding this comment

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

This is basically exactly what the withProjectsSpecified HoC was doing

loading: false,
}));
jest.spyOn(ProjectsStore, 'getAll').mockImplementation(() => initialData.projects);
jest.spyOn(ProjectsStore, 'isLoading').mockImplementation(() => false);
Copy link
Member Author

Choose a reason for hiding this comment

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

Both functions are called now in withProjects

Kind of annoying that this function mocked all of the store. I almost would have rather it just used the store

* IssuesList ("child view") renders before a single project is enforced,
* will require refactoring views so that they depend on GSH enforcing a
* single project first IF they don't have required feature (and no project id
* in URL).
Copy link
Member Author

Choose a reason for hiding this comment

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

Just wrapping these a bit smaller to fit in 80ch windows


wrapper = mountWithTheme(
<GlobalSelectionHeader
organization={initialData.organization}
shouldForceProject
forceProject={initialData.organization.projects[0]}
Copy link
Member Author

Choose a reason for hiding this comment

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

A lot of tests still use organization.projects but probably shouldn't anymore

});

// Force the withProjects HoC to re-render
ProjectsStore.trigger();
Copy link
Member Author

Choose a reason for hiding this comment

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

This is pretty gross, but what we had here before where we mutated the state object was pretty bad too so 🤷

@evanpurkhiser
Copy link
Member Author

@matejminar could I get another review actually.

I ended up removing the withProjectsSpecified HoC since it was only used in the GlobalSelectionHeader and wasn't really doing anything interesting.

it also made fixing tests a bit easier

Copy link
Member

@matejminar matejminar left a comment

Choose a reason for hiding this comment

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

Tested locally, looks good.

@evanpurkhiser evanpurkhiser merged commit 05194d6 into master Oct 13, 2021
@evanpurkhiser evanpurkhiser deleted the evanpurkhiser/ref-stores-make-projectsstore-uselegacystore-compatible branch October 13, 2021 08:23
@github-actions github-actions bot locked and limited conversation to collaborators Oct 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants