<commit_before>import React from 'react';
import pleaseWait from 'please-wait';
import Lifespan from 'lifespan';
import ClassNames from 'classnames';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import Joyride from 'react-joyride';

import LocalClient from '../stores/local-client.stores.jsx';

import Topbar from './topbar/topbar.components.jsx';
import Toolbar from './toolbar/toolbar.components.jsx';
import Workboard from './workboard.components.jsx';
import ExportAs from './export-as.components.jsx';
import Collection from './collection/collection.components.jsx';
import CreateFamilyModal from './familyVariant/create-family-modal.components.jsx';
import CreateVariantModal from './familyVariant/create-variant-modal.components.jsx';
import ChangeNameFamily from './familyVariant/change-name-family.components.jsx';
import ChangeNameVariant from './familyVariant/change-name-variant.components.jsx';
import DuplicateVariant from './familyVariant/duplicate-variant.components.jsx';
import CreditsExport from './credits-export.components.jsx';
//import NpsMessage from './nps-message.components.jsx';

import {buildTutorialSteps, handleNextStep, handleClosed} from '../helpers/joyride.helpers.js';

export default class Dashboard extends React.Component {

	constructor(props) {
		super(props);
		this.state = {
			joyrideSteps: [],
			uiJoyrideTutorialValue: false,
			firstTimeFile: undefined,
			firstTimeCollection: undefined,
			firstTimeIndivCreate: undefined,
			firstTimeIndivEdit: undefined,
		};
		this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);

		// function bindings
		this.joyrideCallback = this.joyrideCallback.bind(this);
	}

	async componentWillMount() {
		pleaseWait.instance.finish();

		this.client = LocalClient.instance();
		this.lifespan = new Lifespan();

		const prototypoStore = await this.client.fetch('/prototypoStore');

		this.setState({
			joyrideSteps: [],
			firstTimeFile: prototypoStore.head.toJS().firstTimeFile,
			firstTimeCollection: prototypoStore.head.toJS().firstTimeCollection,
			firstTimeIndivCreate: prototypoStore.head.toJS().firstTimeIndivCreate,
			firstTimeIndivEdit: prototypoStore.head.toJS().firstTimeIndivEdit,
		});

		this.client.getStore('/prototypoStore', this.lifespan)
			.onUpdate(({head}) => {
				this.setState({
					openFamilyModal: head.toJS().openFamilyModal,
					openVariantModal: head.toJS().openVariantModal,
					familySelectedVariantCreation: head.toJS().familySelectedVariantCreation,
					collectionSelectedVariant: head.toJS().collectionSelectedVariant,
					openChangeFamilyNameModal: head.toJS().openChangeFamilyNameModal,
					openChangeVariantNameModal: head.toJS().openChangeVariantNameModal,
					openDuplicateVariantModal: head.toJS().openDuplicateVariantModal,
					openBuyCreditsModal: head.toJS().openBuyCreditsModal,
					step: head.toJS().uiOnboardstep,
					collection: head.toJS().uiShowCollection,
					indiv: head.toJS().indivMode,
					exportAs: head.toJS().exportAs,
					uiJoyrideTutorialValue: head.toJS().uiJoyrideTutorialValue,
					firstTimeFile: head.toJS().firstTimeFile,
					firstTimeCollection: head.toJS().firstTimeCollection,
					firstTimeIndivCreate: head.toJS().firstTimeIndivCreate,
					firstTimeIndivEdit: head.toJS().firstTimeIndivEdit,
				});
			})
			.onDelete(() => {
				this.setState(undefined);
			});

	}

	componentWillUnmount() {
		this.lifespan.release();
	}

	componentDidUpdate(prevProps, prevState) {
		const joyrideSteps = buildTutorialSteps(prevState, this.state);

		if (joyrideSteps.length) {
			this.addSteps(joyrideSteps);
			this.refs.joyride.start(true);
		}
	}

	/**
	*	adds given steps to the state
	*	@param {array} steps - an array containing joyride steps objects
	*/
	addSteps(steps) {
		const joyride = this.refs.joyride;

		if (!steps.length) {
			return false;
		}

		this.setState((currentState) => {
			if (currentState.joyrideSteps) {
				currentState.joyrideSteps = currentState.joyrideSteps.concat(joyride.parseSteps(steps));
			}
			return currentState;
		});
	}

	addTooltip(data) {
		this.refs.joyride.addTooltip(data);
	}

	joyrideCallback(joyrideEvent) {
		if (joyrideEvent) {
			switch (joyrideEvent.action) {
				case 'next':
					handleNextStep(this, joyrideEvent);
					break;
				case 'close':
					handleClosed(this);
					this.refs.joyride.stop();
					break;
				default:
					break;
			}
		}
	}<commit_msg>fix bug #350<commit_after>import React from 'react';
import pleaseWait from 'please-wait';
import Lifespan from 'lifespan';
import ClassNames from 'classnames';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import Joyride from 'react-joyride';

