|
| 1 | +/* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | + * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| 3 | + * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 | + |
| 5 | +const React = require('react') |
| 6 | +const ImmutableComponent = require('../immutableComponent') |
| 7 | + |
| 8 | +const {DefaultSectionTitle} = require('../common/sectionTitle') |
| 9 | +const {SettingsList, SettingItem, SettingCheckbox} = require('../common/settings') |
| 10 | + |
| 11 | +const {SettingDropdown} = require('../common/dropdown') |
| 12 | + |
| 13 | +const {tabCloseAction} = require('../../../common/constants/settingsEnums') |
| 14 | +const {changeSetting} = require('../../lib/settingsUtil') |
| 15 | +const getSetting = require('../../../../js/settings').getSetting |
| 16 | +const settings = require('../../../../js/constants/settings') |
| 17 | + |
| 18 | +class TabsTab extends ImmutableComponent { |
| 19 | + get tabsPerTabPageOption () { |
| 20 | + return [6, 8, 10, 20, 100] |
| 21 | + } |
| 22 | + |
| 23 | + get tabCloseActionOptions () { |
| 24 | + return [ |
| 25 | + { |
| 26 | + id: 'tabCloseActionLastActive', |
| 27 | + action: tabCloseAction.LAST_ACTIVE |
| 28 | + }, |
| 29 | + { |
| 30 | + id: 'tabCloseActionNext', |
| 31 | + action: tabCloseAction.NEXT |
| 32 | + }, |
| 33 | + { |
| 34 | + id: 'tabCloseActionParent', |
| 35 | + action: tabCloseAction.PARENT |
| 36 | + } |
| 37 | + ] |
| 38 | + } |
| 39 | + render () { |
| 40 | + return ( |
| 41 | + <div> |
| 42 | + <DefaultSectionTitle data-l10n-id='tabSettings' /> |
| 43 | + <SettingsList> |
| 44 | + <SettingItem dataL10nId='tabsPerTabPage'> |
| 45 | + <SettingDropdown |
| 46 | + data-test-id='tabsPerTabPage' |
| 47 | + value={getSetting(settings.TABS_PER_PAGE, this.props.settings)} |
| 48 | + data-type='number' |
| 49 | + onChange={changeSetting.bind(null, this.props.onChangeSetting, settings.TABS_PER_PAGE)}> |
| 50 | + {// Sorry, Brad says he hates primes :'( |
| 51 | + this.tabsPerTabPageOption.map(option => |
| 52 | + <option |
| 53 | + data-test-id='tabsPerTabPageOption' |
| 54 | + data-test-active={ |
| 55 | + getSetting(settings.TABS_PER_PAGE, this.props.settings) === option |
| 56 | + } |
| 57 | + value={option} |
| 58 | + key={option}> |
| 59 | + {option} |
| 60 | + </option> |
| 61 | + )} |
| 62 | + </SettingDropdown> |
| 63 | + </SettingItem> |
| 64 | + <SettingItem dataL10nId='tabCloseAction'> |
| 65 | + <SettingDropdown |
| 66 | + value={getSetting(settings.TAB_CLOSE_ACTION, this.props.settings)} |
| 67 | + onChange={changeSetting.bind(null, this.props.onChangeSetting, settings.TAB_CLOSE_ACTION)}> |
| 68 | + {this.tabCloseActionOptions.map(option => |
| 69 | + <option |
| 70 | + data-l10n-id={option.id} |
| 71 | + data-test-id='tabCloseActionActiveOption' |
| 72 | + data-test-active={ |
| 73 | + getSetting(settings.TAB_CLOSE_ACTION, this.props.settings) === option.action |
| 74 | + } |
| 75 | + value={option.action} |
| 76 | + /> |
| 77 | + )} |
| 78 | + </SettingDropdown> |
| 79 | + </SettingItem> |
| 80 | + <SettingCheckbox |
| 81 | + dataL10nId='switchToNewTabs' |
| 82 | + dataTestId='switchToNewTabs' |
| 83 | + testIsEnabled={ |
| 84 | + getSetting(settings.SWITCH_TO_NEW_TABS, this.props.settings) === true |
| 85 | + } |
| 86 | + prefKey={settings.SWITCH_TO_NEW_TABS} |
| 87 | + settings={this.props.settings} |
| 88 | + onChangeSetting={this.props.onChangeSetting} |
| 89 | + /> |
| 90 | + <SettingCheckbox |
| 91 | + dataL10nId='paintTabs' |
| 92 | + dataTestId='paintTabs' |
| 93 | + testIsEnabled={ |
| 94 | + getSetting(settings.PAINT_TABS, this.props.settings) === true |
| 95 | + } |
| 96 | + prefKey={settings.PAINT_TABS} |
| 97 | + settings={this.props.settings} |
| 98 | + onChangeSetting={this.props.onChangeSetting} |
| 99 | + /> |
| 100 | + <SettingCheckbox |
| 101 | + dataL10nId='showTabPreviews' |
| 102 | + dataTestId='showTabPreviews' |
| 103 | + testIsEnabled={ |
| 104 | + getSetting(settings.SHOW_TAB_PREVIEWS, this.props.settings) === true |
| 105 | + } |
| 106 | + prefKey={settings.SHOW_TAB_PREVIEWS} |
| 107 | + settings={this.props.settings} |
| 108 | + onChangeSetting={this.props.onChangeSetting} |
| 109 | + /> |
| 110 | + <SettingItem dataL10nId='dashboardSettingsTitle'> |
| 111 | + <SettingCheckbox |
| 112 | + dataL10nId='dashboardShowImages' |
| 113 | + dataTestId='dashboardShowImages' |
| 114 | + testIsEnabled={ |
| 115 | + getSetting(settings.SHOW_DASHBOARD_IMAGES, this.props.settings) === true |
| 116 | + } |
| 117 | + prefKey={settings.SHOW_DASHBOARD_IMAGES} |
| 118 | + settings={this.props.settings} |
| 119 | + onChangeSetting={this.props.onChangeSetting} |
| 120 | + /> |
| 121 | + </SettingItem> |
| 122 | + </SettingsList> |
| 123 | + </div> |
| 124 | + ) |
| 125 | + } |
| 126 | +} |
| 127 | + |
| 128 | +module.exports = TabsTab |
0 commit comments