Commit d8bdffca authored by Mike Conley's avatar Mike Conley
Browse files

Bug 1700198 - Remove most subviewbutton-iconic class usage from FxA panel. r=markh

This also removes code that handled the case where a Send Tab or Send Link to Device
menu needed to be populated when in the STATUS_NOT_CONFIGURED state. Since those menus
should be unavailable when in the STATUS_NOT_CONFIGURED state, we throw instead.

Depends on D118622

Differential Revision: https://phabricator.services.mozilla.com/D118623
parent fe2f862a
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -769,7 +769,7 @@
      </toolbarbutton>
      <toolbarbutton id="PanelUI-fxa-menu-syncnow-button"
                     align="center"
                     class="subviewbutton subviewbutton-iconic"
                     class="subviewbutton"
                     oncommand="gSync.doSyncFromFxaMenu(this);"
                     onmouseover="gSync.refreshSyncButtonsTooltip();"
                     closemenu="none">
@@ -784,27 +784,27 @@
        </hbox>
      </toolbarbutton>
      <toolbarbutton id="PanelUI-fxa-menu-setup-sync-button"
                      class="subviewbutton subviewbutton-iconic"
                      class="subviewbutton"
                      data-l10n-id="appmenu-fxa-setup-sync"
                      oncommand="gSync.openPrefsFromFxaMenu('sync_settings', this);"/>
      <!-- The `Connect Another Device` button is disabled by default until the user logs into Sync. -->
      <toolbarbutton id="PanelUI-fxa-menu-connect-device-button"
                      class="subviewbutton subviewbutton-iconic"
                      class="subviewbutton"
                      data-l10n-id="fxa-menu-connect-another-device"
                      disabled="true"
                      oncommand="gSync.openConnectAnotherDeviceFromFxaMenu(this);"/>
      <toolbarbutton id="PanelUI-fxa-menu-sendtab-button"
                      class="subviewbutton subviewbutton-nav subviewbutton-iconic"
                      class="subviewbutton subviewbutton-nav"
                      closemenu="none"
                      oncommand="gSync.showSendToDeviceViewFromFxaMenu(this);"/>
      <toolbarbutton id="PanelUI-fxa-menu-sync-prefs-button"
                      class="subviewbutton subviewbutton-iconic"
                      class="subviewbutton"
                      data-l10n-id="fxa-menu-sync-settings"
                      hidden="true"
                      oncommand="gSync.openPrefsFromFxaMenu('sync_settings', this);"/>
      <toolbarseparator id="PanelUI-sign-out-separator"/>
      <toolbarbutton id="PanelUI-fxa-menu-account-signout-button"
              class="subviewbutton subviewbutton-iconic"
              class="subviewbutton"
              data-l10n-id="fxa-menu-sign-out"
              oncommand="gSync.disconnect();"/>
      <toolbarseparator id="PanelUI-remote-tabs-separator"/>
+11 −52
Original line number Diff line number Diff line
@@ -878,7 +878,6 @@ var gSync = {
      document,
      "PanelUI-fxa-menu-syncnow-button"
    );
    const fxaMenuPanel = PanelMultiView.getViewNode(document, "PanelUI-fxa");

    const fxaMenuAccountButtonEl = PanelMultiView.getViewNode(
      document,
@@ -890,13 +889,6 @@ var gSync = {
      "fxa-menu-turn-on-sync-default"
    );

    if (PanelUI.protonAppMenuEnabled) {
      let toolbarbuttons = fxaMenuPanel.querySelectorAll("toolbarbutton");
      for (let toolbarbutton of toolbarbuttons) {
        toolbarbutton.classList.remove("subviewbutton-iconic");
      }
    }

    cadButtonEl.setAttribute("disabled", true);
    syncNowButtonEl.hidden = true;
    fxaMenuAccountButtonEl.classList.remove("subviewbutton-nav");
@@ -1122,12 +1114,8 @@ var gSync = {
    }

    // At this point we consider sync to be logged-in.
    if (PanelUI.protonAppMenuEnabled) {
    appMenuHeaderTitle.hidden = true;
    appMenuHeaderDescription.value = state.email;
    } else {
      appMenuLabel.classList.add("subviewbutton-iconic");
    }
    appMenuStatus.setAttribute("fxastatus", "signedin");
    appMenuLabel.setAttribute("label", state.email);
    appMenuLabel.classList.add("subviewbutton-nav");
@@ -1391,8 +1379,15 @@ var gSync = {
      state.status == UIState.STATUS_LOGIN_FAILED
    ) {
      this._appendSendTabVerify(fragment, createDeviceNodeFn);
    } /* status is STATUS_NOT_CONFIGURED */ else {
      this._appendSendTabUnconfigured(fragment, createDeviceNodeFn);
    } else {
      // The only status not handled yet is STATUS_NOT_CONFIGURED, and
      // when we're in that state, none of the menus that call
      // populateSendTabToDevicesMenu are available, so entering this
      // state is unexpected.
      throw new Error(
        "Called populateSendTabToDevicesMenu when in STATUS_NOT_CONFIGURED " +
          "state."
      );
    }

    devicesPopup.appendChild(fragment);
@@ -1558,42 +1553,6 @@ var gSync = {
    );
  },

  _appendSendTabUnconfigured(fragment, createDeviceNodeFn) {
    const brandProductName = gBrandBundle.GetStringFromName("brandProductName");
    const notConnected = this.fxaStrings.GetStringFromName(
      "sendTabToDevice.unconfigured.label2"
    );
    const learnMore = this.fxaStrings.GetStringFromName(
      "sendTabToDevice.unconfigured"
    );
    const actions = [
      { label: learnMore, command: () => this.openSendToDevicePromo() },
    ];
    this._appendSendTabInfoItems(
      fragment,
      createDeviceNodeFn,
      notConnected,
      actions
    );

    // Now add a 'sign in to Firefox' item above the 'learn more' item.
    const signInToFxA = this.fxaStrings.formatStringFromName(
      "sendTabToDevice.signintofxa",
      [brandProductName]
    );
    let signInItem = createDeviceNodeFn(null, signInToFxA, null);
    signInItem.classList.add("sync-menuitem");
    signInItem.setAttribute("label", signInToFxA);
    // Show an icon if opened in the page action panel:
    if (signInItem.classList.contains("subviewbutton")) {
      signInItem.classList.add("subviewbutton-iconic", "signintosync");
    }
    signInItem.addEventListener("command", () => {
      this.openPrefs("sendtab");
    });
    fragment.insertBefore(signInItem, fragment.lastElementChild);
  },

  _appendSendTabInfoItems(fragment, createDeviceNodeFn, statusLabel, actions) {
    const status = createDeviceNodeFn(null, statusLabel, null);
    status.setAttribute("label", statusLabel);