mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 06:55:47 +01:00
introduce permission type without links
This commit is contained in:
@@ -3,12 +3,12 @@ import React from "react";
|
|||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import { Checkbox, InputField } from "../../components/forms";
|
import { Checkbox, InputField } from "../../components/forms";
|
||||||
import TypeSelector from "./TypeSelector";
|
import TypeSelector from "./TypeSelector";
|
||||||
import type { Permission } from "../types/Permissions";
|
import type {PermissionEntry} from "../types/Permissions";
|
||||||
import { SubmitButton } from "../../components/buttons";
|
import { SubmitButton } from "../../components/buttons";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
t: string => string,
|
t: string => string,
|
||||||
createPermission: (permission: Permission) => void,
|
createPermission: (permission: PermissionEntry) => void,
|
||||||
loading: boolean
|
loading: boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
} 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 { Permission, PermissionCollection } from "../types/Permissions";
|
import type {Permission, PermissionCollection, PermissionEntry} from "../types/Permissions";
|
||||||
import SinglePermission from "./SinglePermission";
|
import SinglePermission from "./SinglePermission";
|
||||||
import CreatePermissionForm from "../components/CreatePermissionForm";
|
import CreatePermissionForm from "../components/CreatePermissionForm";
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ type Props = {
|
|||||||
//dispatch functions
|
//dispatch functions
|
||||||
fetchPermissions: (namespace: string, repoName: string) => void,
|
fetchPermissions: (namespace: string, repoName: string) => void,
|
||||||
createPermission: (
|
createPermission: (
|
||||||
permission: Permission,
|
permission: PermissionEntry,
|
||||||
namespace: string,
|
namespace: string,
|
||||||
repoName: string
|
repoName: string
|
||||||
) => void,
|
) => void,
|
||||||
@@ -143,7 +143,7 @@ const mapDispatchToProps = dispatch => {
|
|||||||
dispatch(fetchPermissions(namespace, repoName));
|
dispatch(fetchPermissions(namespace, repoName));
|
||||||
},
|
},
|
||||||
createPermission: (
|
createPermission: (
|
||||||
permission: Permission,
|
permission: PermissionEntry,
|
||||||
namespace: string,
|
namespace: string,
|
||||||
repoName: string
|
repoName: string
|
||||||
) => {
|
) => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { apiClient } from "../../apiclient";
|
import { apiClient } from "../../apiclient";
|
||||||
import * as types from "../../modules/types";
|
import * as types from "../../modules/types";
|
||||||
import type { Action } from "../../types/Action";
|
import type { Action } from "../../types/Action";
|
||||||
import type { PermissionCollection, Permission } from "../types/Permissions";
|
import type {PermissionCollection, Permission, PermissionEntry} from "../types/Permissions";
|
||||||
import { isPending } from "../../modules/pending";
|
import { isPending } from "../../modules/pending";
|
||||||
import { getFailure } from "../../modules/failure";
|
import { getFailure } from "../../modules/failure";
|
||||||
import { Dispatch } from "redux";
|
import { Dispatch } from "redux";
|
||||||
@@ -206,7 +206,7 @@ export function modifyPermissionReset(
|
|||||||
|
|
||||||
// create permission
|
// create permission
|
||||||
export function createPermission(
|
export function createPermission(
|
||||||
permission: Permission,
|
permission: PermissionEntry,
|
||||||
namespace: string,
|
namespace: string,
|
||||||
repoName: string,
|
repoName: string,
|
||||||
callback?: () => void
|
callback?: () => void
|
||||||
@@ -240,7 +240,7 @@ export function createPermission(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createPermissionPending(
|
export function createPermissionPending(
|
||||||
permission: Permission,
|
permission: PermissionEntry,
|
||||||
namespace: string,
|
namespace: string,
|
||||||
repoName: string
|
repoName: string
|
||||||
): Action {
|
): Action {
|
||||||
@@ -252,7 +252,7 @@ export function createPermissionPending(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createPermissionSuccess(
|
export function createPermissionSuccess(
|
||||||
permission: Permission,
|
permission: PermissionEntry,
|
||||||
namespace: string,
|
namespace: string,
|
||||||
repoName: string
|
repoName: string
|
||||||
): Action {
|
): Action {
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ import reducer, {
|
|||||||
} from "./permissions";
|
} from "./permissions";
|
||||||
import type { Permission, PermissionCollection } from "../types/Permissions";
|
import type { Permission, PermissionCollection } from "../types/Permissions";
|
||||||
|
|
||||||
|
const namespace = "hitchhiker";
|
||||||
|
const repoName = "puzzle42";
|
||||||
|
|
||||||
const hitchhiker_puzzle42Permission_user_eins: Permission = {
|
const hitchhiker_puzzle42Permission_user_eins: Permission = {
|
||||||
name: "user_eins",
|
name: "user_eins",
|
||||||
type: "READ",
|
type: "READ",
|
||||||
@@ -115,7 +118,7 @@ describe("permission fetch", () => {
|
|||||||
{
|
{
|
||||||
type: FETCH_PERMISSIONS_PENDING,
|
type: FETCH_PERMISSIONS_PENDING,
|
||||||
payload: {
|
payload: {
|
||||||
namespace: "hitchhiker",
|
namespace: namespace,
|
||||||
repoName: "puzzle42"
|
repoName: "puzzle42"
|
||||||
},
|
},
|
||||||
itemId: "hitchhiker/puzzle42"
|
itemId: "hitchhiker/puzzle42"
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ export type Permission = {
|
|||||||
name: string,
|
name: string,
|
||||||
type: string,
|
type: string,
|
||||||
groupPermission: boolean,
|
groupPermission: boolean,
|
||||||
_links?: Links
|
_links: Links
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type PermissionEntry = {
|
||||||
|
name: string,
|
||||||
|
type: string,
|
||||||
|
groupPermission: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export type PermissionCollection = Permission[];
|
export type PermissionCollection = Permission[];
|
||||||
|
|||||||
Reference in New Issue
Block a user