mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 19:15:52 +01:00
fix formatting with prettier
This commit is contained in:
@@ -29,14 +29,14 @@ import parser from "gitdiff-parser";
|
||||
import simpleDiff from "../__resources__/Diff.simple";
|
||||
import hunksDiff from "../__resources__/Diff.hunks";
|
||||
import binaryDiff from "../__resources__/Diff.binary";
|
||||
import {DiffEventContext, File, FileControlFactory} from "./DiffTypes";
|
||||
import { DiffEventContext, File, FileControlFactory } from "./DiffTypes";
|
||||
import Toast from "../toast/Toast";
|
||||
import { getPath } from "./diffs";
|
||||
import DiffButton from "./DiffButton";
|
||||
import styled from "styled-components";
|
||||
import { MemoryRouter } from "react-router-dom";
|
||||
import {one, two} from "../__resources__/changesets";
|
||||
import {Changeset} from "@scm-manager/ui-types";
|
||||
import { one, two } from "../__resources__/changesets";
|
||||
import { Changeset } from "@scm-manager/ui-types";
|
||||
import JumpToFileButton from "./JumpToFileButton";
|
||||
|
||||
const diffFiles = parser.parse(simpleDiff);
|
||||
@@ -47,7 +47,7 @@ const Container = styled.div`
|
||||
|
||||
const RoutingDecorator = (story: () => ReactNode) => <MemoryRouter initialEntries={["/"]}>{story()}</MemoryRouter>;
|
||||
|
||||
const fileControlFactory: (changeset: Changeset) => FileControlFactory = (changeset) => (file) => {
|
||||
const fileControlFactory: (changeset: Changeset) => FileControlFactory = changeset => file => {
|
||||
const baseUrl = "/repo/hitchhiker/heartOfGold/code/changeset";
|
||||
const sourceLink = {
|
||||
url: `${baseUrl}/${changeset.id}/${file.newPath}/`,
|
||||
@@ -76,10 +76,7 @@ const fileControlFactory: (changeset: Changeset) => FileControlFactory = (change
|
||||
}
|
||||
}
|
||||
|
||||
return links.map(({url, label}) => <JumpToFileButton
|
||||
tooltip={label}
|
||||
link={url}
|
||||
/>);
|
||||
return links.map(({ url, label }) => <JumpToFileButton tooltip={label} link={url} />);
|
||||
};
|
||||
|
||||
storiesOf("Diff", module)
|
||||
@@ -164,8 +161,4 @@ storiesOf("Diff", module)
|
||||
});
|
||||
return <Diff diff={filesWithLanguage} />;
|
||||
})
|
||||
.add("WithLinkToFile", () => (
|
||||
<Diff
|
||||
diff={diffFiles}
|
||||
/>
|
||||
));
|
||||
.add("WithLinkToFile", () => <Diff diff={diffFiles} />);
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
*/
|
||||
import React from "react";
|
||||
import DiffFile from "./DiffFile";
|
||||
import {DiffObjectProps, File, FileControlFactory} from "./DiffTypes";
|
||||
import { DiffObjectProps, File, FileControlFactory } from "./DiffTypes";
|
||||
import Notification from "../Notification";
|
||||
import {WithTranslation, withTranslation} from "react-i18next";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
|
||||
type Props = WithTranslation &
|
||||
DiffObjectProps & {
|
||||
diff: File[];
|
||||
fileControlFactory?: FileControlFactory;
|
||||
};
|
||||
diff: File[];
|
||||
fileControlFactory?: FileControlFactory;
|
||||
};
|
||||
|
||||
class Diff extends React.Component<Props> {
|
||||
static defaultProps: Partial<Props> = {
|
||||
@@ -39,7 +39,7 @@ class Diff extends React.Component<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const {diff, t, ...fileProps} = this.props;
|
||||
const { diff, t, ...fileProps } = this.props;
|
||||
return (
|
||||
<>
|
||||
{diff.length === 0 ? (
|
||||
|
||||
@@ -22,21 +22,21 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
import React from "react";
|
||||
import {withTranslation, WithTranslation} from "react-i18next";
|
||||
import { withTranslation, WithTranslation } from "react-i18next";
|
||||
import classNames from "classnames";
|
||||
import styled from "styled-components";
|
||||
// @ts-ignore
|
||||
import {Decoration, getChangeKey, Hunk} from "react-diff-view";
|
||||
import {ButtonGroup} from "../buttons";
|
||||
import { Decoration, getChangeKey, Hunk } from "react-diff-view";
|
||||
import { ButtonGroup } from "../buttons";
|
||||
import Tag from "../Tag";
|
||||
import Icon from "../Icon";
|
||||
import {Change, ChangeEvent, DiffObjectProps, File, Hunk as HunkType} from "./DiffTypes";
|
||||
import { Change, ChangeEvent, DiffObjectProps, File, Hunk as HunkType } from "./DiffTypes";
|
||||
import TokenizedDiffView from "./TokenizedDiffView";
|
||||
import DiffButton from "./DiffButton";
|
||||
import {MenuContext} from "@scm-manager/ui-components";
|
||||
import DiffExpander, {ExpandableHunk} from "./DiffExpander";
|
||||
import { MenuContext } from "@scm-manager/ui-components";
|
||||
import DiffExpander, { ExpandableHunk } from "./DiffExpander";
|
||||
import HunkExpandLink from "./HunkExpandLink";
|
||||
import {Modal} from "../modals";
|
||||
import { Modal } from "../modals";
|
||||
import ErrorNotification from "../ErrorNotification";
|
||||
import HunkExpandDivider from "./HunkExpandDivider";
|
||||
|
||||
@@ -44,8 +44,8 @@ const EMPTY_ANNOTATION_FACTORY = {};
|
||||
|
||||
type Props = DiffObjectProps &
|
||||
WithTranslation & {
|
||||
file: File;
|
||||
};
|
||||
file: File;
|
||||
};
|
||||
|
||||
type Collapsible = {
|
||||
collapsed?: boolean;
|
||||
@@ -115,7 +115,7 @@ class DiffFile extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
defaultCollapse: () => boolean = () => {
|
||||
const {defaultCollapse, file} = this.props;
|
||||
const { defaultCollapse, file } = this.props;
|
||||
if (typeof defaultCollapse === "boolean") {
|
||||
return defaultCollapse;
|
||||
} else if (typeof defaultCollapse === "function") {
|
||||
@@ -126,7 +126,7 @@ class DiffFile extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
toggleCollapse = () => {
|
||||
const {file} = this.state;
|
||||
const { file } = this.state;
|
||||
if (this.hasContent(file)) {
|
||||
this.setState(state => ({
|
||||
collapsed: !state.collapsed
|
||||
@@ -157,7 +157,7 @@ class DiffFile extends React.Component<Props, State> {
|
||||
<HunkExpandLink
|
||||
icon={"fa-angle-double-up"}
|
||||
onClick={this.expandHead(expandableHunk, expandableHunk.maxExpandHeadRange)}
|
||||
text={this.props.t("diff.expandComplete", {count: expandableHunk.maxExpandHeadRange})}
|
||||
text={this.props.t("diff.expandComplete", { count: expandableHunk.maxExpandHeadRange })}
|
||||
/>
|
||||
</HunkExpandDivider>
|
||||
);
|
||||
@@ -167,19 +167,19 @@ class DiffFile extends React.Component<Props, State> {
|
||||
<HunkExpandLink
|
||||
icon={"fa-angle-up"}
|
||||
onClick={this.expandHead(expandableHunk, 10)}
|
||||
text={this.props.t("diff.expandByLines", {count: 10})}
|
||||
text={this.props.t("diff.expandByLines", { count: 10 })}
|
||||
/>{" "}
|
||||
<HunkExpandLink
|
||||
icon={"fa-angle-double-up"}
|
||||
onClick={this.expandHead(expandableHunk, expandableHunk.maxExpandHeadRange)}
|
||||
text={this.props.t("diff.expandComplete", {count: expandableHunk.maxExpandHeadRange})}
|
||||
text={this.props.t("diff.expandComplete", { count: expandableHunk.maxExpandHeadRange })}
|
||||
/>
|
||||
</HunkExpandDivider>
|
||||
);
|
||||
}
|
||||
}
|
||||
// hunk header must be defined
|
||||
return <span/>;
|
||||
return <span />;
|
||||
};
|
||||
|
||||
createHunkFooter = (expandableHunk: ExpandableHunk) => {
|
||||
@@ -190,7 +190,7 @@ class DiffFile extends React.Component<Props, State> {
|
||||
<HunkExpandLink
|
||||
icon={"fa-angle-double-down"}
|
||||
onClick={this.expandBottom(expandableHunk, expandableHunk.maxExpandBottomRange)}
|
||||
text={this.props.t("diff.expandComplete", {count: expandableHunk.maxExpandBottomRange})}
|
||||
text={this.props.t("diff.expandComplete", { count: expandableHunk.maxExpandBottomRange })}
|
||||
/>
|
||||
</HunkExpandDivider>
|
||||
);
|
||||
@@ -200,19 +200,19 @@ class DiffFile extends React.Component<Props, State> {
|
||||
<HunkExpandLink
|
||||
icon={"fa-angle-down"}
|
||||
onClick={this.expandBottom(expandableHunk, 10)}
|
||||
text={this.props.t("diff.expandByLines", {count: 10})}
|
||||
text={this.props.t("diff.expandByLines", { count: 10 })}
|
||||
/>{" "}
|
||||
<HunkExpandLink
|
||||
icon={"fa-angle-double-down"}
|
||||
onClick={this.expandBottom(expandableHunk, expandableHunk.maxExpandBottomRange)}
|
||||
text={this.props.t("diff.expandComplete", {count: expandableHunk.maxExpandBottomRange})}
|
||||
text={this.props.t("diff.expandComplete", { count: expandableHunk.maxExpandBottomRange })}
|
||||
/>
|
||||
</HunkExpandDivider>
|
||||
);
|
||||
}
|
||||
}
|
||||
// hunk footer must be defined
|
||||
return <span/>;
|
||||
return <span />;
|
||||
};
|
||||
|
||||
createLastHunkFooter = (expandableHunk: ExpandableHunk) => {
|
||||
@@ -222,7 +222,7 @@ class DiffFile extends React.Component<Props, State> {
|
||||
<HunkExpandLink
|
||||
icon={"fa-angle-down"}
|
||||
onClick={this.expandBottom(expandableHunk, 10)}
|
||||
text={this.props.t("diff.expandLastBottomByLines", {count: 10})}
|
||||
text={this.props.t("diff.expandLastBottomByLines", { count: 10 })}
|
||||
/>{" "}
|
||||
<HunkExpandLink
|
||||
icon={"fa-angle-double-down"}
|
||||
@@ -233,7 +233,7 @@ class DiffFile extends React.Component<Props, State> {
|
||||
);
|
||||
}
|
||||
// hunk header must be defined
|
||||
return <span/>;
|
||||
return <span />;
|
||||
};
|
||||
|
||||
expandHead = (expandableHunk: ExpandableHunk, count: number) => {
|
||||
@@ -255,16 +255,16 @@ class DiffFile extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
diffExpanded = (newFile: File) => {
|
||||
this.setState({file: newFile, diffExpander: new DiffExpander(newFile)});
|
||||
this.setState({ file: newFile, diffExpander: new DiffExpander(newFile) });
|
||||
};
|
||||
|
||||
diffExpansionFailed = (err: any) => {
|
||||
this.setState({expansionError: err});
|
||||
this.setState({ expansionError: err });
|
||||
};
|
||||
|
||||
collectHunkAnnotations = (hunk: HunkType) => {
|
||||
const {annotationFactory} = this.props;
|
||||
const {file} = this.state;
|
||||
const { annotationFactory } = this.props;
|
||||
const { file } = this.state;
|
||||
if (annotationFactory) {
|
||||
return annotationFactory({
|
||||
hunk,
|
||||
@@ -276,8 +276,8 @@ class DiffFile extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
handleClickEvent = (change: Change, hunk: HunkType) => {
|
||||
const {onClick} = this.props;
|
||||
const {file} = this.state;
|
||||
const { onClick } = this.props;
|
||||
const { file } = this.state;
|
||||
const context = {
|
||||
changeId: getChangeKey(change),
|
||||
change,
|
||||
@@ -290,7 +290,7 @@ class DiffFile extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
createGutterEvents = (hunk: HunkType) => {
|
||||
const {onClick} = this.props;
|
||||
const { onClick } = this.props;
|
||||
if (onClick) {
|
||||
return {
|
||||
onClick: (event: ChangeEvent) => {
|
||||
@@ -311,7 +311,7 @@ class DiffFile extends React.Component<Props, State> {
|
||||
} else if (i > 0) {
|
||||
items.push(
|
||||
<Decoration>
|
||||
<HunkDivider/>
|
||||
<HunkDivider />
|
||||
</Decoration>
|
||||
);
|
||||
}
|
||||
@@ -354,7 +354,7 @@ class DiffFile extends React.Component<Props, State> {
|
||||
if (file.oldPath !== file.newPath && (file.type === "copy" || file.type === "rename")) {
|
||||
return (
|
||||
<>
|
||||
{file.oldPath} <Icon name="arrow-right" color="inherit"/> {file.newPath}
|
||||
{file.oldPath} <Icon name="arrow-right" color="inherit" /> {file.newPath}
|
||||
</>
|
||||
);
|
||||
} else if (file.type === "delete") {
|
||||
@@ -373,7 +373,7 @@ class DiffFile extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
renderChangeTag = (file: File) => {
|
||||
const {t} = this.props;
|
||||
const { t } = this.props;
|
||||
if (!file.type) {
|
||||
return;
|
||||
}
|
||||
@@ -385,14 +385,14 @@ class DiffFile extends React.Component<Props, State> {
|
||||
const color =
|
||||
value === "added" ? "success is-outlined" : value === "deleted" ? "danger is-outlined" : "info is-outlined";
|
||||
|
||||
return <ChangeTypeTag className={classNames("is-rounded", "has-text-weight-normal")} color={color} label={value}/>;
|
||||
return <ChangeTypeTag className={classNames("is-rounded", "has-text-weight-normal")} color={color} label={value} />;
|
||||
};
|
||||
|
||||
hasContent = (file: File) => file && !file.isBinary && file.hunks && file.hunks.length > 0;
|
||||
|
||||
render() {
|
||||
const {fileControlFactory, fileAnnotationFactory, t} = this.props;
|
||||
const {file, collapsed, sideBySide, diffExpander, expansionError} = this.state;
|
||||
const { fileControlFactory, fileAnnotationFactory, t } = this.props;
|
||||
const { file, collapsed, sideBySide, diffExpander, expansionError } = this.state;
|
||||
const viewType = sideBySide ? "split" : "unified";
|
||||
|
||||
let body = null;
|
||||
@@ -413,39 +413,41 @@ class DiffFile extends React.Component<Props, State> {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const collapseIcon = this.hasContent(file) ? <Icon name={icon} color="inherit"/> : null;
|
||||
const collapseIcon = this.hasContent(file) ? <Icon name={icon} color="inherit" /> : null;
|
||||
const fileControls = fileControlFactory ? fileControlFactory(file, this.setCollapse) : null;
|
||||
const sideBySideToggle = file.hunks && file.hunks.length && <MenuContext.Consumer>
|
||||
{({setCollapsed}) => (
|
||||
<DiffButton
|
||||
icon={sideBySide ? "align-left" : "columns"}
|
||||
tooltip={t(sideBySide ? "diff.combined" : "diff.sideBySide")}
|
||||
onClick={() =>
|
||||
this.toggleSideBySide(() => {
|
||||
if (this.state.sideBySide) {
|
||||
setCollapsed(true);
|
||||
}
|
||||
})
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</MenuContext.Consumer>;
|
||||
const sideBySideToggle = file.hunks && file.hunks.length && (
|
||||
<MenuContext.Consumer>
|
||||
{({ setCollapsed }) => (
|
||||
<DiffButton
|
||||
icon={sideBySide ? "align-left" : "columns"}
|
||||
tooltip={t(sideBySide ? "diff.combined" : "diff.sideBySide")}
|
||||
onClick={() =>
|
||||
this.toggleSideBySide(() => {
|
||||
if (this.state.sideBySide) {
|
||||
setCollapsed(true);
|
||||
}
|
||||
})
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</MenuContext.Consumer>
|
||||
);
|
||||
const headerButtons = (
|
||||
<ButtonWrapper className={classNames("level-right", "is-flex")}>
|
||||
<ButtonGroup>
|
||||
{sideBySideToggle}
|
||||
{fileControls}
|
||||
</ButtonGroup>
|
||||
</ButtonWrapper>
|
||||
);
|
||||
<ButtonWrapper className={classNames("level-right", "is-flex")}>
|
||||
<ButtonGroup>
|
||||
{sideBySideToggle}
|
||||
{fileControls}
|
||||
</ButtonGroup>
|
||||
</ButtonWrapper>
|
||||
);
|
||||
|
||||
let errorModal;
|
||||
if (expansionError) {
|
||||
errorModal = (
|
||||
<Modal
|
||||
title={t("diff.expansionFailed")}
|
||||
closeFunction={() => this.setState({expansionError: undefined})}
|
||||
body={<ErrorNotification error={expansionError}/>}
|
||||
closeFunction={() => this.setState({ expansionError: undefined })}
|
||||
body={<ErrorNotification error={expansionError} />}
|
||||
active={true}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -22,22 +22,22 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
import React from "react";
|
||||
import {apiClient} from "../apiclient";
|
||||
import { apiClient } from "../apiclient";
|
||||
import ErrorNotification from "../ErrorNotification";
|
||||
// @ts-ignore
|
||||
import parser from "gitdiff-parser";
|
||||
|
||||
import Loading from "../Loading";
|
||||
import Diff from "./Diff";
|
||||
import {DiffObjectProps, File} from "./DiffTypes";
|
||||
import {NotFoundError} from "../errors";
|
||||
import {Notification} from "../index";
|
||||
import {withTranslation, WithTranslation} from "react-i18next";
|
||||
import { DiffObjectProps, File } from "./DiffTypes";
|
||||
import { NotFoundError } from "../errors";
|
||||
import { Notification } from "../index";
|
||||
import { withTranslation, WithTranslation } from "react-i18next";
|
||||
|
||||
type Props = WithTranslation &
|
||||
DiffObjectProps & {
|
||||
url: string;
|
||||
};
|
||||
url: string;
|
||||
};
|
||||
|
||||
type State = {
|
||||
diff?: File[];
|
||||
@@ -68,8 +68,8 @@ class LoadingDiff extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
fetchDiff = () => {
|
||||
const {url} = this.props;
|
||||
this.setState({loading: true});
|
||||
const { url } = this.props;
|
||||
this.setState({ loading: true });
|
||||
apiClient
|
||||
.get(url)
|
||||
.then(response => {
|
||||
@@ -95,14 +95,14 @@ class LoadingDiff extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const {diff, loading, error} = this.state;
|
||||
const { diff, loading, error } = this.state;
|
||||
if (error) {
|
||||
if (error instanceof NotFoundError) {
|
||||
return <Notification type="info">{this.props.t("changesets.noChangesets")}</Notification>;
|
||||
}
|
||||
return <ErrorNotification error={error}/>;
|
||||
return <ErrorNotification error={error} />;
|
||||
} else if (loading) {
|
||||
return <Loading/>;
|
||||
return <Loading />;
|
||||
} else if (!diff) {
|
||||
return null;
|
||||
} else {
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
import React from "react";
|
||||
import {Changeset, Collection, Link} from "@scm-manager/ui-types";
|
||||
import { Changeset, Collection, Link } from "@scm-manager/ui-types";
|
||||
import LoadingDiff from "../LoadingDiff";
|
||||
import Notification from "../../Notification";
|
||||
import {WithTranslation, withTranslation} from "react-i18next";
|
||||
import {FileControlFactory} from "../DiffTypes";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { FileControlFactory } from "../DiffTypes";
|
||||
|
||||
type Props = WithTranslation & {
|
||||
changeset: Changeset;
|
||||
@@ -49,12 +49,19 @@ export const createUrl = (changeset: Collection) => {
|
||||
|
||||
class ChangesetDiff extends React.Component<Props> {
|
||||
render() {
|
||||
const {changeset, fileControlFactory, defaultCollapse, t} = this.props;
|
||||
const { changeset, fileControlFactory, defaultCollapse, t } = this.props;
|
||||
if (!isDiffSupported(changeset)) {
|
||||
return <Notification type="danger">{t("changeset.diffNotSupported")}</Notification>;
|
||||
} else {
|
||||
const url = createUrl(changeset);
|
||||
return <LoadingDiff url={url} defaultCollapse={defaultCollapse} sideBySide={false} fileControlFactory={fileControlFactory}/>;
|
||||
return (
|
||||
<LoadingDiff
|
||||
url={url}
|
||||
defaultCollapse={defaultCollapse}
|
||||
sideBySide={false}
|
||||
fileControlFactory={fileControlFactory}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import ChangesetAuthor from "./ChangesetAuthor";
|
||||
import ChangesetTags from "./ChangesetTags";
|
||||
import ChangesetButtonGroup from "./ChangesetButtonGroup";
|
||||
import ChangesetDescription from "./ChangesetDescription";
|
||||
import {FileControlFactory} from "../DiffTypes";
|
||||
import { FileControlFactory } from "../DiffTypes";
|
||||
|
||||
type Props = WithTranslation & {
|
||||
repository: Repository;
|
||||
@@ -102,7 +102,7 @@ class ChangesetRow extends React.Component<Props> {
|
||||
<AvatarWrapper>
|
||||
<AvatarFigure className="media-left">
|
||||
<FixedSizedAvatar className="image">
|
||||
<AvatarImage person={changeset.author}/>
|
||||
<AvatarImage person={changeset.author} />
|
||||
</FixedSizedAvatar>
|
||||
</AvatarFigure>
|
||||
</AvatarWrapper>
|
||||
@@ -120,24 +120,24 @@ class ChangesetRow extends React.Component<Props> {
|
||||
</ExtensionPoint>
|
||||
</h4>
|
||||
<p className="is-hidden-touch">
|
||||
<Trans i18nKey="repos:changeset.summary" components={[changesetId, dateFromNow]}/>
|
||||
<Trans i18nKey="repos:changeset.summary" components={[changesetId, dateFromNow]} />
|
||||
</p>
|
||||
<p className="is-hidden-desktop">
|
||||
<Trans i18nKey="repos:changeset.shortSummary" components={[changesetId, dateFromNow]}/>
|
||||
<Trans i18nKey="repos:changeset.shortSummary" components={[changesetId, dateFromNow]} />
|
||||
</p>
|
||||
<AuthorWrapper className="is-size-7 is-ellipsis-overflow">
|
||||
<ChangesetAuthor changeset={changeset}/>
|
||||
<ChangesetAuthor changeset={changeset} />
|
||||
</AuthorWrapper>
|
||||
</Metadata>
|
||||
</div>
|
||||
</div>
|
||||
<VCenteredColumn className="column">
|
||||
<ChangesetTags changeset={changeset}/>
|
||||
<ChangesetTags changeset={changeset} />
|
||||
</VCenteredColumn>
|
||||
</div>
|
||||
</div>
|
||||
<VCenteredChildColumn className={classNames("column", "is-flex")}>
|
||||
<ChangesetButtonGroup repository={repository} changeset={changeset}/>
|
||||
<ChangesetButtonGroup repository={repository} changeset={changeset} />
|
||||
<ExtensionPoint
|
||||
name="changeset.right"
|
||||
props={{
|
||||
|
||||
@@ -43,7 +43,7 @@ import {
|
||||
} from "@scm-manager/ui-components";
|
||||
import ContributorTable from "./ContributorTable";
|
||||
import { Link as ReactLink } from "react-router-dom";
|
||||
import {FileControlFactory} from "@scm-manager/ui-components";
|
||||
import { FileControlFactory } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = WithTranslation & {
|
||||
changeset: Changeset;
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
import React from "react";
|
||||
import {connect} from "react-redux";
|
||||
import {compose} from "redux";
|
||||
import {withRouter} from "react-router-dom";
|
||||
import {WithTranslation, withTranslation} from "react-i18next";
|
||||
import {Changeset, Repository} from "@scm-manager/ui-types";
|
||||
import {ErrorPage, Loading} from "@scm-manager/ui-components";
|
||||
import { connect } from "react-redux";
|
||||
import { compose } from "redux";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { Changeset, Repository } from "@scm-manager/ui-types";
|
||||
import { ErrorPage, Loading } from "@scm-manager/ui-components";
|
||||
import {
|
||||
fetchChangesetIfNeeded,
|
||||
getChangeset,
|
||||
@@ -35,7 +35,7 @@ import {
|
||||
isFetchChangesetPending
|
||||
} from "../modules/changesets";
|
||||
import ChangesetDetails from "../components/changesets/ChangesetDetails";
|
||||
import {FileControlFactory} from "@scm-manager/ui-components";
|
||||
import { FileControlFactory } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = WithTranslation & {
|
||||
id: string;
|
||||
@@ -50,28 +50,33 @@ type Props = WithTranslation & {
|
||||
|
||||
class ChangesetView extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
const {fetchChangesetIfNeeded, repository, id} = this.props;
|
||||
const { fetchChangesetIfNeeded, repository, id } = this.props;
|
||||
fetchChangesetIfNeeded(repository, id);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: Props) {
|
||||
const {fetchChangesetIfNeeded, repository, id} = this.props;
|
||||
const { fetchChangesetIfNeeded, repository, id } = this.props;
|
||||
if (prevProps.id !== id) {
|
||||
fetchChangesetIfNeeded(repository, id);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {changeset, loading, error, t, repository, fileControlFactoryFactory} = this.props;
|
||||
const { changeset, loading, error, t, repository, fileControlFactoryFactory } = this.props;
|
||||
|
||||
if (error) {
|
||||
return <ErrorPage title={t("changesets.errorTitle")} subtitle={t("changesets.errorSubtitle")} error={error}/>;
|
||||
return <ErrorPage title={t("changesets.errorTitle")} subtitle={t("changesets.errorSubtitle")} error={error} />;
|
||||
}
|
||||
|
||||
if (!changeset || loading) return <Loading/>;
|
||||
if (!changeset || loading) return <Loading />;
|
||||
|
||||
return <ChangesetDetails changeset={changeset} repository={repository}
|
||||
fileControlFactory={fileControlFactoryFactory && fileControlFactoryFactory(changeset)}/>;
|
||||
return (
|
||||
<ChangesetDetails
|
||||
changeset={changeset}
|
||||
repository={repository}
|
||||
fileControlFactory={fileControlFactoryFactory && fileControlFactoryFactory(changeset)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
import React from "react";
|
||||
import {connect} from "react-redux";
|
||||
import {Redirect, Route, RouteComponentProps, Switch} from "react-router-dom";
|
||||
import {WithTranslation, withTranslation} from "react-i18next";
|
||||
import {binder, ExtensionPoint} from "@scm-manager/ui-extensions";
|
||||
import {Changeset, Repository} from "@scm-manager/ui-types";
|
||||
import { connect } from "react-redux";
|
||||
import { Redirect, Route, RouteComponentProps, Switch } from "react-router-dom";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { binder, ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||
import { Changeset, Repository } from "@scm-manager/ui-types";
|
||||
import {
|
||||
CustomQueryFlexWrappedColumns,
|
||||
ErrorPage,
|
||||
@@ -39,7 +39,7 @@ import {
|
||||
StateMenuContextProvider,
|
||||
SubNavigation
|
||||
} from "@scm-manager/ui-components";
|
||||
import {fetchRepoByName, getFetchRepoFailure, getRepository, isFetchRepoPending} from "../modules/repos";
|
||||
import { fetchRepoByName, getFetchRepoFailure, getRepository, isFetchRepoPending } from "../modules/repos";
|
||||
import RepositoryDetails from "../components/RepositoryDetails";
|
||||
import EditRepo from "./EditRepo";
|
||||
import BranchesOverview from "../branches/containers/BranchesOverview";
|
||||
@@ -49,34 +49,34 @@ import EditRepoNavLink from "../components/EditRepoNavLink";
|
||||
import BranchRoot from "../branches/containers/BranchRoot";
|
||||
import PermissionsNavLink from "../components/PermissionsNavLink";
|
||||
import RepositoryNavLink from "../components/RepositoryNavLink";
|
||||
import {getLinks, getRepositoriesLink} from "../../modules/indexResource";
|
||||
import { getLinks, getRepositoriesLink } from "../../modules/indexResource";
|
||||
import CodeOverview from "../codeSection/containers/CodeOverview";
|
||||
import ChangesetView from "./ChangesetView";
|
||||
import SourceExtensions from "../sources/containers/SourceExtensions";
|
||||
import {FileControlFactory, JumpToFileButton} from "@scm-manager/ui-components";
|
||||
import { FileControlFactory, JumpToFileButton } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = RouteComponentProps &
|
||||
WithTranslation & {
|
||||
namespace: string;
|
||||
name: string;
|
||||
repository: Repository;
|
||||
loading: boolean;
|
||||
error: Error;
|
||||
repoLink: string;
|
||||
indexLinks: object;
|
||||
namespace: string;
|
||||
name: string;
|
||||
repository: Repository;
|
||||
loading: boolean;
|
||||
error: Error;
|
||||
repoLink: string;
|
||||
indexLinks: object;
|
||||
|
||||
// dispatch functions
|
||||
fetchRepoByName: (link: string, namespace: string, name: string) => void;
|
||||
};
|
||||
// dispatch functions
|
||||
fetchRepoByName: (link: string, namespace: string, name: string) => void;
|
||||
};
|
||||
|
||||
class RepositoryRoot extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
const {fetchRepoByName, namespace, name, repoLink} = this.props;
|
||||
const { fetchRepoByName, namespace, name, repoLink } = this.props;
|
||||
fetchRepoByName(repoLink, namespace, name);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: Props) {
|
||||
const {fetchRepoByName, namespace, name, repoLink} = this.props;
|
||||
const { fetchRepoByName, namespace, name, repoLink } = this.props;
|
||||
if (namespace !== prevProps.namespace || name !== prevProps.name) {
|
||||
fetchRepoByName(repoLink, namespace, name);
|
||||
}
|
||||
@@ -106,7 +106,7 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
};
|
||||
|
||||
getCodeLinkname = () => {
|
||||
const {repository} = this.props;
|
||||
const { repository } = this.props;
|
||||
if (repository?._links?.sources) {
|
||||
return "sources";
|
||||
}
|
||||
@@ -117,7 +117,7 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
};
|
||||
|
||||
evaluateDestinationForCodeLink = () => {
|
||||
const {repository} = this.props;
|
||||
const { repository } = this.props;
|
||||
const url = `${this.matchedUrl()}/code`;
|
||||
if (repository?._links?.sources) {
|
||||
return `${url}/sources/`;
|
||||
@@ -126,16 +126,16 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const {loading, error, indexLinks, repository, t} = this.props;
|
||||
const { loading, error, indexLinks, repository, t } = this.props;
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<ErrorPage title={t("repositoryRoot.errorTitle")} subtitle={t("repositoryRoot.errorSubtitle")} error={error}/>
|
||||
<ErrorPage title={t("repositoryRoot.errorTitle")} subtitle={t("repositoryRoot.errorSubtitle")} error={error} />
|
||||
);
|
||||
}
|
||||
|
||||
if (!repository || loading) {
|
||||
return <Loading/>;
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
const url = this.matchedUrl();
|
||||
@@ -154,7 +154,7 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
redirectedUrl = url + "/info";
|
||||
}
|
||||
|
||||
const fileControlFactoryFactory: (changeset: Changeset) => FileControlFactory = (changeset) => (file) => {
|
||||
const fileControlFactoryFactory: (changeset: Changeset) => FileControlFactory = changeset => file => {
|
||||
const baseUrl = `${url}/code/sources`;
|
||||
const sourceLink = {
|
||||
url: `${baseUrl}/${changeset.id}/${file.newPath}/`,
|
||||
@@ -183,73 +183,71 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
return links.map(({url, label}) => <JumpToFileButton
|
||||
tooltip={label}
|
||||
link={url}
|
||||
/>);
|
||||
return links.map(({ url, label }) => <JumpToFileButton tooltip={label} link={url} />);
|
||||
};
|
||||
|
||||
return (
|
||||
<StateMenuContextProvider>
|
||||
<Page
|
||||
title={repository.namespace + "/" + repository.name}
|
||||
afterTitle={<ExtensionPoint name={"repository.afterTitle"} props={{repository}}/>}
|
||||
afterTitle={<ExtensionPoint name={"repository.afterTitle"} props={{ repository }} />}
|
||||
>
|
||||
<CustomQueryFlexWrappedColumns>
|
||||
<PrimaryContentColumn>
|
||||
<Switch>
|
||||
<Redirect exact from={this.props.match.url} to={redirectedUrl}/>
|
||||
<Redirect exact from={this.props.match.url} to={redirectedUrl} />
|
||||
|
||||
{/* redirect pre 2.0.0-rc2 links */}
|
||||
<Redirect from={`${url}/changeset/:id`} to={`${url}/code/changeset/:id`}/>
|
||||
<Redirect exact from={`${url}/sources`} to={`${url}/code/sources`}/>
|
||||
<Redirect from={`${url}/sources/:revision/:path*`} to={`${url}/code/sources/:revision/:path*`}/>
|
||||
<Redirect exact from={`${url}/changesets`} to={`${url}/code/changesets`}/>
|
||||
<Redirect from={`${url}/branch/:branch/changesets`} to={`${url}/code/branch/:branch/changesets/`}/>
|
||||
<Redirect from={`${url}/changeset/:id`} to={`${url}/code/changeset/:id`} />
|
||||
<Redirect exact from={`${url}/sources`} to={`${url}/code/sources`} />
|
||||
<Redirect from={`${url}/sources/:revision/:path*`} to={`${url}/code/sources/:revision/:path*`} />
|
||||
<Redirect exact from={`${url}/changesets`} to={`${url}/code/changesets`} />
|
||||
<Redirect from={`${url}/branch/:branch/changesets`} to={`${url}/code/branch/:branch/changesets/`} />
|
||||
|
||||
<Route path={`${url}/info`} exact component={() => <RepositoryDetails repository={repository}/>}/>
|
||||
<Route path={`${url}/settings/general`} component={() => <EditRepo repository={repository}/>}/>
|
||||
<Route path={`${url}/info`} exact component={() => <RepositoryDetails repository={repository} />} />
|
||||
<Route path={`${url}/settings/general`} component={() => <EditRepo repository={repository} />} />
|
||||
<Route
|
||||
path={`${url}/settings/permissions`}
|
||||
render={() => (
|
||||
<Permissions namespace={this.props.repository.namespace} repoName={this.props.repository.name}/>
|
||||
<Permissions namespace={this.props.repository.namespace} repoName={this.props.repository.name} />
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${url}/code/changeset/:id`}
|
||||
render={() => <ChangesetView repository={repository}
|
||||
fileControlFactoryFactory={fileControlFactoryFactory}/>}
|
||||
render={() => (
|
||||
<ChangesetView repository={repository} fileControlFactoryFactory={fileControlFactoryFactory} />
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/code/sourceext/:extension`}
|
||||
exact={true}
|
||||
render={() => <SourceExtensions repository={repository}/>}
|
||||
render={() => <SourceExtensions repository={repository} />}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/code/sourceext/:extension/:revision/:path*`}
|
||||
render={() => <SourceExtensions repository={repository} baseUrl={`${url}/code/sources`}/>}
|
||||
render={() => <SourceExtensions repository={repository} baseUrl={`${url}/code/sources`} />}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/code`}
|
||||
render={() => <CodeOverview baseUrl={`${url}/code`} repository={repository}/>}
|
||||
render={() => <CodeOverview baseUrl={`${url}/code`} repository={repository} />}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/branch/:branch`}
|
||||
render={() => <BranchRoot repository={repository} baseUrl={`${url}/branch`}/>}
|
||||
render={() => <BranchRoot repository={repository} baseUrl={`${url}/branch`} />}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/branches`}
|
||||
exact={true}
|
||||
render={() => <BranchesOverview repository={repository} baseUrl={`${url}/branch`}/>}
|
||||
render={() => <BranchesOverview repository={repository} baseUrl={`${url}/branch`} />}
|
||||
/>
|
||||
<Route path={`${url}/branches/create`} render={() => <CreateBranch repository={repository}/>}/>
|
||||
<ExtensionPoint name="repository.route" props={extensionProps} renderAll={true}/>
|
||||
<Route path={`${url}/branches/create`} render={() => <CreateBranch repository={repository} />} />
|
||||
<ExtensionPoint name="repository.route" props={extensionProps} renderAll={true} />
|
||||
</Switch>
|
||||
</PrimaryContentColumn>
|
||||
<SecondaryNavigationColumn>
|
||||
<SecondaryNavigation label={t("repositoryRoot.menu.navigationLabel")}>
|
||||
<ExtensionPoint name="repository.navigation.topLevel" props={extensionProps} renderAll={true}/>
|
||||
<ExtensionPoint name="repository.navigation.topLevel" props={extensionProps} renderAll={true} />
|
||||
<NavLink
|
||||
to={`${url}/info`}
|
||||
icon="fas fa-info-circle"
|
||||
@@ -276,15 +274,15 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
activeOnlyWhenExact={false}
|
||||
title={t("repositoryRoot.menu.sourcesNavLink")}
|
||||
/>
|
||||
<ExtensionPoint name="repository.navigation" props={extensionProps} renderAll={true}/>
|
||||
<ExtensionPoint name="repository.navigation" props={extensionProps} renderAll={true} />
|
||||
<SubNavigation
|
||||
to={`${url}/settings/general`}
|
||||
label={t("repositoryRoot.menu.settingsNavLink")}
|
||||
title={t("repositoryRoot.menu.settingsNavLink")}
|
||||
>
|
||||
<EditRepoNavLink repository={repository} editUrl={`${url}/settings/general`}/>
|
||||
<PermissionsNavLink permissionUrl={`${url}/settings/permissions`} repository={repository}/>
|
||||
<ExtensionPoint name="repository.setting" props={extensionProps} renderAll={true}/>
|
||||
<EditRepoNavLink repository={repository} editUrl={`${url}/settings/general`} />
|
||||
<PermissionsNavLink permissionUrl={`${url}/settings/permissions`} repository={repository} />
|
||||
<ExtensionPoint name="repository.setting" props={extensionProps} renderAll={true} />
|
||||
</SubNavigation>
|
||||
</SecondaryNavigation>
|
||||
</SecondaryNavigationColumn>
|
||||
@@ -296,7 +294,7 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: any, ownProps: Props) => {
|
||||
const {namespace, name} = ownProps.match.params;
|
||||
const { namespace, name } = ownProps.match.params;
|
||||
const repository = getRepository(state, namespace, name);
|
||||
const loading = isFetchRepoPending(state, namespace, name);
|
||||
const error = getFetchRepoFailure(state, namespace, name);
|
||||
|
||||
Reference in New Issue
Block a user