Bug 1617786 - Hide part of calendar UI when all calendars are disabled. r=darktrojan
authorPaul Morris <paul@thunderbird.net>
Thu, 20 Feb 2020 15:11:28 -0500
changeset 37461 46b1f5963bc766e3ce036c5a17374fa94039db25
parent 37460 77c269c63ddcf34fa4260cc4992433bd9b6a3817
child 37462 ec89a721f9f9f4d7b2c9a1491364bcbd371ff512
push id2566
push userclokep@gmail.com
push dateMon, 09 Mar 2020 19:20:31 +0000
treeherdercomm-beta@a352facfa0a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdarktrojan
bugs1617786
Bug 1617786 - Hide part of calendar UI when all calendars are disabled. r=darktrojan
calendar/base/content/calendar-chrome-startup.js
calendar/base/modules/calCalendarDeactivator.jsm
calendar/base/modules/moz.build
calendar/base/themes/common/lightning.css
calendar/lightning/content/calendar-menu-events-tasks.inc.xhtml
calendar/lightning/content/calendar-status-bar.inc.xhtml
calendar/lightning/content/calendar-today-pane.inc.xhtml
calendar/lightning/content/calendar-view-menu.inc.xhtml
mail/base/content/mainNavigationToolbox.inc.xhtml
mail/base/content/mainPopupSet.inc.xhtml
mail/components/customizableui/content/panelUI.inc.xhtml
--- a/calendar/base/content/calendar-chrome-startup.js
+++ b/calendar/base/content/calendar-chrome-startup.js
@@ -6,16 +6,19 @@
 /* import-globals-from calendar-command-controller.js */
 /* import-globals-from calendar-management.js */
 /* import-globals-from calendar-ui-utils.js */
 /* import-globals-from calendar-views-utils.js */
 /* globals PanelUI */
 
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
+var { calendarDeactivator } = ChromeUtils.import(
+  "resource:///modules/calendar/calCalendarDeactivator.jsm"
+);
 
 /* exported commonInitCalendar, commonFinishCalendar */
 
 /**
  * Common initialization steps for calendar chrome windows.
  */
 async function commonInitCalendar() {
   // load locale specific default values for preferences
@@ -34,16 +37,19 @@ async function commonInitCalendar() {
   injectCalendarCommandController();
 
   // Set up calendar appmenu buttons.
   setUpCalendarAppMenuButtons();
 
   // Set up calendar menu items in the appmenu.
   setUpCalendarAppMenuItems();
 
+  // Set up calendar deactivation for this window.
+  calendarDeactivator.registerWindow(window);
+
   // Set up item and day selection listeners
   getViewDeck().addEventListener("dayselect", observeViewDaySelect);
   getViewDeck().addEventListener("itemselect", calendarController.onSelectionChanged, true);
 
   // Start alarm service
   Cc["@mozilla.org/calendar/alarm-service;1"].getService(Ci.calIAlarmService).startup();
   document.getElementById("calsidebar_splitter").addEventListener("command", () => {
     document.dispatchEvent(new CustomEvent("viewresize", { bubbles: true }));
new file mode 100644
--- /dev/null
+++ b/calendar/base/modules/calCalendarDeactivator.jsm
@@ -0,0 +1,126 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
+
+this.EXPORTED_SYMBOLS = ["calendarDeactivator"];
+
+/**
+ * Handles deactivation of calendar UI and background processes/services (such
+ * as the alarms service) when users do not want to use calendar functionality.
+ * Also handles re-activation when users change their mind.
+ *
+ * If all of a user's calendars are disabled (e.g. calendar > properties >
+ * "turn this calendar on") then full calendar functionality is deactivated.
+ * If one or more calendars are enabled then full calendar functionality is
+ * activated.
+ *
+ * Note we use "disabled"/"enabled" for a user's individual calendars and
+ * "deactivated"/"activated" for the calendar component as a whole.
+ *
+ * @implements {calICalendarManagerObserver}
+ * @implements {calIObserver}
+ */
+var calendarDeactivator = {
+  windows: new Set(),
+  calendars: null,
+  isCalendarActivated: null,
+  QueryInterface: cal.generateQI([Ci.calICalendarManagerObserver, Ci.calIObserver]),
+
+  initializeDeactivator() {
+    let manager = cal.getCalendarManager();
+    this.calendars = new Set(manager.getCalendars());
+    manager.addObserver(this);
+    manager.addCalendarObserver(this);
+    this.isCalendarActivated = this.checkCalendarsEnabled();
+  },
+
+  /**
+   * Register a window to allow future modifications, and set up the window's
+   * deactivated/activated state. Deregistration is not required.
+   *
+   * @param {ChromeWindow} window - A ChromeWindow object.
+   */
+  registerWindow(window) {
+    if (this.calendars === null) {
+      this.initializeDeactivator();
+    }
+    this.windows.add(window);
+    window.addEventListener("unload", () => this.windows.delete(window));
+
+    if (!this.isCalendarActivated) {
+      window.document.documentElement.setAttribute("calendar-deactivated", "");
+    }
+  },
+
+  /**
+   * Check the enabled state of all of the user's calendars.
+   *
+   * @return {boolean} True if any calendars are enabled, false if all are disabled.
+   */
+  checkCalendarsEnabled() {
+    for (let calendar of this.calendars) {
+      if (!calendar.getProperty("disabled")) {
+        return true;
+      }
+    }
+    return false;
+  },
+
+  /**
+   * If needed, change the calendar activated/deactivated state and update the
+   * UI and background processes/services accordingly.
+   */
+  refreshDeactivatedState() {
+    let someCalsEnabled = this.checkCalendarsEnabled();
+
+    if (someCalsEnabled == this.isCalendarActivated) {
+      return;
+    }
+
+    for (let window of this.windows) {
+      if (someCalsEnabled) {
+        window.document.documentElement.removeAttribute("calendar-deactivated");
+      } else {
+        window.document.documentElement.setAttribute("calendar-deactivated", "");
+      }
+    }
+    this.isCalendarActivated = someCalsEnabled;
+  },
+
+  // calICalendarManagerObserver methods
+  onCalendarRegistered(calendar) {
+    this.calendars.add(calendar);
+
+    if (!this.isCalendarActivated && !calendar.getProperty("disabled")) {
+      this.refreshDeactivatedState();
+    }
+  },
+
+  onCalendarUnregistering(calendar) {
+    this.calendars.delete(calendar);
+
+    if (!calendar.getProperty("disabled")) {
+      this.refreshDeactivatedState();
+    }
+  },
+  onCalendarDeleting(calendar) {},
+
+  // calIObserver methods
+  onStartBatch() {},
+  onEndBatch() {},
+  onLoad() {},
+  onAddItem(item) {},
+  onModifyItem(newItem, oldItem) {},
+  onDeleteItem(deletedItem) {},
+  onError(calendar, errNo, message) {},
+
+  onPropertyChanged(calendar, name, value, oldValue) {
+    if (name == "disabled") {
+      this.refreshDeactivatedState();
+    }
+  },
+
+  onPropertyDeleting(calendar, name) {},
+};
--- a/calendar/base/modules/moz.build
+++ b/calendar/base/modules/moz.build
@@ -20,14 +20,15 @@ EXTRA_JS_MODULES.calendar.utils += [
     'utils/calProviderUtils.jsm',
     'utils/calUnifinderUtils.jsm',
     'utils/calViewUtils.jsm',
     'utils/calWindowUtils.jsm',
     'utils/calXMLUtils.jsm',
 ]
 
 EXTRA_JS_MODULES.calendar += [
+    'calCalendarDeactivator.jsm',
     'calExtract.jsm',
     'calHashedArray.jsm',
     'calRecurrenceUtils.jsm',
     'calUtils.jsm',
     'Ical.jsm',
 ]
--- a/calendar/base/themes/common/lightning.css
+++ b/calendar/base/themes/common/lightning.css
@@ -1,12 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* For deactivating calendar, see calCalendarDeactivator.jsm. */
+:root[calendar-deactivated] .hide-when-calendar-deactivated {
+  display: none;
+}
+
 /* ::: new tab buttons ::: */
 #calendar-tab-button,
 #newMsgButton-calendar-menuitem {
     list-style-image: url(chrome://messenger/skin/shared/in-content/calendar.svg);
     -moz-image-region: auto;
 }
 
 #task-tab-button,
--- a/calendar/lightning/content/calendar-menu-events-tasks.inc.xhtml
+++ b/calendar/lightning/content/calendar-menu-events-tasks.inc.xhtml
@@ -1,13 +1,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 <menu id="menu_Event_Task"
+      class="hide-when-calendar-deactivated"
       label="&lightning.menu.eventtask.label;"
       accesskey="&lightning.menu.eventtask.accesskey;">
   <menupopup id="menu_Event_Task_Popup" onpopupshowing="changeMenuForTask(event); setupDeleteMenuitem('ltnDeleteSelectedCalendar')">
     <menuitem id="ltnNewEvent2"
               label="&event.new.event;"
               accesskey="&event.new.event.accesskey;"
               key="calendar-new-event-key"
               command="calendar_new_event_command"/>
--- a/calendar/lightning/content/calendar-status-bar.inc.xhtml
+++ b/calendar/lightning/content/calendar-status-bar.inc.xhtml
@@ -69,17 +69,17 @@
          hidden="true"/>
   <label id="status-freebusy-busy-label"
          value="&event.freebusy.legend.busy;"
          hidden="true"/>
 </hbox>
 <!-- end event/task in tab statusbarpanels -->
 
 <calendar-modebox id="calendar-show-todaypane-panel"
-                  class="statusbarpanel"
+                  class="statusbarpanel hide-when-calendar-deactivated"
                   mode="mail,calendar,task,chat,calendarEvent,calendarTask"
                   collapsedinmodes="special"
                   pack="center">
   <toolbarbutton id="calendar-status-todaypane-button"
                  type="checkbox"
                  label="&todaypane.statusButton.label;"
                  tooltiptext="&calendar.todaypane.button.tooltip;"
                  command="calendar_toggle_todaypane_command"/>
--- a/calendar/lightning/content/calendar-today-pane.inc.xhtml
+++ b/calendar/lightning/content/calendar-today-pane.inc.xhtml
@@ -1,20 +1,21 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 <splitter id="today-splitter"
+          class="calendar-sidebar-splitter hide-when-calendar-deactivated"
           collapse="after"
           resizebefore="closest"
           state="collapsed"
-          class="calendar-sidebar-splitter"
           oncommand="TodayPane.onCommandTodaySplitter();">
 </splitter>
 <calendar-modevbox id="today-pane-panel"
+                   class="hide-when-calendar-deactivated"
                    mode="mail,calendar,task,chat,calendarEvent,calendarTask"
                    modewidths="200,200,200,200,200,200"
                    modesplitterstates="open,open,open,open,open,open"
                    refcontrol="calendar_toggle_todaypane_command"
                    persist="modewidths">
   <box class="sidebar-header" align="center">
     <label id="today-pane-header"/>
     <spacer flex="1"/>
--- a/calendar/lightning/content/calendar-view-menu.inc.xhtml
+++ b/calendar/lightning/content/calendar-view-menu.inc.xhtml
@@ -1,14 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-<menuseparator id="ltnViewMenuSeparator"/>
+<menuseparator id="ltnViewMenuSeparator"
+               class="hide-when-calendar-deactivated"/>
 <menu id="ltnTodayPaneMenu"
+      class="hide-when-calendar-deactivated"
       label="&calendar.context.button.label;"
       accesskey="&calendar.context.button.accesskey;">
   <menupopup id="ltnTodayPaneMenuPopup">
     <menuitem id="ltnShowTodayPane-2"
               label="&todaypane.showTodayPane.label;"
               accesskey="&todaypane.showTodayPane.accesskey;"
               type="checkbox"
               key="todaypanekey"
@@ -33,16 +35,17 @@
               value="none"
               type="radio"
               oncommand="TodayPane.displayMiniSection('none')"
               label="&todaypane.showNone.label;"
               accesskey="&todaypane.showNone.accesskey;"/>
   </menupopup>
 </menu>
 <menu id="ltnCalendarMenu"
+      class="hide-when-calendar-deactivated"
       observes="calendar_in_foreground"
       label="&lightning.menu.view.calendar.label;"
       accesskey="&lightning.menu.view.calendar.accesskey;">
   <menupopup id="ltnCalendarMenuPopup">
     <menuitem id="ltnChangeViewDay"
               label="&lightning.toolbar.day.label;"
               accesskey="&lightning.toolbar.day.accesskey;"
               type="radio"
@@ -120,16 +123,17 @@
                   label="&calendar.orientation.label;"
                   accesskey="&calendar.orientation.accesskey;"
                   command="calendar_toggle_orientation_command"/>
       </menupopup>
     </menu>
   </menupopup>
 </menu>
 <menu id="ltnTasksMenu"
+      class="hide-when-calendar-deactivated"
       observes="calendar_mode_task"
       label="&lightning.menu.view.tasks.label;"
       accesskey="&lightning.menu.view.tasks.accesskey;">
   <menupopup id="ltnTasksMenuPopup">
     <menuitem id="ltnTasksViewFilterTasks"
               type="checkbox"
               label="&calendar.tasks.view.filtertasks.label;"
               accesskey="&calendar.tasks.view.filtertasks.accesskey;"
--- a/mail/base/content/mainNavigationToolbox.inc.xhtml
+++ b/mail/base/content/mainNavigationToolbox.inc.xhtml
@@ -46,26 +46,29 @@
                 label="&newMenu.label;"
                 accesskey="&newMenu.accesskey;">
             <menupopup id="menu_NewPopup" onpopupshowing="menu_new_init();">
               <menuitem id="menu_newNewMsgCmd" label="&newNewMsgCmd.label;"
                         accesskey="&newNewMsgCmd.accesskey;"
                         key="key_newMessage2"
                         command="cmd_newMessage"/>
               <menuitem id="calendar-new-event-menuitem"
+                        class="hide-when-calendar-deactivated"
                         label="&lightning.menupopup.new.event.label;"
                         accesskey="&lightning.menupopup.new.event.accesskey;"
                         key="calendar-new-event-key"
                         command="calendar_new_event_command"/>
               <menuitem id="calendar-new-task-menuitem"
+                        class="hide-when-calendar-deactivated"
                         label="&lightning.menupopup.new.task.label;"
                         accesskey="&lightning.menupopup.new.task.accesskey;"
                         key="calendar-new-todo-key"
                         command="calendar_new_todo_command"/>
               <menuseparator id="calendar-after-new-task-menuseparator"
+                             class="hide-when-calendar-deactivated"
                              observes="menu_newFolder"/>
               <menuitem id="menu_newFolder" label="&newFolderCmd.label;"
                         command="cmd_newFolder"
                         accesskey="&newFolderCmd.accesskey;"
                         class="menuitem-iconic"/>
               <menuitem id="menu_newVirtualFolder" label="&newVirtualFolderCmd.label;"
                         command="cmd_newVirtualFolder"
                         accesskey="&newVirtualFolderCmd.accesskey;"
@@ -125,21 +128,23 @@
           <menuitem id="menu_close"
                     label="&closeCmd.label;"
                     key="key_close"
                     accesskey="&closeCmd.accesskey;"
                     command="cmd_close"
                     class="menuitem-iconic"/>
           <menuseparator id="fileMenuAfterCloseSeparator"/>
           <menuitem id="calendar-save-menuitem"
+                    class="hide-when-calendar-deactivated"
                     label="&event.menu.item.save.label;"
                     accesskey="&event.menu.item.save.tab.accesskey;"
                     key="save-key"
                     command="cmd_save"/>
           <menuitem id="calendar-save-and-close-menuitem"
+                    class="hide-when-calendar-deactivated"
                     label="&event.menu.item.saveandclose.label;"
                     accesskey="&event.menu.item.saveandclose.tab.accesskey;"
                     command="cmd_accept"/>
           <menu id="menu_saveAs" class="menu-iconic menuitem-iconic"
                 label="&saveAsMenu.label;" accesskey="&saveAsMenu.accesskey;">
             <menupopup id="menu_SavePopup">
               <menuitem id="menu_saveAsFile" label="&saveAsFileCmd.label;"
                accesskey="&saveAsFileCmd.accesskey;"
@@ -652,21 +657,23 @@
                         accesskey="&nextStarredMsgCmd.accesskey;"
                         command="cmd_nextFlaggedMsg"/>
               <menuseparator id="goNextAfterFlaggedSeparator"/>
               <menuitem id="menu_nextUnreadThread"
                         label="&nextUnreadThread.label;"
                         accesskey="&nextUnreadThread.accesskey;"
                         command="cmd_nextUnreadThread"
                         key="key_nextUnreadThread"/>
-              <menuseparator id="goNextAfterUnreadThreadSeparator"/>
+              <menuseparator id="goNextAfterUnreadThreadSeparator"
+                             class="hide-when-calendar-deactivated"/>
               <!-- Label is set up automatically using the view id. When writing
                    a view extension, add a `label-<myviewtype>` attribute with
                    the correct label. -->
               <menuitem id="calendar-go-menu-next"
+                        class="hide-when-calendar-deactivated"
                         label=""
                         label-day="&lightning.toolbar.day.label;"
                         label-week="&lightning.toolbar.week.label;"
                         label-multiweek="&lightning.toolbar.week.label;"
                         label-month="&lightning.toolbar.month.label;"
                         accesskey-day="&lightning.toolbar.day.accesskey;"
                         accesskey-week="&lightning.toolbar.week.accesskey;"
                         accesskey-multiweek="&lightning.toolbar.week.accesskey;"
@@ -685,21 +692,23 @@
                         label="&prevUnreadMsgCmd.label;"
                         accesskey="&prevUnreadMsgCmd.accesskey;"
                         command="cmd_previousUnreadMsg"
                         key="key_previousUnreadMsg"/>
               <menuitem id="menu_prevFlaggedMsg"
                         label="&prevStarredMsgCmd.label;"
                         accesskey="&prevStarredMsgCmd.accesskey;"
                         command="cmd_previousFlaggedMsg"/>
-              <menuseparator id="goPreviousAfterFlaggedSeparator"/>
+              <menuseparator id="goPreviousAfterFlaggedSeparator"
+                             class="hide-when-calendar-deactivated"/>
               <!-- Label is set up automatically using the view id. When writing
                    a view extension, add a `label-<myviewtype>` attribute with
                    the correct label. -->
               <menuitem id="calendar-go-menu-previous"
+                        class="hide-when-calendar-deactivated"
                         label=""
                         label-day="&lightning.toolbar.day.label;"
                         label-week="&lightning.toolbar.week.label;"
                         label-multiweek="&lightning.toolbar.week.label;"
                         label-month="&lightning.toolbar.month.label;"
                         accesskey-day="&lightning.toolbar.day.accesskey;"
                         accesskey-week="&lightning.toolbar.week.accesskey;"
                         accesskey-multiweek="&lightning.toolbar.week.accesskey;"
@@ -712,16 +721,17 @@
                     key="key_goForward"
                     class="menuitem-iconic"/>
           <menuitem id="menu_goBack" label="&goBackCmd.label;"
                     accesskey="&goBackCmd.accesskey;" command="cmd_goBack"
                     key="key_goBack"
                     class="menuitem-iconic"/>
           <menuseparator id="goNextSeparator"/>
           <menuitem id="calendar-go-to-today-menuitem"
+                    class="hide-when-calendar-deactivated"
                     label="&goTodayCmd.label;"
                     accesskey="&goTodayCmd.accesskey;"
                     command="calendar_go_to_today_command"
                     key="calendar-go-to-today-key"/>
           <menuitem id="menu_goChat" label="&goChatCmd.label;"
                     accesskey="&goChatCmd.accesskey;"
                     command="cmd_chat"
                     key="key_goChat"/>
--- a/mail/base/content/mainPopupSet.inc.xhtml
+++ b/mail/base/content/mainPopupSet.inc.xhtml
@@ -323,16 +323,17 @@
                  favoritesAccessKey="&contextMoveCopyMsgFavoritesMenu.accesskey;"/>
     </menu>
     <menuitem id="mailContext-moveToFolderAgain"
               command="cmd_moveToFolderAgain"
               label="&moveToFolderAgain.label;"
               accesskey="&moveToFolderAgain.accesskey;"/>
 
     <menu id="mailContext-calendar-convert-menu"
+          class="hide-when-calendar-deactivated"
           label="&calendar.context.convertmenu.label;"
           accesskey="&calendar.context.convertmenu.accesskey.mail;">
       <menupopup id="mailContext-calendar-convert-menupopup">
         <menuitem id="mailContext-calendar-convert-event-menuitem"
                   label="&calendar.context.convertmenu.event.label;"
                   accesskey="&calendar.context.convertmenu.event.accesskey;"
                   oncommand="calendarExtract.extractFromEmail(true)" />
         <menuitem id="mailContext-calendar-convert-task-menuitem"
--- a/mail/components/customizableui/content/panelUI.inc.xhtml
+++ b/mail/components/customizableui/content/panelUI.inc.xhtml
@@ -121,17 +121,17 @@
                        closemenu="none"
                        oncommand="PanelUI.showSubView('appMenu-goView', this)"/>
         <toolbarbutton id="appmenu_messageMenu"
                        class="subviewbutton subviewbutton-nav"
                        label="&msgMenu.label;"
                        closemenu="none"
                        oncommand="PanelUI.showSubView('appMenu-messageView', this)"/>
         <toolbarbutton id="appmenu_Event_Task"
-                       class="subviewbutton subviewbutton-nav"
+                       class="subviewbutton subviewbutton-nav hide-when-calendar-deactivated"
                        label="&lightning.menu.eventtask.label;"
                        closemenu="none"
                        oncommand="PanelUI.showSubView('appmenu_Event_Task_View', this)"/>
         <toolbarbutton id="appmenu_tasksMenu"
                        class="subviewbutton subviewbutton-nav"
                        label="&tasksMenu.label;"
                        closemenu="none"
                        oncommand="PanelUI.showSubView('appMenu-toolsView', this)"/>
@@ -160,24 +160,25 @@
       <vbox id="appMenu-newViewItems"
             class="panel-subview-body">
         <toolbarbutton id="appmenu_newNewMsgCmd"
                        class="subviewbutton subviewbutton-iconic"
                        label="&newNewMsgCmd.label;"
                        key="key_newMessage2"
                        command="cmd_newMessage"/>
         <toolbarbutton id="appmenu_calendar-new-event-menu-item"
-                       class="subviewbutton subviewbutton-iconic"
+                       class="subviewbutton subviewbutton-iconic hide-when-calendar-deactivated"
                        label="&lightning.menupopup.new.event.label;"
                        command="calendar_new_event_command"/>
         <toolbarbutton id="appmenu_calendar-new-task-menu-item"
-                       class="subviewbutton subviewbutton-iconic"
+                       class="subviewbutton subviewbutton-iconic hide-when-calendar-deactivated"
                        label="&lightning.menupopup.new.task.label;"
                        command="calendar_new_todo_command"/>
         <toolbarseparator id="appmenu_calendar-after-new-task-separator"
+                          class="hide-when-calendar-deactivated"
                           observes="appmenu_newFolder"/>
         <toolbarbutton id="appmenu_newFolder"
                        class="subviewbutton subviewbutton-iconic"
                        label="&newFolderCmd.label;"
                        command="cmd_newFolder"/>
         <toolbarbutton id="appmenu_newVirtualFolder"
                        class="subviewbutton subviewbutton-iconic"
                        label="&newVirtualFolderCmd.label;"
@@ -656,30 +657,31 @@
                class="PanelUI-subView">
       <vbox id="appMenu-viewViewItems"
             class="panel-subview-body">
         <toolbarbutton id="appmenu_FolderViews"
                        class="subviewbutton subviewbutton-nav"
                        label="&folderView.label;"
                        closemenu="none"
                        oncommand="PanelUI.showSubView('appMenu-foldersView', this)"/>
-        <toolbarseparator id="appmenu_calendar-view-menu-separator"/>
+        <toolbarseparator id="appmenu_calendar-view-menu-separator"
+                          class="hide-when-calendar-deactivated"/>
         <toolbarbutton id="appmenu_calendar-today-pane-menu"
-                      class="subviewbutton subviewbutton-nav"
+                      class="subviewbutton subviewbutton-nav hide-when-calendar-deactivated"
                       label="&calendar.context.button.label;"
                       closemenu="none"
                       oncommand="PanelUI.showSubView('appmenu_calendar-today-pane-view', this)"/>
         <toolbarbutton id="appmenu_calendar-calendar-menu"
-                      class="subviewbutton subviewbutton-nav"
+                      class="subviewbutton subviewbutton-nav hide-when-calendar-deactivated"
                       observes="calendar_in_foreground"
                       label="&lightning.menu.view.calendar.label;"
                       closemenu="none"
                       oncommand="PanelUI.showSubView('appmenu_calendar-calendar-view', this)"/>
         <toolbarbutton id="appmenu_calendar-tasks-menu"
-                      class="subviewbutton subviewbutton-nav"
+                      class="subviewbutton subviewbutton-nav hide-when-calendar-deactivated"
                       observes="calendar_mode_task"
                       label="&lightning.menu.view.tasks.label;"
                       closemenu="none"
                       oncommand="PanelUI.showSubView('appmenu_calendar-tasks-view', this)"/>
         <toolbarseparator id="appmenu_viewSortMenuSeparator"/>
         <toolbarbutton id="appmenu_viewSortMenu"
                        class="subviewbutton subviewbutton-nav"
                        label="&sortMenu.label;"
@@ -1224,17 +1226,17 @@
                        command="cmd_goForward"/>
         <toolbarbutton id="appmenu_goBack"
                        class="subviewbutton subviewbutton-iconic"
                        label="&goBackCmd.label;"
                        key="key_goBack"
                        command="cmd_goBack"/>
         <toolbarseparator id="appmenu_goNextSeparator"/>
         <toolbarbutton id="appmenu_calendar-go-to-today"
-                       class="subviewbutton subviewbutton-iconic"
+                       class="subviewbutton subviewbutton-iconic hide-when-calendar-deactivated"
                        label="&goTodayCmd.label;"
                        command="calendar_go_to_today_command"/>
         <toolbarbutton id="appmenu_goChat"
                        class="subviewbutton subviewbutton-iconic"
                        label="&goChatCmd.label;"
                        key="key_goChat"
                        command="cmd_chat"/>
         <toolbarseparator id="appmenu_goChatSeparator"/>
@@ -1280,22 +1282,23 @@
                        label="&nextStarredMsgCmd.label;"
                        command="cmd_nextFlaggedMsg"/>
         <toolbarseparator id="appmenu_goNextAfterFlaggedSeparator"/>
         <toolbarbutton id="appmenu_nextUnreadThread"
                        class="subviewbutton subviewbutton-iconic"
                        label="&nextUnreadThread.label;"
                        key="key_nextUnreadThread"
                        command="cmd_nextUnreadThread"/>
-        <toolbarseparator id="appmenu_GoNextAfterUnreadThreadSeparator"/>
+        <toolbarseparator id="appmenu_GoNextAfterUnreadThreadSeparator"
+                          class="hide-when-calendar-deactivated"/>
         <!-- Label is set up automatically using the view id. When writing a
              view extension, add a `label-<myviewtype>` attribute with the
              correct label. -->
         <toolbarbutton id="appmenu_calendar-go-menu-next"
-                       class="subviewbutton subviewbutton-iconic"
+                       class="subviewbutton subviewbutton-iconic hide-when-calendar-deactivated"
                        label=""
                        label-day="&lightning.toolbar.day.label;"
                        label-week="&lightning.toolbar.week.label;"
                        label-multiweek="&lightning.toolbar.week.label;"
                        label-month="&lightning.toolbar.month.label;"
                        command="calendar_view_next_command"/>
       </vbox>
     </panelview>
@@ -1315,22 +1318,23 @@
                        class="subviewbutton subviewbutton-iconic"
                        label="&prevUnreadMsgCmd.label;"
                        key="key_previousUnreadMsg"
                        command="cmd_previousUnreadMsg"/>
         <toolbarbutton id="appmenu_prevFlaggedMsg"
                        class="subviewbutton subviewbutton-iconic"
                        label="&prevStarredMsgCmd.label;"
                        command="cmd_previousFlaggedMsg"/>
-        <toolbarseparator id="appmenu_goPreviousAfterFlaggedSeparator"/>
+        <toolbarseparator id="appmenu_goPreviousAfterFlaggedSeparator"
+                          class="hide-when-calendar-deactivated"/>
         <!-- Label is set up automatically using the view id. When writing a
              view extension, add a `label-<myviewtype>` attribute with the
              correct label. -->
         <toolbarbutton id="appmenu_calendar-go-menu-previous"
-                       class="subviewbutton subviewbutton-iconic"
+                       class="subviewbutton subviewbutton-iconic hide-when-calendar-deactivated"
                        label=""
                        label-day="&lightning.toolbar.day.label;"
                        label-week="&lightning.toolbar.week.label;"
                        label-multiweek="&lightning.toolbar.week.label;"
                        label-month="&lightning.toolbar.month.label;"
                        command="calendar_view_prev_command"/>
       </vbox>
     </panelview>