merge with develop

This commit is contained in:
Sebastian Sdorra
2020-07-02 10:24:04 +02:00
55 changed files with 1382 additions and 971 deletions

View File

@@ -113,7 +113,8 @@
"repositoryForm": {
"subtitle": "Repository bearbeiten",
"submit": "Speichern",
"initializeRepository": "Repository initiieren"
"initializeRepository": "Repository initiieren",
"dangerZone": "Gefahrenzone"
},
"sources": {
"file-tree": {
@@ -196,6 +197,8 @@
},
"deleteRepo": {
"button": "Repository löschen",
"subtitle": "Löscht dieses Repository",
"description": "Diese Aktion kann nicht rückgangig gemacht werden.",
"confirmAlert": {
"title": "Repository löschen",
"message": "Soll das Repository wirklich gelöscht werden?",
@@ -203,6 +206,22 @@
"cancel": "Nein"
}
},
"renameRepo": {
"button": "Repository umbenennen",
"subtitle": "Benennt dieses Repository um",
"description": "Es werden keine Weiterleitung auf den neuen Namen eingerichtet.",
"modal": {
"title": "Repository umbenennen",
"label": {
"repoName": "Repository Name",
"repoNamespace": "Repository Namespace"
},
"button": {
"rename": "Umbenennen",
"cancel": "Abbrechen"
}
}
},
"diff": {
"sideBySide": "Zur zweispaltigen Ansicht wechseln",
"combined": "Zur kombinierten Ansicht wechseln",

View File

@@ -113,7 +113,8 @@
"repositoryForm": {
"subtitle": "Edit Repository",
"submit": "Save",
"initializeRepository": "Initialize repository"
"initializeRepository": "Initialize repository",
"dangerZone": "Danger Zone"
},
"sources": {
"file-tree": {
@@ -196,6 +197,8 @@
},
"deleteRepo": {
"button": "Delete Repository",
"subtitle": "Deletes this repository",
"description": "Once a repository was deleted, this cannot be undone. Please be careful with this action.",
"confirmAlert": {
"title": "Delete repository",
"message": "Do you really want to delete the repository?",
@@ -203,6 +206,22 @@
"cancel": "No"
}
},
"renameRepo": {
"button": "Rename Repository",
"subtitle": "Renames this repository",
"description": "There will be no redirects to the renamed repository.",
"modal": {
"title": "Rename repository",
"label": {
"repoName": "Repository name",
"repoNamespace": "Repository namespace"
},
"button": {
"rename": "Rename",
"cancel": "Cancel"
}
}
},
"diff": {
"changes": {
"add": "added",

View File

@@ -44,7 +44,7 @@ import GlobalConfig from "./GlobalConfig";
import RepositoryRoles from "../roles/containers/RepositoryRoles";
import SingleRepositoryRole from "../roles/containers/SingleRepositoryRole";
import CreateRepositoryRole from "../roles/containers/CreateRepositoryRole";
import { StateMenuContextProvider } from "@scm-manager/ui-components/src/navigation/MenuContext";
import { StateMenuContextProvider } from "@scm-manager/ui-components";
type Props = RouteComponentProps &
WithTranslation & {

View File

@@ -54,7 +54,7 @@ import PluginBottomActions from "../components/PluginBottomActions";
import ExecutePendingActionModal from "../components/ExecutePendingActionModal";
import CancelPendingActionModal from "../components/CancelPendingActionModal";
import UpdateAllActionModal from "../components/UpdateAllActionModal";
import { Plugin } from "@scm-manager/ui-types/src";
import { Plugin } from "@scm-manager/ui-types";
import ShowPendingModal from "../components/ShowPendingModal";
type Props = WithTranslation & {

View File

@@ -31,7 +31,7 @@ import { Page } from "@scm-manager/ui-components";
import { getGroupsLink, getUserAutoCompleteLink } from "../../modules/indexResource";
import { createGroup, createGroupReset, getCreateGroupFailure, isCreateGroupPending } from "../modules/groups";
import GroupForm from "../components/GroupForm";
import { apiClient } from "@scm-manager/ui-components/src";
import { apiClient } from "@scm-manager/ui-components";
type Props = WithTranslation & {
createGroup: (link: string, group: Group, callback?: () => void) => void;

View File

@@ -31,7 +31,7 @@ import { DisplayedUser, Group } from "@scm-manager/ui-types";
import { ErrorNotification } from "@scm-manager/ui-components";
import { getUserAutoCompleteLink } from "../../modules/indexResource";
import DeleteGroup from "./DeleteGroup";
import { apiClient } from "@scm-manager/ui-components/src";
import { apiClient } from "@scm-manager/ui-components";
import { compose } from "redux";
type Props = {

View File

@@ -26,8 +26,9 @@ import styled from "styled-components";
import { WithTranslation, withTranslation } from "react-i18next";
import { ExtensionPoint } from "@scm-manager/ui-extensions";
import { Repository, RepositoryType } from "@scm-manager/ui-types";
import { Checkbox, Level, InputField, Select, SubmitButton, Subtitle, Textarea } from "@scm-manager/ui-components";
import { Checkbox, InputField, Level, Select, SubmitButton, Subtitle, Textarea } from "@scm-manager/ui-components";
import * as validator from "./repositoryValidation";
import { CUSTOM_NAMESPACE_STRATEGY } from "../../modules/repos";
const CheckboxWrapper = styled.div`
margin-top: 2em;
@@ -59,8 +60,6 @@ type State = {
contactValidationError: boolean;
};
const CUSTOM_NAMESPACE_STRATEGY = "CustomNamespaceStrategy";
class RepositoryForm extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
@@ -108,7 +107,7 @@ class RepositoryForm extends React.Component<Props, State> {
);
};
submit = (event: Event) => {
submit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
if (this.isValid()) {
this.props.submitForm(this.state.repository, this.state.initRepository);

View File

@@ -0,0 +1,73 @@
/*
* 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 } from "react";
import { Repository, Links } from "@scm-manager/ui-types";
import RenameRepository from "./RenameRepository";
import DeleteRepo from "./DeleteRepo";
import styled from "styled-components";
import { Subtitle } from "@scm-manager/ui-components";
import { useTranslation } from "react-i18next";
type Props = {
repository: Repository;
indexLinks: Links;
};
const DangerZoneContainer = styled.div`
padding: 1rem;
border: 1px solid #ff6a88;
border-radius: 5px;
> *:not(:last-child) {
padding-bottom: 1.5rem;
border-bottom: solid 2px whitesmoke;
}
`;
const DangerZone: FC<Props> = ({ repository, indexLinks }) => {
const [t] = useTranslation("repos");
const dangerZone = [];
if (repository?._links?.rename || repository?._links?.renameWithNamespace) {
dangerZone.push(<RenameRepository repository={repository} indexLinks={indexLinks} />);
}
if (repository?._links?.delete) {
// @ts-ignore
dangerZone.push(<DeleteRepo repository={repository} />);
}
if (dangerZone.length === 0) {
return null;
}
return (
<>
<hr />
<Subtitle subtitle={t("repositoryForm.dangerZone")} />
<DangerZoneContainer>{dangerZone.map(entry => entry)}</DangerZoneContainer>
</>
);
};
export default DangerZone;

View File

@@ -24,23 +24,21 @@
import React from "react";
import { connect } from "react-redux";
import { compose } from "redux";
import { withRouter } from "react-router-dom";
import { RouteComponentProps, withRouter } from "react-router-dom";
import { WithTranslation, withTranslation } from "react-i18next";
import { History } from "history";
import { Repository } from "@scm-manager/ui-types";
import { confirmAlert, DeleteButton, ErrorNotification, Level } from "@scm-manager/ui-components";
import { confirmAlert, DeleteButton, ErrorNotification, Level, ButtonGroup } from "@scm-manager/ui-components";
import { deleteRepo, getDeleteRepoFailure, isDeleteRepoPending } from "../modules/repos";
type Props = WithTranslation & {
loading: boolean;
error: Error;
repository: Repository;
confirmDialog?: boolean;
deleteRepo: (p1: Repository, p2: () => void) => void;
// context props
history: History;
};
type Props = RouteComponentProps &
WithTranslation & {
loading: boolean;
error: Error;
repository: Repository;
confirmDialog?: boolean;
deleteRepo: (p1: Repository, p2: () => void) => void;
};
class DeleteRepo extends React.Component<Props> {
static defaultProps = {
@@ -88,9 +86,16 @@ class DeleteRepo extends React.Component<Props> {
return (
<>
<hr />
<ErrorNotification error={error} />
<Level right={<DeleteButton label={t("deleteRepo.button")} action={action} loading={loading} />} />
<Level
left={
<div>
<strong>{t("deleteRepo.subtitle")}</strong>
<p>{t("deleteRepo.description")}</p>
</div>
}
right={<DeleteButton label={t("deleteRepo.button")} action={action} loading={loading} />}
/>
</>
);
}

View File

@@ -25,17 +25,19 @@ import React from "react";
import { connect } from "react-redux";
import { withRouter } from "react-router-dom";
import RepositoryForm from "../components/form";
import DeleteRepo from "./DeleteRepo";
import { Repository } from "@scm-manager/ui-types";
import { Repository, Links } from "@scm-manager/ui-types";
import { getModifyRepoFailure, isModifyRepoPending, modifyRepo, modifyRepoReset } from "../modules/repos";
import { History } from "history";
import { ErrorNotification } from "@scm-manager/ui-components";
import { ExtensionPoint } from "@scm-manager/ui-extensions";
import { compose } from "redux";
import DangerZone from "./DangerZone";
import { getLinks } from "../../modules/indexResource";
type Props = {
loading: boolean;
error: Error;
indexLinks: Links;
modifyRepo: (p1: Repository, p2: () => void) => void;
modifyRepoReset: (p: Repository) => void;
@@ -69,7 +71,7 @@ class EditRepo extends React.Component<Props> {
};
render() {
const { loading, error, repository } = this.props;
const { loading, error, repository, indexLinks } = this.props;
const url = this.matchedUrl();
@@ -79,7 +81,7 @@ class EditRepo extends React.Component<Props> {
};
return (
<div>
<>
<ErrorNotification error={error} />
<RepositoryForm
repository={this.props.repository}
@@ -89,8 +91,8 @@ class EditRepo extends React.Component<Props> {
}}
/>
<ExtensionPoint name="repo-config.route" props={extensionProps} renderAll={true} />
<DeleteRepo repository={repository} />
</div>
<DangerZone repository={repository} indexLinks={indexLinks} />
</>
);
}
}
@@ -99,9 +101,12 @@ const mapStateToProps = (state: any, ownProps: Props) => {
const { namespace, name } = ownProps.repository;
const loading = isModifyRepoPending(state, namespace, name);
const error = getModifyRepoFailure(state, namespace, name);
const indexLinks = getLinks(state);
return {
loading,
error
error,
indexLinks
};
};

View File

@@ -0,0 +1,178 @@
/*
* 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, useEffect, useState } from "react";
import { Link, Links, Repository } from "@scm-manager/ui-types";
import { CONTENT_TYPE, CUSTOM_NAMESPACE_STRATEGY } from "../modules/repos";
import { Button, ButtonGroup, ErrorNotification, InputField, Level, Loading, Modal } from "@scm-manager/ui-components";
import { useTranslation } from "react-i18next";
import { apiClient } from "@scm-manager/ui-components";
import { useHistory } from "react-router-dom";
import { ExtensionPoint } from "@scm-manager/ui-extensions";
import * as validator from "../components/form/repositoryValidation";
type Props = {
repository: Repository;
indexLinks: Links;
};
const RenameRepository: FC<Props> = ({ repository, indexLinks }) => {
let history = useHistory();
const [t] = useTranslation("repos");
const [error, setError] = useState<Error | undefined>(undefined);
const [loading, setLoading] = useState(false);
const [showModal, setShowModal] = useState(false);
const [name, setName] = useState(repository.name);
const [namespace, setNamespace] = useState(repository.namespace);
const [nameValidationError, setNameValidationError] = useState(false);
const [namespaceValidationError, setNamespaceValidationError] = useState(false);
const [currentNamespaceStrategie, setCurrentNamespaceStrategy] = useState("");
useEffect(() => {
apiClient
.get((indexLinks?.namespaceStrategies as Link).href)
.then(result => result.json())
.then(result => setCurrentNamespaceStrategy(result.current))
.catch(setError);
}, [repository]);
if (error) {
return <ErrorNotification error={error} />;
}
if (loading) {
return <Loading />;
}
const isValid =
!nameValidationError &&
!namespaceValidationError &&
(repository.name !== name || repository.namespace !== namespace);
const handleNamespaceChange = (namespace: string) => {
setNamespaceValidationError(!validator.isNameValid(namespace));
setNamespace(namespace);
};
const handleNameChange = (name: string) => {
setNameValidationError(!validator.isNameValid(name));
setName(name);
};
const renderNamespaceField = () => {
const props = {
label: t("repository.namespace"),
helpText: t("help.namespaceHelpText"),
value: namespace,
onChange: handleNamespaceChange,
errorMessage: t("validation.namespace-invalid"),
validationError: namespaceValidationError
};
if (currentNamespaceStrategie === CUSTOM_NAMESPACE_STRATEGY) {
return <InputField {...props} />;
}
return <ExtensionPoint name="repos.create.namespace" props={props} renderAll={false} />;
};
const rename = () => {
setLoading(true);
const url = repository?._links?.renameWithNamespace
? (repository?._links?.renameWithNamespace as Link).href
: (repository?._links?.rename as Link).href;
apiClient
.post(url, { name, namespace }, CONTENT_TYPE)
.then(() => setLoading(false))
.then(() => history.push(`/repo/${namespace}/${name}`))
.catch(setError);
};
const modalBody = (
<div>
<InputField
label={t("renameRepo.modal.label.repoName")}
name={t("renameRepo.modal.label.repoName")}
errorMessage={t("validation.name-invalid")}
helpText={t("help.nameHelpText")}
validationError={nameValidationError}
value={name}
onChange={handleNameChange}
/>
{renderNamespaceField()}
</div>
);
const footer = (
<>
<ButtonGroup>
<Button
color="warning"
icon="exclamation-triangle"
label={t("renameRepo.modal.button.rename")}
disabled={!isValid}
title={t("renameRepo.modal.button.rename")}
action={rename}
/>
<Button
label={t("renameRepo.modal.button.cancel")}
title={t("renameRepo.modal.button.cancel")}
action={() => setShowModal(false)}
/>
</ButtonGroup>
</>
);
return (
<>
<Modal
active={showModal}
title={t("renameRepo.modal.title")}
footer={footer}
body={modalBody}
closeFunction={() => setShowModal(false)}
/>
<Level
left={
<div>
<strong>{t("renameRepo.subtitle")}</strong>
<p>{t("renameRepo.description")}</p>
</div>
}
right={
<Button
label={t("renameRepo.button")}
action={() => setShowModal(true)}
loading={loading}
color="warning"
icon="edit"
/>
}
/>
</>
);
};
export default RenameRepository;

View File

@@ -74,6 +74,13 @@ class RepositoryRoot extends React.Component<Props> {
fetchRepoByName(repoLink, namespace, name);
}
componentDidUpdate(prevProps: Props) {
const { fetchRepoByName, namespace, name, repoLink } = this.props;
if (namespace !== prevProps.namespace || name !== prevProps.name) {
fetchRepoByName(repoLink, namespace, name);
}
}
stripEndingSlash = (url: string) => {
if (url.endsWith("/")) {
return url.substring(0, url.length - 1);

View File

@@ -27,7 +27,6 @@ import * as types from "../../modules/types";
import { Action, Repository, RepositoryCollection } from "@scm-manager/ui-types";
import { isPending } from "../../modules/pending";
import { getFailure } from "../../modules/failure";
import React from "react";
export const FETCH_REPOS = "scm/repos/FETCH_REPOS";
export const FETCH_REPOS_PENDING = `${FETCH_REPOS}_${types.PENDING_SUFFIX}`;
@@ -56,7 +55,9 @@ export const DELETE_REPO_PENDING = `${DELETE_REPO}_${types.PENDING_SUFFIX}`;
export const DELETE_REPO_SUCCESS = `${DELETE_REPO}_${types.SUCCESS_SUFFIX}`;
export const DELETE_REPO_FAILURE = `${DELETE_REPO}_${types.FAILURE_SUFFIX}`;
const CONTENT_TYPE = "application/vnd.scmm-repository+json;v=2";
export const CONTENT_TYPE = "application/vnd.scmm-repository+json;v=2";
export const CUSTOM_NAMESPACE_STRATEGY = "CustomNamespaceStrategy";
// fetch repos

View File

@@ -29,7 +29,7 @@ import { binder, ExtensionPoint } from "@scm-manager/ui-extensions";
import { File } from "@scm-manager/ui-types";
import { DateFromNow, FileSize, Tooltip } from "@scm-manager/ui-components";
import FileIcon from "./FileIcon";
import { Icon } from "@scm-manager/ui-components/src";
import { Icon } from "@scm-manager/ui-components";
import { WithTranslation, withTranslation } from "react-i18next";
type Props = WithTranslation & {