<commit_before>import { notification, Select } from "antd";
import React, { useState } from "react";
import { useGetProjectDetailsQuery } from "../../apis/projects/project";
import { useRoles } from "../../contexts/roles-context";

/**
 * React component to render the project role.  If the user can manage members,
 * then a select component will be rendered allowing the user to change the role
 * any member.  If the user cannot manage, just the label for the project role
 * will be rendered
 *
 * @param {object} item - the current item to be rendered
 * @returns {*}
 * @constructor
 */
export function ProjectRole({ projectId, item, updateRoleFn }) {
  const { data: project = {} } = useGetProjectDetailsQuery(projectId);
  const [role, setRole] = React.useState(item.role);
  const [loading, setLoading] = useState(false);
  const { roles, getRoleFromKey } = useRoles();

  /**
   * When the project role for the user is updated, update the new value on
   * the server as well.
   *
   * @param {string} value - updated role
   */
  const onChange = (value) => {
    setLoading(true);
    updateRoleFn({ projectId, id: item.id, role: value })
      .then((message) => {
        notification.success({ message });
        setRole(value);
      })
      .catch((message) =>
        notification.error({
          message,
        })
      )
      .finally(() => setLoading(false));
  };

  return project.canManage ? (
    <Select
      className="t-role-select"
      value={role}
      style={{ width: "100%" }}
      onChange={onChange}
      loading={loading}
      disabled={loading}
    >
      {roles.map((role) => (
        <Select.Option
          className={`t-${role.value}`}
          value={role.value}
          key={role.value}
        >
          {role.label}
        </Select.Option>
      ))}
    </Select>
  ) : (
    getRoleFromKey(item.role)
  );
}<commit_msg>Updated ProjectRole to use canManageRemote of a project rather than just canManage<commit_after>import { notification, Select } from "antd";
import React, { useState } from "react";
import { useGetProjectDetailsQuery } from "../../apis/projects/project";
import { useRoles } from "../../contexts/roles-context";

/**
 * React component to render the project role.  If the user can manage members,
 * then a select component will be rendered allowing the user to change the role
 * any member.  If the user cannot manage, just the label for the project role
 * will be rendered
 *
 * @param {object} item - the current item to be rendered
 * @returns {*}
 * @constructor
 */
export function ProjectRole({ projectId, item, updateRoleFn }) {
  const { data: project = {} } = useGetProjectDetailsQuery(projectId);
  const [role, setRole] = React.useState(item.role);
  const [loading, setLoading] = useState(false);
  const { roles, getRoleFromKey } = useRoles();

  /**
   * When the project role for the user is updated, update the new value on
   * the server as well.
   *
   * @param {string} value - updated role
   */
  const onChange = (value) => {
    setLoading(true);
    updateRoleFn({ projectId, id: item.id, role: value })
      .then((message) => {
        notification.success({ message });
        setRole(value);
      })
      .catch((message) =>
        notification.error({
          message,
        })
      )
      .finally(() => setLoading(false));
  };

  return project.canManageRemote ? (
    <Select
      className="t-role-select"
      value={role}
      style={{ width: "100%" }}
      onChange={onChange}
      loading={loading}
      disabled={loading}
    >
      {roles.map((role) => (
        <Select.Option
          className={`t-${role.value}`}
          value={role.value}
          key={role.value}
        >
          {role.label}
        </Select.Option>
      ))}
    </Select>
  ) : (
    getRoleFromKey(item.role)
  );
}
{'fraction_non_alphanumeric': 0.13762659049597506, 'fraction_numerical': 0.0015580368735393405, 'mean_word_length': 2.6271186440677967, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, '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': '6887853', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1121, 'n_words': 327}