mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
Feature/import export encryption (#1533)
Add option to encrypt repository exports with a password and add possibility to decrypt them on repository import. Also make the repository export asynchronous. This implies that the repository export will be created on the server and can be downloaded multiple times. The repository export will be deleted automatically 10 days after creation.
This commit is contained in:
@@ -28,7 +28,6 @@ import RepositoryInformationForm from "./RepositoryInformationForm";
|
||||
import { apiClient, ErrorNotification, Level, SubmitButton } from "@scm-manager/ui-components";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import ImportFromBundleForm from "./ImportFromBundleForm";
|
||||
import ImportFullRepositoryForm from "./ImportFullRepositoryForm";
|
||||
|
||||
type Props = {
|
||||
@@ -44,9 +43,9 @@ const ImportFullRepository: FC<Props> = ({ url, repositoryType, setImportPending
|
||||
type: repositoryType,
|
||||
contact: "",
|
||||
description: "",
|
||||
_links: {},
|
||||
_links: {}
|
||||
});
|
||||
|
||||
const [password, setPassword] = useState("");
|
||||
const [valid, setValid] = useState({ namespaceAndName: false, contact: true, file: false });
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<Error | undefined>();
|
||||
@@ -59,7 +58,7 @@ const ImportFullRepository: FC<Props> = ({ url, repositoryType, setImportPending
|
||||
setLoading(loading);
|
||||
};
|
||||
|
||||
const isValid = () => Object.values(valid).every((v) => v);
|
||||
const isValid = () => Object.values(valid).every(v => v);
|
||||
|
||||
const submit = (event: FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
@@ -69,7 +68,7 @@ const ImportFullRepository: FC<Props> = ({ url, repositoryType, setImportPending
|
||||
apiClient
|
||||
.postBinary(url, formData => {
|
||||
formData.append("bundle", file, file?.name);
|
||||
formData.append("repository", JSON.stringify(repo));
|
||||
formData.append("repository", JSON.stringify({ ...repo, password }));
|
||||
})
|
||||
.then(response => {
|
||||
const location = response.headers.get("Location");
|
||||
@@ -91,7 +90,12 @@ const ImportFullRepository: FC<Props> = ({ url, repositoryType, setImportPending
|
||||
return (
|
||||
<form onSubmit={submit}>
|
||||
<ErrorNotification error={error} />
|
||||
<ImportFullRepositoryForm setFile={setFile} setValid={(file: boolean) => setValid({ ...valid, file })}/>
|
||||
<ImportFullRepositoryForm
|
||||
setFile={setFile}
|
||||
password={password}
|
||||
setPassword={setPassword}
|
||||
setValid={(file: boolean) => setValid({ ...valid, file })}
|
||||
/>
|
||||
<hr />
|
||||
<NamespaceAndNameFields
|
||||
repository={repo}
|
||||
|
||||
Reference in New Issue
Block a user