Skip to content

ref(sentry10): Remove ProjectLink and ProjectState #13626

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

Merged
merged 2 commits into from
Jun 11, 2019
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
50 changes: 0 additions & 50 deletions src/sentry/static/sentry/app/components/projectLink.jsx

This file was deleted.

16 changes: 0 additions & 16 deletions src/sentry/static/sentry/app/mixins/projectState.jsx

This file was deleted.

97 changes: 51 additions & 46 deletions src/sentry/static/sentry/app/utils/withPlugins.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,74 @@ import {defined} from 'app/utils';
import {fetchPlugins} from 'app/actionCreators/plugins';
import getDisplayName from 'app/utils/getDisplayName';
import PluginsStore from 'app/stores/pluginsStore';
import ProjectState from 'app/mixins/projectState';
import SentryTypes from 'app/sentryTypes';

import withOrganization from 'app/utils/withOrganization';
import withProject from 'app/utils/withProject';

/**
* Higher order component that fetches list of plugins and
* passes PluginsStore to component as `plugins`
*/
const withPlugins = WrappedComponent =>
createReactClass({
displayName: `withPlugins(${getDisplayName(WrappedComponent)})`,
propTypes: {
organization: SentryTypes.Organization,
project: SentryTypes.Project,
},
mixins: [ProjectState, Reflux.connect(PluginsStore, 'store')],
withOrganization(
withProject(
createReactClass({
displayName: `withPlugins(${getDisplayName(WrappedComponent)})`,
propTypes: {
organization: SentryTypes.Organization,
project: SentryTypes.Project,
},
mixins: [Reflux.connect(PluginsStore, 'store')],

componentDidMount() {
this.fetchPlugins();
},
componentDidMount() {
this.fetchPlugins();
},

componentDidUpdate(prevProps, prevState, prevContext) {
const organization = this.props.organization || this.getOrganization();
const project = this.props.project || this.getProject();
componentDidUpdate(prevProps, prevState, prevContext) {
const {organization, project} = this.props;

// Only fetch plugins when a org slug or project slug has changed
const prevOrg = prevProps.organization || (prevContext && prevContext.organization);
const prevProject = prevProps.project || (prevContext && prevContext.project);
// Only fetch plugins when a org slug or project slug has changed
const prevOrg =
prevProps.organization || (prevContext && prevContext.organization);
const prevProject = prevProps.project || (prevContext && prevContext.project);

// If previous org/project is undefined then it means:
// the HoC has mounted, `fetchPlugins` has been called (via cDM), and
// store was updated. We don't need to fetchPlugins again (or it will cause an infinite loop)
//
// This is for the unusual case where component is mounted and receives a new org/project prop
// e.g. when switching projects via breadcrumbs in settings.
if (!defined(prevProject) || !defined(prevOrg)) {
return;
}
// If previous org/project is undefined then it means:
// the HoC has mounted, `fetchPlugins` has been called (via cDM), and
// store was updated. We don't need to fetchPlugins again (or it will cause an infinite loop)
//
// This is for the unusual case where component is mounted and receives a new org/project prop
// e.g. when switching projects via breadcrumbs in settings.
if (!defined(prevProject) || !defined(prevOrg)) {
return;
}

const isOrgSame = prevOrg.slug === organization.slug;
const isProjectSame = prevProject.slug === project.slug;
const isOrgSame = prevOrg.slug === organization.slug;
const isProjectSame = prevProject.slug === project.slug;

// Don't do anything if org and project are the same
if (isOrgSame && isProjectSame) {
return;
}
// Don't do anything if org and project are the same
if (isOrgSame && isProjectSame) {
return;
}

this.fetchPlugins();
},
this.fetchPlugins();
},

fetchPlugins() {
const organization = this.props.organization || this.getOrganization();
const project = this.props.project || this.getProject();
fetchPlugins() {
const {organization, project} = this.props;

if (!project || !organization) {
return;
}
if (!project || !organization) {
return;
}

fetchPlugins({projectId: project.slug, orgId: organization.slug});
},
fetchPlugins({projectId: project.slug, orgId: organization.slug});
},

render() {
return <WrappedComponent {...this.props} plugins={this.state.store} />;
},
});
render() {
return <WrappedComponent {...this.props} plugins={this.state.store} />;
},
})
)
);

export default withPlugins;
45 changes: 0 additions & 45 deletions tests/js/spec/components/__snapshots__/projectLink.spec.jsx.snap

This file was deleted.

2 changes: 0 additions & 2 deletions tests/js/spec/components/eventOrGroupExtraDetails.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {shallow} from 'enzyme';
import toJson from 'enzyme-to-json';
import EventOrGroupExtraDetails from 'app/components/eventOrGroupExtraDetails';

jest.mock('app/mixins/projectState');

describe('EventOrGroupExtraDetails', function() {
it('renders last and first seen', function() {
const component = shallow(
Expand Down
45 changes: 0 additions & 45 deletions tests/js/spec/components/projectLink.spec.jsx

This file was deleted.

Loading