mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
created repo specific xhangeset and sourceslink
This commit is contained in:
@@ -3,6 +3,7 @@ import React from "react";
|
||||
import type { Repository, Branch } from "@scm-manager/ui-types";
|
||||
import { ButtonGroup, Button } from "@scm-manager/ui-components";
|
||||
import { translate } from "react-i18next";
|
||||
import { createChangesetLink, createSourcesLink } from "../../modules/branches";
|
||||
|
||||
type Props = {
|
||||
repository: Repository,
|
||||
@@ -16,8 +17,8 @@ class BranchButtonGroup extends React.Component<Props> {
|
||||
render() {
|
||||
const { repository, branch, t } = this.props;
|
||||
|
||||
const changesetLink = "";
|
||||
const sourcesLink = "";
|
||||
const changesetLink = createChangesetLink(repository, branch);
|
||||
const sourcesLink = createSourcesLink(repository, branch);
|
||||
|
||||
return (
|
||||
<ButtonGroup>
|
||||
|
||||
@@ -5,7 +5,12 @@ import {
|
||||
SUCCESS_SUFFIX
|
||||
} from "../../modules/types";
|
||||
import { apiClient } from "@scm-manager/ui-components";
|
||||
import type { Action, Branch, Repository } from "@scm-manager/ui-types";
|
||||
import type {
|
||||
Action,
|
||||
Branch,
|
||||
Changeset,
|
||||
Repository
|
||||
} from "@scm-manager/ui-types";
|
||||
import { isPending } from "../../modules/pending";
|
||||
import { getFailure } from "../../modules/failure";
|
||||
|
||||
@@ -22,7 +27,9 @@ export const FETCH_BRANCH_FAILURE = `${FETCH_BRANCH}_${FAILURE_SUFFIX}`;
|
||||
// Fetching branches
|
||||
|
||||
export function fetchBranchByName(link: string, name: string) {
|
||||
const branchUrl = link.endsWith("/") ? link + encodeURIComponent(name) : link + "/" + encodeURIComponent(name);
|
||||
const branchUrl = link.endsWith("/")
|
||||
? link + encodeURIComponent(name)
|
||||
: link + "/" + encodeURIComponent(name);
|
||||
return fetchBranch(branchUrl, name);
|
||||
}
|
||||
|
||||
@@ -203,3 +210,15 @@ function createKey(repository: Repository): string {
|
||||
const { namespace, name } = repository;
|
||||
return `${namespace}/${name}`;
|
||||
}
|
||||
|
||||
export function createChangesetLink(repository: Repository, branch: Branch) {
|
||||
return `/repo/${repository.namespace}/${
|
||||
repository.name
|
||||
}/branch/${encodeURIComponent(branch.name)}/changesets/`;
|
||||
}
|
||||
|
||||
export function createSourcesLink(repository: Repository, branch: Branch) {
|
||||
return `/repo/${repository.namespace}/${
|
||||
repository.name
|
||||
}/sources/${encodeURIComponent(branch.name)}/`;
|
||||
}
|
||||
|
||||
@@ -161,11 +161,6 @@ describe("branches", () => {
|
||||
const newState = reducer({}, fetchBranchSuccess(branch3));
|
||||
expect(newState["branch3"]).toBe(branch3);
|
||||
});
|
||||
|
||||
it("should update state according to FETCH_BRANCH_SUCCESS action", () => {
|
||||
const newState = reducer({}, fetchBranch(URL + "/branch1", "branch1"));
|
||||
expect(newState["branch1"]).toBe(branch1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("branch selectors", () => {
|
||||
|
||||
Reference in New Issue
Block a user