import LocalClient from '../stores/local-client.stores.jsx';

import Topbar from './topbar/topbar.components.jsx';
import Toolbar from './toolbar/toolbar.components.jsx';
import Workboard from './workboard.components.jsx';
import ExportAs from './export-as.components.jsx';
import Collection from './collection/collection.components.jsx';
import CreateFamilyModal from './familyVariant/create-family-modal.components.jsx';
import CreateVariantModal from './familyVariant/create-variant-modal.components.jsx';
import ChangeNameFamily from './familyVariant/change-name-family.components.jsx';
import ChangeNameVariant from './familyVariant/change-name-variant.components.jsx';
import DuplicateVariant from './familyVariant/duplicate-variant.components.jsx';
import CreditsExport from './credits-export.components.jsx';
//import NpsMessage from './nps-message.components.jsx';

import {buildTutorialSteps, handleNextStep, handleClosed} from '../helpers/joyride.helpers.js';

export default class Dashboard extends React.Component {

	constructor(props) {
		super(props);
		this.state = {
			joyrideSteps: [],
			uiJoyrideTutorialValue: false,
			firstTimeFile: undefined,
			firstTimeCollection: undefined,
			firstTimeIndivCreate: undefined,
			firstTimeIndivEdit: undefined,
		};
		this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);

		// function bindings
		this.joyrideCallback = this.joyrideCallback.bind(this);
	}

	async componentWillMount() {
		pleaseWait.instance.finish();

		this.client = LocalClient.instance();
		this.lifespan = new Lifespan();

		const prototypoStore = await this.client.fetch('/prototypoStore');

		this.setState({
			joyrideSteps: [],
			firstTimeFile: prototypoStore.head.toJS().firstTimeFile,
			firstTimeCollection: prototypoStore.head.toJS().firstTimeCollection,
			firstTimeIndivCreate: prototypoStore.head.toJS().firstTimeIndivCreate,
			firstTimeIndivEdit: prototypoStore.head.toJS().firstTimeIndivEdit,
		});

		this.client.getStore('/prototypoStore', this.lifespan)
			.onUpdate(({head}) => {
				this.setState({
					openFamilyModal: head.toJS().openFamilyModal,
					openVariantModal: head.toJS().openVariantModal,
					familySelectedVariantCreation: head.toJS().familySelectedVariantCreation,
					collectionSelectedVariant: head.toJS().collectionSelectedVariant,
					openChangeFamilyNameModal: head.toJS().openChangeFamilyNameModal,
					openChangeVariantNameModal: head.toJS().openChangeVariantNameModal,
					openDuplicateVariantModal: head.toJS().openDuplicateVariantModal,
					openBuyCreditsModal: head.toJS().openBuyCreditsModal,
					step: head.toJS().uiOnboardstep,
					collection: head.toJS().uiShowCollection,
					indiv: head.toJS().indivMode,
					exportAs: head.toJS().exportAs,
					uiJoyrideTutorialValue: head.toJS().uiJoyrideTutorialValue,
					firstTimeFile: head.toJS().firstTimeFile,
					firstTimeCollection: head.toJS().firstTimeCollection,
					firstTimeIndivCreate: head.toJS().firstTimeIndivCreate,
					firstTimeIndivEdit: head.toJS().firstTimeIndivEdit,
				});
			})
			.onDelete(() => {
				this.setState(undefined);
			});

	}

	componentWillUnmount() {
		this.lifespan.release();
	}

	componentDidUpdate(prevProps, prevState) {
		const joyrideSteps = buildTutorialSteps(prevState, this.state);

		if (joyrideSteps.length) {
			this.addSteps(joyrideSteps);
			this.refs.joyride.start(true);
		}
	}

	/**
	*	adds given steps to the state
	*	@param {array} steps - an array containing joyride steps objects
	*/
	addSteps(steps) {
		const joyride = this.refs.joyride;

		if (!steps.length) {
			return false;
		}

		this.setState((currentState) => {
			if (currentState.joyrideSteps) {
				currentState.joyrideSteps = currentState.joyrideSteps.concat(joyride.parseSteps(steps));
			}
			return currentState;
		});
	}

	addTooltip(data) {
		this.refs.joyride.addTooltip(data);
	}

	joyrideCallback(joyrideEvent) {
		if (joyrideEvent) {
			switch (joyrideEvent.action) {
				case 'next':
					handleNextStep(this, joyrideEvent);
					break;
				case 'close':
					handleClosed(this);
					this.refs.joyride.stop();
					break;
				case 'esc':
					handleClosed(this);
					this.refs.joyride.stop();
					break;
				default:
					break;
			}
		}
	}
{'fraction_non_alphanumeric': 0.12253443526170799, 'fraction_numerical': 0.00033057851239669424, 'mean_word_length': 4.693851944792974, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7383540', 'n_tokens_mistral': 3263, 'n_tokens_neox': 2790, 'n_words': 477}