Merge branch

This commit is contained in:
vpopescu
2022-11-02 15:22:21 +01:00
84 changed files with 1569 additions and 972 deletions

View File

@@ -98,13 +98,13 @@ const AddUser = (props) => {
.then((data) => dispatchPageChange(data, 0))
.then(() => history.push("/"))
.catch(() =>
setErrorAlert(`Failed to update users.`)
setErrorAlert(`Failed to update users.`),
)
: setErrorAlert(
`Failed to create user. ${
data.status == 409 ? "User already exists." : ""
}`
)
}`,
),
)
.catch(() => setErrorAlert(`Failed to create user.`));
}}

View File

@@ -131,7 +131,7 @@ test("Shows a more specific UI error dialogue when user creation returns an impr
});
let errorDialog = screen.getByText(
"Failed to create user. User already exists."
"Failed to create user. User already exists.",
);
expect(errorDialog).toBeVisible();

View File

@@ -81,14 +81,14 @@ const CreateGroup = (props) => {
.then((data) => dispatchPageUpdate(data, 0))
.then(() => history.push("/groups"))
.catch(() =>
setErrorAlert(`Could not update groups list.`)
setErrorAlert(`Could not update groups list.`),
)
: setErrorAlert(
`Failed to create group. ${
data.status == 409
? "Group already exists."
: ""
}`
}`,
);
})
.catch(() => setErrorAlert(`Failed to create group.`));

View File

@@ -107,7 +107,7 @@ test("Shows a more specific UI error dialogue when user creation returns an impr
});
let errorDialog = screen.getByText(
"Failed to create group. Group already exists."
"Failed to create group. Group already exists.",
);
expect(errorDialog).toBeVisible();

View File

