merged with 2.0.0-m3

This commit is contained in:
Florian Scholdei
2018-12-21 14:31:23 +01:00
56 changed files with 1461 additions and 369 deletions

View File

@@ -1,40 +0,0 @@
// @flow
import React from "react";
import classNames from "classnames";
type Props = {
options: string[],
optionSelected: string => void,
preselectedOption?: string,
className: any
};
class DropDown extends React.Component<Props> {
render() {
const { options, preselectedOption, className } = this.props;
return (
<div className={classNames(className, "select")}>
<select
value={preselectedOption ? preselectedOption : ""}
onChange={this.change}
>
<option key="" />
{options.map(option => {
return (
<option key={option} value={option}>
{option}
</option>
);
})}
</select>
</div>
);
}
change = (event: SyntheticInputEvent<HTMLSelectElement>) => {
this.props.optionSelected(event.target.value);
};
}
export default DropDown;

View File

@@ -1,106 +0,0 @@
// @flow
import React from "react";
import type { Branch } from "@scm-manager/ui-types";
import DropDown from "../components/DropDown";
import { translate } from "react-i18next";
import injectSheet from "react-jss";
import { compose } from "redux";
import classNames from "classnames";
const styles = {
zeroflex: {
flexGrow: 0
},
minWidthOfLabel: {
minWidth: "4.5rem"
},
wrapper: {
padding: "1rem 1.5rem 0.25rem 1.5rem",
border: "1px solid #eee",
borderRadius: "5px 5px 0 0"
}
};
type Props = {
branches: Branch[], // TODO: Use generics?
selected: (branch?: Branch) => void,
selectedBranch: string,
// context props
classes: Object,
t: string => string
};
type State = { selectedBranch?: Branch };
class BranchSelector extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {};
}
componentDidMount() {
this.props.branches
.filter(branch => branch.name === this.props.selectedBranch)
.forEach(branch => this.setState({ selectedBranch: branch }));
}
render() {
const { branches, classes, t } = this.props;
if (branches) {
return (
<div
className={classNames(
"has-background-light field",
"is-horizontal",
classes.wrapper
)}
>
<div
className={classNames(
"field-label",
"is-normal",
classes.zeroflex,
classes.minWidthOfLabel
)}
>
<label className="label">{t("branch-selector.label")}</label>
</div>
<div className="field-body">
<div className="field is-narrow">
<div className="control">
<DropDown
className="is-fullwidth"
options={branches.map(b => b.name)}
optionSelected={this.branchSelected}
preselectedOption={
this.state.selectedBranch
? this.state.selectedBranch.name
: ""
}
/>
</div>
</div>
</div>
</div>
);
} else {
return null;
}
}
branchSelected = (branchName: string) => {
const { branches, selected } = this.props;
const branch = branches.find(b => b.name === branchName);
selected(branch);
this.setState({ selectedBranch: branch });
};
}
export default compose(
injectSheet(styles),
translate("repos")
)(BranchSelector);

View File

