tor-browser

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

CompatibilityWarning.js (3292B)


      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 "use strict";
      6 
      7 const {
      8  createFactory,
      9  PureComponent,
     10 } = require("resource://devtools/client/shared/vendor/react.mjs");
     11 const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js");
     12 
     13 const FluentReact = require("resource://devtools/client/shared/vendor/fluent-react.js");
     14 const Localized = createFactory(FluentReact.Localized);
     15 
     16 const Message = createFactory(
     17  require("resource://devtools/client/aboutdebugging/src/components/shared/Message.js")
     18 );
     19 
     20 const {
     21  MESSAGE_LEVEL,
     22 } = require("resource://devtools/client/aboutdebugging/src/constants.js");
     23 const {
     24  COMPATIBILITY_STATUS,
     25 } = require("resource://devtools/client/shared/remote-debugging/version-checker.js");
     26 
     27 const TROUBLESHOOTING_URL =
     28  "https://firefox-source-docs.mozilla.org/devtools-user/about_colon_debugging/";
     29 const FENNEC_TROUBLESHOOTING_URL =
     30  "https://firefox-source-docs.mozilla.org/devtools-user/about_colon_debugging/index.html#connection-to-firefox-for-android-68";
     31 
     32 const Types = require("resource://devtools/client/aboutdebugging/src/types/index.js");
     33 
     34 class CompatibilityWarning extends PureComponent {
     35  static get propTypes() {
     36    return {
     37      compatibilityReport: Types.compatibilityReport.isRequired,
     38    };
     39  }
     40 
     41  render() {
     42    const {
     43      localID,
     44      localVersion,
     45      minVersion,
     46      runtimeID,
     47      runtimeVersion,
     48      status,
     49    } = this.props.compatibilityReport;
     50 
     51    if (status === COMPATIBILITY_STATUS.COMPATIBLE) {
     52      return null;
     53    }
     54 
     55    let localizationId, statusClassName;
     56    switch (status) {
     57      case COMPATIBILITY_STATUS.TOO_OLD:
     58        statusClassName = "qa-compatibility-warning-too-old";
     59        localizationId = "about-debugging-browser-version-too-old";
     60        break;
     61      case COMPATIBILITY_STATUS.TOO_RECENT:
     62        statusClassName = "qa-compatibility-warning-too-recent";
     63        localizationId = "about-debugging-browser-version-too-recent";
     64        break;
     65      case COMPATIBILITY_STATUS.TOO_OLD_FENNEC:
     66        statusClassName = "qa-compatibility-warning-too-old-fennec";
     67        localizationId = "about-debugging-browser-version-too-old-fennec";
     68        break;
     69    }
     70 
     71    const troubleshootingUrl =
     72      status === COMPATIBILITY_STATUS.TOO_OLD_FENNEC
     73        ? FENNEC_TROUBLESHOOTING_URL
     74        : TROUBLESHOOTING_URL;
     75 
     76    const messageLevel =
     77      status === COMPATIBILITY_STATUS.TOO_OLD_FENNEC
     78        ? MESSAGE_LEVEL.ERROR
     79        : MESSAGE_LEVEL.WARNING;
     80 
     81    return Message(
     82      {
     83        level: messageLevel,
     84        isCloseable: true,
     85      },
     86      Localized(
     87        {
     88          id: localizationId,
     89          a: dom.a({
     90            href: troubleshootingUrl,
     91            target: "_blank",
     92          }),
     93          $localID: localID,
     94          $localVersion: localVersion,
     95          $minVersion: minVersion,
     96          $runtimeID: runtimeID,
     97          $runtimeVersion: runtimeVersion,
     98        },
     99        dom.p(
    100          {
    101            className: `qa-compatibility-warning ${statusClassName}`,
    102          },
    103          localizationId
    104        )
    105      )
    106    );
    107  }
    108 }
    109 
    110 module.exports = CompatibilityWarning;