2020-03-23 15:35:58 +01:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2021-02-24 08:17:40 +01:00
|
|
|
import React, { FC } from "react";
|
|
|
|
|
import { Redirect, useRouteMatch } from "react-router-dom";
|
2019-10-20 18:02:52 +02:00
|
|
|
import RepositoryForm from "../components/form";
|
2021-02-24 08:17:40 +01:00
|
|
|
import { Repository } from "@scm-manager/ui-types";
|
2021-02-25 13:01:03 +01:00
|
|
|
import { ErrorNotification, Subtitle, urls } from "@scm-manager/ui-components";
|
2019-10-20 18:02:52 +02:00
|
|
|
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
2020-11-11 15:58:58 +01:00
|
|
|
import RepositoryDangerZone from "./RepositoryDangerZone";
|
2021-02-24 08:17:40 +01:00
|
|
|
import { useTranslation } from "react-i18next";
|
2021-01-08 09:19:33 +01:00
|
|
|
import ExportRepository from "./ExportRepository";
|
2021-02-24 08:17:40 +01:00
|
|
|
import { useIndexLinks, useUpdateRepository } from "@scm-manager/ui-api";
|
2018-08-06 15:41:20 +02:00
|
|
|
|
2021-02-24 08:17:40 +01:00
|
|
|
type Props = {
|
|
|
|
|
repository: Repository;
|
|
|
|
|
};
|
2019-02-06 09:51:31 +01:00
|
|
|
|
2021-02-24 08:17:40 +01:00
|
|
|
const EditRepo: FC<Props> = ({ repository }) => {
|
|
|
|
|
const match = useRouteMatch();
|
|
|
|
|
const { isLoading, error, update, isUpdated } = useUpdateRepository();
|
|
|
|
|
const indexLinks = useIndexLinks();
|
|
|
|
|
const [t] = useTranslation("repos");
|
2019-02-06 09:51:31 +01:00
|
|
|
|
2021-02-24 08:17:40 +01:00
|
|
|
if (isUpdated) {
|
|
|
|
|
return <Redirect to={`/repo/${repository.namespace}/${repository.name}`} />;
|
2018-08-06 15:41:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-02-24 08:17:40 +01:00
|
|
|
const url = urls.matchedUrlFromMatch(match);
|
|
|
|
|
const extensionProps = {
|
|
|
|
|
repository,
|
|
|
|
|
url
|
2018-08-06 15:41:20 +02:00
|
|
|
};
|
|
|
|
|
|
2021-02-24 08:17:40 +01:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Subtitle subtitle={t("repositoryForm.subtitle")} />
|
|
|
|
|
<ErrorNotification error={error} />
|
|
|
|
|
<RepositoryForm repository={repository} loading={isLoading} modifyRepository={update} />
|
2021-02-25 13:01:03 +01:00
|
|
|
{repository._links.exportInfo && <ExportRepository repository={repository} />}
|
2021-02-24 08:17:40 +01:00
|
|
|
<ExtensionPoint name="repo-config.route" props={extensionProps} renderAll={true} />
|
|
|
|
|
<RepositoryDangerZone repository={repository} indexLinks={indexLinks} />
|
|
|
|
|
</>
|
|
|
|
|
);
|
2018-08-06 15:41:20 +02:00
|
|
|
};
|
|
|
|
|
|
2021-02-24 08:17:40 +01:00
|
|
|
export default EditRepo;
|