@@ -2,11 +2,15 @@
import React from "react";
import type { Branch, Repository } from "@scm-manager/ui-types";
import { translate } from "react-i18next";
import { Route, withRouter } from "react-router-dom";
import Changesets from "./Changesets";
import BranchSelector from "./BranchSelector";
import { connect } from "react-redux";
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
import {
BranchSelector,
ErrorNotification,
Loading
} from "@scm-manager/ui-components";
import {
fetchBranches,
getBranches,
@@ -32,7 +36,8 @@ type Props = {
// Context props
history: any, // TODO flow type
match: any
match: any,
t: string => string
};
class BranchRoot extends React.Component<Props> {
@@ -92,10 +97,11 @@ class BranchRoot extends React.Component<Props> {
}
renderBranchSelector = () => {
const { repository, branches, selected } = this.props;
const { repository, branches, selected, t } = this.props;
if (repository._links.branches) {
return (
<BranchSelector
label={t("branch-selector.label")}
branches={branches}
selectedBranch={selected}
selected={(b: Branch) => {
@@ -133,6 +139,7 @@ const mapStateToProps = (state: any, ownProps: Props) => {
export default compose(
withRouter,
translate("repos"),
connect(
mapStateToProps,
mapDispatchToProps

View File

@@ -1,32 +1,19 @@
//@flow
import React from "react";
import {
deleteRepo,
fetchRepoByName,
getFetchRepoFailure,
getRepository,
isFetchRepoPending
} from "../modules/repos";
import {deleteRepo, fetchRepoByName, getFetchRepoFailure, getRepository, isFetchRepoPending} from "../modules/repos";
import { connect } from "react-redux";
import { Route, Switch } from "react-router-dom";
import type { Repository } from "@scm-manager/ui-types";
import {connect} from "react-redux";
import {Route, Switch} from "react-router-dom";
import type {Repository} from "@scm-manager/ui-types";
import {
ErrorPage,
Loading,
Navigation,
NavLink,
Page,
Section
} from "@scm-manager/ui-components";
import { translate } from "react-i18next";
import {ErrorPage, Loading, Navigation, NavLink, Page, Section} from "@scm-manager/ui-components";
import {translate} from "react-i18next";
import RepositoryDetails from "../components/RepositoryDetails";
import DeleteNavAction from "../components/DeleteNavAction";
import Edit from "../containers/Edit";
import Permissions from "../permissions/containers/Permissions";
import type { History } from "history";
import type {History} from "history";
import EditNavLink from "../components/EditNavLink";
import BranchRoot from "./ChangesetsRoot";
@@ -34,8 +21,8 @@ import ChangesetView from "./ChangesetView";
import PermissionsNavLink from "../components/PermissionsNavLink";
import Sources from "../sources/containers/Sources";
import RepositoryNavLink from "../components/RepositoryNavLink";
import { getRepositoriesLink } from "../../modules/indexResource";
import { ExtensionPoint } from "@scm-manager/ui-extensions";
import {getRepositoriesLink} from "../../modules/indexResource";
import {ExtensionPoint} from "@scm-manager/ui-extensions";
type Props = {
namespace: string,
@@ -200,15 +187,15 @@ class RepositoryRoot extends React.Component<Props> {
label={t("repository-root.sources")}
activeOnlyWhenExact={false}
/>
<PermissionsNavLink
permissionUrl={`${url}/permissions`}
repository={repository}
/>
<ExtensionPoint
name="repository.navigation"
props={extensionProps}
renderAll={true}
/>
<PermissionsNavLink
permissionUrl={`${url}/permissions`}
repository={repository}
/>
</Section>
<Section label={t("repository-root.actions-label")}>
<DeleteNavAction repository={repository} delete={this.delete} />

View File

@@ -5,7 +5,8 @@ import { withRouter } from "react-router-dom";
import type { Branch, Repository } from "@scm-manager/ui-types";
import FileTree from "../components/FileTree";
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
import BranchSelector from "../../containers/BranchSelector";
import BranchSelector from "../../../../../scm-ui-components/packages/ui-components/src/BranchSelector";
import { translate } from "react-i18next";
import {
fetchBranches,
getBranches,
@@ -32,7 +33,8 @@ type Props = {
// Context props
history: any,
match: any
match: any,
t: string => string
};
class Sources extends React.Component<Props> {
@@ -109,13 +111,14 @@ class Sources extends React.Component<Props> {
}
renderBranchSelector = () => {
const { branches, revision } = this.props;
const { branches, revision, t } = this.props;
if (branches) {
return (
<BranchSelector
branches={branches}
selectedBranch={revision}
label={t("branch-selector.label")}
selected={(b: Branch) => {
this.branchSelected(b);
}}
@@ -160,6 +163,7 @@ const mapDispatchToProps = dispatch => {
};
export default compose(
translate("repos"),
withRouter,
connect(
mapStateToProps,