bitbake: toastergui: prevent contamination of libtoaster context
This patch modifies the New Build button to use a local copy of the default libtoaster project context in order to prevent page contamination when a different project is selected in the drop-down menu. (Bitbake rev: 937665bd57dad04dd6bb46d06488b699f5c54d29) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
4f459fca79
commit
379a030702
|
@ -11,7 +11,8 @@ function basePageInit(ctx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentProjectId = libtoaster.ctx.projectId;
|
var selectedProject = libtoaster.ctx;
|
||||||
|
var selectedTarget;
|
||||||
|
|
||||||
/* Hide the change project icon when there is only one project */
|
/* Hide the change project icon when there is only one project */
|
||||||
if (ctx.numProjects === 1) {
|
if (ctx.numProjects === 1) {
|
||||||
|
@ -27,18 +28,16 @@ function basePageInit(ctx) {
|
||||||
var newBuildProjectSaveBtn = $("#new-build-button #save-project-button");
|
var newBuildProjectSaveBtn = $("#new-build-button #save-project-button");
|
||||||
|
|
||||||
|
|
||||||
var selectedTarget;
|
|
||||||
|
|
||||||
_checkProjectBuildable();
|
_checkProjectBuildable();
|
||||||
_setupNewBuildButton();
|
_setupNewBuildButton();
|
||||||
|
|
||||||
|
|
||||||
function _checkProjectBuildable() {
|
function _checkProjectBuildable() {
|
||||||
if (libtoaster.ctx.projectId === undefined) {
|
if (selectedProject.projectId === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl,
|
libtoaster.getProjectInfo(selectedProject.projectPageUrl,
|
||||||
function (data) {
|
function (data) {
|
||||||
if (data.machine.name === undefined || data.layers.length === 0) {
|
if (data.machine.name === undefined || data.layers.length === 0) {
|
||||||
/* we can't build anything with out a machine and some layers */
|
/* we can't build anything with out a machine and some layers */
|
||||||
|
@ -52,9 +51,14 @@ function basePageInit(ctx) {
|
||||||
newBuildTargetInput.prop("disabled", false);
|
newBuildTargetInput.prop("disabled", false);
|
||||||
newBuildTargetBuildBtn.prop("disabled", false);
|
newBuildTargetBuildBtn.prop("disabled", false);
|
||||||
|
|
||||||
libtoaster.makeTypeahead(newBuildTargetInput, libtoaster.ctx.projectTargetsUrl, { format: "json" }, function (item) {
|
libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function (item) {
|
||||||
/* successfully selected a target */
|
/* successfully selected a target */
|
||||||
selectedTarget = item;
|
selectedProject.projectPageUrl = item.projectPageUrl;
|
||||||
|
selectedProject.projectName = item.name;
|
||||||
|
selectedProject.projectId = item.id;
|
||||||
|
selectedProject.projectBuildsUrl = item.projectBuildsUrl;
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,18 +67,17 @@ function basePageInit(ctx) {
|
||||||
|
|
||||||
function _setupNewBuildButton() {
|
function _setupNewBuildButton() {
|
||||||
/* Setup New build button */
|
/* Setup New build button */
|
||||||
var selectedProject;
|
|
||||||
|
|
||||||
/* If we don't have a current project then present the set project
|
/* If we don't have a current project then present the set project
|
||||||
* form.
|
* form.
|
||||||
*/
|
*/
|
||||||
if (libtoaster.ctx.projectId === undefined) {
|
if (selectedProject.projectId === undefined) {
|
||||||
$('#change-project-form').show();
|
$('#change-project-form').show();
|
||||||
$('#project .icon-pencil').hide();
|
$('#project .icon-pencil').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
libtoaster.makeTypeahead(newBuildProjectInput, libtoaster.ctx.projectsUrl, { format : "json" }, function (item) {
|
libtoaster.makeTypeahead(newBuildProjectInput, selectedProject.projectsUrl, { format : "json" }, function (item) {
|
||||||
/* successfully selected a project */
|
/* successfully selected a project */
|
||||||
newBuildProjectSaveBtn.removeAttr("disabled");
|
newBuildProjectSaveBtn.removeAttr("disabled");
|
||||||
selectedProject = item;
|
selectedProject = item;
|
||||||
|
@ -107,23 +110,18 @@ function basePageInit(ctx) {
|
||||||
selectedTarget = { name: newBuildTargetInput.val() };
|
selectedTarget = { name: newBuildTargetInput.val() };
|
||||||
}
|
}
|
||||||
/* fire and forget */
|
/* fire and forget */
|
||||||
libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, libtoaster.ctx.projectId, selectedTarget.name, null, null);
|
libtoaster.startABuild(selectedProject.projectBuildsUrl, selectedProject.projectId, selectedTarget.name, null, null);
|
||||||
window.location.replace(libtoaster.ctx.projectPageUrl);
|
window.location.replace(selectedProject.projectPageUrl);
|
||||||
});
|
});
|
||||||
|
|
||||||
newBuildProjectSaveBtn.click(function () {
|
newBuildProjectSaveBtn.click(function () {
|
||||||
libtoaster.ctx.projectId = selectedProject.pk;
|
selectedProject.projectId = selectedProject.pk;
|
||||||
/* Update the typeahead project_id paramater */
|
/* Update the typeahead project_id paramater */
|
||||||
_checkProjectBuildable();
|
_checkProjectBuildable();
|
||||||
|
|
||||||
/* we set the effective context of the page to the currently selected project */
|
/* we set the effective context of the page to the currently selected project */
|
||||||
/* TBD: do we override even if we already have a context project ?? */
|
/* TBD: do we override even if we already have a context project ?? */
|
||||||
/* TODO: replace global library context with references to the "selected" project */
|
/* TODO: replace global library context with references to the "selected" project */
|
||||||
libtoaster.ctx.projectPageUrl = selectedProject.projectPageUrl;
|
|
||||||
libtoaster.ctx.projectName = selectedProject.name;
|
|
||||||
libtoaster.ctx.projectId = selectedProject.id;
|
|
||||||
|
|
||||||
ctx.projectBuildsUrl = selectedProject.projectBuildsUrl;
|
|
||||||
|
|
||||||
/* we can create a target typeahead only after we have a project selected */
|
/* we can create a target typeahead only after we have a project selected */
|
||||||
newBuildTargetInput.prop("disabled", false);
|
newBuildTargetInput.prop("disabled", false);
|
||||||
|
@ -137,8 +135,8 @@ function basePageInit(ctx) {
|
||||||
newBuildTargetInput.val("");
|
newBuildTargetInput.val("");
|
||||||
|
|
||||||
/* set up new form aspect */
|
/* set up new form aspect */
|
||||||
$("#new-build-button #project a").text(selectedProject.name).attr('href', libtoaster.ctx.projectPageUrl);
|
$("#new-build-button #project a").text(selectedProject.name).attr('href', selectedProject.projectPageUrl);
|
||||||
$("#new-build-button .alert a").attr('href', libtoaster.ctx.projectPageUrl);
|
$("#new-build-button .alert a").attr('href', selectedProject.projectPageUrl);
|
||||||
$("#project .icon-pencil").show();
|
$("#project .icon-pencil").show();
|
||||||
|
|
||||||
$("#change-project-form").slideUp({ 'complete' : function () {
|
$("#change-project-form").slideUp({ 'complete' : function () {
|
||||||
|
|
Loading…
Reference in New Issue