mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-18 03:01:05 +01:00
Added missing files
hg did not show them as added
This commit is contained in:
4
scm-ui/jest.config.js
Normal file
4
scm-ui/jest.config.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
collectCoverage: true,
|
||||
coverageFormats: ["json", "html"]
|
||||
};
|
||||
29
scm-ui/src/users/containers/EditUserButton.js
Normal file
29
scm-ui/src/users/containers/EditUserButton.js
Normal file
@@ -0,0 +1,29 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import type { User } from "../types/User";
|
||||
|
||||
type Props = {
|
||||
user: User,
|
||||
editUser: User => void
|
||||
};
|
||||
|
||||
type State = {};
|
||||
|
||||
class EditUserButton extends React.Component<Props, State> {
|
||||
render() {
|
||||
if (!this.isEditable()) {
|
||||
return "";
|
||||
}
|
||||
return (
|
||||
<button type="button" onClick={e => this.props.editUser(this.props.user)}>
|
||||
Edit user
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
isEditable = () => {
|
||||
return this.props.user._links.update;
|
||||
};
|
||||
}
|
||||
|
||||
export default EditUserButton;
|
||||
31
scm-ui/src/users/containers/EditUserButton.test.js
Normal file
31
scm-ui/src/users/containers/EditUserButton.test.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import React from "react";
|
||||
import { configure, shallow } from "enzyme";
|
||||
import EditUserButton from "./EditUserButton";
|
||||
import Adapter from "enzyme-adapter-react-16";
|
||||
|
||||
import "raf/polyfill";
|
||||
|
||||
configure({ adapter: new Adapter() });
|
||||
|
||||
it("should render nothing, if the edit link is missing", () => {
|
||||
const user = {
|
||||
_links: {}
|
||||
};
|
||||
|
||||
const button = shallow(<EditUserButton user={user} />);
|
||||
expect(button.text()).toBe("");
|
||||
});
|
||||
|
||||
it("should render the button", () => {
|
||||
const user = {
|
||||
_links: {
|
||||
update: {
|
||||
href: "/users"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const button = shallow(<EditUserButton user={user} />);
|
||||
expect(button.text()).not.toBe("");
|
||||
});
|
||||
|
||||
7
scm-ui/src/users/types/UserEntry.js
Normal file
7
scm-ui/src/users/types/UserEntry.js
Normal file
@@ -0,0 +1,7 @@
|
||||
type UserEntry = {
|
||||
loading: boolean,
|
||||
error: Error,
|
||||
user: User
|
||||
};
|
||||
|
||||
export type UserEntry;
|
||||
Reference in New Issue
Block a user