mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 02:31:14 +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 = {
|
type Props = {
|
||||||
url: string;
|
baseUrl: string;
|
||||||
|
currentUrl: string;
|
||||||
branches: Branch[];
|
branches: Branch[];
|
||||||
|
selectedBranch: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const CodeViewSwitcher: FC<Props> = ({ url, branches }) => {
|
const CodeViewSwitcher: FC<Props> = ({ baseUrl, currentUrl, branches, selectedBranch }) => {
|
||||||
const [t] = useTranslation("repos");
|
const [t] = useTranslation("repos");
|
||||||
|
|
||||||
const createDestinationUrl = (destination: string, suffix?: string) => {
|
const createDestinationUrl = (destination: string, branch?: string, suffix?: string) => {
|
||||||
let splittedUrl = url.split("/");
|
if (!branches) {
|
||||||
|
return baseUrl + "/" + destination + "/";
|
||||||
|
}
|
||||||
|
let splittedUrl = currentUrl.split("/");
|
||||||
splittedUrl[5] = destination;
|
splittedUrl[5] = destination;
|
||||||
|
if (branch) {
|
||||||
|
splittedUrl[6] = branch;
|
||||||
|
}
|
||||||
splittedUrl.splice(7, splittedUrl.length);
|
splittedUrl.splice(7, splittedUrl.length);
|
||||||
if (suffix) {
|
if (suffix) {
|
||||||
splittedUrl.push(suffix);
|
splittedUrl.push(suffix);
|
||||||
@@ -37,13 +45,27 @@ const CodeViewSwitcher: FC<Props> = ({ url, branches }) => {
|
|||||||
<SmallButton
|
<SmallButton
|
||||||
label={t("code.commits")}
|
label={t("code.commits")}
|
||||||
icon="fa fa-exchange-alt"
|
icon="fa fa-exchange-alt"
|
||||||
color={url.includes("/code/branch") || url.includes("/code/changesets") ? "link is-selected" : undefined}
|
color={
|
||||||
link={branches ? createDestinationUrl("branch", "changesets/") : createDestinationUrl("changesets")}
|
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
|
<SmallButton
|
||||||
label={t("code.sources")}
|
label={t("code.sources")}
|
||||||
icon="fa fa-code"
|
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")}
|
link={createDestinationUrl("sources")}
|
||||||
/>
|
/>
|
||||||
</ButtonAddonsMarginRight>
|
</ButtonAddonsMarginRight>
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class CodeOverview extends React.Component<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { repository, baseUrl, branches, error, loading, t } = this.props;
|
const { repository, baseUrl, branches, selectedBranch, error, loading, t } = this.props;
|
||||||
const url = baseUrl;
|
const url = baseUrl;
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
@@ -103,11 +103,11 @@ class CodeOverview extends React.Component<Props> {
|
|||||||
<BranchSelector
|
<BranchSelector
|
||||||
label={t("code.branchSelector")}
|
label={t("code.branchSelector")}
|
||||||
branches={branches}
|
branches={branches}
|
||||||
selectedBranch={this.props.selectedBranch}
|
selectedBranch={selectedBranch}
|
||||||
onSelectBranch={this.branchSelected}
|
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>
|
</CodeActionBar>
|
||||||
<Route
|
<Route
|
||||||
@@ -125,7 +125,13 @@ class CodeOverview extends React.Component<Props> {
|
|||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path={`${url}/branch/:branch/changesets/`}
|
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>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user