mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 19:15:52 +01:00
resolve further merging conflicts
This commit is contained in:
@@ -1,38 +0,0 @@
|
|||||||
import React from "react"
|
|
||||||
import type { Changeset } from "@scm-manager/ui-types"
|
|
||||||
import {ExtensionPoint} from "@scm-manager/ui-extensions";
|
|
||||||
import {Link} from "react-router-dom";
|
|
||||||
import {History} from "history";
|
|
||||||
import { NavLink } from "@scm-manager/ui-components";
|
|
||||||
import {withRouter} from "react-router-dom";
|
|
||||||
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
changeset: Changeset,
|
|
||||||
location: any
|
|
||||||
}
|
|
||||||
|
|
||||||
class ChangesetRow extends React.Component<Props> {
|
|
||||||
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { changeset } = this.props;
|
|
||||||
// todo: i18n
|
|
||||||
return (
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<ExtensionPoint
|
|
||||||
name="repos.changeset-table.information"
|
|
||||||
renderAll={true}
|
|
||||||
props={{ changeset }}
|
|
||||||
/>
|
|
||||||
<p> <NavLink to={`${this.props.location.pathname}/commit/${changeset.id}`} label={changeset.description}/></p>
|
|
||||||
<p className="is-size-7">Changeset { changeset.id } commited at { changeset.date }</p>
|
|
||||||
<p className="is-size-7">{changeset.author.name} <a href={"mailto:" + changeset.author.mail}><{changeset.author.mail}></a></p></td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default withRouter(ChangesetRow);
|
|
||||||
@@ -1,158 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import { connect } from "react-redux";
|
|
||||||
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
|
|
||||||
|
|
||||||
import {
|
|
||||||
fetchChangesetsByNamespaceAndName,
|
|
||||||
fetchChangesetsByNamespaceNameAndBranch,
|
|
||||||
getChangesets,
|
|
||||||
getFetchChangesetsFailure,
|
|
||||||
isFetchChangesetsPending
|
|
||||||
} from "../modules/changesets";
|
|
||||||
import type { History } from "history";
|
|
||||||
import {
|
|
||||||
fetchBranchesByNamespaceAndName,
|
|
||||||
getBranchNames
|
|
||||||
} from "../../repos/modules/branches";
|
|
||||||
import type { Repository } from "@scm-manager/ui-types";
|
|
||||||
import ChangesetTable from "../components/ChangesetTable";
|
|
||||||
import DropDown from "../components/DropDown";
|
|
||||||
import { Route, withRouter } from "react-router-dom";
|
|
||||||
import ChangesetView from "../../repos/changesets/containers/ChangesetView";
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
repository: Repository,
|
|
||||||
branchName: string,
|
|
||||||
history: History,
|
|
||||||
fetchChangesetsByNamespaceNameAndBranch: (
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
branch: string
|
|
||||||
) => void
|
|
||||||
};
|
|
||||||
|
|
||||||
class Changesets extends React.Component<State, Props> {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
const { namespace, name } = this.props.repository;
|
|
||||||
const branchName = this.props.match.params.branch;
|
|
||||||
if (branchName) {
|
|
||||||
this.props.fetchChangesetsByNamespaceNameAndBranch(
|
|
||||||
namespace,
|
|
||||||
name,
|
|
||||||
branchName
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
this.props.fetchChangesetsByNamespaceAndName(namespace, name);
|
|
||||||
}
|
|
||||||
this.props.fetchBranchesByNamespaceAndName(namespace, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
matchedUrl = () => {
|
|
||||||
return this.props.match.url;
|
|
||||||
};
|
|
||||||
render() {
|
|
||||||
const url = this.matchedUrl();
|
|
||||||
|
|
||||||
const { changesets, loading, error, repository } = this.props;
|
|
||||||
if (loading || !changesets) {
|
|
||||||
return <Loading />;
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className="column is-three-quarters">
|
|
||||||
<Route exact path={url} render={this.renderChangesets} />
|
|
||||||
<Route
|
|
||||||
exact
|
|
||||||
path={`${url}/commit/:id`}
|
|
||||||
component={() => <ChangesetView repository={repository} />}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderChangesets = () => {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<ErrorNotification error={this.props.error} />
|
|
||||||
{this.renderContent()}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
renderContent = () => {
|
|
||||||
const branch = this.props.match.params.branch;
|
|
||||||
const { changesets, branchNames } = this.props;
|
|
||||||
|
|
||||||
if (branchNames) {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<DropDown
|
|
||||||
options={branchNames}
|
|
||||||
preselectedOption={branch}
|
|
||||||
optionSelected={branch => this.branchChanged(branch)}
|
|
||||||
/>
|
|
||||||
<ChangesetTable changesets={changesets} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return <ChangesetTable changesets={changesets} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
branchChanged = (branchName: string) => {
|
|
||||||
const { history, repository } = this.props;
|
|
||||||
history.push(
|
|
||||||
`/repo/${repository.namespace}/${repository.name}/history/${branchName}`
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps: Props) => {
|
|
||||||
const { namespace, name } = ownProps.repository;
|
|
||||||
return {
|
|
||||||
loading: isFetchChangesetsPending(namespace, name, state),
|
|
||||||
changesets: getChangesets(
|
|
||||||
state,
|
|
||||||
namespace,
|
|
||||||
name,
|
|
||||||
ownProps.match.params.branch
|
|
||||||
),
|
|
||||||
branchNames: getBranchNames(namespace, name, state),
|
|
||||||
error: getFetchChangesetsFailure(
|
|
||||||
state,
|
|
||||||
namespace,
|
|
||||||
name,
|
|
||||||
ownProps.match.params.branch
|
|
||||||
)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
|
||||||
return {
|
|
||||||
fetchChangesetsByNamespaceAndName: (namespace: string, name: string) => {
|
|
||||||
dispatch(fetchChangesetsByNamespaceAndName(namespace, name));
|
|
||||||
},
|
|
||||||
fetchChangesetsByNamespaceNameAndBranch: (
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
branch: string
|
|
||||||
) => {
|
|
||||||
dispatch(
|
|
||||||
fetchChangesetsByNamespaceNameAndBranch(namespace, name, branch)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
fetchBranchesByNamespaceAndName: (namespace: string, name: string) => {
|
|
||||||
dispatch(fetchBranchesByNamespaceAndName(namespace, name));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export default withRouter(
|
|
||||||
connect(
|
|
||||||
mapStateToProps,
|
|
||||||
mapDispatchToProps
|
|
||||||
)(Changesets)
|
|
||||||
);
|
|
||||||
@@ -1,297 +0,0 @@
|
|||||||
// @flow
|
|
||||||
|
|
||||||
import {
|
|
||||||
FAILURE_SUFFIX,
|
|
||||||
PENDING_SUFFIX,
|
|
||||||
SUCCESS_SUFFIX
|
|
||||||
} from "../../modules/types";
|
|
||||||
import { apiClient } from "@scm-manager/ui-components";
|
|
||||||
import { isPending } from "../../modules/pending";
|
|
||||||
import { getFailure } from "../../modules/failure";
|
|
||||||
|
|
||||||
export const FETCH_CHANGESETS = "scm/repos/FETCH_CHANGESETS";
|
|
||||||
export const FETCH_CHANGESETS_PENDING = `${FETCH_CHANGESETS}_${PENDING_SUFFIX}`;
|
|
||||||
export const FETCH_CHANGESETS_SUCCESS = `${FETCH_CHANGESETS}_${SUCCESS_SUFFIX}`;
|
|
||||||
export const FETCH_CHANGESETS_FAILURE = `${FETCH_CHANGESETS}_${FAILURE_SUFFIX}`;
|
|
||||||
|
|
||||||
/****added for detailed view of changesets****/
|
|
||||||
|
|
||||||
export const FETCH_CHANGESET = "scm/repos/FETCH_CHANGESET";
|
|
||||||
export const FETCH_CHANGESET_PENDING = `${FETCH_CHANGESET}_${PENDING_SUFFIX}`;
|
|
||||||
export const FETCH_CHANGESET_SUCCESS = `${FETCH_CHANGESET}_${SUCCESS_SUFFIX}`;
|
|
||||||
export const FETCH_CHANGESET_FAILURE = `${FETCH_CHANGESET}_${FAILURE_SUFFIX}`;
|
|
||||||
|
|
||||||
/********/
|
|
||||||
|
|
||||||
const REPO_URL = "repositories";
|
|
||||||
|
|
||||||
/****added for detailed view of changesets****/
|
|
||||||
|
|
||||||
export function fetchChangesetIfNeeded(state: Object, namespace: string, repoName: string, id: string) {
|
|
||||||
return function(dispatch) {
|
|
||||||
if (shouldFetchChangeset(state, namespace, repoName, id)) {
|
|
||||||
dispatch(fetchChangeset(url));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function shouldFetchChangeset(state: Object, namespace: string, repoName: string, id: string) {
|
|
||||||
// decide if changeset should be fetched here
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fetchChangeset(namespace: string, repoName: string, id: string) {
|
|
||||||
return function(dispatch) {
|
|
||||||
dispatch(fetchChangesetPending(namespace, repoName, id));
|
|
||||||
return apiClient
|
|
||||||
.get(url)
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(json => dispatch(fetchChangesetSuccess(namespace, repoName, id)))
|
|
||||||
.catch(err => {
|
|
||||||
dispatch(fetchChangesetFailure(namespace, repoName, id, err));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchChangesetPending(
|
|
||||||
namespace: string, repoName: string, id: string
|
|
||||||
): Action {
|
|
||||||
return {
|
|
||||||
type: FETCH_CHANGESET_PENDING,
|
|
||||||
payload: {
|
|
||||||
namespace,
|
|
||||||
repoName,
|
|
||||||
id
|
|
||||||
},
|
|
||||||
itemId: createItemId(namespace, repoName) + "/" + id
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchChangesetSuccess(
|
|
||||||
namespace: string, repoName: string, id: string
|
|
||||||
): Action {
|
|
||||||
return {
|
|
||||||
type: FETCH_CHANGESET_SUCCESS,
|
|
||||||
payload: { namespace, repoName, id },
|
|
||||||
itemId: createItemId(namespace, repoName) + "/" + id
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function fetchChangesetFailure(
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
id: string,
|
|
||||||
error: Error
|
|
||||||
): Action {
|
|
||||||
return {
|
|
||||||
type: FETCH_CHANGESET_FAILURE,
|
|
||||||
payload: {
|
|
||||||
namespace,
|
|
||||||
name,
|
|
||||||
id,
|
|
||||||
error
|
|
||||||
},
|
|
||||||
itemId: createItemId(namespace, repoName) + "/" + id
|
|
||||||
};
|
|
||||||
|
|
||||||
/********/
|
|
||||||
|
|
||||||
// actions
|
|
||||||
export function fetchChangesetsByNamespaceAndName(
|
|
||||||
namespace: string,
|
|
||||||
name: string
|
|
||||||
) {
|
|
||||||
return function(dispatch: any) {
|
|
||||||
dispatch(fetchChangesetsPending(namespace, name));
|
|
||||||
return apiClient
|
|
||||||
.get(REPO_URL + "/" + namespace + "/" + name + "/changesets")
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
dispatch(fetchChangesetsSuccess(data, namespace, name));
|
|
||||||
})
|
|
||||||
.catch(cause => {
|
|
||||||
dispatch(fetchChangesetsFailure(namespace, name, cause));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchChangesetsByNamespaceNameAndBranch(
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
branch: string
|
|
||||||
) {
|
|
||||||
return function(dispatch: any) {
|
|
||||||
dispatch(fetchChangesetsPending(namespace, name, branch));
|
|
||||||
return apiClient
|
|
||||||
.get(
|
|
||||||
REPO_URL +
|
|
||||||
"/" +
|
|
||||||
namespace +
|
|
||||||
"/" +
|
|
||||||
name +
|
|
||||||
"/branches/" +
|
|
||||||
branch +
|
|
||||||
"/changesets"
|
|
||||||
)
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
dispatch(fetchChangesetsSuccess(data, namespace, name, branch));
|
|
||||||
})
|
|
||||||
.catch(cause => {
|
|
||||||
dispatch(fetchChangesetsFailure(namespace, name, branch, cause));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchChangesetsPending(
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
branch?: string
|
|
||||||
): Action {
|
|
||||||
return {
|
|
||||||
type: FETCH_CHANGESETS_PENDING,
|
|
||||||
payload: {
|
|
||||||
namespace,
|
|
||||||
name,
|
|
||||||
branch
|
|
||||||
},
|
|
||||||
itemId: createItemId(namespace, name, branch)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchChangesetsSuccess(
|
|
||||||
collection: any,
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
branch?: string
|
|
||||||
): Action {
|
|
||||||
return {
|
|
||||||
type: FETCH_CHANGESETS_SUCCESS,
|
|
||||||
payload: { collection, namespace, name, branch },
|
|
||||||
itemId: createItemId(namespace, name, branch)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function fetchChangesetsFailure(
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
branch?: string,
|
|
||||||
error: Error
|
|
||||||
): Action {
|
|
||||||
return {
|
|
||||||
type: FETCH_CHANGESETS_FAILURE,
|
|
||||||
payload: {
|
|
||||||
namespace,
|
|
||||||
name,
|
|
||||||
branch,
|
|
||||||
error
|
|
||||||
},
|
|
||||||
itemId: createItemId(namespace, name, branch)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function createItemId(
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
branch?: string
|
|
||||||
): string {
|
|
||||||
let itemId = namespace + "/" + name;
|
|
||||||
if (branch && branch !== "") {
|
|
||||||
itemId = itemId + "/" + branch;
|
|
||||||
}
|
|
||||||
return itemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
// reducer
|
|
||||||
export default function reducer(
|
|
||||||
state: any = {},
|
|
||||||
action: Action = { type: "UNKNOWN" }
|
|
||||||
): Object {
|
|
||||||
switch (action.type) {
|
|
||||||
case FETCH_CHANGESETS_SUCCESS:
|
|
||||||
const { namespace, name, branch } = action.payload;
|
|
||||||
const key = createItemId(namespace, name, branch);
|
|
||||||
let oldChangesets = { [key]: {} };
|
|
||||||
if (state[key] !== undefined) {
|
|
||||||
oldChangesets[key] = state[key];
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
[key]: {
|
|
||||||
byId: extractChangesetsByIds(
|
|
||||||
action.payload.collection,
|
|
||||||
oldChangesets[key].byId
|
|
||||||
)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractChangesetsByIds(data: any, oldChangesetsByIds: any) {
|
|
||||||
const changesets = data._embedded.changesets;
|
|
||||||
const changesetsByIds = {};
|
|
||||||
|
|
||||||
for (let changeset of changesets) {
|
|
||||||
changesetsByIds[changeset.id] = changeset;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let id in oldChangesetsByIds) {
|
|
||||||
changesetsByIds[id] = oldChangesetsByIds[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
return changesetsByIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
//selectors
|
|
||||||
export function getChangesetsForNamespaceAndNameFromState(
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
state: Object
|
|
||||||
) {
|
|
||||||
const key = createItemId(namespace, name);
|
|
||||||
if (!state.changesets[key]) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return Object.values(state.changesets[key].byId);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getChangesets(
|
|
||||||
state: Object,
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
branch: string
|
|
||||||
) {
|
|
||||||
const key = createItemId(namespace, name, branch);
|
|
||||||
if (!state.changesets[key]) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return Object.values(state.changesets[key].byId);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isFetchChangesetsPending(
|
|
||||||
state: Object,
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
branch?: string
|
|
||||||
) {
|
|
||||||
return isPending(
|
|
||||||
state,
|
|
||||||
FETCH_CHANGESETS,
|
|
||||||
createItemId(namespace, name, branch)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getFetchChangesetsFailure(
|
|
||||||
state: Object,
|
|
||||||
namespace: string,
|
|
||||||
name: string,
|
|
||||||
branch?: string
|
|
||||||
) {
|
|
||||||
return getFailure(
|
|
||||||
state,
|
|
||||||
FETCH_CHANGESETS,
|
|
||||||
createItemId(namespace, name, branch)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
//@flow
|
|
||||||
import type { Links } from "@scm-manager/ui-types";
|
|
||||||
|
|
||||||
export type Changeset = {
|
|
||||||
id: String,
|
|
||||||
author: {
|
|
||||||
mail: String,
|
|
||||||
name: String
|
|
||||||
},
|
|
||||||
date: String,
|
|
||||||
description: String,
|
|
||||||
_links: Links
|
|
||||||
};
|
|
||||||
@@ -92,7 +92,7 @@ class Changesets extends React.Component<State, Props> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <ChangesetList changesets={changesets} />;
|
return <ChangesetList repository={repository} changesets={changesets} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
renderPaginator() {
|
renderPaginator() {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
isFetchRepoPending
|
isFetchRepoPending
|
||||||
} from "../modules/repos";
|
} from "../modules/repos";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Route, Switch } from "react-router-dom";
|
import { Route } from "react-router-dom";
|
||||||
import type { Repository } from "@scm-manager/ui-types";
|
import type { Repository } from "@scm-manager/ui-types";
|
||||||
import {
|
import {
|
||||||
Page,
|
Page,
|
||||||
@@ -25,8 +25,8 @@ import Edit from "../containers/Edit";
|
|||||||
|
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import EditNavLink from "../components/EditNavLink";
|
import EditNavLink from "../components/EditNavLink";
|
||||||
import ChangesetView from "../changesets/containers/ChangesetView";
|
|
||||||
import Changesets from "./Changesets";
|
import Changesets from "./Changesets";
|
||||||
|
import ChangesetView from "./ChangesetView";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
namespace: string,
|
namespace: string,
|
||||||
@@ -104,15 +104,18 @@ class RepositoryRoot extends React.Component<Props> {
|
|||||||
component={() => <Edit repository={repository} />}
|
component={() => <Edit repository={repository} />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
|
exact
|
||||||
path={`${url}/history`}
|
path={`${url}/history`}
|
||||||
component={() => <Changesets repository={repository} />}
|
component={() => <Changesets repository={repository} />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
|
exact
|
||||||
path={`${url}/history/:branch`}
|
path={`${url}/history/:branch`}
|
||||||
component={() => <Changesets repository={repository} />}
|
component={() => <Changesets repository={repository} />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path={`${url}/changesets/:id`}
|
exact
|
||||||
|
path={`${url}/changeset/:id`}
|
||||||
component={() => <ChangesetView repository={repository} />}
|
component={() => <ChangesetView repository={repository} />}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -16,9 +16,104 @@ export const FETCH_CHANGESETS_PENDING = `${FETCH_CHANGESETS}_${PENDING_SUFFIX}`;
|
|||||||
export const FETCH_CHANGESETS_SUCCESS = `${FETCH_CHANGESETS}_${SUCCESS_SUFFIX}`;
|
export const FETCH_CHANGESETS_SUCCESS = `${FETCH_CHANGESETS}_${SUCCESS_SUFFIX}`;
|
||||||
export const FETCH_CHANGESETS_FAILURE = `${FETCH_CHANGESETS}_${FAILURE_SUFFIX}`;
|
export const FETCH_CHANGESETS_FAILURE = `${FETCH_CHANGESETS}_${FAILURE_SUFFIX}`;
|
||||||
|
|
||||||
|
//added for detailed view of changesets
|
||||||
|
|
||||||
|
export const FETCH_CHANGESET = "scm/repos/FETCH_CHANGESET";
|
||||||
|
export const FETCH_CHANGESET_PENDING = `${FETCH_CHANGESET}_${PENDING_SUFFIX}`;
|
||||||
|
export const FETCH_CHANGESET_SUCCESS = `${FETCH_CHANGESET}_${SUCCESS_SUFFIX}`;
|
||||||
|
export const FETCH_CHANGESET_FAILURE = `${FETCH_CHANGESET}_${FAILURE_SUFFIX}`;
|
||||||
|
|
||||||
|
// end of detailed view add
|
||||||
|
|
||||||
|
// actions
|
||||||
const REPO_URL = "repositories";
|
const REPO_URL = "repositories";
|
||||||
//TODO: Content type
|
//TODO: Content type
|
||||||
// actions
|
|
||||||
|
//added for detailed view of changesets
|
||||||
|
|
||||||
|
function fetchChangesetIfNeeded(
|
||||||
|
state: Object,
|
||||||
|
namespace: string,
|
||||||
|
repoName: string,
|
||||||
|
id: string
|
||||||
|
) {
|
||||||
|
return function(dispatch) {
|
||||||
|
if (shouldFetchChangeset(state, namespace, repoName, id)) {
|
||||||
|
dispatch(fetchChangeset(url));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function shouldFetchChangeset(
|
||||||
|
state: Object,
|
||||||
|
namespace: string,
|
||||||
|
repoName: string,
|
||||||
|
id: string
|
||||||
|
) {
|
||||||
|
// decide if changeset should be fetched here
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchChangeset(namespace: string, repoName: string, id: string) {
|
||||||
|
return function(dispatch) {
|
||||||
|
dispatch(fetchChangesetPending(namespace, repoName, id));
|
||||||
|
return apiClient
|
||||||
|
.get(url)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(json => dispatch(fetchChangesetSuccess(namespace, repoName, id)))
|
||||||
|
.catch(err => {
|
||||||
|
dispatch(fetchChangesetFailure(namespace, repoName, id, err));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchChangesetPending(
|
||||||
|
namespace: string,
|
||||||
|
repoName: string,
|
||||||
|
id: string
|
||||||
|
): Action {
|
||||||
|
return {
|
||||||
|
type: FETCH_CHANGESET_PENDING,
|
||||||
|
payload: {
|
||||||
|
namespace,
|
||||||
|
repoName,
|
||||||
|
id
|
||||||
|
},
|
||||||
|
itemId: createItemId(namespace, repoName) + "/" + id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchChangesetSuccess(
|
||||||
|
namespace: string,
|
||||||
|
repoName: string,
|
||||||
|
id: string
|
||||||
|
): Action {
|
||||||
|
return {
|
||||||
|
type: FETCH_CHANGESET_SUCCESS,
|
||||||
|
payload: { namespace, repoName, id },
|
||||||
|
itemId: createItemId(namespace, repoName) + "/" + id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchChangesetFailure(
|
||||||
|
namespace: string,
|
||||||
|
name: string,
|
||||||
|
id: string,
|
||||||
|
error: Error
|
||||||
|
): Action {
|
||||||
|
return {
|
||||||
|
type: FETCH_CHANGESET_FAILURE,
|
||||||
|
payload: {
|
||||||
|
namespace,
|
||||||
|
name,
|
||||||
|
id,
|
||||||
|
error
|
||||||
|
},
|
||||||
|
itemId: createItemId(namespace, repoName) + "/" + id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// end of detailed view add
|
||||||
|
|
||||||
export function fetchChangesetsWithOptions(
|
export function fetchChangesetsWithOptions(
|
||||||
namespace: string,
|
namespace: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user