@@ -19,12 +19,13 @@ | |||
*/ | |||
import { getJSON, post } from 'sonar-ui-common/helpers/request'; | |||
import throwGlobalError from '../app/utils/throwGlobalError'; | |||
import { Branch, PullRequest } from '../types/branch-like'; | |||
export function getBranches(project: string): Promise<T.Branch[]> { | |||
export function getBranches(project: string): Promise<Branch[]> { | |||
return getJSON('/api/project_branches/list', { project }).then(r => r.branches, throwGlobalError); | |||
} | |||
export function getPullRequests(project: string): Promise<T.PullRequest[]> { | |||
export function getPullRequests(project: string): Promise<PullRequest[]> { | |||
return getJSON('/api/project_pull_requests/list', { project }).then( | |||
r => r.pullRequests, | |||
throwGlobalError |
@@ -19,6 +19,7 @@ | |||
*/ | |||
import { getJSON, post, postJSON, RequestData } from 'sonar-ui-common/helpers/request'; | |||
import throwGlobalError from '../app/utils/throwGlobalError'; | |||
import { BranchParameters } from '../types/branch-like'; | |||
export interface BaseSearchProjectsParameters { | |||
analyzedBefore?: string; | |||
@@ -121,7 +122,7 @@ export function getComponentLeaves( | |||
} | |||
export function getComponent( | |||
data: { component: string; metricKeys: string } & T.BranchParameters | |||
data: { component: string; metricKeys: string } & BranchParameters | |||
): Promise<{ component: T.ComponentMeasure }> { | |||
return getJSON('/api/measures/component', data); | |||
} | |||
@@ -148,7 +149,7 @@ type GetTreeParams = { | |||
q?: string; | |||
s?: string; | |||
strategy?: 'all' | 'leaves' | 'children'; | |||
} & T.BranchParameters; | |||
} & BranchParameters; | |||
export function getTree<T = TreeComponent>( | |||
data: GetTreeParams & { qualifiers?: string } | |||
@@ -164,17 +165,17 @@ export function getDirectories(data: GetTreeParams) { | |||
return getTree<TreeComponentWithPath>({ ...data, qualifiers: 'DIR' }); | |||
} | |||
export function getComponentData(data: { component: string } & T.BranchParameters): Promise<any> { | |||
export function getComponentData(data: { component: string } & BranchParameters): Promise<any> { | |||
return getJSON('/api/components/show', data); | |||
} | |||
export function doesComponentExists( | |||
data: { component: string } & T.BranchParameters | |||
data: { component: string } & BranchParameters | |||
): Promise<boolean> { | |||
return getComponentData(data).then(({ component }) => component !== undefined, () => false); | |||
} | |||
export function getComponentShow(data: { component: string } & T.BranchParameters): Promise<any> { | |||
export function getComponentShow(data: { component: string } & BranchParameters): Promise<any> { | |||
return getComponentData(data).catch(throwGlobalError); | |||
} | |||
@@ -182,7 +183,7 @@ export function getParents(component: string): Promise<any> { | |||
return getComponentShow({ component }).then(r => r.ancestors); | |||
} | |||
export function getBreadcrumbs(data: { component: string } & T.BranchParameters): Promise<any> { | |||
export function getBreadcrumbs(data: { component: string } & BranchParameters): Promise<any> { | |||
return getComponentShow(data).then(r => { | |||
const reversedAncestors = [...r.ancestors].reverse(); | |||
return [...reversedAncestors, r.component]; | |||
@@ -275,25 +276,25 @@ export function getSuggestions( | |||
} | |||
export function getComponentForSourceViewer( | |||
data: { component: string } & T.BranchParameters | |||
data: { component: string } & BranchParameters | |||
): Promise<T.SourceViewerFile> { | |||
return getJSON('/api/components/app', data); | |||
} | |||
export function getSources( | |||
data: { key: string; from?: number; to?: number } & T.BranchParameters | |||
data: { key: string; from?: number; to?: number } & BranchParameters | |||
): Promise<T.SourceLine[]> { | |||
return getJSON('/api/sources/lines', data).then(r => r.sources); | |||
} | |||
export function getDuplications( | |||
data: { key: string } & T.BranchParameters | |||
data: { key: string } & BranchParameters | |||
): Promise<{ duplications: T.Duplication[]; files: T.Dict<T.DuplicatedFile> }> { | |||
return getJSON('/api/duplications/show', data).catch(throwGlobalError); | |||
} | |||
export function getTests( | |||
data: { sourceFileKey: string; sourceFileLineNumber: number | string } & T.BranchParameters | |||
data: { sourceFileKey: string; sourceFileLineNumber: number | string } & BranchParameters | |||
): Promise<any> { | |||
return getJSON('/api/tests/list', data).then(r => r.tests); | |||
} |
@@ -19,9 +19,10 @@ | |||
*/ | |||
import { getJSON, post, postJSON, RequestData } from 'sonar-ui-common/helpers/request'; | |||
import throwGlobalError from '../app/utils/throwGlobalError'; | |||
import { BranchParameters } from '../types/branch-like'; | |||
export function getMeasures( | |||
data: { component: string; metricKeys: string } & T.BranchParameters | |||
data: { component: string; metricKeys: string } & BranchParameters | |||
): Promise<T.Measure[]> { | |||
return getJSON('/api/measures/component', data).then(r => r.component.measures, throwGlobalError); | |||
} |
@@ -19,6 +19,7 @@ | |||
*/ | |||
import { getJSON } from 'sonar-ui-common/helpers/request'; | |||
import throwGlobalError from '../app/utils/throwGlobalError'; | |||
import { BranchParameters } from '../types/branch-like'; | |||
export function getGlobalNavigation(): Promise<T.AppState> { | |||
return getJSON('/api/navigation/global'); | |||
@@ -27,7 +28,7 @@ export function getGlobalNavigation(): Promise<T.AppState> { | |||
type NavComponent = T.Omit<T.Component, 'alm' | 'qualifier' | 'leakPeriodDate' | 'path' | 'tags'>; | |||
export function getComponentNavigation( | |||
data: { component: string } & T.BranchParameters | |||
data: { component: string } & BranchParameters | |||
): Promise<NavComponent> { | |||
return getJSON('/api/navigation/component', data).catch(throwGlobalError); | |||
} |
@@ -19,6 +19,7 @@ | |||
*/ | |||
import { getJSON, post, postJSON, RequestData } from 'sonar-ui-common/helpers/request'; | |||
import throwGlobalError from '../app/utils/throwGlobalError'; | |||
import { BranchParameters } from '../types/branch-like'; | |||
export function getProjectActivity( | |||
data: { | |||
@@ -27,7 +28,7 @@ export function getProjectActivity( | |||
from?: string; | |||
p?: number; | |||
ps?: number; | |||
} & T.BranchParameters | |||
} & BranchParameters | |||
): Promise<{ analyses: T.Analysis[]; paging: T.Paging }> { | |||
return getJSON('/api/project_analyses/search', data).catch(throwGlobalError); | |||
} |
@@ -19,6 +19,7 @@ | |||
*/ | |||
import { getJSON, post, postJSON } from 'sonar-ui-common/helpers/request'; | |||
import throwGlobalError from '../app/utils/throwGlobalError'; | |||
import { BranchParameters } from '../types/branch-like'; | |||
export function fetchQualityGates(data: { | |||
organization?: string; | |||
@@ -174,7 +175,7 @@ export function getQualityGateProjectStatus( | |||
data: { | |||
projectKey?: string; | |||
projectId?: string; | |||
} & T.BranchParameters | |||
} & BranchParameters | |||
): Promise<T.QualityGateProjectStatus> { | |||
return getJSON('/api/qualitygates/project_status', data) | |||
.then(r => r.projectStatus) |
@@ -21,6 +21,7 @@ import { omitBy } from 'lodash'; | |||
import { getJSON, post, postJSON, RequestData } from 'sonar-ui-common/helpers/request'; | |||
import throwGlobalError from '../app/utils/throwGlobalError'; | |||
import { isCategoryDefinition } from '../apps/settings/utils'; | |||
import { BranchParameters } from '../types/branch-like'; | |||
export function getDefinitions(component?: string): Promise<T.SettingCategoryDefinition[]> { | |||
return getJSON('/api/settings/list_definitions', { component }).then( | |||
@@ -30,7 +31,7 @@ export function getDefinitions(component?: string): Promise<T.SettingCategoryDef | |||
} | |||
export function getValues( | |||
data: { keys: string; component?: string } & T.BranchParameters | |||
data: { keys: string; component?: string } & BranchParameters | |||
): Promise<T.SettingValue[]> { | |||
return getJSON('/api/settings/values', data).then(r => r.settings); | |||
} | |||
@@ -57,13 +58,13 @@ export function setSettingValue( | |||
} | |||
export function setSimpleSettingValue( | |||
data: { component?: string; value: string; key: string } & T.BranchParameters | |||
data: { component?: string; value: string; key: string } & BranchParameters | |||
): Promise<void | Response> { | |||
return post('/api/settings/set', data).catch(throwGlobalError); | |||
} | |||
export function resetSettingValue( | |||
data: { keys: string; component?: string } & T.BranchParameters | |||
data: { keys: string; component?: string } & BranchParameters | |||
): Promise<void> { | |||
return post('/api/settings/reset', data); | |||
} |
@@ -19,6 +19,7 @@ | |||
*/ | |||
import { getJSON } from 'sonar-ui-common/helpers/request'; | |||
import throwGlobalError from '../app/utils/throwGlobalError'; | |||
import { BranchParameters } from '../types/branch-like'; | |||
interface TimeMachineResponse { | |||
measures: { | |||
@@ -36,7 +37,7 @@ export function getTimeMachineData( | |||
p?: number; | |||
ps?: number; | |||
to?: string; | |||
} & T.BranchParameters | |||
} & BranchParameters | |||
): Promise<TimeMachineResponse> { | |||
return getJSON('/api/measures/search_history', data).catch(throwGlobalError); | |||
} | |||
@@ -48,7 +49,7 @@ export function getAllTimeMachineData( | |||
from?: string; | |||
p?: number; | |||
to?: string; | |||
} & T.BranchParameters, | |||
} & BranchParameters, | |||
prev?: TimeMachineResponse | |||
): Promise<TimeMachineResponse> { | |||
return getTimeMachineData({ ...data, ps: 1000 }).then(r => { |
@@ -29,17 +29,16 @@ import { Location, Router, withRouter } from '../../components/hoc/withRouter'; | |||
import { | |||
getBranchLikeQuery, | |||
isBranch, | |||
isLongLivingBranch, | |||
isMainBranch, | |||
isPullRequest, | |||
isShortLivingBranch | |||
} from '../../helpers/branches'; | |||
isPullRequest | |||
} from '../../helpers/branch-like'; | |||
import { isSonarCloud } from '../../helpers/system'; | |||
import { | |||
fetchOrganization, | |||
registerBranchStatus, | |||
requireAuthorization | |||
} from '../../store/rootActions'; | |||
import { BranchLike } from '../../types/branch-like'; | |||
import ComponentContainerNotFound from './ComponentContainerNotFound'; | |||
import { ComponentContext } from './ComponentContext'; | |||
import ComponentNav from './nav/component/ComponentNav'; | |||
@@ -48,14 +47,14 @@ interface Props { | |||
children: React.ReactElement; | |||
fetchOrganization: (organization: string) => void; | |||
location: Pick<Location, 'query'>; | |||
registerBranchStatus: (branchLike: T.BranchLike, component: string, status: T.Status) => void; | |||
registerBranchStatus: (branchLike: BranchLike, component: string, status: T.Status) => void; | |||
requireAuthorization: (router: Pick<Router, 'replace'>) => void; | |||
router: Pick<Router, 'replace'>; | |||
} | |||
interface State { | |||
branchLike?: T.BranchLike; | |||
branchLikes: T.BranchLike[]; | |||
branchLike?: BranchLike; | |||
branchLikes: BranchLike[]; | |||
component?: T.Component; | |||
currentTask?: T.Task; | |||
isPending: boolean; | |||
@@ -143,8 +142,8 @@ export class ComponentContainer extends React.PureComponent<Props, State> { | |||
fetchBranches = ( | |||
component: T.Component | |||
): Promise<{ | |||
branchLike?: T.BranchLike; | |||
branchLikes: T.BranchLike[]; | |||
branchLike?: BranchLike; | |||
branchLikes: BranchLike[]; | |||
component: T.Component; | |||
}> => { | |||
const breadcrumb = component.breadcrumbs.find(({ qualifier }) => { | |||
@@ -222,7 +221,7 @@ export class ComponentContainer extends React.PureComponent<Props, State> { | |||
); | |||
}; | |||
fetchWarnings = (component: T.Component, branchLike?: T.BranchLike) => { | |||
fetchWarnings = (component: T.Component, branchLike?: BranchLike) => { | |||
if (component.qualifier === 'TRK') { | |||
getAnalysisStatus({ | |||
component: component.key, | |||
@@ -236,14 +235,14 @@ export class ComponentContainer extends React.PureComponent<Props, State> { | |||
} | |||
}; | |||
getCurrentBranchLike = (branchLikes: T.BranchLike[]) => { | |||
getCurrentBranchLike = (branchLikes: BranchLike[]) => { | |||
const { query } = this.props.location; | |||
return query.pullRequest | |||
? branchLikes.find(b => isPullRequest(b) && b.key === query.pullRequest) | |||
: branchLikes.find(b => isBranch(b) && (query.branch ? b.name === query.branch : b.isMain)); | |||
}; | |||
getCurrentTask = (current: T.Task, branchLike?: T.BranchLike) => { | |||
getCurrentTask = (current: T.Task, branchLike?: BranchLike) => { | |||
if (!current) { | |||
return undefined; | |||
} | |||
@@ -253,26 +252,23 @@ export class ComponentContainer extends React.PureComponent<Props, State> { | |||
: undefined; | |||
}; | |||
getPendingTasks = (pendingTasks: T.Task[], branchLike?: T.BranchLike) => { | |||
getPendingTasks = (pendingTasks: T.Task[], branchLike?: BranchLike) => { | |||
return pendingTasks.filter(task => this.isSameBranch(task, branchLike)); | |||
}; | |||
isSameBranch = ( | |||
task: Pick<T.Task, 'branch' | 'branchType' | 'pullRequest'>, | |||
branchLike?: T.BranchLike | |||
) => { | |||
isSameBranch = (task: Pick<T.Task, 'branch' | 'pullRequest'>, branchLike?: BranchLike) => { | |||
if (branchLike && !isMainBranch(branchLike)) { | |||
if (isPullRequest(branchLike)) { | |||
return branchLike.key === task.pullRequest; | |||
} | |||
if (isShortLivingBranch(branchLike) || isLongLivingBranch(branchLike)) { | |||
return branchLike.type === task.branchType && branchLike.name === task.branch; | |||
if (isBranch(branchLike)) { | |||
return branchLike.name === task.branch; | |||
} | |||
} | |||
return !task.branch && !task.pullRequest; | |||
}; | |||
registerBranchStatuses = (branchLikes: T.BranchLike[], component: T.Component) => { | |||
registerBranchStatuses = (branchLikes: BranchLike[], component: T.Component) => { | |||
branchLikes.forEach(branchLike => { | |||
if (branchLike.status) { | |||
this.props.registerBranchStatus( |
@@ -18,9 +18,10 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import * as React from 'react'; | |||
import { BranchLike } from '../../types/branch-like'; | |||
interface ComponentContextType { | |||
branchLike: T.BranchLike | undefined; | |||
branchLike: BranchLike | undefined; | |||
component: T.Component | undefined; | |||
} | |||
@@ -18,13 +18,14 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import * as React from 'react'; | |||
import { BranchLike } from '../../types/branch-like'; | |||
import handleRequiredAuthorization from '../utils/handleRequiredAuthorization'; | |||
import A11ySkipTarget from './a11y/A11ySkipTarget'; | |||
interface Props { | |||
children: JSX.Element; | |||
branchLike?: T.BranchLike; | |||
branchLikes: T.BranchLike[]; | |||
branchLike?: BranchLike; | |||
branchLikes: BranchLike[]; | |||
component: T.Component; | |||
isInProgress?: boolean; | |||
isPending?: boolean; |
@@ -25,20 +25,15 @@ import { getTasksForComponent } from '../../../api/ce'; | |||
import { getComponentData } from '../../../api/components'; | |||
import { getComponentNavigation } from '../../../api/nav'; | |||
import { STATUSES } from '../../../apps/background-tasks/constants'; | |||
import { mockBranch, mockMainBranch, mockPullRequest } from '../../../helpers/mocks/branch-like'; | |||
import { isSonarCloud } from '../../../helpers/system'; | |||
import { | |||
mockComponent, | |||
mockLocation, | |||
mockLongLivingBranch, | |||
mockMainBranch, | |||
mockPullRequest, | |||
mockRouter, | |||
mockShortLivingBranch | |||
} from '../../../helpers/testMocks'; | |||
import { mockComponent, mockLocation, mockRouter } from '../../../helpers/testMocks'; | |||
import { ComponentContainer } from '../ComponentContainer'; | |||
jest.mock('../../../api/branches', () => { | |||
const { mockMainBranch, mockPullRequest } = require.requireActual('../../../helpers/testMocks'); | |||
const { mockMainBranch, mockPullRequest } = require.requireActual( | |||
'../../../helpers/mocks/branch-like' | |||
); | |||
return { | |||
getBranches: jest | |||
.fn() | |||
@@ -79,7 +74,7 @@ jest.mock('../nav/component/ComponentNav', () => ({ | |||
const Inner = () => <div />; | |||
const mainBranch: T.MainBranch = mockMainBranch(); | |||
const mainBranch = mockMainBranch(); | |||
beforeEach(() => { | |||
jest.clearAllMocks(); | |||
@@ -154,40 +149,23 @@ it('filters correctly the pending tasks for a main branch', () => { | |||
const wrapper = shallowRender(); | |||
const component = wrapper.instance(); | |||
const mainBranch = mockMainBranch(); | |||
const shortBranch = mockShortLivingBranch(); | |||
const longBranch = mockLongLivingBranch(); | |||
const branch3 = mockBranch({ name: 'branch-3' }); | |||
const branch2 = mockBranch({ name: 'branch-2' }); | |||
const pullRequest = mockPullRequest(); | |||
expect(component.isSameBranch({}, undefined)).toBeTruthy(); | |||
expect(component.isSameBranch({}, mainBranch)).toBeTruthy(); | |||
expect(component.isSameBranch({}, shortBranch)).toBeFalsy(); | |||
expect( | |||
component.isSameBranch({ branch: shortBranch.name, branchType: 'SHORT' }, shortBranch) | |||
).toBeTruthy(); | |||
expect( | |||
component.isSameBranch({ branch: 'feature', branchType: 'SHORT' }, longBranch) | |||
).toBeFalsy(); | |||
expect( | |||
component.isSameBranch({ branch: 'feature', branchType: 'SHORT' }, longBranch) | |||
).toBeFalsy(); | |||
expect( | |||
component.isSameBranch({ branch: 'branch-6.6', branchType: 'LONG' }, longBranch) | |||
).toBeFalsy(); | |||
expect( | |||
component.isSameBranch({ branch: longBranch.name, branchType: 'LONG' }, longBranch) | |||
).toBeTruthy(); | |||
expect( | |||
component.isSameBranch({ branch: 'branch-6.7', branchType: 'LONG' }, pullRequest) | |||
).toBeFalsy(); | |||
expect(component.isSameBranch({}, branch3)).toBeFalsy(); | |||
expect(component.isSameBranch({ branch: branch3.name }, branch3)).toBeTruthy(); | |||
expect(component.isSameBranch({ branch: 'feature' }, branch2)).toBeFalsy(); | |||
expect(component.isSameBranch({ branch: 'branch-6.6' }, branch2)).toBeFalsy(); | |||
expect(component.isSameBranch({ branch: branch2.name }, branch2)).toBeTruthy(); | |||
expect(component.isSameBranch({ branch: 'branch-6.7' }, pullRequest)).toBeFalsy(); | |||
expect(component.isSameBranch({ pullRequest: pullRequest.key }, pullRequest)).toBeTruthy(); | |||
const currentTask = { pullRequest: pullRequest.key, status: STATUSES.IN_PROGRESS } as T.Task; | |||
const failedTask = { ...currentTask, status: STATUSES.FAILED }; | |||
const pendingTasks = [ | |||
currentTask, | |||
{ branch: shortBranch.name, branchType: 'SHORT' } as T.Task, | |||
{} as T.Task | |||
]; | |||
const pendingTasks = [currentTask, { branch: branch3.name } as T.Task, {} as T.Task]; | |||
expect(component.getCurrentTask(currentTask, undefined)).toBe(undefined); | |||
expect(component.getCurrentTask(failedTask, mainBranch)).toBe(failedTask); | |||
expect(component.getCurrentTask(currentTask, mainBranch)).toBe(undefined); |
@@ -18,11 +18,12 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import * as React from 'react'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import NotFound from '../NotFound'; | |||
import Extension from './Extension'; | |||
export interface ProjectPageExtensionProps { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
component: T.Component; | |||
location: { query: { id: string } }; | |||
params: { |
@@ -20,7 +20,8 @@ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { mockComponent, mockLocation, mockMainBranch } from '../../../../helpers/testMocks'; | |||
import { mockMainBranch } from '../../../../helpers/mocks/branch-like'; | |||
import { mockComponent, mockLocation } from '../../../../helpers/testMocks'; | |||
import ProjectPageExtension, { ProjectPageExtensionProps } from '../ProjectPageExtension'; | |||
it('should render correctly', () => { |
@@ -12,6 +12,7 @@ exports[`should render correctly 1`] = ` | |||
Object { | |||
"branchLike": Object { | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": true, | |||
"name": "master", | |||
}, |
@@ -46,13 +46,13 @@ import Tooltip from 'sonar-ui-common/components/controls/Tooltip'; | |||
import AlertErrorIcon from 'sonar-ui-common/components/icons/AlertErrorIcon'; | |||
import AlertSuccessIcon from 'sonar-ui-common/components/icons/AlertSuccessIcon'; | |||
import AlertWarnIcon from 'sonar-ui-common/components/icons/AlertWarnIcon'; | |||
import BranchIcon from 'sonar-ui-common/components/icons/BranchIcon'; | |||
import CheckIcon from 'sonar-ui-common/components/icons/CheckIcon'; | |||
import ClearIcon from 'sonar-ui-common/components/icons/ClearIcon'; | |||
import DetachIcon from 'sonar-ui-common/components/icons/DetachIcon'; | |||
import DropdownIcon from 'sonar-ui-common/components/icons/DropdownIcon'; | |||
import HelpIcon from 'sonar-ui-common/components/icons/HelpIcon'; | |||
import LockIcon from 'sonar-ui-common/components/icons/LockIcon'; | |||
import LongLivingBranchIcon from 'sonar-ui-common/components/icons/LongLivingBranchIcon'; | |||
import PlusCircleIcon from 'sonar-ui-common/components/icons/PlusCircleIcon'; | |||
import PullRequestIcon from 'sonar-ui-common/components/icons/PullRequestIcon'; | |||
import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon'; | |||
@@ -75,9 +75,9 @@ import CoverageRating from '../../../components/ui/CoverageRating'; | |||
import { | |||
getBranchLikeQuery, | |||
isBranch, | |||
isLongLivingBranch, | |||
isMainBranch, | |||
isPullRequest | |||
} from '../../../helpers/branches'; | |||
} from '../../../helpers/branch-like'; | |||
import * as measures from '../../../helpers/measures'; | |||
import { | |||
getStandards, | |||
@@ -101,7 +101,7 @@ const exposeLibraries = () => { | |||
global.SonarHelpers = { | |||
getBranchLikeQuery, | |||
isBranch, | |||
isLongLivingBranch, | |||
isMainBranch, | |||
isPullRequest, | |||
getStandards, | |||
renderCWECategory, | |||
@@ -149,7 +149,7 @@ const exposeLibraries = () => { | |||
Level, | |||
ListFooter, | |||
LockIcon, | |||
LongLivingBranchIcon, | |||
LongLivingBranchIcon: BranchIcon, | |||
Modal, | |||
NotFound, | |||
PlusCircleIcon, |
@@ -22,12 +22,13 @@ import { last } from 'lodash'; | |||
import * as React from 'react'; | |||
import { Link } from 'react-router'; | |||
import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon'; | |||
import { isMainBranch } from '../../../../helpers/branches'; | |||
import { isMainBranch } from '../../../../helpers/branch-like'; | |||
import { getProjectUrl } from '../../../../helpers/urls'; | |||
import { BranchLike } from '../../../../types/branch-like'; | |||
interface Props { | |||
component: T.Component; | |||
currentBranchLike: T.BranchLike | undefined; | |||
currentBranchLike: BranchLike | undefined; | |||
} | |||
export function ComponentBreadcrumb(props: Props) { |
@@ -20,6 +20,7 @@ | |||
import * as React from 'react'; | |||
import ContextNavBar from 'sonar-ui-common/components/ui/ContextNavBar'; | |||
import { STATUSES } from '../../../../apps/background-tasks/constants'; | |||
import { BranchLike } from '../../../../types/branch-like'; | |||
import { rawSizes } from '../../../theme'; | |||
import RecentHistory from '../../RecentHistory'; | |||
import './ComponentNav.css'; | |||
@@ -29,8 +30,8 @@ import ComponentNavMenu from './ComponentNavMenu'; | |||
import ComponentNavMeta from './ComponentNavMeta'; | |||
interface Props { | |||
branchLikes: T.BranchLike[]; | |||
currentBranchLike: T.BranchLike | undefined; | |||
branchLikes: BranchLike[]; | |||
currentBranchLike: BranchLike | undefined; | |||
component: T.Component; | |||
currentTask?: T.Task; | |||
currentTaskOnSameBranch?: boolean; |
@@ -19,14 +19,15 @@ | |||
*/ | |||
import * as React from 'react'; | |||
import Helmet from 'react-helmet'; | |||
import { BranchLike } from '../../../../types/branch-like'; | |||
import BranchLikeNavigation from './branch-like/BranchLikeNavigation'; | |||
import CurrentBranchLikeMergeInformation from './branch-like/CurrentBranchLikeMergeInformation'; | |||
import { ComponentBreadcrumb } from './ComponentBreadcrumb'; | |||
export interface ComponentNavHeaderProps { | |||
branchLikes: T.BranchLike[]; | |||
branchLikes: BranchLike[]; | |||
component: T.Component; | |||
currentBranchLike: T.BranchLike | undefined; | |||
currentBranchLike: BranchLike | undefined; | |||
} | |||
export function ComponentNavHeader(props: ComponentNavHeaderProps) { |
@@ -25,13 +25,9 @@ import DropdownIcon from 'sonar-ui-common/components/icons/DropdownIcon'; | |||
import NavBarTabs from 'sonar-ui-common/components/ui/NavBarTabs'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import { withAppState } from '../../../../components/hoc/withAppState'; | |||
import { | |||
getBranchLikeQuery, | |||
isMainBranch, | |||
isPullRequest, | |||
isShortLivingBranch | |||
} from '../../../../helpers/branches'; | |||
import { getBranchLikeQuery, isMainBranch, isPullRequest } from '../../../../helpers/branch-like'; | |||
import { isSonarCloud } from '../../../../helpers/system'; | |||
import { BranchLike } from '../../../../types/branch-like'; | |||
const SETTINGS_URLS = [ | |||
'/project/admin', | |||
@@ -52,7 +48,7 @@ const SETTINGS_URLS = [ | |||
interface Props { | |||
appState: Pick<T.AppState, 'branchesEnabled'>; | |||
branchLike: T.BranchLike | undefined; | |||
branchLike: BranchLike | undefined; | |||
component: T.Component; | |||
location?: any; | |||
} | |||
@@ -113,7 +109,7 @@ export class ComponentNavMenu extends React.PureComponent<Props> { | |||
renderActivityLink() { | |||
const { branchLike } = this.props; | |||
if (isShortLivingBranch(branchLike) || isPullRequest(branchLike)) { | |||
if (isPullRequest(branchLike)) { | |||
return null; | |||
} | |||
@@ -159,7 +155,7 @@ export class ComponentNavMenu extends React.PureComponent<Props> { | |||
const { branchLike, component } = this.props; | |||
const { extensions = [] } = component; | |||
if (isShortLivingBranch(branchLike) || isPullRequest(branchLike)) { | |||
if (isPullRequest(branchLike)) { | |||
return null; | |||
} | |||
@@ -26,18 +26,14 @@ import BranchStatus from '../../../../components/common/BranchStatus'; | |||
import Favorite from '../../../../components/controls/Favorite'; | |||
import HomePageSelect from '../../../../components/controls/HomePageSelect'; | |||
import DateTimeFormatter from '../../../../components/intl/DateTimeFormatter'; | |||
import { | |||
isLongLivingBranch, | |||
isMainBranch, | |||
isPullRequest, | |||
isShortLivingBranch | |||
} from '../../../../helpers/branches'; | |||
import { isBranch, isMainBranch, isPullRequest } from '../../../../helpers/branch-like'; | |||
import { isLoggedIn } from '../../../../helpers/users'; | |||
import { getCurrentUser, Store } from '../../../../store/rootReducer'; | |||
import { BranchLike } from '../../../../types/branch-like'; | |||
import ComponentNavWarnings from './ComponentNavWarnings'; | |||
export interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
currentUser: T.CurrentUser; | |||
component: T.Component; | |||
warnings: string[]; | |||
@@ -45,9 +41,9 @@ export interface Props { | |||
export function ComponentNavMeta({ branchLike, component, currentUser, warnings }: Props) { | |||
const mainBranch = !branchLike || isMainBranch(branchLike); | |||
const longBranch = isLongLivingBranch(branchLike); | |||
const isABranch = isBranch(branchLike); | |||
const currentPage = getCurrentPage(component, branchLike); | |||
const displayVersion = component.version !== undefined && (mainBranch || longBranch); | |||
const displayVersion = component.version !== undefined && isABranch; | |||
return ( | |||
<div className="navbar-context-meta flex-0"> | |||
@@ -73,12 +69,12 @@ export function ComponentNavMeta({ branchLike, component, currentUser, warnings | |||
qualifier={component.qualifier} | |||
/> | |||
)} | |||
{(mainBranch || longBranch) && currentPage !== undefined && ( | |||
{isABranch && currentPage !== undefined && ( | |||
<HomePageSelect className="spacer-left" currentPage={currentPage} /> | |||
)} | |||
</div> | |||
)} | |||
{(isShortLivingBranch(branchLike) || isPullRequest(branchLike)) && ( | |||
{isPullRequest(branchLike) && ( | |||
<div className="navbar-context-meta-secondary display-inline-flex-center"> | |||
{isPullRequest(branchLike) && branchLike.url !== undefined && ( | |||
<a | |||
@@ -97,16 +93,16 @@ export function ComponentNavMeta({ branchLike, component, currentUser, warnings | |||
); | |||
} | |||
export function getCurrentPage(component: T.Component, branchLike: T.BranchLike | undefined) { | |||
export function getCurrentPage(component: T.Component, branchLike: BranchLike | undefined) { | |||
let currentPage: T.HomePage | undefined; | |||
if (component.qualifier === 'VW' || component.qualifier === 'SVW') { | |||
currentPage = { type: 'PORTFOLIO', component: component.key }; | |||
} else if (component.qualifier === 'APP') { | |||
const branch = isLongLivingBranch(branchLike) ? branchLike.name : undefined; | |||
const branch = isBranch(branchLike) ? branchLike.name : undefined; | |||
currentPage = { type: 'APPLICATION', component: component.key, branch }; | |||
} else if (component.qualifier === 'TRK') { | |||
// when home page is set to the default branch of a project, its name is returned as `undefined` | |||
const branch = isLongLivingBranch(branchLike) ? branchLike.name : undefined; | |||
const branch = isBranch(branchLike) ? branchLike.name : undefined; | |||
currentPage = { type: 'PROJECT', component: component.key, branch }; | |||
} | |||
return currentPage; |
@@ -20,7 +20,8 @@ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { mockComponent, mockMainBranch } from '../../../../../helpers/testMocks'; | |||
import { mockMainBranch } from '../../../../../helpers/mocks/branch-like'; | |||
import { mockComponent } from '../../../../../helpers/testMocks'; | |||
import { ComponentQualifier } from '../../../../../types/component'; | |||
import { ComponentBreadcrumb } from '../ComponentBreadcrumb'; | |||
@@ -20,7 +20,7 @@ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { mockSetOfBranchAndPullRequest } from '../../../../../helpers/mocks/branch-pull-request'; | |||
import { mockSetOfBranchAndPullRequest } from '../../../../../helpers/mocks/branch-like'; | |||
import { mockComponent } from '../../../../../helpers/testMocks'; | |||
import { ComponentNavHeader, ComponentNavHeaderProps } from '../ComponentNavHeader'; | |||
@@ -19,10 +19,10 @@ | |||
*/ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { mockMainBranch } from '../../../../../helpers/testMocks'; | |||
import { mockBranch, mockMainBranch } from '../../../../../helpers/mocks/branch-like'; | |||
import { ComponentNavMenu } from '../ComponentNavMenu'; | |||
const mainBranch: T.MainBranch = mockMainBranch(); | |||
const mainBranch = mockMainBranch(); | |||
const baseComponent = { | |||
breadcrumbs: [], | |||
@@ -95,37 +95,10 @@ it('should render correctly for security extensions', () => { | |||
expect(wrapper.find('Dropdown[data-test="security"]')).toMatchSnapshot(); | |||
}); | |||
it('should work for short-living branches', () => { | |||
const branch: T.ShortLivingBranch = { | |||
isMain: false, | |||
excludedFromPurge: true, | |||
mergeBranch: 'master', | |||
name: 'feature', | |||
type: 'SHORT' | |||
}; | |||
const component = { | |||
...baseComponent, | |||
configuration: { showSettings: true }, | |||
extensions: [{ key: 'component-foo', name: 'ComponentFoo' }] | |||
}; | |||
expect( | |||
shallow( | |||
<ComponentNavMenu | |||
appState={{ branchesEnabled: true }} | |||
branchLike={branch} | |||
component={component} | |||
/> | |||
) | |||
).toMatchSnapshot(); | |||
}); | |||
it('should work for long-living branches', () => { | |||
const branch: T.LongLivingBranch = { | |||
excludedFromPurge: true, | |||
isMain: false, | |||
name: 'release', | |||
type: 'LONG' | |||
}; | |||
it('should work for a branch', () => { | |||
const branch = mockBranch({ | |||
name: 'release' | |||
}); | |||
[true, false].forEach(showSettings => | |||
expect( | |||
shallow( |
@@ -19,24 +19,14 @@ | |||
*/ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { | |||
mockComponent, | |||
mockCurrentUser, | |||
mockLoggedInUser, | |||
mockLongLivingBranch, | |||
mockPullRequest, | |||
mockShortLivingBranch | |||
} from '../../../../../helpers/testMocks'; | |||
import { mockBranch, mockPullRequest } from '../../../../../helpers/mocks/branch-like'; | |||
import { mockComponent, mockCurrentUser, mockLoggedInUser } from '../../../../../helpers/testMocks'; | |||
import { ComponentNavMeta, getCurrentPage, Props } from '../ComponentNavMeta'; | |||
describe('#ComponentNavMeta', () => { | |||
it('renders status of short-living branch', () => { | |||
expect(shallowRender()).toMatchSnapshot(); | |||
}); | |||
it('renders meta for long-living branch', () => { | |||
it('renders meta for a branch', () => { | |||
expect( | |||
shallowRender({ branchLike: mockLongLivingBranch(), currentUser: mockLoggedInUser() }) | |||
shallowRender({ branchLike: mockBranch(), currentUser: mockLoggedInUser() }) | |||
).toMatchSnapshot(); | |||
}); | |||
@@ -63,16 +53,16 @@ describe('#getCurrentPage', () => { | |||
expect( | |||
getCurrentPage( | |||
mockComponent({ key: 'foo', qualifier: 'APP' }), | |||
mockLongLivingBranch({ name: 'develop' }) | |||
mockBranch({ name: 'develop' }) | |||
) | |||
).toEqual({ type: 'APPLICATION', component: 'foo', branch: 'develop' }); | |||
}); | |||
it('should return a portfolio page', () => { | |||
expect(getCurrentPage(mockComponent(), mockShortLivingBranch())).toEqual({ | |||
it('should return a project page', () => { | |||
expect(getCurrentPage(mockComponent(), mockBranch({ name: 'feature/foo' }))).toEqual({ | |||
type: 'PROJECT', | |||
component: 'my-project', | |||
branch: undefined | |||
branch: 'feature/foo' | |||
}); | |||
}); | |||
}); | |||
@@ -80,7 +70,7 @@ describe('#getCurrentPage', () => { | |||
function shallowRender(props: Partial<Props> = {}) { | |||
return shallow( | |||
<ComponentNavMeta | |||
branchLike={mockShortLivingBranch()} | |||
branchLike={mockBranch()} | |||
component={mockComponent({ analysisDate: '2017-01-02T00:00:00.000Z', version: '0.0.1' })} | |||
currentUser={mockCurrentUser()} | |||
warnings={[]} |
@@ -39,9 +39,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "slb-1", | |||
"type": "SHORT", | |||
"name": "branch-11", | |||
} | |||
} | |||
/> | |||
@@ -52,16 +50,13 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "slb-1", | |||
"type": "SHORT", | |||
"name": "branch-11", | |||
}, | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-1", | |||
"type": "LONG", | |||
"name": "branch-1", | |||
}, | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
@@ -81,9 +76,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "llb-1", | |||
"name": "slb-2", | |||
"type": "SHORT", | |||
"name": "branch-12", | |||
}, | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
@@ -97,15 +90,13 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-3", | |||
"type": "LONG", | |||
"name": "branch-3", | |||
}, | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-2", | |||
"type": "LONG", | |||
"name": "branch-2", | |||
}, | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
@@ -146,9 +137,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "slb-1", | |||
"type": "SHORT", | |||
"name": "branch-11", | |||
} | |||
} | |||
/> | |||
@@ -158,9 +147,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "slb-1", | |||
"type": "SHORT", | |||
"name": "branch-11", | |||
} | |||
} | |||
/> |
@@ -35,7 +35,7 @@ exports[`should render correctly for security extensions 1`] = ` | |||
exports[`should render correctly for security extensions 2`] = `null`; | |||
exports[`should work for all qualifiers 1`] = ` | |||
exports[`should work for a branch 1`] = ` | |||
<NavBarTabs> | |||
<li> | |||
<Link | |||
@@ -46,6 +46,7 @@ exports[`should work for all qualifiers 1`] = ` | |||
Object { | |||
"pathname": "/dashboard", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -64,6 +65,7 @@ exports[`should work for all qualifiers 1`] = ` | |||
Object { | |||
"pathname": "/project/issues", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
"resolved": "false", | |||
}, | |||
@@ -82,6 +84,7 @@ exports[`should work for all qualifiers 1`] = ` | |||
Object { | |||
"pathname": "/component_measures", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -99,6 +102,7 @@ exports[`should work for all qualifiers 1`] = ` | |||
Object { | |||
"pathname": "/code", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -116,6 +120,7 @@ exports[`should work for all qualifiers 1`] = ` | |||
Object { | |||
"pathname": "/project/activity", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -124,107 +129,10 @@ exports[`should work for all qualifiers 1`] = ` | |||
project_activity.page | |||
</Link> | |||
</li> | |||
<Dropdown | |||
data-test="administration" | |||
overlay={ | |||
<ul | |||
className="menu" | |||
> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/settings", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
project_settings.page | |||
</Link> | |||
</li> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/branches", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
project_branch_pull_request.page | |||
</Link> | |||
</li> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/baseline", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
project_baseline.page | |||
</Link> | |||
</li> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/webhooks", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
webhooks.page | |||
</Link> | |||
</li> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/deletion", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
deletion.page | |||
</Link> | |||
</li> | |||
</ul> | |||
} | |||
tagName="li" | |||
> | |||
<Component /> | |||
</Dropdown> | |||
</NavBarTabs> | |||
`; | |||
exports[`should work for all qualifiers 2`] = ` | |||
exports[`should work for a branch 2`] = ` | |||
<NavBarTabs> | |||
<li> | |||
<Link | |||
@@ -233,8 +141,9 @@ exports[`should work for all qualifiers 2`] = ` | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/portfolio", | |||
"pathname": "/dashboard", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -253,6 +162,7 @@ exports[`should work for all qualifiers 2`] = ` | |||
Object { | |||
"pathname": "/project/issues", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
"resolved": "false", | |||
}, | |||
@@ -271,6 +181,7 @@ exports[`should work for all qualifiers 2`] = ` | |||
Object { | |||
"pathname": "/component_measures", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -288,12 +199,13 @@ exports[`should work for all qualifiers 2`] = ` | |||
Object { | |||
"pathname": "/code", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
view_projects.page | |||
code.page | |||
</Link> | |||
</li> | |||
<li> | |||
@@ -305,6 +217,7 @@ exports[`should work for all qualifiers 2`] = ` | |||
Object { | |||
"pathname": "/project/activity", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -313,39 +226,10 @@ exports[`should work for all qualifiers 2`] = ` | |||
project_activity.page | |||
</Link> | |||
</li> | |||
<Dropdown | |||
data-test="administration" | |||
overlay={ | |||
<ul | |||
className="menu" | |||
> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/deletion", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
deletion.page | |||
</Link> | |||
</li> | |||
</ul> | |||
} | |||
tagName="li" | |||
> | |||
<Component /> | |||
</Dropdown> | |||
</NavBarTabs> | |||
`; | |||
exports[`should work for all qualifiers 3`] = ` | |||
exports[`should work for all qualifiers 1`] = ` | |||
<NavBarTabs> | |||
<li> | |||
<Link | |||
@@ -354,7 +238,7 @@ exports[`should work for all qualifiers 3`] = ` | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/portfolio", | |||
"pathname": "/dashboard", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
@@ -414,7 +298,7 @@ exports[`should work for all qualifiers 3`] = ` | |||
} | |||
} | |||
> | |||
view_projects.page | |||
code.page | |||
</Link> | |||
</li> | |||
<li> | |||
@@ -434,10 +318,107 @@ exports[`should work for all qualifiers 3`] = ` | |||
project_activity.page | |||
</Link> | |||
</li> | |||
<Dropdown | |||
data-test="administration" | |||
overlay={ | |||
<ul | |||
className="menu" | |||
> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/settings", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
project_settings.page | |||
</Link> | |||
</li> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/branches", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
project_branch_pull_request.page | |||
</Link> | |||
</li> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/baseline", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
project_baseline.page | |||
</Link> | |||
</li> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/webhooks", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
webhooks.page | |||
</Link> | |||
</li> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/deletion", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
deletion.page | |||
</Link> | |||
</li> | |||
</ul> | |||
} | |||
tagName="li" | |||
> | |||
<Component /> | |||
</Dropdown> | |||
</NavBarTabs> | |||
`; | |||
exports[`should work for all qualifiers 4`] = ` | |||
exports[`should work for all qualifiers 2`] = ` | |||
<NavBarTabs> | |||
<li> | |||
<Link | |||
@@ -446,7 +427,7 @@ exports[`should work for all qualifiers 4`] = ` | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/dashboard", | |||
"pathname": "/portfolio", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
@@ -558,7 +539,7 @@ exports[`should work for all qualifiers 4`] = ` | |||
</NavBarTabs> | |||
`; | |||
exports[`should work for long-living branches 1`] = ` | |||
exports[`should work for all qualifiers 3`] = ` | |||
<NavBarTabs> | |||
<li> | |||
<Link | |||
@@ -567,9 +548,8 @@ exports[`should work for long-living branches 1`] = ` | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/dashboard", | |||
"pathname": "/portfolio", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -588,7 +568,6 @@ exports[`should work for long-living branches 1`] = ` | |||
Object { | |||
"pathname": "/project/issues", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
"resolved": "false", | |||
}, | |||
@@ -607,7 +586,6 @@ exports[`should work for long-living branches 1`] = ` | |||
Object { | |||
"pathname": "/component_measures", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -625,13 +603,12 @@ exports[`should work for long-living branches 1`] = ` | |||
Object { | |||
"pathname": "/code", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
code.page | |||
view_projects.page | |||
</Link> | |||
</li> | |||
<li> | |||
@@ -643,7 +620,6 @@ exports[`should work for long-living branches 1`] = ` | |||
Object { | |||
"pathname": "/project/activity", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -655,7 +631,7 @@ exports[`should work for long-living branches 1`] = ` | |||
</NavBarTabs> | |||
`; | |||
exports[`should work for long-living branches 2`] = ` | |||
exports[`should work for all qualifiers 4`] = ` | |||
<NavBarTabs> | |||
<li> | |||
<Link | |||
@@ -666,7 +642,6 @@ exports[`should work for long-living branches 2`] = ` | |||
Object { | |||
"pathname": "/dashboard", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -685,7 +660,6 @@ exports[`should work for long-living branches 2`] = ` | |||
Object { | |||
"pathname": "/project/issues", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
"resolved": "false", | |||
}, | |||
@@ -704,7 +678,6 @@ exports[`should work for long-living branches 2`] = ` | |||
Object { | |||
"pathname": "/component_measures", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -722,13 +695,12 @@ exports[`should work for long-living branches 2`] = ` | |||
Object { | |||
"pathname": "/code", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
code.page | |||
view_projects.page | |||
</Link> | |||
</li> | |||
<li> | |||
@@ -740,7 +712,6 @@ exports[`should work for long-living branches 2`] = ` | |||
Object { | |||
"pathname": "/project/activity", | |||
"query": Object { | |||
"branch": "release", | |||
"id": "foo", | |||
}, | |||
} | |||
@@ -749,85 +720,35 @@ exports[`should work for long-living branches 2`] = ` | |||
project_activity.page | |||
</Link> | |||
</li> | |||
</NavBarTabs> | |||
`; | |||
exports[`should work for short-living branches 1`] = ` | |||
<NavBarTabs> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/dashboard", | |||
"query": Object { | |||
"branch": "feature", | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
overview.page | |||
</Link> | |||
</li> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
className="" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/issues", | |||
"query": Object { | |||
"branch": "feature", | |||
"id": "foo", | |||
"resolved": "false", | |||
}, | |||
} | |||
} | |||
> | |||
issues.page | |||
</Link> | |||
</li> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/component_measures", | |||
"query": Object { | |||
"branch": "feature", | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
layout.measures | |||
</Link> | |||
</li> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/code", | |||
"query": Object { | |||
"branch": "feature", | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
code.page | |||
</Link> | |||
</li> | |||
<Dropdown | |||
data-test="administration" | |||
overlay={ | |||
<ul | |||
className="menu" | |||
> | |||
<li> | |||
<Link | |||
activeClassName="active" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/deletion", | |||
"query": Object { | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
deletion.page | |||
</Link> | |||
</li> | |||
</ul> | |||
} | |||
tagName="li" | |||
> | |||
<Component /> | |||
</Dropdown> | |||
</NavBarTabs> | |||
`; | |||
@@ -1,6 +1,6 @@ | |||
// Jest Snapshot v1, https://goo.gl/fbAQLP | |||
exports[`#ComponentNavMeta renders meta for long-living branch 1`] = ` | |||
exports[`#ComponentNavMeta renders meta for a branch 1`] = ` | |||
<div | |||
className="navbar-context-meta flex-0" | |||
> | |||
@@ -83,34 +83,3 @@ exports[`#ComponentNavMeta renders meta for pull request 1`] = ` | |||
</div> | |||
</div> | |||
`; | |||
exports[`#ComponentNavMeta renders status of short-living branch 1`] = ` | |||
<div | |||
className="navbar-context-meta flex-0" | |||
> | |||
<div | |||
className="spacer-left text-ellipsis" | |||
> | |||
<DateTimeFormatter | |||
date="2017-01-02T00:00:00.000Z" | |||
/> | |||
</div> | |||
<div | |||
className="navbar-context-meta-secondary display-inline-flex-center" | |||
> | |||
<Connect(BranchStatus) | |||
branchLike={ | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "feature/foo", | |||
"type": "SHORT", | |||
} | |||
} | |||
component="my-project" | |||
/> | |||
</div> | |||
</div> | |||
`; |
@@ -22,15 +22,16 @@ import * as classNames from 'classnames'; | |||
import * as React from 'react'; | |||
import Toggler from 'sonar-ui-common/components/controls/Toggler'; | |||
import { withAppState } from '../../../../../components/hoc/withAppState'; | |||
import { BranchLike } from '../../../../../types/branch-like'; | |||
import './BranchLikeNavigation.css'; | |||
import CurrentBranchLike from './CurrentBranchLike'; | |||
import Menu from './Menu'; | |||
export interface BranchLikeNavigationProps { | |||
appState: Pick<T.AppState, 'branchesEnabled'>; | |||
branchLikes: T.BranchLike[]; | |||
branchLikes: BranchLike[]; | |||
component: T.Component; | |||
currentBranchLike: T.BranchLike; | |||
currentBranchLike: BranchLike; | |||
} | |||
export function BranchLikeNavigation(props: BranchLikeNavigationProps) { |
@@ -26,15 +26,16 @@ import PlusCircleIcon from 'sonar-ui-common/components/icons/PlusCircleIcon'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import DocTooltip from '../../../../../components/docs/DocTooltip'; | |||
import BranchLikeIcon from '../../../../../components/icons/BranchLikeIcon'; | |||
import { getBranchLikeDisplayName } from '../../../../../helpers/branches'; | |||
import { getBranchLikeDisplayName } from '../../../../../helpers/branch-like'; | |||
import { getPortfolioAdminUrl } from '../../../../../helpers/urls'; | |||
import { BranchLike } from '../../../../../types/branch-like'; | |||
import { ComponentQualifier } from '../../../../../types/component'; | |||
import { colors } from '../../../../theme'; | |||
export interface CurrentBranchLikeProps { | |||
branchesEnabled: boolean; | |||
component: T.Component; | |||
currentBranchLike: T.BranchLike; | |||
currentBranchLike: BranchLike; | |||
hasManyBranches: boolean; | |||
} | |||
@@ -21,10 +21,11 @@ | |||
import * as React from 'react'; | |||
import { FormattedMessage } from 'react-intl'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import { isPullRequest } from '../../../../../helpers/branches'; | |||
import { isPullRequest } from '../../../../../helpers/branch-like'; | |||
import { BranchLike } from '../../../../../types/branch-like'; | |||
export interface CurrentBranchLikeMergeInformationProps { | |||
currentBranchLike: T.BranchLike; | |||
currentBranchLike: BranchLike; | |||
} | |||
export function CurrentBranchLikeMergeInformation(props: CurrentBranchLikeMergeInformationProps) { |
@@ -30,25 +30,26 @@ import { | |||
isBranch, | |||
isPullRequest, | |||
isSameBranchLike | |||
} from '../../../../../helpers/branches'; | |||
} from '../../../../../helpers/branch-like'; | |||
import { getBranchLikeUrl } from '../../../../../helpers/urls'; | |||
import { BranchLike, BranchLikeTree } from '../../../../../types/branch-like'; | |||
import { ComponentQualifier } from '../../../../../types/component'; | |||
import MenuItemList from './MenuItemList'; | |||
interface Props { | |||
branchLikes: T.BranchLike[]; | |||
branchLikes: BranchLike[]; | |||
canAdminComponent?: boolean; | |||
component: T.Component; | |||
currentBranchLike: T.BranchLike; | |||
currentBranchLike: BranchLike; | |||
onClose: () => void; | |||
router: Pick<Router, 'push'>; | |||
} | |||
interface State { | |||
branchLikesToDisplay: T.BranchLike[]; | |||
branchLikesToDisplayTree: T.BranchLikeTree; | |||
branchLikesToDisplay: BranchLike[]; | |||
branchLikesToDisplayTree: BranchLikeTree; | |||
query: string; | |||
selectedBranchLike: T.BranchLike | undefined; | |||
selectedBranchLike: BranchLike | undefined; | |||
} | |||
export class Menu extends React.PureComponent<Props, State> { | |||
@@ -70,7 +71,7 @@ export class Menu extends React.PureComponent<Props, State> { | |||
}; | |||
} | |||
processBranchLikes = (branchLikes: T.BranchLike[]) => { | |||
processBranchLikes = (branchLikes: BranchLike[]) => { | |||
const tree = getBrancheLikesAsTree(branchLikes); | |||
return { | |||
branchLikesToDisplay: [ | |||
@@ -128,9 +129,9 @@ export class Menu extends React.PureComponent<Props, State> { | |||
handleSearchChange = (query: string) => { | |||
const q = query.toLowerCase(); | |||
const filterBranch = (branch: T.BranchLike) => | |||
const filterBranch = (branch: BranchLike) => | |||
isBranch(branch) && branch.name.toLowerCase().includes(q); | |||
const filterPullRequest = (pr: T.BranchLike) => | |||
const filterPullRequest = (pr: BranchLike) => | |||
isPullRequest(pr) && (pr.title.toLowerCase().includes(q) || pr.key.toLowerCase().includes(q)); | |||
const filteredBranchLikes = this.props.branchLikes.filter( | |||
@@ -144,7 +145,7 @@ export class Menu extends React.PureComponent<Props, State> { | |||
}); | |||
}; | |||
handleOnSelect = (branchLike: T.BranchLike) => { | |||
handleOnSelect = (branchLike: BranchLike) => { | |||
this.setState({ selectedBranchLike: branchLike }, () => { | |||
this.props.onClose(); | |||
this.props.router.push(getBranchLikeUrl(this.props.component.key, branchLike)); |
@@ -23,13 +23,14 @@ import * as React from 'react'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import BranchStatus from '../../../../../components/common/BranchStatus'; | |||
import BranchLikeIcon from '../../../../../components/icons/BranchLikeIcon'; | |||
import { getBranchLikeDisplayName, isMainBranch } from '../../../../../helpers/branches'; | |||
import { getBranchLikeDisplayName, isMainBranch } from '../../../../../helpers/branch-like'; | |||
import { BranchLike } from '../../../../../types/branch-like'; | |||
export interface MenuItemProps { | |||
branchLike: T.BranchLike; | |||
branchLike: BranchLike; | |||
component: T.Component; | |||
indent?: boolean; | |||
onSelect: (branchLike: T.BranchLike) => void; | |||
onSelect: (branchLike: BranchLike) => void; | |||
selected: boolean; | |||
setSelectedNode?: (node: HTMLLIElement) => void; | |||
} |
@@ -23,15 +23,16 @@ import HelpTooltip from 'sonar-ui-common/components/controls/HelpTooltip'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import { scrollToElement } from 'sonar-ui-common/helpers/scrolling'; | |||
import { isDefined } from 'sonar-ui-common/helpers/types'; | |||
import { getBranchLikeKey, isSameBranchLike } from '../../../../../helpers/branches'; | |||
import { getBranchLikeKey, isSameBranchLike } from '../../../../../helpers/branch-like'; | |||
import { BranchLike, BranchLikeTree } from '../../../../../types/branch-like'; | |||
import MenuItem from './MenuItem'; | |||
export interface MenuItemListProps { | |||
branchLikeTree: T.BranchLikeTree; | |||
branchLikeTree: BranchLikeTree; | |||
component: T.Component; | |||
hasResults: boolean; | |||
onSelect: (branchLike: T.BranchLike) => void; | |||
selectedBranchLike: T.BranchLike | undefined; | |||
onSelect: (branchLike: BranchLike) => void; | |||
selectedBranchLike: BranchLike | undefined; | |||
} | |||
export function MenuItemList(props: MenuItemListProps) { | |||
@@ -46,7 +47,7 @@ export function MenuItemList(props: MenuItemListProps) { | |||
const { branchLikeTree, component, hasResults, onSelect, selectedBranchLike } = props; | |||
const renderItem = (branchLike: T.BranchLike, indent?: boolean) => ( | |||
const renderItem = (branchLike: BranchLike, indent?: boolean) => ( | |||
<MenuItem | |||
branchLike={branchLike} | |||
component={component} |
@@ -22,7 +22,7 @@ import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import Toggler from 'sonar-ui-common/components/controls/Toggler'; | |||
import { click } from 'sonar-ui-common/helpers/testUtils'; | |||
import { mockSetOfBranchAndPullRequest } from '../../../../../../helpers/mocks/branch-pull-request'; | |||
import { mockSetOfBranchAndPullRequest } from '../../../../../../helpers/mocks/branch-like'; | |||
import { mockAppState, mockComponent } from '../../../../../../helpers/testMocks'; | |||
import { BranchLikeNavigation, BranchLikeNavigationProps } from '../BranchLikeNavigation'; | |||
@@ -20,7 +20,8 @@ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { mockComponent, mockMainBranch } from '../../../../../../helpers/testMocks'; | |||
import { mockMainBranch } from '../../../../../../helpers/mocks/branch-like'; | |||
import { mockComponent } from '../../../../../../helpers/testMocks'; | |||
import { ComponentQualifier } from '../../../../../../types/component'; | |||
import { CurrentBranchLike, CurrentBranchLikeProps } from '../CurrentBranchLike'; | |||
@@ -20,7 +20,7 @@ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { mockMainBranch, mockPullRequest } from '../../../../../../helpers/testMocks'; | |||
import { mockMainBranch, mockPullRequest } from '../../../../../../helpers/mocks/branch-like'; | |||
import { | |||
CurrentBranchLikeMergeInformation, | |||
CurrentBranchLikeMergeInformationProps |
@@ -24,8 +24,11 @@ import { Link } from 'react-router'; | |||
import SearchBox from 'sonar-ui-common/components/controls/SearchBox'; | |||
import { KeyCodes } from 'sonar-ui-common/helpers/keycodes'; | |||
import { click, mockEvent } from 'sonar-ui-common/helpers/testUtils'; | |||
import { mockSetOfBranchAndPullRequest } from '../../../../../../helpers/mocks/branch-pull-request'; | |||
import { mockComponent, mockPullRequest, mockRouter } from '../../../../../../helpers/testMocks'; | |||
import { | |||
mockPullRequest, | |||
mockSetOfBranchAndPullRequest | |||
} from '../../../../../../helpers/mocks/branch-like'; | |||
import { mockComponent, mockRouter } from '../../../../../../helpers/testMocks'; | |||
import { Menu } from '../Menu'; | |||
import { MenuItemList } from '../MenuItemList'; | |||
@@ -98,7 +101,7 @@ it('should handle keyboard shortcut correctly', () => { | |||
onKeyDown(mockEvent({ keyCode: KeyCodes.DownArrow })); | |||
onKeyDown(mockEvent({ keyCode: KeyCodes.DownArrow })); | |||
expect(wrapper.state().selectedBranchLike).toBe(branchLikes[7]); | |||
expect(wrapper.state().selectedBranchLike).toBe(branchLikes[0]); | |||
onKeyDown(mockEvent({ keyCode: KeyCodes.Enter })); | |||
expect(push).toHaveBeenCalled(); |
@@ -21,11 +21,8 @@ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { click } from 'sonar-ui-common/helpers/testUtils'; | |||
import { | |||
mockComponent, | |||
mockMainBranch, | |||
mockPullRequest | |||
} from '../../../../../../helpers/testMocks'; | |||
import { mockMainBranch, mockPullRequest } from '../../../../../../helpers/mocks/branch-like'; | |||
import { mockComponent } from '../../../../../../helpers/testMocks'; | |||
import { MenuItem, MenuItemProps } from '../MenuItem'; | |||
it('should render a main branch correctly', () => { |
@@ -20,9 +20,12 @@ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { getBrancheLikesAsTree } from '../../../../../../helpers/branches'; | |||
import { mockSetOfBranchAndPullRequest } from '../../../../../../helpers/mocks/branch-pull-request'; | |||
import { mockComponent, mockPullRequest } from '../../../../../../helpers/testMocks'; | |||
import { getBrancheLikesAsTree } from '../../../../../../helpers/branch-like'; | |||
import { | |||
mockPullRequest, | |||
mockSetOfBranchAndPullRequest | |||
} from '../../../../../../helpers/mocks/branch-like'; | |||
import { mockComponent } from '../../../../../../helpers/testMocks'; | |||
import { MenuItemList, MenuItemListProps } from '../MenuItemList'; | |||
it('should render correctly', () => { |
@@ -34,9 +34,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "slb-1", | |||
"type": "SHORT", | |||
"name": "branch-11", | |||
} | |||
} | |||
hasManyBranches={true} | |||
@@ -59,16 +57,13 @@ exports[`should render the menu trigger if branches are enabled 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "slb-1", | |||
"type": "SHORT", | |||
"name": "branch-11", | |||
}, | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-1", | |||
"type": "LONG", | |||
"name": "branch-1", | |||
}, | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
@@ -88,9 +83,7 @@ exports[`should render the menu trigger if branches are enabled 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "llb-1", | |||
"name": "slb-2", | |||
"type": "SHORT", | |||
"name": "branch-12", | |||
}, | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
@@ -104,15 +97,13 @@ exports[`should render the menu trigger if branches are enabled 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-3", | |||
"type": "LONG", | |||
"name": "branch-3", | |||
}, | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-2", | |||
"type": "LONG", | |||
"name": "branch-2", | |||
}, | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
@@ -153,9 +144,7 @@ exports[`should render the menu trigger if branches are enabled 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "slb-1", | |||
"type": "SHORT", | |||
"name": "branch-11", | |||
} | |||
} | |||
onClose={[Function]} | |||
@@ -197,9 +186,7 @@ exports[`should render the menu trigger if branches are enabled 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "slb-1", | |||
"type": "SHORT", | |||
"name": "branch-11", | |||
} | |||
} | |||
hasManyBranches={true} |
@@ -28,8 +28,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-1", | |||
"type": "LONG", | |||
"name": "branch-1", | |||
}, | |||
"pullRequests": Array [], | |||
}, | |||
@@ -38,8 +37,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-2", | |||
"type": "LONG", | |||
"name": "branch-11", | |||
}, | |||
"pullRequests": Array [], | |||
}, | |||
@@ -48,8 +46,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-3", | |||
"type": "LONG", | |||
"name": "branch-12", | |||
}, | |||
"pullRequests": Array [], | |||
}, | |||
@@ -58,9 +55,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "slb-1", | |||
"type": "SHORT", | |||
"name": "branch-2", | |||
}, | |||
"pullRequests": Array [], | |||
}, | |||
@@ -69,9 +64,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "llb-1", | |||
"name": "slb-2", | |||
"type": "SHORT", | |||
"name": "branch-3", | |||
}, | |||
"pullRequests": Array [], | |||
}, | |||
@@ -201,8 +194,7 @@ exports[`should render correctly with no current branch like 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-1", | |||
"type": "LONG", | |||
"name": "branch-1", | |||
}, | |||
"pullRequests": Array [], | |||
}, | |||
@@ -211,8 +203,7 @@ exports[`should render correctly with no current branch like 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-2", | |||
"type": "LONG", | |||
"name": "branch-11", | |||
}, | |||
"pullRequests": Array [], | |||
}, | |||
@@ -221,8 +212,7 @@ exports[`should render correctly with no current branch like 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-3", | |||
"type": "LONG", | |||
"name": "branch-12", | |||
}, | |||
"pullRequests": Array [], | |||
}, | |||
@@ -231,9 +221,7 @@ exports[`should render correctly with no current branch like 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "slb-1", | |||
"type": "SHORT", | |||
"name": "branch-2", | |||
}, | |||
"pullRequests": Array [], | |||
}, | |||
@@ -242,9 +230,7 @@ exports[`should render correctly with no current branch like 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "llb-1", | |||
"name": "slb-2", | |||
"type": "SHORT", | |||
"name": "branch-3", | |||
}, | |||
"pullRequests": Array [], | |||
}, | |||
@@ -319,9 +305,7 @@ exports[`should render correctly with no current branch like 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "slb-1", | |||
"type": "SHORT", | |||
"name": "branch-11", | |||
} | |||
} | |||
/> |
@@ -146,8 +146,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-1", | |||
"type": "LONG", | |||
"name": "branch-1", | |||
} | |||
} | |||
component={ | |||
@@ -173,7 +172,7 @@ exports[`should render correctly 1`] = ` | |||
"tags": Array [], | |||
} | |||
} | |||
key="branch-llb-1" | |||
key="branch-branch-1" | |||
onSelect={[MockFunction]} | |||
selected={false} | |||
setSelectedNode={[Function]} | |||
@@ -185,8 +184,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-2", | |||
"type": "LONG", | |||
"name": "branch-11", | |||
} | |||
} | |||
component={ | |||
@@ -212,9 +210,9 @@ exports[`should render correctly 1`] = ` | |||
"tags": Array [], | |||
} | |||
} | |||
key="branch-llb-2" | |||
key="branch-branch-11" | |||
onSelect={[MockFunction]} | |||
selected={false} | |||
selected={true} | |||
setSelectedNode={[Function]} | |||
/> | |||
<hr /> | |||
@@ -224,8 +222,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"name": "llb-3", | |||
"type": "LONG", | |||
"name": "branch-12", | |||
} | |||
} | |||
component={ | |||
@@ -251,7 +248,7 @@ exports[`should render correctly 1`] = ` | |||
"tags": Array [], | |||
} | |||
} | |||
key="branch-llb-3" | |||
key="branch-branch-12" | |||
onSelect={[MockFunction]} | |||
selected={false} | |||
setSelectedNode={[Function]} | |||
@@ -263,9 +260,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "slb-1", | |||
"type": "SHORT", | |||
"name": "branch-2", | |||
} | |||
} | |||
component={ | |||
@@ -291,9 +286,9 @@ exports[`should render correctly 1`] = ` | |||
"tags": Array [], | |||
} | |||
} | |||
key="branch-slb-1" | |||
key="branch-branch-2" | |||
onSelect={[MockFunction]} | |||
selected={true} | |||
selected={false} | |||
setSelectedNode={[Function]} | |||
/> | |||
<hr /> | |||
@@ -303,9 +298,7 @@ exports[`should render correctly 1`] = ` | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "llb-1", | |||
"name": "slb-2", | |||
"type": "SHORT", | |||
"name": "branch-3", | |||
} | |||
} | |||
component={ | |||
@@ -331,7 +324,7 @@ exports[`should render correctly 1`] = ` | |||
"tags": Array [], | |||
} | |||
} | |||
key="branch-slb-2" | |||
key="branch-branch-3" | |||
onSelect={[MockFunction]} | |||
selected={false} | |||
setSelectedNode={[Function]} |
@@ -19,17 +19,11 @@ | |||
*/ | |||
import * as React from 'react'; | |||
import { Link } from 'react-router'; | |||
import LongLivingBranchIcon from 'sonar-ui-common/components/icons/LongLivingBranchIcon'; | |||
import BranchIcon from 'sonar-ui-common/components/icons/BranchIcon'; | |||
import PullRequestIcon from 'sonar-ui-common/components/icons/PullRequestIcon'; | |||
import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon'; | |||
import ShortLivingBranchIcon from 'sonar-ui-common/components/icons/ShortLivingBranchIcon'; | |||
import Organization from '../../../components/shared/Organization'; | |||
import { | |||
getLongLivingBranchUrl, | |||
getProjectUrl, | |||
getPullRequestUrl, | |||
getShortLivingBranchUrl | |||
} from '../../../helpers/urls'; | |||
import { getBranchUrl, getProjectUrl, getPullRequestUrl } from '../../../helpers/urls'; | |||
import TaskType from './TaskType'; | |||
interface Props { | |||
@@ -48,11 +42,10 @@ export default function TaskComponent({ task }: Props) { | |||
return ( | |||
<td> | |||
{task.branchType === 'SHORT' && <ShortLivingBranchIcon className="little-spacer-right" />} | |||
{task.branchType === 'LONG' && <LongLivingBranchIcon className="little-spacer-right" />} | |||
{task.branch !== undefined && <BranchIcon className="little-spacer-right" />} | |||
{task.pullRequest !== undefined && <PullRequestIcon className="little-spacer-right" />} | |||
{!task.branchType && !task.pullRequest && task.componentQualifier && ( | |||
{!task.branch && !task.pullRequest && task.componentQualifier && ( | |||
<span className="little-spacer-right"> | |||
<QualifierIcon qualifier={task.componentQualifier} /> | |||
</span> | |||
@@ -87,11 +80,7 @@ export default function TaskComponent({ task }: Props) { | |||
function getTaskComponentUrl(componentKey: string, task: T.Task) { | |||
if (task.branch) { | |||
if (task.branchType === 'SHORT') { | |||
return getShortLivingBranchUrl(componentKey, task.branch); | |||
} else if (task.branchType === 'LONG') { | |||
return getLongLivingBranchUrl(componentKey, task.branch); | |||
} | |||
return getBranchUrl(componentKey, task.branch); | |||
} else if (task.pullRequest) { | |||
return getPullRequestUrl(componentKey, task.pullRequest); | |||
} |
@@ -39,11 +39,7 @@ it('renders correctly', () => { | |||
}); | |||
it('renders correctly for branches and pullrequest', () => { | |||
expect( | |||
shallow(<TaskComponent task={{ ...TASK, branch: 'feature', branchType: 'SHORT' }} />) | |||
).toMatchSnapshot(); | |||
expect( | |||
shallow(<TaskComponent task={{ ...TASK, branch: 'branch-6.7', branchType: 'LONG' }} />) | |||
).toMatchSnapshot(); | |||
expect(shallow(<TaskComponent task={{ ...TASK, branch: 'feature' }} />)).toMatchSnapshot(); | |||
expect(shallow(<TaskComponent task={{ ...TASK, branch: 'branch-6.7' }} />)).toMatchSnapshot(); | |||
expect(shallow(<TaskComponent task={{ ...TASK, pullRequest: 'pr-89' }} />)).toMatchSnapshot(); | |||
}); |
@@ -49,7 +49,7 @@ exports[`renders correctly 2`] = ` | |||
exports[`renders correctly for branches and pullrequest 1`] = ` | |||
<td> | |||
<ShortLivingBranchIcon | |||
<BranchIcon | |||
className="little-spacer-right" | |||
/> | |||
<Connect(Organization) | |||
@@ -95,7 +95,7 @@ exports[`renders correctly for branches and pullrequest 1`] = ` | |||
exports[`renders correctly for branches and pullrequest 2`] = ` | |||
<td> | |||
<LongLivingBranchIcon | |||
<BranchIcon | |||
className="little-spacer-right" | |||
/> | |||
<Connect(Organization) |
@@ -18,7 +18,7 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import { getChildren } from '../../../api/components'; | |||
import { mockMainBranch, mockPullRequest } from '../../../helpers/testMocks'; | |||
import { mockMainBranch, mockPullRequest } from '../../../helpers/mocks/branch-like'; | |||
import { addComponent, addComponentChildren, getComponentBreadcrumbs } from '../bucket'; | |||
import { getCodeMetrics, loadMoreChildren, retrieveComponentChildren } from '../utils'; | |||
@@ -28,10 +28,11 @@ import ListFooter from 'sonar-ui-common/components/controls/ListFooter'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import A11ySkipTarget from '../../../app/components/a11y/A11ySkipTarget'; | |||
import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; | |||
import { isPullRequest, isSameBranchLike, isShortLivingBranch } from '../../../helpers/branches'; | |||
import { isPullRequest, isSameBranchLike } from '../../../helpers/branch-like'; | |||
import { getCodeUrl, getProjectUrl } from '../../../helpers/urls'; | |||
import { fetchBranchStatus, fetchMetrics } from '../../../store/rootActions'; | |||
import { getMetrics } from '../../../store/rootReducer'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { addComponent, addComponentBreadcrumbs, clearBucket } from '../bucket'; | |||
import '../code.css'; | |||
import { loadMoreChildren, retrieveComponent, retrieveComponentChildren } from '../utils'; | |||
@@ -45,12 +46,12 @@ interface StateToProps { | |||
} | |||
interface DispatchToProps { | |||
fetchBranchStatus: (branchLike: T.BranchLike, projectKey: string) => Promise<void>; | |||
fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>; | |||
fetchMetrics: () => void; | |||
} | |||
interface OwnProps { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
component: T.Component; | |||
location: Pick<Location, 'query'>; | |||
router: Pick<InjectedRouter, 'push'>; | |||
@@ -231,7 +232,7 @@ export class App extends React.PureComponent<Props, State> { | |||
refreshBranchStatus = () => { | |||
const { branchLike, component } = this.props; | |||
if (branchLike && component && (isPullRequest(branchLike) || isShortLivingBranch(branchLike))) { | |||
if (branchLike && component && isPullRequest(branchLike)) { | |||
this.props.fetchBranchStatus(branchLike, component.key); | |||
} | |||
}; |
@@ -18,10 +18,11 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import * as React from 'react'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import ComponentName from './ComponentName'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
breadcrumbs: T.Breadcrumb[]; | |||
rootComponent: T.ComponentMeasure; | |||
} |
@@ -21,12 +21,13 @@ import * as classNames from 'classnames'; | |||
import * as React from 'react'; | |||
import { withScrollTo } from '../../../components/hoc/withScrollTo'; | |||
import { WorkspaceContext } from '../../../components/workspace/context'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import ComponentMeasure from './ComponentMeasure'; | |||
import ComponentName from './ComponentName'; | |||
import ComponentPin from './ComponentPin'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
canBePinned?: boolean; | |||
canBrowse?: boolean; | |||
component: T.ComponentMeasure; |
@@ -19,11 +19,12 @@ | |||
*/ | |||
import * as React from 'react'; | |||
import { Link } from 'react-router'; | |||
import LongLivingBranchIcon from 'sonar-ui-common/components/icons/LongLivingBranchIcon'; | |||
import BranchIcon from 'sonar-ui-common/components/icons/BranchIcon'; | |||
import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import { colors } from '../../../app/theme'; | |||
import { getBranchLikeQuery } from '../../../helpers/branches'; | |||
import { getBranchLikeQuery } from '../../../helpers/branch-like'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
export function getTooltip(component: T.ComponentMeasure) { | |||
const isFile = component.qualifier === 'FIL' || component.qualifier === 'UTS'; | |||
@@ -50,7 +51,7 @@ export function mostCommonPrefix(strings: string[]) { | |||
} | |||
export interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
canBrowse?: boolean; | |||
component: T.ComponentMeasure; | |||
previous?: T.ComponentMeasure; | |||
@@ -115,7 +116,7 @@ export default function ComponentName({ | |||
</span> | |||
{component.branch ? ( | |||
<span className="text-ellipsis spacer-left"> | |||
<LongLivingBranchIcon className="little-spacer-right" /> | |||
<BranchIcon className="little-spacer-right" /> | |||
<span className="note">{component.branch}</span> | |||
</span> | |||
) : ( |
@@ -21,9 +21,10 @@ import * as React from 'react'; | |||
import PinIcon from 'sonar-ui-common/components/icons/PinIcon'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import { WorkspaceContextShape } from '../../../components/workspace/context'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
component: T.ComponentMeasure; | |||
openComponent: WorkspaceContextShape['openComponent']; | |||
} |
@@ -20,6 +20,7 @@ | |||
import { intersection } from 'lodash'; | |||
import * as React from 'react'; | |||
import withKeyboardNavigation from '../../../components/hoc/withKeyboardNavigation'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { getCodeMetrics } from '../utils'; | |||
import Component from './Component'; | |||
import ComponentsEmpty from './ComponentsEmpty'; | |||
@@ -27,7 +28,7 @@ import ComponentsHeader from './ComponentsHeader'; | |||
interface Props { | |||
baseComponent?: T.ComponentMeasure; | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
components: T.ComponentMeasure[]; | |||
metrics: T.Dict<T.Metric>; | |||
rootComponent: T.ComponentMeasure; |
@@ -23,10 +23,11 @@ import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import { getTree } from '../../../api/components'; | |||
import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; | |||
import { getBranchLikeQuery } from '../../../helpers/branches'; | |||
import { getBranchLikeQuery } from '../../../helpers/branch-like'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
component: T.ComponentMeasure; | |||
location: Location; | |||
onSearchClear: () => void; |
@@ -22,9 +22,10 @@ import * as React from 'react'; | |||
import { scrollToElement } from 'sonar-ui-common/helpers/scrolling'; | |||
import withKeyboardNavigation from '../../../components/hoc/withKeyboardNavigation'; | |||
import SourceViewer from '../../../components/SourceViewer/SourceViewer'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
component: string; | |||
componentMeasures: T.Measure[] | undefined; | |||
location: Pick<Location, 'query'>; |
@@ -20,7 +20,8 @@ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; | |||
import { mockIssue, mockPullRequest, mockRouter } from '../../../../helpers/testMocks'; | |||
import { mockPullRequest } from '../../../../helpers/mocks/branch-like'; | |||
import { mockIssue, mockRouter } from '../../../../helpers/testMocks'; | |||
import { retrieveComponent } from '../../utils'; | |||
import { App } from '../App'; | |||
@@ -19,7 +19,8 @@ | |||
*/ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { mockComponentMeasure, mockMainBranch } from '../../../../helpers/testMocks'; | |||
import { mockMainBranch } from '../../../../helpers/mocks/branch-like'; | |||
import { mockComponentMeasure } from '../../../../helpers/testMocks'; | |||
import ComponentName, { getTooltip, mostCommonPrefix, Props } from '../ComponentName'; | |||
describe('#getTooltip', () => { |
@@ -19,18 +19,13 @@ | |||
*/ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { mockBranch } from '../../../../helpers/mocks/branch-like'; | |||
import { Components } from '../Components'; | |||
const COMPONENT = { key: 'foo', name: 'Foo', qualifier: 'TRK' }; | |||
const PORTFOLIO = { key: 'bar', name: 'Bar', qualifier: 'VW' }; | |||
const METRICS = { coverage: { id: '1', key: 'coverage', type: 'PERCENT', name: 'Coverage' } }; | |||
const BRANCH: T.ShortLivingBranch = { | |||
isMain: false, | |||
excludedFromPurge: true, | |||
name: 'feature', | |||
mergeBranch: 'master', | |||
type: 'SHORT' | |||
}; | |||
const BRANCH = mockBranch({ name: 'feature' }); | |||
it('renders correctly', () => { | |||
expect( |
@@ -160,7 +160,7 @@ foo:src/index.tsx" | |||
<span | |||
className="text-ellipsis spacer-left" | |||
> | |||
<LongLivingBranchIcon | |||
<BranchIcon | |||
className="little-spacer-right" | |||
/> | |||
<span | |||
@@ -239,7 +239,7 @@ foo" | |||
<span | |||
className="text-ellipsis spacer-left" | |||
> | |||
<LongLivingBranchIcon | |||
<BranchIcon | |||
className="little-spacer-right" | |||
/> | |||
<span |
@@ -165,7 +165,11 @@ exports[`renders correctly for leak 1`] = ` | |||
} | |||
} | |||
canBePinned={true} | |||
metrics={Array []} | |||
metrics={ | |||
Array [ | |||
"coverage", | |||
] | |||
} | |||
rootComponent={ | |||
Object { | |||
"key": "foo", | |||
@@ -178,11 +182,10 @@ exports[`renders correctly for leak 1`] = ` | |||
<withScrollTo(Component) | |||
branchLike={ | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "feature", | |||
"type": "SHORT", | |||
} | |||
} | |||
canBePinned={true} | |||
@@ -194,7 +197,16 @@ exports[`renders correctly for leak 1`] = ` | |||
} | |||
} | |||
key="foo" | |||
metrics={Array []} | |||
metrics={ | |||
Array [ | |||
Object { | |||
"id": "1", | |||
"key": "coverage", | |||
"name": "Coverage", | |||
"type": "PERCENT", | |||
}, | |||
] | |||
} | |||
rootComponent={ | |||
Object { | |||
"key": "foo", | |||
@@ -212,7 +224,7 @@ exports[`renders correctly for leak 1`] = ` | |||
</td> | |||
<td | |||
colSpan={4} | |||
colSpan={5} | |||
> | |||
</td> | |||
@@ -222,11 +234,10 @@ exports[`renders correctly for leak 1`] = ` | |||
<withScrollTo(Component) | |||
branchLike={ | |||
Object { | |||
"analysisDate": "2018-01-01", | |||
"excludedFromPurge": true, | |||
"isMain": false, | |||
"mergeBranch": "master", | |||
"name": "feature", | |||
"type": "SHORT", | |||
} | |||
} | |||
canBePinned={true} | |||
@@ -239,7 +250,16 @@ exports[`renders correctly for leak 1`] = ` | |||
} | |||
} | |||
key="foo" | |||
metrics={Array []} | |||
metrics={ | |||
Array [ | |||
Object { | |||
"id": "1", | |||
"key": "coverage", | |||
"name": "Coverage", | |||
"type": "PERCENT", | |||
}, | |||
] | |||
} | |||
rootComponent={ | |||
Object { | |||
"key": "foo", | |||
@@ -255,7 +275,7 @@ exports[`renders correctly for leak 1`] = ` | |||
colSpan={3} | |||
/> | |||
<td | |||
colSpan={4} | |||
colSpan={5} | |||
/> | |||
</tr> | |||
</tbody> |
@@ -18,7 +18,8 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import { getBreadcrumbs, getChildren, getComponent } from '../../api/components'; | |||
import { getBranchLikeQuery, isPullRequest, isShortLivingBranch } from '../../helpers/branches'; | |||
import { getBranchLikeQuery, isPullRequest } from '../../helpers/branch-like'; | |||
import { BranchLike } from '../../types/branch-like'; | |||
import { | |||
addComponent, | |||
addComponentBreadcrumbs, | |||
@@ -75,8 +76,8 @@ function prepareChildren(r: any): Children { | |||
}; | |||
} | |||
export function showLeakMeasure(branchLike?: T.BranchLike) { | |||
return isShortLivingBranch(branchLike) || isPullRequest(branchLike); | |||
export function showLeakMeasure(branchLike?: BranchLike) { | |||
return isPullRequest(branchLike); | |||
} | |||
function skipRootDir(breadcrumbs: T.ComponentMeasure[]) { | |||
@@ -101,7 +102,7 @@ function storeChildrenBreadcrumbs(parentComponentKey: string, children: T.Breadc | |||
export function getCodeMetrics( | |||
qualifier: string, | |||
branchLike?: T.BranchLike, | |||
branchLike?: BranchLike, | |||
options: { includeQGStatus?: boolean } = {} | |||
) { | |||
if (['VW', 'SVW'].includes(qualifier)) { | |||
@@ -117,7 +118,7 @@ export function getCodeMetrics( | |||
return [...METRICS]; | |||
} | |||
function retrieveComponentBase(componentKey: string, qualifier: string, branchLike?: T.BranchLike) { | |||
function retrieveComponentBase(componentKey: string, qualifier: string, branchLike?: BranchLike) { | |||
const existing = getComponentFromBucket(componentKey); | |||
if (existing) { | |||
return Promise.resolve(existing); | |||
@@ -138,7 +139,7 @@ function retrieveComponentBase(componentKey: string, qualifier: string, branchLi | |||
export function retrieveComponentChildren( | |||
componentKey: string, | |||
qualifier: string, | |||
branchLike?: T.BranchLike | |||
branchLike?: BranchLike | |||
): Promise<{ components: T.ComponentMeasure[]; page: number; total: number }> { | |||
const existing = getComponentChildren(componentKey); | |||
if (existing) { | |||
@@ -167,7 +168,7 @@ export function retrieveComponentChildren( | |||
function retrieveComponentBreadcrumbs( | |||
component: string, | |||
branchLike?: T.BranchLike | |||
branchLike?: BranchLike | |||
): Promise<T.Breadcrumb[]> { | |||
const existing = getComponentBreadcrumbs(component); | |||
if (existing) { | |||
@@ -185,7 +186,7 @@ function retrieveComponentBreadcrumbs( | |||
export function retrieveComponent( | |||
componentKey: string, | |||
qualifier: string, | |||
branchLike?: T.BranchLike | |||
branchLike?: BranchLike | |||
): Promise<{ | |||
breadcrumbs: T.Breadcrumb[]; | |||
component: T.ComponentMeasure; | |||
@@ -212,7 +213,7 @@ export function loadMoreChildren( | |||
componentKey: string, | |||
page: number, | |||
qualifier: string, | |||
branchLike?: T.BranchLike | |||
branchLike?: BranchLike | |||
): Promise<Children> { | |||
const metrics = getCodeMetrics(qualifier, branchLike, { includeQGStatus: true }); | |||
@@ -40,14 +40,10 @@ import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; | |||
import ScreenPositionHelper from '../../../components/common/ScreenPositionHelper'; | |||
import { enhanceMeasure } from '../../../components/measure/utils'; | |||
import '../../../components/search-navigator.css'; | |||
import { | |||
getBranchLikeQuery, | |||
isPullRequest, | |||
isSameBranchLike, | |||
isShortLivingBranch | |||
} from '../../../helpers/branches'; | |||
import { getBranchLikeQuery, isPullRequest, isSameBranchLike } from '../../../helpers/branch-like'; | |||
import { getLeakPeriod } from '../../../helpers/periods'; | |||
import { fetchBranchStatus } from '../../../store/rootActions'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import Sidebar from '../sidebar/Sidebar'; | |||
import '../style.css'; | |||
import { | |||
@@ -68,9 +64,9 @@ import MeasureOverviewContainer from './MeasureOverviewContainer'; | |||
import MeasuresEmpty from './MeasuresEmpty'; | |||
interface Props extends WithRouterProps { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
component: T.ComponentMeasure; | |||
fetchBranchStatus: (branchLike: T.BranchLike, projectKey: string) => Promise<void>; | |||
fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>; | |||
} | |||
interface State { | |||
@@ -240,7 +236,7 @@ export class App extends React.PureComponent<Props, State> { | |||
refreshBranchStatus = () => { | |||
const { branchLike, component } = this.props; | |||
if (branchLike && component && (isPullRequest(branchLike) || isShortLivingBranch(branchLike))) { | |||
if (branchLike && component && isPullRequest(branchLike)) { | |||
this.props.fetchBranchStatus(branchLike, component.key); | |||
} | |||
}; | |||
@@ -270,7 +266,7 @@ export class App extends React.PureComponent<Props, State> { | |||
} | |||
const hideDrilldown = | |||
(isShortLivingBranch(branchLike) || isPullRequest(branchLike)) && | |||
isPullRequest(branchLike) && | |||
(metric.key === 'coverage' || metric.key === 'duplicated_lines_density'); | |||
if (hideDrilldown) { |
@@ -20,12 +20,13 @@ | |||
import * as key from 'keymaster'; | |||
import * as React from 'react'; | |||
import { getBreadcrumbs } from '../../../api/components'; | |||
import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches'; | |||
import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import Breadcrumb from './Breadcrumb'; | |||
interface Props { | |||
backToFirst: boolean; | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
className?: string; | |||
component: T.ComponentMeasure; | |||
handleSelect: (component: string) => void; |
@@ -26,9 +26,10 @@ import { getComponentTree } from '../../../api/components'; | |||
import { getMeasures } from '../../../api/measures'; | |||
import A11ySkipTarget from '../../../app/components/a11y/A11ySkipTarget'; | |||
import SourceViewer from '../../../components/SourceViewer/SourceViewer'; | |||
import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches'; | |||
import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like'; | |||
import { getPeriodValue, isDiffMetric } from '../../../helpers/measures'; | |||
import { getProjectUrl } from '../../../helpers/urls'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { complementary } from '../config/complementary'; | |||
import FilesView from '../drilldown/FilesView'; | |||
import TreeMapView from '../drilldown/TreeMapView'; | |||
@@ -39,7 +40,7 @@ import MeasureHeader from './MeasureHeader'; | |||
import MeasureViewSelect from './MeasureViewSelect'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
leakPeriod?: T.Period; | |||
requestedMetric: Pick<T.Metric, 'key' | 'direction'>; | |||
metrics: T.Dict<T.Metric>; |
@@ -27,11 +27,12 @@ import LanguageDistributionContainer from '../../../components/charts/LanguageDi | |||
import Measure from '../../../components/measure/Measure'; | |||
import { isDiffMetric } from '../../../helpers/measures'; | |||
import { getMeasureHistoryUrl } from '../../../helpers/urls'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { hasFullMeasures } from '../utils'; | |||
import LeakPeriodLegend from './LeakPeriodLegend'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
component: T.ComponentMeasure; | |||
leakPeriod?: T.Period; | |||
measureValue?: string; |
@@ -23,7 +23,8 @@ import PageActions from 'sonar-ui-common/components/ui/PageActions'; | |||
import { getComponentLeaves } from '../../../api/components'; | |||
import A11ySkipTarget from '../../../app/components/a11y/A11ySkipTarget'; | |||
import SourceViewer from '../../../components/SourceViewer/SourceViewer'; | |||
import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches'; | |||
import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import BubbleChart from '../drilldown/BubbleChart'; | |||
import { enhanceComponent, getBubbleMetrics, hasFullMeasures, isFileType } from '../utils'; | |||
import Breadcrumbs from './Breadcrumbs'; | |||
@@ -31,7 +32,7 @@ import LeakPeriodLegend from './LeakPeriodLegend'; | |||
import MeasureContentHeader from './MeasureContentHeader'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
className?: string; | |||
component: T.ComponentMeasure; | |||
domain: string; |
@@ -20,13 +20,14 @@ | |||
import * as React from 'react'; | |||
import { InjectedRouter } from 'react-router'; | |||
import { getComponentShow } from '../../../api/components'; | |||
import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches'; | |||
import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like'; | |||
import { getProjectUrl } from '../../../helpers/urls'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { isViewType, Query } from '../utils'; | |||
import MeasureOverview from './MeasureOverview'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
className?: string; | |||
domain: string; | |||
leakPeriod?: T.Period; |
@@ -21,14 +21,8 @@ import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; | |||
import { getMeasuresAndMeta } from '../../../../api/measures'; | |||
import { | |||
mockComponent, | |||
mockIssue, | |||
mockLocation, | |||
mockMainBranch, | |||
mockPullRequest, | |||
mockRouter | |||
} from '../../../../helpers/testMocks'; | |||
import { mockMainBranch, mockPullRequest } from '../../../../helpers/mocks/branch-like'; | |||
import { mockComponent, mockIssue, mockLocation, mockRouter } from '../../../../helpers/testMocks'; | |||
import { App } from '../App'; | |||
jest.mock('../../../../api/metrics', () => ({ |
@@ -19,6 +19,7 @@ | |||
*/ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { mockBranch } from '../../../../helpers/mocks/branch-like'; | |||
import MeasureHeader from '../MeasureHeader'; | |||
const METRIC = { | |||
@@ -64,31 +65,13 @@ it('should render correctly for leak', () => { | |||
).toMatchSnapshot(); | |||
}); | |||
it('should render with long living branch', () => { | |||
const longBranch: T.LongLivingBranch = { | |||
isMain: false, | |||
excludedFromPurge: true, | |||
name: 'branch-6.7', | |||
type: 'LONG' | |||
}; | |||
expect( | |||
shallow(<MeasureHeader branchLike={longBranch} {...PROPS} />).find('Link') | |||
).toMatchSnapshot(); | |||
}); | |||
it('should render with short living branch', () => { | |||
const shortBranch: T.ShortLivingBranch = { | |||
isMain: false, | |||
excludedFromPurge: true, | |||
name: 'feature', | |||
mergeBranch: 'master', | |||
type: 'SHORT' | |||
}; | |||
it('should render with a branch', () => { | |||
const branch = mockBranch({ name: 'feature' }); | |||
expect( | |||
shallow( | |||
<MeasureHeader | |||
{...PROPS} | |||
branchLike={shortBranch} | |||
branchLike={branch} | |||
measureValue={LEAK_MEASURE} | |||
metric={LEAK_METRIC} | |||
/> |
@@ -128,28 +128,7 @@ exports[`should render correctly for leak 1`] = ` | |||
</div> | |||
`; | |||
exports[`should render with long living branch 1`] = ` | |||
<Link | |||
className="js-show-history spacer-left button button-small" | |||
onlyActiveOnIndex={false} | |||
style={Object {}} | |||
to={ | |||
Object { | |||
"pathname": "/project/activity", | |||
"query": Object { | |||
"branch": "branch-6.7", | |||
"custom_metrics": "reliability_rating", | |||
"graph": "custom", | |||
"id": "foo", | |||
}, | |||
} | |||
} | |||
> | |||
<HistoryIcon /> | |||
</Link> | |||
`; | |||
exports[`should render with short living branch 1`] = ` | |||
exports[`should render with a branch 1`] = ` | |||
<div | |||
className="measure-details-header big-spacer-bottom" | |||
> | |||
@@ -169,6 +148,7 @@ exports[`should render with short living branch 1`] = ` | |||
> | |||
<strong> | |||
<Measure | |||
className="leak-box" | |||
metricKey="new_reliability_rating" | |||
metricType="RATING" | |||
value="3.0" | |||
@@ -178,7 +158,26 @@ exports[`should render with short living branch 1`] = ` | |||
</div> | |||
<div | |||
className="measure-details-primary-actions" | |||
/> | |||
> | |||
<InjectIntl(LeakPeriodLegend) | |||
className="spacer-left" | |||
component={ | |||
Object { | |||
"key": "foo", | |||
"name": "Foo", | |||
"qualifier": "TRK", | |||
} | |||
} | |||
period={ | |||
Object { | |||
"date": "2017-05-16T13:50:02+0200", | |||
"index": 1, | |||
"mode": "previous_version", | |||
"parameter": "6,4", | |||
} | |||
} | |||
/> | |||
</div> | |||
</div> | |||
</div> | |||
`; |
@@ -19,8 +19,8 @@ | |||
*/ | |||
import * as React from 'react'; | |||
import { Link } from 'react-router'; | |||
import BranchIcon from 'sonar-ui-common/components/icons/BranchIcon'; | |||
import LinkIcon from 'sonar-ui-common/components/icons/LinkIcon'; | |||
import LongLivingBranchIcon from 'sonar-ui-common/components/icons/LongLivingBranchIcon'; | |||
import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import { splitPath } from 'sonar-ui-common/helpers/path'; | |||
@@ -30,10 +30,11 @@ import { | |||
getComponentDrilldownUrlWithSelection, | |||
getProjectUrl | |||
} from '../../../helpers/urls'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { View } from '../utils'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
component: T.ComponentMeasureEnhanced; | |||
onClick: (component: string) => void; | |||
metric: T.Metric; | |||
@@ -76,7 +77,7 @@ export default class ComponentCell extends React.PureComponent<Props> { | |||
<> | |||
{component.branch ? ( | |||
<> | |||
<LongLivingBranchIcon className="spacer-left little-spacer-right" /> | |||
<BranchIcon className="spacer-left little-spacer-right" /> | |||
<span className="note">{component.branch}</span> | |||
</> | |||
) : ( |
@@ -19,13 +19,14 @@ | |||
*/ | |||
import * as React from 'react'; | |||
import { getLocalizedMetricName } from 'sonar-ui-common/helpers/l10n'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { complementary } from '../config/complementary'; | |||
import { View } from '../utils'; | |||
import ComponentsListRow from './ComponentsListRow'; | |||
import EmptyResult from './EmptyResult'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
components: T.ComponentMeasureEnhanced[]; | |||
onClick: (component: string) => void; | |||
metric: T.Metric; |
@@ -19,12 +19,13 @@ | |||
*/ | |||
import * as classNames from 'classnames'; | |||
import * as React from 'react'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { View } from '../utils'; | |||
import ComponentCell from './ComponentCell'; | |||
import MeasureCell from './MeasureCell'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
component: T.ComponentMeasureEnhanced; | |||
isSelected: boolean; | |||
onClick: (component: string) => void; |
@@ -27,11 +27,12 @@ import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n | |||
import { formatMeasure } from 'sonar-ui-common/helpers/measures'; | |||
import { scrollToElement } from 'sonar-ui-common/helpers/scrolling'; | |||
import { isDiffMetric, isPeriodBestValue } from '../../../helpers/measures'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { View } from '../utils'; | |||
import ComponentsList from './ComponentsList'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
components: T.ComponentMeasureEnhanced[]; | |||
defaultShowBestMeasures: boolean; | |||
fetchMore: () => void; |
@@ -33,10 +33,11 @@ import { isDefined } from 'sonar-ui-common/helpers/types'; | |||
import { colors } from '../../../app/theme'; | |||
import ColorBoxLegend from '../../../components/charts/ColorBoxLegend'; | |||
import { isDiffMetric } from '../../../helpers/measures'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import EmptyResult from './EmptyResult'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
components: T.ComponentMeasureEnhanced[]; | |||
handleSelect: (component: string) => void; | |||
metric: T.Metric; |
@@ -21,13 +21,9 @@ import { groupBy, memoize, sortBy, toPairs } from 'lodash'; | |||
import { getLocalizedMetricName } from 'sonar-ui-common/helpers/l10n'; | |||
import { cleanQuery, parseAsString, serializeString } from 'sonar-ui-common/helpers/query'; | |||
import { enhanceMeasure } from '../../components/measure/utils'; | |||
import { | |||
isLongLivingBranch, | |||
isMainBranch, | |||
isPullRequest, | |||
isShortLivingBranch | |||
} from '../../helpers/branches'; | |||
import { isBranch, isPullRequest } from '../../helpers/branch-like'; | |||
import { getDisplayMetrics, isDiffMetric } from '../../helpers/measures'; | |||
import { BranchLike } from '../../types/branch-like'; | |||
import { bubbles } from './config/bubbles'; | |||
import { domains } from './config/domains'; | |||
@@ -149,14 +145,14 @@ export function hasFacetStat(metric: string): boolean { | |||
return metric !== 'alert_status'; | |||
} | |||
export function hasFullMeasures(branch?: T.BranchLike) { | |||
return !branch || isLongLivingBranch(branch) || isMainBranch(branch); | |||
export function hasFullMeasures(branch?: BranchLike) { | |||
return !branch || isBranch(branch); | |||
} | |||
export function getMeasuresPageMetricKeys(metrics: T.Dict<T.Metric>, branch?: T.BranchLike) { | |||
export function getMeasuresPageMetricKeys(metrics: T.Dict<T.Metric>, branch?: BranchLike) { | |||
const metricKeys = getDisplayMetrics(Object.values(metrics)).map(metric => metric.key); | |||
if (isPullRequest(branch) || isShortLivingBranch(branch)) { | |||
if (isPullRequest(branch)) { | |||
return metricKeys.filter(key => isDiffMetric(key)); | |||
} else { | |||
return metricKeys; |
@@ -47,11 +47,11 @@ import { | |||
fillBranchLike, | |||
getBranchLikeQuery, | |||
isPullRequest, | |||
isSameBranchLike, | |||
isShortLivingBranch | |||
} from '../../../helpers/branches'; | |||
isSameBranchLike | |||
} from '../../../helpers/branch-like'; | |||
import { isSonarCloud } from '../../../helpers/system'; | |||
import { fetchBranchStatus } from '../../../store/rootActions'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import * as actions from '../actions'; | |||
import ConciseIssuesList from '../conciseIssuesList/ConciseIssuesList'; | |||
import ConciseIssuesListHeader from '../conciseIssuesList/ConciseIssuesListHeader'; | |||
@@ -99,10 +99,10 @@ interface FetchIssuesPromise { | |||
} | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
component?: T.Component; | |||
currentUser: T.CurrentUser; | |||
fetchBranchStatus: (branchLike: T.BranchLike, projectKey: string) => Promise<void>; | |||
fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>; | |||
fetchIssues: (query: T.RawQuery, requestOrganizations?: boolean) => Promise<FetchIssuesPromise>; | |||
hideAuthorFacet?: boolean; | |||
location: Pick<Location, 'pathname' | 'query'>; | |||
@@ -827,7 +827,7 @@ export class App extends React.PureComponent<Props, State> { | |||
handleReload = () => { | |||
this.fetchFirstIssues(); | |||
this.refreshBranchStatus(); | |||
if (isShortLivingBranch(this.props.branchLike) || isPullRequest(this.props.branchLike)) { | |||
if (isPullRequest(this.props.branchLike)) { | |||
this.props.onBranchesChange(); | |||
} | |||
}; | |||
@@ -880,7 +880,7 @@ export class App extends React.PureComponent<Props, State> { | |||
refreshBranchStatus = () => { | |||
const { branchLike, component } = this.props; | |||
if (branchLike && component && (isPullRequest(branchLike) || isShortLivingBranch(branchLike))) { | |||
if (branchLike && component && isPullRequest(branchLike)) { | |||
this.props.fetchBranchStatus(branchLike, component.key); | |||
} | |||
}; |
@@ -18,11 +18,12 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import * as React from 'react'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { Query, scrollToIssue } from '../utils'; | |||
import ListItem from './ListItem'; | |||
interface Props { | |||
branchLike: T.BranchLike | undefined; | |||
branchLike: BranchLike | undefined; | |||
checked: string[]; | |||
component: T.Component | undefined; | |||
issues: T.Issue[]; |
@@ -21,11 +21,12 @@ import { uniq } from 'lodash'; | |||
import * as React from 'react'; | |||
import { scrollToElement } from 'sonar-ui-common/helpers/scrolling'; | |||
import SourceViewer from '../../../components/SourceViewer/SourceViewer'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import CrossComponentSourceViewer from '../crossComponentSourceViewer/CrossComponentSourceViewer'; | |||
import { getLocations, getSelectedLocation } from '../utils'; | |||
interface Props { | |||
branchLike: T.BranchLike | undefined; | |||
branchLike: BranchLike | undefined; | |||
issues: T.Issue[]; | |||
loadIssues: (component: string, from: number, to: number) => Promise<T.Issue[]>; | |||
locationsNavigator: boolean; |
@@ -19,11 +19,12 @@ | |||
*/ | |||
import * as React from 'react'; | |||
import Issue from '../../../components/issue/Issue'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { Query } from '../utils'; | |||
import ComponentBreadcrumbs from './ComponentBreadcrumbs'; | |||
interface Props { | |||
branchLike: T.BranchLike | undefined; | |||
branchLike: BranchLike | undefined; | |||
checked: boolean; | |||
component: T.Component | undefined; | |||
issue: T.Issue; |
@@ -21,6 +21,7 @@ import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import handleRequiredAuthentication from 'sonar-ui-common/helpers/handleRequiredAuthentication'; | |||
import { KEYCODE_MAP, keydown, waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; | |||
import { mockPullRequest } from '../../../../helpers/mocks/branch-like'; | |||
import { | |||
mockComponent, | |||
mockCurrentUser, | |||
@@ -28,7 +29,6 @@ import { | |||
mockIssue, | |||
mockLocation, | |||
mockLoggedInUser, | |||
mockPullRequest, | |||
mockRouter | |||
} from '../../../../helpers/testMocks'; | |||
import { |
@@ -19,7 +19,8 @@ | |||
*/ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { mockIssue, mockMainBranch } from '../../../../helpers/testMocks'; | |||
import { mockMainBranch } from '../../../../helpers/mocks/branch-like'; | |||
import { mockIssue } from '../../../../helpers/testMocks'; | |||
import IssuesSourceViewer from '../IssuesSourceViewer'; | |||
it('should render SourceViewer correctly', () => { |
@@ -23,7 +23,8 @@ import { getSources } from '../../../api/components'; | |||
import getCoverageStatus from '../../../components/SourceViewer/helpers/getCoverageStatus'; | |||
import { locationsByLine } from '../../../components/SourceViewer/helpers/indexing'; | |||
import SourceViewerHeaderSlim from '../../../components/SourceViewer/SourceViewerHeaderSlim'; | |||
import { getBranchLikeQuery } from '../../../helpers/branches'; | |||
import { getBranchLikeQuery } from '../../../helpers/branch-like'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import SnippetViewer from './SnippetViewer'; | |||
import { | |||
createSnippets, | |||
@@ -34,7 +35,7 @@ import { | |||
} from './utils'; | |||
interface Props { | |||
branchLike: T.BranchLike | undefined; | |||
branchLike: BranchLike | undefined; | |||
duplications?: T.Duplication[]; | |||
duplicationsByLine?: { [line: number]: number[] }; | |||
highlightedLocationMessage: { index: number; text: string | undefined } | undefined; |
@@ -33,12 +33,13 @@ import { | |||
} from '../../../components/SourceViewer/helpers/indexing'; | |||
import { SourceViewerContext } from '../../../components/SourceViewer/SourceViewerContext'; | |||
import { WorkspaceContext } from '../../../components/workspace/context'; | |||
import { getBranchLikeQuery } from '../../../helpers/branches'; | |||
import { getBranchLikeQuery } from '../../../helpers/branch-like'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import ComponentSourceSnippetViewer from './ComponentSourceSnippetViewer'; | |||
import { groupLocationsByComponent } from './utils'; | |||
interface Props { | |||
branchLike: T.Branch | T.PullRequest | undefined; | |||
branchLike: BranchLike | undefined; | |||
highlightedLocationMessage?: { index: number; text: string | undefined }; | |||
issue: T.Issue; | |||
issues: T.Issue[]; |
@@ -30,10 +30,11 @@ import { | |||
optimizeLocationMessage, | |||
optimizeSelectedIssue | |||
} from '../../../components/SourceViewer/helpers/lines'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { inSnippet, LINES_BELOW_ISSUE } from './utils'; | |||
interface Props { | |||
branchLike: T.BranchLike | undefined; | |||
branchLike: BranchLike | undefined; | |||
component: T.SourceViewerFile; | |||
duplications?: T.Duplication[]; | |||
duplicationsByLine?: { [line: number]: number[] }; |
@@ -22,11 +22,10 @@ import { range, times } from 'lodash'; | |||
import * as React from 'react'; | |||
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; | |||
import { getSources } from '../../../../api/components'; | |||
import { mockBranch, mockMainBranch } from '../../../../helpers/mocks/branch-like'; | |||
import { | |||
mockFlowLocation, | |||
mockIssue, | |||
mockMainBranch, | |||
mockShortLivingBranch, | |||
mockSnippetsByComponent, | |||
mockSourceLine, | |||
mockSourceViewerFile | |||
@@ -144,7 +143,7 @@ it('should get the right branch when expanding', async () => { | |||
}; | |||
const wrapper = shallowRender({ | |||
branchLike: mockShortLivingBranch({ name: 'asdf' }), | |||
branchLike: mockBranch({ name: 'asdf' }), | |||
snippetGroup | |||
}); | |||
@@ -21,12 +21,8 @@ import { mount, shallow } from 'enzyme'; | |||
import { range } from 'lodash'; | |||
import * as React from 'react'; | |||
import { scrollHorizontally } from 'sonar-ui-common/helpers/scrolling'; | |||
import { | |||
mockIssue, | |||
mockMainBranch, | |||
mockSourceLine, | |||
mockSourceViewerFile | |||
} from '../../../../helpers/testMocks'; | |||
import { mockMainBranch } from '../../../../helpers/mocks/branch-like'; | |||
import { mockIssue, mockSourceLine, mockSourceViewerFile } from '../../../../helpers/testMocks'; | |||
import SnippetViewer from '../SnippetViewer'; | |||
jest.mock('sonar-ui-common/helpers/scrolling', () => ({ |
@@ -22,15 +22,16 @@ import { Button, ResetButtonLink } from 'sonar-ui-common/components/controls/but | |||
import Modal from 'sonar-ui-common/components/controls/Modal'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import CodeSnippet from '../../../components/common/CodeSnippet'; | |||
import { getBranchLikeQuery } from '../../../helpers/branches'; | |||
import { getBranchLikeQuery } from '../../../helpers/branch-like'; | |||
import { isSonarCloud } from '../../../helpers/system'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import BadgeButton from './BadgeButton'; | |||
import BadgeParams from './BadgeParams'; | |||
import './styles.css'; | |||
import { BadgeOptions, BadgeType, getBadgeSnippet, getBadgeUrl } from './utils'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
metrics: T.Dict<T.Metric>; | |||
project: string; | |||
qualifier: string; |
@@ -21,6 +21,7 @@ import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { click } from 'sonar-ui-common/helpers/testUtils'; | |||
import { Location } from 'sonar-ui-common/helpers/urls'; | |||
import { mockBranch } from '../../../../helpers/mocks/branch-like'; | |||
import { isSonarCloud } from '../../../../helpers/system'; | |||
import ProjectBadges from '../ProjectBadges'; | |||
@@ -35,13 +36,7 @@ jest.mock('../../../../helpers/urls', () => ({ | |||
jest.mock('../../../../helpers/system', () => ({ isSonarCloud: jest.fn() })); | |||
const shortBranch: T.ShortLivingBranch = { | |||
excludedFromPurge: true, | |||
isMain: false, | |||
mergeBranch: '', | |||
name: 'branch-6.6', | |||
type: 'SHORT' | |||
}; | |||
const shortBranch = mockBranch({ name: 'branch-6.6' }); | |||
it('should display the modal after click on sonarcloud', () => { | |||
(isSonarCloud as jest.Mock).mockImplementation(() => true); |
@@ -23,17 +23,18 @@ import { lazyLoad } from 'sonar-ui-common/components/lazyLoad'; | |||
import { getBaseUrl, getPathUrlAsString } from 'sonar-ui-common/helpers/urls'; | |||
import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; | |||
import { Router, withRouter } from '../../../components/hoc/withRouter'; | |||
import { isPullRequest, isShortLivingBranch } from '../../../helpers/branches'; | |||
import { isPullRequest } from '../../../helpers/branch-like'; | |||
import { isSonarCloud } from '../../../helpers/system'; | |||
import { getProjectUrl } from '../../../helpers/urls'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import OverviewApp from './OverviewApp'; | |||
const EmptyOverview = lazyLoad(() => import('./EmptyOverview')); | |||
const ReviewApp = lazyLoad(() => import('../pullRequests/ReviewApp')); | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLikes: T.BranchLike[]; | |||
branchLike?: BranchLike; | |||
branchLikes: BranchLike[]; | |||
component: T.Component; | |||
isInProgress?: boolean; | |||
isPending?: boolean; | |||
@@ -75,7 +76,7 @@ export class App extends React.PureComponent<Props> { | |||
</Helmet> | |||
)} | |||
{isShortLivingBranch(branchLike) || isPullRequest(branchLike) ? ( | |||
{isPullRequest(branchLike) ? ( | |||
<> | |||
<Suggestions suggestions="pull_requests" /> | |||
<ReviewApp branchLike={branchLike} component={component} /> |
@@ -25,9 +25,10 @@ import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n | |||
import { getApplicationLeak } from '../../../api/application'; | |||
import DateFromNow from '../../../components/intl/DateFromNow'; | |||
import DateTooltipFormatter from '../../../components/intl/DateTooltipFormatter'; | |||
import { Branch } from '../../../types/branch-like'; | |||
interface Props { | |||
branch?: T.LongLivingBranch; | |||
branch?: Branch; | |||
component: T.LightComponent; | |||
} | |||
@@ -22,17 +22,18 @@ import { FormattedMessage } from 'react-intl'; | |||
import { connect } from 'react-redux'; | |||
import { Alert } from 'sonar-ui-common/components/ui/Alert'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import { isBranch, isLongLivingBranch, isMainBranch } from '../../../helpers/branches'; | |||
import { isBranch, isMainBranch } from '../../../helpers/branch-like'; | |||
import { isSonarCloud } from '../../../helpers/system'; | |||
import { isLoggedIn } from '../../../helpers/users'; | |||
import { getCurrentUser, Store } from '../../../store/rootReducer'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import AnalyzeTutorial from '../../tutorials/analyzeProject/AnalyzeTutorial'; | |||
import AnalyzeTutorialSonarCloud from '../../tutorials/analyzeProject/AnalyzeTutorialSonarCloud'; | |||
import MetaContainer from '../meta/MetaContainer'; | |||
interface OwnProps { | |||
branchLike?: T.BranchLike; | |||
branchLikes: T.BranchLike[]; | |||
branchLike?: BranchLike; | |||
branchLikes: BranchLike[]; | |||
component: T.Component; | |||
hasAnalyses?: boolean; | |||
onComponentChange: (changes: {}) => void; | |||
@@ -55,7 +56,8 @@ export function EmptyOverview({ | |||
const hasBranches = branchLikes.length > 1; | |||
const hasBadBranchConfig = | |||
branchLikes.length > 2 || | |||
(branchLikes.length === 2 && branchLikes.some(branch => isLongLivingBranch(branch))); | |||
(branchLikes.length === 2 && | |||
branchLikes.some(branch => isBranch(branch) && !isMainBranch(branchLike))); | |||
return ( | |||
<div className="page page-limited"> | |||
<div className="overview page-with-sidebar"> | |||
@@ -106,7 +108,7 @@ export function WarningMessage({ | |||
branchLike, | |||
message | |||
}: { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
message: string; | |||
}) { | |||
if (!isBranch(branchLike)) { |
@@ -28,14 +28,15 @@ import A11ySkipTarget from '../../../app/components/a11y/A11ySkipTarget'; | |||
import { | |||
getBranchLikeDisplayName, | |||
getBranchLikeQuery, | |||
isLongLivingBranch, | |||
isBranch, | |||
isMainBranch, | |||
isSameBranchLike | |||
} from '../../../helpers/branches'; | |||
} from '../../../helpers/branch-like'; | |||
import { enhanceMeasuresWithMetrics } from '../../../helpers/measures'; | |||
import { getLeakPeriod } from '../../../helpers/periods'; | |||
import { fetchMetrics } from '../../../store/rootActions'; | |||
import { getMetrics, Store } from '../../../store/rootReducer'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import { | |||
DEFAULT_GRAPH, | |||
getDisplayedHistoryMetrics, | |||
@@ -53,7 +54,7 @@ import '../styles.css'; | |||
import { HISTORY_METRICS_LIST, METRICS } from '../utils'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
component: T.Component; | |||
fetchMetrics: () => void; | |||
onComponentChange: (changes: {}) => void; | |||
@@ -251,7 +252,7 @@ export class OverviewApp extends React.PureComponent<Props, State> { | |||
<div className="overview-main page-main"> | |||
{component.qualifier === 'APP' ? ( | |||
<ApplicationQualityGate | |||
branch={isLongLivingBranch(branchLike) ? branchLike : undefined} | |||
branch={isBranch(branchLike) && !isMainBranch(branchLike) ? branchLike : undefined} | |||
component={component} | |||
/> | |||
) : ( |
@@ -19,12 +19,8 @@ | |||
*/ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { | |||
mockComponent, | |||
mockLoggedInUser, | |||
mockMainBranch, | |||
mockPullRequest | |||
} from '../../../../helpers/testMocks'; | |||
import { mockMainBranch, mockPullRequest } from '../../../../helpers/mocks/branch-like'; | |||
import { mockComponent, mockLoggedInUser } from '../../../../helpers/testMocks'; | |||
import { EmptyOverview, WarningMessage } from '../EmptyOverview'; | |||
const branch = mockMainBranch(); |
@@ -22,13 +22,8 @@ import * as React from 'react'; | |||
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; | |||
import { getMeasuresAndMeta } from '../../../../api/measures'; | |||
import { getAllTimeMachineData } from '../../../../api/time-machine'; | |||
import { | |||
mockComponent, | |||
mockLongLivingBranch, | |||
mockMainBranch, | |||
mockMeasure, | |||
mockMetric | |||
} from '../../../../helpers/testMocks'; | |||
import { mockBranch, mockMainBranch } from '../../../../helpers/mocks/branch-like'; | |||
import { mockComponent, mockMeasure, mockMetric } from '../../../../helpers/testMocks'; | |||
import { OverviewApp } from '../OverviewApp'; | |||
jest.mock('../../../../api/measures', () => { | |||
@@ -111,7 +106,7 @@ it('should show the correct message if the project is empty', async () => { | |||
await waitAndUpdate(wrapper); | |||
expect(wrapper.find('h3').text()).toBe('overview.project.main_branch_empty'); | |||
wrapper.setProps({ branchLike: mockLongLivingBranch({ name: 'branch-foo' }) }); | |||
wrapper.setProps({ branchLike: mockBranch({ name: 'branch-foo' }) }); | |||
await waitAndUpdate(wrapper); | |||
expect(wrapper.find('h3').text()).toBe('overview.project.branch_X_empty.branch-foo'); | |||
@@ -133,7 +128,7 @@ it('should show the correct message if the project has no lines of code', async | |||
await waitAndUpdate(wrapper); | |||
expect(wrapper.find('h3').text()).toBe('overview.project.main_branch_no_lines_of_code'); | |||
wrapper.setProps({ branchLike: mockLongLivingBranch({ name: 'branch-foo' }) }); | |||
wrapper.setProps({ branchLike: mockBranch({ name: 'branch-foo' }) }); | |||
await waitAndUpdate(wrapper); | |||
expect(wrapper.find('h3').text()).toBe('overview.project.branch_X_no_lines_of_code.branch-foo'); | |||
@@ -22,12 +22,13 @@ import { Link } from 'react-router'; | |||
import { translate } from 'sonar-ui-common/helpers/l10n'; | |||
import { getProjectActivity } from '../../../api/projectActivity'; | |||
import PreviewGraph from '../../../components/preview-graph/PreviewGraph'; | |||
import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches'; | |||
import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like'; | |||
import { getActivityUrl } from '../../../helpers/urls'; | |||
import { BranchLike } from '../../../types/branch-like'; | |||
import Analysis from './Analysis'; | |||
interface Props { | |||
branchLike?: T.BranchLike; | |||
branchLike?: BranchLike; | |||
component: T.Component; | |||
history?: { | |||
[metric: string]: Array<{ date: Date; value?: string }>; |
@@ -19,11 +19,11 @@ | |||
*/ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { mockMainBranch } from '../../../../helpers/testMocks'; | |||
import { mockMainBranch } from '../../../../helpers/mocks/branch-like'; | |||
import AnalysesList from '../AnalysesList'; | |||
it('should render show more link', () => { | |||
const branchLike: T.MainBranch = mockMainBranch(); | |||
const branchLike = mockMainBranch(); | |||
const component = { | |||
breadcrumbs: [{ key: 'foo', name: 'foo', qualifier: 'TRK' }], | |||
key: 'foo', |
@@ -22,7 +22,7 @@ import BugIcon from 'sonar-ui-common/components/icons/BugIcon'; | |||
import { translateWithParameters } from 'sonar-ui-common/helpers/l10n'; | |||
import DocTooltip from '../../../components/docs/DocTooltip'; | |||
import DateFromNow from '../../../components/intl/DateFromNow'; | |||
import { isLongLivingBranch } from '../../../helpers/branches'; | |||
import { isBranch, isMainBranch } from '../../../helpers/branch-like'; | |||
import ApplicationLeakPeriodLegend from '../components/ApplicationLeakPeriodLegend'; | |||
import LeakPeriodLegend from '../components/LeakPeriodLegend'; | |||
import { getMetricName } from '../utils'; | |||
@@ -62,7 +62,7 @@ export class Bugs extends React.PureComponent<ComposedProps> { | |||
<div className="overview-domain-leak"> | |||
{component.qualifier === 'APP' ? ( | |||
<ApplicationLeakPeriodLegend | |||
branch={isLongLivingBranch(branchLike) ? branchLike : undefined} | |||
branch={isBranch(branchLike) && !isMainBranch(branchLike) ? branchLike : undefined} | |||
component={component} | |||
/> | |||
) : ( |
@@ -19,12 +19,8 @@ | |||
*/ | |||
import { shallow } from 'enzyme'; | |||
import * as React from 'react'; | |||
import { | |||
mockComponent, | |||
mockMainBranch, | |||
mockMeasureEnhanced, | |||
mockMetric | |||
} from '../../../../helpers/testMocks'; | |||
import { mockMainBranch } from '../../../../helpers/mocks/branch-like'; | |||
import { mockComponent, mockMeasureEnhanced, mockMetric } from '../../../../helpers/testMocks'; | |||
import Bugs from '../Bugs'; | |||
import { ComposedProps } from '../enhance'; | |||