mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-18 03:01:05 +01:00
refactoring
This commit is contained in:
@@ -1,23 +0,0 @@
|
|||||||
// @flow
|
|
||||||
import React from "react";
|
|
||||||
import type { Permission } from "../../types/Permissions";
|
|
||||||
import { Checkbox } from "../../../components/forms";
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
permission: Permission
|
|
||||||
};
|
|
||||||
|
|
||||||
export default class PermissionRow extends React.Component<Props> {
|
|
||||||
render() {
|
|
||||||
const { permission } = this.props;
|
|
||||||
return (
|
|
||||||
<tr>
|
|
||||||
<td>{permission.name}</td>
|
|
||||||
<td className="is-hidden-mobile">{permission.type}</td>
|
|
||||||
<td>
|
|
||||||
<Checkbox checked={permission ? permission.groupPermission : false} />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,12 +6,12 @@ import {
|
|||||||
fetchPermissions,
|
fetchPermissions,
|
||||||
getFetchPermissionsFailure,
|
getFetchPermissionsFailure,
|
||||||
isFetchPermissionsPending,
|
isFetchPermissionsPending,
|
||||||
getPermissionsOfRepo,
|
getPermissionsOfRepo
|
||||||
} from "../modules/permissions";
|
} from "../modules/permissions";
|
||||||
import Loading from "../../components/Loading";
|
import Loading from "../../components/Loading";
|
||||||
import ErrorPage from "../../components/ErrorPage";
|
import ErrorPage from "../../components/ErrorPage";
|
||||||
import type { PermissionCollection } from "../types/Permissions";
|
import type { PermissionCollection } from "../types/Permissions";
|
||||||
import PermissionsTable from "./PermissionsTable";
|
import SinglePermission from "./SinglePermission";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
namespace: string,
|
namespace: string,
|
||||||
@@ -53,12 +53,28 @@ class Permissions extends React.Component<Props> {
|
|||||||
|
|
||||||
if (permissions.length > 0)
|
if (permissions.length > 0)
|
||||||
return (
|
return (
|
||||||
<PermissionsTable
|
<table className="table is-hoverable is-fullwidth">
|
||||||
permissions={permissions}
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{t("permission.name")}</th>
|
||||||
|
<th className="is-hidden-mobile">{t("permission.type")}</th>
|
||||||
|
<th>{t("permission.group-permission")}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{permissions.map((permission, index) => {
|
||||||
|
return (
|
||||||
|
<SinglePermission
|
||||||
|
key={index}
|
||||||
namespace={namespace}
|
namespace={namespace}
|
||||||
name={name}
|
name={name}
|
||||||
|
permission={permission}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
})}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
);
|
||||||
|
|
||||||
return <div />;
|
return <div />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
// @flow
|
|
||||||
import React from "react";
|
|
||||||
import { translate } from "react-i18next";
|
|
||||||
import PermissionRow from "../components/table/PermissionRow";
|
|
||||||
import type { Permission, PermissionCollection } from "../types/Permissions";
|
|
||||||
import SinglePermission from "./SinglePermission";
|
|
||||||
import type { History } from "history";
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
t: string => string,
|
|
||||||
permissions: PermissionCollection,
|
|
||||||
modifyPermission: (Permission, string, string, () => void) => void,
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
match: any,
|
|
||||||
history: History
|
|
||||||
};
|
|
||||||
|
|
||||||
class PermissionsTable extends React.Component<Props> {
|
|
||||||
permissionsModified = () => {
|
|
||||||
const { history, name, namespace } = this.props;
|
|
||||||
console.log(history);
|
|
||||||
history.push(`/repo/${namespace}/${name}/permissions`);
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { permissions, t, namespace, name } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<table className="table is-hoverable is-fullwidth">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>{t("permission.name")}</th>
|
|
||||||
<th className="is-hidden-mobile">{t("permission.type")}</th>
|
|
||||||
<th>{t("permission.group-permission")}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{permissions.map((permission, index) => {
|
|
||||||
if (permission._links.update)
|
|
||||||
return (
|
|
||||||
<SinglePermission
|
|
||||||
key={index}
|
|
||||||
namespace={namespace}
|
|
||||||
name={name}
|
|
||||||
permission={permission}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
else return <PermissionRow key={index} permission={permission} />;
|
|
||||||
})}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default translate("permissions")(PermissionsTable);
|
|
||||||
@@ -62,19 +62,25 @@ class SinglePermission extends React.Component<Props, State> {
|
|||||||
<DeleteButton label={t("edit-permission.delete-button")} />
|
<DeleteButton label={t("edit-permission.delete-button")} />
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
return (
|
const typeSelector = this.props.permission._links.update ? (
|
||||||
<tr>
|
<td>
|
||||||
<td>{permission.name}</td>
|
|
||||||
<td className="is-hidden-mobile">
|
|
||||||
<Select
|
<Select
|
||||||
onChange={this.handleTypeChange}
|
onChange={this.handleTypeChange}
|
||||||
value={permission.type ? permission.type : ""}
|
value={permission.type ? permission.type : ""}
|
||||||
options={this.createSelectOptions(types)}
|
options={this.createSelectOptions(types)}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
) : (
|
||||||
|
<td>{permission.type}</td>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<tr>
|
||||||
|
<td>{permission.name}</td>
|
||||||
<td>
|
<td>
|
||||||
<Checkbox checked={permission ? permission.groupPermission : false} />
|
<Checkbox checked={permission ? permission.groupPermission : false} />
|
||||||
</td>
|
</td>
|
||||||
|
{typeSelector}
|
||||||
<td>{deleteButton}</td>
|
<td>{deleteButton}</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user