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