@@ -96,8 +96,8 @@ const EditUser = (props) => {
.then(() => history.push("/"))
.catch(() =>
setErrorAlert(
`Could not update users list.`
)
`Could not update users list.`,
),
)
: setErrorAlert(`Failed to edit user.`);
})
@@ -129,7 +129,7 @@ const EditUser = (props) => {
editUser(
username,
updatedUsername != "" ? updatedUsername : username,
admin
admin,
)
.then((data) => {
data.status < 300
@@ -137,7 +137,7 @@ const EditUser = (props) => {
.then((data) => dispatchPageChange(data, 0))
.then(() => history.push("/"))
.catch(() =>
setErrorAlert(`Could not update users list.`)
setErrorAlert(`Could not update users list.`),
)
: setErrorAlert(`Failed to edit user.`);
})

View File

@@ -111,21 +111,18 @@ const GroupEdit = (props) => {
className="btn btn-primary"
onClick={() => {
let new_users = selected.filter(
(e) => !group_data.users.includes(e)
(e) => !group_data.users.includes(e),
);
let removed_users = group_data.users.filter(
(e) => !selected.includes(e)
(e) => !selected.includes(e),
);
let promiseQueue = [];
// check for changes
if (changed) {
if (new_users.length > 0)
promiseQueue.push(addToGroup(new_users, group_data.name));
if (removed_users.length > 0)
promiseQueue.push(
removeFromGroup(removed_users, group_data.name)
);
}
if (new_users.length > 0)
promiseQueue.push(addToGroup(new_users, group_data.name));
if (removed_users.length > 0)
promiseQueue.push(
removeFromGroup(removed_users, group_data.name),
);
if (hasDuplicates(propkeys) == true) {
setErrorAlert(`Duplicate keys found!`);

View File

@@ -90,7 +90,7 @@ const GroupSelect = (props) => {
>
{e}
</div>
)
),
)}
</div>
</div>

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useEffect } from "react";
import { useSelector, useDispatch } from "react-redux";
import PropTypes from "prop-types";
@@ -37,7 +37,7 @@ const Groups = (props) => {
useEffect(() => {
updateGroups(offset, limit).then((data) =>
dispatchPageUpdate(data.items, data._pagination)
dispatchPageUpdate(data.items, data._pagination),
);
}, [offset, limit]);

View File

@@ -38,11 +38,11 @@ const ServerDashboard = (props) => {
adminAsc = (e) => e.sort((a) => (a.admin ? 1 : -1)),
dateDesc = (e) =>
e.sort((a, b) =>
new Date(a.last_activity) - new Date(b.last_activity) > 0 ? -1 : 1
new Date(a.last_activity) - new Date(b.last_activity) > 0 ? -1 : 1,
),
dateAsc = (e) =>
e.sort((a, b) =>
new Date(a.last_activity) - new Date(b.last_activity) > 0 ? 1 : -1
new Date(a.last_activity) - new Date(b.last_activity) > 0 ? 1 : -1,
),
runningAsc = (e) => e.sort((a) => (a.server == null ? -1 : 1)),
runningDesc = (e) => e.sort((a) => (a.server == null ? 1 : -1));
@@ -136,7 +136,7 @@ const ServerDashboard = (props) => {
dispatchPageUpdate(
data.items,
data._pagination,
name_filter
name_filter,
);
})
.catch(() => {
@@ -176,7 +176,7 @@ const ServerDashboard = (props) => {
dispatchPageUpdate(
data.items,
data._pagination,
name_filter
name_filter,
);
})
.catch(() => {
@@ -471,7 +471,7 @@ const ServerDashboard = (props) => {
failedServers.length > 1 ? "servers" : "server"
}. ${
failedServers.length > 1 ? "Are they " : "Is it "
} already running?`
} already running?`,
);
}
return res;
@@ -482,11 +482,11 @@ const ServerDashboard = (props) => {
dispatchPageUpdate(
data.items,
data._pagination,
name_filter
name_filter,
);
})
.catch(() =>
setErrorAlert(`Failed to update users list.`)
setErrorAlert(`Failed to update users list.`),
);
return res;
})
@@ -511,7 +511,7 @@ const ServerDashboard = (props) => {
failedServers.length > 1 ? "servers" : "server"
}. ${
failedServers.length > 1 ? "Are they " : "Is it "
} already stopped?`
} already stopped?`,
);
}
return res;
@@ -522,11 +522,11 @@ const ServerDashboard = (props) => {
dispatchPageUpdate(
data.items,
data._pagination,
name_filter
name_filter,
);
})
.catch(() =>
setErrorAlert(`Failed to update users list.`)
setErrorAlert(`Failed to update users list.`),
);
return res;
})

View File

@@ -369,7 +369,7 @@ test("Shows a UI error dialogue when start all servers fails", async () => {
/>
</Switch>
</HashRouter>
</Provider>
</Provider>,
);
});
@@ -403,7 +403,7 @@ test("Shows a UI error dialogue when stop all servers fails", async () => {
/>
</Switch>
</HashRouter>
</Provider>
</Provider>,
);
});
@@ -437,7 +437,7 @@ test("Shows a UI error dialogue when start user server fails", async () => {
/>
</Switch>
</HashRouter>
</Provider>
</Provider>,
);
});
@@ -471,7 +471,7 @@ test("Shows a UI error dialogue when start user server returns an improper statu
/>
</Switch>
</HashRouter>
</Provider>
</Provider>,
);
});
@@ -505,7 +505,7 @@ test("Shows a UI error dialogue when stop user servers fails", async () => {
/>
</Switch>
</HashRouter>
</Provider>
</Provider>,
);
});
@@ -539,7 +539,7 @@ test("Shows a UI error dialogue when stop user server returns an improper status
/>
</Switch>
</HashRouter>
</Provider>
</Provider>,
);
});
@@ -585,7 +585,7 @@ test("Search for user calls updateUsers with name filter", async () => {
/>
</Switch>
</HashRouter>
</Provider>
</Provider>,
);
});