Fix getPermissions() crash issue.
This commit is contained in:
parent
98113c7663
commit
b3f5d9ea06
|
@ -1,10 +1,11 @@
|
|||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import {render} from "@testing-library/react";
|
||||
import App from "./App";
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
it("renders without crashing", () => {
|
||||
const div = document.createElement("div");
|
||||
ReactDOM.render(<App />, div);
|
||||
ReactDOM.unmountComponentAtNode(div);
|
||||
test("renders learn react link", () => {
|
||||
const {getByText} = render(<App />);
|
||||
const linkElement = getByText(/learn react/i);
|
||||
// eslint-disable-next-line no-undef
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
||||
|
|
|
@ -67,15 +67,15 @@ class FileTree extends React.Component {
|
|||
|
||||
getPermissions() {
|
||||
PermissionBackend.getPermissions(Conf.AuthConfig.organizationName)
|
||||
.then((permissions) => {
|
||||
if (permissions.status === "ok") {
|
||||
permissions = permissions.filter(permission => (permission.domains[0] === this.props.store.name) && permission.users.length !== 0);
|
||||
.then((res) => {
|
||||
if (res.status === "ok") {
|
||||
const permissions = res.data.filter(permission => (permission.domains[0] === this.props.store.name) && permission.users.length !== 0);
|
||||
this.setState({
|
||||
permissions: permissions,
|
||||
permissionMap: this.getPermissionMap(permissions),
|
||||
});
|
||||
} else {
|
||||
Setting.showMessage("error", `Failed to get permissions: ${permissions.msg}`);
|
||||
Setting.showMessage("error", `Failed to get permissions: ${res.msg}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue