<commit_before>import React, { Component } from "react";
import {
  Modal,
  ModalHeader,
  ModalBody,
  ModalFooter,
  ButtonGroup,
  Button,
  FormGroup,
  Input,
  Label
} from "reactstrap";
const components = [
  "Alert Condition",
  "Damage Reports",
  "Damage Teams",
  "Decontamination",
  "Docking",
  "Engines",
  "External Sensors",
  "Interception",
  "Internal Sensors",
  "Jump Drive",
  "Long Range Comm",
  "Medical Teams",
  "Navigation",
  "Phasers",
  "Probes",
  "Railgun",
  "Reactivation Code",
  "Reactor",
  "Remote Access",
  "Security Teams",
  "Self Destruct",
  "Shields",
  "Short Range Comm",
  "Sickbay",
  "Signal Jammer",
  "Stealth Field",
  "THX",
  "Targeting",
  "Torpedos",
  "Tractor Beam",
  "Transporter"
];

class NotificationConfig extends Component {
  constructor(props) {
    super(props);
    const storedAllowed = localStorage.getItem("allowed_notifications");
    const allowed = storedAllowed
      ? JSON.parse(storedAllowed)
      : components.reduce((prev, next) => {
          prev[next] = true;
          return prev;
        }, {});
    this.state = {
      allowed
    };
  }
  render() {
    const { modal, toggle } = this.props;
    const { allowed } = this.state;
    return (
      <Modal isOpen={modal} toggle={toggle}>
        <ModalHeader toggle={toggle}>
          <div>Notification Config</div>
          <small>
            Configure which notifications items show up in this web browser.
          </small>
        </ModalHeader>

        <ModalBody>
          <ButtonGroup>
            <Button
              size="sm"
              color="danger"
              onClick={() =>
                this.setState(
                  state => ({
                    allowed: components.reduce((prev, next) => {
                      prev[next] = false;
                      return prev;
                    }, {})
                  }),
                  () => {
                    localStorage.setItem(
                      "allowed_notifications",
                      JSON.stringify(this.state.allowed)
                    );
                  }
                )
              }
            >
              Uncheck All
            </Button>
            <Button
              size="sm"
              color="success"
              onClick={() =>
                this.setState(
                  state => ({
                    allowed: components.reduce((prev, next) => {
                      prev[next] = true;
                      return prev;
                    }, {})
                  }),
                  () => {
                    localStorage.setItem(
                      "allowed_notifications",
                      JSON.stringify(this.state.allowed)
                    );
                  }
                )
              }
            >
              Check All
            </Button>
          </ButtonGroup>
          <div className="flex-row flex-wrap" style={{ display: "flex" }}>
            {components.map(c => (
              <FormGroup key={c} check style={{ width: "50%" }}>
                <Label check>
                  <Input
                    type="checkbox"
                    checked={allowed[c] || false}
                    onChange={() =>
                      this.setState(
                        state => ({
                          allowed: { ...state.allowed, [c]: !state.allowed[c] }
                        }),
                        () => {
                          localStorage.setItem(
                            "allowed_notifications",
                            JSON.stringify(this.state.allowed)
                          );
                        }
                      )
                    }
                  />{" "}
                  {c}
                </Label>
              </FormGroup>
            ))}
          </div>
        </ModalBody>
        <ModalFooter>
          <Button color="primary" onClick={toggle}>
            Close
          </Button>
        </ModalFooter>
      </Modal>
    );
  }
}
export default NotificationConfig;<commit_msg>Adding the speech notification settings.<commit_after>import React, { Component } from "react";
import {
  Modal,
  ModalHeader,
  ModalBody,
  ModalFooter,
  ButtonGroup,
  Button,
  FormGroup,
  Input,
  Label,
  Col,
  Row
} from "reactstrap";

const components = [
  "Alert Condition",
  "Damage Reports",
  "Damage Teams",
  "Decontamination",
  "Docking",
  "Engines",
  "External Sensors",
  "Interception",
  "Internal Sensors",
  "Jump Drive",
  "Long Range Comm",
  "Medical Teams",
  "Navigation",
  "Phasers",
  "Probes",
  "Railgun",
  "Reactivation Code",
  "Reactor",
  "Remote Access",
  "Security Teams",
  "Self Destruct",
  "Shields",
  "Short Range Comm",
  "Sickbay",
  "Signal Jammer",
  "Stealth Field",
  "THX",
  "Targeting",
  "Torpedos",
  "Tractor Beam",
  "Transporter"
];

