mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-06 12:20:56 +01:00
Finish rename Role to RepositoryRole
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
// @flow
|
||||
|
||||
import type {Links} from "./hal";
|
||||
|
||||
export type RepositoryRole = {
|
||||
name: string,
|
||||
verbs: string[],
|
||||
type?: string,
|
||||
creationDate?: string,
|
||||
lastModified?: string,
|
||||
_links: Links
|
||||
};
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
//@flow
|
||||
|
||||
import type { Links } from "./hal";
|
||||
|
||||
export type Role = {
|
||||
name: string,
|
||||
verbs: string[],
|
||||
creationDate?: number,
|
||||
lastModified?: number,
|
||||
system: boolean,
|
||||
_links: Links
|
||||
};
|
||||
@@ -16,7 +16,6 @@ export type { Changeset } from "./Changesets";
|
||||
export type { Tag } from "./Tags";
|
||||
|
||||
export type { Config } from "./Config";
|
||||
export type { Role } from "./Role";
|
||||
|
||||
export type { IndexResources } from "./IndexResources";
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import type { Role } from "@scm-manager/ui-types";
|
||||
import type { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import { translate } from "react-i18next";
|
||||
import { compose } from "redux";
|
||||
import injectSheet from "react-jss";
|
||||
|
||||
type Props = {
|
||||
role: Role,
|
||||
role: RepositoryRole,
|
||||
// context props
|
||||
t: string => string
|
||||
};
|
||||
@@ -18,7 +18,6 @@ const styles = {
|
||||
};
|
||||
|
||||
class AvailableVerbs extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
const { role, t, classes } = this.props;
|
||||
|
||||
@@ -29,14 +28,16 @@ class AvailableVerbs extends React.Component<Props> {
|
||||
<td className={classes.spacing}>
|
||||
<ul>
|
||||
{role.verbs.map(verb => {
|
||||
return <li>{t("verbs.repository." + verb + ".displayName")}</li>;
|
||||
return (
|
||||
<li>{t("verbs.repository." + verb + ".displayName")}</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
return (verbs);
|
||||
return verbs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import type { Role } from "@scm-manager/ui-types";
|
||||
import type { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import ExtensionPoint from "@scm-manager/ui-extensions/lib/ExtensionPoint";
|
||||
import PermissionRoleDetailsTable from "./PermissionRoleDetailsTable";
|
||||
import { Button, Subtitle } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
role: Role,
|
||||
role: RepositoryRole,
|
||||
url: string,
|
||||
|
||||
// context props
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import type { Role } from "@scm-manager/ui-types";
|
||||
import type { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import { translate } from "react-i18next";
|
||||
import AvailableVerbs from "./AvailableVerbs";
|
||||
|
||||
type Props = {
|
||||
role: Role,
|
||||
role: RepositoryRole,
|
||||
// context props
|
||||
t: string => string
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import type { Role } from "@scm-manager/ui-types";
|
||||
import type { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import SystemRoleTag from "./SystemRoleTag";
|
||||
|
||||
type Props = {
|
||||
baseUrl: string,
|
||||
role: Role
|
||||
role: RepositoryRole
|
||||
};
|
||||
|
||||
class PermissionRoleRow extends React.Component<Props> {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import type { Role } from "@scm-manager/ui-types";
|
||||
import type { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import PermissionRoleRow from "./PermissionRoleRow";
|
||||
|
||||
type Props = {
|
||||
baseUrl: string,
|
||||
roles: Role[],
|
||||
roles: RepositoryRole[],
|
||||
|
||||
t: string => string
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
getFetchVerbsFailure,
|
||||
isFetchVerbsPending
|
||||
} from "../modules/roles";
|
||||
import type { Role } from "@scm-manager/ui-types";
|
||||
import type { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import {
|
||||
getRepositoryRolesLink,
|
||||
getRepositoryVerbsLink
|
||||
@@ -22,19 +22,19 @@ type Props = {
|
||||
error?: Error,
|
||||
|
||||
//dispatch function
|
||||
addRole: (link: string, role: Role, callback?: () => void) => void,
|
||||
addRole: (link: string, role: RepositoryRole, callback?: () => void) => void,
|
||||
|
||||
// context objects
|
||||
t: string => string
|
||||
};
|
||||
|
||||
class CreateRepositoryRole extends React.Component<Props> {
|
||||
repositoryRoleCreated = (role: Role) => {
|
||||
repositoryRoleCreated = (role: RepositoryRole) => {
|
||||
const { history } = this.props;
|
||||
history.push("/config/role/" + role.name + "/info");
|
||||
};
|
||||
|
||||
createRepositoryRole = (role: Role) => {
|
||||
createRepositoryRole = (role: RepositoryRole) => {
|
||||
this.props.addRole(this.props.repositoryRolesLink, role, () =>
|
||||
this.repositoryRoleCreated(role)
|
||||
);
|
||||
@@ -75,7 +75,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
addRole: (link: string, role: Role, callback?: () => void) => {
|
||||
addRole: (link: string, role: RepositoryRole, callback?: () => void) => {
|
||||
dispatch(createRole(link, role, callback));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9,25 +9,29 @@ import {
|
||||
modifyRole
|
||||
} from "../modules/roles";
|
||||
import { ErrorNotification } from "@scm-manager/ui-components";
|
||||
import type { Role } from "@scm-manager/ui-types";
|
||||
import type { RepositoryRole } from "@scm-manager/ui-types";
|
||||
|
||||
type Props = {
|
||||
disabled: boolean,
|
||||
role: Role,
|
||||
role: RepositoryRole,
|
||||
repositoryRolesLink: string,
|
||||
error?: Error,
|
||||
|
||||
//dispatch function
|
||||
updateRole: (link: string, role: Role, callback?: () => void) => void
|
||||
updateRole: (
|
||||
link: string,
|
||||
role: RepositoryRole,
|
||||
callback?: () => void
|
||||
) => void
|
||||
};
|
||||
|
||||
class EditRepositoryRole extends React.Component<Props> {
|
||||
repositoryRoleUpdated = (role: Role) => {
|
||||
repositoryRoleUpdated = (role: RepositoryRole) => {
|
||||
const { history } = this.props;
|
||||
history.push("/config/roles/");
|
||||
};
|
||||
|
||||
updateRepositoryRole = (role: Role) => {
|
||||
updateRepositoryRole = (role: RepositoryRole) => {
|
||||
this.props.updateRole(role, () => this.repositoryRoleUpdated(role));
|
||||
};
|
||||
|
||||
@@ -62,7 +66,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
updateRole: (role: Role, callback?: () => void) => {
|
||||
updateRole: (role: RepositoryRole, callback?: () => void) => {
|
||||
dispatch(modifyRole(role, callback));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { translate } from "react-i18next";
|
||||
import type { Role } from "@scm-manager/ui-types";
|
||||
import type { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import { InputField, SubmitButton } from "@scm-manager/ui-components";
|
||||
import PermissionCheckbox from "../../../repos/permissions/components/PermissionCheckbox";
|
||||
import {
|
||||
@@ -11,15 +11,18 @@ import {
|
||||
getVerbsFromState,
|
||||
isFetchVerbsPending
|
||||
} from "../modules/roles";
|
||||
import {getRepositoryRolesLink, getRepositoryVerbsLink} from "../../../modules/indexResource";
|
||||
import {
|
||||
getRepositoryRolesLink,
|
||||
getRepositoryVerbsLink
|
||||
} from "../../../modules/indexResource";
|
||||
|
||||
type Props = {
|
||||
role?: Role,
|
||||
role?: RepositoryRole,
|
||||
loading?: boolean,
|
||||
nameDisabled: boolean,
|
||||
availableVerbs: string[],
|
||||
verbsLink: string,
|
||||
submitForm: Role => void,
|
||||
submitForm: RepositoryRole => void,
|
||||
|
||||
// context objects
|
||||
t: string => string,
|
||||
@@ -29,7 +32,7 @@ type Props = {
|
||||
};
|
||||
|
||||
type State = {
|
||||
role: Role
|
||||
role: RepositoryRole
|
||||
};
|
||||
|
||||
class RepositoryRoleForm extends React.Component<Props, State> {
|
||||
@@ -47,10 +50,10 @@ class RepositoryRoleForm extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { fetchAvailableVerbs, verbsLink} = this.props;
|
||||
const { fetchAvailableVerbs, verbsLink } = this.props;
|
||||
fetchAvailableVerbs(verbsLink);
|
||||
if (this.props.role) {
|
||||
this.setState({role: this.props.role})
|
||||
this.setState({ role: this.props.role });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +98,7 @@ class RepositoryRoleForm extends React.Component<Props, State> {
|
||||
submit = (event: Event) => {
|
||||
event.preventDefault();
|
||||
if (this.isValid()) {
|
||||
this.props.submitForm(this.state.role)
|
||||
this.props.submitForm(this.state.role);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -163,7 +166,7 @@ const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
fetchAvailableVerbs: (link: string) => {
|
||||
dispatch(fetchAvailableVerbs(link));
|
||||
},
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import {withRouter} from "react-router-dom";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import { translate } from "react-i18next";
|
||||
import type { History } from "history";
|
||||
import type { Role, PagedCollection } from "@scm-manager/ui-types";
|
||||
import type { RepositoryRole, PagedCollection } from "@scm-manager/ui-types";
|
||||
import {
|
||||
Title,
|
||||
Loading,
|
||||
@@ -25,7 +25,7 @@ import PermissionRoleTable from "../components/PermissionRoleTable";
|
||||
import { getRolesLink } from "../../../modules/indexResource";
|
||||
type Props = {
|
||||
baseUrl: string,
|
||||
roles: Role[],
|
||||
roles: RepositoryRole[],
|
||||
loading: boolean,
|
||||
error: Error,
|
||||
canAddRoles: boolean,
|
||||
@@ -90,19 +90,26 @@ class RepositoryRoles extends React.Component<Props> {
|
||||
return (
|
||||
<>
|
||||
<PermissionRoleTable baseUrl={baseUrl} roles={roles} />
|
||||
<LinkPaginator collection={list} page={page} />
|
||||
<LinkPaginator collection={list} page={page} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Notification type="info">{t("repositoryRole.noPermissionRoles")}</Notification>
|
||||
<Notification type="info">
|
||||
{t("repositoryRole.noPermissionRoles")}
|
||||
</Notification>
|
||||
);
|
||||
}
|
||||
|
||||
renderCreateButton() {
|
||||
const { canAddRoles, baseUrl, t } = this.props;
|
||||
if (canAddRoles) {
|
||||
return <CreateButton label={t("repositoryRole.createButton")} link={`${baseUrl}/create`} />;
|
||||
return (
|
||||
<CreateButton
|
||||
label={t("repositoryRole.createButton")}
|
||||
link={`${baseUrl}/create`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -137,7 +144,9 @@ const mapDispatchToProps = dispatch => {
|
||||
};
|
||||
};
|
||||
|
||||
export default withRouter(connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(translate("config")(RepositoryRoles)));
|
||||
export default withRouter(
|
||||
connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(translate("config")(RepositoryRoles))
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Loading, ErrorPage, Title } from "@scm-manager/ui-components";
|
||||
import { Route } from "react-router";
|
||||
import type { History } from "history";
|
||||
import { translate } from "react-i18next";
|
||||
import type { Role } from "@scm-manager/ui-types";
|
||||
import type { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import { getRepositoryRolesLink } from "../../../modules/indexResource";
|
||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||
import {
|
||||
@@ -20,7 +20,7 @@ import EditRepositoryRole from "./EditRepositoryRole";
|
||||
|
||||
type Props = {
|
||||
roleName: string,
|
||||
role: Role,
|
||||
role: RepositoryRole,
|
||||
loading: boolean,
|
||||
error: Error,
|
||||
repositoryRolesLink: string,
|
||||
@@ -83,22 +83,22 @@ class SingleRepositoryRole extends React.Component<Props> {
|
||||
<Title title={t("repositoryRole.title")} />
|
||||
<div className="columns">
|
||||
<div className="column is-three-quarters">
|
||||
<Route
|
||||
path={`${url}/info`}
|
||||
component={() => (
|
||||
<PermissionRoleDetail role={role} url={url} />
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/edit`}
|
||||
exact
|
||||
component={() => <EditRepositoryRole role={role} history={this.props.history} />}
|
||||
/>
|
||||
<ExtensionPoint
|
||||
name="roles.route"
|
||||
props={extensionProps}
|
||||
renderAll={true}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/info`}
|
||||
component={() => <PermissionRoleDetail role={role} url={url} />}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/edit`}
|
||||
exact
|
||||
component={() => (
|
||||
<EditRepositoryRole role={role} history={this.props.history} />
|
||||
)}
|
||||
/>
|
||||
<ExtensionPoint
|
||||
name="roles.route"
|
||||
props={extensionProps}
|
||||
renderAll={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -4,7 +4,11 @@ import { isPending } from "../../../modules/pending";
|
||||
import { getFailure } from "../../../modules/failure";
|
||||
import * as types from "../../../modules/types";
|
||||
import { combineReducers, Dispatch } from "redux";
|
||||
import type {Action, PagedCollection, Repository, Role} from "@scm-manager/ui-types";
|
||||
import type {
|
||||
Action,
|
||||
PagedCollection,
|
||||
RepositoryRole
|
||||
} from "@scm-manager/ui-types";
|
||||
|
||||
export const FETCH_ROLES = "scm/roles/FETCH_ROLES";
|
||||
export const FETCH_ROLES_PENDING = `${FETCH_ROLES}_${types.PENDING_SUFFIX}`;
|
||||
@@ -138,12 +142,12 @@ export function fetchRoleByName(link: string, name: string) {
|
||||
return fetchRole(roleUrl, name);
|
||||
}
|
||||
|
||||
export function fetchRoleByLink(role: Role) {
|
||||
export function fetchRoleByLink(role: RepositoryRole) {
|
||||
return fetchRole(role._links.self.href, role.name);
|
||||
}
|
||||
|
||||
// create role
|
||||
export function createRolePending(role: Role): Action {
|
||||
export function createRolePending(role: RepositoryRole): Action {
|
||||
return {
|
||||
type: CREATE_ROLE_PENDING,
|
||||
role
|
||||
@@ -169,7 +173,11 @@ export function createRoleReset() {
|
||||
};
|
||||
}
|
||||
|
||||
export function createRole(link: string, role: Role, callback?: () => void) {
|
||||
export function createRole(
|
||||
link: string,
|
||||
role: RepositoryRole,
|
||||
callback?: () => void
|
||||
) {
|
||||
return function(dispatch: Dispatch) {
|
||||
dispatch(createRolePending(role));
|
||||
return apiClient
|
||||
@@ -233,7 +241,7 @@ function verbReducer(state: any = {}, action: any = {}) {
|
||||
}
|
||||
|
||||
// modify role
|
||||
export function modifyRolePending(role: Role): Action {
|
||||
export function modifyRolePending(role: RepositoryRole): Action {
|
||||
return {
|
||||
type: MODIFY_ROLE_PENDING,
|
||||
payload: role,
|
||||
@@ -241,7 +249,7 @@ export function modifyRolePending(role: Role): Action {
|
||||
};
|
||||
}
|
||||
|
||||
export function modifyRoleSuccess(role: Role): Action {
|
||||
export function modifyRoleSuccess(role: RepositoryRole): Action {
|
||||
return {
|
||||
type: MODIFY_ROLE_SUCCESS,
|
||||
payload: role,
|
||||
@@ -249,7 +257,7 @@ export function modifyRoleSuccess(role: Role): Action {
|
||||
};
|
||||
}
|
||||
|
||||
export function modifyRoleFailure(role: Role, error: Error): Action {
|
||||
export function modifyRoleFailure(role: RepositoryRole, error: Error): Action {
|
||||
return {
|
||||
type: MODIFY_ROLE_FAILURE,
|
||||
payload: {
|
||||
@@ -260,14 +268,14 @@ export function modifyRoleFailure(role: Role, error: Error): Action {
|
||||
};
|
||||
}
|
||||
|
||||
export function modifyRoleReset(role: Role): Action {
|
||||
export function modifyRoleReset(role: RepositoryRole): Action {
|
||||
return {
|
||||
type: MODIFY_ROLE_RESET,
|
||||
itemId: role.name
|
||||
};
|
||||
}
|
||||
|
||||
export function modifyRole(role: Role, callback?: () => void) {
|
||||
export function modifyRole(role: RepositoryRole, callback?: () => void) {
|
||||
return function(dispatch: Dispatch) {
|
||||
dispatch(modifyRolePending(role));
|
||||
return apiClient
|
||||
@@ -288,7 +296,7 @@ export function modifyRole(role: Role, callback?: () => void) {
|
||||
}
|
||||
|
||||
// delete role
|
||||
export function deleteRolePending(role: Role): Action {
|
||||
export function deleteRolePending(role: RepositoryRole): Action {
|
||||
return {
|
||||
type: DELETE_ROLE_PENDING,
|
||||
payload: role,
|
||||
@@ -296,7 +304,7 @@ export function deleteRolePending(role: Role): Action {
|
||||
};
|
||||
}
|
||||
|
||||
export function deleteRoleSuccess(role: Role): Action {
|
||||
export function deleteRoleSuccess(role: RepositoryRole): Action {
|
||||
return {
|
||||
type: DELETE_ROLE_SUCCESS,
|
||||
payload: role,
|
||||
@@ -304,7 +312,7 @@ export function deleteRoleSuccess(role: Role): Action {
|
||||
};
|
||||
}
|
||||
|
||||
export function deleteRoleFailure(role: Role, error: Error): Action {
|
||||
export function deleteRoleFailure(role: RepositoryRole, error: Error): Action {
|
||||
return {
|
||||
type: DELETE_ROLE_FAILURE,
|
||||
payload: {
|
||||
@@ -315,7 +323,7 @@ export function deleteRoleFailure(role: Role, error: Error): Action {
|
||||
};
|
||||
}
|
||||
|
||||
export function deleteRole(role: Role, callback?: () => void) {
|
||||
export function deleteRole(role: RepositoryRole, callback?: () => void) {
|
||||
return function(dispatch: any) {
|
||||
dispatch(deleteRolePending(role));
|
||||
return apiClient
|
||||
@@ -333,7 +341,7 @@ export function deleteRole(role: Role, callback?: () => void) {
|
||||
}
|
||||
|
||||
function extractRolesByNames(
|
||||
roles: Role[],
|
||||
roles: RepositoryRole[],
|
||||
roleNames: string[],
|
||||
oldRolesByNames: Object
|
||||
) {
|
||||
@@ -460,7 +468,7 @@ export function getRolesFromState(state: Object) {
|
||||
if (!roleNames) {
|
||||
return null;
|
||||
}
|
||||
const roleEntries: Role[] = [];
|
||||
const roleEntries: RepositoryRole[] = [];
|
||||
|
||||
for (let roleName of roleNames) {
|
||||
roleEntries.push(state.roles.byNames[roleName]);
|
||||
@@ -470,12 +478,7 @@ export function getRolesFromState(state: Object) {
|
||||
}
|
||||
|
||||
export function getRoleCreateLink(state: Object) {
|
||||
if (
|
||||
state &&
|
||||
state.list &&
|
||||
state.list._links &&
|
||||
state.list._links.create
|
||||
) {
|
||||
if (state && state.list && state.list._links && state.list._links.create) {
|
||||
return state.list._links.create.href;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user