mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
fetch changesets for selected branch // fetch changesets for default branch if trying to fetch changesets for specific revision
This commit is contained in:
@@ -15,16 +15,24 @@ const ButtonAddonsMarginRight = styled(ButtonAddons)`
|
||||
`;
|
||||
|
||||
type Props = {
|
||||
url: string;
|
||||
baseUrl: string;
|
||||
currentUrl: string;
|
||||
branches: Branch[];
|
||||
selectedBranch: string;
|
||||
};
|
||||
|
||||
const CodeViewSwitcher: FC<Props> = ({ url, branches }) => {
|
||||
const CodeViewSwitcher: FC<Props> = ({ baseUrl, currentUrl, branches, selectedBranch }) => {
|
||||
const [t] = useTranslation("repos");
|
||||
|
||||
const createDestinationUrl = (destination: string, suffix?: string) => {
|
||||
let splittedUrl = url.split("/");
|
||||
const createDestinationUrl = (destination: string, branch?: string, suffix?: string) => {
|
||||
if (!branches) {
|
||||
return baseUrl + "/" + destination + "/";
|
||||
}
|
||||
let splittedUrl = currentUrl.split("/");
|
||||
splittedUrl[5] = destination;
|
||||
if (branch) {
|
||||
splittedUrl[6] = branch;
|
||||
}
|
||||
splittedUrl.splice(7, splittedUrl.length);
|
||||
if (suffix) {
|
||||
splittedUrl.push(suffix);
|
||||
@@ -37,13 +45,27 @@ const CodeViewSwitcher: FC<Props> = ({ url, branches }) => {
|
||||
<SmallButton
|
||||
label={t("code.commits")}
|
||||
icon="fa fa-exchange-alt"
|
||||
color={url.includes("/code/branch") || url.includes("/code/changesets") ? "link is-selected" : undefined}
|
||||
link={branches ? createDestinationUrl("branch", "changesets/") : createDestinationUrl("changesets")}
|
||||
color={
|
||||
currentUrl.includes("/code/branch") || currentUrl.includes("/code/changesets")
|
||||
? "link is-selected"
|
||||
: undefined
|
||||
}
|
||||
link={
|
||||
branches
|
||||
? branches.filter(branch => branch.name === selectedBranch).length === 0
|
||||
? createDestinationUrl(
|
||||
"branch",
|
||||
branches.filter(branch => branch.defaultBranch === true)[0].name,
|
||||
"changesets/"
|
||||
)
|
||||
: createDestinationUrl("branch", selectedBranch, "changesets/")
|
||||
: createDestinationUrl("changesets")
|
||||
}
|
||||
/>
|
||||
<SmallButton
|
||||
label={t("code.sources")}
|
||||
icon="fa fa-code"
|
||||
color={url.includes("/code/sources") ? "link is-selected" : undefined}
|
||||
color={currentUrl.includes("/code/sources") ? "link is-selected" : undefined}
|
||||
link={createDestinationUrl("sources")}
|
||||
/>
|
||||
</ButtonAddonsMarginRight>
|
||||
|
||||
@@ -82,7 +82,7 @@ class CodeOverview extends React.Component<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { repository, baseUrl, branches, error, loading, t } = this.props;
|
||||
const { repository, baseUrl, branches, selectedBranch, error, loading, t } = this.props;
|
||||
const url = baseUrl;
|
||||
|
||||
if (loading) {
|
||||
@@ -103,11 +103,11 @@ class CodeOverview extends React.Component<Props> {
|
||||
<BranchSelector
|
||||
label={t("code.branchSelector")}
|
||||
branches={branches}
|
||||
selectedBranch={this.props.selectedBranch}
|
||||
selectedBranch={selectedBranch}
|
||||
onSelectBranch={this.branchSelected}
|
||||
/>
|
||||
}
|
||||
right={<CodeViewSwitcher url={this.props.location.pathname} branches={branches} />}
|
||||
right={<CodeViewSwitcher baseUrl={url} currentUrl={this.props.location.pathname} branches={branches} selectedBranch={selectedBranch}/>}
|
||||
/>
|
||||
</CodeActionBar>
|
||||
<Route
|
||||
@@ -125,7 +125,13 @@ class CodeOverview extends React.Component<Props> {
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/branch/:branch/changesets/`}
|
||||
render={() => <ChangesetsRoot repository={repository} baseUrl={`${url}/changesets`} />}
|
||||
render={() => (
|
||||
<ChangesetsRoot
|
||||
repository={repository}
|
||||
baseUrl={`${url}/changesets`}
|
||||
selectedBranch={branches && branches.filter(b => b.name === this.props.selectedBranch)[0]}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user