remove if else to show permission add option also in repos without any permissions

This commit is contained in:
Maren Süwer
2018-09-03 14:19:44 +02:00
parent 0acaca78b0
commit 1e68060a98

View File

@@ -15,7 +15,6 @@ import {
import Loading from "../../components/Loading"; import Loading from "../../components/Loading";
import ErrorPage from "../../components/ErrorPage"; import ErrorPage from "../../components/ErrorPage";
import type { import type {
Permission,
PermissionCollection, PermissionCollection,
PermissionEntry PermissionEntry
} from "../types/Permissions"; } from "../types/Permissions";
@@ -70,6 +69,7 @@ class Permissions extends React.Component<Props> {
loadingCreatePermission, loadingCreatePermission,
hasPermissionToCreate hasPermissionToCreate
} = this.props; } = this.props;
console.log(permissions);
if (error) { if (error) {
return ( return (
@@ -98,36 +98,32 @@ class Permissions extends React.Component<Props> {
loading={loadingCreatePermission} loading={loadingCreatePermission}
/> />
) : null; ) : null;
return (
if (permissions.length > 0) <div>
return ( <table className="table is-hoverable is-fullwidth">
<div> <thead>
<table className="table is-hoverable is-fullwidth"> <tr>
<thead> <th>{t("permission.name")}</th>
<tr> <th className="is-hidden-mobile">{t("permission.type")}</th>
<th>{t("permission.name")}</th> <th>{t("permission.group-permission")}</th>
<th className="is-hidden-mobile">{t("permission.type")}</th> </tr>
<th>{t("permission.group-permission")}</th> </thead>
</tr> <tbody>
</thead> {permissions.map(permission => {
<tbody> return (
{permissions.map((permission, index) => { <SinglePermission
return ( key={permission.name}
<SinglePermission namespace={namespace}
key={index} repoName={repoName}
namespace={namespace} permission={permission}
repoName={repoName} />
permission={permission} );
/> })}
); </tbody>
})} </table>
</tbody> {createPermissionForm}
</table> </div>
{createPermissionForm} );
</div>
);
return <div />;
} }
} }
@@ -142,7 +138,6 @@ const mapStateToProps = (state, ownProps) => {
namespace, namespace,
repoName repoName
); );
console.log(permissions);
const hasPermissionToCreate = hasCreatePermission(state, namespace, repoName); const hasPermissionToCreate = hasCreatePermission(state, namespace, repoName);
return { return {
namespace, namespace,