class NotificationConfig extends Component {
  constructor(props) {
    super(props);
    const storedAllowed = localStorage.getItem("allowed_notifications");
    const storedSpeech = localStorage.getItem("allowed_speech");
    const allowed = storedAllowed
      ? JSON.parse(storedAllowed)
      : components.reduce((prev, next) => {
          prev[next] = true;
          return prev;
        }, {});
    const speech = storedSpeech
      ? JSON.parse(storedSpeech)
      : components.reduce((prev, next) => {
          prev[next] = true;
          return prev;
        }, {});
    this.state = {
      allowed,
      speech
    };
  }
  render() {
    const { modal, toggle } = this.props;
    const { allowed, speech } = this.state;
    return (
      <Modal isOpen={modal} toggle={toggle} size="lg">
        <ModalHeader toggle={toggle}>
          <div>Notification Config</div>
          <small>
            Configure which notifications items show up in this web browser.
          </small>
        </ModalHeader>

        <ModalBody>
          <Row>
            <Col sm={6}>
              <h3>Text Notifications</h3>
              <ButtonGroup>
                <Button
                  size="sm"
                  color="danger"
                  onClick={() =>
                    this.setState(
                      state => ({
                        allowed: components.reduce((prev, next) => {
                          prev[next] = false;
                          return prev;
                        }, {})
                      }),
                      () => {
                        localStorage.setItem(
                          "allowed_notifications",
                          JSON.stringify(this.state.allowed)
                        );
                      }
                    )
                  }
                >
                  Uncheck All
                </Button>
                <Button
                  size="sm"
                  color="success"
                  onClick={() =>
                    this.setState(
                      state => ({
                        allowed: components.reduce((prev, next) => {
                          prev[next] = true;
                          return prev;
                        }, {})
                      }),
                      () => {
                        localStorage.setItem(
                          "allowed_notifications",
                          JSON.stringify(this.state.allowed)
                        );
                      }
                    )
                  }
                >
                  Check All
                </Button>
              </ButtonGroup>
              <div className="flex-row flex-wrap" style={{ display: "flex" }}>
                {components.map(c => (
                  <FormGroup key={c} check style={{ width: "50%" }}>
                    <Label check>
                      <Input
                        type="checkbox"
                        checked={allowed[c] || false}
                        onChange={() =>
                          this.setState(
                            state => ({
                              allowed: {
                                ...state.allowed,
                                [c]: !state.allowed[c]
                              }
                            }),
                            () => {
                              localStorage.setItem(
                                "allowed_notifications",
                                JSON.stringify(this.state.allowed)
                              );
                            }
                          )
                        }
                      />{" "}
                      {c}
                    </Label>
                  </FormGroup>
                ))}
              </div>
            </Col>
            <Col sm={6}>
              <h3>Speech Notifications</h3>
              <ButtonGroup>
                <Button
                  size="sm"
                  color="danger"
                  onClick={() =>
                    this.setState(
                      state => ({
                        speech: components.reduce((prev, next) => {
                          prev[next] = false;
                          return prev;
                        }, {})
                      }),
                      () => {
                        localStorage.setItem(
                          "allowed_speech",
                          JSON.stringify(this.state.speech)
                        );
                      }
                    )
                  }
                >
                  Uncheck All
                </Button>
                <Button
                  size="sm"
                  color="success"
                  onClick={() =>
                    this.setState(
                      state => ({
                        speech: components.reduce((prev, next) => {
                          prev[next] = true;
                          return prev;
                        }, {})
                      }),
                      () => {
                        localStorage.setItem(
                          "allowed_speech",
                          JSON.stringify(this.state.speech)
                        );
                      }
                    )
                  }
                >
                  Check All
                </Button>
              </ButtonGroup>
              <div className="flex-row flex-wrap" style={{ display: "flex" }}>
                {components.map(c => (
                  <FormGroup key={c} check style={{ width: "50%" }}>
                    <Label check>
                      <Input
                        type="checkbox"
                        checked={speech[c] || false}
                        onChange={() =>
                          this.setState(
                            state => ({
                              speech: {
                                ...state.speech,
                                [c]: !state.speech[c]
                              }
                            }),
                            () => {
                              localStorage.setItem(
                                "allowed_speech",
                                JSON.stringify(this.state.speech)
                              );
                            }
                          )
                        }
                      />{" "}
                      {c}
                    </Label>
                  </FormGroup>
                ))}
              </div>
            </Col>
          </Row>
        </ModalBody>
        <ModalFooter>
          <Button color="primary" onClick={toggle}>
            Close
          </Button>
        </ModalFooter>
      </Modal>
    );
  }
}
export default NotificationConfig;
{'fraction_non_alphanumeric': 0.11025227214813556, 'fraction_numerical': 0.001019281406608341, 'mean_word_length': 0.8742438713785419, 'pattern_counts': {'":': 0, '<': 80, '<?xml version=': 0, '>': 119, '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': '3746546', 'n_tokens_mistral': 2865, 'n_tokens_neox': 2708, 'n_words': 514}