aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx')
-rw-r--r--server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx23
1 files changed, 16 insertions, 7 deletions
diff --git a/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx b/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx
index 8eebe3fe573..ca7cc933a6e 100644
--- a/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx
+++ b/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx
@@ -41,11 +41,17 @@ interface Props extends StateProps, DispatchProps {
currentPage: T.HomePage;
}
-class HomePageSelect extends React.PureComponent<Props> {
+export const DEFAULT_HOMEPAGE: T.HomePage = { type: 'PROJECTS' };
+
+export class HomePageSelect extends React.PureComponent<Props> {
handleClick = () => {
this.props.setHomePage(this.props.currentPage);
};
+ handleReset = () => {
+ this.props.setHomePage(DEFAULT_HOMEPAGE);
+ };
+
render() {
const { currentPage, currentUser } = this.props;
@@ -54,23 +60,26 @@ class HomePageSelect extends React.PureComponent<Props> {
}
const { homepage } = currentUser;
- const checked = homepage !== undefined && isSameHomePage(homepage, currentPage);
- const tooltip = checked ? translate('homepage.current') : translate('homepage.check');
+ const isChecked = homepage !== undefined && isSameHomePage(homepage, currentPage);
+ const isDefault = isChecked && isSameHomePage(currentPage, DEFAULT_HOMEPAGE);
+ const tooltip = isChecked
+ ? translate(isDefault ? 'homepage.current.is_default' : 'homepage.current')
+ : translate('homepage.check');
return (
<Tooltip overlay={tooltip}>
- {checked ? (
+ {isDefault ? (
<span
aria-label={tooltip}
className={classNames('display-inline-block', this.props.className)}>
- <HomeIcon filled={checked} />
+ <HomeIcon filled={isChecked} />
</span>
) : (
<ButtonLink
aria-label={tooltip}
className={classNames('link-no-underline', 'set-homepage-link', this.props.className)}
- onClick={this.handleClick}>
- <HomeIcon filled={checked} />
+ onClick={isChecked ? this.handleReset : this.handleClick}>
+ <HomeIcon filled={isChecked} />
</ButtonLink>
)}
</Tooltip>