mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
Added types, components and logic for changesets
This commit is contained in:
21
scm-ui/src/changesets/components/ChangesetRow.js
Normal file
21
scm-ui/src/changesets/components/ChangesetRow.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import React from "react"
|
||||
import type { Changeset } from "@scm-manager/ui-types"
|
||||
|
||||
type Props = {
|
||||
changeset: Changeset
|
||||
}
|
||||
|
||||
class ChangesetRow extends React.Component<Props> {
|
||||
|
||||
// Todo: Add extension point to author field
|
||||
render() {
|
||||
const {changeset} = this.props;
|
||||
return <tr>
|
||||
<td>{ changeset.author.name }</td>
|
||||
<td>{ changeset.description }</td>
|
||||
<td>{ changeset.date }</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
|
||||
export default ChangesetRow;
|
||||
59
scm-ui/src/changesets/components/Changesets.js
Normal file
59
scm-ui/src/changesets/components/Changesets.js
Normal file
@@ -0,0 +1,59 @@
|
||||
import React from "react"
|
||||
import { connect } from "react-redux";
|
||||
import ChangesetRow from "./ChangesetRow";
|
||||
import type {Changeset} from "@scm-manager/ui-types";
|
||||
|
||||
import { fetchChangesetsByNamespaceAndName, getChangesetsForNameAndNamespaceFromState } from "../modules/changesets";
|
||||
import { translate } from "react-i18next";
|
||||
|
||||
type Props = {
|
||||
changesets: Changeset[],
|
||||
t: string => string
|
||||
}
|
||||
|
||||
class Changesets extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
const {namespace, name} = this.props.repository;
|
||||
this.props.fetchChangesetsByNamespaceAndName(namespace, name);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { t, changesets } = this.props;
|
||||
if (!changesets) {
|
||||
return null;
|
||||
}
|
||||
return <table className="table is-hoverable is-fullwidth">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t("author.name")}</th>
|
||||
<th>{t("changeset.description")}</th>
|
||||
<th className="is-hidden-mobile">{t("changeset.date")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{changesets.map((changeset, index) => {
|
||||
return <ChangesetRow key={index} changeset={changeset} />;
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
changesets: getChangesetsForNameAndNamespaceFromState(ownProps.repository.namespace, ownProps.repository.name, state)
|
||||
}
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
fetchChangesetsByNamespaceAndName: (namespace: string, name: string) => {
|
||||
dispatch(fetchChangesetsByNamespaceAndName(namespace, name))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(translate("changesets")(Changesets));
|
||||
Reference in New Issue
Block a user