mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 22:15:45 +01:00
added view and edit of admin user and groups
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { Checkbox, InputField } from "../../../components/forms/index";
|
||||
import Subtitle from "../../../components/layout/Subtitle";
|
||||
import AdminGroupTable from "../table/AdminGroupTable";
|
||||
import ProxySettings from "./ProxySettings";
|
||||
import AdminUserTable from "../table/AdminUserTable";
|
||||
import AddAdminGroupField from "../fields/AddAdminGroupField";
|
||||
import AddAdminUserField from "../fields/AddAdminUserField";
|
||||
|
||||
type Props = {
|
||||
adminGroups: string[],
|
||||
@@ -13,17 +17,58 @@ type Props = {
|
||||
//TODO: Einbauen!
|
||||
class AdminSettings extends React.Component<Props> {
|
||||
render() {
|
||||
const {
|
||||
t,
|
||||
adminGroups,
|
||||
adminUsers
|
||||
} = this.props;
|
||||
const { t, adminGroups, adminUsers } = this.props;
|
||||
|
||||
return (
|
||||
null
|
||||
<div>
|
||||
<Subtitle subtitle={t("admin-settings.name")} />
|
||||
<AdminGroupTable
|
||||
adminGroups={adminGroups}
|
||||
onChange={(isValid, changedValue, name) =>
|
||||
this.props.onChange(isValid, changedValue, name)
|
||||
}
|
||||
/>
|
||||
<AddAdminGroupField addGroup={this.addGroup} />
|
||||
<AdminUserTable
|
||||
adminUsers={adminUsers}
|
||||
onChange={(isValid, changedValue, name) =>
|
||||
this.props.onChange(isValid, changedValue, name)
|
||||
}
|
||||
/>
|
||||
<AddAdminUserField addUser={this.addUser} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
addGroup = (groupname: string) => {
|
||||
if (this.isAdminGroupMember(groupname)) {
|
||||
return;
|
||||
}
|
||||
this.props.onChange(
|
||||
true,
|
||||
[...this.props.adminGroups, groupname],
|
||||
"adminGroups"
|
||||
);
|
||||
};
|
||||
|
||||
isAdminGroupMember = (groupname: string) => {
|
||||
return this.props.adminGroups.includes(groupname);
|
||||
};
|
||||
|
||||
addUser = (username: string) => {
|
||||
if (this.isAdminUserMember(username)) {
|
||||
return;
|
||||
}
|
||||
this.props.onChange(
|
||||
true,
|
||||
[...this.props.adminUsers, username],
|
||||
"adminUsers"
|
||||
);
|
||||
};
|
||||
|
||||
isAdminUserMember = (username: string) => {
|
||||
return this.props.adminUsers.includes(username);
|
||||
};
|
||||
}
|
||||
|
||||
export default translate("config")(AdminSettings);
|
||||
|
||||
Reference in New Issue
Block a user