зеркало из https://github.com/mozilla/gecko-dev.git
Bug 915226 - Merge all refresh/start/stop/debug buttons to two buttons called update and debug r=paul
This commit is contained in:
Родитель
e03a8d916e
Коммит
5585c96e3a
|
@ -1072,7 +1072,6 @@ pref("devtools.commands.dir", "");
|
|||
|
||||
// Disable the app manager
|
||||
pref("devtools.appmanager.enabled", true);
|
||||
pref("devtools.appmanager.simulatorInstallPage", "https://addons.mozilla.org/firefox/addon/firefox-os-simulator/");
|
||||
pref("devtools.appmanager.firstrun", true);
|
||||
|
||||
// Toolbox preferences
|
||||
|
|
|
@ -109,7 +109,7 @@ let UI = {
|
|||
},
|
||||
|
||||
installSimulator: function() {
|
||||
let url = Services.prefs.getCharPref("devtools.appmanager.simulatorInstallPage");
|
||||
let url = "https://developer.mozilla.org/docs/Mozilla/Firefox_OS/Using_the_App_Manager#Simulator";
|
||||
window.open(url);
|
||||
},
|
||||
|
||||
|
|
|
@ -116,41 +116,59 @@ let UI = {
|
|||
|
||||
validate: function(project) {
|
||||
let validation = new AppValidator(project);
|
||||
validation.validate()
|
||||
.then(function () {
|
||||
if (validation.manifest) {
|
||||
project.name = validation.manifest.name;
|
||||
project.icon = UI._getLocalIconURL(project, validation.manifest);
|
||||
project.manifest = validation.manifest;
|
||||
}
|
||||
return validation.validate()
|
||||
.then(function () {
|
||||
if (validation.manifest) {
|
||||
project.name = validation.manifest.name;
|
||||
project.icon = UI._getLocalIconURL(project, validation.manifest);
|
||||
project.manifest = validation.manifest;
|
||||
}
|
||||
|
||||
project.validationStatus = "valid";
|
||||
project.validationStatus = "valid";
|
||||
|
||||
if (validation.warnings.length > 0) {
|
||||
project.warningsCount = validation.warnings.length;
|
||||
project.warnings = validation.warnings.join(",\n ");
|
||||
project.validationStatus = "warning";
|
||||
} else {
|
||||
project.warnings = "";
|
||||
project.warningsCount = 0;
|
||||
}
|
||||
if (validation.warnings.length > 0) {
|
||||
project.warningsCount = validation.warnings.length;
|
||||
project.warnings = validation.warnings.join(",\n ");
|
||||
project.validationStatus = "warning";
|
||||
} else {
|
||||
project.warnings = "";
|
||||
project.warningsCount = 0;
|
||||
}
|
||||
|
||||
if (validation.errors.length > 0) {
|
||||
project.errorsCount = validation.errors.length;
|
||||
project.errors = validation.errors.join(",\n ");
|
||||
project.validationStatus = "error";
|
||||
} else {
|
||||
project.errors = "";
|
||||
project.errorsCount = 0;
|
||||
}
|
||||
if (validation.errors.length > 0) {
|
||||
project.errorsCount = validation.errors.length;
|
||||
project.errors = validation.errors.join(",\n ");
|
||||
project.validationStatus = "error";
|
||||
} else {
|
||||
project.errors = "";
|
||||
project.errorsCount = 0;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
update: function(location) {
|
||||
update: function(button, location) {
|
||||
button.disabled = true;
|
||||
let project = AppProjects.get(location);
|
||||
this.validate(project);
|
||||
this.validate(project)
|
||||
.then(() => {
|
||||
// Install the app to the device if we are connected,
|
||||
// and there is no error
|
||||
if (project.errorsCount == 0 && this.listTabsResponse) {
|
||||
return this.install(project);
|
||||
}
|
||||
})
|
||||
.then(
|
||||
() => {
|
||||
button.disabled = false;
|
||||
},
|
||||
(res) => {
|
||||
button.disabled = false;
|
||||
let message = res.error + ": " + res.message;
|
||||
alert(message);
|
||||
this.connection.log(message);
|
||||
});
|
||||
},
|
||||
|
||||
remove: function(location) {
|
||||
|
@ -165,11 +183,7 @@ let UI = {
|
|||
}
|
||||
},
|
||||
|
||||
install: function(button, location) {
|
||||
button.dataset.originalTextContent = button.textContent;
|
||||
button.textContent = Utils.l10n("project.installing");
|
||||
button.disabled = true;
|
||||
let project = AppProjects.get(location);
|
||||
install: function(project) {
|
||||
let install;
|
||||
if (project.type == "packaged") {
|
||||
install = installPackaged(this.connection.client, this.listTabsResponse.webappsActor, project.location, project.packagedAppOrigin);
|
||||
|
@ -183,43 +197,37 @@ let UI = {
|
|||
};
|
||||
install = installHosted(this.connection.client, this.listTabsResponse.webappsActor, appId, metadata, project.manifest);
|
||||
}
|
||||
install.then(function () {
|
||||
button.disabled = false;
|
||||
button.textContent = Utils.l10n("project.installed");
|
||||
setTimeout(function() {
|
||||
button.textContent = button.dataset.originalTextContent;
|
||||
}, 1500);
|
||||
},
|
||||
function (res) {
|
||||
button.disabled = false;
|
||||
let message = res.error + ": " + res.message;
|
||||
alert(message);
|
||||
this.connection.log(message);
|
||||
});
|
||||
return install;
|
||||
},
|
||||
|
||||
start: function(location) {
|
||||
let project = AppProjects.get(location);
|
||||
start: function(project) {
|
||||
let deferred = promise.defer();
|
||||
let request = {
|
||||
to: this.listTabsResponse.webappsActor,
|
||||
type: "launch",
|
||||
manifestURL: this._getProjectManifestURL(project)
|
||||
};
|
||||
this.connection.client.request(request, (res) => {
|
||||
|
||||
if (res.error)
|
||||
deferred.reject(res.error);
|
||||
else
|
||||
deferred.resolve(res);
|
||||
});
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
stop: function(location) {
|
||||
let project = AppProjects.get(location);
|
||||
let deferred = promise.defer();
|
||||
let request = {
|
||||
to: this.listTabsResponse.webappsActor,
|
||||
type: "close",
|
||||
manifestURL: this._getProjectManifestURL(project)
|
||||
};
|
||||
this.connection.client.request(request, (res) => {
|
||||
|
||||
promive.resolve(res);
|
||||
});
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
_getTargetForApp: function(manifest) { // FIXME <- will be implemented in bug 912476
|
||||
|
@ -252,8 +260,39 @@ let UI = {
|
|||
return deferred.promise;
|
||||
},
|
||||
|
||||
openToolbox: function(location) {
|
||||
debug: function(button, location) {
|
||||
button.disabled = true;
|
||||
let project = AppProjects.get(location);
|
||||
// First try to open the app
|
||||
this.start(project)
|
||||
.then(
|
||||
null,
|
||||
(error) => {
|
||||
// If not installed, install and open it
|
||||
if (error == "NO_SUCH_APP") {
|
||||
return this.install(project)
|
||||
.then(() => this.start(project));
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
// Finally, when it's finally opened, display the toolbox
|
||||
return this.openToolbox(project)
|
||||
})
|
||||
.then(() => {
|
||||
// And only when the toolbox is opened, release the button
|
||||
button.disabled = false;
|
||||
},
|
||||
(msg) => {
|
||||
button.disabled = false;
|
||||
alert(msg);
|
||||
this.connection.log(msg);
|
||||
});
|
||||
},
|
||||
|
||||
openToolbox: function(project) {
|
||||
let deferred = promise.defer();
|
||||
let manifest = this._getProjectManifestURL(project);
|
||||
this._getTargetForApp(manifest).then((target) => {
|
||||
gDevTools.showToolbox(target,
|
||||
|
@ -262,11 +301,12 @@ let UI = {
|
|||
this.connection.once(Connection.Events.DISCONNECTED, () => {
|
||||
toolbox.destroy();
|
||||
});
|
||||
deferred.resolve();
|
||||
});
|
||||
}, console.error);
|
||||
}, deferred.reject);
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
|
||||
reveal: function(location) {
|
||||
let project = AppProjects.get(location);
|
||||
if (project.type == "packaged") {
|
||||
|
|
|
@ -70,11 +70,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="project-buttons">
|
||||
<button class="project-button-refresh" onclick="UI.update(this.dataset.location)" template='{"type":"attribute","path":"location","name":"data-location"}'>&projects.reloadFiles;</button>
|
||||
<button class="device-action project-button-install" onclick="UI.install(this, this.dataset.location)" template='{"type":"attribute","path":"location","name":"data-location"}'>&projects.installApp;</button>
|
||||
<button class="device-action project-button-start" onclick="UI.start(this.dataset.location)" template='{"type":"attribute","path":"location","name":"data-location"}'>&projects.startApp;</button>
|
||||
<button class="device-action project-button-stop" onclick="UI.stop(this.dataset.location)" template='{"type":"attribute","path":"location","name":"data-location"}'>&projects.stopApp;</button>
|
||||
<button class="device-action project-button-debug" onclick="UI.openToolbox(this.dataset.location)" template='{"type":"attribute","path":"location","name":"data-location"}'>&projects.debugApp;</button>
|
||||
<button class="project-button-update" onclick="UI.update(this, this.dataset.location)" template='{"type":"attribute","path":"location","name":"data-location"}' title="&projects.updateAppTooltip;">&projects.updateApp;</button>
|
||||
<button class="device-action project-button-debug" onclick="UI.debug(this, this.dataset.location)" template='{"type":"attribute","path":"location","name":"data-location"}' title="&projects.debugAppTooltip;">&projects.debugApp;</button>
|
||||
</div>
|
||||
<div class="project-errors" template='{"type":"textContent","path":"errors"}'></div>
|
||||
<div class="project-warnings" template='{"type":"textContent","path":"warnings"}'></div>
|
||||
|
|
|
@ -66,11 +66,10 @@
|
|||
<!ENTITY projects.title "Local Apps">
|
||||
<!ENTITY projects.appDetails "App Details">
|
||||
<!ENTITY projects.removeAppFromList "Remove this app from the list of apps you are working on. This will not remove it from a device or a simulator.">
|
||||
<!ENTITY projects.reloadFiles "Refresh">
|
||||
<!ENTITY projects.installApp "Install">
|
||||
<!ENTITY projects.startApp "Start">
|
||||
<!ENTITY projects.stopApp "Stop">
|
||||
<!ENTITY projects.updateApp "Update">
|
||||
<!ENTITY projects.updateAppTooltip "Execute validation checks and update the app to the connected device">
|
||||
<!ENTITY projects.debugApp "Debug">
|
||||
<!ENTITY projects.debugAppTooltip "Open Developer Tools connected to this app">
|
||||
<!ENTITY projects.hostedManifestPlaceHolder2 "http://example.com/app/manifest.webapp">
|
||||
<!ENTITY projects.noProjects "No projects. Add a new packaged app below (local directory) or a hosted app (link to a manifest file).">
|
||||
|
||||
|
|
|
@ -358,31 +358,11 @@ strong {
|
|||
color: #FFF;
|
||||
}
|
||||
|
||||
.project-button-install,
|
||||
.project-button-start {
|
||||
color: #18BC9C
|
||||
}
|
||||
|
||||
.project-button-install:hover,
|
||||
.project-button-start:hover {
|
||||
background-color: #18BC9C;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
.project-button-stop {
|
||||
color: #E74C3C;
|
||||
}
|
||||
|
||||
.project-button-stop:hover {
|
||||
background-color: #E74C3C;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
.project-button-refresh {
|
||||
.project-button-update {
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.project-button-refresh:hover {
|
||||
.project-button-update:hover {
|
||||
background-color: #777;
|
||||
color: #FFF;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче