mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
complete module and show changesets, error and loading
This commit is contained in:
@@ -9,5 +9,9 @@
|
|||||||
"author": {
|
"author": {
|
||||||
"name": "Author",
|
"name": "Author",
|
||||||
"mail": "Mail"
|
"mail": "Mail"
|
||||||
|
},
|
||||||
|
"changeset-error": {
|
||||||
|
"title": "Error",
|
||||||
|
"subtitle": "Unknown changeset error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
48
scm-ui/src/repos/components/ChangesetDetails.js
Normal file
48
scm-ui/src/repos/components/ChangesetDetails.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
//@flow
|
||||||
|
import React from "react";
|
||||||
|
import type { Changeset } from "@scm-manager/ui-types";
|
||||||
|
import { translate } from "react-i18next";
|
||||||
|
import { MailLink, DateFromNow } from "@scm-manager/ui-components";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
changeset: Changeset,
|
||||||
|
t: string => string
|
||||||
|
};
|
||||||
|
|
||||||
|
class ChangesetDetails extends React.Component<Props> {
|
||||||
|
render() {
|
||||||
|
const { changeset, t } = this.props;
|
||||||
|
return (
|
||||||
|
<table className="table">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>{t("changeset.id")}</td>
|
||||||
|
<td>{changeset.id}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{t("author.name")}</td>
|
||||||
|
<td>{changeset.author.name}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{t("author.mail")}</td>
|
||||||
|
<td>
|
||||||
|
<MailLink address={changeset.author.mail} />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{t("changeset.description")}</td>
|
||||||
|
<td>{changeset.description}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{t("changeset.date")}</td>
|
||||||
|
<td>
|
||||||
|
<DateFromNow date={changeset.date} />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default translate("changesets")(ChangesetDetails);
|
||||||
@@ -2,43 +2,68 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { withRouter } from "react-router-dom";
|
import { withRouter } from "react-router-dom";
|
||||||
import type { Changeset } from "@scm-manager/ui-types";
|
import type { Changeset, Repository } from "@scm-manager/ui-types";
|
||||||
import { fetchChangesetIfNeeded } from "../modules/changesets";
|
import {
|
||||||
|
fetchChangesetIfNeeded,
|
||||||
|
fetchChangesetReset,
|
||||||
|
getChangeset,
|
||||||
|
getFetchChangesetFailure,
|
||||||
|
isFetchChangesetPending
|
||||||
|
} from "../modules/changesets";
|
||||||
|
import ChangesetDetails from "../components/ChangesetDetails";
|
||||||
|
import { translate } from "react-i18next";
|
||||||
|
import { Loading, ErrorPage } from "@scm-manager/ui-components";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
id: string,
|
id: string,
|
||||||
changeset: Changeset,
|
changeset: Changeset,
|
||||||
repository: Repository,
|
repository: Repository,
|
||||||
repositories: Repository[],
|
loading: boolean,
|
||||||
|
error: Error,
|
||||||
fetchChangesetIfNeeded: (
|
fetchChangesetIfNeeded: (
|
||||||
namespace: string,
|
namespace: string,
|
||||||
repoName: string,
|
repoName: string,
|
||||||
id: string
|
id: string
|
||||||
) => void
|
) => void,
|
||||||
|
resetForm: (namespace: string, repoName: string, id: string) => void,
|
||||||
|
match: any,
|
||||||
|
t: string => string
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChangesetView extends React.Component<State, Props> {
|
class ChangesetView extends React.Component<Props> {
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { fetchChangesetIfNeeded, repository } = this.props;
|
const { fetchChangesetIfNeeded, repository } = this.props;
|
||||||
const id = this.props.match.params.id;
|
const id = this.props.match.params.id;
|
||||||
//state macht keinen Sinn?! repositories holen!
|
|
||||||
fetchChangesetIfNeeded(repository.namespace, repository.name, id);
|
fetchChangesetIfNeeded(repository.namespace, repository.name, id);
|
||||||
|
this.props.resetForm(repository.namespace, repository.name, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const id = this.props.match.params.id;
|
const { changeset, loading, error, t } = this.props;
|
||||||
|
|
||||||
return <div>Hallo! Changesets here! {id}</div>;
|
if (error) {
|
||||||
|
return (
|
||||||
|
<ErrorPage
|
||||||
|
title={t("changeset-error.title")}
|
||||||
|
subtitle={t("changeset-error.subtitle")}
|
||||||
|
error={error}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!changeset || loading) return <Loading />;
|
||||||
|
|
||||||
|
return <ChangesetDetails changeset={changeset} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps: Props) => {
|
const mapStateToProps = (state, ownProps: Props) => {
|
||||||
return null;
|
const { namespace, name } = ownProps.repository;
|
||||||
|
const id = ownProps.match.params.id;
|
||||||
|
const changeset = getChangeset(state, namespace, name, id);
|
||||||
|
const loading = isFetchChangesetPending(state, namespace, name, id);
|
||||||
|
const error = getFetchChangesetFailure(state, namespace, name, id);
|
||||||
|
return { changeset, error, loading };
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
@@ -49,6 +74,9 @@ const mapDispatchToProps = dispatch => {
|
|||||||
id: string
|
id: string
|
||||||
) => {
|
) => {
|
||||||
dispatch(fetchChangesetIfNeeded(namespace, repoName, id));
|
dispatch(fetchChangesetIfNeeded(namespace, repoName, id));
|
||||||
|
},
|
||||||
|
resetForm: (namespace: string, repoName: string, id: string) => {
|
||||||
|
dispatch(fetchChangesetReset(namespace, repoName, id));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -57,5 +85,5 @@ export default withRouter(
|
|||||||
connect(
|
connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps
|
mapDispatchToProps
|
||||||
)(ChangesetView)
|
)(translate("changesets")(ChangesetView))
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import { isPending } from "../../modules/pending";
|
|||||||
import { getFailure } from "../../modules/failure";
|
import { getFailure } from "../../modules/failure";
|
||||||
import { combineReducers } from "redux";
|
import { combineReducers } from "redux";
|
||||||
import type { Action, PagedCollection } from "@scm-manager/ui-types";
|
import type { Action, PagedCollection } from "@scm-manager/ui-types";
|
||||||
|
import * as types from "../../modules/types";
|
||||||
|
import { CREATE_USER_RESET } from "../../users/modules/users";
|
||||||
|
|
||||||
export const FETCH_CHANGESETS = "scm/repos/FETCH_CHANGESETS";
|
export const FETCH_CHANGESETS = "scm/repos/FETCH_CHANGESETS";
|
||||||
export const FETCH_CHANGESETS_PENDING = `${FETCH_CHANGESETS}_${PENDING_SUFFIX}`;
|
export const FETCH_CHANGESETS_PENDING = `${FETCH_CHANGESETS}_${PENDING_SUFFIX}`;
|
||||||
@@ -22,6 +24,7 @@ export const FETCH_CHANGESET = "scm/repos/FETCH_CHANGESET";
|
|||||||
export const FETCH_CHANGESET_PENDING = `${FETCH_CHANGESET}_${PENDING_SUFFIX}`;
|
export const FETCH_CHANGESET_PENDING = `${FETCH_CHANGESET}_${PENDING_SUFFIX}`;
|
||||||
export const FETCH_CHANGESET_SUCCESS = `${FETCH_CHANGESET}_${SUCCESS_SUFFIX}`;
|
export const FETCH_CHANGESET_SUCCESS = `${FETCH_CHANGESET}_${SUCCESS_SUFFIX}`;
|
||||||
export const FETCH_CHANGESET_FAILURE = `${FETCH_CHANGESET}_${FAILURE_SUFFIX}`;
|
export const FETCH_CHANGESET_FAILURE = `${FETCH_CHANGESET}_${FAILURE_SUFFIX}`;
|
||||||
|
export const FETCH_CHANGESET_RESET = `${FETCH_CHANGESET}_${types.RESET_SUFFIX}`;
|
||||||
|
|
||||||
//********end of detailed view add
|
//********end of detailed view add
|
||||||
|
|
||||||
@@ -57,7 +60,6 @@ export function fetchChangeset(
|
|||||||
dispatch(fetchChangesetSuccess(data, namespace, repoName, id))
|
dispatch(fetchChangesetSuccess(data, namespace, repoName, id))
|
||||||
)
|
)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log(err);
|
|
||||||
dispatch(fetchChangesetFailure(namespace, repoName, id, err));
|
dispatch(fetchChangesetFailure(namespace, repoName, id, err));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -109,6 +111,17 @@ function fetchChangesetFailure(
|
|||||||
itemId: createItemId(namespace, repoName, id)
|
itemId: createItemId(namespace, repoName, id)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fetchChangesetReset(
|
||||||
|
namespace: string,
|
||||||
|
repoName: string,
|
||||||
|
id: string
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
type: FETCH_CHANGESET_RESET,
|
||||||
|
itemId: createItemId(namespace, repoName, id)
|
||||||
|
};
|
||||||
|
}
|
||||||
//********end of detailed view add
|
//********end of detailed view add
|
||||||
|
|
||||||
export function fetchChangesetsWithOptions(
|
export function fetchChangesetsWithOptions(
|
||||||
|
|||||||
Reference in New Issue
Block a user