mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
apply eslint and prettier rules
This commit is contained in:
@@ -6,16 +6,8 @@ import { translate } from "react-i18next";
|
||||
import styled from "styled-components";
|
||||
import { binder } from "@scm-manager/ui-extensions";
|
||||
import { Repository, File } from "@scm-manager/ui-types";
|
||||
import {
|
||||
ErrorNotification,
|
||||
Loading,
|
||||
Notification
|
||||
} from "@scm-manager/ui-components";
|
||||
import {
|
||||
getFetchSourcesFailure,
|
||||
isFetchSourcesPending,
|
||||
getSources
|
||||
} from "../modules/sources";
|
||||
import { ErrorNotification, Loading, Notification } from "@scm-manager/ui-components";
|
||||
import { getFetchSourcesFailure, isFetchSourcesPending, getSources } from "../modules/sources";
|
||||
import FileTreeLeaf from "./FileTreeLeaf";
|
||||
|
||||
type Props = {
|
||||
@@ -113,27 +105,15 @@ class FileTree extends React.Component<Props> {
|
||||
<tr>
|
||||
<FixedWidthTh />
|
||||
<th>{t("sources.file-tree.name")}</th>
|
||||
<th className="is-hidden-mobile">
|
||||
{t("sources.file-tree.length")}
|
||||
</th>
|
||||
<th className="is-hidden-mobile">
|
||||
{t("sources.file-tree.lastModified")}
|
||||
</th>
|
||||
<th className="is-hidden-mobile">
|
||||
{t("sources.file-tree.description")}
|
||||
</th>
|
||||
{binder.hasExtension("repos.sources.tree.row.right") && (
|
||||
<th className="is-hidden-mobile" />
|
||||
)}
|
||||
<th className="is-hidden-mobile">{t("sources.file-tree.length")}</th>
|
||||
<th className="is-hidden-mobile">{t("sources.file-tree.lastModified")}</th>
|
||||
<th className="is-hidden-mobile">{t("sources.file-tree.description")}</th>
|
||||
{binder.hasExtension("repos.sources.tree.row.right") && <th className="is-hidden-mobile" />}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{files.map(file => (
|
||||
<FileTreeLeaf
|
||||
key={file.name}
|
||||
file={file}
|
||||
baseUrl={baseUrlWithRevision}
|
||||
/>
|
||||
<FileTreeLeaf key={file.name} file={file} baseUrl={baseUrlWithRevision} />
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -66,16 +66,12 @@ export default class FileTreeLeaf extends React.Component<Props> {
|
||||
return (
|
||||
<tr>
|
||||
<td>{this.createFileIcon(file)}</td>
|
||||
<MinWidthTd className="is-word-break">
|
||||
{this.createFileName(file)}
|
||||
</MinWidthTd>
|
||||
<MinWidthTd className="is-word-break">{this.createFileName(file)}</MinWidthTd>
|
||||
<td className="is-hidden-mobile">{fileSize}</td>
|
||||
<td className="is-hidden-mobile">
|
||||
<DateFromNow date={file.lastModified} />
|
||||
</td>
|
||||
<MinWidthTd className={classNames("is-word-break", "is-hidden-mobile")}>
|
||||
{file.description}
|
||||
</MinWidthTd>
|
||||
<MinWidthTd className={classNames("is-word-break", "is-hidden-mobile")}>{file.description}</MinWidthTd>
|
||||
{binder.hasExtension("repos.sources.tree.row.right") && (
|
||||
<td className="is-hidden-mobile">
|
||||
{!file.directory && (
|
||||
|
||||
@@ -13,10 +13,7 @@ class DownloadViewer extends React.Component<Props> {
|
||||
const { t, file } = this.props;
|
||||
return (
|
||||
<div className="has-text-centered">
|
||||
<DownloadButton
|
||||
url={file._links.self.href}
|
||||
displayName={t("sources.content.downloadButton")}
|
||||
/>
|
||||
<DownloadButton url={file._links.self.href} displayName={t("sources.content.downloadButton")} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,22 +28,14 @@ class FileButtonAddons extends React.Component<Props> {
|
||||
return (
|
||||
<ButtonAddons className={className}>
|
||||
<div title={t("sources.content.sourcesButton")}>
|
||||
<Button
|
||||
action={this.showSources}
|
||||
className="reduced"
|
||||
color={this.color(!historyIsSelected)}
|
||||
>
|
||||
<Button action={this.showSources} className="reduced" color={this.color(!historyIsSelected)}>
|
||||
<span className="icon">
|
||||
<i className="fas fa-code" />
|
||||
</span>
|
||||
</Button>
|
||||
</div>
|
||||
<div title={t("sources.content.historyButton")}>
|
||||
<Button
|
||||
action={this.showHistory}
|
||||
className="reduced"
|
||||
color={this.color(historyIsSelected)}
|
||||
>
|
||||
<Button action={this.showHistory} className="reduced" color={this.color(historyIsSelected)}>
|
||||
<span className="icon">
|
||||
<i className="fas fa-history" />
|
||||
</span>
|
||||
|
||||
@@ -63,9 +63,7 @@ class SourcecodeViewer extends React.Component<Props, State> {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<SyntaxHighlighter language={getLanguage(language)} value={content} />
|
||||
);
|
||||
return <SyntaxHighlighter language={getLanguage(language)} value={content} />;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,7 @@ import classNames from "classnames";
|
||||
import styled from "styled-components";
|
||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||
import { File, Repository } from "@scm-manager/ui-types";
|
||||
import {
|
||||
DateFromNow,
|
||||
ErrorNotification,
|
||||
FileSize,
|
||||
Icon
|
||||
} from "@scm-manager/ui-components";
|
||||
import { DateFromNow, ErrorNotification, FileSize, Icon } from "@scm-manager/ui-components";
|
||||
import { getSources } from "../modules/sources";
|
||||
import FileButtonAddons from "../components/content/FileButtonAddons";
|
||||
import SourcesView from "./SourcesView";
|
||||
@@ -91,9 +86,7 @@ class Content extends React.Component<Props, State> {
|
||||
<RightMarginFileButtonAddons
|
||||
file={file}
|
||||
historyIsSelected={showHistory}
|
||||
showHistory={(changeShowHistory: boolean) =>
|
||||
this.setShowHistoryState(changeShowHistory)
|
||||
}
|
||||
showHistory={(changeShowHistory: boolean) => this.setShowHistoryState(changeShowHistory)}
|
||||
/>
|
||||
) : null;
|
||||
|
||||
@@ -189,12 +182,7 @@ class Content extends React.Component<Props, State> {
|
||||
showHistory && file._links.history ? (
|
||||
<HistoryView file={file} repository={repository} />
|
||||
) : (
|
||||
<SourcesView
|
||||
revision={revision}
|
||||
file={file}
|
||||
repository={repository}
|
||||
path={path}
|
||||
/>
|
||||
<SourcesView revision={revision} file={file} repository={repository} path={path} />
|
||||
);
|
||||
const moreInformation = this.showMoreInformation();
|
||||
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
import React from "react";
|
||||
import {
|
||||
File,
|
||||
Changeset,
|
||||
Repository,
|
||||
PagedCollection
|
||||
} from "@scm-manager/ui-types";
|
||||
import {
|
||||
ErrorNotification,
|
||||
Loading,
|
||||
StatePaginator,
|
||||
ChangesetList
|
||||
} from "@scm-manager/ui-components";
|
||||
import { File, Changeset, Repository, PagedCollection } from "@scm-manager/ui-types";
|
||||
import { ErrorNotification, Loading, StatePaginator, ChangesetList } from "@scm-manager/ui-components";
|
||||
import { getHistory } from "./history";
|
||||
|
||||
type Props = {
|
||||
@@ -67,9 +57,7 @@ class HistoryView extends React.Component<Props, State> {
|
||||
updatePage(page: number) {
|
||||
const { file } = this.props;
|
||||
const internalPage = page - 1;
|
||||
this.updateHistory(
|
||||
file._links.history.href + "?page=" + internalPage.toString()
|
||||
);
|
||||
this.updateHistory(file._links.history.href + "?page=" + internalPage.toString());
|
||||
}
|
||||
|
||||
showHistory() {
|
||||
|
||||
@@ -3,12 +3,7 @@ import { connect } from "react-redux";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import { Branch, Repository } from "@scm-manager/ui-types";
|
||||
import FileTree from "../components/FileTree";
|
||||
import {
|
||||
BranchSelector,
|
||||
Breadcrumb,
|
||||
ErrorNotification,
|
||||
Loading
|
||||
} from "@scm-manager/ui-components";
|
||||
import { BranchSelector, Breadcrumb, ErrorNotification, Loading } from "@scm-manager/ui-components";
|
||||
import { translate } from "react-i18next";
|
||||
import {
|
||||
fetchBranches,
|
||||
@@ -55,13 +50,7 @@ class Sources extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const {
|
||||
fetchBranches,
|
||||
repository,
|
||||
revision,
|
||||
path,
|
||||
fetchSources
|
||||
} = this.props;
|
||||
const { fetchBranches, repository, revision, path, fetchSources } = this.props;
|
||||
|
||||
fetchBranches(repository);
|
||||
fetchSources(repository, revision, path);
|
||||
@@ -116,15 +105,7 @@ class Sources extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
repository,
|
||||
baseUrl,
|
||||
loading,
|
||||
error,
|
||||
revision,
|
||||
path,
|
||||
currentFileIsDirectory
|
||||
} = this.props;
|
||||
const { repository, baseUrl, loading, error, revision, path, currentFileIsDirectory } = this.props;
|
||||
|
||||
if (error) {
|
||||
return <ErrorNotification error={error} />;
|
||||
@@ -139,18 +120,11 @@ class Sources extends React.Component<Props, State> {
|
||||
<div className="panel">
|
||||
{this.renderBranchSelector()}
|
||||
{this.renderBreadcrumb()}
|
||||
<FileTree
|
||||
repository={repository}
|
||||
revision={revision}
|
||||
path={path}
|
||||
baseUrl={baseUrl}
|
||||
/>
|
||||
<FileTree repository={repository} revision={revision} path={path} baseUrl={baseUrl} />
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<Content repository={repository} revision={revision} path={path} />
|
||||
);
|
||||
return <Content repository={repository} revision={revision} path={path} />;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,9 +159,7 @@ class Sources extends React.Component<Props, State> {
|
||||
path={path}
|
||||
baseUrl={baseUrl}
|
||||
branch={selectedBranch}
|
||||
defaultBranch={
|
||||
branches && branches.filter(b => b.defaultBranch === true)[0]
|
||||
}
|
||||
defaultBranch={branches && branches.filter(b => b.defaultBranch === true)[0]}
|
||||
branches={branches}
|
||||
repository={repository}
|
||||
/>
|
||||
|
||||
@@ -10,7 +10,7 @@ describe("get content type", () => {
|
||||
});
|
||||
|
||||
it("should return content", done => {
|
||||
let headers = {
|
||||
const headers = {
|
||||
"Content-Type": "application/text",
|
||||
"X-Programming-Language": "JAVA"
|
||||
};
|
||||
|
||||
@@ -16,8 +16,7 @@ import {
|
||||
isDirectory
|
||||
} from "./sources";
|
||||
|
||||
const sourcesUrl =
|
||||
"http://localhost:8081/scm/rest/api/v2/repositories/scm/core/sources/";
|
||||
const sourcesUrl = "http://localhost:8081/scm/rest/api/v2/repositories/scm/core/sources/";
|
||||
|
||||
const repository: Repository = {
|
||||
name: "core",
|
||||
@@ -185,21 +184,14 @@ describe("reducer tests", () => {
|
||||
const expectedState = {
|
||||
"scm/core/_/": collection
|
||||
};
|
||||
expect(
|
||||
reducer({}, fetchSourcesSuccess(repository, "", "", collection))
|
||||
).toEqual(expectedState);
|
||||
expect(reducer({}, fetchSourcesSuccess(repository, "", "", collection))).toEqual(expectedState);
|
||||
});
|
||||
|
||||
it("should store the collection, with revision and path", () => {
|
||||
const expectedState = {
|
||||
"scm/core/abc/src/main": collection
|
||||
};
|
||||
expect(
|
||||
reducer(
|
||||
{},
|
||||
fetchSourcesSuccess(repository, "abc", "src/main", collection)
|
||||
)
|
||||
).toEqual(expectedState);
|
||||
expect(reducer({}, fetchSourcesSuccess(repository, "abc", "src/main", collection))).toEqual(expectedState);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -212,9 +204,7 @@ describe("selector tests", () => {
|
||||
}
|
||||
}
|
||||
};
|
||||
expect(
|
||||
isDirectory(state, repository, "abc", "src/main/package.json")
|
||||
).toBeFalsy();
|
||||
expect(isDirectory(state, repository, "abc", "src/main/package.json")).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should return true if it is directory", () => {
|
||||
|
||||
@@ -9,11 +9,7 @@ export const FETCH_SOURCES_PENDING = `${FETCH_SOURCES}_${types.PENDING_SUFFIX}`;
|
||||
export const FETCH_SOURCES_SUCCESS = `${FETCH_SOURCES}_${types.SUCCESS_SUFFIX}`;
|
||||
export const FETCH_SOURCES_FAILURE = `${FETCH_SOURCES}_${types.FAILURE_SUFFIX}`;
|
||||
|
||||
export function fetchSources(
|
||||
repository: Repository,
|
||||
revision: string,
|
||||
path: string
|
||||
) {
|
||||
export function fetchSources(repository: Repository, revision: string, path: string) {
|
||||
return function(dispatch: any) {
|
||||
dispatch(fetchSourcesPending(repository, revision, path));
|
||||
return apiClient
|
||||
@@ -39,23 +35,14 @@ function createUrl(repository: Repository, revision: string, path: string) {
|
||||
return `${base}${encodeURIComponent(revision)}/${pathDefined}`;
|
||||
}
|
||||
|
||||
export function fetchSourcesPending(
|
||||
repository: Repository,
|
||||
revision: string,
|
||||
path: string
|
||||
): Action {
|
||||
export function fetchSourcesPending(repository: Repository, revision: string, path: string): Action {
|
||||
return {
|
||||
type: FETCH_SOURCES_PENDING,
|
||||
itemId: createItemId(repository, revision, path)
|
||||
};
|
||||
}
|
||||
|
||||
export function fetchSourcesSuccess(
|
||||
repository: Repository,
|
||||
revision: string,
|
||||
path: string,
|
||||
sources: File
|
||||
) {
|
||||
export function fetchSourcesSuccess(repository: Repository, revision: string, path: string, sources: File) {
|
||||
return {
|
||||
type: FETCH_SOURCES_SUCCESS,
|
||||
payload: sources,
|
||||
@@ -63,12 +50,7 @@ export function fetchSourcesSuccess(
|
||||
};
|
||||
}
|
||||
|
||||
export function fetchSourcesFailure(
|
||||
repository: Repository,
|
||||
revision: string,
|
||||
path: string,
|
||||
error: Error
|
||||
): Action {
|
||||
export function fetchSourcesFailure(repository: Repository, revision: string, path: string, error: Error): Action {
|
||||
return {
|
||||
type: FETCH_SOURCES_FAILURE,
|
||||
payload: error,
|
||||
@@ -101,12 +83,7 @@ export default function reducer(
|
||||
|
||||
// selectors
|
||||
|
||||
export function isDirectory(
|
||||
state: any,
|
||||
repository: Repository,
|
||||
revision: string,
|
||||
path: string
|
||||
): boolean {
|
||||
export function isDirectory(state: any, repository: Repository, revision: string, path: string): boolean {
|
||||
const currentFile = getSources(state, repository, revision, path);
|
||||
if (currentFile && !currentFile.directory) {
|
||||
return false;
|
||||
@@ -127,17 +104,8 @@ export function getSources(
|
||||
return null;
|
||||
}
|
||||
|
||||
export function isFetchSourcesPending(
|
||||
state: any,
|
||||
repository: Repository,
|
||||
revision: string,
|
||||
path: string
|
||||
): boolean {
|
||||
return isPending(
|
||||
state,
|
||||
FETCH_SOURCES,
|
||||
createItemId(repository, revision, path)
|
||||
);
|
||||
export function isFetchSourcesPending(state: any, repository: Repository, revision: string, path: string): boolean {
|
||||
return isPending(state, FETCH_SOURCES, createItemId(repository, revision, path));
|
||||
}
|
||||
|
||||
export function getFetchSourcesFailure(
|
||||
@@ -146,9 +114,5 @@ export function getFetchSourcesFailure(
|
||||
revision: string,
|
||||
path: string
|
||||
): Error | null | undefined {
|
||||
return getFailure(
|
||||
state,
|
||||
FETCH_SOURCES,
|
||||
createItemId(repository, revision, path)
|
||||
);
|
||||
return getFailure(state, FETCH_SOURCES, createItemId(repository, revision, path));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user