mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
Fixed minor issues
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
fetchChangesetsByBranchAndPage,
|
||||
fetchChangesetsByLink,
|
||||
fetchChangesetsByPage,
|
||||
getChangesets,
|
||||
getChangesetsFromState,
|
||||
getFetchChangesetsFailure,
|
||||
isFetchChangesetsPending,
|
||||
@@ -54,16 +55,11 @@ type Props = {
|
||||
branch: Branch
|
||||
};
|
||||
|
||||
type State = {
|
||||
branch: string
|
||||
};
|
||||
type State = {};
|
||||
|
||||
class Changesets extends React.PureComponent<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
branch: ""
|
||||
};
|
||||
}
|
||||
|
||||
onPageChange = (link: string) => {
|
||||
@@ -95,16 +91,18 @@ class Changesets extends React.PureComponent<Props, State> {
|
||||
componentDidUpdate(prevProps: Props) {
|
||||
const { page, list, repository, match } = this.props;
|
||||
const { namespace, name } = repository;
|
||||
const branch = decodeURIComponent(match.params.branch);
|
||||
const branch = match.params.branch;
|
||||
|
||||
if (!this.props.loading) {
|
||||
if (prevProps.branch !== this.props.branch) {
|
||||
this.setState({ branch });
|
||||
this.updateContent();
|
||||
}
|
||||
|
||||
if (list && (list.page || list.page === 0)) {
|
||||
console.log(list);
|
||||
// backend starts paging at 0
|
||||
const statePage: number = list.page + 1;
|
||||
console.log(`page: ${page} - statePage: ${statePage}`);
|
||||
if (page !== statePage) {
|
||||
if (branch) {
|
||||
this.props.history.push(
|
||||
@@ -194,9 +192,9 @@ const getPageFromProps = props => {
|
||||
const mapStateToProps = (state, ownProps: Props) => {
|
||||
const { repository } = ownProps;
|
||||
const branchName = ownProps.match.params.branch;
|
||||
const branch = getBranch(state, repository, branchName);
|
||||
const branch = getBranch(state, repository, decodeURIComponent(branchName));
|
||||
const loading = isFetchChangesetsPending(state, repository, branch);
|
||||
const changesets = getChangesetsFromState(state, repository);
|
||||
const changesets = getChangesets(state, repository, branch);
|
||||
const branchNames = getBranchNames(state, repository);
|
||||
const error = getFetchChangesetsFailure(state, repository, branch);
|
||||
const list = selectListAsCollection(state, repository);
|
||||
|
||||
@@ -132,7 +132,7 @@ export function getBranch(
|
||||
state: Object,
|
||||
repository: Repository,
|
||||
name: string
|
||||
): Branch {
|
||||
): ?Branch {
|
||||
const key = createKey(repository);
|
||||
if (state.branches[key]) {
|
||||
if (state.branches[key].byNames[name]) {
|
||||
|
||||
@@ -82,7 +82,6 @@ export function fetchChangesetsByPage(repository: Repository, page: number) {
|
||||
return fetchChangesetsWithOptions(repository, undefined, `?page=${page - 1}`);
|
||||
}
|
||||
|
||||
// TODO: Rewrite code to fetch changesets by branches, adjust tests and let BranchChooser fetch branches
|
||||
export function fetchChangesetsByBranchAndPage(
|
||||
repository: Repository,
|
||||
branch: Branch,
|
||||
@@ -171,7 +170,7 @@ function byKeyReducer(
|
||||
return {
|
||||
...state,
|
||||
[key]: {
|
||||
byId: { ...byIds },
|
||||
byId: byIds,
|
||||
list: {
|
||||
entries: changesetIds,
|
||||
entry: {
|
||||
|
||||
Reference in New Issue
Block a user