<commit_before>'use strict';

import * as Rx from 'rx';
import * as React from 'react';

import { Navbar, Nav, NavItem, NavDropdown, NavDropdownProps, MenuItem, Button } from 'react-bootstrap';
import { Image } from 'react-bootstrap';

import { BaseView, IBaseViewProps } from '../../React/BaseView';
import SearchView from '../Search/SearchView';
import Icon from '../Icon/Icon';

import PageHeaderViewModel from './PageHeaderViewModel';
import { IMenuItem } from './Actions'

import './PageHeader.less';

interface IPageHeaderProps extends IBaseViewProps {
  brand?: any;
}

export class PageHeaderView extends BaseView<IPageHeaderProps, PageHeaderViewModel> {
  public static displayName = 'PageHeaderView';

  static defaultProps = {
    brand: 'WebRx.React Rocks!!!'
  }

  updateOn() {
    return [
      this.state.appSwitcherMenuItems.listChanged,
      this.state.appMenus.listChanged,
      this.state.appActions.listChanged,
      this.state.helpMenuItems.listChanged,
      this.state.adminMenuItems.listChanged,
      this.state.userMenuItems.listChanged,
    ]
  }

  private isMenuItemDisabled(item: IMenuItem) {
    let isDisabled = true;

    if (item.command == null && String.isNullOrEmpty(item.uri) === false) {
      isDisabled = false;
    } else if (item.command != null && item.command.canExecute(null) === true) {
      isDisabled = false;
    }

    return isDisabled;
  }

  private createMenu(items: wx.IObservableList<IMenuItem> | IMenuItem[], icon: any, propsCreator: () => NavDropdownProps, defaultValue?: any) {
    let length = items == null ? null : items.length;
    if (length instanceof Function) {
      length = (length as wx.IObservableProperty<number>)();
    }
    let title = (
      <div className='PageHeader-menuTitle'>
        {icon}
      </div>
    );
    return length == null || length === 0 ? defaultValue : (
      <NavDropdown title={title} {...propsCreator()}>
        {
          items.map(x => {
            let icon = <Icon name={x.iconName} fixedWidth />;
            return (<commit_msg>hide menu icons in page header when the icon name is null or empty<commit_after>'use strict';

import * as Rx from 'rx';
import * as React from 'react';

import { Navbar, Nav, NavItem, NavDropdown, NavDropdownProps, MenuItem, Button } from 'react-bootstrap';
import { Image } from 'react-bootstrap';

import { BaseView, IBaseViewProps } from '../../React/BaseView';
import SearchView from '../Search/SearchView';
import Icon from '../Icon/Icon';

import PageHeaderViewModel from './PageHeaderViewModel';
import { IMenuItem } from './Actions'

import './PageHeader.less';

interface IPageHeaderProps extends IBaseViewProps {
  brand?: any;
}

export class PageHeaderView extends BaseView<IPageHeaderProps, PageHeaderViewModel> {
  public static displayName = 'PageHeaderView';

  static defaultProps = {
    brand: 'WebRx.React Rocks!!!'
  }

  updateOn() {
    return [
      this.state.appSwitcherMenuItems.listChanged,
      this.state.appMenus.listChanged,
      this.state.appActions.listChanged,
      this.state.helpMenuItems.listChanged,
      this.state.adminMenuItems.listChanged,
      this.state.userMenuItems.listChanged,
    ]
  }

  private isMenuItemDisabled(item: IMenuItem) {
    let isDisabled = true;

    if (item.command == null && String.isNullOrEmpty(item.uri) === false) {
      isDisabled = false;
    } else if (item.command != null && item.command.canExecute(null) === true) {
      isDisabled = false;
    }

    return isDisabled;
  }

  private createMenu(items: wx.IObservableList<IMenuItem> | IMenuItem[], icon: any, propsCreator: () => NavDropdownProps, defaultValue?: any) {
    let length = items == null ? null : items.length;
    if (length instanceof Function) {
      length = (length as wx.IObservableProperty<number>)();
    }
    let title = (
      <div className='PageHeader-menuTitle'>
        {icon}
      </div>
    );
    return length == null || length === 0 ? defaultValue : (
      <NavDropdown title={title} {...propsCreator()}>
        {
          items.map(x => {
            let icon = <Icon name={x.iconName} fixedWidth hidden={String.isNullOrEmpty(x.iconName)} />;
            return (
{'fraction_non_alphanumeric': 0.1291477679637145, 'fraction_numerical': 0.00047744091668656003, 'mean_word_length': 3.31513903192585, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '6955066', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1240, 'n_words': 308}