diff options
author | Wouter Admiraal <wouter.admiraal@sonarsource.com> | 2020-06-15 15:20:46 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-06-19 20:04:42 +0000 |
commit | 72a34678a0da474c17e1d375a7e9f8699f9433ce (patch) | |
tree | c3d59cf9f73a2a105e22a36501f15792a555e707 /server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx | |
parent | 12818cc0a81f8c5843534966aceb71725b7506c5 (diff) | |
download | sonarqube-72a34678a0da474c17e1d375a7e9f8699f9433ce.tar.gz sonarqube-72a34678a0da474c17e1d375a7e9f8699f9433ce.zip |
SONAR-13114 Click on the Homepage button reverts back to the default homepage
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.tsx | 23 |
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> |