зеркало из https://github.com/mozilla/gecko-dev.git
Bug 867200 - Remove Sync Now button and update sync related logic. r=rnewman, ally
This commit is contained in:
Родитель
f1dbe5cca7
Коммит
a99d102edb
|
@ -402,15 +402,14 @@
|
|||
|
||||
<flyoutpanel id="sync-flyoutpanel" headertext="&syncHeader.title;">
|
||||
<description>&sync.setup.description;</description>
|
||||
<setting id="sync-connect" type="control">
|
||||
<description id="sync-lastsync" collapsed="true"></description>
|
||||
<description id="sync-errordescription" collapsed="true"></description>
|
||||
<setting id="sync-connect" type="control" collapsed="true">
|
||||
<button label="&sync.setupbutton.label;" oncommand="Sync.tryConnect();" />
|
||||
</setting>
|
||||
<setting id="sync-connected" class="setting-group" type="control" collapsed="true">
|
||||
<button id="sync-pairdevice" label="&sync.pair.button;" oncommand="SyncPairDevice.open();" />
|
||||
</setting>
|
||||
<setting id="sync-sync" class="setting-subgroup" type="control" collapsed="true">
|
||||
<button id="sync-syncButton" label="&sync.syncNow2;" oncommand="Sync.sync();"/>
|
||||
</setting>
|
||||
<setting id="sync-device" class="setting-subgroup" type="string" title="&sync.deviceName;" onchange="Sync.changeName(this);" collapsed="true"/>
|
||||
<setting id="sync-disconnect" class="setting-subgroup" type="control" collapsed="true">
|
||||
<button label="&sync.removebutton.label;" oncommand="Sync.disconnect();" />
|
||||
|
|
|
@ -13,6 +13,20 @@ let Sync = {
|
|||
_progressValue: 0,
|
||||
_progressMax: null,
|
||||
|
||||
get _isSetup() {
|
||||
if (Weave.Status.checkSetup() == Weave.CLIENT_NOT_CONFIGURED) {
|
||||
return false;
|
||||
}
|
||||
// check for issues related to failed logins that do not have anything to
|
||||
// do with network, server, and other non-client issues. See the login
|
||||
// failure status codes in sync service.
|
||||
return (Weave.Status.login != Weave.LOGIN_FAILED_NO_USERNAME &&
|
||||
Weave.Status.login != Weave.LOGIN_FAILED_NO_PASSWORD &&
|
||||
Weave.Status.login != Weave.LOGIN_FAILED_NO_PASSPHRASE &&
|
||||
Weave.Status.login != Weave.LOGIN_FAILED_INVALID_PASSPHRASE &&
|
||||
Weave.Status.login != Weave.LOGIN_FAILED_LOGIN_REJECTED);
|
||||
},
|
||||
|
||||
init: function init() {
|
||||
if (this._bundle) {
|
||||
return;
|
||||
|
@ -70,17 +84,13 @@ let Sync = {
|
|||
|
||||
this.setupData = { account: "", password: "" , synckey: "", serverURL: "" };
|
||||
|
||||
if (Weave.Status.checkSetup() != Weave.CLIENT_NOT_CONFIGURED) {
|
||||
// Put the settings UI into a state of "connecting..." if we are going to auto-connect
|
||||
this._elements.connect.firstChild.disabled = true;
|
||||
|
||||
try {
|
||||
this._elements.device.value = Services.prefs.getCharPref("services.sync.client.name");
|
||||
} catch(e) {}
|
||||
} else if (Weave.Status.login != Weave.LOGIN_FAILED_NO_USERNAME) {
|
||||
if (this._isSetup) {
|
||||
this.loadSetupData();
|
||||
}
|
||||
|
||||
// Update the state of the ui
|
||||
this._updateUI();
|
||||
|
||||
this._boundOnEngineSync = this.onEngineSync.bind(this);
|
||||
this._boundOnServiceSync = this.onServiceSync.bind(this);
|
||||
this._progressBar = document.getElementById("syncsetup-progressbar");
|
||||
|
@ -402,11 +412,6 @@ let Sync = {
|
|||
},
|
||||
|
||||
get _elements() {
|
||||
// Do a quick test to see if the options exist yet
|
||||
let syncButton = document.getElementById("sync-syncButton");
|
||||
if (syncButton == null)
|
||||
return null;
|
||||
|
||||
// Get all the setting nodes from the add-ons display
|
||||
let elements = {};
|
||||
let setupids = ["account", "password", "synckey", "usecustomserver", "customserver"];
|
||||
|
@ -414,7 +419,8 @@ let Sync = {
|
|||
elements[id] = document.getElementById("syncsetup-" + id);
|
||||
});
|
||||
|
||||
let settingids = ["device", "connect", "connected", "disconnect", "sync", "pairdevice"];
|
||||
let settingids = ["device", "connect", "connected", "disconnect", "lastsync", "pairdevice",
|
||||
"errordescription"];
|
||||
settingids.forEach(function(id) {
|
||||
elements[id] = document.getElementById("sync-" + id);
|
||||
});
|
||||
|
@ -424,6 +430,66 @@ let Sync = {
|
|||
return this._elements = elements;
|
||||
},
|
||||
|
||||
_updateUI: function _updateUI() {
|
||||
if (this._elements == null)
|
||||
return;
|
||||
|
||||
let connect = this._elements.connect;
|
||||
let connected = this._elements.connected;
|
||||
let device = this._elements.device;
|
||||
let disconnect = this._elements.disconnect;
|
||||
let lastsync = this._elements.lastsync;
|
||||
let pairdevice = this._elements.pairdevice;
|
||||
|
||||
// This gets updated when an error occurs
|
||||
this._elements.errordescription.collapsed = true;
|
||||
|
||||
let isConfigured = (!this._loginError && this._isSetup);
|
||||
|
||||
connect.collapsed = isConfigured;
|
||||
connected.collapsed = !isConfigured;
|
||||
lastsync.collapsed = !isConfigured;
|
||||
device.collapsed = !isConfigured;
|
||||
disconnect.collapsed = !isConfigured;
|
||||
|
||||
// Set the device name text edit to configured name or the auto generated
|
||||
// name if we aren't set up.
|
||||
try {
|
||||
device.value = Services.prefs.getCharPref("services.sync.client.name");
|
||||
} catch(ex) {
|
||||
device.value = Weave.Service.clientsEngine.localName || "";
|
||||
}
|
||||
|
||||
try {
|
||||
let accountStr = this._bundle.formatStringFromName("account.label", [Weave.Service.identity.account], 1);
|
||||
disconnect.setAttribute("title", accountStr);
|
||||
} catch (ex) {}
|
||||
|
||||
// If we're already locked, a sync is in progress..
|
||||
if (Weave.Service.locked && isConfigured) {
|
||||
connect.firstChild.disabled = true;
|
||||
}
|
||||
|
||||
// Show the day-of-week and time (HH:MM) of last sync
|
||||
let lastSync = Weave.Svc.Prefs.get("lastSync");
|
||||
lastsync.textContent = "";
|
||||
if (lastSync != null) {
|
||||
let syncDate = new Date(lastSync).toLocaleFormat("%A %I:%M %p");
|
||||
let dateStr = this._bundle.formatStringFromName("lastSync2.label", [syncDate], 1);
|
||||
lastsync.textContent = dateStr;
|
||||
}
|
||||
|
||||
// Check the lock again on a timeout since it's set after observers notify
|
||||
setTimeout(function(self) {
|
||||
// Prevent certain actions when the service is locked
|
||||
if (Weave.Service.locked) {
|
||||
connect.firstChild.disabled = true;
|
||||
} else {
|
||||
connect.firstChild.disabled = false;
|
||||
}
|
||||
}, 100, this);
|
||||
},
|
||||
|
||||
observe: function observe(aSubject, aTopic, aData) {
|
||||
if (aTopic == "weave:service:ready") {
|
||||
Services.obs.removeObserver(this, aTopic);
|
||||
|
@ -438,20 +504,16 @@ let Sync = {
|
|||
if (this._elements == null)
|
||||
return;
|
||||
|
||||
// Make some aliases
|
||||
let connect = this._elements.connect;
|
||||
let connected = this._elements.connected;
|
||||
let device = this._elements.device;
|
||||
let disconnect = this._elements.disconnect;
|
||||
let sync = this._elements.sync;
|
||||
let pairdevice = this._elements.pairdevice;
|
||||
// Update the state of the ui
|
||||
this._updateUI();
|
||||
|
||||
let errormsg = this._elements.errordescription;
|
||||
|
||||
// Show what went wrong with login if necessary
|
||||
if (aTopic == "weave:ui:login:error") {
|
||||
this._loginError = true;
|
||||
connect.setAttribute("desc", Weave.Utils.getErrorString(Weave.Status.login));
|
||||
} else {
|
||||
connect.removeAttribute("desc");
|
||||
errormsg.textContent = Weave.Utils.getErrorString(Weave.Status.login);
|
||||
errormsg.collapsed = false;
|
||||
}
|
||||
|
||||
if (aTopic == "weave:service:login:finish") {
|
||||
|
@ -461,51 +523,11 @@ let Sync = {
|
|||
this.loadSetupData();
|
||||
}
|
||||
|
||||
let isConfigured = (!this._loginError && Weave.Status.checkSetup() != Weave.CLIENT_NOT_CONFIGURED);
|
||||
|
||||
connect.collapsed = isConfigured;
|
||||
connected.collapsed = !isConfigured;
|
||||
|
||||
if (!isConfigured) {
|
||||
connect.firstChild.disabled = false;
|
||||
}
|
||||
|
||||
sync.collapsed = !isConfigured;
|
||||
device.collapsed = !isConfigured;
|
||||
disconnect.collapsed = !isConfigured;
|
||||
|
||||
// Check the lock on a timeout because it's set just after notifying
|
||||
setTimeout(function(self) {
|
||||
// Prevent certain actions when the service is locked
|
||||
if (Weave.Service.locked) {
|
||||
connect.firstChild.disabled = true;
|
||||
sync.firstChild.disabled = true;
|
||||
|
||||
if (aTopic == "weave:service:login:start")
|
||||
connect.setAttribute("title", self._bundle.GetStringFromName("connecting.label"));
|
||||
|
||||
if (aTopic == "weave:service:sync:start")
|
||||
sync.setAttribute("title", self._bundle.GetStringFromName("lastSyncInProgress2.label"));
|
||||
} else {
|
||||
connect.firstChild.disabled = false;
|
||||
sync.firstChild.disabled = false;
|
||||
}
|
||||
}, 0, this);
|
||||
|
||||
// Dynamically generate some strings
|
||||
let accountStr = this._bundle.formatStringFromName("account.label", [Weave.Service.identity.account], 1);
|
||||
disconnect.setAttribute("title", accountStr);
|
||||
|
||||
// Show the day-of-week and time (HH:MM) of last sync
|
||||
let lastSync = Weave.Svc.Prefs.get("lastSync");
|
||||
if (lastSync != null) {
|
||||
let syncDate = new Date(lastSync).toLocaleFormat("%a %H:%M");
|
||||
let dateStr = this._bundle.formatStringFromName("lastSync2.label", [syncDate], 1);
|
||||
sync.setAttribute("title", dateStr);
|
||||
}
|
||||
|
||||
// Check for a storage format update, update the user and load the Sync update page
|
||||
if (aTopic =="weave:service:sync:error") {
|
||||
errormsg.textContent = Weave.Utils.getErrorString(Weave.Status.sync);
|
||||
errormsg.collapsed = false;
|
||||
|
||||
let clientOutdated = false, remoteOutdated = false;
|
||||
if (Weave.Status.sync == Weave.VERSION_OUT_OF_DATE) {
|
||||
clientOutdated = true;
|
||||
|
@ -538,8 +560,6 @@ let Sync = {
|
|||
Browser.addTab("https://services.mozilla.com/update/", true, Browser.selectedTab);
|
||||
}
|
||||
}
|
||||
|
||||
device.value = Weave.Service.clientsEngine.localName || "";
|
||||
},
|
||||
|
||||
changeName: function changeName(aInput) {
|
||||
|
|
|
@ -9,7 +9,6 @@ sync.defaultAccountApplication=Metro %S
|
|||
|
||||
# %S is the date and time at which the last sync successfully completed
|
||||
lastSync2.label=Last sync: %S
|
||||
lastSyncInProgress2.label=Last sync: in progress…
|
||||
|
||||
# %S is the username logged in
|
||||
account.label=Account: %S
|
||||
|
|
Загрузка…
Ссылка в новой задаче