aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/app
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2018-02-15 17:20:18 +0100
committerStas Vilchik <stas.vilchik@sonarsource.com>2018-03-02 13:17:32 +0100
commitf9b743b8b4c974d5c08829c98e7dc5c52f52eed1 (patch)
tree94f4276c0bfb7cdb572a63c83f5df5a45789e6c4 /server/sonar-web/src/main/js/app
parenta6e5fdbdaabb92324857dd5c452d8f9b4ffff85b (diff)
downloadsonarqube-f9b743b8b4c974d5c08829c98e7dc5c52f52eed1.tar.gz
sonarqube-f9b743b8b4c974d5c08829c98e7dc5c52f52eed1.zip
SONAR-10423 display home page selector (#3065)
Diffstat (limited to 'server/sonar-web/src/main/js/app')
-rw-r--r--server/sonar-web/src/main/js/app/components/Landing.tsx2
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx43
-rw-r--r--server/sonar-web/src/main/js/app/types.ts32
3 files changed, 56 insertions, 21 deletions
diff --git a/server/sonar-web/src/main/js/app/components/Landing.tsx b/server/sonar-web/src/main/js/app/components/Landing.tsx
index ed401366a98..bf257783c72 100644
--- a/server/sonar-web/src/main/js/app/components/Landing.tsx
+++ b/server/sonar-web/src/main/js/app/components/Landing.tsx
@@ -37,7 +37,7 @@ class Landing extends React.PureComponent<Props> {
componentDidMount() {
const { currentUser, onSonarCloud } = this.props;
if (isLoggedIn(currentUser)) {
- if (onSonarCloud && currentUser.homepage) {
+ if (currentUser.homepage) {
const homepage = getHomePageUrl(currentUser.homepage);
this.context.router.replace(homepage);
} else {
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx
index 42ab6e09378..9bee1a224fe 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx
@@ -19,13 +19,17 @@
*/
import * as React from 'react';
import { connect } from 'react-redux';
-import { Branch, Component, CurrentUser, isLoggedIn, HomePageType } from '../../../types';
+import { Branch, Component, CurrentUser, isLoggedIn, HomePageType, HomePage } from '../../../types';
import BranchStatus from '../../../../components/common/BranchStatus';
import DateTimeFormatter from '../../../../components/intl/DateTimeFormatter';
import Favorite from '../../../../components/controls/Favorite';
import HomePageSelect from '../../../../components/controls/HomePageSelect';
import Tooltip from '../../../../components/controls/Tooltip';
-import { isShortLivingBranch } from '../../../../helpers/branches';
+import {
+ isShortLivingBranch,
+ isLongLivingBranch,
+ getBranchName
+} from '../../../../helpers/branches';
import { translate } from '../../../../helpers/l10n';
import { getCurrentUser } from '../../../../store/rootReducer';
@@ -41,6 +45,20 @@ interface Props extends StateProps {
export function ComponentNavMeta({ branch, component, currentUser }: Props) {
const shortBranch = isShortLivingBranch(branch);
const mainBranch = !branch || branch.isMain;
+ const longBranch = isLongLivingBranch(branch);
+
+ let currentPage: HomePage | undefined;
+ if (component.qualifier === 'VW' || component.qualifier === 'SVW') {
+ currentPage = { type: HomePageType.Portfolio, component: component.key };
+ } else if (component.qualifier === 'APP') {
+ currentPage = { type: HomePageType.Application, component: component.key };
+ } else if (component.qualifier === 'TRK') {
+ currentPage = {
+ type: HomePageType.Project,
+ component: component.key,
+ branch: getBranchName(branch)
+ };
+ }
return (
<div className="navbar-context-meta">
@@ -51,26 +69,27 @@ export function ComponentNavMeta({ branch, component, currentUser }: Props) {
)}
{component.version &&
!shortBranch && (
- <Tooltip overlay={`${translate('version')} ${component.version}`} mouseEnterDelay={0.5}>
+ <Tooltip mouseEnterDelay={0.5} overlay={`${translate('version')} ${component.version}`}>
<div className="spacer-left text-limited">
{translate('version')} {component.version}
</div>
</Tooltip>
)}
- {isLoggedIn(currentUser) &&
- mainBranch && (
- <div className="navbar-context-meta-secondary">
+ {isLoggedIn(currentUser) && (
+ <div className="navbar-context-meta-secondary">
+ {mainBranch && (
<Favorite
component={component.key}
favorite={Boolean(component.isFavorite)}
qualifier={component.qualifier}
/>
- <HomePageSelect
- className="spacer-left"
- currentPage={{ type: HomePageType.Project, parameter: component.key }}
- />
- </div>
- )}
+ )}
+ {(mainBranch || longBranch) &&
+ currentPage !== undefined && (
+ <HomePageSelect className="spacer-left" currentPage={currentPage} />
+ )}
+ </div>
+ )}
{shortBranch && (
<div className="navbar-context-meta-secondary">
<BranchStatus branch={branch!} />
diff --git a/server/sonar-web/src/main/js/app/types.ts b/server/sonar-web/src/main/js/app/types.ts
index c2fe0d91b1c..252f6c135a2 100644
--- a/server/sonar-web/src/main/js/app/types.ts
+++ b/server/sonar-web/src/main/js/app/types.ts
@@ -130,16 +130,27 @@ export interface Group {
name: string;
}
-export interface HomePage {
- parameter?: string;
- type: HomePageType;
-}
+export type HomePage =
+ | { type: HomePageType.Application; component: string }
+ | { type: HomePageType.Issues }
+ | { type: HomePageType.MyIssues }
+ | { type: HomePageType.MyProjects }
+ | { type: HomePageType.Organization; organization: string }
+ | { type: HomePageType.Portfolio; component: string }
+ | { type: HomePageType.Portfolios }
+ | { type: HomePageType.Project; branch: string | undefined; component: string }
+ | { type: HomePageType.Projects };
export enum HomePageType {
- Project = 'PROJECT',
- Organization = 'ORGANIZATION',
+ Application = 'APPLICATION',
+ Issues = 'ISSUES',
+ MyIssues = 'MY_ISSUES',
MyProjects = 'MY_PROJECTS',
- MyIssues = 'MY_ISSUES'
+ Organization = 'ORGANIZATION',
+ Portfolio = 'PORTFOLIO',
+ Portfolios = 'PORTFOLIOS',
+ Project = 'PROJECT',
+ Projects = 'PROJECTS'
}
export interface IdentityProvider {
@@ -155,7 +166,12 @@ export function isLoggedIn(user: CurrentUser): user is LoggedInUser {
}
export function isSameHomePage(a: HomePage, b: HomePage) {
- return a.type === b.type && a.parameter === b.parameter;
+ return (
+ a.type === b.type &&
+ (a as any).branch === (b as any).branch &&
+ (a as any).component === (b as any).component &&
+ (a as any).organization === (b as any).organization
+ );
}
export interface LightComponent {