mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
fixed small review findings
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React from "react";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import { apiClient, ErrorNotification, Loading, SyntaxHighlighter } from "@scm-manager/ui-components";
|
||||
import { File } from "@scm-manager/ui-types";
|
||||
import { File, Link } from "@scm-manager/ui-types";
|
||||
|
||||
type Props = WithTranslation & {
|
||||
file: File;
|
||||
@@ -27,14 +27,14 @@ class SourcecodeViewer extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { file } = this.props;
|
||||
const { currentFileRevision } = this.state;
|
||||
if (file.revision !== currentFileRevision) {
|
||||
this.fetchContent();
|
||||
}
|
||||
this.fetchContentIfChanged();
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.fetchContentIfChanged();
|
||||
}
|
||||
|
||||
private fetchContentIfChanged() {
|
||||
const { file } = this.props;
|
||||
const { currentFileRevision } = this.state;
|
||||
if (file.revision !== currentFileRevision) {
|
||||
@@ -44,7 +44,7 @@ class SourcecodeViewer extends React.Component<Props, State> {
|
||||
|
||||
fetchContent = () => {
|
||||
const { file } = this.props;
|
||||
getContent(file._links.self.href)
|
||||
getContent((file._links.self as Link).href)
|
||||
.then(content => {
|
||||
this.setState({
|
||||
content,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import { Changeset, File, PagedCollection, Repository } from "@scm-manager/ui-types";
|
||||
import { Changeset, File, PagedCollection, Repository, Link } from "@scm-manager/ui-types";
|
||||
import { ChangesetList, ErrorNotification, Loading, StatePaginator } from "@scm-manager/ui-components";
|
||||
import { getHistory } from "./history";
|
||||
|
||||
@@ -31,14 +31,16 @@ class HistoryView extends React.Component<Props, State> {
|
||||
|
||||
componentDidMount() {
|
||||
const { file } = this.props;
|
||||
file && this.updateHistory(file._links.history.href);
|
||||
if (file) {
|
||||
this.updateHistory((file._links.history as Link).href);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
const { file } = this.props;
|
||||
const { currentRevision } = this.state;
|
||||
if (file?.revision !== currentRevision) {
|
||||
this.updateHistory(file._links.history.href);
|
||||
this.updateHistory((file._links.history as Link).href);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +69,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 as Link).href + "?page=" + internalPage.toString());
|
||||
}
|
||||
|
||||
showHistory() {
|
||||
|
||||
@@ -24,7 +24,7 @@ type Props = WithTranslation &
|
||||
sources?: File | null;
|
||||
|
||||
// dispatch props
|
||||
fetchSources: (repository: Repository, revision: string | undefined, path: string | undefined) => void;
|
||||
fetchSources: (repository: Repository, revision?: string, path?: string) => void;
|
||||
};
|
||||
|
||||
const extensionPointName = "repos.sources.extensions";
|
||||
|
||||
@@ -25,7 +25,7 @@ type Props = WithTranslation &
|
||||
selectedBranch: string;
|
||||
|
||||
// dispatch props
|
||||
fetchSources: (p1: Repository, p2: string, p3: string) => void;
|
||||
fetchSources: (repository: Repository, revision: string, path: string) => void;
|
||||
};
|
||||
|
||||
class Sources extends React.Component<Props> {
|
||||
|
||||
Reference in New Issue
Block a user