{
handleEnabledXsrfProtectionChange = (value: boolean) => {
this.props.onChange(true, value, "enabledXsrfProtection");
};
+ handleEnabledUserConverterChange = (value: boolean) => {
+ this.props.onChange(true, value, "enabledUserConverter");
+ };
handleAnonymousMode = (value: string) => {
this.props.onChange(true, value, "anonymousMode");
};
diff --git a/scm-ui/ui-webapp/src/repos/branches/components/BranchForm.tsx b/scm-ui/ui-webapp/src/repos/branches/components/BranchForm.tsx
index 35d2a42bd9..e4d9864c1f 100644
--- a/scm-ui/ui-webapp/src/repos/branches/components/BranchForm.tsx
+++ b/scm-ui/ui-webapp/src/repos/branches/components/BranchForm.tsx
@@ -124,15 +124,13 @@ class BranchForm extends React.Component {
handleSourceChange = (source: string) => {
this.setState({
- ...this.state,
source
});
};
handleNameChange = (name: string) => {
this.setState({
- nameValidationError: !validator.isNameValid(name),
- ...this.state,
+ nameValidationError: !validator.isBranchValid(name),
name
});
};
diff --git a/scm-ui/ui-webapp/src/users/components/UserConverter.tsx b/scm-ui/ui-webapp/src/users/components/UserConverter.tsx
new file mode 100644
index 0000000000..4b2f0f0fa7
--- /dev/null
+++ b/scm-ui/ui-webapp/src/users/components/UserConverter.tsx
@@ -0,0 +1,137 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020-present Cloudogu GmbH and Contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+import React, { FC, useState } from "react";
+import {
+ Button,
+ Modal,
+ PasswordConfirmation,
+ SubmitButton,
+ ErrorNotification,
+ Level
+} from "@scm-manager/ui-components";
+import { useTranslation } from "react-i18next";
+import { Link, User } from "@scm-manager/ui-types";
+import { convertToExternal, convertToInternal } from "./convertUser";
+import styled from "styled-components";
+
+const ExternalDescription = styled.div`
+ display: flex;
+ align-items: center;
+ font-weight: 400;
+`;
+
+type Props = {
+ user: User;
+ fetchUser: (user: User) => void;
+};
+
+const UserConverter: FC = ({ user, fetchUser }) => {
+ const [t] = useTranslation("users");
+ const [showPasswordModal, setShowPasswordModal] = useState(false);
+ const [password, setPassword] = useState("");
+ const [passwordValid, setPasswordValid] = useState(false);
+ const [error, setError] = useState();
+
+ const toInternal = () => {
+ convertToInternal((user._links.convertToInternal as Link).href, password)
+ .then(() => fetchUser(user))
+ .then(() => setShowPasswordModal(false))
+ .catch(setError);
+ };
+
+ const toExternal = () => {
+ convertToExternal((user._links.convertToExternal as Link).href)
+ .then(() => fetchUser(user))
+ .catch(setError);
+ };
+
+ const changePassword = (password: string, valid: boolean) => {
+ setPassword(password);
+ setPasswordValid(valid);
+ };
+
+ const getUserExternalDescription = () => {
+ if (user.external) {
+ return t("userForm.userIsExternal");
+ } else {
+ return t("userForm.userIsInternal");
+ }
+ };
+
+ const getConvertButton = () => {
+ if (user.external) {
+ return (
+
);
-
- passwordChangeField =
;
} else {
// edit existing user
subtitle =
;
@@ -179,18 +179,37 @@ class UserForm extends React.Component
{
/>
- {passwordChangeField}
-