mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
Fix rendering trigger
This commit is contained in:
@@ -138,22 +138,14 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
<Route
|
||||
path={`${url}/sources`}
|
||||
exact={true}
|
||||
component={props => (
|
||||
<Sources
|
||||
{...props}
|
||||
repository={repository}
|
||||
baseUrl={`${url}/sources`}
|
||||
/>
|
||||
render={() => (
|
||||
<Sources repository={repository} baseUrl={`${url}/sources`} />
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/sources/:revision/:path*`}
|
||||
component={props => (
|
||||
<Sources
|
||||
{...props}
|
||||
repository={repository}
|
||||
baseUrl={`${url}/sources`}
|
||||
/>
|
||||
render={() => (
|
||||
<Sources repository={repository} baseUrl={`${url}/sources`} />
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
|
||||
@@ -55,6 +55,13 @@ class FileTree extends React.Component<Props> {
|
||||
fetchSources(repository, revision, path);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const { fetchSources, repository, revision, path } = this.props;
|
||||
if (prevProps.revision !== revision || prevProps.path !== path) {
|
||||
fetchSources(repository, revision, path);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
error,
|
||||
@@ -138,18 +145,17 @@ class FileTree extends React.Component<Props> {
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: any, ownProps: Props) => {
|
||||
const { repository, match } = ownProps;
|
||||
const { revision, path } = match.params;
|
||||
const { repository, revision, path } = ownProps;
|
||||
|
||||
const loading = isFetchSourcesPending(state, repository, revision, path);
|
||||
const error = getFetchSourcesFailure(state, repository, revision, path);
|
||||
const tree = getSources(state, repository, revision, path);
|
||||
|
||||
return {
|
||||
loading,
|
||||
error,
|
||||
revision,
|
||||
path,
|
||||
loading,
|
||||
error,
|
||||
tree
|
||||
};
|
||||
};
|
||||
|
||||
@@ -20,6 +20,7 @@ type Props = {
|
||||
error: Error,
|
||||
baseUrl: string,
|
||||
branches: Branch[],
|
||||
revision: string,
|
||||
path: string,
|
||||
|
||||
// dispatch props
|
||||
@@ -39,6 +40,7 @@ class Sources extends React.Component<Props> {
|
||||
|
||||
branchSelected = (branch?: Branch) => {
|
||||
const { baseUrl, history, path } = this.props;
|
||||
|
||||
let url;
|
||||
if (branch) {
|
||||
if (path) {
|
||||
@@ -53,7 +55,7 @@ class Sources extends React.Component<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { repository, baseUrl, loading, error } = this.props;
|
||||
const { repository, baseUrl, loading, error, revision, path } = this.props;
|
||||
|
||||
if (error) {
|
||||
return <ErrorNotification error={error} />;
|
||||
@@ -66,7 +68,12 @@ class Sources extends React.Component<Props> {
|
||||
return (
|
||||
<>
|
||||
{this.renderBranchSelector()}
|
||||
<FileTree repository={repository} baseUrl={baseUrl} />
|
||||
<FileTree
|
||||
repository={repository}
|
||||
revision={revision}
|
||||
path={path}
|
||||
baseUrl={baseUrl}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -89,7 +96,7 @@ class Sources extends React.Component<Props> {
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const { repository, match } = ownProps;
|
||||
const { path } = match.params;
|
||||
const { revision, path } = match.params;
|
||||
|
||||
const loading = isFetchBranchesPending(state, repository);
|
||||
const error = getFetchBranchesFailure(state, repository);
|
||||
@@ -97,6 +104,7 @@ const mapStateToProps = (state, ownProps) => {
|
||||
|
||||
return {
|
||||
repository,
|
||||
revision,
|
||||
path,
|
||||
loading,
|
||||
error,
|
||||
|
||||
Reference in New Issue
Block a user