Clean and lint

This commit is contained in:
Nathan Barber
2021-12-01 01:52:18 -05:00
parent c0d5778d93
commit 999cc0a37c
6 changed files with 32 additions and 35 deletions

View File

@@ -71,7 +71,7 @@ const AddUser = (props) => {
type="checkbox" type="checkbox"
id="admin-check" id="admin-check"
checked={admin} checked={admin}
onChange={(e) => setAdmin(!admin)} onChange={() => setAdmin(!admin)}
/> />
<span> </span> <span> </span>
<label className="form-check-label">Admin</label> <label className="form-check-label">Admin</label>
@@ -104,14 +104,16 @@ const AddUser = (props) => {
? updateUsers(0, limit) ? updateUsers(0, limit)
.then((data) => dispatchPageChange(data, 0)) .then((data) => dispatchPageChange(data, 0))
.then(() => history.push("/")) .then(() => history.push("/"))
.catch((err) => console.log(err)) .catch(() =>
setErrorAlert(`Failed to update users.`)
)
: setErrorAlert( : setErrorAlert(
`Failed to create user. ${ `Failed to create user. ${
data.status == 409 ? "User already exists." : "" data.status == 409 ? "User already exists." : ""
}` }`
) )
) )
.catch((err) => setErrorAlert(`Failed to create user.`)); .catch(() => setErrorAlert(`Failed to create user.`));
}} }}
> >
Add Users Add Users

View File

@@ -80,7 +80,7 @@ const CreateGroup = (props) => {
? updateGroups(0, limit) ? updateGroups(0, limit)
.then((data) => dispatchPageUpdate(data, 0)) .then((data) => dispatchPageUpdate(data, 0))
.then(() => history.push("/groups")) .then(() => history.push("/groups"))
.catch((err) => .catch(() =>
setErrorAlert(`Could not update groups list.`) setErrorAlert(`Could not update groups list.`)
) )
: setErrorAlert( : setErrorAlert(
@@ -91,7 +91,7 @@ const CreateGroup = (props) => {
}` }`
); );
}) })
.catch((err) => setErrorAlert(`Failed to create group.`)); .catch(() => setErrorAlert(`Failed to create group.`));
}} }}
> >
Create Create

View File

@@ -19,14 +19,7 @@ const EditUser = (props) => {
}); });
}; };
var { var { editUser, deleteUser, noChangeEvent, updateUsers, history } = props;
editUser,
deleteUser,
failRegexEvent,
noChangeEvent,
updateUsers,
history,
} = props;
if (props.location.state == undefined) { if (props.location.state == undefined) {
props.history.push("/"); props.history.push("/");
@@ -101,14 +94,14 @@ const EditUser = (props) => {
? updateUsers(0, limit) ? updateUsers(0, limit)
.then((data) => dispatchPageChange(data, 0)) .then((data) => dispatchPageChange(data, 0))
.then(() => history.push("/")) .then(() => history.push("/"))
.catch((err) => .catch(() =>
setErrorAlert( setErrorAlert(
`Could not update users list.` `Could not update users list.`
) )
) )
: setErrorAlert(`Failed to edit user.`); : setErrorAlert(`Failed to edit user.`);
}) })
.catch((err) => { .catch(() => {
setErrorAlert(`Failed to edit user.`); setErrorAlert(`Failed to edit user.`);
}); });
}} }}
@@ -147,14 +140,14 @@ const EditUser = (props) => {
? updateUsers(0, limit) ? updateUsers(0, limit)
.then((data) => dispatchPageChange(data, 0)) .then((data) => dispatchPageChange(data, 0))
.then(() => history.push("/")) .then(() => history.push("/"))
.catch((err) => .catch(() =>
setErrorAlert( setErrorAlert(
`Could not update users list.` `Could not update users list.`
) )
) )
: setErrorAlert(`Failed to edit user.`); : setErrorAlert(`Failed to edit user.`);
}) })
.catch((err) => { .catch(() => {
setErrorAlert(`Failed to edit user.`); setErrorAlert(`Failed to edit user.`);
}); });
} else { } else {
@@ -169,12 +162,12 @@ const EditUser = (props) => {
? updateUsers(0, limit) ? updateUsers(0, limit)
.then((data) => dispatchPageChange(data, 0)) .then((data) => dispatchPageChange(data, 0))
.then(() => history.push("/")) .then(() => history.push("/"))
.catch((err) => .catch(() =>
setErrorAlert(`Could not update users list.`) setErrorAlert(`Could not update users list.`)
) )
: setErrorAlert(`Failed to edit user.`); : setErrorAlert(`Failed to edit user.`);
}) })
.catch((err) => { .catch(() => {
setErrorAlert(`Failed to edit user.`); setErrorAlert(`Failed to edit user.`);
}); });
} }

