Update ESLint and Prettier
This commit is contained in:
1 parent
5a9e03db2c
commit
ac980116bd
110 files changed
+2993
-2794
No files matched your search
+41
-39
@@ -38,11 +38,11 @@ const memoizedJsonParse = memoize(JSON.parse);
|
||||
|
||||
const attributes = [
|
||||
{ id: "_id", label: "Username" },
|
||||
{ id: "roles", label: "Roles", type: "multi", options: [] }
|
||||
{ id: "roles", label: "Roles", type: "multi", options: [] },
|
||||
];
|
||||
|
||||
const unpackSmartQuery = memoize(query => {
|
||||
return map(query, e => {
|
||||
const unpackSmartQuery = memoize((query) => {
|
||||
return map(query, (e) => {
|
||||
if (Array.isArray(e) && e[0] === "FUNC" && e[1] === "Q")
|
||||
return smartQuery.unpack("users", e[2], e[3]);
|
||||
return e;
|
||||
@@ -71,7 +71,7 @@ function putActionHandler(action, _object, isNew): Promise<ValidationErrors> {
|
||||
return void resolve({ password: "Password can not be empty" });
|
||||
} else if (password !== confirm) {
|
||||
return void resolve({
|
||||
confirm: "Confirm password doesn't match password"
|
||||
confirm: "Confirm password doesn't match password",
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ function putActionHandler(action, _object, isNew): Promise<ValidationErrors> {
|
||||
|
||||
store
|
||||
.resourceExists("users", id)
|
||||
.then(exists => {
|
||||
.then((exists) => {
|
||||
if (exists && isNew) {
|
||||
store.fulfill(0, Date.now());
|
||||
return void resolve({ _id: "User already exists" });
|
||||
@@ -123,7 +123,7 @@ function putActionHandler(action, _object, isNew): Promise<ValidationErrors> {
|
||||
store.fulfill(0, Date.now());
|
||||
resolve();
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
store.fulfill(0, Date.now());
|
||||
reject(err);
|
||||
});
|
||||
@@ -133,17 +133,19 @@ function putActionHandler(action, _object, isNew): Promise<ValidationErrors> {
|
||||
});
|
||||
}
|
||||
|
||||
const getDownloadUrl = memoize(filter => {
|
||||
const getDownloadUrl = memoize((filter) => {
|
||||
const cols = {};
|
||||
for (const attr of attributes) cols[attr.label] = attr.id;
|
||||
|
||||
return `api/users.csv?${m.buildQueryString({
|
||||
filter: stringify(filter),
|
||||
columns: JSON.stringify(cols)
|
||||
columns: JSON.stringify(cols),
|
||||
})}`;
|
||||
});
|
||||
|
||||
export function init(args): Promise<{}> {
|
||||
export function init(
|
||||
args: Record<string, unknown>
|
||||
): Promise<Record<string, unknown>> {
|
||||
if (!window.authorizer.hasAccess("users", 2)) {
|
||||
return Promise.reject(
|
||||
new Error("You are not authorized to view this page")
|
||||
@@ -157,7 +159,7 @@ export function init(args): Promise<{}> {
|
||||
|
||||
export const component: ClosureComponent = (): Component => {
|
||||
return {
|
||||
view: vnode => {
|
||||
view: (vnode) => {
|
||||
document.title = "Users - GenieACS";
|
||||
|
||||
function showMore(): void {
|
||||
@@ -203,7 +205,7 @@ export const component: ClosureComponent = (): Component => {
|
||||
|
||||
const users = store.fetch("users", filter, {
|
||||
limit: vnode.state["showCount"] || PAGE_SIZE,
|
||||
sort: sort
|
||||
sort: sort,
|
||||
});
|
||||
|
||||
const count = store.count("users", filter);
|
||||
@@ -213,7 +215,7 @@ export const component: ClosureComponent = (): Component => {
|
||||
if (permissions.fulfilled) {
|
||||
for (const attr of attributes) {
|
||||
if (attr.id === "roles")
|
||||
attr.options = [...new Set(permissions.value.map(p => p.role))];
|
||||
attr.options = [...new Set(permissions.value.map((p) => p.role))];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +231,7 @@ export const component: ClosureComponent = (): Component => {
|
||||
attrs["sortAttributes"] = sortAttributes;
|
||||
attrs["onSortChange"] = onSortChange;
|
||||
attrs["downloadUrl"] = downloadUrl;
|
||||
attrs["recordActionsCallback"] = user => {
|
||||
attrs["recordActionsCallback"] = (user) => {
|
||||
return [
|
||||
m(
|
||||
"a",
|
||||
@@ -243,12 +245,12 @@ export const component: ClosureComponent = (): Component => {
|
||||
{
|
||||
base: {
|
||||
_id: user._id,
|
||||
roles: user.roles.split(",")
|
||||
roles: user.roles.split(","),
|
||||
},
|
||||
actionHandler: (action, object) => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
putActionHandler(action, object, false)
|
||||
.then(errors => {
|
||||
.then((errors) => {
|
||||
const errorList = errors
|
||||
? Object.values(errors)
|
||||
: [];
|
||||
@@ -260,19 +262,19 @@ export const component: ClosureComponent = (): Component => {
|
||||
}
|
||||
resolve();
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
notifications.push("error", err.message);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
resource: "users",
|
||||
attributes: attributes
|
||||
attributes: attributes,
|
||||
}
|
||||
)
|
||||
)
|
||||
),
|
||||
];
|
||||
|
||||
if (canWrite) {
|
||||
@@ -283,7 +285,7 @@ export const component: ClosureComponent = (): Component => {
|
||||
onPasswordChange: () => {
|
||||
overlay.close(cb);
|
||||
m.redraw();
|
||||
}
|
||||
},
|
||||
};
|
||||
children.push(m(changePasswordComponent, _attrs));
|
||||
}
|
||||
@@ -291,10 +293,10 @@ export const component: ClosureComponent = (): Component => {
|
||||
return children;
|
||||
};
|
||||
overlay.open(cb);
|
||||
}
|
||||
},
|
||||
},
|
||||
"Show"
|
||||
)
|
||||
),
|
||||
];
|
||||
};
|
||||
|
||||
@@ -305,10 +307,10 @@ export const component: ClosureComponent = (): Component => {
|
||||
attributes[0],
|
||||
{ id: "password", label: "Password", type: "password" },
|
||||
{ id: "confirm", label: "Confirm password", type: "password" },
|
||||
attributes[1]
|
||||
]
|
||||
attributes[1],
|
||||
],
|
||||
};
|
||||
attrs["actionsCallback"] = (selected): Children => {
|
||||
attrs["actionsCallback"] = (selected: Set<string>): Children => {
|
||||
return [
|
||||
m(
|
||||
"button.primary",
|
||||
@@ -321,9 +323,9 @@ export const component: ClosureComponent = (): Component => {
|
||||
Object.assign(
|
||||
{
|
||||
actionHandler: (action, object) => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
putActionHandler(action, object, true)
|
||||
.then(errors => {
|
||||
.then((errors) => {
|
||||
const errorList = errors
|
||||
? Object.values(errors)
|
||||
: [];
|
||||
@@ -335,19 +337,19 @@ export const component: ClosureComponent = (): Component => {
|
||||
}
|
||||
resolve();
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
notifications.push("error", err.message);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
formData
|
||||
)
|
||||
);
|
||||
};
|
||||
overlay.open(cb);
|
||||
}
|
||||
},
|
||||
},
|
||||
"New"
|
||||
),
|
||||
@@ -356,7 +358,7 @@ export const component: ClosureComponent = (): Component => {
|
||||
{
|
||||
title: "Delete selected users",
|
||||
disabled: !selected.size,
|
||||
onclick: e => {
|
||||
onclick: (e) => {
|
||||
if (
|
||||
!confirm(`Deleting ${selected.size} users. Are you sure?`)
|
||||
)
|
||||
@@ -365,25 +367,25 @@ export const component: ClosureComponent = (): Component => {
|
||||
e.redraw = false;
|
||||
e.target.disabled = true;
|
||||
Promise.all(
|
||||
Array.from(selected).map(id =>
|
||||
Array.from(selected).map((id) =>
|
||||
store.deleteResource("users", id)
|
||||
)
|
||||
)
|
||||
.then(res => {
|
||||
.then((res) => {
|
||||
notifications.push(
|
||||
"success",
|
||||
`${res.length} users deleted`
|
||||
);
|
||||
store.fulfill(0, Date.now());
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
notifications.push("error", err.message);
|
||||
store.fulfill(0, Date.now());
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
"Delete"
|
||||
)
|
||||
),
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -396,8 +398,8 @@ export const component: ClosureComponent = (): Component => {
|
||||
return [
|
||||
m("h1", "Listing users"),
|
||||
m(filterComponent, filterAttrs),
|
||||
m(indexTableComponent, attrs)
|
||||
m(indexTableComponent, attrs),
|
||||
];
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user