2018-08-16 10:55:39 +02:00
|
|
|
//@flow
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { translate } from "react-i18next";
|
2018-08-21 11:27:35 +02:00
|
|
|
import { RemoveEntryOfTableButton } from "../../../components/buttons";
|
2018-08-16 10:55:39 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
adminGroups: string[],
|
|
|
|
|
t: string => string,
|
2018-08-16 12:12:59 +02:00
|
|
|
onChange: (boolean, any, string) => void,
|
|
|
|
|
disabled: boolean
|
2018-08-16 10:55:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type State = {};
|
|
|
|
|
|
|
|
|
|
class AdminGroupTable extends React.Component<Props, State> {
|
|
|
|
|
render() {
|
2018-08-16 12:12:59 +02:00
|
|
|
const { t, disabled } = this.props;
|
2018-08-16 10:55:39 +02:00
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<label className="label">{t("admin-settings.admin-groups")}</label>
|
|
|
|
|
<table className="table is-hoverable is-fullwidth">
|
|
|
|
|
<tbody>
|
|
|
|
|
{this.props.adminGroups.map(group => {
|
|
|
|
|
return (
|
|
|
|
|
<tr key={group}>
|
|
|
|
|
<td key={group}>{group}</td>
|
|
|
|
|
<td>
|
2018-08-21 11:27:35 +02:00
|
|
|
<RemoveEntryOfTableButton
|
|
|
|
|
entryname={group}
|
|
|
|
|
removeEntry={this.removeEntry}
|
2018-08-16 12:12:59 +02:00
|
|
|
disabled={disabled}
|
2018-08-21 11:27:35 +02:00
|
|
|
label={t("admin-settings.remove-group-button")}
|
2018-08-16 10:55:39 +02:00
|
|
|
/>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 11:27:35 +02:00
|
|
|
removeEntry = (groupname: string) => {
|
2018-08-16 10:55:39 +02:00
|
|
|
const newGroups = this.props.adminGroups.filter(name => name !== groupname);
|
|
|
|
|
this.props.onChange(true, newGroups, "adminGroups");
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default translate("config")(AdminGroupTable);
|