mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
apply prettier, removed flow related config and added tsconfig
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { translate } from 'react-i18next';
|
||||
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 React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { translate } from "react-i18next";
|
||||
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 { getSources } from '../modules/sources';
|
||||
import FileButtonAddons from '../components/content/FileButtonAddons';
|
||||
import SourcesView from './SourcesView';
|
||||
import HistoryView from './HistoryView';
|
||||
Icon
|
||||
} from "@scm-manager/ui-components";
|
||||
import { getSources } from "../modules/sources";
|
||||
import FileButtonAddons from "../components/content/FileButtonAddons";
|
||||
import SourcesView from "./SourcesView";
|
||||
import HistoryView from "./HistoryView";
|
||||
|
||||
type Props = {
|
||||
loading: boolean;
|
||||
@@ -59,33 +59,33 @@ class Content extends React.Component<Props, State> {
|
||||
|
||||
this.state = {
|
||||
collapsed: true,
|
||||
showHistory: false,
|
||||
showHistory: false
|
||||
};
|
||||
}
|
||||
|
||||
toggleCollapse = () => {
|
||||
this.setState(prevState => ({
|
||||
collapsed: !prevState.collapsed,
|
||||
collapsed: !prevState.collapsed
|
||||
}));
|
||||
};
|
||||
|
||||
setShowHistoryState(showHistory: boolean) {
|
||||
this.setState({
|
||||
...this.state,
|
||||
showHistory,
|
||||
showHistory
|
||||
});
|
||||
}
|
||||
|
||||
handleExtensionError = (error: Error) => {
|
||||
this.setState({
|
||||
errorFromExtension: error,
|
||||
errorFromExtension: error
|
||||
});
|
||||
};
|
||||
|
||||
showHeader() {
|
||||
const { file, revision } = this.props;
|
||||
const { showHistory, collapsed } = this.state;
|
||||
const icon = collapsed ? 'angle-right' : 'angle-down';
|
||||
const icon = collapsed ? "angle-right" : "angle-down";
|
||||
|
||||
const selector = file._links.history ? (
|
||||
<RightMarginFileButtonAddons
|
||||
@@ -99,7 +99,7 @@ class Content extends React.Component<Props, State> {
|
||||
|
||||
return (
|
||||
<span className="has-cursor-pointer">
|
||||
<VCenteredChild className={classNames('media', 'is-flex')}>
|
||||
<VCenteredChild className={classNames("media", "is-flex")}>
|
||||
<div className="media-content" onClick={this.toggleCollapse}>
|
||||
<RightMarginIcon name={icon} color="inherit" />
|
||||
<span className="is-word-break">{file.name}</span>
|
||||
@@ -111,7 +111,7 @@ class Content extends React.Component<Props, State> {
|
||||
props={{
|
||||
file,
|
||||
revision,
|
||||
handleExtensionError: this.handleExtensionError,
|
||||
handleExtensionError: this.handleExtensionError
|
||||
}}
|
||||
renderAll={true}
|
||||
/>
|
||||
@@ -127,7 +127,7 @@ class Content extends React.Component<Props, State> {
|
||||
const date = <DateFromNow date={file.lastModified} />;
|
||||
const description = file.description ? (
|
||||
<p>
|
||||
{file.description.split('\n').map((item, key) => {
|
||||
{file.description.split("\n").map((item, key) => {
|
||||
return (
|
||||
<span key={key}>
|
||||
{item}
|
||||
@@ -137,30 +137,30 @@ class Content extends React.Component<Props, State> {
|
||||
})}
|
||||
</p>
|
||||
) : null;
|
||||
const fileSize = file.directory ? '' : <FileSize bytes={file.length} />;
|
||||
const fileSize = file.directory ? "" : <FileSize bytes={file.length} />;
|
||||
if (!collapsed) {
|
||||
return (
|
||||
<LighterGreyBackgroundPanelBlock className="panel-block">
|
||||
<LighterGreyBackgroundTable className="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{t('sources.content.path')}</td>
|
||||
<td>{t("sources.content.path")}</td>
|
||||
<td className="is-word-break">{file.path}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{t('sources.content.branch')}</td>
|
||||
<td>{t("sources.content.branch")}</td>
|
||||
<td className="is-word-break">{revision}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{t('sources.content.size')}</td>
|
||||
<td>{t("sources.content.size")}</td>
|
||||
<td>{fileSize}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{t('sources.content.lastModified')}</td>
|
||||
<td>{t("sources.content.lastModified")}</td>
|
||||
<td>{date}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{t('sources.content.description')}</td>
|
||||
<td>{t("sources.content.description")}</td>
|
||||
<td className="is-word-break">{description}</td>
|
||||
</tr>
|
||||
<ExtensionPoint
|
||||
@@ -169,7 +169,7 @@ class Content extends React.Component<Props, State> {
|
||||
props={{
|
||||
file,
|
||||
repository,
|
||||
revision,
|
||||
revision
|
||||
}}
|
||||
/>
|
||||
</tbody>
|
||||
@@ -217,8 +217,8 @@ const mapStateToProps = (state: any, ownProps: Props) => {
|
||||
const file = getSources(state, repository, revision, path);
|
||||
|
||||
return {
|
||||
file,
|
||||
file
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(translate('repos')(Content));
|
||||
export default connect(mapStateToProps)(translate("repos")(Content));
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
import {
|
||||
File,
|
||||
Changeset,
|
||||
Repository,
|
||||
PagedCollection,
|
||||
} from '@scm-manager/ui-types';
|
||||
PagedCollection
|
||||
} from "@scm-manager/ui-types";
|
||||
import {
|
||||
ErrorNotification,
|
||||
Loading,
|
||||
StatePaginator,
|
||||
ChangesetList,
|
||||
} from '@scm-manager/ui-components';
|
||||
import { getHistory } from './history';
|
||||
ChangesetList
|
||||
} from "@scm-manager/ui-components";
|
||||
import { getHistory } from "./history";
|
||||
|
||||
type Props = {
|
||||
file: File;
|
||||
@@ -33,7 +33,7 @@ class HistoryView extends React.Component<Props, State> {
|
||||
this.state = {
|
||||
loaded: false,
|
||||
page: 1,
|
||||
changesets: [],
|
||||
changesets: []
|
||||
};
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class HistoryView extends React.Component<Props, State> {
|
||||
this.setState({
|
||||
...this.state,
|
||||
error: result.error,
|
||||
loaded: true,
|
||||
loaded: true
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
@@ -57,7 +57,7 @@ class HistoryView extends React.Component<Props, State> {
|
||||
loaded: true,
|
||||
changesets: result.changesets,
|
||||
pageCollection: result.pageCollection,
|
||||
page: result.pageCollection.page,
|
||||
page: result.pageCollection.page
|
||||
});
|
||||
}
|
||||
})
|
||||
@@ -68,7 +68,7 @@ class HistoryView extends React.Component<Props, State> {
|
||||
const { file } = this.props;
|
||||
const internalPage = page - 1;
|
||||
this.updateHistory(
|
||||
file._links.history.href + '?page=' + internalPage.toString(),
|
||||
file._links.history.href + "?page=" + internalPage.toString()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import React from 'react';
|
||||
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 React from "react";
|
||||
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 { translate } from 'react-i18next';
|
||||
Loading
|
||||
} from "@scm-manager/ui-components";
|
||||
import { translate } from "react-i18next";
|
||||
import {
|
||||
fetchBranches,
|
||||
getBranches,
|
||||
getFetchBranchesFailure,
|
||||
isFetchBranchesPending,
|
||||
} from '../../branches/modules/branches';
|
||||
import { compose } from 'redux';
|
||||
import Content from './Content';
|
||||
import { fetchSources, isDirectory } from '../modules/sources';
|
||||
isFetchBranchesPending
|
||||
} from "../../branches/modules/branches";
|
||||
import { compose } from "redux";
|
||||
import Content from "./Content";
|
||||
import { fetchSources, isDirectory } from "../modules/sources";
|
||||
|
||||
type Props = {
|
||||
repository: Repository;
|
||||
@@ -50,7 +50,7 @@ class Sources extends React.Component<Props, State> {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
selectedBranch: null,
|
||||
selectedBranch: null
|
||||
};
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class Sources extends React.Component<Props, State> {
|
||||
repository,
|
||||
revision,
|
||||
path,
|
||||
fetchSources,
|
||||
fetchSources
|
||||
} = this.props;
|
||||
|
||||
fetchBranches(repository);
|
||||
@@ -99,7 +99,7 @@ class Sources extends React.Component<Props, State> {
|
||||
let url;
|
||||
if (branch) {
|
||||
this.setState({
|
||||
selectedBranch: branch,
|
||||
selectedBranch: branch
|
||||
});
|
||||
if (path) {
|
||||
url = `${baseUrl}/${encodeURIComponent(branch.name)}/${path}`;
|
||||
@@ -108,7 +108,7 @@ class Sources extends React.Component<Props, State> {
|
||||
}
|
||||
} else {
|
||||
this.setState({
|
||||
selectedBranch: null,
|
||||
selectedBranch: null
|
||||
});
|
||||
url = `${baseUrl}/`;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ class Sources extends React.Component<Props, State> {
|
||||
error,
|
||||
revision,
|
||||
path,
|
||||
currentFileIsDirectory,
|
||||
currentFileIsDirectory
|
||||
} = this.props;
|
||||
|
||||
if (error) {
|
||||
@@ -163,7 +163,7 @@ class Sources extends React.Component<Props, State> {
|
||||
<BranchSelector
|
||||
branches={branches}
|
||||
selectedBranch={revision}
|
||||
label={t('changesets.branchSelectorLabel')}
|
||||
label={t("changesets.branchSelectorLabel")}
|
||||
selected={(b: Branch) => {
|
||||
this.branchSelected(b);
|
||||
}}
|
||||
@@ -215,7 +215,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
loading,
|
||||
error,
|
||||
branches,
|
||||
currentFileIsDirectory,
|
||||
currentFileIsDirectory
|
||||
};
|
||||
};
|
||||
|
||||
@@ -226,15 +226,15 @@ const mapDispatchToProps = dispatch => {
|
||||
},
|
||||
fetchSources: (repository: Repository, revision: string, path: string) => {
|
||||
dispatch(fetchSources(repository, revision, path));
|
||||
},
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export default compose(
|
||||
translate('repos'),
|
||||
translate("repos"),
|
||||
withRouter,
|
||||
connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
),
|
||||
mapDispatchToProps
|
||||
)
|
||||
)(Sources);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
|
||||
import SourcecodeViewer from '../components/content/SourcecodeViewer';
|
||||
import ImageViewer from '../components/content/ImageViewer';
|
||||
import DownloadViewer from '../components/content/DownloadViewer';
|
||||
import { ExtensionPoint } from '@scm-manager/ui-extensions';
|
||||
import { getContentType } from './contentType';
|
||||
import { File, Repository } from '@scm-manager/ui-types';
|
||||
import { ErrorNotification, Loading } from '@scm-manager/ui-components';
|
||||
import SourcecodeViewer from "../components/content/SourcecodeViewer";
|
||||
import ImageViewer from "../components/content/ImageViewer";
|
||||
import DownloadViewer from "../components/content/DownloadViewer";
|
||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||
import { getContentType } from "./contentType";
|
||||
import { File, Repository } from "@scm-manager/ui-types";
|
||||
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
repository: Repository;
|
||||
@@ -27,9 +27,9 @@ class SourcesView extends React.Component<Props, State> {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
contentType: '',
|
||||
language: '',
|
||||
loaded: false,
|
||||
contentType: "",
|
||||
language: "",
|
||||
loaded: false
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,14 +41,14 @@ class SourcesView extends React.Component<Props, State> {
|
||||
this.setState({
|
||||
...this.state,
|
||||
error: result.error,
|
||||
loaded: true,
|
||||
loaded: true
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
...this.state,
|
||||
contentType: result.type,
|
||||
language: result.language,
|
||||
loaded: true,
|
||||
loaded: true
|
||||
});
|
||||
}
|
||||
})
|
||||
@@ -58,11 +58,11 @@ class SourcesView extends React.Component<Props, State> {
|
||||
showSources() {
|
||||
const { file, revision } = this.props;
|
||||
const { contentType, language } = this.state;
|
||||
if (contentType.startsWith('image/')) {
|
||||
if (contentType.startsWith("image/")) {
|
||||
return <ImageViewer file={file} />;
|
||||
} else if (language) {
|
||||
return <SourcecodeViewer file={file} language={language} />;
|
||||
} else if (contentType.startsWith('text/')) {
|
||||
} else if (contentType.startsWith("text/")) {
|
||||
return <SourcecodeViewer file={file} language="none" />;
|
||||
} else {
|
||||
return (
|
||||
@@ -71,7 +71,7 @@ class SourcesView extends React.Component<Props, State> {
|
||||
props={{
|
||||
file,
|
||||
contentType,
|
||||
revision,
|
||||
revision
|
||||
}}
|
||||
>
|
||||
<DownloadViewer file={file} />
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import fetchMock from 'fetch-mock';
|
||||
import { getContentType } from './contentType';
|
||||
import fetchMock from "fetch-mock";
|
||||
import { getContentType } from "./contentType";
|
||||
|
||||
describe('get content type', () => {
|
||||
const CONTENT_URL = '/repositories/scmadmin/TestRepo/content/testContent';
|
||||
describe("get content type", () => {
|
||||
const CONTENT_URL = "/repositories/scmadmin/TestRepo/content/testContent";
|
||||
|
||||
afterEach(() => {
|
||||
fetchMock.reset();
|
||||
fetchMock.restore();
|
||||
});
|
||||
|
||||
it('should return content', done => {
|
||||
it("should return content", done => {
|
||||
let headers = {
|
||||
'Content-Type': 'application/text',
|
||||
'X-Programming-Language': 'JAVA',
|
||||
"Content-Type": "application/text",
|
||||
"X-Programming-Language": "JAVA"
|
||||
};
|
||||
|
||||
fetchMock.head('/api/v2' + CONTENT_URL, {
|
||||
headers,
|
||||
fetchMock.head("/api/v2" + CONTENT_URL, {
|
||||
headers
|
||||
});
|
||||
|
||||
getContentType(CONTENT_URL).then(content => {
|
||||
expect(content.type).toBe('application/text');
|
||||
expect(content.language).toBe('JAVA');
|
||||
expect(content.type).toBe("application/text");
|
||||
expect(content.language).toBe("JAVA");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { apiClient } from '@scm-manager/ui-components';
|
||||
import { apiClient } from "@scm-manager/ui-components";
|
||||
|
||||
export function getContentType(url: string) {
|
||||
return apiClient
|
||||
.head(url)
|
||||
.then(response => {
|
||||
return {
|
||||
type: response.headers.get('Content-Type'),
|
||||
language: response.headers.get('X-Programming-Language'),
|
||||
type: response.headers.get("Content-Type"),
|
||||
language: response.headers.get("X-Programming-Language")
|
||||
};
|
||||
})
|
||||
.catch(err => {
|
||||
return {
|
||||
error: err,
|
||||
error: err
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import fetchMock from 'fetch-mock';
|
||||
import { getHistory } from './history';
|
||||
import fetchMock from "fetch-mock";
|
||||
import { getHistory } from "./history";
|
||||
|
||||
describe('get content type', () => {
|
||||
const FILE_URL = '/repositories/scmadmin/TestRepo/history/file';
|
||||
describe("get content type", () => {
|
||||
const FILE_URL = "/repositories/scmadmin/TestRepo/history/file";
|
||||
|
||||
afterEach(() => {
|
||||
fetchMock.reset();
|
||||
@@ -14,32 +14,32 @@ describe('get content type', () => {
|
||||
pageTotal: 10,
|
||||
_links: {
|
||||
self: {
|
||||
href: '/repositories/scmadmin/TestRepo/history/file?page=0&pageSize=10',
|
||||
href: "/repositories/scmadmin/TestRepo/history/file?page=0&pageSize=10"
|
||||
},
|
||||
first: {
|
||||
href: '/repositories/scmadmin/TestRepo/history/file?page=0&pageSize=10',
|
||||
href: "/repositories/scmadmin/TestRepo/history/file?page=0&pageSize=10"
|
||||
},
|
||||
next: {
|
||||
href: '/repositories/scmadmin/TestRepo/history/file?page=1&pageSize=10',
|
||||
href: "/repositories/scmadmin/TestRepo/history/file?page=1&pageSize=10"
|
||||
},
|
||||
last: {
|
||||
href: '/repositories/scmadmin/TestRepo/history/file?page=9&pageSize=10',
|
||||
},
|
||||
href: "/repositories/scmadmin/TestRepo/history/file?page=9&pageSize=10"
|
||||
}
|
||||
},
|
||||
_embedded: {
|
||||
changesets: [
|
||||
{
|
||||
id: '1234',
|
||||
id: "1234"
|
||||
},
|
||||
{
|
||||
id: '2345',
|
||||
},
|
||||
],
|
||||
},
|
||||
id: "2345"
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
it('should return history', done => {
|
||||
fetchMock.get('/api/v2' + FILE_URL, history);
|
||||
it("should return history", done => {
|
||||
fetchMock.get("/api/v2" + FILE_URL, history);
|
||||
|
||||
getHistory(FILE_URL).then(content => {
|
||||
expect(content.changesets).toEqual(history._embedded.changesets);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { apiClient } from '@scm-manager/ui-components';
|
||||
import { apiClient } from "@scm-manager/ui-components";
|
||||
|
||||
export function getHistory(url: string) {
|
||||
return apiClient
|
||||
@@ -11,13 +11,13 @@ export function getHistory(url: string) {
|
||||
_embedded: result._embedded,
|
||||
_links: result._links,
|
||||
page: result.page,
|
||||
pageTotal: result.pageTotal,
|
||||
},
|
||||
pageTotal: result.pageTotal
|
||||
}
|
||||
};
|
||||
})
|
||||
.catch(err => {
|
||||
return {
|
||||
error: err,
|
||||
error: err
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user