1
0
Fork 0

Aardvark: allow (un-)mounting non-internal system apps, prohibit mounting reserved paths.

This commit is contained in:
Alan Plum 2014-07-01 11:42:47 +02:00
parent 369485b129
commit 00a0b4513a
3 changed files with 67 additions and 61 deletions

View File

@ -31,5 +31,5 @@
</span>
</div>
<%}%>
<h5 class="collectionName"><%= appInfos[1] %><%= attributes.isSystem ? " (system)" : "" %><%= appInfos[0] === "dev" ? " (dev)" : ""%></h5>
<h5 class="collectionName"><%= appInfos[1] %><%= attributes.isSystem && attributes.mount.charAt(0) === "/" && attributes.mount.charAt(1) === "_" ? " (system)" : "" %><%= appInfos[0] === "dev" ? " (dev)" : ""%></h5>
</script>

View File

@ -27,6 +27,15 @@
initialize: function(){
this._show = true;
var mount = this.model.get("mount");
var isSystem = (
this.model.get("isSystem") &&
mount.charAt(0) === '/' &&
mount.charAt(1) === '_'
);
if (isSystem) {
this.buttonConfig = [];
} else {
this.buttonConfig = [
window.modalView.createDeleteButton(
"Uninstall", this.uninstall.bind(this)
@ -35,6 +44,7 @@
"Save", this.changeFoxx.bind(this)
)
];
}
this.showMod = window.modalView.show.bind(
window.modalView,
"modalTable.ejs",
@ -72,6 +82,12 @@
isSystem,
active,
modView = window.modalView;
var mount = this.model.get("mount");
var editable = !(
this.model.get("isSystem") &&
mount.charAt(0) === '/' &&
mount.charAt(1) === '_'
);
if (this.model.get("isSystem")) {
isSystem = "Yes";
} else {
@ -85,6 +101,7 @@
list.push(modView.createReadOnlyEntry(
"id_name", "Name", name
));
if (editable) {
list.push(modView.createTextEntry(
"change-mount-point", "Mount", this.model.get("mount"),
"The path where the app can be reached.",
@ -97,6 +114,11 @@
}
]
));
} else {
list.push(modView.createReadOnlyEntry(
"change-mount-point", "Mount", this.model.get("mount")
));
}
/*
* For the future, update apps to available newer versions
* versOptions.push(modView.createOptionEntry(appInfos[2]));
@ -116,9 +138,15 @@
editFoxxDialog: function(event) {
event.stopPropagation();
if (this.model.get("isSystem") || this.model.get("development")) {
var mount = this.model.get("mount");
var isSystem = (
this.model.get("isSystem") &&
mount.charAt(0) === '/' &&
mount.charAt(1) === '_'
);
if (this.model.get("development")) {
this.buttonConfig[0].disabled = true;
} else {
} else if (!isSystem) {
delete this.buttonConfig[0].disabled;
}
this.showMod(this.buttonConfig, this.fillValues());
@ -163,11 +191,9 @@
},
uninstall: function () {
if (!this.model.get("isSystem")) {
this.model.destroy({ async: false });
window.modalView.hide();
this.appsView.reload();
}
},
showDocu: function(event) {

View File

@ -91,8 +91,6 @@
"Install", this.installDialog.bind(this)
)
];
var buttonSystemInfoConfig = [
];
this.showMod = window.modalView.show.bind(
window.modalView,
"modalTable.ejs",
@ -123,12 +121,6 @@
"Application Settings",
buttonInfoMultipleVersionsConfigUpdate
);
this.showSystemInfoMod = window.modalView.show.bind(
window.modalView,
"modalTable.ejs",
"Application Settings",
buttonSystemInfoConfig
);
this.showPurgeMod = window.modalView.show.bind(
window.modalView,
"modalTable.ejs",
@ -334,38 +326,23 @@
infoDialog: function(event) {
var name = this.model.get("name"),
mountinfo = this.model.collection.gitInfo(name),
versions, isSystem = false, isGit;
isGit;
if (mountinfo.git === true) {
this.model.set("isGit", mountinfo.git);
this.model.set("gitUrl", mountinfo.url);
}
if (this.model.get("isSystem")) {
isSystem = true;
} else {
isSystem = false;
}
versions = this.model.get("versions");
isGit = this.model.get("isGit");
event.stopPropagation();
if (isSystem === false && !versions && !isGit) {
this.showInfoMod(this.fillInfoValues());
}
else if (isSystem === false && !versions && isGit) {
this.showInfoModUpdate(this.fillInfoValues());
}
else if (isSystem === false && versions && !isGit) {
this.showInfoMultipleVersionsMod(this.fillInfoValues());
}
else if (isSystem === false && versions && isGit) {
this.showInfoMultipleVersionsModUpdate(this.fillInfoValues());
}
else {
this.showSystemInfoMod(this.fillInfoValues());
}
this[
this.model.get("versions")
? (isGit ? 'showInfoMultipleVersionsModUpdate' : 'showInfoMultipleVersionsMod')
: (isGit ? 'showInfoModUpdate' : 'showInfoMod')
](this.fillInfoValues());
this.selectHighestVersion();
},
@ -401,9 +378,12 @@
install: function() {
var mountPoint = $("#mount-point").val(),
version = "",
regex = /^(\/[^\/\s]+)+$/,
self = this;
if (!regex.test(mountPoint)){
if (/^\/_.+$/.test(mountPoint)) {
alert("Sorry, mount paths starting with an underscore are reserved for internal use.");
return false;
}
if (!/^(\/[^\/\s]+)+$/.test(mountPoint)){
alert("Sorry, you have to give a valid mount point, e.g.: /myPath");
return false;
}