mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
improve typing and fixed import
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import React from "react";
|
||||
|
||||
import InputField from "../../components/forms/InputField";
|
||||
import { SubmitButton, Button } from "../../components/buttons";
|
||||
import { SubmitButton } from "../../components/buttons";
|
||||
import { translate } from "react-i18next";
|
||||
import type { Group } from "../types/Group";
|
||||
import * as validator from "./groupValidation";
|
||||
@@ -117,8 +117,7 @@ class GroupForm extends React.Component<Props, State> {
|
||||
members: usernames
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
addUser = (username: string) => {
|
||||
if (this.isMember(username)) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @flow
|
||||
import { apiClient } from "../../apiclient";
|
||||
import { isPending } from "../../modules/pending";
|
||||
import { getFailure } from "../../modules/failure";
|
||||
@@ -5,7 +6,7 @@ import * as types from "../../modules/types";
|
||||
import { combineReducers, Dispatch } from "redux";
|
||||
import type { Action } from "../../types/Action";
|
||||
import type { PagedCollection } from "../../types/Collection";
|
||||
import type { Groups } from "../types/Groups";
|
||||
import type { Group } from "../types/Group";
|
||||
|
||||
export const FETCH_GROUPS = "scm/groups/FETCH_GROUPS";
|
||||
export const FETCH_GROUPS_PENDING = `${FETCH_GROUPS}_${types.PENDING_SUFFIX}`;
|
||||
@@ -139,10 +140,11 @@ export function createGroup(group: Group, callback?: () => void) {
|
||||
return apiClient
|
||||
.postWithContentType(GROUPS_URL, group, CONTENT_TYPE_GROUP)
|
||||
.then(() => {
|
||||
dispatch(createGroupSuccess())
|
||||
dispatch(createGroupSuccess());
|
||||
if (callback) {
|
||||
callback();
|
||||
}})
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
dispatch(
|
||||
createGroupFailure(
|
||||
@@ -175,7 +177,7 @@ export function createGroupFailure(error: Error) {
|
||||
export function createGroupReset() {
|
||||
return {
|
||||
type: CREATE_GROUP_RESET
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// modify group
|
||||
@@ -185,14 +187,19 @@ export function modifyGroup(group: Group, callback?: () => void) {
|
||||
return apiClient
|
||||
.putWithContentType(group._links.update.href, group, CONTENT_TYPE_GROUP)
|
||||
.then(() => {
|
||||
dispatch(modifyGroupSuccess(group))
|
||||
dispatch(modifyGroupSuccess(group));
|
||||
if (callback) {
|
||||
callback()
|
||||
callback();
|
||||
}
|
||||
})
|
||||
.catch(cause => {
|
||||
dispatch(modifyGroupFailure(group, new Error(`could not modify group ${group.name}: ${cause.message}`)))
|
||||
})
|
||||
dispatch(
|
||||
modifyGroupFailure(
|
||||
group,
|
||||
new Error(`could not modify group ${group.name}: ${cause.message}`)
|
||||
)
|
||||
);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -201,7 +208,7 @@ export function modifyGroupPending(group: Group): Action {
|
||||
type: MODIFY_GROUP_PENDING,
|
||||
payload: group,
|
||||
itemId: group.name
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function modifyGroupSuccess(group: Group): Action {
|
||||
@@ -209,7 +216,7 @@ export function modifyGroupSuccess(group: Group): Action {
|
||||
type: MODIFY_GROUP_SUCCESS,
|
||||
payload: group,
|
||||
itemId: group.name
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function modifyGroupFailure(group: Group, error: Error): Action {
|
||||
@@ -220,7 +227,7 @@ export function modifyGroupFailure(group: Group, error: Error): Action {
|
||||
group
|
||||
},
|
||||
itemId: group.name
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//delete group
|
||||
@@ -274,7 +281,7 @@ export function deleteGroupFailure(group: Group, error: Error): Action {
|
||||
|
||||
//reducer
|
||||
function extractGroupsByNames(
|
||||
groups: Groups[],
|
||||
groups: Group[],
|
||||
groupNames: string[],
|
||||
oldGroupsByNames: Object
|
||||
) {
|
||||
@@ -436,11 +443,11 @@ export function getCreateGroupFailure(state: Object) {
|
||||
}
|
||||
|
||||
export function isModifyGroupPending(state: Object, name: string) {
|
||||
return(isPending(state, MODIFY_GROUP, name))
|
||||
return isPending(state, MODIFY_GROUP, name);
|
||||
}
|
||||
|
||||
export function getModifyGroupFailure(state: Object, name: string) {
|
||||
return(getFailure(state, MODIFY_GROUP, name))
|
||||
return getFailure(state, MODIFY_GROUP, name);
|
||||
}
|
||||
|
||||
export function getGroupByName(state: Object, name: string) {
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
//@flow
|
||||
import type { Collection } from "../../types/Collection";
|
||||
import type { Links } from "../../types/hal";
|
||||
import type { User } from "../../users/types/User";
|
||||
|
||||
export type Group = {
|
||||
export type Member = {
|
||||
name: string,
|
||||
_links: Links
|
||||
};
|
||||
|
||||
export type Group = Collection & {
|
||||
name: string,
|
||||
description: string,
|
||||
type: string,
|
||||
members: string[],
|
||||
_links: Links,
|
||||
_embedded: {
|
||||
members: User[]
|
||||
members: Member[]
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user