Fix error editing preset when missing permissions
This commit is contained in:
1 parent
2a3d155e85
commit
9a5f259c87
2 files changed
+30
-21
No files matched your search
+16
-16
@@ -212,30 +212,30 @@ export const component: ClosureComponent = (): Component => {
|
||||
const count = store.count("presets", filter);
|
||||
|
||||
const userDefinedProvisions: Set<string> = new Set();
|
||||
|
||||
const provisionIds = new Set([
|
||||
"refresh",
|
||||
"value",
|
||||
"tag",
|
||||
"reboot",
|
||||
"reset",
|
||||
"download",
|
||||
"instances"
|
||||
]);
|
||||
|
||||
const provisions = store.fetch("provisions", true);
|
||||
if (provisions.fulfilled) {
|
||||
const provisionAttr = attributes.find(attr => {
|
||||
return attr.id === "provision";
|
||||
});
|
||||
|
||||
const provisionIds = new Set([
|
||||
"refresh",
|
||||
"value",
|
||||
"tag",
|
||||
"reboot",
|
||||
"reset",
|
||||
"download",
|
||||
"instances"
|
||||
]);
|
||||
|
||||
for (const p of provisions.value) {
|
||||
userDefinedProvisions.add(p["_id"]);
|
||||
provisionIds.add(p["_id"]);
|
||||
}
|
||||
|
||||
provisionAttr["options"] = Array.from(provisionIds);
|
||||
}
|
||||
|
||||
const provisionAttr = attributes.find(attr => {
|
||||
return attr.id === "provision";
|
||||
});
|
||||
provisionAttr["options"] = Array.from(provisionIds);
|
||||
|
||||
const downloadUrl = getDownloadUrl(filter);
|
||||
|
||||
const valueCallback = (attr, preset): {} => {
|
||||
|
||||
@@ -32,12 +32,18 @@ const singular = {
|
||||
|
||||
function createField(current, attr, focus): Children {
|
||||
if (attr.type === "combo") {
|
||||
const options = [m("option", { value: "" }, "--Please choose--")];
|
||||
for (const op of attr.options) options.push(m("option", { value: op }, op));
|
||||
|
||||
let selected = "";
|
||||
if (attr.options.includes(current.object[attr.id]))
|
||||
let optionsValues = attr.options;
|
||||
if (current.object[attr.id] != null) {
|
||||
if (!optionsValues.includes(current.object[attr.id]))
|
||||
optionsValues = optionsValues.concat([current.object[attr.id]]);
|
||||
selected = current.object[attr.id];
|
||||
}
|
||||
|
||||
const options = [m("option", { value: "" }, "")];
|
||||
for (const op of optionsValues)
|
||||
options.push(m("option", { value: op }, op));
|
||||
|
||||
return m(
|
||||
"select",
|
||||
{
|
||||
@@ -56,8 +62,11 @@ function createField(current, attr, focus): Children {
|
||||
options
|
||||
);
|
||||
} else if (attr.type === "multi") {
|
||||
const optionsValues = Array.from(
|
||||
new Set(attr.options.concat(current.object[attr.id] || []))
|
||||
);
|
||||
const currentSelected = new Set(current.object[attr.id]);
|
||||
const options = attr.options.map(op => {
|
||||
const options = optionsValues.map(op => {
|
||||
const id = `${attr.id}-${op}`;
|
||||
const opts = {
|
||||
type: "checkbox",
|
||||
|
||||
Reference in new issue
Block a user