<commit_before>import React, {PropTypes} from 'react'
import {withRouter} from 'react-router'

import AutoRefreshDropdown from 'shared/components/AutoRefreshDropdown'
import TimeRangeDropdown from 'shared/components/TimeRangeDropdown'
import SourceIndicator from 'shared/components/SourceIndicator'
import GraphTips from 'shared/components/GraphTips'

const {func, number, shape, string} = PropTypes

const Header = ({
  timeRange,
  autoRefresh,
  showWriteForm,
  onManualRefresh,
  onChooseTimeRange,
  onChooseAutoRefresh,
}) =>
  <div className="page-header full-width">
    <div className="page-header__container">
      <div className="page-header__left">
        <h1 className="page-header__title">Data Explorer</h1>
      </div>
      <div className="page-header__right">
        <GraphTips />
        <SourceIndicator />
        <div
          className="btn btn-sm btn-default"
          onClick={showWriteForm}
          data-test="write-data-button"
        >
          <span className="icon pencil" />
          Write Data
        </div>
        <AutoRefreshDropdown
          iconName="refresh"
          selected={autoRefresh}
          onChoose={onChooseAutoRefresh}
          onManualRefresh={onManualRefresh}
        />
        <TimeRangeDropdown
          selected={timeRange}
          page="DataExplorer"
          onChooseTimeRange={onChooseTimeRange}
        />
      </div>
    </div>
  </div>

Header.propTypes = {
  onChooseAutoRefresh: func.isRequired,
  onChooseTimeRange: func.isRequired,
  onManualRefresh: func.isRequired,
  autoRefresh: number.isRequired,
  showWriteForm: func.isRequired,
  timeRange: shape({
    lower: string,
    upper: string,
  }).isRequired,
}

export default withRouter(Header)
<commit_msg>Render Write Data button based on user authorization<commit_after>import React, {PropTypes} from 'react'
import {withRouter} from 'react-router'

import Authorized, {EDITOR_ROLE} from 'src/auth/Authorized'

import AutoRefreshDropdown from 'shared/components/AutoRefreshDropdown'
import TimeRangeDropdown from 'shared/components/TimeRangeDropdown'
import SourceIndicator from 'shared/components/SourceIndicator'
import GraphTips from 'shared/components/GraphTips'

const {func, number, shape, string} = PropTypes

const Header = ({
  timeRange,
  autoRefresh,
  showWriteForm,
  onManualRefresh,
  onChooseTimeRange,
  onChooseAutoRefresh,
}) =>
  <div className="page-header full-width">
    <div className="page-header__container">
      <div className="page-header__left">
        <h1 className="page-header__title">Data Explorer</h1>
      </div>
      <div className="page-header__right">
        <GraphTips />
        <SourceIndicator />
        <Authorized requiredRole={EDITOR_ROLE}>
          <div
            className="btn btn-sm btn-default"
            onClick={showWriteForm}
            data-test="write-data-button"
          >
            <span className="icon pencil" />
            Write Data
          </div>
        </Authorized>
        <AutoRefreshDropdown
          iconName="refresh"
          selected={autoRefresh}
          onChoose={onChooseAutoRefresh}
          onManualRefresh={onManualRefresh}
        />
        <TimeRangeDropdown
          selected={timeRange}
          page="DataExplorer"
          onChooseTimeRange={onChooseTimeRange}
        />
      </div>
    </div>
  </div>

Header.propTypes = {
  onChooseAutoRefresh: func.isRequired,
  onChooseTimeRange: func.isRequired,
  onManualRefresh: func.isRequired,
  autoRefresh: number.isRequired,
  showWriteForm: func.isRequired,
  timeRange: shape({
    lower: string,
    upper: string,
  }).isRequired,
}

export default withRouter(Header)

{'fraction_non_alphanumeric': 0.1040195545898968, 'fraction_numerical': 0.0010863661053775121, 'mean_word_length': 3.0741150442477876, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 41, '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': '7047176', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1055, 'n_words': 213}