mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
use permissions url provided by repo
This commit is contained in:
@@ -62,17 +62,19 @@ export const DELETE_PERMISSION_RESET = `${DELETE_PERMISSION}_${
|
||||
types.RESET_SUFFIX
|
||||
}`;
|
||||
|
||||
const REPOS_URL = "repositories";
|
||||
const PERMISSIONS_URL = "permissions";
|
||||
const CONTENT_TYPE = "application/vnd.scmm-permission+json";
|
||||
|
||||
// fetch permissions
|
||||
|
||||
export function fetchPermissions(namespace: string, repoName: string) {
|
||||
export function fetchPermissions(
|
||||
link: string,
|
||||
namespace: string,
|
||||
repoName: string
|
||||
) {
|
||||
return function(dispatch: any) {
|
||||
dispatch(fetchPermissionsPending(namespace, repoName));
|
||||
return apiClient
|
||||
.get(`${REPOS_URL}/${namespace}/${repoName}/${PERMISSIONS_URL}`)
|
||||
.get(link)
|
||||
.then(response => response.json())
|
||||
.then(permissions => {
|
||||
dispatch(fetchPermissionsSuccess(permissions, namespace, repoName));
|
||||
@@ -219,6 +221,7 @@ export function modifyPermissionReset(namespace: string, repoName: string) {
|
||||
|
||||
// create permission
|
||||
export function createPermission(
|
||||
link: string,
|
||||
permission: PermissionEntry,
|
||||
namespace: string,
|
||||
repoName: string,
|
||||
@@ -227,11 +230,7 @@ export function createPermission(
|
||||
return function(dispatch: Dispatch) {
|
||||
dispatch(createPermissionPending(permission, namespace, repoName));
|
||||
return apiClient
|
||||
.post(
|
||||
`${REPOS_URL}/${namespace}/${repoName}/${PERMISSIONS_URL}`,
|
||||
permission,
|
||||
CONTENT_TYPE
|
||||
)
|
||||
.post(link, permission, CONTENT_TYPE)
|
||||
.then(response => {
|
||||
const location = response.headers.get("Location");
|
||||
return apiClient.get(location);
|
||||
|
||||
@@ -101,6 +101,7 @@ const hitchhiker_puzzle42RepoPermissions = {
|
||||
|
||||
describe("permission fetch", () => {
|
||||
const REPOS_URL = "/api/v2/repositories";
|
||||
const URL = "repositories";
|
||||
const mockStore = configureMockStore([thunk]);
|
||||
|
||||
afterEach(() => {
|
||||
@@ -132,7 +133,13 @@ describe("permission fetch", () => {
|
||||
|
||||
const store = mockStore({});
|
||||
return store
|
||||
.dispatch(fetchPermissions("hitchhiker", "puzzle42"))
|
||||
.dispatch(
|
||||
fetchPermissions(
|
||||
URL + "/hitchhiker/puzzle42/permissions",
|
||||
"hitchhiker",
|
||||
"puzzle42"
|
||||
)
|
||||
)
|
||||
.then(() => {
|
||||
expect(store.getActions()).toEqual(expectedActions);
|
||||
});
|
||||
@@ -145,7 +152,13 @@ describe("permission fetch", () => {
|
||||
|
||||
const store = mockStore({});
|
||||
return store
|
||||
.dispatch(fetchPermissions("hitchhiker", "puzzle42"))
|
||||
.dispatch(
|
||||
fetchPermissions(
|
||||
URL + "/hitchhiker/puzzle42/permissions",
|
||||
"hitchhiker",
|
||||
"puzzle42"
|
||||
)
|
||||
)
|
||||
.then(() => {
|
||||
const actions = store.getActions();
|
||||
expect(actions[0].type).toEqual(FETCH_PERMISSIONS_PENDING);
|
||||
@@ -247,6 +260,7 @@ describe("permission fetch", () => {
|
||||
return store
|
||||
.dispatch(
|
||||
createPermission(
|
||||
URL + "/hitchhiker/puzzle42/permissions",
|
||||
hitchhiker_puzzle42Permission_user_eins,
|
||||
"hitchhiker",
|
||||
"puzzle42"
|
||||
@@ -268,6 +282,7 @@ describe("permission fetch", () => {
|
||||
return store
|
||||
.dispatch(
|
||||
createPermission(
|
||||
URL + "/hitchhiker/puzzle42/permissions",
|
||||
hitchhiker_puzzle42Permission_user_eins,
|
||||
"hitchhiker",
|
||||
"puzzle42"
|
||||
@@ -304,6 +319,7 @@ describe("permission fetch", () => {
|
||||
return store
|
||||
.dispatch(
|
||||
createPermission(
|
||||
URL + "/hitchhiker/puzzle42/permissions",
|
||||
hitchhiker_puzzle42Permission_user_eins,
|
||||
"hitchhiker",
|
||||
"puzzle42",
|
||||
|
||||
Reference in New Issue
Block a user