<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import Relay from 'react-relay/classic';
import DocumentTitle from 'react-document-title';

import PageHeader from '../../shared/PageHeader';
import UserAvatar from '../../shared/UserAvatar';

import MemberEditRole from './role';
import MemberEditRemove from './remove';
import MemberEditTeamMemberships from './team-memberships';

const AVATAR_SIZE = 50;

class Edit extends React.PureComponent {
  static displayName = "Member.Edit";

  static propTypes = {
    viewer: PropTypes.shape({
      user: PropTypes.shape({
        id: PropTypes.string.isRequired
      }).isRequired
    }).isRequired,
    organizationMember: PropTypes.shape({
      uuid: PropTypes.string.isRequired,
      user: PropTypes.shape({
        id: PropTypes.string.isRequired,
        name: PropTypes.string.isRequired,
        email: PropTypes.string.isRequired,
        avatar: PropTypes.shape({
          url: PropTypes.string.isRequired
        }).isRequired
      }).isRequired
    })
  };

  render() {
    if (!this.props.organizationMember) {
      return null;
    }

    const isSelf = this.props.organizationMember.user.id === this.props.viewer.user.id;

    return (
      <DocumentTitle title={`Users · ${this.props.organizationMember.user.name}`}>
        <div>
          <PageHeader>
            <PageHeader.Icon>
              <UserAvatar
                user={this.props.organizationMember.user}
                className="align-middle mr2"
                style={{ width: AVATAR_SIZE, height: AVATAR_SIZE }}
              />
            </PageHeader.Icon>
            <PageHeader.Title className="truncate mr2">
              {this.props.organizationMember.user.name}
            </PageHeader.Title>
            <PageHeader.Description className="truncate mr2">
              {this.props.organizationMember.user.email}
            </PageHeader.Description>
            <PageHeader.Menu>
              <MemberEditRemove
                isSelf={isSelf}
                viewer={this.props.viewer}
                organizationMember={this.props.organizationMember}
              />
            </PageHeader.Menu>
          </PageHeader>
          <MemberEditRole
            isSelf={isSelf}
            viewer={this.props.viewer}
            organizationMember={this.props.organizationMember}
          />
          <MemberEditTeamMemberships
            isSelf={isSelf}
            organizationMember={this.props.organizationMember}
          />
        </div>
      </DocumentTitle>
    );
  }
}

export default Relay.createContainer(Edit, {
  fragments: {
    viewer: () => Relay.QL`
      fragment on Viewer {
        ${MemberEditRemove.getFragment('viewer')}
        user {
          id
        }
      }
    `,
    organizationMember: () => Relay.QL`
      fragment on OrganizationMember {
        ${MemberEditRole.getFragment('organizationMember')}
        ${MemberEditRemove.getFragment('organizationMember')}
        ${MemberEditTeamMemberships.getFragment('organizationMember')}
        uuid
        user {
          id
          name
          email
          avatar {
            url
          }
        }
      }
    `
  }
});
<commit_msg>Only display team editor if we can admin teams<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import Relay from 'react-relay/classic';
import DocumentTitle from 'react-document-title';

import PageHeader from '../../shared/PageHeader';
import UserAvatar from '../../shared/UserAvatar';

import MemberEditRole from './role';
import MemberEditRemove from './remove';
import MemberEditTeamMemberships from './team-memberships';

const AVATAR_SIZE = 50;

class Edit extends React.PureComponent {
  static displayName = "Member.Edit";

  static propTypes = {
    viewer: PropTypes.shape({
      user: PropTypes.shape({
        id: PropTypes.string.isRequired
      }).isRequired
    }).isRequired,
    organizationMember: PropTypes.shape({
      uuid: PropTypes.string.isRequired,
      organization: PropTypes.shape({
        permissions: PropTypes.shape({
          teamAdmin: PropTypes.shape({
            allowed: PropTypes.bool.isRequired
          }).isRequired
        }).isRequired
      }).isRequired,
      user: PropTypes.shape({
        id: PropTypes.string.isRequired,
        name: PropTypes.string.isRequired,
        email: PropTypes.string.isRequired,
        avatar: PropTypes.shape({
          url: PropTypes.string.isRequired
        }).isRequired
      }).isRequired
    })
  };

  render() {
    if (!this.props.organizationMember) {
      return null;
    }

    const isSelf = this.props.organizationMember.user.id === this.props.viewer.user.id;

    let memberEditTeamMemberships = null;
    if (this.props.organizationMember.organization.permissions.teamAdmin.allowed) {
      memberEditTeamMemberships = (
        <MemberEditTeamMemberships
          isSelf={isSelf}
          organizationMember={this.props.organizationMember}
        />
      );
    }

    return (
      <DocumentTitle title={`Users · ${this.props.organizationMember.user.name}`}>
        <div>
          <PageHeader>
            <PageHeader.Icon>
              <UserAvatar
                user={this.props.organizationMember.user}
                className="align-middle mr2"
                style={{ width: AVATAR_SIZE, height: AVATAR_SIZE }}
              />
            </PageHeader.Icon>
            <PageHeader.Title className="truncate mr2">
              {this.props.organizationMember.user.name}
            </PageHeader.Title>
            <PageHeader.Description className="truncate mr2">
              {this.props.organizationMember.user.email}
            </PageHeader.Description>
            <PageHeader.Menu>
              <MemberEditRemove
                isSelf={isSelf}
                viewer={this.props.viewer}
                organizationMember={this.props.organizationMember}
              />
            </PageHeader.Menu>
          </PageHeader>
          <MemberEditRole
            isSelf={isSelf}
            viewer={this.props.viewer}
            organizationMember={this.props.organizationMember}
          />
          {memberEditTeamMemberships}
        </div>
      </DocumentTitle>
    );
  }
}

export default Relay.createContainer(Edit, {
  fragments: {
    viewer: () => Relay.QL`
      fragment on Viewer {
        ${MemberEditRemove.getFragment('viewer')}
        user {
          id
        }
      }
    `,
    organizationMember: () => Relay.QL`
      fragment on OrganizationMember {
        ${MemberEditRole.getFragment('organizationMember')}
        ${MemberEditRemove.getFragment('organizationMember')}
        ${MemberEditTeamMemberships.getFragment('organizationMember')}
        uuid
        organization {
          permissions {
            teamAdmin {
              allowed
            }
          }
        }
        user {
          id
          name
          email
          avatar {
            url
          }
        }
      }
    `
  }
});

{'fraction_non_alphanumeric': 0.10980113636363636, 'fraction_numerical': 0.0014204545454545455, 'mean_word_length': 1.9936224489795917, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2118819', 'n_tokens_mistral': 1892, 'n_tokens_neox': 1863, 'n_words': 338}