mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 06:55:47 +01:00
Add tooltip to shortlinks on repository overview
This commit is contained in:
@@ -27,10 +27,11 @@ import { CardColumn, DateFromNow } from "@scm-manager/ui-components";
|
|||||||
import RepositoryEntryLink from "./RepositoryEntryLink";
|
import RepositoryEntryLink from "./RepositoryEntryLink";
|
||||||
import RepositoryAvatar from "./RepositoryAvatar";
|
import RepositoryAvatar from "./RepositoryAvatar";
|
||||||
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
import { ExtensionPoint } from "@scm-manager/ui-extensions";
|
||||||
|
import { withTranslation, WithTranslation } from "react-i18next";
|
||||||
|
|
||||||
type DateProp = Date | string;
|
type DateProp = Date | string;
|
||||||
|
|
||||||
type Props = {
|
type Props = WithTranslation & {
|
||||||
repository: Repository;
|
repository: Repository;
|
||||||
// @VisibleForTesting
|
// @VisibleForTesting
|
||||||
// the baseDate is only to avoid failing snapshot tests
|
// the baseDate is only to avoid failing snapshot tests
|
||||||
@@ -43,29 +44,67 @@ class RepositoryEntry extends React.Component<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
renderBranchesLink = (repository: Repository, repositoryLink: string) => {
|
renderBranchesLink = (repository: Repository, repositoryLink: string) => {
|
||||||
|
const { t } = this.props;
|
||||||
if (repository._links["branches"]) {
|
if (repository._links["branches"]) {
|
||||||
return <RepositoryEntryLink icon="code-branch" to={repositoryLink + "/branches/"} />;
|
return (
|
||||||
|
<RepositoryEntryLink
|
||||||
|
icon="code-branch"
|
||||||
|
to={repositoryLink + "/branches/"}
|
||||||
|
tooltip={t("repositoryRoot.tooltip.branches")}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
renderTagsLink = (repository: Repository, repositoryLink: string) => {
|
||||||
|
const { t } = this.props;
|
||||||
|
if (repository._links["tags"]) {
|
||||||
|
return (
|
||||||
|
<RepositoryEntryLink icon="tags" to={repositoryLink + "/tags/"} tooltip={t("repositoryRoot.tooltip.tags")} />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
renderChangesetsLink = (repository: Repository, repositoryLink: string) => {
|
renderChangesetsLink = (repository: Repository, repositoryLink: string) => {
|
||||||
|
const { t } = this.props;
|
||||||
if (repository._links["changesets"]) {
|
if (repository._links["changesets"]) {
|
||||||
return <RepositoryEntryLink icon="exchange-alt" to={repositoryLink + "/code/changesets/"} />;
|
return (
|
||||||
|
<RepositoryEntryLink
|
||||||
|
icon="exchange-alt"
|
||||||
|
to={repositoryLink + "/code/changesets/"}
|
||||||
|
tooltip={t("repositoryRoot.tooltip.commits")}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
renderSourcesLink = (repository: Repository, repositoryLink: string) => {
|
renderSourcesLink = (repository: Repository, repositoryLink: string) => {
|
||||||
|
const { t } = this.props;
|
||||||
if (repository._links["sources"]) {
|
if (repository._links["sources"]) {
|
||||||
return <RepositoryEntryLink icon="code" to={repositoryLink + "/code/sources/"} />;
|
return (
|
||||||
|
<RepositoryEntryLink
|
||||||
|
icon="code"
|
||||||
|
to={repositoryLink + "/code/sources/"}
|
||||||
|
tooltip={t("repositoryRoot.tooltip.sources")}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
renderModifyLink = (repository: Repository, repositoryLink: string) => {
|
renderModifyLink = (repository: Repository, repositoryLink: string) => {
|
||||||
|
const { t } = this.props;
|
||||||
if (repository._links["update"]) {
|
if (repository._links["update"]) {
|
||||||
return <RepositoryEntryLink icon="cog" to={repositoryLink + "/settings/general"} />;
|
return (
|
||||||
|
<RepositoryEntryLink
|
||||||
|
icon="cog"
|
||||||
|
to={repositoryLink + "/settings/general"}
|
||||||
|
tooltip={t("repositoryRoot.tooltip.settings")}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
@@ -74,6 +113,7 @@ class RepositoryEntry extends React.Component<Props> {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{this.renderBranchesLink(repository, repositoryLink)}
|
{this.renderBranchesLink(repository, repositoryLink)}
|
||||||
|
{this.renderTagsLink(repository, repositoryLink)}
|
||||||
{this.renderChangesetsLink(repository, repositoryLink)}
|
{this.renderChangesetsLink(repository, repositoryLink)}
|
||||||
{this.renderSourcesLink(repository, repositoryLink)}
|
{this.renderSourcesLink(repository, repositoryLink)}
|
||||||
<ExtensionPoint name={"repository.card.quickLink"} props={{ repository, repositoryLink }} renderAll={true} />
|
<ExtensionPoint name={"repository.card.quickLink"} props={{ repository, repositoryLink }} renderAll={true} />
|
||||||
@@ -118,4 +158,4 @@ class RepositoryEntry extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RepositoryEntry;
|
export default withTranslation("repos")(RepositoryEntry);
|
||||||
|
|||||||
@@ -25,10 +25,12 @@ import React from "react";
|
|||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { Icon } from "@scm-manager/ui-components";
|
import { Icon } from "@scm-manager/ui-components";
|
||||||
|
import Tooltip from "../Tooltip";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
to: string;
|
to: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
|
tooltip?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const PointerEventsLink = styled(Link)`
|
const PointerEventsLink = styled(Link)`
|
||||||
@@ -37,10 +39,20 @@ const PointerEventsLink = styled(Link)`
|
|||||||
|
|
||||||
class RepositoryEntryLink extends React.Component<Props> {
|
class RepositoryEntryLink extends React.Component<Props> {
|
||||||
render() {
|
render() {
|
||||||
const { to, icon } = this.props;
|
const { to, icon, tooltip } = this.props;
|
||||||
|
|
||||||
|
let content = <Icon className="fa-lg" name={icon} color="inherit" />;
|
||||||
|
if (tooltip) {
|
||||||
|
content = (
|
||||||
|
<Tooltip message={tooltip} location="top">
|
||||||
|
{content}
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PointerEventsLink className="level-item" to={to}>
|
<PointerEventsLink className="level-item" to={to}>
|
||||||
<Icon className="fa-lg" name={icon} color="inherit" />
|
{content}
|
||||||
</PointerEventsLink>
|
</PointerEventsLink>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,13 @@
|
|||||||
"settingsNavLink": "Einstellungen",
|
"settingsNavLink": "Einstellungen",
|
||||||
"generalNavLink": "Generell",
|
"generalNavLink": "Generell",
|
||||||
"permissionsNavLink": "Berechtigungen"
|
"permissionsNavLink": "Berechtigungen"
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"branches": "Branches",
|
||||||
|
"tags": "Tags",
|
||||||
|
"commits": "Commits",
|
||||||
|
"sources": "Sources",
|
||||||
|
"settings": "Einstellungen"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"overview": {
|
"overview": {
|
||||||
|
|||||||
@@ -36,6 +36,13 @@
|
|||||||
"settingsNavLink": "Settings",
|
"settingsNavLink": "Settings",
|
||||||
"generalNavLink": "General",
|
"generalNavLink": "General",
|
||||||
"permissionsNavLink": "Permissions"
|
"permissionsNavLink": "Permissions"
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"branches": "Branches",
|
||||||
|
"tags": "Tags",
|
||||||
|
"commits": "Commits",
|
||||||
|
"sources": "Sources",
|
||||||
|
"settings": "Settings"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"overview": {
|
"overview": {
|
||||||
|
|||||||
Reference in New Issue
Block a user