<commit_before>
import React from "react";
import TrackerReact from "meteor/ultimatejs:tracker-react";
import language from "../../languages/languages.js";
import nav from "../../flux/stores/NavigationStore.js";
import formStore from "/client/flux/stores/formStore.js";

import AppForm from "./AppForm.jsx";

import {withTheme} from "@material-ui/core/styles";
import Paper from "@material-ui/core/Paper";
import Avatar from "@material-ui/core/Avatar";
import Button from "@material-ui/core/Button";
import IconButton from "@material-ui/core/IconButton";
import Drawer from "@material-ui/core/Drawer";
import Typography from "@material-ui/core/Typography";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import ListItemIcon from "@material-ui/core/ListItemIcon";
import ListItemText from "@material-ui/core/ListItemText";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
import DialogTitle from "@material-ui/core/DialogTitle";
import DialogContent from "@material-ui/core/DialogContent";
import ContentAdd from "@material-ui/icons/Add";
import Settings from "@material-ui/icons/Settings";
import Launch from "@material-ui/icons/Launch";


export default class Nav extends TrackerReact(React.Component) {

  constructor(props) {
    super(props);

    this.state = {
      subscription: {
        modules: Meteor.subscribe("userModules"),
        moduleTypes: Meteor.subscribe("userModuleTypes"),
        schemas: Meteor.subscribe("userSchemas"),
        pages: Meteor.subscribe("userPages"),
        user: Meteor.subscribe("user"),
        apps: Meteor.subscribe("userApps")
      },
      navDrawer: false,
      page: FlowRouter.getRouteName(),
      selectApp: false,
      dialog: false,
      editApp: false,
      selectModel: false,
      appForm: false,
      newApp: false
    };
  }

  componentWillMount() {
    nav.on("open-nav-drawer", ()=> {
      var navDrawerState = this.state.navDrawer;
      this.setState({
        "navDrawer": !navDrawerState
      });

    });
  }

  componentWillUnmount() {
    this.state.subscription.modules.stop();
    this.state.subscription.moduleTypes.stop();
    this.state.subscription.schemas.stop();
    this.state.subscription.pages.stop();
    this.state.subscription.user.stop();
    this.state.subscription.apps.stop();
  }

  title() {
    var user = Meteor.users.find().fetch()[0];
    if (user) {
      var app = Apps.find({id:user.selectedApp}).fetch()[0];
      if (app) {
        return app;
      } else {
        return {name:"", subtitle: ""};
      }
    } else {
      return {name:"", subtitle: ""};
    }
  }

  closeNav() {
    this.setState({
      "navDrawer": false
    });
  }

  apps() {
    return Apps.find().fetch();
  }

  pages() {
    return Pages.find().fetch();
  }

  go(route) {
    FlowRouter.go(route);
  }

  open() {
    this.setState({dialog: true});
  }

  selectApp(id) {
    Meteor.call("selectApp", id);
    location.reload();
    // this.close();
  }

  go(route) {
    FlowRouter.go(route);
  }

  module() {
    var id;
    var module = Modules.find().fetch()[0];
    if (module) {
      id = module.id;
    } else {
      id = "";
    }
    return id;
  }

  close() {
    this.setState({dialog:false});
  }

  newApp() {
    this.setState({dialog:false, newApp:true});
  }

  saveNewApp() {
    Meteor.call("newApp", formStore.getData("newApp").name);
    this.cancelNewApp();
  }

  cancelNewApp() {
    this.setState({newApp:false});
  }

  cancelEditApp() {
    this.setState({editApp: false});
  }

  saveEditApp() {
    if (formStore.getData("editApp")) {
      Meteor.call("editApp", formStore.getData("editApp").name);
    }
    this.cancelEditApp();
  }

  deleteApp() {
    Meteor.call("deleteApp");
    this.setState({editApp: false, dialog: true});
  }

  editApp() {
    this.setState({editApp: true});
  }

  update(field) {
    if (field === "model") {
      this.setState({selectModel: true});
    }
  }

  selectModel() {

  }

  cancelSelectModel() {
    this.setState({selectModel: false});
  }

  closeAppForm() {
    this.setState({newApp: false, editApp: false});
  }

  appNameShort() {
    name = this.title().name;
    nameSplitted = name.split(" ");
    short = "";
    for (var i = 0; i < nameSplitted.length; i++) {
      short += nameSplitted[i][0];
    }
    if (short !== "undefined") {
      return short;
    } else {
      return "";
    }
  }

