Skip to content

ref: Remove usage of getOrganizationState function #13474

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 1 commit into from
May 30, 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
15 changes: 0 additions & 15 deletions src/sentry/static/sentry/app/mixins/organizationState.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,3 @@ const OrganizationStateMixin = {
};

export default OrganizationStateMixin;

// Non-mixin version for use with es6 components
export const getOrganizationState = function(org) {
return {
getOrganization: () => {
return org;
},
getAccess: () => {
return new Set(org.access);
},
getFeatures: () => {
return new Set(org.features);
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Box} from 'grid-emotion';
import PropTypes from 'prop-types';
import React from 'react';

import {getOrganizationState} from 'app/mixins/organizationState';
import {sortProjects} from 'app/utils';
import {t} from 'app/locale';
import Button from 'app/components/button';
Expand All @@ -13,13 +12,17 @@ import {Panel, PanelBody, PanelHeader, PanelItem} from 'app/components/panels';
import ProjectListItem from 'app/views/settings/components/settingsProjectItem';
import SentryTypes from 'app/sentryTypes';
import SettingsPageHeader from 'app/views/settings/components/settingsPageHeader';
import withOrganization from 'app/utils/withOrganization';

import ProjectStatsGraph from './projectStatsGraph';

export default class OrganizationProjects extends AsyncView {
class OrganizationProjects extends AsyncView {
static propTypes = {
organization: SentryTypes.Organization,
};

static contextTypes = {
router: PropTypes.object.isRequired,
organization: SentryTypes.Organization,
};

componentWillReceiveProps(nextProps, nextContext) {
Expand Down Expand Up @@ -64,16 +67,14 @@ export default class OrganizationProjects extends AsyncView {
}

getTitle() {
const org = this.context.organization;
const org = this.props.organization;
return `${org.name} Projects`;
}

renderBody() {
const {projectList, projectListPageLinks, projectStats} = this.state;
const {organization} = this.context;
const canCreateProjects = getOrganizationState(this.context.organization)
.getAccess()
.has('project:admin');
const {organization} = this.props;
const canCreateProjects = new Set(organization.access).has('project:admin');

const hasNewRoutes = new Set(organization.features).has('sentry10');

Expand Down Expand Up @@ -111,10 +112,7 @@ export default class OrganizationProjects extends AsyncView {
{sortProjects(projectList).map((project, i) => (
<PanelItem p={0} key={project.id} align="center">
<Box p={2} flex="1">
<ProjectListItem
project={project}
organization={this.context.organization}
/>
<ProjectListItem project={project} organization={organization} />
</Box>
<Box w={3 / 12} p={2}>
<ProjectStatsGraph
Expand Down Expand Up @@ -148,3 +146,5 @@ export default class OrganizationProjects extends AsyncView {
);
}
}

export default withOrganization(OrganizationProjects);
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';

import {getOrganizationState} from 'app/mixins/organizationState';
import {openCreateTeamModal} from 'app/actionCreators/modal';
import {t} from 'app/locale';
import Button from 'app/components/button';
Expand Down Expand Up @@ -39,9 +38,7 @@ class OrganizationTeams extends React.Component {
return null;
}

const canCreateTeams = getOrganizationState(organization)
.getAccess()
.has('project:admin');
const canCreateTeams = new Set(organization.access).has('project:admin');

const action = (
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
addSuccessMessage,
removeIndicator,
} from 'app/actionCreators/indicator';
import {getOrganizationState} from 'app/mixins/organizationState';
import {t, tct} from 'app/locale';
import AsyncView from 'app/views/asyncView';
import Button from 'app/components/button';
Expand Down Expand Up @@ -248,7 +247,7 @@ export default class ProjectKeys extends AsyncView {
renderResults() {
const {routes, params} = this.props;
const {orgId, projectId} = params;
const access = getOrganizationState(this.context.organization).getAccess();
const access = new Set(this.context.organization.access);

return (
<div>
Expand Down Expand Up @@ -276,7 +275,7 @@ export default class ProjectKeys extends AsyncView {
}

renderBody() {
const access = getOrganizationState(this.context.organization).getAccess();
const access = new Set(this.context.organization.access);
const isEmpty = !this.state.keyList.length;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import styled, {css} from 'react-emotion';

import {addErrorMessage} from 'app/actionCreators/indicator';
import {addTeamToProject, removeTeamFromProject} from 'app/actionCreators/projects';
import {getOrganizationState} from 'app/mixins/organizationState';
import {openCreateTeamModal} from 'app/actionCreators/modal';
import {t} from 'app/locale';
import AsyncView from 'app/views/asyncView';
Expand All @@ -21,7 +20,7 @@ class ProjectTeams extends AsyncView {

canCreateTeam = () => {
const {organization} = this.props;
const access = getOrganizationState(organization).getAccess();
const access = new Set(organization.access);
return (
access.has('org:write') && access.has('team:write') && access.has('project:write')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
transferProject,
} from 'app/actionCreators/projects';
import {fields} from 'app/data/forms/projectGeneralSettings';
import {getOrganizationState} from 'app/mixins/organizationState';
import {t, tct} from 'app/locale';
import AsyncView from 'app/views/asyncView';
import Button from 'app/components/button';
Expand Down Expand Up @@ -92,11 +91,13 @@ class ProjectGeneralSettings extends AsyncView {
}, handleXhrErrorResponse('Unable to transfer project'));
};

isProjectAdmin = () => {
return new Set(this.context.organization.access).has('project:admin');
};

renderRemoveProject() {
const project = this.state.data;
const isProjectAdmin = getOrganizationState(this.context.organization)
.getAccess()
.has('project:admin');
const isProjectAdmin = this.isProjectAdmin();
const {isInternal} = project;

return (
Expand Down Expand Up @@ -150,9 +151,7 @@ class ProjectGeneralSettings extends AsyncView {

renderTransferProject() {
const project = this.state.data;
const isProjectAdmin = getOrganizationState(this.context.organization)
.getAccess()
.has('project:admin');
const isProjectAdmin = this.isProjectAdmin();
const {isInternal} = project;

return (
Expand Down
Loading