tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WelcomeBox.js (3874B)


      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
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 import { Component } from "devtools/client/shared/vendor/react";
      6 import {
      7  div,
      8  p,
      9  span,
     10 } from "devtools/client/shared/vendor/react-dom-factories";
     11 import PropTypes from "devtools/client/shared/vendor/react-prop-types";
     12 
     13 import { connect } from "devtools/client/shared/vendor/react-redux";
     14 import { primaryPaneTabs } from "../constants";
     15 
     16 import actions from "../actions/index";
     17 import { getPaneCollapse } from "../selectors/index";
     18 const {
     19  stringifyFromElectronKey,
     20 } = require("resource://devtools/client/shared/key-shortcuts.js");
     21 
     22 export class WelcomeBox extends Component {
     23  static get propTypes() {
     24    return {
     25      openQuickOpen: PropTypes.func.isRequired,
     26      setActiveSearch: PropTypes.func.isRequired,
     27      toggleShortcutsModal: PropTypes.func.isRequired,
     28      setPrimaryPaneTab: PropTypes.func.isRequired,
     29    };
     30  }
     31 
     32  render() {
     33    const searchSourcesShortcut = stringifyFromElectronKey(
     34      L10N.getStr("sources.search.key2")
     35    );
     36 
     37    const searchProjectShortcut = stringifyFromElectronKey(
     38      L10N.getStr("projectTextSearch.key")
     39    );
     40 
     41    const allShortcutsShortcut = stringifyFromElectronKey(
     42      L10N.getStr("allShortcut.key")
     43    );
     44 
     45    const allShortcutsLabel = L10N.getStr("welcome.allShortcuts");
     46    const searchSourcesLabel = L10N.getStr("welcome.search2").substring(2);
     47    const searchProjectLabel = L10N.getStr("welcome.findInFiles2").substring(2);
     48 
     49    return div(
     50      {
     51        className: "welcomebox",
     52      },
     53      div(
     54        {
     55          className: "alignlabel",
     56        },
     57        div(
     58          {
     59            className: "shortcutFunction",
     60          },
     61          p(
     62            {
     63              className: "welcomebox__searchSources",
     64              role: "button",
     65              tabIndex: "0",
     66              onClick: () => this.props.openQuickOpen(),
     67            },
     68            span(
     69              {
     70                className: "shortcutKey",
     71              },
     72              searchSourcesShortcut
     73            ),
     74            span(
     75              {
     76                className: "shortcutLabel",
     77              },
     78              searchSourcesLabel
     79            )
     80          ),
     81          p(
     82            {
     83              className: "welcomebox__searchProject",
     84              role: "button",
     85              tabIndex: "0",
     86              onClick: () => {
     87                this.props.setActiveSearch(primaryPaneTabs.PROJECT_SEARCH);
     88                this.props.setPrimaryPaneTab(primaryPaneTabs.PROJECT_SEARCH);
     89              },
     90            },
     91            span(
     92              {
     93                className: "shortcutKey",
     94              },
     95              searchProjectShortcut
     96            ),
     97            span(
     98              {
     99                className: "shortcutLabel",
    100              },
    101              searchProjectLabel
    102            )
    103          ),
    104          p(
    105            {
    106              className: "welcomebox__allShortcuts",
    107              role: "button",
    108              tabIndex: "0",
    109              onClick: () => this.props.toggleShortcutsModal(),
    110            },
    111            span(
    112              {
    113                className: "shortcutKey",
    114              },
    115              allShortcutsShortcut
    116            ),
    117            span(
    118              {
    119                className: "shortcutLabel",
    120              },
    121              allShortcutsLabel
    122            )
    123          )
    124        )
    125      )
    126    );
    127  }
    128 }
    129 
    130 const mapStateToProps = state => ({
    131  endPanelCollapsed: getPaneCollapse(state, "end"),
    132 });
    133 
    134 export default connect(mapStateToProps, {
    135  togglePaneCollapse: actions.togglePaneCollapse,
    136  setActiveSearch: actions.setActiveSearch,
    137  openQuickOpen: actions.openQuickOpen,
    138  setPrimaryPaneTab: actions.setPrimaryPaneTab,
    139 })(WelcomeBox);