summaryrefslogtreecommitdiffstats
path: root/comm/mail/components/about-support/content/calendars.js
blob: a55b59572cd2911cc4e9dd762515e358086be9d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* 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/. */

/* globals CLASS_DATA_PRIVATE */

var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");

let boolean = val => (!val && val !== false ? "" : val);
let string = val => (val ? String(val) : "");

/**
 * A list of tuples for each calendar property displayed where each tuple
 * contains the following elements:
 * 0 - The name of the property passed to getProperty().
 * 1 - A function that accepts the property value and attempts it into a string.
 * 2 - Boolean indicating whether the property is private data (optional).
 */
let gCalendarProperties = [
  ["name", string, true],
  ["type", string],
  ["disabled", boolean],
  ["username", string, true],
  ["uri", string, true],
  ["refreshInterval", string],
  ["readOnly", boolean],
  ["suppressAlarms", boolean],
  ["cache.enabled", boolean],
  ["imip.identity", identity => string(identity && identity.key)],
  ["imip.identity.disabled", boolean],
  ["imip.identity.account", account => string(account && account.key)],
  ["organizerId", string, true],
  ["forceEmailScheduling", boolean],
  ["capabilities.alarms.popup.supported", boolean],
  ["capabilities.alarms.oninviations.supported", boolean],
  ["capabilities.alarms.maxCount", string],
  ["capabilities.attachments.supported", boolean],
  ["capabilities.categories.maxCount", string],
  ["capabilities.privacy.supported", boolean],
  ["capabilities.priority.supported", boolean],
  ["capabilities.events.supported", boolean],
  ["capabilities.tasks.supported", boolean],
  ["capabilities.timezones.floating.supported", boolean],
  ["capabilities.timezones.UTC.supported", boolean],
  ["capabilities.autoschedule.supported", boolean],
];

/**
 * Populates the "Calendars" section of the troubleshooting information page
 * with the properties of each configured calendar.
 */
function populateCalendarsSection() {
  let container = document.getElementById("calendar-tables");
  let tableTmpl = document.getElementById("calendars-table-template");
  let rowTmpl = document.getElementById("calendars-table-row-template");

  for (let calendar of cal.manager.getCalendars()) {
    let table = tableTmpl.content.cloneNode(true).querySelector("table");
    table.firstElementChild.textContent = calendar.name;

    let tbody = table.querySelector("tbody");
    for (let [prop, transform, isPrivate] of gCalendarProperties) {
      let tr = rowTmpl.content.cloneNode(true).querySelector("tr");
      let l10nKey = `calendars-table-${prop
        .toLowerCase()
        .replaceAll(".", "-")}`;

      tr.cells[0].setAttribute("data-l10n-id", l10nKey);
      tr.cells[1].textContent = transform(calendar.getProperty(prop));
      if (isPrivate) {
        tr.cells[1].setAttribute("class", CLASS_DATA_PRIVATE);
      }
      tbody.appendChild(tr);
    }
    container.appendChild(table);
  }
}