tor-browser

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

RegistrationList.js (2583B)


      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  openTrustedLink,
      9 } = require("resource://devtools/client/shared/link.js");
     10 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs");
     11 const {
     12  createFactory,
     13  PureComponent,
     14 } = require("resource://devtools/client/shared/vendor/react.mjs");
     15 const {
     16  a,
     17  article,
     18  footer,
     19  h1,
     20  p,
     21  ul,
     22 } = require("resource://devtools/client/shared/vendor/react-dom-factories.js");
     23 
     24 const FluentReact = require("resource://devtools/client/shared/vendor/fluent-react.js");
     25 const Localized = createFactory(FluentReact.Localized);
     26 
     27 const Types = require("resource://devtools/client/application/src/types/index.js");
     28 const Registration = createFactory(
     29  require("resource://devtools/client/application/src/components/service-workers/Registration.js")
     30 );
     31 
     32 /**
     33 * This component handles the list of service workers displayed in the application panel
     34 * and also displays a suggestion to use about debugging for debugging other service
     35 * workers.
     36 */
     37 class RegistrationList extends PureComponent {
     38  static get propTypes() {
     39    return {
     40      canDebugWorkers: PropTypes.bool.isRequired,
     41      registrations: Types.registrationArray.isRequired,
     42    };
     43  }
     44 
     45  render() {
     46    const { canDebugWorkers, registrations } = this.props;
     47 
     48    return [
     49      article(
     50        {
     51          className: "registrations-container",
     52          key: "registrations-container",
     53        },
     54        Localized(
     55          { id: "serviceworker-list-header" },
     56          h1({
     57            className: "app-page__title",
     58          })
     59        ),
     60        ul(
     61          { className: "registrations-container__list" },
     62          registrations.map(registration =>
     63            Registration({
     64              key: registration.id,
     65              isDebugEnabled: canDebugWorkers,
     66              registration,
     67              className: "registrations-container__item",
     68            })
     69          )
     70        )
     71      ),
     72 
     73      footer(
     74        { className: "aboutdebugging-plug" },
     75        Localized(
     76          {
     77            id: "serviceworker-list-aboutdebugging",
     78            key: "serviceworkerlist-footer",
     79            a: a({
     80              className: "aboutdebugging-plug__link",
     81              onClick: () => openTrustedLink("about:debugging#workers"),
     82            }),
     83          },
     84          p({})
     85        )
     86      ),
     87    ];
     88  }
     89 }
     90 
     91 // Exports
     92 module.exports = RegistrationList;