  render() {
    var windowWidth = window.innerWidth;
    const palette = "#3f51b5";
    return (
      <Drawer
        variant={windowWidth > 900 ? "permanent" : "temporary"}<commit_msg>Fixed variables declaration<commit_after>
import React from "react";
import TrackerReact from "meteor/ultimatejs:tracker-react";
import language from "../../languages/languages.js";
import nav from "../../flux/stores/NavigationStore.js";
import formStore from "/client/flux/stores/formStore.js";

import AppForm from "./AppForm.jsx";

import {withTheme} from "@material-ui/core/styles";
import Paper from "@material-ui/core/Paper";
import Avatar from "@material-ui/core/Avatar";
import Button from "@material-ui/core/Button";
import IconButton from "@material-ui/core/IconButton";
import Drawer from "@material-ui/core/Drawer";
import Typography from "@material-ui/core/Typography";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import ListItemIcon from "@material-ui/core/ListItemIcon";
import ListItemText from "@material-ui/core/ListItemText";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
import DialogTitle from "@material-ui/core/DialogTitle";
import DialogContent from "@material-ui/core/DialogContent";
import ContentAdd from "@material-ui/icons/Add";
import Settings from "@material-ui/icons/Settings";
import Launch from "@material-ui/icons/Launch";


export default class Nav extends TrackerReact(React.Component) {

  constructor(props) {
    super(props);

    this.state = {
      subscription: {
        modules: Meteor.subscribe("userModules"),
        moduleTypes: Meteor.subscribe("userModuleTypes"),
        schemas: Meteor.subscribe("userSchemas"),
        pages: Meteor.subscribe("userPages"),
        user: Meteor.subscribe("user"),
        apps: Meteor.subscribe("userApps")
      },
      navDrawer: false,
      page: FlowRouter.getRouteName(),
      selectApp: false,
      dialog: false,
      editApp: false,
      selectModel: false,
      appForm: false,
      newApp: false
    };
  }

  componentWillMount() {
    nav.on("open-nav-drawer", ()=> {
      var navDrawerState = this.state.navDrawer;
      this.setState({
        "navDrawer": !navDrawerState
      });

    });
  }

  componentWillUnmount() {
    this.state.subscription.modules.stop();
    this.state.subscription.moduleTypes.stop();
    this.state.subscription.schemas.stop();
    this.state.subscription.pages.stop();
    this.state.subscription.user.stop();
    this.state.subscription.apps.stop();
  }

  title() {
    var user = Meteor.users.find().fetch()[0];
    if (user) {
      var app = Apps.find({id:user.selectedApp}).fetch()[0];
      if (app) {
        return app;
      } else {
        return {name:"", subtitle: ""};
      }
    } else {
      return {name:"", subtitle: ""};
    }
  }

  closeNav() {
    this.setState({
      "navDrawer": false
    });
  }

  apps() {
    return Apps.find().fetch();
  }

  pages() {
    return Pages.find().fetch();
  }

  go(route) {
    FlowRouter.go(route);
  }

  open() {
    this.setState({dialog: true});
  }

  selectApp(id) {
    Meteor.call("selectApp", id);
    location.reload();
    // this.close();
  }

  go(route) {
    FlowRouter.go(route);
  }

  module() {
    let id;
    var module = Modules.find().fetch()[0];
    if (module) {
      id = module.id;
    } else {
      id = "";
    }
    return id;
  }

  close() {
    this.setState({dialog:false});
  }

  newApp() {
    this.setState({dialog:false, newApp:true});
  }

  saveNewApp() {
    Meteor.call("newApp", formStore.getData("newApp").name);
    this.cancelNewApp();
  }

  cancelNewApp() {
    this.setState({newApp:false});
  }

  cancelEditApp() {
    this.setState({editApp: false});
  }

  saveEditApp() {
    if (formStore.getData("editApp")) {
      Meteor.call("editApp", formStore.getData("editApp").name);
    }
    this.cancelEditApp();
  }

  deleteApp() {
    Meteor.call("deleteApp");
    this.setState({editApp: false, dialog: true});
  }

  editApp() {
    this.setState({editApp: true});
  }

  update(field) {
    if (field === "model") {
      this.setState({selectModel: true});
    }
  }

  selectModel() {

  }

  cancelSelectModel() {
    this.setState({selectModel: false});
  }

  closeAppForm() {
    this.setState({newApp: false, editApp: false});
  }

  appNameShort() {
    let name = this.title().name;
    let nameSplitted = name.split(" ");
    let short = "";
    for (var i = 0; i < nameSplitted.length; i++) {
      short += nameSplitted[i][0];
    }
    if (short !== "undefined") {
      return short;
    } else {
      return "";
    }
  }

  render() {
    var windowWidth = window.innerWidth;
    const palette = "#3f51b5";
    return (
      <Drawer
        variant={windowWidth > 900 ? "permanent" : "temporary"}
{'fraction_non_alphanumeric': 0.16250266922912662, 'fraction_numerical': 0.0025624599615631004, 'mean_word_length': 2.9893526405451447, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 7, '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': '1340044', 'n_tokens_mistral': 3084, 'n_tokens_neox': 3021, 'n_words': 576}