View File

@@ -116,7 +116,7 @@ const GroupEdit = (props) => {
.then(() => history.push("/groups")) .then(() => history.push("/groups"))
: setErrorAlert(`Failed to edit group.`); : setErrorAlert(`Failed to edit group.`);
}) })
.catch((err) => setErrorAlert(`Failed to edit group.`)); .catch(() => setErrorAlert(`Failed to edit group.`));
}} }}
> >
Apply Apply
@@ -137,7 +137,7 @@ const GroupEdit = (props) => {
.then(() => history.push("/groups")) .then(() => history.push("/groups"))
: setErrorAlert(`Failed to delete group.`); : setErrorAlert(`Failed to delete group.`);
}) })
.catch((err) => setErrorAlert(`Failed to delete group.`)); .catch(() => setErrorAlert(`Failed to delete group.`));
}} }}
> >
Delete Group Delete Group

View File

@@ -169,14 +169,12 @@ const ServerDashboard = (props) => {
.then((data) => { .then((data) => {
dispatchPageUpdate(data, page); dispatchPageUpdate(data, page);
}) })
.catch((err) => .catch(() =>
setErrorAlert(`Failed to update users list.`) setErrorAlert(`Failed to update users list.`)
); );
return res; return res;
}) })
.catch((err) => .catch(() => setErrorAlert(`Failed to start servers.`));
setErrorAlert(`Failed to start servers.`)
);
}} }}
> >
Start All Start All
@@ -207,12 +205,12 @@ const ServerDashboard = (props) => {
.then((data) => { .then((data) => {
dispatchPageUpdate(data, page); dispatchPageUpdate(data, page);
}) })
.catch((err) => .catch(() =>
setErrorAlert(`Failed to update users list.`) setErrorAlert(`Failed to update users list.`)
); );
return res; return res;
}) })
.catch((err) => setErrorAlert(`Failed to stop servers.`)); .catch(() => setErrorAlert(`Failed to stop servers.`));
}} }}
> >
Stop All Stop All
@@ -249,7 +247,7 @@ const ServerDashboard = (props) => {
.then((data) => { .then((data) => {
dispatchPageUpdate(data, page); dispatchPageUpdate(data, page);
}) })
.catch((err) => .catch(() =>
setErrorAlert( setErrorAlert(
`Failed to update users list.` `Failed to update users list.`
) )
@@ -257,9 +255,7 @@ const ServerDashboard = (props) => {
: setErrorAlert(`Failed to stop server`); : setErrorAlert(`Failed to stop server`);
return res; return res;
}) })
.catch((err) => .catch(() => setErrorAlert(`Failed to stop server.`))
setErrorAlert(`Failed to stop server.`)
)
} }
> >
Stop Server Stop Server
@@ -276,7 +272,7 @@ const ServerDashboard = (props) => {
.then((data) => { .then((data) => {
dispatchPageUpdate(data, page); dispatchPageUpdate(data, page);
}) })
.catch((err) => .catch(() =>
setErrorAlert( setErrorAlert(
`Failed to update users list.` `Failed to update users list.`
) )
@@ -284,7 +280,7 @@ const ServerDashboard = (props) => {
: setErrorAlert(`Failed to start server`); : setErrorAlert(`Failed to start server`);
return res; return res;
}) })
.catch((err) => { .catch(() => {
setErrorAlert(`Failed to start server.`); setErrorAlert(`Failed to start server.`);
}) })
} }

View File

@@ -37,8 +37,14 @@ const withAPI = withProps(() => ({
jhapiRequest("/users/" + username, "GET") jhapiRequest("/users/" + username, "GET")
.then((data) => data.status) .then((data) => data.status)
.then((data) => (data > 200 ? false : true)), .then((data) => (data > 200 ? false : true)),
failRegexEvent: () => {}, // Temporarily Unused
noChangeEvent: () => {}, failRegexEvent: () => {
return null;
},
noChangeEvent: () => {
return null;
},
//
refreshGroupsData: () => refreshGroupsData: () =>
jhapiRequest("/groups", "GET").then((data) => data.json()), jhapiRequest("/groups", "GET").then((data) => data.json()),
refreshUserData: () => refreshUserData: () =>