<commit_before>/**
 *
 * @license
 * Copyright (C) 2016-2017 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @author <NAME>
 * @created 2016-10-18
 * @file header.ts
 * @description Reducers for header actions
 */
'use strict';

// Imports
import * as Actions from '../actionTypes';
import { Name, TabSet } from '../../typings/global';
const CoreTranslations = require('../../assets/json/CoreTranslations');

/** Header reducer state. */
export interface State {
  title: Name | string;           // Title for the current screen
  tabTitles: TabSet<Name|string>; // Title last set in the tab
  showBack: boolean;              // True to show a back button in the header, false to hide
  tabShowBack: TabSet<boolean>;   // Whether the tab should show a back button
  showSearch: boolean;            // True to show a search field in the header, false to hide
  tabShowSearch: TabSet<boolean>; // Whether the tab should show a search button
}

/** Default title to use for the header. */
const defaultTitle = {
  name_en: CoreTranslations && CoreTranslations.en ? CoreTranslations.en.app_name : 'Campus Guide',
  name_fr: CoreTranslations && CoreTranslations.fr ? CoreTranslations.fr.app_name : 'Guide de campus',
};

/** Initial header state. */
const initialState: State = {
  showBack: false,
  showSearch: true,
  tabShowBack: {
    discover: false,
    find: false,
    schedule: false,
    search: false,
    settings: false,
  },
  tabShowSearch: {
    discover: false,
    find: true,
    schedule: false,
    search: true,
    settings: false,
  },
  tabTitles: {
    discover: {
      name_en: CoreTranslations && CoreTranslations.en ? CoreTranslations.en.discover : 'Campus Guide',
      name_fr: CoreTranslations && CoreTranslations.fr ? CoreTranslations.fr.discover : 'Guide de campus',
    },
    find: {
      name_en: CoreTranslations && CoreTranslations.en ? CoreTranslations.en.find : 'Campus Guide',
      name_fr: CoreTranslations && CoreTranslations.fr ? CoreTranslations.fr.find : 'Guide de campus',
    },
    schedule: {
      name_en: CoreTranslations && CoreTranslations.en ? CoreTranslations.en.schedule : 'Campus Guide',
      name_fr: CoreTranslations && CoreTranslations.fr ? CoreTranslations.fr.schedule : 'Guide de campus',
    },
    search: {
      name_en: CoreTranslations && CoreTranslations.en ? CoreTranslations.en.search : 'Campus Guide',
      name_fr: CoreTranslations && CoreTranslations.fr ? CoreTranslations.fr.search : 'Guide de campus',
    },
    settings: {
      name_en: CoreTranslations && CoreTranslations.en ? CoreTranslations.en.settings : 'Campus Guide',
      name_fr: CoreTranslations && CoreTranslations.fr ? CoreTranslations.fr.settings : 'Guide de campus',
    },
  },
  title: defaultTitle,
};

/**
 * When provided with a header action, parses the parameters and returns an updated state.
 *
 * @param {State} state  the current state
 * @param {any}   action the action being taken
 * @returns {State} an updated state based on the previous state and the action taken
 */
export default function header(state: State = initialState, action: any): State {
  switch (action.type) {<commit_msg>Use app name for main tab title<commit_after>/**
 *
 * @license
 * Copyright (C) 2016-2017 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @author <NAME>
 * @created 2016-10-18
 * @file header.ts
 * @description Reducers for header actions
 */
'use strict';

// Imports
import * as Actions from '../actionTypes';
import { Name, TabSet } from '../../typings/global';
const CoreTranslations = require('../../assets/json/CoreTranslations');

/** Header reducer state. */
export interface State {
  title: Name | string;           // Title for the current screen
  tabTitles: TabSet<Name|string>; // Title last set in the tab
  showBack: boolean;              // True to show a back button in the header, false to hide
  tabShowBack: TabSet<boolean>;   // Whether the tab should show a back button
  showSearch: boolean;            // True to show a search field in the header, false to hide
  tabShowSearch: TabSet<boolean>; // Whether the tab should show a search button
}

/** Default title to use for the header. */
const defaultTitle = {
  name_en: CoreTranslations && CoreTranslations.en ? CoreTranslations.en.app_name : 'Campus Guide',
  name_fr: CoreTranslations && CoreTranslations.fr ? CoreTranslations.fr.app_name : 'Guide de campus',
};

/** Initial header state. */
const initialState: State = {
  showBack: false,
  showSearch: true,
  tabShowBack: {
    discover: false,
    find: false,
    schedule: false,
    search: false,
    settings: false,
  },
  tabShowSearch: {
    discover: false,
    find: true,
    schedule: false,
    search: true,
    settings: false,
  },
  tabTitles: {
    discover: {
      name_en: CoreTranslations && CoreTranslations.en ? CoreTranslations.en.discover : 'Campus Guide',
      name_fr: CoreTranslations && CoreTranslations.fr ? CoreTranslations.fr.discover : 'Guide de campus',
    },
    find: defaultTitle,
    schedule: {
      name_en: CoreTranslations && CoreTranslations.en ? CoreTranslations.en.schedule : 'Campus Guide',
      name_fr: CoreTranslations && CoreTranslations.fr ? CoreTranslations.fr.schedule : 'Guide de campus',
    },
    search: {
      name_en: CoreTranslations && CoreTranslations.en ? CoreTranslations.en.search : 'Campus Guide',
      name_fr: CoreTranslations && CoreTranslations.fr ? CoreTranslations.fr.search : 'Guide de campus',
    },
    settings: {
      name_en: CoreTranslations && CoreTranslations.en ? CoreTranslations.en.settings : 'Campus Guide',
      name_fr: CoreTranslations && CoreTranslations.fr ? CoreTranslations.fr.settings : 'Guide de campus',
    },
  },
  title: defaultTitle,
};

/**
 * When provided with a header action, parses the parameters and returns an updated state.
 *
 * @param {State} state  the current state
 * @param {any}   action the action being taken
 * @returns {State} an updated state based on the previous state and the action taken
 */
export default function header(state: State = initialState, action: any): State {
  switch (action.type) {
{'fraction_non_alphanumeric': 0.10611561016475844, 'fraction_numerical': 0.005585032113934655, 'mean_word_length': 3.4965473948524797, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6237526', 'n_tokens_mistral': 2109, 'n_tokens_neox': 2075, 'n_words': 714}