mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 02:31:14 +01:00
apply eslint and prettier rules
This commit is contained in:
@@ -2,12 +2,7 @@ import React from "react";
|
||||
import { translate, InjectedTranslateProps } from "react-i18next";
|
||||
import classNames from "classnames";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
Change,
|
||||
Diff as DiffComponent,
|
||||
getChangeKey,
|
||||
Hunk
|
||||
} from "react-diff-view";
|
||||
import { Change, Diff as DiffComponent, getChangeKey, Hunk } from "react-diff-view";
|
||||
import { Button, ButtonGroup } from "../buttons";
|
||||
import Tag from "../Tag";
|
||||
import Icon from "../Icon";
|
||||
@@ -183,14 +178,10 @@ class DiffFile extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
renderFileTitle = (file: File) => {
|
||||
if (
|
||||
file.oldPath !== file.newPath &&
|
||||
(file.type === "copy" || file.type === "rename")
|
||||
) {
|
||||
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") {
|
||||
@@ -200,10 +191,7 @@ class DiffFile extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
hoverFileTitle = (file: File): string => {
|
||||
if (
|
||||
file.oldPath !== file.newPath &&
|
||||
(file.type === "copy" || file.type === "rename")
|
||||
) {
|
||||
if (file.oldPath !== file.newPath && (file.type === "copy" || file.type === "rename")) {
|
||||
return `${file.oldPath} > ${file.newPath}`;
|
||||
} else if (file.type === "delete") {
|
||||
return file.oldPath;
|
||||
@@ -222,19 +210,9 @@ class DiffFile extends React.Component<Props, State> {
|
||||
value = file.type;
|
||||
}
|
||||
const color =
|
||||
value === "added"
|
||||
? "success is-outlined"
|
||||
: value === "deleted"
|
||||
? "danger is-outlined"
|
||||
: "info is-outlined";
|
||||
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} />;
|
||||
};
|
||||
|
||||
render() {
|
||||
@@ -245,9 +223,7 @@ class DiffFile extends React.Component<Props, State> {
|
||||
let body = null;
|
||||
let icon = "angle-right";
|
||||
if (!collapsed) {
|
||||
const fileAnnotations = fileAnnotationFactory
|
||||
? fileAnnotationFactory(file)
|
||||
: null;
|
||||
const fileAnnotations = fileAnnotationFactory ? fileAnnotationFactory(file) : null;
|
||||
icon = "angle-down";
|
||||
body = (
|
||||
<div className="panel-block is-paddingless">
|
||||
@@ -258,32 +234,20 @@ class DiffFile extends React.Component<Props, State> {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const collapseIcon =
|
||||
file && !file.isBinary ? <Icon name={icon} color="inherit" /> : null;
|
||||
const collapseIcon = file && !file.isBinary ? <Icon name={icon} color="inherit" /> : null;
|
||||
|
||||
const fileControls = fileControlFactory
|
||||
? fileControlFactory(file, this.setCollapse)
|
||||
: null;
|
||||
const fileControls = fileControlFactory ? fileControlFactory(file, this.setCollapse) : null;
|
||||
return (
|
||||
<DiffFilePanel
|
||||
className={classNames("panel", "is-size-6")}
|
||||
collapsed={(file && file.isBinary) || collapsed}
|
||||
>
|
||||
<DiffFilePanel className={classNames("panel", "is-size-6")} collapsed={(file && file.isBinary) || collapsed}>
|
||||
<div className="panel-heading">
|
||||
<FlexWrapLevel className="level">
|
||||
<FullWidthTitleHeader
|
||||
className={classNames(
|
||||
"level-left",
|
||||
"is-flex",
|
||||
"has-cursor-pointer"
|
||||
)}
|
||||
className={classNames("level-left", "is-flex", "has-cursor-pointer")}
|
||||
onClick={this.toggleCollapse}
|
||||
title={this.hoverFileTitle(file)}
|
||||
>
|
||||
{collapseIcon}
|
||||
<TitleWrapper
|
||||
className={classNames("is-ellipsis-overflow", "is-size-6")}
|
||||
>
|
||||
<TitleWrapper className={classNames("is-ellipsis-overflow", "is-size-6")}>
|
||||
{this.renderFileTitle(file)}
|
||||
</TitleWrapper>
|
||||
{this.renderChangeTag(file)}
|
||||
|
||||
@@ -63,10 +63,7 @@ export type DiffEventContext = BaseContext & {
|
||||
|
||||
export type DiffEventHandler = (context: DiffEventContext) => void;
|
||||
|
||||
export type FileControlFactory = (
|
||||
file: File,
|
||||
setCollapseState: (p: boolean) => void
|
||||
) => ReactNode | null | undefined;
|
||||
export type FileControlFactory = (file: File, setCollapseState: (p: boolean) => void) => ReactNode | null | undefined;
|
||||
|
||||
export type DiffObjectProps = {
|
||||
sideBySide: boolean;
|
||||
|
||||
@@ -27,10 +27,7 @@ class ChangesetAuthor extends React.Component<Props> {
|
||||
renderWithMail(name: string, mail: string) {
|
||||
const { t } = this.props;
|
||||
return (
|
||||
<a
|
||||
href={"mailto:" + mail}
|
||||
title={t("changeset.author.mailto") + " " + mail}
|
||||
>
|
||||
<a href={"mailto:" + mail} title={t("changeset.author.mailto") + " " + mail}>
|
||||
{name}
|
||||
</a>
|
||||
);
|
||||
|
||||
@@ -19,18 +19,8 @@ class ChangesetButtonGroup extends React.Component<Props> {
|
||||
const sourcesLink = createSourcesLink(repository, changeset);
|
||||
return (
|
||||
<ButtonAddons className="is-marginless">
|
||||
<Button
|
||||
link={changesetLink}
|
||||
icon="exchange-alt"
|
||||
label={t("changeset.buttons.details")}
|
||||
reducedMobile={true}
|
||||
/>
|
||||
<Button
|
||||
link={sourcesLink}
|
||||
icon="code"
|
||||
label={t("changeset.buttons.sources")}
|
||||
reducedMobile={true}
|
||||
/>
|
||||
<Button link={changesetLink} icon="exchange-alt" label={t("changeset.buttons.details")} reducedMobile={true} />
|
||||
<Button link={sourcesLink} icon="code" label={t("changeset.buttons.sources")} reducedMobile={true} />
|
||||
</ButtonAddons>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,11 +28,7 @@ class ChangesetDiff extends React.Component<Props> {
|
||||
render() {
|
||||
const { changeset, defaultCollapse, t } = this.props;
|
||||
if (!this.isDiffSupported(changeset)) {
|
||||
return (
|
||||
<Notification type="danger">
|
||||
{t("changeset.diffNotSupported")}
|
||||
</Notification>
|
||||
);
|
||||
return <Notification type="danger">{t("changeset.diffNotSupported")}</Notification>;
|
||||
} else {
|
||||
const url = this.createUrl(changeset);
|
||||
return <LoadingDiff url={url} defaultCollapse={defaultCollapse} />;
|
||||
|
||||
@@ -12,13 +12,7 @@ class ChangesetList extends React.Component<Props> {
|
||||
render() {
|
||||
const { repository, changesets } = this.props;
|
||||
const content = changesets.map(changeset => {
|
||||
return (
|
||||
<ChangesetRow
|
||||
key={changeset.id}
|
||||
repository={repository}
|
||||
changeset={changeset}
|
||||
/>
|
||||
);
|
||||
return <ChangesetRow key={changeset.id} repository={repository} changeset={changeset} />;
|
||||
});
|
||||
return <>{content}</>;
|
||||
}
|
||||
|
||||
@@ -98,18 +98,10 @@ class ChangesetRow extends React.Component<Props> {
|
||||
</ExtensionPoint>
|
||||
</h4>
|
||||
<p className="is-hidden-touch">
|
||||
<Interpolate
|
||||
i18nKey="changeset.summary"
|
||||
id={changesetId}
|
||||
time={dateFromNow}
|
||||
/>
|
||||
<Interpolate i18nKey="changeset.summary" id={changesetId} time={dateFromNow} />
|
||||
</p>
|
||||
<p className="is-hidden-desktop">
|
||||
<Interpolate
|
||||
i18nKey="changeset.shortSummary"
|
||||
id={changesetId}
|
||||
time={dateFromNow}
|
||||
/>
|
||||
<Interpolate i18nKey="changeset.shortSummary" id={changesetId} time={dateFromNow} />
|
||||
</p>
|
||||
<AuthorWrapper className="is-size-7">
|
||||
<ChangesetAuthor changeset={changeset} />
|
||||
@@ -123,10 +115,7 @@ class ChangesetRow extends React.Component<Props> {
|
||||
</div>
|
||||
</div>
|
||||
<VCenteredChildColumn className={classNames("column", "is-flex")}>
|
||||
<ChangesetButtonGroup
|
||||
repository={repository}
|
||||
changeset={changeset}
|
||||
/>
|
||||
<ChangesetButtonGroup repository={repository} changeset={changeset} />
|
||||
<ExtensionPoint
|
||||
name="changeset.right"
|
||||
props={{
|
||||
|
||||
@@ -17,10 +17,7 @@ class ChangesetTagsCollapsed extends React.Component<Props> {
|
||||
const message = tags.map(tag => tag.name).join(", ");
|
||||
return (
|
||||
<Tooltip location="top" message={message}>
|
||||
<ChangesetTagBase
|
||||
icon="tags"
|
||||
label={tags.length + " " + t("changeset.tags")}
|
||||
/>
|
||||
<ChangesetTagBase icon="tags" label={tags.length + " " + t("changeset.tags")} />
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,17 +5,11 @@ export type Description = {
|
||||
message: string;
|
||||
};
|
||||
|
||||
export function createChangesetLink(
|
||||
repository: Repository,
|
||||
changeset: Changeset
|
||||
) {
|
||||
export function createChangesetLink(repository: Repository, changeset: Changeset) {
|
||||
return `/repo/${repository.namespace}/${repository.name}/changeset/${changeset.id}`;
|
||||
}
|
||||
|
||||
export function createSourcesLink(
|
||||
repository: Repository,
|
||||
changeset: Changeset
|
||||
) {
|
||||
export function createSourcesLink(repository: Repository, changeset: Changeset) {
|
||||
return `/repo/${repository.namespace}/${repository.name}/sources/${changeset.id}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
import { File, FileChangeType, Hunk } from "./DiffTypes";
|
||||
import {
|
||||
getPath,
|
||||
createHunkIdentifier,
|
||||
createHunkIdentifierFromContext
|
||||
} from "./diffs";
|
||||
import { getPath, createHunkIdentifier, createHunkIdentifierFromContext } from "./diffs";
|
||||
|
||||
describe("tests for diff util functions", () => {
|
||||
const file = (
|
||||
type: FileChangeType,
|
||||
oldPath: string,
|
||||
newPath: string
|
||||
): File => {
|
||||
const file = (type: FileChangeType, oldPath: string, newPath: string): File => {
|
||||
return {
|
||||
hunks: [],
|
||||
type: type,
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
import * as diffs from "./diffs";
|
||||
|
||||
export { diffs };
|
||||
|
||||
export * from "./changesets";
|
||||
|
||||
export { default as Diff } from "./Diff";
|
||||
export { default as DiffFile } from "./DiffFile";
|
||||
export { default as LoadingDiff } from "./LoadingDiff";
|
||||
|
||||
import {
|
||||
File,
|
||||
FileChangeType,
|
||||
@@ -21,6 +13,14 @@ import {
|
||||
DiffEventContext
|
||||
} from "./DiffTypes";
|
||||
|
||||
export { diffs };
|
||||
|
||||
export * from "./changesets";
|
||||
|
||||
export { default as Diff } from "./Diff";
|
||||
export { default as DiffFile } from "./DiffFile";
|
||||
export { default as LoadingDiff } from "./LoadingDiff";
|
||||
|
||||
export {
|
||||
File,
|
||||
FileChangeType,
|
||||
|
||||
Reference in New Issue
Block a user