mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 18:26:16 +01:00
lang file + fixed edit group subtitle, paths + remaned editgroup to general
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import {
|
||||
Subtitle,
|
||||
AutocompleteAddEntryToTableField,
|
||||
LabelWithHelpIcon,
|
||||
MemberNameTable,
|
||||
@@ -73,34 +74,38 @@ class GroupForm extends React.Component<Props, State> {
|
||||
render() {
|
||||
const { t, loading } = this.props;
|
||||
const { group } = this.state;
|
||||
let nameField = null;
|
||||
let firstField = null;
|
||||
if (!this.props.group) {
|
||||
nameField = (
|
||||
// create new group
|
||||
firstField = (
|
||||
<InputField
|
||||
label={t("group.name")}
|
||||
errorMessage={t("group-form.name-error")}
|
||||
errorMessage={t("groupForm.nameError")}
|
||||
onChange={this.handleGroupNameChange}
|
||||
value={group.name}
|
||||
validationError={this.state.nameValidationError}
|
||||
helpText={t("group-form.help.nameHelpText")}
|
||||
helpText={t("groupForm.help.nameHelpText")}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
// edit existing group
|
||||
firstField = <Subtitle subtitle={t("groupForm.subtitle")} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={this.submit}>
|
||||
{nameField}
|
||||
{firstField}
|
||||
<Textarea
|
||||
label={t("group.description")}
|
||||
errorMessage={t("group-form.description-error")}
|
||||
errorMessage={t("groupForm.descriptionError")}
|
||||
onChange={this.handleDescriptionChange}
|
||||
value={group.description}
|
||||
validationError={false}
|
||||
helpText={t("group-form.help.descriptionHelpText")}
|
||||
helpText={t("groupForm.help.descriptionHelpText")}
|
||||
/>
|
||||
<LabelWithHelpIcon
|
||||
label={t("group.members")}
|
||||
helpText={t("group-form.help.memberHelpText")}
|
||||
helpText={t("groupForm.help.memberHelpText")}
|
||||
/>
|
||||
<MemberNameTable
|
||||
members={group.members}
|
||||
@@ -120,7 +125,7 @@ class GroupForm extends React.Component<Props, State> {
|
||||
/>
|
||||
<SubmitButton
|
||||
disabled={!this.isValid()}
|
||||
label={t("group-form.submit")}
|
||||
label={t("groupForm.submit")}
|
||||
loading={loading}
|
||||
/>
|
||||
</form>
|
||||
|
||||
@@ -3,9 +3,12 @@ import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import GroupForm from "../components/GroupForm";
|
||||
import {
|
||||
modifyGroup,
|
||||
deleteGroup,
|
||||
getModifyGroupFailure,
|
||||
isModifyGroupPending,
|
||||
modifyGroup,
|
||||
getDeleteGroupFailure,
|
||||
isDeleteGroupPending,
|
||||
modifyGroupReset
|
||||
} from "../modules/groups";
|
||||
import type { History } from "history";
|
||||
@@ -13,19 +16,21 @@ import { withRouter } from "react-router-dom";
|
||||
import type { Group } from "@scm-manager/ui-types";
|
||||
import { ErrorNotification } from "@scm-manager/ui-components";
|
||||
import { getUserAutoCompleteLink } from "../../modules/indexResource";
|
||||
import DeleteGroup from "../components/DeleteGroup";
|
||||
|
||||
type Props = {
|
||||
group: Group,
|
||||
fetchGroup: (name: string) => void,
|
||||
modifyGroup: (group: Group, callback?: () => void) => void,
|
||||
modifyGroupReset: Group => void,
|
||||
fetchGroup: (name: string) => void,
|
||||
deleteGroup: (group: Group, callback?: () => void) => void,
|
||||
autocompleteLink: string,
|
||||
history: History,
|
||||
loading?: boolean,
|
||||
error: Error
|
||||
};
|
||||
|
||||
class EditGroup extends React.Component<Props> {
|
||||
class GeneralGroup extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
const { group, modifyGroupReset } = this.props;
|
||||
modifyGroupReset(group);
|
||||
@@ -39,6 +44,14 @@ class EditGroup extends React.Component<Props> {
|
||||
this.props.modifyGroup(group, this.groupModified(group));
|
||||
};
|
||||
|
||||
deleteGroup = (group: Group) => {
|
||||
this.props.deleteGroup(group, this.groupDeleted);
|
||||
};
|
||||
|
||||
groupDeleted = () => {
|
||||
this.props.history.push("/groups");
|
||||
};
|
||||
|
||||
loadUserAutocompletion = (inputValue: string) => {
|
||||
const url = this.props.autocompleteLink + "?q=";
|
||||
return fetch(url + inputValue)
|
||||
@@ -66,14 +79,18 @@ class EditGroup extends React.Component<Props> {
|
||||
loading={loading}
|
||||
loadUserSuggestions={this.loadUserAutocompletion}
|
||||
/>
|
||||
<hr />
|
||||
<DeleteGroup
|
||||
group={group}
|
||||
deleteGroup={this.deleteGroup} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const loading = isModifyGroupPending(state, ownProps.group.name);
|
||||
const error = getModifyGroupFailure(state, ownProps.group.name);
|
||||
const loading = isModifyGroupPending(state, ownProps.group.name) || isDeleteGroupPending(state, ownProps.group.name);
|
||||
const error = getModifyGroupFailure(state, ownProps.group.name) || getDeleteGroupFailure(state, ownProps.group.name);
|
||||
const autocompleteLink = getUserAutoCompleteLink(state);
|
||||
return {
|
||||
loading,
|
||||
@@ -89,6 +106,9 @@ const mapDispatchToProps = dispatch => {
|
||||
},
|
||||
modifyGroupReset: (group: Group) => {
|
||||
dispatch(modifyGroupReset(group));
|
||||
},
|
||||
deleteGroup: (group: Group, callback?: () => void) => {
|
||||
dispatch(deleteGroup(group, callback));
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -96,4 +116,4 @@ const mapDispatchToProps = dispatch => {
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(withRouter(EditGroup));
|
||||
)(withRouter(GeneralGroup));
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
} from "../modules/groups";
|
||||
|
||||
import { translate } from "react-i18next";
|
||||
import EditGroup from "./EditGroup";
|
||||
import GeneralGroup from "./GeneralGroup";
|
||||
import { getGroupsLink } from "../../modules/indexResource";
|
||||
import SetPermissions from "../../permissions/components/SetPermissions";
|
||||
import {ExtensionPoint} from "@scm-manager/ui-extensions";
|
||||
@@ -99,10 +99,10 @@ class SingleGroup extends React.Component<Props> {
|
||||
<Route
|
||||
path={`${url}/settings/general`}
|
||||
exact
|
||||
component={() => <EditGroup group={group} />}
|
||||
component={() => <GeneralGroup group={group} />}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/permissions`}
|
||||
path={`${url}/settings/permissions`}
|
||||
exact
|
||||
component={() => (
|
||||
<SetPermissions selectedPermissionsLink={group._links.permissions} />
|
||||
@@ -136,7 +136,7 @@ class SingleGroup extends React.Component<Props> {
|
||||
/>
|
||||
<SetPermissionsNavLink
|
||||
group={group}
|
||||
permissionsUrl={`${url}/permissions`}
|
||||
permissionsUrl={`${url}/settings/permissions`}
|
||||
/>
|
||||
</SubNavigation>
|
||||
</Section>
|
||||
|
||||
Reference in New Issue
Block a user