<commit_before>import React from "react";
import PropTypes from "prop-types";
import ImmutablePropTypes from "react-immutable-proptypes";
import { List, Switch } from "antd";

/**
 * Component to display a list of switches which control the column
 * visibility within the metadata table.  Each switch represents
 * a Metadata Field.
 */
export default class ColumnVisibility extends React.Component {
  static propTypes = {
    /**
     * A list of Metadata templates related to the project.
     */
    templates: ImmutablePropTypes.list.isRequired,
    /**
     * The index in the templates that is currently displayed.
     */
    current: PropTypes.number.isRequired,
    /**
     * A callback function for when there is a modification to the current template.
     * This allows the table to be updated.
     */
    templateModified: PropTypes.func.isRequired,
    /**
     * The current height of the table.  This is only used to update the height of the
     * panel when the user modifies the size of the browser window.
     */
    height: PropTypes.number.isRequired
  };

  /**
   * Handle togging of a check box.
   * @param {object} item - Metadata Field selected
   * @param {boolean} checked - whether the field should be visible or hidden.
   * @param {array} columns - list of all the columns
   */
  fieldUpdated = (item, checked, columns) => {
    item.hide = !checked;
    this.setState({ columns });

    /*
    Update the global state with the modified template.
     */
    this.props.templateModified(columns);
  };

  render() {
    let columns = [];
    if (this.props.templates.size > 0) {
      const template = this.props.templates.get(this.props.current).toJS();
      columns =
        template.modified.length === 0 ? template.fields : template.modified;
    }

    return (
      <div className="ag-grid-tool-panel--inner">
        {typeof columns !== "undefined" ? (
          <div style={{ overflowY: "auto", height: this.props.height - 77 }}>
            <List
              dataSource={columns}
              renderItem={item => (
                <List.Item
                  actions={[
                    <Switch
                      size="small"
                      className="t-field-switch"
                      checked={!item.hide}
                      onChange={checked =>
                        this.fieldUpdated(item, checked, columns)
                      }
                    />
                  ]}
                >
                  <span style={{ marginLeft: 10 }}>{item.headerName}</span>
                </List.Item>
              )}
            />
          </div>
        ) : null}
      </div>
    );<commit_msg>Do not show the ability to hide the sample name column.<commit_after>import React from "react";
import PropTypes from "prop-types";
import ImmutablePropTypes from "react-immutable-proptypes";
import { List, Switch } from "antd";

/**
 * Component to display a list of switches which control the column
 * visibility within the metadata table.  Each switch represents
 * a Metadata Field.
 */
export default class ColumnVisibility extends React.Component {
  static propTypes = {
    /**
     * A list of Metadata templates related to the project.
     */
    templates: ImmutablePropTypes.list.isRequired,
    /**
     * The index in the templates that is currently displayed.
     */
    current: PropTypes.number.isRequired,
    /**
     * A callback function for when there is a modification to the current template.
     * This allows the table to be updated.
     */
    templateModified: PropTypes.func.isRequired,
    /**
     * The current height of the table.  This is only used to update the height of the
     * panel when the user modifies the size of the browser window.
     */
    height: PropTypes.number.isRequired
  };

  /**
   * Handle togging of a check box.
   * @param {object} item - Metadata Field selected
   * @param {boolean} checked - whether the field should be visible or hidden.
   * @param {array} columns - list of all the columns
   */
  fieldUpdated = (item, checked, columns) => {
    item.hide = !checked;
    this.setState({ columns });

    /*
    Update the global state with the modified template.
     */
    this.props.templateModified(columns);
  };

  render() {
    let columns = [];
    if (this.props.templates.size > 0) {
      const template = this.props.templates.get(this.props.current).toJS();
      columns =
        template.modified.length === 0 ? template.fields : template.modified;
    }

    return (
      <div className="ag-grid-tool-panel--inner">
        {typeof columns !== "undefined" ? (
          <div style={{ overflowY: "auto", height: this.props.height - 77 }}>
            <List
              dataSource={columns.filter(f => f.field !== "sampleLabel")}
              renderItem={item => (
                <List.Item
                  actions={[
                    <Switch
                      size="small"
                      className="t-field-switch"
                      checked={!item.hide}
                      onChange={checked =>
                        this.fieldUpdated(item, checked, columns)
                      }
                    />
                  ]}
                >
                  <span style={{ marginLeft: 10 }}>{item.headerName}</span>
                </List.Item>
              )}
            />
          </div>
        ) : null}
      </div>
    );
{'fraction_non_alphanumeric': 0.10704432591502668, 'fraction_numerical': 0.002207099503402612, 'mean_word_length': 1.8651211801896734, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 32, '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': '5837543', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1381, 'n_words': 446}