diff options
730 files changed, 3945 insertions, 3014 deletions
diff --git a/server/sonar-web/src/main/js/api/alm-integrations.ts b/server/sonar-web/src/main/js/api/alm-integrations.ts index d2849f70b8a..c83b6772707 100644 --- a/server/sonar-web/src/main/js/api/alm-integrations.ts +++ b/server/sonar-web/src/main/js/api/alm-integrations.ts @@ -29,6 +29,7 @@ import { GithubRepository, GitlabProject } from '../types/alm-integration'; +import { Paging } from '../types/types'; import { ProjectBase } from './components'; export function setAlmPersonalAccessToken( @@ -198,7 +199,7 @@ export function getGithubRepositories(data: { pageSize: number; page?: number; query?: string; -}): Promise<{ repositories: GithubRepository[]; paging: T.Paging }> { +}): Promise<{ repositories: GithubRepository[]; paging: Paging }> { const { almSetting, organization, pageSize, page = 1, query } = data; return getJSON('/api/alm_integrations/list_github_repositories', { almSetting, @@ -214,7 +215,7 @@ export function getGitlabProjects(data: { page?: number; pageSize?: number; query?: string; -}): Promise<{ projects: GitlabProject[]; projectsPaging: T.Paging }> { +}): Promise<{ projects: GitlabProject[]; projectsPaging: Paging }> { const { almSetting, pageSize, page, query } = data; return getJSON('/api/alm_integrations/search_gitlab_repos', { almSetting, diff --git a/server/sonar-web/src/main/js/api/components.ts b/server/sonar-web/src/main/js/api/components.ts index 6d719bceaeb..53441bed474 100644 --- a/server/sonar-web/src/main/js/api/components.ts +++ b/server/sonar-web/src/main/js/api/components.ts @@ -21,6 +21,18 @@ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post, postJSON, RequestData } from '../helpers/request'; import { BranchParameters } from '../types/branch-like'; import { ComponentQualifier, TreeComponent, TreeComponentWithPath } from '../types/component'; +import { + ComponentMeasure, + Dict, + DuplicatedFile, + Duplication, + Metric, + MyProject, + Paging, + SourceLine, + SourceViewerFile, + Visibility +} from '../types/types'; export interface BaseSearchProjectsParameters { analyzedBefore?: string; @@ -28,14 +40,14 @@ export interface BaseSearchProjectsParameters { projects?: string; q?: string; qualifiers?: string; - visibility?: T.Visibility; + visibility?: Visibility; } export interface ProjectBase { key: string; name: string; qualifier: string; - visibility: T.Visibility; + visibility: Visibility; } export interface Project extends ProjectBase { @@ -52,7 +64,7 @@ export function getComponents( parameters: SearchProjectsParameters ): Promise<{ components: Project[]; - paging: T.Paging; + paging: Paging; }> { return getJSON('/api/projects/search', parameters); } @@ -74,7 +86,7 @@ export function deletePortfolio(portfolio: string): Promise<void | Response> { export function createProject(data: { name: string; project: string; - visibility?: T.Visibility; + visibility?: Visibility; }): Promise<{ project: ProjectBase }> { return postJSON('/api/projects/create', data).catch(throwGlobalError); } @@ -97,10 +109,10 @@ export function getComponentTree( metrics: string[] = [], additional: RequestData = {} ): Promise<{ - baseComponent: T.ComponentMeasure; - components: T.ComponentMeasure[]; - metrics: T.Metric[]; - paging: T.Paging; + baseComponent: ComponentMeasure; + components: ComponentMeasure[]; + metrics: Metric[]; + paging: Paging; }> { const url = '/api/measures/component_tree'; const data = { ...additional, component, metricKeys: metrics.join(','), strategy }; @@ -125,7 +137,7 @@ export function getComponentLeaves( export function getComponent( data: { component: string; metricKeys: string } & BranchParameters -): Promise<{ component: T.ComponentMeasure }> { +): Promise<{ component: ComponentMeasure }> { return getJSON('/api/measures/component', data); } @@ -141,7 +153,7 @@ type GetTreeParams = { export function getTree<T = TreeComponent>( data: GetTreeParams & { qualifiers?: string } -): Promise<{ baseComponent: TreeComponent; components: T[]; paging: T.Paging }> { +): Promise<{ baseComponent: TreeComponent; components: T[]; paging: Paging }> { return getJSON('/api/components/tree', data).catch(throwGlobalError); } @@ -184,7 +196,7 @@ export function getBreadcrumbs(data: { component: string } & BranchParameters): export function getMyProjects(data: { p?: number; ps?: number; -}): Promise<{ paging: T.Paging; projects: T.MyProject[] }> { +}): Promise<{ paging: Paging; projects: MyProject[] }> { return getJSON('/api/projects/search_my_projects', data); } @@ -196,7 +208,7 @@ export interface Component { analysisDate?: string; qualifier: ComponentQualifier; tags: string[]; - visibility: T.Visibility; + visibility: Visibility; leakPeriodDate?: string; needIssueSync?: boolean; } @@ -211,7 +223,7 @@ export function searchProjects( ): Promise<{ components: Component[]; facets: Facet[]; - paging: T.Paging; + paging: Paging; }> { const url = '/api/components/search_projects'; return getJSON(url, data); @@ -266,19 +278,19 @@ export function getSuggestions( export function getComponentForSourceViewer( data: { component: string } & BranchParameters -): Promise<T.SourceViewerFile> { +): Promise<SourceViewerFile> { return getJSON('/api/components/app', data); } export function getSources( data: { key: string; from?: number; to?: number } & BranchParameters -): Promise<T.SourceLine[]> { +): Promise<SourceLine[]> { return getJSON('/api/sources/lines', data).then(r => r.sources); } export function getDuplications( data: { key: string } & BranchParameters -): Promise<{ duplications: T.Duplication[]; files: T.Dict<T.DuplicatedFile> }> { +): Promise<{ duplications: Duplication[]; files: Dict<DuplicatedFile> }> { return getJSON('/api/duplications/show', data).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/issues.ts b/server/sonar-web/src/main/js/api/issues.ts index 47f94bf9fd4..b9260e3e903 100644 --- a/server/sonar-web/src/main/js/api/issues.ts +++ b/server/sonar-web/src/main/js/api/issues.ts @@ -21,6 +21,7 @@ import throwGlobalError from '../app/utils/throwGlobalError'; import getCoverageStatus from '../components/SourceViewer/helpers/getCoverageStatus'; import { getJSON, post, postJSON, RequestData } from '../helpers/request'; import { IssueResponse, RawIssuesResponse } from '../types/issues'; +import { Dict, FacetValue, IssueChangelog, SnippetsByComponent, SourceLine } from '../types/types'; type FacetName = | 'assigned_to_me' @@ -50,7 +51,7 @@ export function getFacets( query: RequestData, facets: FacetName[] ): Promise<{ - facets: Array<{ property: string; values: T.FacetValue[] }>; + facets: Array<{ property: string; values: FacetValue[] }>; response: RawIssuesResponse; }> { const data = { @@ -85,7 +86,7 @@ export function searchIssueTags(data: { .catch(throwGlobalError); } -export function getIssueChangelog(issue: string): Promise<{ changelog: T.IssueChangelog[] }> { +export function getIssueChangelog(issue: string): Promise<{ changelog: IssueChangelog[] }> { return getJSON('/api/issues/changelog', { issue }).catch(throwGlobalError); } @@ -143,12 +144,12 @@ export function searchIssueAuthors(data: { return getJSON('/api/issues/authors', data).then(r => r.authors, throwGlobalError); } -export function getIssueFlowSnippets(issueKey: string): Promise<T.Dict<T.SnippetsByComponent>> { +export function getIssueFlowSnippets(issueKey: string): Promise<Dict<SnippetsByComponent>> { return getJSON('/api/sources/issue_snippets', { issueKey }).then(result => { Object.keys(result).forEach(k => { if (result[k].sources) { result[k].sources = result[k].sources.reduce( - (lineMap: T.Dict<T.SourceLine>, line: T.SourceLine) => { + (lineMap: Dict<SourceLine>, line: SourceLine) => { line.coverageStatus = getCoverageStatus(line); lineMap[line.line] = line; return lineMap; diff --git a/server/sonar-web/src/main/js/api/languages.ts b/server/sonar-web/src/main/js/api/languages.ts index 603acf899ca..a0d2c0d8bd9 100644 --- a/server/sonar-web/src/main/js/api/languages.ts +++ b/server/sonar-web/src/main/js/api/languages.ts @@ -19,7 +19,8 @@ */ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON } from '../helpers/request'; +import { Language } from '../types/types'; -export function getLanguages(): Promise<T.Language[]> { +export function getLanguages(): Promise<Language[]> { return getJSON('/api/languages/list').then(r => r.languages, throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/measures.ts b/server/sonar-web/src/main/js/api/measures.ts index 482af37a61b..4930375e554 100644 --- a/server/sonar-web/src/main/js/api/measures.ts +++ b/server/sonar-web/src/main/js/api/measures.ts @@ -25,12 +25,13 @@ import { MeasuresAndMetaWithPeriod, MeasuresForProjects } from '../types/measures'; +import { Measure } from '../types/types'; const COMPONENT_URL = '/api/measures/component'; export function getMeasures( data: { component: string; metricKeys: string } & BranchParameters -): Promise<T.Measure[]> { +): Promise<Measure[]> { return getJSON(COMPONENT_URL, data).then(r => r.component.measures, throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/metrics.ts b/server/sonar-web/src/main/js/api/metrics.ts index b6230b51b7e..342c4df20bf 100644 --- a/server/sonar-web/src/main/js/api/metrics.ts +++ b/server/sonar-web/src/main/js/api/metrics.ts @@ -19,9 +19,10 @@ */ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON } from '../helpers/request'; +import { Metric } from '../types/types'; export interface MetricsResponse { - metrics: T.Metric[]; + metrics: Metric[]; p: number; ps: number; total: number; @@ -39,13 +40,13 @@ export function getAllMetrics(data?: { isCustom?: boolean; p?: number; ps?: number; -}): Promise<T.Metric[]> { +}): Promise<Metric[]> { return inner(data); function inner( data: { p?: number; ps?: number } = { ps: 500 }, prev?: MetricsResponse - ): Promise<T.Metric[]> { + ): Promise<Metric[]> { return getMetrics(data).then(r => { const result = prev ? prev.metrics.concat(r.metrics) : r.metrics; if (r.p * r.ps >= r.total) { diff --git a/server/sonar-web/src/main/js/api/nav.ts b/server/sonar-web/src/main/js/api/nav.ts index 8b89c9f4f89..df8599f8c45 100644 --- a/server/sonar-web/src/main/js/api/nav.ts +++ b/server/sonar-web/src/main/js/api/nav.ts @@ -20,8 +20,9 @@ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON } from '../helpers/request'; import { BranchParameters } from '../types/branch-like'; +import { Component } from '../types/types'; -type NavComponent = T.Omit<T.Component, 'alm' | 'qualifier' | 'leakPeriodDate' | 'path' | 'tags'>; +type NavComponent = Omit<Component, 'alm' | 'qualifier' | 'leakPeriodDate' | 'path' | 'tags'>; export function getComponentNavigation( data: { component: string } & BranchParameters diff --git a/server/sonar-web/src/main/js/api/newCodePeriod.ts b/server/sonar-web/src/main/js/api/newCodePeriod.ts index 60048a6fe0b..e3962b39e2d 100644 --- a/server/sonar-web/src/main/js/api/newCodePeriod.ts +++ b/server/sonar-web/src/main/js/api/newCodePeriod.ts @@ -19,18 +19,19 @@ */ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post } from '../helpers/request'; +import { NewCodePeriod, NewCodePeriodBranch, NewCodePeriodSettingType } from '../types/types'; export function getNewCodePeriod(data?: { project?: string; branch?: string; -}): Promise<T.Omit<T.NewCodePeriod, 'effectiveValue'>> { +}): Promise<Omit<NewCodePeriod, 'effectiveValue'>> { return getJSON('/api/new_code_periods/show', data).catch(throwGlobalError); } export function setNewCodePeriod(data: { project?: string; branch?: string; - type: T.NewCodePeriodSettingType; + type: NewCodePeriodSettingType; value?: string; }): Promise<void> { return post('/api/new_code_periods/set', data).catch(throwGlobalError); @@ -42,6 +43,6 @@ export function resetNewCodePeriod(data: { project?: string; branch?: string }): export function listBranchesNewCodePeriod(data: { project: string; -}): Promise<{ newCodePeriods: T.NewCodePeriodBranch[] }> { +}): Promise<{ newCodePeriods: NewCodePeriodBranch[] }> { return getJSON('/api/new_code_periods/list', data).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/notifications.ts b/server/sonar-web/src/main/js/api/notifications.ts index f6c3111c6a2..2dfd9f7a685 100644 --- a/server/sonar-web/src/main/js/api/notifications.ts +++ b/server/sonar-web/src/main/js/api/notifications.ts @@ -19,11 +19,12 @@ */ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post } from '../helpers/request'; +import { Notification } from '../types/types'; export function getNotifications(): Promise<{ channels: string[]; globalTypes: string[]; - notifications: T.Notification[]; + notifications: Notification[]; perProjectTypes: string[]; }> { return getJSON('/api/notifications/list').catch(throwGlobalError); diff --git a/server/sonar-web/src/main/js/api/permissions.ts b/server/sonar-web/src/main/js/api/permissions.ts index f2a726ee1cc..2f1b25ce8cb 100644 --- a/server/sonar-web/src/main/js/api/permissions.ts +++ b/server/sonar-web/src/main/js/api/permissions.ts @@ -19,6 +19,13 @@ */ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post, postJSON, RequestData } from '../helpers/request'; +import { + Paging, + PermissionGroup, + PermissionTemplate, + PermissionUser, + Visibility +} from '../types/types'; import { BaseSearchProjectsParameters } from './components'; const PAGE_SIZE = 100; @@ -56,7 +63,7 @@ export function revokePermissionFromGroup(data: { } interface GetPermissionTemplatesResponse { - permissionTemplates: T.PermissionTemplate[]; + permissionTemplates: PermissionTemplate[]; defaultTemplates: Array<{ templateId: string; qualifier: string }>; permissions: Array<{ key: string; name: string; description: string }>; } @@ -134,7 +141,7 @@ export function getPermissionsUsersForComponent(data: { permission?: string; p?: number; ps?: number; -}): Promise<{ paging: T.Paging; users: T.PermissionUser[] }> { +}): Promise<{ paging: Paging; users: PermissionUser[] }> { if (!data.ps) { data.ps = PAGE_SIZE; } @@ -147,7 +154,7 @@ export function getPermissionsGroupsForComponent(data: { permission?: string; p?: number; ps?: number; -}): Promise<{ paging: T.Paging; groups: T.PermissionGroup[] }> { +}): Promise<{ paging: Paging; groups: PermissionGroup[] }> { if (!data.ps) { data.ps = PAGE_SIZE; } @@ -159,7 +166,7 @@ export function getGlobalPermissionsUsers(data: { permission?: string; p?: number; ps?: number; -}): Promise<{ paging: T.Paging; users: T.PermissionUser[] }> { +}): Promise<{ paging: Paging; users: PermissionUser[] }> { if (!data.ps) { data.ps = PAGE_SIZE; } @@ -171,7 +178,7 @@ export function getGlobalPermissionsGroups(data: { permission?: string; p?: number; ps?: number; -}): Promise<{ paging: T.Paging; groups: T.PermissionGroup[] }> { +}): Promise<{ paging: Paging; groups: PermissionGroup[] }> { if (!data.ps) { data.ps = PAGE_SIZE; } @@ -210,13 +217,13 @@ export function getPermissionTemplateGroups( export function changeProjectVisibility( project: string, - visibility: T.Visibility + visibility: Visibility ): Promise<void | Response> { return post('/api/projects/update_visibility', { project, visibility }).catch(throwGlobalError); } export function changeProjectDefaultVisibility( - projectVisibility: T.Visibility + projectVisibility: Visibility ): Promise<void | Response> { return post('/api/projects/update_default_visibility', { projectVisibility }).catch( throwGlobalError diff --git a/server/sonar-web/src/main/js/api/projectActivity.ts b/server/sonar-web/src/main/js/api/projectActivity.ts index 4d12622b743..e43a6a95622 100644 --- a/server/sonar-web/src/main/js/api/projectActivity.ts +++ b/server/sonar-web/src/main/js/api/projectActivity.ts @@ -20,6 +20,7 @@ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post, postJSON, RequestData } from '../helpers/request'; import { BranchParameters } from '../types/branch-like'; +import { Analysis, Paging } from '../types/types'; export function getProjectActivity( data: { @@ -29,7 +30,7 @@ export function getProjectActivity( p?: number; ps?: number; } & BranchParameters -): Promise<{ analyses: T.Analysis[]; paging: T.Paging }> { +): Promise<{ analyses: Analysis[]; paging: Paging }> { return getJSON('/api/project_analyses/search', data).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/projectLinks.ts b/server/sonar-web/src/main/js/api/projectLinks.ts index a77b313f144..f1273863c87 100644 --- a/server/sonar-web/src/main/js/api/projectLinks.ts +++ b/server/sonar-web/src/main/js/api/projectLinks.ts @@ -19,8 +19,9 @@ */ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post, postJSON } from '../helpers/request'; +import { ProjectLink } from '../types/types'; -export function getProjectLinks(projectKey: string): Promise<T.ProjectLink[]> { +export function getProjectLinks(projectKey: string): Promise<ProjectLink[]> { return getJSON('/api/project_links/search', { projectKey }).then(r => r.links, throwGlobalError); } @@ -32,6 +33,6 @@ export function createLink(data: { name: string; projectKey: string; url: string; -}): Promise<T.ProjectLink> { +}): Promise<ProjectLink> { return postJSON('/api/project_links/create', data).then(r => r.link, throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/quality-gates.ts b/server/sonar-web/src/main/js/api/quality-gates.ts index 1c86cc84767..19dda5b4322 100644 --- a/server/sonar-web/src/main/js/api/quality-gates.ts +++ b/server/sonar-web/src/main/js/api/quality-gates.ts @@ -28,19 +28,20 @@ import { QualityGateProjectStatus, SearchPermissionsParameters } from '../types/quality-gates'; +import { Condition, Paging, QualityGate, UserBase } from '../types/types'; export function fetchQualityGates(): Promise<{ actions: { create: boolean }; - qualitygates: T.QualityGate[]; + qualitygates: QualityGate[]; }> { return getJSON('/api/qualitygates/list').catch(throwGlobalError); } -export function fetchQualityGate(data: { id: number | string }): Promise<T.QualityGate> { +export function fetchQualityGate(data: { id: number | string }): Promise<QualityGate> { return getJSON('/api/qualitygates/show', data).catch(throwGlobalError); } -export function createQualityGate(data: { name: string }): Promise<T.QualityGate> { +export function createQualityGate(data: { name: string }): Promise<QualityGate> { return postJSON('/api/qualitygates/create', data).catch(throwGlobalError); } @@ -52,7 +53,7 @@ export function renameQualityGate(data: { id: string; name: string }): Promise<v return post('/api/qualitygates/rename', data).catch(throwGlobalError); } -export function copyQualityGate(data: { id: string; name: string }): Promise<T.QualityGate> { +export function copyQualityGate(data: { id: string; name: string }): Promise<QualityGate> { return postJSON('/api/qualitygates/copy', data).catch(throwGlobalError); } @@ -63,12 +64,12 @@ export function setQualityGateAsDefault(data: { id: string }): Promise<void | Re export function createCondition( data: { gateId: string; - } & T.Omit<T.Condition, 'id'> -): Promise<T.Condition> { + } & Omit<Condition, 'id'> +): Promise<Condition> { return postJSON('/api/qualitygates/create_condition', data).catch(throwGlobalError); } -export function updateCondition(data: T.Condition): Promise<T.Condition> { +export function updateCondition(data: Condition): Promise<Condition> { return postJSON('/api/qualitygates/update_condition', data).catch(throwGlobalError); } @@ -76,7 +77,7 @@ export function deleteCondition(data: { id: number }): Promise<void> { return post('/api/qualitygates/delete_condition', data); } -export function getGateForProject(data: { project: string }): Promise<T.QualityGate | undefined> { +export function getGateForProject(data: { project: string }): Promise<QualityGate | undefined> { return getJSON('/api/qualitygates/get_by_project', data).then( ({ qualityGate }) => qualityGate && { @@ -94,7 +95,7 @@ export function searchProjects(data: { query?: string; selected?: string; }): Promise<{ - paging: T.Paging; + paging: Paging; results: Array<{ key: string; name: string; selected: boolean }>; }> { return getJSON('/api/qualitygates/search', data).catch(throwGlobalError); @@ -140,7 +141,7 @@ export function removeUser(data: AddDeleteUserPermissionsParameters) { return post('/api/qualitygates/remove_user', data).catch(throwGlobalError); } -export function searchUsers(data: SearchPermissionsParameters): Promise<{ users: T.UserBase[] }> { +export function searchUsers(data: SearchPermissionsParameters): Promise<{ users: UserBase[] }> { return getJSON('/api/qualitygates/search_users', data).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/quality-profiles.ts b/server/sonar-web/src/main/js/api/quality-profiles.ts index 551eb65e5c6..8b96a4eef77 100644 --- a/server/sonar-web/src/main/js/api/quality-profiles.ts +++ b/server/sonar-web/src/main/js/api/quality-profiles.ts @@ -22,6 +22,7 @@ import throwGlobalError from '../app/utils/throwGlobalError'; import { Exporter, ProfileChangelogEvent } from '../apps/quality-profiles/types'; import { csvEscape } from '../helpers/csv'; import { getJSON, post, postJSON, RequestData } from '../helpers/request'; +import { Dict, Paging, ProfileInheritanceDetails, UserSelected } from '../types/types'; export interface ProfileActions { associateProjects?: boolean; @@ -98,7 +99,7 @@ export interface ProfileProject { export function getProfileProjects( data: RequestData -): Promise<{ more: boolean; paging: T.Paging; results: ProfileProject[] }> { +): Promise<{ more: boolean; paging: Paging; results: ProfileProject[] }> { return getJSON('/api/qualityprofiles/projects', data).catch(throwGlobalError); } @@ -106,9 +107,9 @@ export function getProfileInheritance({ language, name: qualityProfile }: Profile): Promise<{ - ancestors: T.ProfileInheritanceDetails[]; - children: T.ProfileInheritanceDetails[]; - profile: T.ProfileInheritanceDetails; + ancestors: ProfileInheritanceDetails[]; + children: ProfileInheritanceDetails[]; + profile: ProfileInheritanceDetails; }> { return getJSON('/api/qualityprofiles/inheritance', { language, @@ -201,8 +202,8 @@ export interface CompareResponse { modified: Array<{ key: string; name: string; - left: { params: T.Dict<string>; severity: string }; - right: { params: T.Dict<string>; severity: string }; + left: { params: Dict<string>; severity: string }; + right: { params: Dict<string>; severity: string }; }>; } @@ -234,8 +235,8 @@ export interface SearchUsersGroupsParameters { } interface SearchUsersResponse { - users: T.UserSelected[]; - paging: T.Paging; + users: UserSelected[]; + paging: Paging; } export function searchUsers(parameters: SearchUsersGroupsParameters): Promise<SearchUsersResponse> { @@ -244,7 +245,7 @@ export function searchUsers(parameters: SearchUsersGroupsParameters): Promise<Se export interface SearchGroupsResponse { groups: Array<{ name: string }>; - paging: T.Paging; + paging: Paging; } export function searchGroups( @@ -314,7 +315,7 @@ export function bulkDeactivateRules(data: BulkActivateParameters) { export function activateRule(data: { key: string; - params?: T.Dict<string>; + params?: Dict<string>; reset?: boolean; rule: string; severity?: string; diff --git a/server/sonar-web/src/main/js/api/rules.ts b/server/sonar-web/src/main/js/api/rules.ts index cf22ee7fbcb..1fae18f0649 100644 --- a/server/sonar-web/src/main/js/api/rules.ts +++ b/server/sonar-web/src/main/js/api/rules.ts @@ -20,6 +20,7 @@ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post, postJSON } from '../helpers/request'; import { GetRulesAppResponse, SearchRulesResponse } from '../types/coding-rules'; +import { RuleActivation, RuleDetails } from '../types/types'; export function getRulesApp(): Promise<GetRulesAppResponse> { return getJSON('/api/rules/app').catch(throwGlobalError); @@ -73,7 +74,7 @@ export function getRuleRepositories(parameters: { export function getRuleDetails(parameters: { actives?: boolean; key: string; -}): Promise<{ actives?: T.RuleActivation[]; rule: T.RuleDetails }> { +}): Promise<{ actives?: RuleActivation[]; rule: RuleDetails }> { return getJSON('/api/rules/show', parameters).catch(throwGlobalError); } @@ -91,7 +92,7 @@ export function createRule(data: { status?: string; template_key: string; type?: string; -}): Promise<T.RuleDetails> { +}): Promise<RuleDetails> { return postJSON('/api/rules/create', data).then( r => r.rule, response => { @@ -122,6 +123,6 @@ export function updateRule(data: { severity?: string; status?: string; tags?: string; -}): Promise<T.RuleDetails> { +}): Promise<RuleDetails> { return postJSON('/api/rules/update', data).then(r => r.rule, throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/security-hotspots.ts b/server/sonar-web/src/main/js/api/security-hotspots.ts index ed6094e24f0..71ccfa9d1c8 100644 --- a/server/sonar-web/src/main/js/api/security-hotspots.ts +++ b/server/sonar-web/src/main/js/api/security-hotspots.ts @@ -29,6 +29,7 @@ import { HotspotSetStatusRequest, HotspotStatus } from '../types/security-hotspots'; +import { UserBase } from '../types/types'; const HOTSPOTS_SEARCH_URL = '/api/hotspots/search'; @@ -94,7 +95,7 @@ export function getSecurityHotspotList( export function getSecurityHotspotDetails(securityHotspotKey: string): Promise<Hotspot> { return getJSON('/api/hotspots/show', { hotspot: securityHotspotKey }) - .then((response: Hotspot & { users: T.UserBase[] }) => { + .then((response: Hotspot & { users: UserBase[] }) => { const { users, ...hotspot } = response; if (users) { diff --git a/server/sonar-web/src/main/js/api/system.ts b/server/sonar-web/src/main/js/api/system.ts index 7a613374ec3..28856dfe651 100644 --- a/server/sonar-web/src/main/js/api/system.ts +++ b/server/sonar-web/src/main/js/api/system.ts @@ -20,16 +20,17 @@ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post, postJSON, requestTryAndRepeatUntil } from '../helpers/request'; import { SystemUpgrade } from '../types/system'; +import { SysInfoCluster, SysInfoStandalone, SysStatus } from '../types/types'; export function setLogLevel(level: string): Promise<void | Response> { return post('/api/system/change_log_level', { level }).catch(throwGlobalError); } -export function getSystemInfo(): Promise<T.SysInfoCluster | T.SysInfoStandalone> { +export function getSystemInfo(): Promise<SysInfoCluster | SysInfoStandalone> { return getJSON('/api/system/info').catch(throwGlobalError); } -export function getSystemStatus(): Promise<{ id: string; version: string; status: T.SysStatus }> { +export function getSystemStatus(): Promise<{ id: string; version: string; status: SysStatus }> { return getJSON('/api/system/status'); } @@ -64,7 +65,7 @@ export function restart(): Promise<void | Response> { export function waitSystemUPStatus(): Promise<{ id: string; version: string; - status: T.SysStatus; + status: SysStatus; }> { return requestTryAndRepeatUntil( getSystemStatus, diff --git a/server/sonar-web/src/main/js/api/time-machine.ts b/server/sonar-web/src/main/js/api/time-machine.ts index 5ea6da6053f..25d327b665d 100644 --- a/server/sonar-web/src/main/js/api/time-machine.ts +++ b/server/sonar-web/src/main/js/api/time-machine.ts @@ -20,13 +20,14 @@ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON } from '../helpers/request'; import { BranchParameters } from '../types/branch-like'; +import { Paging } from '../types/types'; interface TimeMachineResponse { measures: { metric: string; history: Array<{ date: string; value?: string }>; }[]; - paging: T.Paging; + paging: Paging; } export function getTimeMachineData( diff --git a/server/sonar-web/src/main/js/api/user-tokens.ts b/server/sonar-web/src/main/js/api/user-tokens.ts index da711f55914..a0cac21841c 100644 --- a/server/sonar-web/src/main/js/api/user-tokens.ts +++ b/server/sonar-web/src/main/js/api/user-tokens.ts @@ -19,13 +19,14 @@ */ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post, postJSON } from '../helpers/request'; +import { NewUserToken, UserToken } from '../types/types'; /** List tokens for given user login */ -export function getTokens(login: string): Promise<T.UserToken[]> { +export function getTokens(login: string): Promise<UserToken[]> { return getJSON('/api/user_tokens/search', { login }).then(r => r.userTokens, throwGlobalError); } -export function generateToken(data: { name: string; login?: string }): Promise<T.NewUserToken> { +export function generateToken(data: { name: string; login?: string }): Promise<NewUserToken> { return postJSON('/api/user_tokens/generate', data).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/user_groups.ts b/server/sonar-web/src/main/js/api/user_groups.ts index bbb8e95a5f8..09ba9bad023 100644 --- a/server/sonar-web/src/main/js/api/user_groups.ts +++ b/server/sonar-web/src/main/js/api/user_groups.ts @@ -19,13 +19,14 @@ */ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post, postJSON } from '../helpers/request'; +import { Group, Paging, UserSelected } from '../types/types'; export function searchUsersGroups(data: { f?: string; p?: number; ps?: number; q?: string; -}): Promise<{ groups: T.Group[]; paging: T.Paging }> { +}): Promise<{ groups: Group[]; paging: Paging }> { return getJSON('/api/user_groups/search', data).catch(throwGlobalError); } @@ -36,7 +37,7 @@ export function getUsersInGroup(data: { ps?: number; q?: string; selected?: string; -}): Promise<T.Paging & { users: T.UserSelected[] }> { +}): Promise<Paging & { users: UserSelected[] }> { return getJSON('/api/user_groups/users', data).catch(throwGlobalError); } @@ -48,7 +49,7 @@ export function removeUserFromGroup(data: { id?: string; name?: string; login?: return post('/api/user_groups/remove_user', data).catch(throwGlobalError); } -export function createGroup(data: { description?: string; name: string }): Promise<T.Group> { +export function createGroup(data: { description?: string; name: string }): Promise<Group> { return postJSON('/api/user_groups/create', data).then(r => r.group, throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/users.ts b/server/sonar-web/src/main/js/api/users.ts index 73cee845733..575e72c986a 100644 --- a/server/sonar-web/src/main/js/api/users.ts +++ b/server/sonar-web/src/main/js/api/users.ts @@ -19,8 +19,16 @@ */ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post, postJSON } from '../helpers/request'; +import { + CurrentUser, + CurrentUserSetting, + HomePage, + IdentityProvider, + Paging, + User +} from '../types/types'; -export function getCurrentUser(): Promise<T.CurrentUser> { +export function getCurrentUser(): Promise<CurrentUser> { return getJSON('/api/users/current'); } @@ -46,11 +54,11 @@ export function getUserGroups(data: { ps?: number; q?: string; selected?: string; -}): Promise<{ paging: T.Paging; groups: UserGroup[] }> { +}): Promise<{ paging: Paging; groups: UserGroup[] }> { return getJSON('/api/users/groups', data); } -export function getIdentityProviders(): Promise<{ identityProviders: T.IdentityProvider[] }> { +export function getIdentityProviders(): Promise<{ identityProviders: IdentityProvider[] }> { return getJSON('/api/users/identity_providers').catch(throwGlobalError); } @@ -58,7 +66,7 @@ export function searchUsers(data: { p?: number; ps?: number; q?: string; -}): Promise<{ paging: T.Paging; users: T.User[] }> { +}): Promise<{ paging: Paging; users: User[] }> { data.q = data.q || undefined; return getJSON('/api/users/search', data).catch(throwGlobalError); } @@ -79,22 +87,22 @@ export function updateUser(data: { login: string; name?: string; scmAccount: string[]; -}): Promise<T.User> { +}): Promise<User> { return postJSON('/api/users/update', { ...data, scmAccount: data.scmAccount.length > 0 ? data.scmAccount : '' }); } -export function deactivateUser(data: { login: string }): Promise<T.User> { +export function deactivateUser(data: { login: string }): Promise<User> { return postJSON('/api/users/deactivate', data).catch(throwGlobalError); } -export function setHomePage(homepage: T.HomePage): Promise<void | Response> { +export function setHomePage(homepage: HomePage): Promise<void | Response> { return post('/api/users/set_homepage', homepage).catch(throwGlobalError); } -export function setUserSetting(setting: T.CurrentUserSetting): Promise<void | Response> { +export function setUserSetting(setting: CurrentUserSetting): Promise<void | Response> { return post('/api/users/set_setting', setting).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/web-api.ts b/server/sonar-web/src/main/js/api/web-api.ts index c5bd4d8a535..7ea902083be 100644 --- a/server/sonar-web/src/main/js/api/web-api.ts +++ b/server/sonar-web/src/main/js/api/web-api.ts @@ -19,9 +19,10 @@ */ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON } from '../helpers/request'; +import { WebApi } from '../types/types'; interface RawDomain { - actions: T.WebApi.Action[]; + actions: WebApi.Action[]; deprecatedSince?: string; description: string; internal: boolean; @@ -35,7 +36,7 @@ export function fetchWebApi(showInternal = true): Promise<RawDomain[]> { .catch(throwGlobalError); } -export function fetchResponseExample(domain: string, action: string): Promise<T.WebApi.Example> { +export function fetchResponseExample(domain: string, action: string): Promise<WebApi.Example> { return getJSON('/api/webservices/response_example', { controller: domain, action }).catch( throwGlobalError ); diff --git a/server/sonar-web/src/main/js/api/webhooks.ts b/server/sonar-web/src/main/js/api/webhooks.ts index 0cb8b283a77..2da2c594edb 100644 --- a/server/sonar-web/src/main/js/api/webhooks.ts +++ b/server/sonar-web/src/main/js/api/webhooks.ts @@ -19,13 +19,14 @@ */ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post, postJSON } from '../helpers/request'; +import { Paging, Webhook, WebhookDelivery } from '../types/types'; export function createWebhook(data: { name: string; project?: string; secret?: string; url: string; -}): Promise<{ webhook: T.Webhook }> { +}): Promise<{ webhook: Webhook }> { return postJSON('/api/webhooks/create', data).catch(throwGlobalError); } @@ -33,7 +34,7 @@ export function deleteWebhook(data: { webhook: string }): Promise<void | Respons return post('/api/webhooks/delete', data).catch(throwGlobalError); } -export function searchWebhooks(data: { project?: string }): Promise<{ webhooks: T.Webhook[] }> { +export function searchWebhooks(data: { project?: string }): Promise<{ webhooks: Webhook[] }> { return getJSON('/api/webhooks/list', data).catch(throwGlobalError); } @@ -53,14 +54,14 @@ export function searchDeliveries(data: { p?: number; ps?: number; }): Promise<{ - deliveries: T.WebhookDelivery[]; - paging: T.Paging; + deliveries: WebhookDelivery[]; + paging: Paging; }> { return getJSON('/api/webhooks/deliveries', data).catch(throwGlobalError); } export function getDelivery(data: { deliveryId: string; -}): Promise<{ delivery: T.WebhookDelivery & { payload: string } }> { +}): Promise<{ delivery: WebhookDelivery & { payload: string } }> { return getJSON('/api/webhooks/delivery', data).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/app/components/AdminContainer.tsx b/server/sonar-web/src/main/js/app/components/AdminContainer.tsx index 655061e58ec..d46f69d7701 100644 --- a/server/sonar-web/src/main/js/app/components/AdminContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/AdminContainer.tsx @@ -28,18 +28,19 @@ import { translate } from '../../helpers/l10n'; import { setAdminPages } from '../../store/appState'; import { getAppState, Store } from '../../store/rootReducer'; import { PendingPluginResult } from '../../types/plugins'; +import { AppState, Extension, SysStatus } from '../../types/types'; import AdminContext, { defaultPendingPlugins, defaultSystemStatus } from './AdminContext'; import SettingsNav from './nav/settings/SettingsNav'; interface Props { - appState: Pick<T.AppState, 'adminPages' | 'canAdmin'>; + appState: Pick<AppState, 'adminPages' | 'canAdmin'>; location: {}; - setAdminPages: (adminPages: T.Extension[]) => void; + setAdminPages: (adminPages: Extension[]) => void; } interface State { pendingPlugins: PendingPluginResult; - systemStatus: T.SysStatus; + systemStatus: SysStatus; } export class AdminContainer extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/app/components/AdminContext.tsx b/server/sonar-web/src/main/js/app/components/AdminContext.tsx index 20efcc7a98e..d0d4b32edca 100644 --- a/server/sonar-web/src/main/js/app/components/AdminContext.tsx +++ b/server/sonar-web/src/main/js/app/components/AdminContext.tsx @@ -19,12 +19,13 @@ */ import * as React from 'react'; import { PendingPluginResult } from '../../types/plugins'; +import { SysStatus } from '../../types/types'; export interface AdminContextInterface { fetchSystemStatus: () => void; fetchPendingPlugins: () => void; pendingPlugins: PendingPluginResult; - systemStatus: T.SysStatus; + systemStatus: SysStatus; } export const defaultPendingPlugins = { installing: [], removing: [], updating: [] }; diff --git a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx index ddf887c160e..8a156351d98 100644 --- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx @@ -43,16 +43,17 @@ import { import { BranchLike } from '../../types/branch-like'; import { ComponentQualifier, isPortfolioLike } from '../../types/component'; import { Task, TaskStatuses, TaskTypes, TaskWarning } from '../../types/tasks'; +import { AppState, Component, Status } from '../../types/types'; import ComponentContainerNotFound from './ComponentContainerNotFound'; import { ComponentContext } from './ComponentContext'; import PageUnavailableDueToIndexation from './indexation/PageUnavailableDueToIndexation'; import ComponentNav from './nav/component/ComponentNav'; interface Props { - appState: Pick<T.AppState, 'branchesEnabled'>; + appState: Pick<AppState, 'branchesEnabled'>; children: React.ReactElement; location: Pick<Location, 'query' | 'pathname'>; - registerBranchStatus: (branchLike: BranchLike, component: string, status: T.Status) => void; + registerBranchStatus: (branchLike: BranchLike, component: string, status: Status) => void; requireAuthorization: (router: Pick<Router, 'replace'>) => void; router: Pick<Router, 'replace'>; } @@ -60,7 +61,7 @@ interface Props { interface State { branchLike?: BranchLike; branchLikes: BranchLike[]; - component?: T.Component; + component?: Component; currentTask?: Task; isPending: boolean; loading: boolean; @@ -153,7 +154,7 @@ export class ComponentContainer extends React.PureComponent<Props, State> { } }; - fetchBranches = async (componentWithQualifier: T.Component) => { + fetchBranches = async (componentWithQualifier: Component) => { const breadcrumb = componentWithQualifier.breadcrumbs.find(({ qualifier }) => { return ([ComponentQualifier.Application, ComponentQualifier.Project] as string[]).includes( qualifier @@ -228,7 +229,7 @@ export class ComponentContainer extends React.PureComponent<Props, State> { ); }; - fetchWarnings = (component: T.Component, branchLike?: BranchLike) => { + fetchWarnings = (component: Component, branchLike?: BranchLike) => { if (component.qualifier === ComponentQualifier.Project) { getAnalysisStatus({ component: component.key, @@ -242,7 +243,7 @@ export class ComponentContainer extends React.PureComponent<Props, State> { } }; - fetchProjectBindingErrors = async (component: T.Component) => { + fetchProjectBindingErrors = async (component: Component) => { if ( component.qualifier === ComponentQualifier.Project && component.analysisDate === undefined && @@ -257,7 +258,7 @@ export class ComponentContainer extends React.PureComponent<Props, State> { } }; - addQualifier = (component: T.Component) => ({ + addQualifier = (component: Component) => ({ ...component, qualifier: component.breadcrumbs[component.breadcrumbs.length - 1].qualifier }); @@ -298,7 +299,7 @@ export class ComponentContainer extends React.PureComponent<Props, State> { newTasksInProgress: Task[], currentTask: Task | undefined, newCurrentTask: Task | undefined, - component: T.Component | undefined + component: Component | undefined ) => { const progressHasChanged = Boolean( tasksInProgress && @@ -329,7 +330,7 @@ export class ComponentContainer extends React.PureComponent<Props, State> { needsAnotherCheck = ( shouldFetchComponent: boolean, - component: T.Component | undefined, + component: Component | undefined, newTasksInProgress: Task[] ) => { return ( @@ -354,7 +355,7 @@ export class ComponentContainer extends React.PureComponent<Props, State> { return !task.branch && !task.pullRequest; }; - registerBranchStatuses = (branchLikes: BranchLike[], component: T.Component) => { + registerBranchStatuses = (branchLikes: BranchLike[], component: Component) => { branchLikes.forEach(branchLike => { if (branchLike.status) { this.props.registerBranchStatus( @@ -366,11 +367,11 @@ export class ComponentContainer extends React.PureComponent<Props, State> { }); }; - handleComponentChange = (changes: Partial<T.Component>) => { + handleComponentChange = (changes: Partial<Component>) => { if (this.mounted) { this.setState(state => { if (state.component) { - const newComponent: T.Component = { ...state.component, ...changes }; + const newComponent: Component = { ...state.component, ...changes }; return { component: newComponent }; } return null; diff --git a/server/sonar-web/src/main/js/app/components/ComponentContext.tsx b/server/sonar-web/src/main/js/app/components/ComponentContext.tsx index 6c04fc47149..d4f76af1aef 100644 --- a/server/sonar-web/src/main/js/app/components/ComponentContext.tsx +++ b/server/sonar-web/src/main/js/app/components/ComponentContext.tsx @@ -19,10 +19,11 @@ */ import * as React from 'react'; import { BranchLike } from '../../types/branch-like'; +import { Component } from '../../types/types'; interface ComponentContextType { branchLike: BranchLike | undefined; - component: T.Component | undefined; + component: Component | undefined; } export const ComponentContext = React.createContext<ComponentContextType>({ diff --git a/server/sonar-web/src/main/js/app/components/Landing.tsx b/server/sonar-web/src/main/js/app/components/Landing.tsx index cf30a1dc2a2..e83e6db014e 100644 --- a/server/sonar-web/src/main/js/app/components/Landing.tsx +++ b/server/sonar-web/src/main/js/app/components/Landing.tsx @@ -22,9 +22,10 @@ import { withCurrentUser } from '../../components/hoc/withCurrentUser'; import { Router, withRouter } from '../../components/hoc/withRouter'; import { getHomePageUrl } from '../../helpers/urls'; import { isLoggedIn } from '../../helpers/users'; +import { CurrentUser } from '../../types/types'; export interface LandingProps { - currentUser: T.CurrentUser; + currentUser: CurrentUser; router: Router; } diff --git a/server/sonar-web/src/main/js/app/components/NonAdminPagesContainer.tsx b/server/sonar-web/src/main/js/app/components/NonAdminPagesContainer.tsx index 52ba2178c46..0b43a747dc9 100644 --- a/server/sonar-web/src/main/js/app/components/NonAdminPagesContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/NonAdminPagesContainer.tsx @@ -22,12 +22,13 @@ import { Alert } from '../../components/ui/Alert'; import { translate } from '../../helpers/l10n'; import { BranchLike } from '../../types/branch-like'; import { isApplication } from '../../types/component'; +import { Component } from '../../types/types'; export interface NonAdminPagesContainerProps { children: JSX.Element; branchLike?: BranchLike; branchLikes: BranchLike[]; - component: T.Component; + component: Component; isInProgress?: boolean; isPending?: boolean; onBranchesChange: () => void; diff --git a/server/sonar-web/src/main/js/app/components/PluginRiskConsent.tsx b/server/sonar-web/src/main/js/app/components/PluginRiskConsent.tsx index fa61f086bbe..e13a73c357b 100644 --- a/server/sonar-web/src/main/js/app/components/PluginRiskConsent.tsx +++ b/server/sonar-web/src/main/js/app/components/PluginRiskConsent.tsx @@ -27,11 +27,12 @@ import { hasGlobalPermission } from '../../helpers/users'; import { Permissions } from '../../types/permissions'; import { RiskConsent } from '../../types/plugins'; import { SettingsKey } from '../../types/settings'; +import { LoggedInUser } from '../../types/types'; import GlobalMessagesContainer from './GlobalMessagesContainer'; import './PluginRiskConsent.css'; export interface PluginRiskConsentProps { - currentUser: T.LoggedInUser; + currentUser: LoggedInUser; router: Router; } diff --git a/server/sonar-web/src/main/js/app/components/ProjectAdminContainer.tsx b/server/sonar-web/src/main/js/app/components/ProjectAdminContainer.tsx index 4f5256a68c1..0f0f62a7cc3 100644 --- a/server/sonar-web/src/main/js/app/components/ProjectAdminContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/ProjectAdminContainer.tsx @@ -19,6 +19,7 @@ */ import * as React from 'react'; import { BranchLike } from '../../types/branch-like'; +import { Component } from '../../types/types'; import handleRequiredAuthorization from '../utils/handleRequiredAuthorization'; import A11ySkipTarget from './a11y/A11ySkipTarget'; @@ -26,7 +27,7 @@ interface Props { children: JSX.Element; branchLike?: BranchLike; branchLikes: BranchLike[]; - component: T.Component; + component: Component; isInProgress?: boolean; isPending?: boolean; onBranchesChange: () => void; diff --git a/server/sonar-web/src/main/js/app/components/ResetPassword.tsx b/server/sonar-web/src/main/js/app/components/ResetPassword.tsx index 2ae0a133426..39e92d7bc4d 100644 --- a/server/sonar-web/src/main/js/app/components/ResetPassword.tsx +++ b/server/sonar-web/src/main/js/app/components/ResetPassword.tsx @@ -22,10 +22,11 @@ import ResetPasswordForm from '../../components/common/ResetPasswordForm'; import { whenLoggedIn } from '../../components/hoc/whenLoggedIn'; import { translate } from '../../helpers/l10n'; import { getBaseUrl } from '../../helpers/system'; +import { LoggedInUser } from '../../types/types'; import GlobalMessagesContainer from './GlobalMessagesContainer'; export interface ResetPasswordProps { - currentUser: T.LoggedInUser; + currentUser: LoggedInUser; } export function ResetPassword({ currentUser }: ResetPasswordProps) { diff --git a/server/sonar-web/src/main/js/app/components/StartupModal.tsx b/server/sonar-web/src/main/js/app/components/StartupModal.tsx index 30c6dd2189f..1a8bfbdb0e7 100644 --- a/server/sonar-web/src/main/js/app/components/StartupModal.tsx +++ b/server/sonar-web/src/main/js/app/components/StartupModal.tsx @@ -29,6 +29,7 @@ import { get, save } from '../../helpers/storage'; import { isLoggedIn } from '../../helpers/users'; import { getAppState, getCurrentUser, Store } from '../../store/rootReducer'; import { EditionKey } from '../../types/editions'; +import { CurrentUser } from '../../types/types'; const LicensePromptModal = lazyLoadComponent( () => import('../../apps/marketplace/components/LicensePromptModal'), @@ -38,7 +39,7 @@ const LicensePromptModal = lazyLoadComponent( interface StateProps { canAdmin?: boolean; currentEdition?: EditionKey; - currentUser: T.CurrentUser; + currentUser: CurrentUser; } interface OwnProps { diff --git a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx index 89dc7822561..b57efcbeeba 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx @@ -33,6 +33,7 @@ import { waitAndUpdate } from '../../../helpers/testUtils'; import { AlmKeys } from '../../../types/alm-settings'; import { ComponentQualifier } from '../../../types/component'; import { TaskStatuses, TaskTypes } from '../../../types/tasks'; +import { Component } from '../../../types/types'; import { ComponentContainer } from '../ComponentContainer'; import PageUnavailableDueToIndexation from '../indexation/PageUnavailableDueToIndexation'; @@ -87,7 +88,7 @@ it('changes component', () => { const wrapper = shallowRender(); wrapper.setState({ branchLikes: [mockMainBranch()], - component: { qualifier: 'TRK', visibility: 'public' } as T.Component, + component: { qualifier: 'TRK', visibility: 'public' } as Component, loading: false }); diff --git a/server/sonar-web/src/main/js/app/components/__tests__/Landing-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/Landing-test.tsx index afb7e647292..445027a56d0 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/Landing-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/Landing-test.tsx @@ -21,6 +21,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { mockCurrentUser, mockLoggedInUser, mockRouter } from '../../../helpers/testMocks'; +import { CurrentUser } from '../../../types/types'; import { Landing } from '../Landing'; it.each([ @@ -30,7 +31,7 @@ it.each([ mockLoggedInUser({ homepage: { type: 'ISSUES' } }), expect.objectContaining({ pathname: '/issues' }) ] -])('should render correctly', (currentUser: T.CurrentUser, homepageUrl: string) => { +])('should render correctly', (currentUser: CurrentUser, homepageUrl: string) => { const router = mockRouter(); shallowRender({ router, currentUser }); expect(router.replace).toHaveBeenCalledWith(homepageUrl); diff --git a/server/sonar-web/src/main/js/app/components/__tests__/StartupModal-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/StartupModal-test.tsx index 79d76ac2f1f..66b38284f94 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/StartupModal-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/StartupModal-test.tsx @@ -26,6 +26,7 @@ import { hasMessage } from '../../../helpers/l10n'; import { get, save } from '../../../helpers/storage'; import { waitAndUpdate } from '../../../helpers/testUtils'; import { EditionKey } from '../../../types/editions'; +import { LoggedInUser } from '../../../types/types'; import { StartupModal } from '../StartupModal'; jest.mock('../../../api/marketplace', () => ({ @@ -48,7 +49,7 @@ jest.mock('../../../helpers/dates', () => ({ jest.mock('date-fns', () => ({ differenceInDays: jest.fn().mockReturnValue(1) })); -const LOGGED_IN_USER: T.LoggedInUser = { +const LOGGED_IN_USER: LoggedInUser = { groups: [], isLoggedIn: true, login: 'luke', diff --git a/server/sonar-web/src/main/js/app/components/a11y/A11yContext.tsx b/server/sonar-web/src/main/js/app/components/a11y/A11yContext.tsx index 7ce06095713..fc77dcc865f 100644 --- a/server/sonar-web/src/main/js/app/components/a11y/A11yContext.tsx +++ b/server/sonar-web/src/main/js/app/components/a11y/A11yContext.tsx @@ -18,11 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { createContext } from 'react'; +import { A11ySkipLink } from '../../../types/types'; export interface A11yContextShape { - addA11ySkipLink: (link: T.A11ySkipLink) => void; - removeA11ySkipLink: (link: T.A11ySkipLink) => void; - links: T.A11ySkipLink[]; + addA11ySkipLink: (link: A11ySkipLink) => void; + removeA11ySkipLink: (link: A11ySkipLink) => void; + links: A11ySkipLink[]; } export const A11yContext = createContext<A11yContextShape>({ diff --git a/server/sonar-web/src/main/js/app/components/a11y/A11yProvider.tsx b/server/sonar-web/src/main/js/app/components/a11y/A11yProvider.tsx index 7cf824997af..94878df365b 100644 --- a/server/sonar-web/src/main/js/app/components/a11y/A11yProvider.tsx +++ b/server/sonar-web/src/main/js/app/components/a11y/A11yProvider.tsx @@ -19,17 +19,18 @@ */ import { sortBy } from 'lodash'; import * as React from 'react'; +import { A11ySkipLink } from '../../../types/types'; import { A11yContext } from './A11yContext'; interface State { - links: T.A11ySkipLink[]; + links: A11ySkipLink[]; } export default class A11yProvider extends React.Component<{}, State> { keys: string[] = []; state: State = { links: [] }; - addA11ySkipLink = (link: T.A11ySkipLink) => { + addA11ySkipLink = (link: A11ySkipLink) => { this.setState(prevState => { const links = [...prevState.links]; links.push({ ...link, weight: link.weight || 0 }); @@ -37,7 +38,7 @@ export default class A11yProvider extends React.Component<{}, State> { }); }; - removeA11ySkipLink = (link: T.A11ySkipLink) => { + removeA11ySkipLink = (link: A11ySkipLink) => { this.setState(prevState => { const links = prevState.links.filter(l => l.key !== link.key); return { links }; diff --git a/server/sonar-web/src/main/js/app/components/a11y/A11ySkipTarget.tsx b/server/sonar-web/src/main/js/app/components/a11y/A11ySkipTarget.tsx index 59775b7e133..ba6eed44866 100644 --- a/server/sonar-web/src/main/js/app/components/a11y/A11ySkipTarget.tsx +++ b/server/sonar-web/src/main/js/app/components/a11y/A11ySkipTarget.tsx @@ -19,6 +19,7 @@ */ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; +import { A11ySkipLink } from '../../../types/types'; import { A11yContext } from './A11yContext'; interface Props { @@ -42,8 +43,8 @@ export default function A11ySkipTarget(props: Props) { } interface InnerProps { - addA11ySkipLink: (link: T.A11ySkipLink) => void; - removeA11ySkipLink: (link: T.A11ySkipLink) => void; + addA11ySkipLink: (link: A11ySkipLink) => void; + removeA11ySkipLink: (link: A11ySkipLink) => void; } export class A11ySkipTargetInner extends React.PureComponent<Props & InnerProps> { @@ -55,7 +56,7 @@ export class A11ySkipTargetInner extends React.PureComponent<Props & InnerProps> this.props.removeA11ySkipLink(this.getLink()); } - getLink = (): T.A11ySkipLink => { + getLink = (): A11ySkipLink => { const { anchor: key, label = translate('skip_to_content'), weight } = this.props; return { key, label, weight }; }; diff --git a/server/sonar-web/src/main/js/app/components/embed-docs-modal/EmbedDocsPopup.tsx b/server/sonar-web/src/main/js/app/components/embed-docs-modal/EmbedDocsPopup.tsx index d924b95db37..ad28ea1fae7 100644 --- a/server/sonar-web/src/main/js/app/components/embed-docs-modal/EmbedDocsPopup.tsx +++ b/server/sonar-web/src/main/js/app/components/embed-docs-modal/EmbedDocsPopup.tsx @@ -22,6 +22,7 @@ import { Link } from 'react-router'; import { DropdownOverlay } from '../../../components/controls/Dropdown'; import { translate } from '../../../helpers/l10n'; import { getBaseUrl } from '../../../helpers/system'; +import { SuggestionLink } from '../../../types/types'; import { SuggestionsContext } from './SuggestionsContext'; interface Props { @@ -33,7 +34,7 @@ export default class EmbedDocsPopup extends React.PureComponent<Props> { return <li className="menu-header">{text}</li>; } - renderSuggestions = ({ suggestions }: { suggestions: T.SuggestionLink[] }) => { + renderSuggestions = ({ suggestions }: { suggestions: SuggestionLink[] }) => { if (suggestions.length === 0) { return null; } diff --git a/server/sonar-web/src/main/js/app/components/embed-docs-modal/SuggestionsContext.ts b/server/sonar-web/src/main/js/app/components/embed-docs-modal/SuggestionsContext.ts index 10df414861b..1309f651165 100644 --- a/server/sonar-web/src/main/js/app/components/embed-docs-modal/SuggestionsContext.ts +++ b/server/sonar-web/src/main/js/app/components/embed-docs-modal/SuggestionsContext.ts @@ -18,11 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { createContext } from 'react'; +import { SuggestionLink } from '../../../types/types'; interface SuggestionsContextShape { addSuggestions: (key: string) => void; removeSuggestions: (key: string) => void; - suggestions: T.SuggestionLink[]; + suggestions: SuggestionLink[]; } export const SuggestionsContext = createContext<SuggestionsContextShape>({ diff --git a/server/sonar-web/src/main/js/app/components/embed-docs-modal/SuggestionsProvider.tsx b/server/sonar-web/src/main/js/app/components/embed-docs-modal/SuggestionsProvider.tsx index 969173db085..dee13bfe4d1 100644 --- a/server/sonar-web/src/main/js/app/components/embed-docs-modal/SuggestionsProvider.tsx +++ b/server/sonar-web/src/main/js/app/components/embed-docs-modal/SuggestionsProvider.tsx @@ -20,12 +20,13 @@ import suggestionsJson from 'Docs/EmbedDocsSuggestions.json'; import * as React from 'react'; import { isSonarCloud } from '../../../helpers/system'; +import { Dict, SuggestionLink } from '../../../types/types'; import { SuggestionsContext } from './SuggestionsContext'; -type SuggestionsJson = T.Dict<T.SuggestionLink[]>; +type SuggestionsJson = Dict<SuggestionLink[]>; interface State { - suggestions: T.SuggestionLink[]; + suggestions: SuggestionLink[]; } export default class SuggestionsProvider extends React.Component<{}, State> { @@ -34,7 +35,7 @@ export default class SuggestionsProvider extends React.Component<{}, State> { fetchSuggestions = () => { const jsonList = suggestionsJson as SuggestionsJson; - let suggestions: T.SuggestionLink[] = []; + let suggestions: SuggestionLink[] = []; this.keys.forEach(key => { if (jsonList[key]) { suggestions = [...jsonList[key], ...suggestions]; diff --git a/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx b/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx index 8d4e5dea4ea..8d82d94ba3d 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx +++ b/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx @@ -28,15 +28,16 @@ import { getBaseUrl } from '../../../helpers/system'; import { addGlobalErrorMessage } from '../../../store/globalMessages'; import { getCurrentUser, Store } from '../../../store/rootReducer'; import { ExtensionStartMethod } from '../../../types/extension'; +import { CurrentUser, Dict, Extension as TypeExtension } from '../../../types/types'; import * as theme from '../../theme'; import getStore from '../../utils/getStore'; interface Props extends WrappedComponentProps { - currentUser: T.CurrentUser; - extension: T.Extension; + currentUser: CurrentUser; + extension: TypeExtension; location: Location; onFail: (message: string) => void; - options?: T.Dict<any>; + options?: Dict<any>; router: Router; } diff --git a/server/sonar-web/src/main/js/app/components/extensions/GlobalAdminPageExtension.tsx b/server/sonar-web/src/main/js/app/components/extensions/GlobalAdminPageExtension.tsx index 136b8ba0363..0cfce78a66b 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/GlobalAdminPageExtension.tsx +++ b/server/sonar-web/src/main/js/app/components/extensions/GlobalAdminPageExtension.tsx @@ -20,11 +20,12 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { getAppState, Store } from '../../../store/rootReducer'; +import { Extension as TypeExtension } from '../../../types/types'; import NotFound from '../NotFound'; import Extension from './Extension'; interface Props { - adminPages: T.Extension[] | undefined; + adminPages: TypeExtension[] | undefined; params: { extensionKey: string; pluginKey: string }; } diff --git a/server/sonar-web/src/main/js/app/components/extensions/GlobalPageExtension.tsx b/server/sonar-web/src/main/js/app/components/extensions/GlobalPageExtension.tsx index 5f0e1b1aee0..6d241c737c2 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/GlobalPageExtension.tsx +++ b/server/sonar-web/src/main/js/app/components/extensions/GlobalPageExtension.tsx @@ -20,11 +20,12 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { getAppState, Store } from '../../../store/rootReducer'; +import { Extension as TypeExtension } from '../../../types/types'; import NotFound from '../NotFound'; import Extension from './Extension'; interface Props { - globalPages: T.Extension[] | undefined; + globalPages: TypeExtension[] | undefined; params: { extensionKey: string; pluginKey: string }; } diff --git a/server/sonar-web/src/main/js/app/components/extensions/PortfolioPage.tsx b/server/sonar-web/src/main/js/app/components/extensions/PortfolioPage.tsx index 24b95c4f8b5..7cb9ebfa62b 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/PortfolioPage.tsx +++ b/server/sonar-web/src/main/js/app/components/extensions/PortfolioPage.tsx @@ -20,11 +20,12 @@ import * as React from 'react'; import { WithRouterProps } from 'react-router'; import withIndexationGuard from '../../../components/hoc/withIndexationGuard'; +import { Component } from '../../../types/types'; import { PageContext } from '../indexation/PageUnavailableDueToIndexation'; import ProjectPageExtension from './ProjectPageExtension'; export interface PortfolioPageProps extends WithRouterProps { - component: T.Component; + component: Component; } export function PortfolioPage({ component, location }: PortfolioPageProps) { diff --git a/server/sonar-web/src/main/js/app/components/extensions/ProjectAdminPageExtension.tsx b/server/sonar-web/src/main/js/app/components/extensions/ProjectAdminPageExtension.tsx index 9c3dede7d2f..c0de02046e7 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/ProjectAdminPageExtension.tsx +++ b/server/sonar-web/src/main/js/app/components/extensions/ProjectAdminPageExtension.tsx @@ -21,11 +21,12 @@ import { Location } from 'history'; import * as React from 'react'; import { connect } from 'react-redux'; import { addGlobalErrorMessage } from '../../../store/globalMessages'; +import { Component } from '../../../types/types'; import NotFound from '../NotFound'; import Extension from './Extension'; export interface ProjectAdminPageExtensionProps { - component: T.Component; + component: Component; location: Location; params: { extensionKey: string; pluginKey: string }; } diff --git a/server/sonar-web/src/main/js/app/components/extensions/ProjectPageExtension.tsx b/server/sonar-web/src/main/js/app/components/extensions/ProjectPageExtension.tsx index 756bae9d23f..2e61a8461cf 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/ProjectPageExtension.tsx +++ b/server/sonar-web/src/main/js/app/components/extensions/ProjectPageExtension.tsx @@ -19,12 +19,13 @@ */ import * as React from 'react'; import { BranchLike } from '../../../types/branch-like'; +import { Component } from '../../../types/types'; import NotFound from '../NotFound'; import Extension from './Extension'; export interface ProjectPageExtensionProps { branchLike?: BranchLike; - component: T.Component; + component: Component; location: { query: { id: string } }; params: { extensionKey: string; diff --git a/server/sonar-web/src/main/js/app/components/indexation/IndexationContextProvider.tsx b/server/sonar-web/src/main/js/app/components/indexation/IndexationContextProvider.tsx index 699a502505b..2b6b74ea49f 100644 --- a/server/sonar-web/src/main/js/app/components/indexation/IndexationContextProvider.tsx +++ b/server/sonar-web/src/main/js/app/components/indexation/IndexationContextProvider.tsx @@ -21,11 +21,12 @@ import * as React from 'react'; import { withAppState } from '../../../components/hoc/withAppState'; import { IndexationContextInterface, IndexationStatus } from '../../../types/indexation'; +import { AppState } from '../../../types/types'; import { IndexationContext } from './IndexationContext'; import IndexationNotificationHelper from './IndexationNotificationHelper'; interface Props { - appState: Pick<T.AppState, 'needIssueSync'>; + appState: Pick<AppState, 'needIssueSync'>; } export class IndexationContextProvider extends React.PureComponent< diff --git a/server/sonar-web/src/main/js/app/components/indexation/IndexationNotification.tsx b/server/sonar-web/src/main/js/app/components/indexation/IndexationNotification.tsx index 6111cb3bd0d..bfae18e371c 100644 --- a/server/sonar-web/src/main/js/app/components/indexation/IndexationNotification.tsx +++ b/server/sonar-web/src/main/js/app/components/indexation/IndexationNotification.tsx @@ -25,12 +25,13 @@ import withIndexationContext, { import { hasGlobalPermission, isLoggedIn } from '../../../helpers/users'; import { IndexationNotificationType } from '../../../types/indexation'; import { Permissions } from '../../../types/permissions'; +import { CurrentUser } from '../../../types/types'; import './IndexationNotification.css'; import IndexationNotificationHelper from './IndexationNotificationHelper'; import IndexationNotificationRenderer from './IndexationNotificationRenderer'; interface Props extends WithIndexationContextProps { - currentUser: T.CurrentUser; + currentUser: CurrentUser; } interface State { diff --git a/server/sonar-web/src/main/js/app/components/indexation/PageUnavailableDueToIndexation.tsx b/server/sonar-web/src/main/js/app/components/indexation/PageUnavailableDueToIndexation.tsx index 5c43f41c660..4f2a907df5e 100644 --- a/server/sonar-web/src/main/js/app/components/indexation/PageUnavailableDueToIndexation.tsx +++ b/server/sonar-web/src/main/js/app/components/indexation/PageUnavailableDueToIndexation.tsx @@ -24,10 +24,11 @@ import withIndexationContext, { } from '../../../components/hoc/withIndexationContext'; import { Alert } from '../../../components/ui/Alert'; import { translate } from '../../../helpers/l10n'; +import { Component } from '../../../types/types'; interface Props extends WithIndexationContextProps { pageContext?: PageContext; - component?: Pick<T.Component, 'qualifier' | 'name'>; + component?: Pick<Component, 'qualifier' | 'name'>; } export enum PageContext { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/Breadcrumb.tsx b/server/sonar-web/src/main/js/app/components/nav/component/Breadcrumb.tsx index 37a77838362..69e580ef0d9 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/Breadcrumb.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/Breadcrumb.tsx @@ -24,9 +24,10 @@ import QualifierIcon from '../../../../components/icons/QualifierIcon'; import { isMainBranch } from '../../../../helpers/branch-like'; import { getComponentOverviewUrl } from '../../../../helpers/urls'; import { BranchLike } from '../../../../types/branch-like'; +import { Component } from '../../../../types/types'; interface Props { - component: T.Component; + component: Component; currentBranchLike: BranchLike | undefined; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx index df02475cfcf..4c25501f4c3 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.tsx @@ -27,6 +27,7 @@ import { import { BranchLike } from '../../../../types/branch-like'; import { ComponentQualifier } from '../../../../types/component'; import { Task, TaskStatuses, TaskWarning } from '../../../../types/tasks'; +import { Component } from '../../../../types/types'; import { rawSizes } from '../../../theme'; import RecentHistory from '../../RecentHistory'; import ComponentNavBgTaskNotif from './ComponentNavBgTaskNotif'; @@ -40,12 +41,12 @@ import ProjectInformation from './projectInformation/ProjectInformation'; export interface ComponentNavProps { branchLikes: BranchLike[]; currentBranchLike: BranchLike | undefined; - component: T.Component; + component: Component; currentTask?: Task; currentTaskOnSameBranch?: boolean; isInProgress?: boolean; isPending?: boolean; - onComponentChange: (changes: Partial<T.Component>) => void; + onComponentChange: (changes: Partial<Component>) => void; onWarningDismiss: () => void; projectBinding?: ProjectAlmBindingResponse; projectBindingErrors?: ProjectAlmBindingConfigurationErrors; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBgTaskNotif.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBgTaskNotif.tsx index a802c839259..2c3d19b4cb6 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBgTaskNotif.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBgTaskNotif.tsx @@ -26,10 +26,11 @@ import { Alert } from '../../../../components/ui/Alert'; import { hasMessage, translate } from '../../../../helpers/l10n'; import { getComponentBackgroundTaskUrl } from '../../../../helpers/urls'; import { Task, TaskStatuses } from '../../../../types/tasks'; +import { Component } from '../../../../types/types'; import ComponentNavLicenseNotif from './ComponentNavLicenseNotif'; interface Props extends Pick<WithRouterProps, 'location'> { - component: T.Component; + component: Component; currentTask?: Task; currentTaskOnSameBranch?: boolean; isInProgress?: boolean; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavLicenseNotif.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavLicenseNotif.tsx index 28a8a51a725..526be9ad391 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavLicenseNotif.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavLicenseNotif.tsx @@ -25,9 +25,10 @@ import { Alert } from '../../../../components/ui/Alert'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; import { ComponentQualifier } from '../../../../types/component'; import { Task } from '../../../../types/tasks'; +import { AppState } from '../../../../types/types'; interface Props { - appState: Pick<T.AppState, 'canAdmin'>; + appState: Pick<AppState, 'canAdmin'>; currentTask?: Task; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavProjectBindingErrorNotif.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavProjectBindingErrorNotif.tsx index 5ceeb6675e9..ee50074ebbd 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavProjectBindingErrorNotif.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavProjectBindingErrorNotif.tsx @@ -24,9 +24,10 @@ import { PULL_REQUEST_DECORATION_BINDING_CATEGORY } from '../../../../apps/setti import { Alert } from '../../../../components/ui/Alert'; import { translate } from '../../../../helpers/l10n'; import { getProjectSettingsUrl } from '../../../../helpers/urls'; +import { Component } from '../../../../types/types'; export interface ComponentNavProjectBindingErrorNotifProps { - component: T.Component; + component: Component; } export function ComponentNavProjectBindingErrorNotif( diff --git a/server/sonar-web/src/main/js/app/components/nav/component/Header.tsx b/server/sonar-web/src/main/js/app/components/nav/component/Header.tsx index dfbb27a8db7..5d16418d4c3 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/Header.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/Header.tsx @@ -25,15 +25,16 @@ import { isLoggedIn } from '../../../../helpers/users'; import { getCurrentUser, Store } from '../../../../store/rootReducer'; import { ProjectAlmBindingResponse } from '../../../../types/alm-settings'; import { BranchLike } from '../../../../types/branch-like'; +import { Component, CurrentUser } from '../../../../types/types'; import BranchLikeNavigation from './branch-like/BranchLikeNavigation'; import CurrentBranchLikeMergeInformation from './branch-like/CurrentBranchLikeMergeInformation'; import { Breadcrumb } from './Breadcrumb'; export interface HeaderProps { branchLikes: BranchLike[]; - component: T.Component; + component: Component; currentBranchLike: BranchLike | undefined; - currentUser: T.CurrentUser; + currentUser: CurrentUser; projectBinding?: ProjectAlmBindingResponse; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/HeaderMeta.tsx b/server/sonar-web/src/main/js/app/components/nav/component/HeaderMeta.tsx index 3a7f2a4c454..92937c38839 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/HeaderMeta.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/HeaderMeta.tsx @@ -30,13 +30,14 @@ import { getCurrentUser, Store } from '../../../../store/rootReducer'; import { BranchLike } from '../../../../types/branch-like'; import { ComponentQualifier } from '../../../../types/component'; import { TaskWarning } from '../../../../types/tasks'; +import { Component, CurrentUser, HomePage } from '../../../../types/types'; import ComponentNavWarnings from './ComponentNavWarnings'; import './HeaderMeta.css'; export interface HeaderMetaProps { branchLike?: BranchLike; - currentUser: T.CurrentUser; - component: T.Component; + currentUser: CurrentUser; + component: Component; onWarningDismiss: () => void; warnings: TaskWarning[]; } @@ -93,8 +94,8 @@ export function HeaderMeta(props: HeaderMetaProps) { ); } -export function getCurrentPage(component: T.Component, branchLike: BranchLike | undefined) { - let currentPage: T.HomePage | undefined; +export function getCurrentPage(component: Component, branchLike: BranchLike | undefined) { + let currentPage: HomePage | undefined; const branch = isBranch(branchLike) && !branchLike.isMain ? branchLike.name : undefined; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx index 609f6461392..b40c25cb88a 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx @@ -33,6 +33,7 @@ import { hasMessage, translate, translateWithParameters } from '../../../../help import { getPortfolioUrl, getProjectQueryUrl } from '../../../../helpers/urls'; import { BranchLike, BranchParameters } from '../../../../types/branch-like'; import { ComponentQualifier, isPortfolioLike } from '../../../../types/component'; +import { AppState, Component, Extension } from '../../../../types/types'; import './Menu.css'; const SETTINGS_URLS = [ @@ -52,10 +53,10 @@ const SETTINGS_URLS = [ ]; interface Props { - appState: Pick<T.AppState, 'branchesEnabled'>; + appState: Pick<AppState, 'branchesEnabled'>; branchLike: BranchLike | undefined; branchLikes: BranchLike[] | undefined; - component: T.Component; + component: Component; isInProgress?: boolean; isPending?: boolean; onToggleProjectInfo: () => void; @@ -539,7 +540,7 @@ export class Menu extends React.PureComponent<Props> { ); }; - renderExtension = ({ key, name }: T.Extension, isAdmin: boolean, baseQuery: Query) => { + renderExtension = ({ key, name }: Extension, isAdmin: boolean, baseQuery: Query) => { const pathname = isAdmin ? `/project/admin/extension/${key}` : `/project/extension/${key}`; const query = { ...baseQuery, qualifier: this.props.component.qualifier }; return ( diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx index 5b748818f9b..457f73fd977 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx @@ -23,14 +23,15 @@ import Toggler from '../../../../../components/controls/Toggler'; import { withAppState } from '../../../../../components/hoc/withAppState'; import { ProjectAlmBindingResponse } from '../../../../../types/alm-settings'; import { BranchLike } from '../../../../../types/branch-like'; +import { AppState, Component } from '../../../../../types/types'; import './BranchLikeNavigation.css'; import CurrentBranchLike from './CurrentBranchLike'; import Menu from './Menu'; export interface BranchLikeNavigationProps { - appState: Pick<T.AppState, 'branchesEnabled'>; + appState: Pick<AppState, 'branchesEnabled'>; branchLikes: BranchLike[]; - component: T.Component; + component: Component; currentBranchLike: BranchLike; projectBinding?: ProjectAlmBindingResponse; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLike.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLike.tsx index 8d8b3b7d837..15bc425c6c0 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLike.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/CurrentBranchLike.tsx @@ -30,11 +30,12 @@ import { getApplicationAdminUrl } from '../../../../../helpers/urls'; import { AlmKeys, ProjectAlmBindingResponse } from '../../../../../types/alm-settings'; import { BranchLike } from '../../../../../types/branch-like'; import { ComponentQualifier } from '../../../../../types/component'; +import { Component } from '../../../../../types/types'; import { colors } from '../../../../theme'; export interface CurrentBranchLikeProps { branchesEnabled: boolean; - component: T.Component; + component: Component; currentBranchLike: BranchLike; hasManyBranches: boolean; projectBinding?: ProjectAlmBindingResponse; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx index e9d079c80c6..f5a0c4f746e 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/Menu.tsx @@ -33,12 +33,13 @@ import { translate } from '../../../../../helpers/l10n'; import { getBranchLikeUrl } from '../../../../../helpers/urls'; import { BranchLike, BranchLikeTree } from '../../../../../types/branch-like'; import { ComponentQualifier } from '../../../../../types/component'; +import { Component } from '../../../../../types/types'; import MenuItemList from './MenuItemList'; interface Props { branchLikes: BranchLike[]; canAdminComponent?: boolean; - component: T.Component; + component: Component; currentBranchLike: BranchLike; onClose: () => void; router: Pick<Router, 'push'>; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx index 16631eeba2c..07b0f84f772 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItem.tsx @@ -24,10 +24,11 @@ import BranchLikeIcon from '../../../../../components/icons/BranchLikeIcon'; import { getBranchLikeDisplayName, isMainBranch } from '../../../../../helpers/branch-like'; import { translate } from '../../../../../helpers/l10n'; import { BranchLike } from '../../../../../types/branch-like'; +import { Component } from '../../../../../types/types'; export interface MenuItemProps { branchLike: BranchLike; - component: T.Component; + component: Component; indent?: boolean; onSelect: (branchLike: BranchLike) => void; selected: boolean; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItemList.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItemList.tsx index cddc6aba4d8..05d0d2caf67 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItemList.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/MenuItemList.tsx @@ -24,11 +24,12 @@ import { translate } from '../../../../../helpers/l10n'; import { scrollToElement } from '../../../../../helpers/scrolling'; import { isDefined } from '../../../../../helpers/types'; import { BranchLike, BranchLikeTree } from '../../../../../types/branch-like'; +import { Component } from '../../../../../types/types'; import MenuItem from './MenuItem'; export interface MenuItemListProps { branchLikeTree: BranchLikeTree; - component: T.Component; + component: Component; hasResults: boolean; onSelect: (branchLike: BranchLike) => void; selectedBranchLike: BranchLike | undefined; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/ProjectInformation.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/ProjectInformation.tsx index 3df9c2b97f0..21f8af7f3ab 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/ProjectInformation.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/ProjectInformation.tsx @@ -26,6 +26,7 @@ import { getCurrentUser, getMetrics, Store } from '../../../../../store/rootRedu import { BranchLike } from '../../../../../types/branch-like'; import { ComponentQualifier } from '../../../../../types/component'; import { MetricKey } from '../../../../../types/metrics'; +import { Component, CurrentUser, Dict, Measure, Metric } from '../../../../../types/types'; import ProjectBadges from './badges/ProjectBadges'; import InfoDrawerPage from './InfoDrawerPage'; import ProjectNotifications from './notifications/ProjectNotifications'; @@ -35,15 +36,15 @@ import ProjectInformationRenderer from './ProjectInformationRenderer'; interface Props { branchLike?: BranchLike; - component: T.Component; - currentUser: T.CurrentUser; + component: Component; + currentUser: CurrentUser; fetchMetrics: () => void; onComponentChange: (changes: {}) => void; - metrics: T.Dict<T.Metric>; + metrics: Dict<Metric>; } interface State { - measures?: T.Measure[]; + measures?: Measure[]; page: ProjectInformationPages; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/ProjectInformationRenderer.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/ProjectInformationRenderer.tsx index f322b691ee4..39d964949e8 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/ProjectInformationRenderer.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/ProjectInformationRenderer.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import PrivacyBadgeContainer from '../../../../../components/common/PrivacyBadgeContainer'; import { translate } from '../../../../../helpers/l10n'; import { ComponentQualifier } from '../../../../../types/component'; +import { Component, Measure } from '../../../../../types/types'; import DrawerLink from './DrawerLink'; import MetaKey from './meta/MetaKey'; import MetaLinks from './meta/MetaLinks'; @@ -33,8 +34,8 @@ import { ProjectInformationPages } from './ProjectInformationPages'; export interface ProjectInformationRendererProps { canConfigureNotifications: boolean; canUseBadges: boolean; - component: T.Component; - measures?: T.Measure[]; + component: Component; + measures?: Measure[]; onComponentChange: (changes: {}) => void; onPageChange: (page: ProjectInformationPages) => void; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/BadgeParams.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/BadgeParams.tsx index 0327f91c636..d546cf3a8f8 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/BadgeParams.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/BadgeParams.tsx @@ -22,11 +22,12 @@ import * as React from 'react'; import { fetchWebApi } from '../../../../../../api/web-api'; import SelectLegacy from '../../../../../../components/controls/SelectLegacy'; import { getLocalizedMetricName, translate } from '../../../../../../helpers/l10n'; +import { Dict, Metric } from '../../../../../../types/types'; import { BadgeFormats, BadgeOptions, BadgeType } from './utils'; interface Props { className?: string; - metrics: T.Dict<T.Metric>; + metrics: Dict<Metric>; options: BadgeOptions; type: BadgeType; updateOptions: (options: Partial<BadgeOptions>) => void; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/ProjectBadges.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/ProjectBadges.tsx index b219a077bae..ae3438a5ae6 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/ProjectBadges.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/ProjectBadges.tsx @@ -30,6 +30,7 @@ import { getBranchLikeQuery } from '../../../../../../helpers/branch-like'; import { translate } from '../../../../../../helpers/l10n'; import { BranchLike } from '../../../../../../types/branch-like'; import { MetricKey } from '../../../../../../types/metrics'; +import { Component, Dict, Metric } from '../../../../../../types/types'; import BadgeButton from './BadgeButton'; import BadgeParams from './BadgeParams'; import './styles.css'; @@ -37,8 +38,8 @@ import { BadgeOptions, BadgeType, getBadgeSnippet, getBadgeUrl } from './utils'; interface Props { branchLike?: BranchLike; - metrics: T.Dict<T.Metric>; - component: T.Component; + metrics: Dict<Metric>; + component: Component; } interface State { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/__tests__/BadgeParams-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/__tests__/BadgeParams-test.tsx index 696ec84f04f..436999cd6fe 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/__tests__/BadgeParams-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/badges/__tests__/BadgeParams-test.tsx @@ -19,6 +19,7 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { Metric } from '../../../../../../../types/types'; import BadgeParams from '../BadgeParams'; import { BadgeType } from '../utils'; @@ -38,8 +39,8 @@ jest.mock('../../../../../../../api/web-api', () => ({ })); const METRICS = { - alert_status: { key: 'alert_status', name: 'Quality Gate' } as T.Metric, - coverage: { key: 'coverage', name: 'Coverage' } as T.Metric + alert_status: { key: 'alert_status', name: 'Quality Gate' } as Metric, + coverage: { key: 'coverage', name: 'Coverage' } as Metric }; it('should display measure badge params', () => { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaLink.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaLink.tsx index a8856725e8d..2df7e993348 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaLink.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaLink.tsx @@ -21,11 +21,12 @@ import * as React from 'react'; import { ClearButton } from '../../../../../../components/controls/buttons'; import ProjectLinkIcon from '../../../../../../components/icons/ProjectLinkIcon'; import { getLinkName } from '../../../../../../helpers/projectLinks'; +import { ProjectLink } from '../../../../../../types/types'; import isValidUri from '../../../../../utils/isValidUri'; interface Props { iconOnly?: boolean; - link: T.ProjectLink; + link: ProjectLink; } interface State { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaLinks.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaLinks.tsx index 0c6915d8dc1..7c9868e16e8 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaLinks.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaLinks.tsx @@ -21,14 +21,15 @@ import * as React from 'react'; import { getProjectLinks } from '../../../../../../api/projectLinks'; import { translate } from '../../../../../../helpers/l10n'; import { orderLinks } from '../../../../../../helpers/projectLinks'; +import { LightComponent, ProjectLink } from '../../../../../../types/types'; import MetaLink from './MetaLink'; interface Props { - component: T.LightComponent; + component: LightComponent; } interface State { - links?: T.ProjectLink[]; + links?: ProjectLink[]; } export default class MetaLinks extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaQualityProfiles.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaQualityProfiles.tsx index fdbcfeb82fd..abdc03228d2 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaQualityProfiles.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaQualityProfiles.tsx @@ -25,18 +25,19 @@ import Tooltip from '../../../../../../components/controls/Tooltip'; import { translate, translateWithParameters } from '../../../../../../helpers/l10n'; import { getQualityProfileUrl } from '../../../../../../helpers/urls'; import { getLanguages, Store } from '../../../../../../store/rootReducer'; +import { ComponentQualityProfile, Dict, Languages } from '../../../../../../types/types'; interface StateProps { - languages: T.Languages; + languages: Languages; } interface OwnProps { headerClassName?: string; - profiles: T.ComponentQualityProfile[]; + profiles: ComponentQualityProfile[]; } interface State { - deprecatedByKey: T.Dict<number>; + deprecatedByKey: Dict<number>; } export class MetaQualityProfiles extends React.PureComponent<StateProps & OwnProps, State> { @@ -60,7 +61,7 @@ export class MetaQualityProfiles extends React.PureComponent<StateProps & OwnPro Promise.all(requests).then( responses => { if (this.mounted) { - const deprecatedByKey: T.Dict<number> = {}; + const deprecatedByKey: Dict<number> = {}; responses.forEach((count, i) => { const profileKey = existingProfiles[i].key; deprecatedByKey[profileKey] = count; @@ -87,7 +88,7 @@ export class MetaQualityProfiles extends React.PureComponent<StateProps & OwnPro return count || 0; } - renderProfile(profile: T.ComponentQualityProfile) { + renderProfile(profile: ComponentQualityProfile) { const languageFromStore = this.props.languages[profile.language]; const languageName = languageFromStore ? languageFromStore.name : profile.language; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaSize.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaSize.tsx index ebafe436f72..2c025b6af57 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaSize.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaSize.tsx @@ -24,10 +24,11 @@ import { translate } from '../../../../../../helpers/l10n'; import { formatMeasure, localizeMetric } from '../../../../../../helpers/measures'; import { ComponentQualifier } from '../../../../../../types/component'; import { MetricKey } from '../../../../../../types/metrics'; +import { Component, Measure } from '../../../../../../types/types'; export interface MetaSizeProps { - component: T.Component; - measures: T.Measure[]; + component: Component; + measures: Measure[]; } export default function MetaSize({ component, measures }: MetaSizeProps) { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaTags.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaTags.tsx index 5cd57a46e5b..25ff262bcc7 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaTags.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/meta/MetaTags.tsx @@ -25,10 +25,11 @@ import TagsList from '../../../../../../components/tags/TagsList'; import { PopupPlacement } from '../../../../../../components/ui/popups'; import { translate } from '../../../../../../helpers/l10n'; import { ComponentQualifier } from '../../../../../../types/component'; +import { Component } from '../../../../../../types/types'; import MetaTagsSelector from './MetaTagsSelector'; interface Props { - component: T.Component; + component: Component; onComponentChange: (changes: {}) => void; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/ProjectNotifications.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/ProjectNotifications.tsx index 835b0bf5255..1932ce09689 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/ProjectNotifications.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/notifications/ProjectNotifications.tsx @@ -26,9 +26,10 @@ import { import { Alert } from '../../../../../../components/ui/Alert'; import DeferredSpinner from '../../../../../../components/ui/DeferredSpinner'; import { translate } from '../../../../../../helpers/l10n'; +import { Component } from '../../../../../../types/types'; interface Props { - component: T.Component; + component: Component; } export function ProjectNotifications(props: WithNotificationsProps & Props) { diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx index fb04e40f614..eab30c61e22 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import { connect } from 'react-redux'; import NavBar from '../../../../components/ui/NavBar'; import { getAppState, getCurrentUser, Store } from '../../../../store/rootReducer'; +import { AppState, CurrentUser } from '../../../../types/types'; import { rawSizes } from '../../../theme'; import EmbedDocsPopupHelper from '../../embed-docs-modal/EmbedDocsPopupHelper'; import Search from '../../search/Search'; @@ -30,8 +31,8 @@ import GlobalNavMenu from './GlobalNavMenu'; import GlobalNavUser from './GlobalNavUser'; export interface GlobalNavProps { - appState: Pick<T.AppState, 'canAdmin' | 'globalPages' | 'qualifiers'>; - currentUser: T.CurrentUser; + appState: Pick<AppState, 'canAdmin' | 'globalPages' | 'qualifiers'>; + currentUser: CurrentUser; location: { pathname: string }; } diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx index c72524bd66e..4113762716f 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavMenu.tsx @@ -26,10 +26,11 @@ import DropdownIcon from '../../../../components/icons/DropdownIcon'; import { translate } from '../../../../helpers/l10n'; import { getQualityGatesUrl } from '../../../../helpers/urls'; import { ComponentQualifier } from '../../../../types/component'; +import { AppState, CurrentUser, Extension } from '../../../../types/types'; interface Props { - appState: Pick<T.AppState, 'canAdmin' | 'globalPages' | 'qualifiers'>; - currentUser: T.CurrentUser; + appState: Pick<AppState, 'canAdmin' | 'globalPages' | 'qualifiers'>; + currentUser: CurrentUser; location: { pathname: string }; } @@ -118,7 +119,7 @@ export default class GlobalNavMenu extends React.PureComponent<Props> { ); } - renderGlobalPageLink = ({ key, name }: T.Extension) => { + renderGlobalPageLink = ({ key, name }: Extension) => { return ( <li key={key}> <Link to={`/extension/${key}`}>{name}</Link> diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavUser.tsx b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavUser.tsx index f1a1d0a989b..5c4fdabb799 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavUser.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavUser.tsx @@ -25,10 +25,11 @@ import Avatar from '../../../../components/ui/Avatar'; import { translate } from '../../../../helpers/l10n'; import { getBaseUrl } from '../../../../helpers/system'; import { isLoggedIn } from '../../../../helpers/users'; +import { CurrentUser, LoggedInUser } from '../../../../types/types'; import { rawSizes } from '../../../theme'; interface Props { - currentUser: T.CurrentUser; + currentUser: CurrentUser; router: Pick<Router, 'push'>; } @@ -46,7 +47,7 @@ export class GlobalNavUser extends React.PureComponent<Props> { }; renderAuthenticated() { - const currentUser = this.props.currentUser as T.LoggedInUser; + const currentUser = this.props.currentUser as LoggedInUser; return ( <Dropdown className="js-user-authenticated" diff --git a/server/sonar-web/src/main/js/app/components/nav/settings/PendingPluginsActionNotif.tsx b/server/sonar-web/src/main/js/app/components/nav/settings/PendingPluginsActionNotif.tsx index 664f80ee8e1..da4fe7a37fa 100644 --- a/server/sonar-web/src/main/js/app/components/nav/settings/PendingPluginsActionNotif.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/settings/PendingPluginsActionNotif.tsx @@ -26,12 +26,13 @@ import { Button } from '../../../../components/controls/buttons'; import { Alert } from '../../../../components/ui/Alert'; import { translate } from '../../../../helpers/l10n'; import { PendingPluginResult } from '../../../../types/plugins'; +import { SysStatus } from '../../../../types/types'; interface Props { fetchSystemStatus: () => void; pending: PendingPluginResult; refreshPending: () => void; - systemStatus: T.SysStatus; + systemStatus: SysStatus; } export default class PendingPluginsActionNotif extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx b/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx index e78a3252499..51974109b4c 100644 --- a/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx @@ -28,17 +28,18 @@ import { translate } from '../../../../helpers/l10n'; import { getBaseUrl } from '../../../../helpers/system'; import { AdminPageExtension } from '../../../../types/extension'; import { PendingPluginResult } from '../../../../types/plugins'; +import { Extension, SysStatus } from '../../../../types/types'; import { rawSizes } from '../../../theme'; import PendingPluginsActionNotif from './PendingPluginsActionNotif'; import SystemRestartNotif from './SystemRestartNotif'; interface Props { - extensions: T.Extension[]; + extensions: Extension[]; fetchPendingPlugins: () => void; fetchSystemStatus: () => void; location: {}; pendingPlugins: PendingPluginResult; - systemStatus: T.SysStatus; + systemStatus: SysStatus; } export default class SettingsNav extends React.PureComponent<Props> { @@ -81,7 +82,7 @@ export default class SettingsNav extends React.PureComponent<Props> { return this.isSomethingActive(urls); } - renderExtension = ({ key, name }: T.Extension) => { + renderExtension = ({ key, name }: Extension) => { return ( <li key={key}> <Link activeClassName="active" to={`/admin/extension/${key}`}> diff --git a/server/sonar-web/src/main/js/app/components/promotion-notification/PromotionNotification.tsx b/server/sonar-web/src/main/js/app/components/promotion-notification/PromotionNotification.tsx index 5390e76c6db..ac4998c44fe 100644 --- a/server/sonar-web/src/main/js/app/components/promotion-notification/PromotionNotification.tsx +++ b/server/sonar-web/src/main/js/app/components/promotion-notification/PromotionNotification.tsx @@ -26,11 +26,12 @@ import { translate } from '../../../helpers/l10n'; import { getBaseUrl } from '../../../helpers/system'; import { isLoggedIn } from '../../../helpers/users'; import { setSonarlintAd } from '../../../store/users'; +import { CurrentUser } from '../../../types/types'; import './PromotionNotification.css'; export interface PromotionNotificationProps { setSonarlintAd: () => void; - currentUser: T.CurrentUser; + currentUser: CurrentUser; } export function PromotionNotification(props: PromotionNotificationProps) { diff --git a/server/sonar-web/src/main/js/app/components/search/Search.tsx b/server/sonar-web/src/main/js/app/components/search/Search.tsx index 5bcfd07fec5..df317990db2 100644 --- a/server/sonar-web/src/main/js/app/components/search/Search.tsx +++ b/server/sonar-web/src/main/js/app/components/search/Search.tsx @@ -34,6 +34,7 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; import { scrollToElement } from '../../../helpers/scrolling'; import { getComponentOverviewUrl } from '../../../helpers/urls'; import { ComponentQualifier } from '../../../types/component'; +import { CurrentUser, Dict } from '../../../types/types'; import RecentHistory from '../RecentHistory'; import './Search.css'; import { ComponentResult, More, Results, sortQualifiers } from './utils'; @@ -42,7 +43,7 @@ const SearchResults = lazyLoadComponent(() => import('./SearchResults')); const SearchResult = lazyLoadComponent(() => import('./SearchResult')); interface OwnProps { - currentUser: T.CurrentUser; + currentUser: CurrentUser; } type Props = OwnProps & WithRouterProps; @@ -52,7 +53,7 @@ interface State { loadingMore?: string; more: More; open: boolean; - projects: T.Dict<{ name: string }>; + projects: Dict<{ name: string }>; query: string; results: Results; selected?: string; @@ -62,7 +63,7 @@ interface State { export class Search extends React.PureComponent<Props, State> { input?: HTMLInputElement | null; node?: HTMLElement | null; - nodes: T.Dict<HTMLElement>; + nodes: Dict<HTMLElement>; mounted = false; constructor(props: Props) { diff --git a/server/sonar-web/src/main/js/app/components/search/SearchResult.tsx b/server/sonar-web/src/main/js/app/components/search/SearchResult.tsx index 373dc60c173..47535893f5a 100644 --- a/server/sonar-web/src/main/js/app/components/search/SearchResult.tsx +++ b/server/sonar-web/src/main/js/app/components/search/SearchResult.tsx @@ -25,6 +25,7 @@ import ClockIcon from '../../../components/icons/ClockIcon'; import FavoriteIcon from '../../../components/icons/FavoriteIcon'; import QualifierIcon from '../../../components/icons/QualifierIcon'; import { getComponentOverviewUrl } from '../../../helpers/urls'; +import { Dict } from '../../../types/types'; import { ComponentResult } from './utils'; interface Props { @@ -32,7 +33,7 @@ interface Props { innerRef: (componentKey: string, node: HTMLElement | null) => void; onClose: () => void; onSelect: (componentKey: string) => void; - projects: T.Dict<{ name: string }>; + projects: Dict<{ name: string }>; selected: boolean; } diff --git a/server/sonar-web/src/main/js/app/components/update-notification/UpdateNotification.tsx b/server/sonar-web/src/main/js/app/components/update-notification/UpdateNotification.tsx index e80c06fd3a2..2893542fd47 100644 --- a/server/sonar-web/src/main/js/app/components/update-notification/UpdateNotification.tsx +++ b/server/sonar-web/src/main/js/app/components/update-notification/UpdateNotification.tsx @@ -31,15 +31,16 @@ import { translate } from '../../../helpers/l10n'; import { hasGlobalPermission, isLoggedIn } from '../../../helpers/users'; import { Permissions } from '../../../types/permissions'; import { SystemUpgrade } from '../../../types/system'; +import { AppState, CurrentUser, Dict } from '../../../types/types'; import './UpdateNotification.css'; const MONTH_BEFOR_PREVIOUS_LTS_NOTIFICATION = 6; type GroupedSystemUpdate = { - [x: string]: T.Dict<SystemUpgrade[]>; + [x: string]: Dict<SystemUpgrade[]>; }; -const MAP_VARIANT: T.Dict<AlertVariant> = { +const MAP_VARIANT: Dict<AlertVariant> = { [UpdateUseCase.NewMinorVersion]: 'info', [UpdateUseCase.NewPatch]: 'warning', [UpdateUseCase.PreLTS]: 'warning', @@ -48,8 +49,8 @@ const MAP_VARIANT: T.Dict<AlertVariant> = { interface Props { dismissable: boolean; - appState: Pick<T.AppState, 'version'>; - currentUser: T.CurrentUser; + appState: Pick<AppState, 'version'>; + currentUser: CurrentUser; } interface State { diff --git a/server/sonar-web/src/main/js/app/index.ts b/server/sonar-web/src/main/js/app/index.ts index 78db9a4e0d5..e2778f6546e 100644 --- a/server/sonar-web/src/main/js/app/index.ts +++ b/server/sonar-web/src/main/js/app/index.ts @@ -21,6 +21,7 @@ import { installExtensionsHandler, installWebAnalyticsHandler } from '../helpers import { loadL10nBundle } from '../helpers/l10n'; import { parseJSON, request } from '../helpers/request'; import { getBaseUrl, getSystemStatus } from '../helpers/system'; +import { AppState } from '../types/types'; import './styles/sonar.ts'; installWebAnalyticsHandler(); @@ -43,7 +44,7 @@ if (isMainApp()) { } else { // login, maintenance or setup pages - const appStatePromise: Promise<T.AppState | undefined> = new Promise(resolve => { + const appStatePromise: Promise<AppState | undefined> = new Promise(resolve => { loadAppState() .then(data => { resolve(data); diff --git a/server/sonar-web/src/main/js/app/utils/getStore.ts b/server/sonar-web/src/main/js/app/utils/getStore.ts index e4f077590cd..bce500729ec 100644 --- a/server/sonar-web/src/main/js/app/utils/getStore.ts +++ b/server/sonar-web/src/main/js/app/utils/getStore.ts @@ -22,10 +22,11 @@ import { setAppState } from '../../store/appState'; import rootReducer, { Store as State } from '../../store/rootReducer'; import { receiveCurrentUser } from '../../store/users'; import configureStore from '../../store/utils/configureStore'; +import { AppState, CurrentUser } from '../../types/types'; let store: Store<State, any>; -const createStore = (currentUser?: T.CurrentUser, appState?: T.AppState) => { +const createStore = (currentUser?: CurrentUser, appState?: AppState) => { store = configureStore(rootReducer); if (currentUser) { store.dispatch(receiveCurrentUser(currentUser)); @@ -36,5 +37,5 @@ const createStore = (currentUser?: T.CurrentUser, appState?: T.AppState) => { return store; }; -export default (currentUser?: T.CurrentUser, appState?: T.AppState) => +export default (currentUser?: CurrentUser, appState?: AppState) => store ? store : createStore(currentUser, appState); diff --git a/server/sonar-web/src/main/js/app/utils/startReactApp.tsx b/server/sonar-web/src/main/js/app/utils/startReactApp.tsx index 2b03991f6e3..0448a4f94b2 100644 --- a/server/sonar-web/src/main/js/app/utils/startReactApp.tsx +++ b/server/sonar-web/src/main/js/app/utils/startReactApp.tsx @@ -60,6 +60,7 @@ import webhooksRoutes from '../../apps/webhooks/routes'; import withIndexationGuard from '../../components/hoc/withIndexationGuard'; import { lazyLoadComponent } from '../../components/lazyLoadComponent'; import getHistory from '../../helpers/getHistory'; +import { AppState, CurrentUser } from '../../types/types'; import App from '../components/App'; import GlobalContainer from '../components/GlobalContainer'; import { PageContext } from '../components/indexation/PageUnavailableDueToIndexation'; @@ -279,8 +280,8 @@ function renderAdminRoutes() { export default function startReactApp( lang: string, - currentUser?: T.CurrentUser, - appState?: T.AppState + currentUser?: CurrentUser, + appState?: AppState ) { attachToGlobal(); diff --git a/server/sonar-web/src/main/js/apps/account/components/Account.tsx b/server/sonar-web/src/main/js/apps/account/components/Account.tsx index 2a8bd25fc0a..4aa0dfe8817 100644 --- a/server/sonar-web/src/main/js/apps/account/components/Account.tsx +++ b/server/sonar-web/src/main/js/apps/account/components/Account.tsx @@ -24,12 +24,13 @@ import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import { withCurrentUser } from '../../../components/hoc/withCurrentUser'; import handleRequiredAuthentication from '../../../helpers/handleRequiredAuthentication'; import { translate } from '../../../helpers/l10n'; +import { CurrentUser, LoggedInUser } from '../../../types/types'; import '../account.css'; import Nav from './Nav'; import UserCard from './UserCard'; interface Props { - currentUser: T.CurrentUser; + currentUser: CurrentUser; } export class Account extends React.PureComponent<Props> { @@ -54,7 +55,7 @@ export class Account extends React.PureComponent<Props> { <A11ySkipTarget anchor="account_main" /> <header className="account-header"> <div className="account-container clearfix"> - <UserCard user={currentUser as T.LoggedInUser} /> + <UserCard user={currentUser as LoggedInUser} /> <Nav /> </div> </header> diff --git a/server/sonar-web/src/main/js/apps/account/components/Security.tsx b/server/sonar-web/src/main/js/apps/account/components/Security.tsx index 18a387913d0..9e99cde6276 100644 --- a/server/sonar-web/src/main/js/apps/account/components/Security.tsx +++ b/server/sonar-web/src/main/js/apps/account/components/Security.tsx @@ -23,10 +23,11 @@ import { connect } from 'react-redux'; import ResetPasswordForm from '../../../components/common/ResetPasswordForm'; import { translate } from '../../../helpers/l10n'; import { getCurrentUser, Store } from '../../../store/rootReducer'; +import { LoggedInUser } from '../../../types/types'; import Tokens from './Tokens'; export interface SecurityProps { - user: T.LoggedInUser; + user: LoggedInUser; } export function Security({ user }: SecurityProps) { @@ -45,7 +46,7 @@ export function Security({ user }: SecurityProps) { } const mapStateToProps = (state: Store) => ({ - user: getCurrentUser(state) as T.LoggedInUser + user: getCurrentUser(state) as LoggedInUser }); export default connect(mapStateToProps)(Security); diff --git a/server/sonar-web/src/main/js/apps/account/components/UserCard.tsx b/server/sonar-web/src/main/js/apps/account/components/UserCard.tsx index 2ce11f14604..ba323e5a5a7 100644 --- a/server/sonar-web/src/main/js/apps/account/components/UserCard.tsx +++ b/server/sonar-web/src/main/js/apps/account/components/UserCard.tsx @@ -19,9 +19,10 @@ */ import * as React from 'react'; import Avatar from '../../../components/ui/Avatar'; +import { LoggedInUser } from '../../../types/types'; interface Props { - user: T.LoggedInUser; + user: LoggedInUser; } export default function UserCard({ user }: Props) { diff --git a/server/sonar-web/src/main/js/apps/account/notifications/GlobalNotifications.tsx b/server/sonar-web/src/main/js/apps/account/notifications/GlobalNotifications.tsx index 22258c60a21..5d645cba39f 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/GlobalNotifications.tsx +++ b/server/sonar-web/src/main/js/apps/account/notifications/GlobalNotifications.tsx @@ -20,14 +20,15 @@ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { isSonarCloud } from '../../../helpers/system'; +import { Notification } from '../../../types/types'; import NotificationsList from './NotificationsList'; import SonarCloudNotifications from './SonarCloudNotifications'; interface Props { - addNotification: (n: T.Notification) => void; + addNotification: (n: Notification) => void; channels: string[]; - notifications: T.Notification[]; - removeNotification: (n: T.Notification) => void; + notifications: Notification[]; + removeNotification: (n: Notification) => void; types: string[]; } diff --git a/server/sonar-web/src/main/js/apps/account/notifications/NotificationsList.tsx b/server/sonar-web/src/main/js/apps/account/notifications/NotificationsList.tsx index 1dce17fd8b7..2500318d883 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/NotificationsList.tsx +++ b/server/sonar-web/src/main/js/apps/account/notifications/NotificationsList.tsx @@ -20,15 +20,16 @@ import * as React from 'react'; import Checkbox from '../../../components/controls/Checkbox'; import { hasMessage, translate } from '../../../helpers/l10n'; +import { Notification } from '../../../types/types'; interface Props { - onAdd: (n: T.Notification) => void; - onRemove: (n: T.Notification) => void; + onAdd: (n: Notification) => void; + onRemove: (n: Notification) => void; channels: string[]; checkboxId: (type: string, channel: string) => string; project?: boolean; types: string[]; - notifications: T.Notification[]; + notifications: Notification[]; } export default class NotificationsList extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/apps/account/notifications/ProjectModal.tsx b/server/sonar-web/src/main/js/apps/account/notifications/ProjectModal.tsx index b83d7555ff6..47cf7d8f287 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/ProjectModal.tsx +++ b/server/sonar-web/src/main/js/apps/account/notifications/ProjectModal.tsx @@ -27,20 +27,21 @@ import SearchBox from '../../../components/controls/SearchBox'; import SimpleModal from '../../../components/controls/SimpleModal'; import { KeyboardCodes } from '../../../helpers/keycodes'; import { translate } from '../../../helpers/l10n'; +import { NotificationProject } from '../../../types/types'; interface Props { - addedProjects: T.NotificationProject[]; + addedProjects: NotificationProject[]; closeModal: VoidFunction; - onSubmit: (project: T.NotificationProject) => void; + onSubmit: (project: NotificationProject) => void; } interface State { - highlighted?: T.NotificationProject; + highlighted?: NotificationProject; loading?: boolean; query?: string; open?: boolean; - selectedProject?: T.NotificationProject; - suggestions?: T.NotificationProject[]; + selectedProject?: NotificationProject; + suggestions?: NotificationProject[]; } export default class ProjectModal extends React.PureComponent<Props, State> { @@ -151,7 +152,7 @@ export default class ProjectModal extends React.PureComponent<Props, State> { ); }; - handleSelect = (selectedProject: T.NotificationProject) => { + handleSelect = (selectedProject: NotificationProject) => { this.setState({ open: false, query: selectedProject.projectName, diff --git a/server/sonar-web/src/main/js/apps/account/notifications/ProjectNotifications.tsx b/server/sonar-web/src/main/js/apps/account/notifications/ProjectNotifications.tsx index 3e749bda992..7219a9ad0a0 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/ProjectNotifications.tsx +++ b/server/sonar-web/src/main/js/apps/account/notifications/ProjectNotifications.tsx @@ -20,15 +20,16 @@ import * as React from 'react'; import BoxedGroupAccordion from '../../../components/controls/BoxedGroupAccordion'; import { translate } from '../../../helpers/l10n'; +import { Notification, NotificationProject } from '../../../types/types'; import NotificationsList from './NotificationsList'; interface Props { - addNotification: (n: T.Notification) => void; + addNotification: (n: Notification) => void; channels: string[]; collapsed: boolean; - notifications: T.Notification[]; - project: T.NotificationProject; - removeNotification: (n: T.Notification) => void; + notifications: Notification[]; + project: NotificationProject; + removeNotification: (n: Notification) => void; types: string[]; } diff --git a/server/sonar-web/src/main/js/apps/account/notifications/Projects.tsx b/server/sonar-web/src/main/js/apps/account/notifications/Projects.tsx index cd3e69acd19..b828d965687 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/Projects.tsx +++ b/server/sonar-web/src/main/js/apps/account/notifications/Projects.tsx @@ -22,21 +22,22 @@ import * as React from 'react'; import { Button } from '../../../components/controls/buttons'; import SearchBox from '../../../components/controls/SearchBox'; import { translate } from '../../../helpers/l10n'; +import { Notification, NotificationProject } from '../../../types/types'; import ProjectModal from './ProjectModal'; import ProjectNotifications from './ProjectNotifications'; export interface Props { - addNotification: (n: T.Notification) => void; + addNotification: (n: Notification) => void; channels: string[]; - notifications: T.Notification[]; - removeNotification: (n: T.Notification) => void; + notifications: Notification[]; + removeNotification: (n: Notification) => void; types: string[]; } const THRESHOLD_COLLAPSED = 3; interface State { - addedProjects: T.NotificationProject[]; + addedProjects: NotificationProject[]; search: string; showModal: boolean; } @@ -44,7 +45,7 @@ interface State { function isNotificationProject(project: { project?: string; projectName?: string; -}): project is T.NotificationProject { +}): project is NotificationProject { return project.project !== undefined && project.projectName !== undefined; } @@ -55,11 +56,11 @@ export default class Projects extends React.PureComponent<Props, State> { showModal: false }; - filterSearch = (project: T.NotificationProject, search: string) => { + filterSearch = (project: NotificationProject, search: string) => { return project.projectName && project.projectName.toLowerCase().includes(search); }; - handleAddProject = (project: T.NotificationProject) => { + handleAddProject = (project: NotificationProject) => { this.setState(state => { return { addedProjects: [...state.addedProjects, project] @@ -71,7 +72,7 @@ export default class Projects extends React.PureComponent<Props, State> { this.setState({ search: search.toLowerCase() }); }; - handleSubmit = (selectedProject: T.NotificationProject) => { + handleSubmit = (selectedProject: NotificationProject) => { if (selectedProject) { this.handleAddProject(selectedProject); } @@ -87,7 +88,7 @@ export default class Projects extends React.PureComponent<Props, State> { this.setState({ showModal: true }); }; - removeNotification = (removed: T.Notification, allProjects: T.NotificationProject[]) => { + removeNotification = (removed: Notification, allProjects: NotificationProject[]) => { const projectToRemove = allProjects.find(p => p.project === removed.project); if (projectToRemove) { this.handleAddProject(projectToRemove); @@ -102,7 +103,7 @@ export default class Projects extends React.PureComponent<Props, State> { const projects = uniqBy(notifications, project => project.project).filter( isNotificationProject - ) as T.NotificationProject[]; + ) as NotificationProject[]; const notificationsByProject = groupBy(notifications, n => n.project); const allProjects = uniqBy([...addedProjects, ...projects], project => project.project); const filteredProjects = sortBy(allProjects, 'projectName').filter(p => diff --git a/server/sonar-web/src/main/js/apps/account/notifications/SonarCloudNotifications.tsx b/server/sonar-web/src/main/js/apps/account/notifications/SonarCloudNotifications.tsx index d74356148e9..6ab6be7fb76 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/SonarCloudNotifications.tsx +++ b/server/sonar-web/src/main/js/apps/account/notifications/SonarCloudNotifications.tsx @@ -23,10 +23,11 @@ import Checkbox from '../../../components/controls/Checkbox'; import { translate } from '../../../helpers/l10n'; import { getCurrentUserSetting, Store } from '../../../store/rootReducer'; import { setCurrentUserSetting } from '../../../store/users'; +import { CurrentUserSetting } from '../../../types/types'; interface Props { notificationsOptOut?: boolean; - setCurrentUserSetting: (setting: T.CurrentUserSetting) => void; + setCurrentUserSetting: (setting: CurrentUserSetting) => void; } export class SonarCloudNotifications extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/apps/account/profile/Profile.tsx b/server/sonar-web/src/main/js/apps/account/profile/Profile.tsx index 7eaa6093c49..601b32bf885 100644 --- a/server/sonar-web/src/main/js/apps/account/profile/Profile.tsx +++ b/server/sonar-web/src/main/js/apps/account/profile/Profile.tsx @@ -21,10 +21,11 @@ import * as React from 'react'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import { whenLoggedIn } from '../../../components/hoc/whenLoggedIn'; import { translate } from '../../../helpers/l10n'; +import { LoggedInUser } from '../../../types/types'; import UserExternalIdentity from './UserExternalIdentity'; export interface ProfileProps { - currentUser: T.LoggedInUser; + currentUser: LoggedInUser; } export function Profile({ currentUser }: ProfileProps) { diff --git a/server/sonar-web/src/main/js/apps/account/profile/UserExternalIdentity.tsx b/server/sonar-web/src/main/js/apps/account/profile/UserExternalIdentity.tsx index 096ec5c4382..21fb7d25f62 100644 --- a/server/sonar-web/src/main/js/apps/account/profile/UserExternalIdentity.tsx +++ b/server/sonar-web/src/main/js/apps/account/profile/UserExternalIdentity.tsx @@ -22,13 +22,14 @@ import { getIdentityProviders } from '../../../api/users'; import { colors } from '../../../app/theme'; import { getTextColor } from '../../../helpers/colors'; import { getBaseUrl } from '../../../helpers/system'; +import { IdentityProvider, LoggedInUser } from '../../../types/types'; export interface UserExternalIdentityProps { - user: T.LoggedInUser; + user: LoggedInUser; } interface State { - identityProvider?: T.IdentityProvider; + identityProvider?: IdentityProvider; loading: boolean; } diff --git a/server/sonar-web/src/main/js/apps/account/projects/ProjectCard.tsx b/server/sonar-web/src/main/js/apps/account/projects/ProjectCard.tsx index 36bc2a46a6e..ac1e98d6f30 100644 --- a/server/sonar-web/src/main/js/apps/account/projects/ProjectCard.tsx +++ b/server/sonar-web/src/main/js/apps/account/projects/ProjectCard.tsx @@ -26,15 +26,16 @@ import Level from '../../../components/ui/Level'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { orderLinks } from '../../../helpers/projectLinks'; import { getProjectUrl } from '../../../helpers/urls'; +import { MyProject, ProjectLink } from '../../../types/types'; interface Props { - project: T.MyProject; + project: MyProject; } export default function ProjectCard({ project }: Props) { const { links } = project; - const orderedLinks: T.ProjectLink[] = orderLinks( + const orderedLinks: ProjectLink[] = orderLinks( links.map((link, i) => { const { href, name, type } = link; return { diff --git a/server/sonar-web/src/main/js/apps/account/projects/Projects.tsx b/server/sonar-web/src/main/js/apps/account/projects/Projects.tsx index 8ec4500ade3..1057e0d7602 100644 --- a/server/sonar-web/src/main/js/apps/account/projects/Projects.tsx +++ b/server/sonar-web/src/main/js/apps/account/projects/Projects.tsx @@ -20,12 +20,13 @@ import * as React from 'react'; import ListFooter from '../../../components/controls/ListFooter'; import { translate } from '../../../helpers/l10n'; +import { MyProject } from '../../../types/types'; import ProjectCard from './ProjectCard'; interface Props { loading: boolean; loadMore: () => void; - projects: T.MyProject[]; + projects: MyProject[]; total?: number; } diff --git a/server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.tsx b/server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.tsx index 3c737a10da0..094ee4ff83e 100644 --- a/server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.tsx +++ b/server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.tsx @@ -21,12 +21,13 @@ import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { getMyProjects } from '../../../api/components'; import { translate } from '../../../helpers/l10n'; +import { MyProject } from '../../../types/types'; import Projects from './Projects'; interface State { loading: boolean; page: number; - projects?: T.MyProject[]; + projects?: MyProject[]; total?: number; } diff --git a/server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.tsx b/server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.tsx index 3d657320d67..3644f570232 100644 --- a/server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.tsx +++ b/server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.tsx @@ -19,6 +19,7 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { MyProject } from '../../../../types/types'; import ProjectCard from '../ProjectCard'; it('should render key and name', () => { @@ -73,6 +74,6 @@ it('should render links', () => { expect(wrapper.find('MetaLink').length).toBe(1); }); -function shallowRender(project: Partial<T.MyProject> = {}) { +function shallowRender(project: Partial<MyProject> = {}) { return shallow(<ProjectCard project={{ key: 'key', links: [], name: 'name', ...project }} />); } diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.tsx index 3c77ed5c9d0..78cc9486699 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.tsx @@ -33,6 +33,7 @@ import { toShortNotSoISOString } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; import { parseAsDate } from '../../../helpers/query'; import { Task, TaskStatuses } from '../../../types/tasks'; +import { Component } from '../../../types/types'; import '../background-tasks.css'; import { CURRENTS, DEBOUNCE_DELAY, DEFAULT_FILTERS } from '../constants'; import { mapFiltersToParameters, Query, updateTask } from '../utils'; @@ -43,7 +44,7 @@ import Stats from './Stats'; import Tasks from './Tasks'; interface Props { - component?: Pick<T.Component, 'key'> & { id: string }; // id should be removed when api/ce/activity accept a component key instead of an id + component?: Pick<Component, 'key'> & { id: string }; // id should be removed when api/ce/activity accept a component key instead of an id location: Location; router: Pick<Router, 'push'>; } diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/StatPendingTime.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/StatPendingTime.tsx index 23d0b3b3294..1eecb6f7a5d 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/StatPendingTime.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/StatPendingTime.tsx @@ -21,13 +21,14 @@ import * as React from 'react'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import { translate } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; +import { Component } from '../../../types/types'; // Do not display the pending time for values smaller than this threshold (in ms) const MIN_PENDING_TIME_THRESHOLD = 1000; export interface Props { className?: string; - component?: Pick<T.Component, 'key'>; + component?: Pick<Component, 'key'>; pendingCount?: number; pendingTime?: number; } diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Stats.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Stats.tsx index afa78ecd9a1..92d4eeaa9c1 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Stats.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Stats.tsx @@ -18,12 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Component } from '../../../types/types'; import StatPendingCount from './StatPendingCount'; import StatPendingTime from './StatPendingTime'; import StatStillFailing from './StatStillFailing'; export interface Props { - component?: Pick<T.Component, 'key'>; + component?: Pick<Component, 'key'>; failingCount?: number; onCancelAllPending: () => void; onShowFailing: () => void; diff --git a/server/sonar-web/src/main/js/apps/code/__tests__/buckets-test.tsx b/server/sonar-web/src/main/js/apps/code/__tests__/buckets-test.tsx index f72e9d0a9b0..65e6a09fc8d 100644 --- a/server/sonar-web/src/main/js/apps/code/__tests__/buckets-test.tsx +++ b/server/sonar-web/src/main/js/apps/code/__tests__/buckets-test.tsx @@ -17,16 +17,17 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { ComponentMeasure } from '../../../types/types'; import { addComponent, addComponentChildren, getComponent, getComponentChildren } from '../bucket'; -const component: T.ComponentMeasure = { key: 'frodo', name: 'frodo', qualifier: 'frodo' }; +const component: ComponentMeasure = { key: 'frodo', name: 'frodo', qualifier: 'frodo' }; const componentKey: string = 'foo'; -const childrenA: T.ComponentMeasure[] = [ +const childrenA: ComponentMeasure[] = [ { key: 'foo', name: 'foo', qualifier: 'foo' }, { key: 'bar', name: 'bar', qualifier: 'bar' } ]; -const childrenB: T.ComponentMeasure[] = [ +const childrenB: ComponentMeasure[] = [ { key: 'bart', name: 'bart', qualifier: 'bart' }, { key: 'simpson', name: 'simpson', qualifier: 'simpson' } ]; diff --git a/server/sonar-web/src/main/js/apps/code/bucket.ts b/server/sonar-web/src/main/js/apps/code/bucket.ts index 9c385131cf4..d6f6945ac8f 100644 --- a/server/sonar-web/src/main/js/apps/code/bucket.ts +++ b/server/sonar-web/src/main/js/apps/code/bucket.ts @@ -17,25 +17,28 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -let bucket: T.Dict<T.ComponentMeasure> = {}; -let childrenBucket: T.Dict<{ - children: T.ComponentMeasure[]; + +import { Breadcrumb, ComponentMeasure, Dict } from '../../types/types'; + +let bucket: Dict<ComponentMeasure> = {}; +let childrenBucket: Dict<{ + children: ComponentMeasure[]; page: number; total: number; }> = {}; -let breadcrumbsBucket: T.Dict<T.Breadcrumb[]> = {}; +let breadcrumbsBucket: Dict<Breadcrumb[]> = {}; -export function addComponent(component: T.ComponentMeasure): void { +export function addComponent(component: ComponentMeasure): void { bucket[component.key] = component; } -export function getComponent(componentKey: string): T.ComponentMeasure { +export function getComponent(componentKey: string): ComponentMeasure { return bucket[componentKey]; } export function addComponentChildren( componentKey: string, - children: T.ComponentMeasure[], + children: ComponentMeasure[], total: number, page: number ): void { @@ -49,18 +52,18 @@ export function addComponentChildren( export function getComponentChildren( componentKey: string ): { - children: T.ComponentMeasure[]; + children: ComponentMeasure[]; page: number; total: number; } { return childrenBucket[componentKey]; } -export function addComponentBreadcrumbs(componentKey: string, breadcrumbs: T.Breadcrumb[]): void { +export function addComponentBreadcrumbs(componentKey: string, breadcrumbs: Breadcrumb[]): void { breadcrumbsBucket[componentKey] = breadcrumbs; } -export function getComponentBreadcrumbs(componentKey: string): T.Breadcrumb[] { +export function getComponentBreadcrumbs(componentKey: string): Breadcrumb[] { return breadcrumbsBucket[componentKey]; } diff --git a/server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.tsx b/server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.tsx index 782af6e1793..59fa5120973 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/Breadcrumbs.tsx @@ -19,12 +19,13 @@ */ import * as React from 'react'; import { BranchLike } from '../../../types/branch-like'; +import { Breadcrumb, ComponentMeasure } from '../../../types/types'; import ComponentName from './ComponentName'; interface Props { branchLike?: BranchLike; - breadcrumbs: T.Breadcrumb[]; - rootComponent: T.ComponentMeasure; + breadcrumbs: Breadcrumb[]; + rootComponent: ComponentMeasure; } export default function Breadcrumbs({ branchLike, breadcrumbs, rootComponent }: Props) { diff --git a/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx b/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx index 9ad1391425d..a66a95fc915 100644 --- a/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/CodeApp.tsx @@ -37,6 +37,7 @@ import { fetchBranchStatus, fetchMetrics } from '../../../store/rootActions'; import { getMetrics } from '../../../store/rootReducer'; import { BranchLike } from '../../../types/branch-like'; import { isPortfolioLike } from '../../../types/component'; +import { Breadcrumb, Component, ComponentMeasure, Dict, Issue, Metric } from '../../../types/types'; import { addComponent, addComponentBreadcrumbs, clearBucket } from '../bucket'; import '../code.css'; import { @@ -51,7 +52,7 @@ import Search from './Search'; import SourceViewerWrapper from './SourceViewerWrapper'; interface StateToProps { - metrics: T.Dict<T.Metric>; + metrics: Dict<Metric>; } interface DispatchToProps { @@ -61,7 +62,7 @@ interface DispatchToProps { interface OwnProps { branchLike?: BranchLike; - component: T.Component; + component: Component; location: Pick<Location, 'query'>; router: Pick<InjectedRouter, 'push'>; } @@ -69,14 +70,14 @@ interface OwnProps { type Props = StateToProps & DispatchToProps & OwnProps; interface State { - baseComponent?: T.ComponentMeasure; - breadcrumbs: T.Breadcrumb[]; - components?: T.ComponentMeasure[]; - highlighted?: T.ComponentMeasure; + baseComponent?: ComponentMeasure; + breadcrumbs: Breadcrumb[]; + components?: ComponentMeasure[]; + highlighted?: ComponentMeasure; loading: boolean; page: number; - searchResults?: T.ComponentMeasure[]; - sourceViewer?: T.ComponentMeasure; + searchResults?: ComponentMeasure[]; + sourceViewer?: ComponentMeasure; total: number; newCodeSelected: boolean; } @@ -208,11 +209,11 @@ export class CodeApp extends React.Component<Props, State> { } }; - handleHighlight = (highlighted: T.ComponentMeasure) => { + handleHighlight = (highlighted: ComponentMeasure) => { this.setState({ highlighted }); }; - handleIssueChange = (_: T.Issue) => { + handleIssueChange = (_: Issue) => { this.refreshBranchStatus(); }; @@ -220,11 +221,11 @@ export class CodeApp extends React.Component<Props, State> { this.setState({ searchResults: undefined }); }; - handleSearchResults = (searchResults: T.ComponentMeasure[] = []) => { + handleSearchResults = (searchResults: ComponentMeasure[] = []) => { this.setState({ searchResults }); }; - handleSelect = (component: T.ComponentMeasure) => { + handleSelect = (component: ComponentMeasure) => { const { branchLike, component: rootComponent } = this.props; if (component.refKey) { diff --git a/server/sonar-web/src/main/js/apps/code/components/Component.tsx b/server/sonar-web/src/main/js/apps/code/components/Component.tsx index 61e9f2d02a9..24361a70a49 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Component.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/Component.tsx @@ -24,6 +24,7 @@ import { WorkspaceContext } from '../../../components/workspace/context'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { MetricType } from '../../../types/metrics'; +import { ComponentMeasure as TypeComponentMeasure, Metric } from '../../../types/types'; import ComponentMeasure from './ComponentMeasure'; import ComponentName from './ComponentName'; import ComponentPin from './ComponentPin'; @@ -32,12 +33,12 @@ interface Props { branchLike?: BranchLike; canBePinned?: boolean; canBrowse?: boolean; - component: T.ComponentMeasure; + component: TypeComponentMeasure; hasBaseComponent: boolean; isBaseComponent?: boolean; - metrics: T.Metric[]; - previous?: T.ComponentMeasure; - rootComponent: T.ComponentMeasure; + metrics: Metric[]; + previous?: TypeComponentMeasure; + rootComponent: TypeComponentMeasure; selected?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.tsx index 0b68c399fd8..bc41026f1f9 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.tsx @@ -21,10 +21,11 @@ import * as React from 'react'; import Measure from '../../../components/measure/Measure'; import { getLeakValue } from '../../../components/measure/utils'; import { isDiffMetric } from '../../../helpers/measures'; +import { ComponentMeasure as TypeComponentMeasure, Metric } from '../../../types/types'; interface Props { - component: T.ComponentMeasure; - metric: T.Metric; + component: TypeComponentMeasure; + metric: Metric; } export default class ComponentMeasure extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx index cd67da0d00e..3dc3d132c71 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx @@ -32,8 +32,9 @@ import { isPortfolioLike, isProject } from '../../../types/component'; +import { ComponentMeasure } from '../../../types/types'; -export function getTooltip(component: T.ComponentMeasure) { +export function getTooltip(component: ComponentMeasure) { const isFile = component.qualifier === 'FIL' || component.qualifier === 'UTS'; if (isFile && component.path) { @@ -61,9 +62,9 @@ export function mostCommonPrefix(strings: string[]) { export interface Props { branchLike?: BranchLike; canBrowse?: boolean; - component: T.ComponentMeasure; - previous?: T.ComponentMeasure; - rootComponent: T.ComponentMeasure; + component: ComponentMeasure; + previous?: ComponentMeasure; + rootComponent: ComponentMeasure; unclickable?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentPin.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentPin.tsx index 34ac5a6e654..cd77ea623f6 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentPin.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentPin.tsx @@ -22,10 +22,11 @@ import PinIcon from '../../../components/icons/PinIcon'; import { WorkspaceContextShape } from '../../../components/workspace/context'; import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; +import { ComponentMeasure } from '../../../types/types'; interface Props { branchLike?: BranchLike; - component: T.ComponentMeasure; + component: ComponentMeasure; openComponent: WorkspaceContextShape['openComponent']; } diff --git a/server/sonar-web/src/main/js/apps/code/components/Components.tsx b/server/sonar-web/src/main/js/apps/code/components/Components.tsx index 0946b2275b9..449a4020f22 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Components.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/Components.tsx @@ -22,17 +22,18 @@ import * as React from 'react'; import withKeyboardNavigation from '../../../components/hoc/withKeyboardNavigation'; import { getComponentMeasureUniqueKey } from '../../../helpers/component'; import { BranchLike } from '../../../types/branch-like'; +import { ComponentMeasure, Metric } from '../../../types/types'; import Component from './Component'; import ComponentsEmpty from './ComponentsEmpty'; import ComponentsHeader from './ComponentsHeader'; interface Props { - baseComponent?: T.ComponentMeasure; + baseComponent?: ComponentMeasure; branchLike?: BranchLike; - components: T.ComponentMeasure[]; - metrics: T.Metric[]; - rootComponent: T.ComponentMeasure; - selected?: T.ComponentMeasure; + components: ComponentMeasure[]; + metrics: Metric[]; + rootComponent: ComponentMeasure; + selected?: ComponentMeasure; } const BASE_COLUMN_COUNT = 4; diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx index f458cc98484..8c9067457a7 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx @@ -20,12 +20,13 @@ import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; +import { ComponentMeasure } from '../../../types/types'; interface Props { - baseComponent?: T.ComponentMeasure; + baseComponent?: ComponentMeasure; canBePinned?: boolean; metrics: string[]; - rootComponent: T.ComponentMeasure; + rootComponent: ComponentMeasure; } const SHORT_NAME_METRICS = [ diff --git a/server/sonar-web/src/main/js/apps/code/components/Search.tsx b/server/sonar-web/src/main/js/apps/code/components/Search.tsx index 740504eabd9..ce9b0da5407 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Search.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/Search.tsx @@ -27,16 +27,17 @@ import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { KeyboardCodes } from '../../../helpers/keycodes'; import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; +import { ComponentMeasure } from '../../../types/types'; import PortfolioNewCodeToggle from './PortfolioNewCodeToggle'; interface Props { branchLike?: BranchLike; - component: T.ComponentMeasure; + component: ComponentMeasure; location: Location; newCodeSelected: boolean; onSearchClear: () => void; onNewCodeToggle: (newCode: boolean) => void; - onSearchResults: (results?: T.ComponentMeasure[]) => void; + onSearchResults: (results?: ComponentMeasure[]) => void; router: Router; } diff --git a/server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx b/server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx index 874c5b3379f..73fb535bf69 100644 --- a/server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/SourceViewerWrapper.tsx @@ -23,13 +23,14 @@ import withKeyboardNavigation from '../../../components/hoc/withKeyboardNavigati import SourceViewer from '../../../components/SourceViewer/SourceViewer'; import { scrollToElement } from '../../../helpers/scrolling'; import { BranchLike } from '../../../types/branch-like'; +import { Issue, Measure } from '../../../types/types'; interface Props { branchLike?: BranchLike; component: string; - componentMeasures: T.Measure[] | undefined; + componentMeasures: Measure[] | undefined; location: Pick<Location, 'query'>; - onIssueChange?: (issue: T.Issue) => void; + onIssueChange?: (issue: Issue) => void; } export class SourceViewerWrapper extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/apps/code/utils.ts b/server/sonar-web/src/main/js/apps/code/utils.ts index 3f957269065..99e094128a1 100644 --- a/server/sonar-web/src/main/js/apps/code/utils.ts +++ b/server/sonar-web/src/main/js/apps/code/utils.ts @@ -22,6 +22,7 @@ import { getBranchLikeQuery, isPullRequest } from '../../helpers/branch-like'; import { BranchLike } from '../../types/branch-like'; import { isPortfolioLike } from '../../types/component'; import { MetricKey } from '../../types/metrics'; +import { Breadcrumb, ComponentMeasure } from '../../types/types'; import { addComponent, addComponentBreadcrumbs, @@ -74,7 +75,7 @@ const LEAK_METRICS = [ const PAGE_SIZE = 100; interface Children { - components: T.ComponentMeasure[]; + components: ComponentMeasure[]; page: number; total: number; } @@ -91,17 +92,17 @@ export function showLeakMeasure(branchLike?: BranchLike) { return isPullRequest(branchLike); } -function skipRootDir(breadcrumbs: T.ComponentMeasure[]) { +function skipRootDir(breadcrumbs: ComponentMeasure[]) { return breadcrumbs.filter(component => { return !(component.qualifier === 'DIR' && component.name === '/'); }); } -function storeChildrenBase(children: T.ComponentMeasure[]) { +function storeChildrenBase(children: ComponentMeasure[]) { children.forEach(addComponent); } -function storeChildrenBreadcrumbs(parentComponentKey: string, children: T.Breadcrumb[]) { +function storeChildrenBreadcrumbs(parentComponentKey: string, children: Breadcrumb[]) { const parentBreadcrumbs = getComponentBreadcrumbs(parentComponentKey); if (parentBreadcrumbs) { children.forEach(child => { @@ -166,7 +167,7 @@ export function retrieveComponentChildren( qualifier: string, instance: { mounted: boolean }, branchLike?: BranchLike -): Promise<{ components: T.ComponentMeasure[]; page: number; total: number }> { +): Promise<{ components: ComponentMeasure[]; page: number; total: number }> { const existing = getComponentChildren(componentKey); if (existing) { return Promise.resolve({ @@ -200,7 +201,7 @@ function retrieveComponentBreadcrumbs( component: string, instance: { mounted: boolean }, branchLike?: BranchLike -): Promise<T.Breadcrumb[]> { +): Promise<Breadcrumb[]> { const existing = getComponentBreadcrumbs(component); if (existing) { return Promise.resolve(existing); @@ -222,9 +223,9 @@ export function retrieveComponent( instance: { mounted: boolean }, branchLike?: BranchLike ): Promise<{ - breadcrumbs: T.Breadcrumb[]; - component: T.ComponentMeasure; - components: T.ComponentMeasure[]; + breadcrumbs: Breadcrumb[]; + component: ComponentMeasure; + components: ComponentMeasure[]; page: number; total: number; }> { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationButton.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationButton.tsx index 0d2b133c77c..da930cbf779 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationButton.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationButton.tsx @@ -20,16 +20,17 @@ import * as React from 'react'; import { Profile as BaseProfile } from '../../../api/quality-profiles'; import { Button } from '../../../components/controls/buttons'; +import { Rule, RuleActivation, RuleDetails } from '../../../types/types'; import ActivationFormModal from './ActivationFormModal'; interface Props { - activation?: T.RuleActivation; + activation?: RuleActivation; buttonText: string; className?: string; modalHeader: string; onDone: (severity: string) => Promise<void>; profiles: BaseProfile[]; - rule: T.Rule | T.RuleDetails; + rule: Rule | RuleDetails; } interface State { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx index dd4a680feb0..1c963c7702d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx @@ -28,19 +28,20 @@ import { Alert } from '../../../components/ui/Alert'; import { SEVERITIES } from '../../../helpers/constants'; import { translate } from '../../../helpers/l10n'; import { sanitizeString } from '../../../helpers/sanitize'; +import { Dict, Rule, RuleActivation, RuleDetails } from '../../../types/types'; import { sortProfiles } from '../../quality-profiles/utils'; interface Props { - activation?: T.RuleActivation; + activation?: RuleActivation; modalHeader: string; onClose: () => void; onDone: (severity: string) => Promise<void>; profiles: Profile[]; - rule: T.Rule | T.RuleDetails; + rule: Rule | RuleDetails; } interface State { - params: T.Dict<string>; + params: Dict<string>; profile: string; severity: string; submitting: boolean; @@ -69,7 +70,7 @@ export default class ActivationFormModal extends React.PureComponent<Props, Stat } getParams = ({ activation, rule } = this.props) => { - const params: T.Dict<string> = {}; + const params: Dict<string> = {}; if (rule && rule.params) { for (const param of rule.params) { params[param.key] = param.defaultValue || ''; @@ -148,7 +149,7 @@ export default class ActivationFormModal extends React.PureComponent<Props, Stat const { profile, severity, submitting } = this.state; const { params = [] } = rule; const profilesWithDepth = this.getQualityProfilesWithDepth(); - const isCustomRule = !!(rule as T.RuleDetails).templateKey; + const isCustomRule = !!(rule as RuleDetails).templateKey; const activeInAllProfiles = profilesWithDepth.length <= 0; const isUpdateMode = !!activation; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx index 52157b66998..90ca67697d9 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx @@ -45,6 +45,15 @@ import { isLoggedIn } from '../../../helpers/users'; import { getCurrentUser, getLanguages, Store } from '../../../store/rootReducer'; import { SecurityStandard } from '../../../types/security'; import { + CurrentUser, + Dict, + Languages, + Paging, + RawQuery, + Rule, + RuleActivation +} from '../../../types/types'; +import { shouldOpenSonarSourceSecurityFacet, shouldOpenStandardsChildFacet, shouldOpenStandardsFacet, @@ -78,8 +87,8 @@ const MAX_SEARCH_LENGTH = 200; const LIMIT_BEFORE_LOAD_MORE = 5; interface Props extends WithRouterProps { - currentUser: T.CurrentUser; - languages: T.Languages; + currentUser: CurrentUser; + languages: Languages; } interface State { @@ -88,12 +97,12 @@ interface State { facets?: Facets; loading: boolean; openFacets: OpenFacets; - openRule?: T.Rule; - paging?: T.Paging; + openRule?: Rule; + paging?: Paging; query: Query; - referencedProfiles: T.Dict<Profile>; - referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; - rules: T.Rule[]; + referencedProfiles: Dict<Profile>; + referencedRepositories: Dict<{ key: string; language: string; name: string }>; + rules: Rule[]; selected?: string; usingPermalink?: boolean; } @@ -184,7 +193,7 @@ export class App extends React.PureComponent<Props, State> { detachShortcuts = () => key.deleteScope('coding-rules'); - getOpenRule = (props: Props, rules: T.Rule[]) => { + getOpenRule = (props: Props, rules: Rule[]) => { const open = getOpen(props.location.query); return open && rules.find(rule => rule.key === open); }; @@ -244,7 +253,7 @@ export class App extends React.PureComponent<Props, State> { ); }; - makeFetchRequest = (query?: T.RawQuery) => + makeFetchRequest = (query?: RawQuery) => searchRules({ ...this.getSearchParameters(), ...query }).then( ({ actives: rawActives, facets: rawFacets, p, ps, rules, total }) => { const actives = rawActives && parseActives(rawActives); @@ -254,7 +263,7 @@ export class App extends React.PureComponent<Props, State> { } ); - fetchFirstRules = (query?: T.RawQuery) => { + fetchFirstRules = (query?: RawQuery) => { this.setState({ loading: true }); this.makeFetchRequest(query).then(({ actives, facets, paging, rules }) => { if (this.mounted) { @@ -474,7 +483,7 @@ export class App extends React.PureComponent<Props, State> { handleReset = () => this.props.router.push({ pathname: this.props.location.pathname }); /** Tries to take rule by index, or takes the last one */ - pickRuleAround = (rules: T.Rule[], selectedIndex: number | undefined) => { + pickRuleAround = (rules: Rule[], selectedIndex: number | undefined) => { if (selectedIndex === undefined || rules.length === 0) { return undefined; } @@ -672,7 +681,7 @@ export class App extends React.PureComponent<Props, State> { } } -function parseActives(rawActives: T.Dict<T.RuleActivation[]>) { +function parseActives(rawActives: Dict<RuleActivation[]>) { const actives: Actives = {}; for (const [rule, activations] of Object.entries(rawActives)) { actives[rule] = {}; @@ -686,7 +695,7 @@ function parseActives(rawActives: T.Dict<T.RuleActivation[]>) { function parseFacets(rawFacets: { property: string; values: { count: number; val: string }[] }[]) { const facets: Facets = {}; for (const rawFacet of rawFacets) { - const values: T.Dict<number> = {}; + const values: Dict<number> = {}; for (const rawValue of rawFacet.values) { values[rawValue.val] = rawValue.count; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx index c1fa64a8758..06b15dff35a 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx @@ -24,13 +24,14 @@ import Dropdown from '../../../components/controls/Dropdown'; import Tooltip from '../../../components/controls/Tooltip'; import { PopupPlacement } from '../../../components/ui/popups'; import { translate } from '../../../helpers/l10n'; +import { Dict, Languages } from '../../../types/types'; import { Query } from '../query'; import BulkChangeModal from './BulkChangeModal'; interface Props { - languages: T.Languages; + languages: Languages; query: Query; - referencedProfiles: T.Dict<Profile>; + referencedProfiles: Dict<Profile>; total: number; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChangeModal.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChangeModal.tsx index bb853cf92c5..c286d89510e 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChangeModal.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChangeModal.tsx @@ -25,15 +25,16 @@ import SelectLegacy from '../../../components/controls/SelectLegacy'; import { Alert } from '../../../components/ui/Alert'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; +import { Dict, Languages } from '../../../types/types'; import { Query, serializeQuery } from '../query'; interface Props { action: string; - languages: T.Languages; + languages: Languages; onClose: () => void; profile?: Profile; query: Query; - referencedProfiles: T.Dict<Profile>; + referencedProfiles: Dict<Profile>; total: number; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleButton.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleButton.tsx index d6c87f1c5c1..d1b0d9f28d3 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleButton.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleButton.tsx @@ -18,13 +18,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { RuleDetails } from '../../../types/types'; import CustomRuleFormModal from './CustomRuleFormModal'; interface Props { children: (props: { onClick: () => void }) => React.ReactNode; - customRule?: T.RuleDetails; - onDone: (newRuleDetails: T.RuleDetails) => void; - templateRule: T.RuleDetails; + customRule?: RuleDetails; + onDone: (newRuleDetails: RuleDetails) => void; + templateRule: RuleDetails; } interface State { @@ -53,7 +54,7 @@ export default class CustomRuleButton extends React.PureComponent<Props, State> } }; - handleDone = (newRuleDetails: T.RuleDetails) => { + handleDone = (newRuleDetails: RuleDetails) => { this.handleModalClose(); this.props.onDone(newRuleDetails); }; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx index 25fcb3c8e60..0d6482a6c73 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx @@ -33,12 +33,13 @@ import { csvEscape } from '../../../helpers/csv'; import { translate } from '../../../helpers/l10n'; import { sanitizeString } from '../../../helpers/sanitize'; import { latinize } from '../../../helpers/strings'; +import { Dict, RuleDetails, RuleParameter, RuleType } from '../../../types/types'; interface Props { - customRule?: T.RuleDetails; + customRule?: RuleDetails; onClose: () => void; - onDone: (newRuleDetails: T.RuleDetails) => void; - templateRule: T.RuleDetails; + onDone: (newRuleDetails: RuleDetails) => void; + templateRule: RuleDetails; } interface State { @@ -46,7 +47,7 @@ interface State { key: string; keyModifiedByUser: boolean; name: string; - params: T.Dict<string>; + params: Dict<string>; reactivating: boolean; severity: string; status: string; @@ -59,7 +60,7 @@ export default class CustomRuleFormModal extends React.PureComponent<Props, Stat constructor(props: Props) { super(props); - const params: T.Dict<string> = {}; + const params: Dict<string> = {}; if (props.customRule && props.customRule.params) { for (const param of props.customRule.params) { params[param.key] = param.defaultValue || ''; @@ -211,7 +212,7 @@ export default class CustomRuleFormModal extends React.PureComponent<Props, Stat </div> ); - renderTypeOption = ({ value }: { value: T.RuleType }) => { + renderTypeOption = ({ value }: { value: RuleType }) => { return <TypeHelper type={value} />; }; @@ -277,7 +278,7 @@ export default class CustomRuleFormModal extends React.PureComponent<Props, Stat </div> ); - renderParameterField = (param: T.RuleParameter) => ( + renderParameterField = (param: RuleParameter) => ( <div className="modal-field" key={param.key}> <label className="capitalize" htmlFor={param.key}> {param.key} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/Facet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/Facet.tsx index c5af27f619f..6da6f1e5966 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/Facet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/Facet.tsx @@ -27,13 +27,14 @@ import FacetItem from '../../../components/facet/FacetItem'; import FacetItemsList from '../../../components/facet/FacetItemsList'; import { translate } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; +import { Dict } from '../../../types/types'; import { FacetKey } from '../query'; export interface BasicProps { - onChange: (changes: T.Dict<string | string[] | undefined>) => void; + onChange: (changes: Dict<string | string[] | undefined>) => void; onToggle: (facet: FacetKey) => void; open: boolean; - stats?: T.Dict<number>; + stats?: Dict<number>; values: string[]; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/FacetsList.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/FacetsList.tsx index 2cedf3297aa..fd68568f723 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/FacetsList.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/FacetsList.tsx @@ -19,6 +19,7 @@ */ import * as React from 'react'; import { Profile } from '../../../api/quality-profiles'; +import { Dict } from '../../../types/types'; import StandardFacet from '../../issues/sidebar/StandardFacet'; import { Facets, OpenFacets, Query } from '../query'; import ActivationSeverityFacet from './ActivationSeverityFacet'; @@ -40,8 +41,8 @@ export interface FacetsListProps { onFilterChange: (changes: Partial<Query>) => void; openFacets: OpenFacets; query: Query; - referencedProfiles: T.Dict<Profile>; - referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; + referencedProfiles: Dict<Profile>; + referencedRepositories: Dict<{ key: string; language: string; name: string }>; selectedProfile?: Profile; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/InheritanceFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/InheritanceFacet.tsx index 73c9b85d5cb..839997efa8a 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/InheritanceFacet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/InheritanceFacet.tsx @@ -19,15 +19,16 @@ */ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; +import { RuleInheritance } from '../../../types/types'; import Facet, { BasicProps } from './Facet'; -interface Props extends T.Omit<BasicProps, 'values'> { +interface Props extends Omit<BasicProps, 'values'> { disabled: boolean; - value: T.RuleInheritance | undefined; + value: RuleInheritance | undefined; } export default class InheritanceFacet extends React.PureComponent<Props> { - renderName = (value: T.RuleInheritance) => + renderName = (value: RuleInheritance) => translate('coding_rules.filters.inheritance', value.toLowerCase()); render() { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/PageActions.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/PageActions.tsx index 29a76efda9c..41f81b86009 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/PageActions.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/PageActions.tsx @@ -23,11 +23,12 @@ import ReloadButton from '../../../components/controls/ReloadButton'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import PageShortcutsTooltip from '../../../components/ui/PageShortcutsTooltip'; import { translate } from '../../../helpers/l10n'; +import { Paging } from '../../../types/types'; export interface PageActionsProps { loading: boolean; onReload: () => void; - paging?: T.Paging; + paging?: Paging; selectedIndex?: number; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/ProfileFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/ProfileFacet.tsx index bd968b073ab..95708f97f09 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/ProfileFacet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/ProfileFacet.tsx @@ -27,6 +27,7 @@ import FacetHeader from '../../../components/facet/FacetHeader'; import FacetItem from '../../../components/facet/FacetItem'; import FacetItemsList from '../../../components/facet/FacetItemsList'; import { translate } from '../../../helpers/l10n'; +import { Dict } from '../../../types/types'; import { FacetKey, Query } from '../query'; interface Props { @@ -36,7 +37,7 @@ interface Props { onChange: (changes: Partial<Query>) => void; onToggle: (facet: FacetKey) => void; open: boolean; - referencedProfiles: T.Dict<Profile>; + referencedProfiles: Dict<Profile>; value: string | undefined; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RepositoryFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RepositoryFacet.tsx index cc1b0767edb..b4588d7da8d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RepositoryFacet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RepositoryFacet.tsx @@ -24,14 +24,15 @@ import ListStyleFacet from '../../../components/facet/ListStyleFacet'; import { translate } from '../../../helpers/l10n'; import { highlightTerm } from '../../../helpers/search'; import { getLanguages, Store } from '../../../store/rootReducer'; +import { Dict } from '../../../types/types'; import { BasicProps } from './Facet'; interface StateProps { - referencedLanguages: T.Dict<{ key: string; name: string }>; + referencedLanguages: Dict<{ key: string; name: string }>; } interface Props extends BasicProps, StateProps { - referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; + referencedRepositories: Dict<{ key: string; language: string; name: string }>; } export class RepositoryFacet extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx index 09198ba7b40..df5379be796 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx @@ -25,6 +25,7 @@ import ConfirmButton from '../../../components/controls/ConfirmButton'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Dict, RuleActivation, RuleDetails as TypeRuleDetails } from '../../../types/types'; import { Activation, Query } from '../query'; import CustomRuleButton from './CustomRuleButton'; import RuleDetailsCustomRules from './RuleDetailsCustomRules'; @@ -42,16 +43,16 @@ interface Props { onDeactivate: (profile: string, rule: string) => void; onDelete: (rule: string) => void; onFilterChange: (changes: Partial<Query>) => void; - referencedProfiles: T.Dict<Profile>; - referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; + referencedProfiles: Dict<Profile>; + referencedRepositories: Dict<{ key: string; language: string; name: string }>; ruleKey: string; selectedProfile?: Profile; } interface State { - actives?: T.RuleActivation[]; + actives?: RuleActivation[]; loading: boolean; - ruleDetails?: T.RuleDetails; + ruleDetails?: TypeRuleDetails; } export default class RuleDetails extends React.PureComponent<Props, State> { @@ -93,7 +94,7 @@ export default class RuleDetails extends React.PureComponent<Props, State> { ); }; - handleRuleChange = (ruleDetails: T.RuleDetails) => { + handleRuleChange = (ruleDetails: TypeRuleDetails) => { if (this.mounted) { this.setState({ ruleDetails }); } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsCustomRules.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsCustomRules.tsx index 7acce41dcb1..c6a867a8bed 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsCustomRules.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsCustomRules.tsx @@ -27,16 +27,17 @@ import SeverityHelper from '../../../components/shared/SeverityHelper'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getRuleUrl } from '../../../helpers/urls'; +import { Rule, RuleDetails } from '../../../types/types'; import CustomRuleButton from './CustomRuleButton'; interface Props { canChange?: boolean; - ruleDetails: T.RuleDetails; + ruleDetails: RuleDetails; } interface State { loading: boolean; - rules?: T.Rule[]; + rules?: Rule[]; } export default class RuleDetailsCustomRules extends React.PureComponent<Props, State> { @@ -77,7 +78,7 @@ export default class RuleDetailsCustomRules extends React.PureComponent<Props, S ); }; - handleRuleCreate = (newRuleDetails: T.RuleDetails) => { + handleRuleCreate = (newRuleDetails: RuleDetails) => { if (this.mounted) { this.setState(({ rules = [] }: State) => ({ rules: [...rules, newRuleDetails] @@ -95,7 +96,7 @@ export default class RuleDetailsCustomRules extends React.PureComponent<Props, S }); }; - renderRule = (rule: T.Rule) => ( + renderRule = (rule: Rule) => ( <tr data-rule={rule.key} key={rule.key}> <td className="coding-rules-detail-list-name"> <Link to={getRuleUrl(rule.key)}>{rule.name}</Link> diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx index 79eb7b4007a..83be0999eb9 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx @@ -23,12 +23,13 @@ import FormattingTips from '../../../components/common/FormattingTips'; import { Button, ResetButtonLink } from '../../../components/controls/buttons'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { sanitizeString } from '../../../helpers/sanitize'; +import { RuleDetails } from '../../../types/types'; import RemoveExtendedDescriptionModal from './RemoveExtendedDescriptionModal'; interface Props { canWrite: boolean | undefined; - onChange: (newRuleDetails: T.RuleDetails) => void; - ruleDetails: T.RuleDetails; + onChange: (newRuleDetails: RuleDetails) => void; + ruleDetails: RuleDetails; } interface State { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx index af2f02e39ab..9012c4cbff8 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx @@ -26,10 +26,11 @@ import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; import { getIssuesUrl } from '../../../helpers/urls'; +import { AppState, RuleDetails } from '../../../types/types'; interface Props { - appState: Pick<T.AppState, 'branchesEnabled'>; - ruleDetails: Pick<T.RuleDetails, 'key' | 'type'>; + appState: Pick<AppState, 'branchesEnabled'>; + ruleDetails: Pick<RuleDetails, 'key' | 'type'>; } interface Project { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx index aa1a09e4e84..7f536e71b4d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx @@ -31,6 +31,7 @@ import TagsList from '../../../components/tags/TagsList'; import { PopupPlacement } from '../../../components/ui/popups'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getRuleUrl } from '../../../helpers/urls'; +import { Dict, RuleDetails } from '../../../types/types'; import { Query } from '../query'; import RuleDetailsTagsPopup from './RuleDetailsTagsPopup'; import SimilarRulesFilter from './SimilarRulesFilter'; @@ -40,8 +41,8 @@ interface Props { hideSimilarRulesFilter?: boolean; onFilterChange: (changes: Partial<Query>) => void; onTagsChange: (tags: string[]) => void; - referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; - ruleDetails: T.RuleDetails; + referencedRepositories: Dict<{ key: string; language: string; name: string }>; + ruleDetails: RuleDetails; } const EXTERNAL_RULE_REPO_PREFIX = 'external_'; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsParameters.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsParameters.tsx index 58ff41b223a..0ac6449d606 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsParameters.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsParameters.tsx @@ -20,13 +20,14 @@ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { sanitizeString } from '../../../helpers/sanitize'; +import { RuleParameter } from '../../../types/types'; interface Props { - params: T.RuleParameter[]; + params: RuleParameter[]; } export default class RuleDetailsParameters extends React.PureComponent<Props> { - renderParameter = (param: T.RuleParameter) => ( + renderParameter = (param: RuleParameter) => ( <tr className="coding-rules-detail-parameter" key={param.key}> <td className="coding-rules-detail-parameter-name">{param.key}</td> <td className="coding-rules-detail-parameter-description"> diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx index 5155a3d0dbf..28274295ed8 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx @@ -28,17 +28,18 @@ import Tooltip from '../../../components/controls/Tooltip'; import SeverityHelper from '../../../components/shared/SeverityHelper'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getQualityProfileUrl } from '../../../helpers/urls'; +import { Dict, RuleActivation, RuleDetails } from '../../../types/types'; import BuiltInQualityProfileBadge from '../../quality-profiles/components/BuiltInQualityProfileBadge'; import ActivationButton from './ActivationButton'; import RuleInheritanceIcon from './RuleInheritanceIcon'; interface Props { - activations: T.RuleActivation[] | undefined; + activations: RuleActivation[] | undefined; canWrite: boolean | undefined; onActivate: () => Promise<void>; onDeactivate: () => Promise<void>; - referencedProfiles: T.Dict<Profile>; - ruleDetails: T.RuleDetails; + referencedProfiles: Dict<Profile>; + ruleDetails: RuleDetails; } export default class RuleDetailsProfiles extends React.PureComponent<Props> { @@ -63,7 +64,7 @@ export default class RuleDetailsProfiles extends React.PureComponent<Props> { } }; - renderInheritedProfile = (activation: T.RuleActivation, profile: Profile) => { + renderInheritedProfile = (activation: RuleActivation, profile: Profile) => { if (!profile.parentName) { return null; } @@ -82,7 +83,7 @@ export default class RuleDetailsProfiles extends React.PureComponent<Props> { ); }; - renderSeverity = (activation: T.RuleActivation, parentActivation?: T.RuleActivation) => ( + renderSeverity = (activation: RuleActivation, parentActivation?: RuleActivation) => ( <td className="coding-rules-detail-quality-profile-severity"> <Tooltip overlay={translate('coding_rules.activation_severity')}> <span> @@ -97,10 +98,7 @@ export default class RuleDetailsProfiles extends React.PureComponent<Props> { </td> ); - renderParameter = ( - param: { key: string; value: string }, - parentActivation?: T.RuleActivation - ) => { + renderParameter = (param: { key: string; value: string }, parentActivation?: RuleActivation) => { const originalParam = parentActivation && parentActivation.params.find(p => p.key === param.key); const originalValue = originalParam && originalParam.value; @@ -121,13 +119,13 @@ export default class RuleDetailsProfiles extends React.PureComponent<Props> { ); }; - renderParameters = (activation: T.RuleActivation, parentActivation?: T.RuleActivation) => ( + renderParameters = (activation: RuleActivation, parentActivation?: RuleActivation) => ( <td className="coding-rules-detail-quality-profile-parameters"> {activation.params.map(param => this.renderParameter(param, parentActivation))} </td> ); - renderActions = (activation: T.RuleActivation, profile: Profile) => { + renderActions = (activation: RuleActivation, profile: Profile) => { const canEdit = profile.actions && profile.actions.edit && !profile.isBuiltIn; const { ruleDetails } = this.props; const hasParent = activation.inherit !== 'NONE' && profile.parentKey; @@ -189,7 +187,7 @@ export default class RuleDetailsProfiles extends React.PureComponent<Props> { ); }; - renderActivation = (activation: T.RuleActivation) => { + renderActivation = (activation: RuleActivation) => { const { activations = [], ruleDetails } = this.props; const profile = this.props.referencedProfiles[activation.qProfile]; if (!profile) { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleInheritanceIcon.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleInheritanceIcon.tsx index 958400360f5..4e872e4f751 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleInheritanceIcon.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleInheritanceIcon.tsx @@ -19,10 +19,11 @@ */ import * as React from 'react'; import { colors } from '../../../app/theme'; +import { RuleInheritance } from '../../../types/types'; interface Props { className?: string; - inheritance: T.RuleInheritance; + inheritance: RuleInheritance; } export default function RuleInheritanceIcon({ className, inheritance, ...other }: Props) { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx index 8900d75c92b..3ad661d4fa9 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx @@ -29,6 +29,7 @@ import SeverityIcon from '../../../components/icons/SeverityIcon'; import TagsList from '../../../components/tags/TagsList'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getRuleUrl } from '../../../helpers/urls'; +import { Rule } from '../../../types/types'; import { Activation, Query } from '../query'; import ActivationButton from './ActivationButton'; import RuleInheritanceIcon from './RuleInheritanceIcon'; @@ -42,7 +43,7 @@ interface Props { onDeactivate: (profile: string, rule: string) => void; onFilterChange: (changes: Partial<Query>) => void; onOpen: (ruleKey: string) => void; - rule: T.Rule; + rule: Rule; selected: boolean; selectedProfile?: Profile; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/SimilarRulesFilter.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/SimilarRulesFilter.tsx index c859875597c..9ccadb9d90f 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/SimilarRulesFilter.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/SimilarRulesFilter.tsx @@ -25,11 +25,12 @@ import IssueTypeIcon from '../../../components/icons/IssueTypeIcon'; import TagsIcon from '../../../components/icons/TagsIcon'; import SeverityHelper from '../../../components/shared/SeverityHelper'; import { translate } from '../../../helpers/l10n'; +import { Rule } from '../../../types/types'; import { Query } from '../query'; interface Props { onFilterChange: (changes: Partial<Query>) => void; - rule: T.Rule; + rule: Rule; } export default class SimilarRulesFilter extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/TemplateFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/TemplateFacet.tsx index 7cd1a8bcc19..3dde2ac9a6d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/TemplateFacet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/TemplateFacet.tsx @@ -22,7 +22,7 @@ import HelpTooltip from '../../../components/controls/HelpTooltip'; import { translate } from '../../../helpers/l10n'; import Facet, { BasicProps } from './Facet'; -interface Props extends T.Omit<BasicProps, 'onChange' | 'values'> { +interface Props extends Omit<BasicProps, 'onChange' | 'values'> { onChange: (changes: { template: boolean | undefined }) => void; value: boolean | undefined; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/PageActions-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/PageActions-test.tsx index a4b82a0412a..8541df87275 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/PageActions-test.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/PageActions-test.tsx @@ -20,12 +20,13 @@ import { shallow } from 'enzyme'; import * as React from 'react'; +import { Paging } from '../../../../types/types'; import PageActions, { PageActionsProps } from '../PageActions'; it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot('default'); expect(shallowRender({ loading: true })).toMatchSnapshot('loading'); - expect(shallowRender({ paging: { total: 100 } as T.Paging })).toMatchSnapshot('with paging'); + expect(shallowRender({ paging: { total: 100 } as Paging })).toMatchSnapshot('with paging'); }); function shallowRender(props: Partial<PageActionsProps> = {}) { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetails-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetails-test.tsx index 2bda64184fe..bc56f355155 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetails-test.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetails-test.tsx @@ -23,6 +23,7 @@ import * as React from 'react'; import { deleteRule, getRuleDetails, updateRule } from '../../../../api/rules'; import { mockQualityProfile } from '../../../../helpers/testMocks'; import { waitAndUpdate } from '../../../../helpers/testUtils'; +import { RuleType } from '../../../../types/types'; import RuleDetails from '../RuleDetails'; jest.mock('../../../../api/rules', () => { @@ -104,7 +105,7 @@ it('should correctly handle rule changes', () => { repo: 'bar', severity: 'MAJOR', status: 'READY', - type: 'BUG' as T.RuleType + type: 'BUG' as RuleType }; wrapper.instance().handleRuleChange(ruleChange); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsDescription-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsDescription-test.tsx index 783583d9f57..4787fb62fe0 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsDescription-test.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsDescription-test.tsx @@ -20,13 +20,14 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { change, click, waitAndUpdate } from '../../../../helpers/testUtils'; +import { RuleDetails } from '../../../../types/types'; import RuleDetailsDescription from '../RuleDetailsDescription'; jest.mock('../../../../api/rules', () => ({ updateRule: jest.fn().mockResolvedValue('updatedrule') })); -const RULE: T.RuleDetails = { +const RULE: RuleDetails = { key: 'squid:S1133', repo: 'squid', name: 'Deprecated code should be removed', @@ -40,7 +41,7 @@ const RULE: T.RuleDetails = { type: 'CODE_SMELL' }; -const EXTERNAL_RULE: T.RuleDetails = { +const EXTERNAL_RULE: RuleDetails = { createdAt: '2013-07-26T09:40:51+0200', key: 'external_xoo:OneExternalIssuePerLine', repo: 'external_xoo', @@ -51,7 +52,7 @@ const EXTERNAL_RULE: T.RuleDetails = { type: 'UNKNOWN' }; -const EXTERNAL_RULE_WITH_DATA: T.RuleDetails = { +const EXTERNAL_RULE_WITH_DATA: RuleDetails = { key: 'external_xoo:OneExternalIssueWithDetailsPerLine', repo: 'external_xoo', name: 'One external issue per line', diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx index cddc097c872..a8fe6708c9d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx @@ -19,10 +19,11 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { RuleDetails } from '../../../../types/types'; import RuleDetailsMeta from '../RuleDetailsMeta'; import RuleDetailsTagsPopup from '../RuleDetailsTagsPopup'; -const RULE: T.RuleDetails = { +const RULE: RuleDetails = { key: 'squid:S1133', repo: 'squid', name: 'Deprecated code should be removed', @@ -35,7 +36,7 @@ const RULE: T.RuleDetails = { type: 'CODE_SMELL' }; -const EXTERNAL_RULE: T.RuleDetails = { +const EXTERNAL_RULE: RuleDetails = { key: 'external_xoo:OneExternalIssuePerLine', repo: 'external_xoo', name: 'xoo:OneExternalIssuePerLine', @@ -47,7 +48,7 @@ const EXTERNAL_RULE: T.RuleDetails = { type: 'UNKNOWN' }; -const EXTERNAL_RULE_WITH_DATA: T.RuleDetails = { +const EXTERNAL_RULE_WITH_DATA: RuleDetails = { key: 'external_xoo:OneExternalIssueWithDetailsPerLine', repo: 'external_xoo', name: 'One external issue per line', diff --git a/server/sonar-web/src/main/js/apps/coding-rules/query.ts b/server/sonar-web/src/main/js/apps/coding-rules/query.ts index b851a8a2369..0407fef13fc 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/query.ts +++ b/server/sonar-web/src/main/js/apps/coding-rules/query.ts @@ -30,6 +30,7 @@ import { serializeString, serializeStringArray } from '../../helpers/query'; +import { Dict, RawQuery, RuleInheritance } from '../../types/types'; export interface Query { activation: boolean | undefined; @@ -37,7 +38,7 @@ export interface Query { availableSince: Date | undefined; compareToProfile: string | undefined; cwe: string[]; - inheritance: T.RuleInheritance | undefined; + inheritance: RuleInheritance | undefined; languages: string[]; owaspTop10: string[]; profile: string | undefined; @@ -61,10 +62,10 @@ export interface Facet { export type Facets = { [F in FacetKey]?: Facet }; -export type OpenFacets = T.Dict<boolean>; +export type OpenFacets = Dict<boolean>; export interface Activation { - inherit: T.RuleInheritance; + inherit: RuleInheritance; severity: string; } @@ -74,7 +75,7 @@ export interface Actives { }; } -export function parseQuery(query: T.RawQuery): Query { +export function parseQuery(query: RawQuery): Query { return { activation: parseAsOptionalBoolean(query.activation), activationSeverities: parseAsArray(query.active_severities, parseAsString), @@ -98,7 +99,7 @@ export function parseQuery(query: T.RawQuery): Query { }; } -export function serializeQuery(query: Query): T.RawQuery { +export function serializeQuery(query: Query): RawQuery { return cleanQuery({ activation: serializeOptionalBoolean(query.activation), active_severities: serializeStringArray(query.activationSeverities), @@ -122,7 +123,7 @@ export function serializeQuery(query: Query): T.RawQuery { }); } -export function areQueriesEqual(a: T.RawQuery, b: T.RawQuery) { +export function areQueriesEqual(a: RawQuery, b: RawQuery) { return queriesEqual(parseQuery(a), parseQuery(b)); } @@ -152,15 +153,15 @@ export function getAppFacet(serverFacet: string): FacetKey { return serverFacet === 'active_severities' ? 'activationSeverities' : (serverFacet as FacetKey); } -export function getOpen(query: T.RawQuery) { +export function getOpen(query: RawQuery) { return query.open; } -export function hasRuleKey(query: T.RawQuery) { +export function hasRuleKey(query: RawQuery) { return Boolean(query.rule_key); } -function parseAsInheritance(value?: string): T.RuleInheritance | undefined { +function parseAsInheritance(value?: string): RuleInheritance | undefined { if (value === 'INHERITED' || value === 'NONE' || value === 'OVERRIDES') { return value; } else { @@ -168,6 +169,6 @@ function parseAsInheritance(value?: string): T.RuleInheritance | undefined { } } -function serializeInheritance(value: T.RuleInheritance | undefined): string | undefined { +function serializeInheritance(value: RuleInheritance | undefined): string | undefined { return value; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/routes.ts b/server/sonar-web/src/main/js/apps/coding-rules/routes.ts index 8049584924b..24bbc0ca79b 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/routes.ts +++ b/server/sonar-web/src/main/js/apps/coding-rules/routes.ts @@ -19,10 +19,11 @@ */ import { RedirectFunction, RouterState } from 'react-router'; import { lazyLoadComponent } from '../../components/lazyLoadComponent'; +import { RawQuery } from '../../types/types'; import { parseQuery, serializeQuery } from './query'; -function parseHash(hash: string): T.RawQuery { - const query: T.RawQuery = {}; +function parseHash(hash: string): RawQuery { + const query: RawQuery = {}; const parts = hash.split('|'); parts.forEach(part => { const tokens = part.split('='); diff --git a/server/sonar-web/src/main/js/apps/component-measures/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/component-measures/__tests__/utils-test.ts index 8b8e75c7701..b113953c327 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/__tests__/utils-test.ts @@ -19,6 +19,7 @@ */ import { ComponentQualifier } from '../../../types/component'; import { MetricKey } from '../../../types/metrics'; +import { ComponentMeasure } from '../../../types/types'; import * as utils from '../utils'; const MEASURES = [ @@ -154,7 +155,7 @@ describe('serializeQuery', () => { }); describe('extract measure', () => { - const componentBuilder = (qual: ComponentQualifier): T.ComponentMeasure => { + const componentBuilder = (qual: ComponentQualifier): ComponentMeasure => { return { qualifier: qual, key: '1', diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx index 080358d770f..b93ce49dd07 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx @@ -47,6 +47,14 @@ import { import { fetchBranchStatus } from '../../../store/rootActions'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier, isPortfolioLike } from '../../../types/component'; +import { + ComponentMeasure, + Dict, + Issue, + MeasureEnhanced, + Metric, + Period +} from '../../../types/types'; import Sidebar from '../sidebar/Sidebar'; import '../style.css'; import { @@ -69,15 +77,15 @@ import MeasuresEmpty from './MeasuresEmpty'; interface Props extends WithRouterProps { branchLike?: BranchLike; - component: T.ComponentMeasure; + component: ComponentMeasure; fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>; } interface State { - leakPeriod?: T.Period; + leakPeriod?: Period; loading: boolean; - measures: T.MeasureEnhanced[]; - metrics: T.Dict<T.Metric>; + measures: MeasureEnhanced[]; + metrics: Dict<Metric>; } export class App extends React.PureComponent<Props, State> { @@ -167,7 +175,7 @@ export class App extends React.PureComponent<Props, State> { ); } - getHelmetTitle = (query: Query, displayOverview: boolean, metric?: T.Metric) => { + getHelmetTitle = (query: Query, displayOverview: boolean, metric?: Metric) => { if (displayOverview && query.metric) { return isProjectOverview(query.metric) ? translate('component_measures.overview.project_overview.facet') @@ -195,7 +203,7 @@ export class App extends React.PureComponent<Props, State> { return metric; }; - handleIssueChange = (_: T.Issue) => { + handleIssueChange = (_: Issue) => { this.refreshBranchStatus(); }; @@ -228,7 +236,7 @@ export class App extends React.PureComponent<Props, State> { } }; - renderContent = (displayOverview: boolean, query: Query, metric?: T.Metric) => { + renderContent = (displayOverview: boolean, query: Query, metric?: Metric) => { const { branchLike, component } = this.props; const { leakPeriod } = this.state; if (displayOverview) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumb.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumb.tsx index 72e4d154497..6f5303558a5 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumb.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumb.tsx @@ -20,12 +20,13 @@ import * as React from 'react'; import Tooltip from '../../../components/controls/Tooltip'; import { collapsePath, limitComponentName } from '../../../helpers/path'; +import { ComponentMeasure, ComponentMeasureIntern } from '../../../types/types'; interface Props { canBrowse: boolean; - component: T.ComponentMeasure; + component: ComponentMeasure; isLast: boolean; - handleSelect: (component: T.ComponentMeasureIntern) => void; + handleSelect: (component: ComponentMeasureIntern) => void; } export default class Breadcrumb extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx index aa2a001df31..7971ad6e08b 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx @@ -22,19 +22,20 @@ import * as React from 'react'; import { getBreadcrumbs } from '../../../api/components'; import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; +import { ComponentMeasure, ComponentMeasureIntern } from '../../../types/types'; import Breadcrumb from './Breadcrumb'; interface Props { backToFirst: boolean; branchLike?: BranchLike; className?: string; - component: T.ComponentMeasure; - handleSelect: (component: T.ComponentMeasureIntern) => void; - rootComponent: T.ComponentMeasure; + component: ComponentMeasure; + handleSelect: (component: ComponentMeasureIntern) => void; + rootComponent: ComponentMeasure; } interface State { - breadcrumbs: T.ComponentMeasure[]; + breadcrumbs: ComponentMeasure[]; } export default class Breadcrumbs extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.tsx index 419886e780d..8537b1734de 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.tsx @@ -27,11 +27,12 @@ import DateFromNow from '../../../components/intl/DateFromNow'; import DateTimeFormatter, { formatterOption } from '../../../components/intl/DateTimeFormatter'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getPeriodDate, getPeriodLabel } from '../../../helpers/periods'; +import { ComponentMeasure, Period } from '../../../types/types'; interface Props { className?: string; - component: T.ComponentMeasure; - period: T.Period; + component: ComponentMeasure; + period: Period; } export class LeakPeriodLegend extends React.PureComponent<Props & WrappedComponentProps> { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx index 268241477f9..07b9ccb32a4 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx @@ -35,6 +35,17 @@ import { BranchLike } from '../../../types/branch-like'; import { isFile, isView } from '../../../types/component'; import { MeasurePageView } from '../../../types/measures'; import { MetricKey } from '../../../types/metrics'; +import { + ComponentMeasure, + ComponentMeasureEnhanced, + ComponentMeasureIntern, + Dict, + Issue, + Measure, + Metric, + Paging, + Period +} from '../../../types/types'; import { complementary } from '../config/complementary'; import FilesView from '../drilldown/FilesView'; import TreeMapView from '../drilldown/TreeMapView'; @@ -46,11 +57,11 @@ import MeasureViewSelect from './MeasureViewSelect'; interface Props { branchLike?: BranchLike; - leakPeriod?: T.Period; - requestedMetric: Pick<T.Metric, 'key' | 'direction'>; - metrics: T.Dict<T.Metric>; - onIssueChange?: (issue: T.Issue) => void; - rootComponent: T.ComponentMeasure; + leakPeriod?: Period; + requestedMetric: Pick<Metric, 'key' | 'direction'>; + metrics: Dict<Metric>; + onIssueChange?: (issue: Issue) => void; + rootComponent: ComponentMeasure; router: InjectedRouter; selected?: string; updateQuery: (query: Partial<Query>) => void; @@ -58,14 +69,14 @@ interface Props { } interface State { - baseComponent?: T.ComponentMeasure; - components: T.ComponentMeasureEnhanced[]; + baseComponent?: ComponentMeasure; + components: ComponentMeasureEnhanced[]; loadingMoreComponents: boolean; - measure?: T.Measure; - metric?: T.Metric; - paging?: T.Paging; - secondaryMeasure?: T.Measure; - selectedComponent?: T.ComponentMeasureIntern; + measure?: Measure; + metric?: Metric; + paging?: Paging; + secondaryMeasure?: Measure; + selectedComponent?: ComponentMeasureIntern; } export default class MeasureContent extends React.PureComponent<Props, State> { @@ -180,7 +191,7 @@ export default class MeasureContent extends React.PureComponent<Props, State> { getComponentRequestParams( view: MeasurePageView, - metric: Pick<T.Metric, 'key' | 'direction'>, + metric: Pick<Metric, 'key' | 'direction'>, options: Object = {} ) { const strategy = view === 'list' ? 'leaves' : 'children'; @@ -231,7 +242,7 @@ export default class MeasureContent extends React.PureComponent<Props, State> { this.props.updateQuery({ view }); }; - onOpenComponent = (component: T.ComponentMeasureIntern) => { + onOpenComponent = (component: ComponentMeasureIntern) => { if (isView(this.props.rootComponent.qualifier)) { const comp = this.state.components.find( c => @@ -253,7 +264,7 @@ export default class MeasureContent extends React.PureComponent<Props, State> { } }; - onSelectComponent = (component: T.ComponentMeasureIntern) => { + onSelectComponent = (component: ComponentMeasureIntern) => { this.setState({ selectedComponent: component }); }; @@ -296,7 +307,7 @@ export default class MeasureContent extends React.PureComponent<Props, State> { selectedIdx={selectedIdx} selectedComponent={ selectedIdx !== undefined - ? (this.state.selectedComponent as T.ComponentMeasureEnhanced) + ? (this.state.selectedComponent as ComponentMeasureEnhanced) : undefined } view={view} diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx index 564017d2dd2..eab63058977 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx @@ -28,16 +28,17 @@ import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; import { isDiffMetric } from '../../../helpers/measures'; import { getMeasureHistoryUrl } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; +import { ComponentMeasure, Measure as TypeMeasure, Metric, Period } from '../../../types/types'; import { hasFullMeasures } from '../utils'; import LeakPeriodLegend from './LeakPeriodLegend'; interface Props { branchLike?: BranchLike; - component: T.ComponentMeasure; - leakPeriod?: T.Period; + component: ComponentMeasure; + leakPeriod?: Period; measureValue?: string; - metric: T.Metric; - secondaryMeasure?: T.Measure; + metric: Metric; + secondaryMeasure?: TypeMeasure; } export default function MeasureHeader(props: Props) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx index 95842447139..a7401368782 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx @@ -26,6 +26,16 @@ import PageActions from '../../../components/ui/PageActions'; import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { isFile } from '../../../types/component'; +import { + ComponentMeasure, + ComponentMeasureEnhanced, + ComponentMeasureIntern, + Dict, + Issue, + Metric, + Paging, + Period +} from '../../../types/types'; import BubbleChart from '../drilldown/BubbleChart'; import { BUBBLES_FETCH_LIMIT, enhanceComponent, getBubbleMetrics, hasFullMeasures } from '../utils'; import Breadcrumbs from './Breadcrumbs'; @@ -35,20 +45,20 @@ import MeasureContentHeader from './MeasureContentHeader'; interface Props { branchLike?: BranchLike; className?: string; - component: T.ComponentMeasure; + component: ComponentMeasure; domain: string; - leakPeriod?: T.Period; + leakPeriod?: Period; loading: boolean; - metrics: T.Dict<T.Metric>; - onIssueChange?: (issue: T.Issue) => void; - rootComponent: T.ComponentMeasure; - updateLoading: (param: T.Dict<boolean>) => void; - updateSelected: (component: T.ComponentMeasureIntern) => void; + metrics: Dict<Metric>; + onIssueChange?: (issue: Issue) => void; + rootComponent: ComponentMeasure; + updateLoading: (param: Dict<boolean>) => void; + updateSelected: (component: ComponentMeasureIntern) => void; } interface State { - components: T.ComponentMeasureEnhanced[]; - paging?: T.Paging; + components: ComponentMeasureEnhanced[]; + paging?: Paging; } export default class MeasureOverview extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx index 0fb21b2703e..b7411553e05 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx @@ -24,6 +24,14 @@ import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branch-li import { getProjectUrl } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; import { isView } from '../../../types/component'; +import { + ComponentMeasure, + ComponentMeasureIntern, + Dict, + Issue, + Metric, + Period +} from '../../../types/types'; import { Query } from '../utils'; import MeasureOverview from './MeasureOverview'; @@ -31,10 +39,10 @@ interface Props { branchLike?: BranchLike; className?: string; domain: string; - leakPeriod?: T.Period; - metrics: T.Dict<T.Metric>; - onIssueChange?: (issue: T.Issue) => void; - rootComponent: T.ComponentMeasure; + leakPeriod?: Period; + metrics: Dict<Metric>; + onIssueChange?: (issue: Issue) => void; + rootComponent: ComponentMeasure; router: InjectedRouter; selected?: string; updateQuery: (query: Partial<Query>) => void; @@ -46,7 +54,7 @@ interface LoadingState { } interface State { - component?: T.ComponentMeasure; + component?: ComponentMeasure; loading: LoadingState; } @@ -103,7 +111,7 @@ export default class MeasureOverviewContainer extends React.PureComponent<Props, } }; - updateSelected = (component: T.ComponentMeasureIntern) => { + updateSelected = (component: ComponentMeasureIntern) => { if (this.state.component && isView(this.state.component.qualifier)) { this.props.router.push(getProjectUrl(component.refKey || component.key, component.branch)); } else { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.tsx index f86e9761b8d..91a7de45691 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.tsx @@ -24,11 +24,12 @@ import TreeIcon from '../../../components/icons/TreeIcon'; import TreemapIcon from '../../../components/icons/TreemapIcon'; import { translate } from '../../../helpers/l10n'; import { MeasurePageView } from '../../../types/measures'; +import { Metric } from '../../../types/types'; import { hasList, hasTree, hasTreemap } from '../utils'; interface Props { className?: string; - metric: T.Metric; + metric: Metric; handleViewChange: (view: MeasurePageView) => void; view: MeasurePageView; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/LeakPeriodLegend-test.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/LeakPeriodLegend-test.tsx index 2ba3b0220a4..9da3eb8d0b1 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/LeakPeriodLegend-test.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/LeakPeriodLegend-test.tsx @@ -21,6 +21,7 @@ import { differenceInDays } from 'date-fns'; import { shallow } from 'enzyme'; import * as React from 'react'; import { IntlShape } from 'react-intl'; +import { ComponentMeasure, Period } from '../../../../types/types'; import { LeakPeriodLegend } from '../LeakPeriodLegend'; jest.mock('date-fns', () => { @@ -40,14 +41,14 @@ const APP = { qualifier: 'APP' }; -const PERIOD: T.Period = { +const PERIOD: Period = { date: '2017-05-16T13:50:02+0200', index: 1, mode: 'previous_version', parameter: '6,4' }; -const PERIOD_DAYS: T.Period = { +const PERIOD_DAYS: Period = { date: '2017-05-16T13:50:02+0200', index: 1, mode: 'days', @@ -68,7 +69,7 @@ it('should render a more precise date', () => { expect(getWrapper(PROJECT, PERIOD)).toMatchSnapshot(); }); -function getWrapper(component: T.ComponentMeasure, period: T.Period) { +function getWrapper(component: ComponentMeasure, period: Period) { return shallow( <LeakPeriodLegend component={component} diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx index 5327a836960..ee9b5d2dd17 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx @@ -20,6 +20,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { mockBranch } from '../../../../helpers/mocks/branch-like'; +import { Period } from '../../../../types/types'; import MeasureHeader from '../MeasureHeader'; const METRIC = { @@ -50,7 +51,7 @@ const PROPS = { index: 1, mode: 'previous_version', parameter: '6,4' - } as T.Period, + } as Period, measureValue: '3.0', metric: METRIC }; diff --git a/server/sonar-web/src/main/js/apps/component-measures/config/complementary.ts b/server/sonar-web/src/main/js/apps/component-measures/config/complementary.ts index ffb3b354597..cc028499b2b 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/config/complementary.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/config/complementary.ts @@ -1,3 +1,5 @@ +import { Dict } from '../../../types/types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -17,7 +19,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export const complementary: T.Dict<string[]> = { +export const complementary: Dict<string[]> = { coverage: ['uncovered_lines', 'uncovered_conditions'], line_coverage: ['uncovered_lines'], branch_coverage: ['uncovered_conditions'], diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChart.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChart.tsx index bfeb34a62df..391ef7c9f0b 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChart.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChart.tsx @@ -32,6 +32,14 @@ import { formatMeasure, isDiffMetric } from '../../../helpers/measures'; import { isDefined } from '../../../helpers/types'; import { isProject } from '../../../types/component'; import { + ComponentMeasure, + ComponentMeasureEnhanced, + ComponentMeasureIntern, + Dict, + Metric, + Paging +} from '../../../types/types'; +import { BUBBLES_FETCH_LIMIT, getBubbleMetrics, getBubbleYDomain, @@ -42,12 +50,12 @@ import EmptyResult from './EmptyResult'; const HEIGHT = 500; interface Props { - component: T.ComponentMeasure; - components: T.ComponentMeasureEnhanced[]; + component: ComponentMeasure; + components: ComponentMeasureEnhanced[]; domain: string; - metrics: T.Dict<T.Metric>; - paging?: T.Paging; - updateSelected: (component: T.ComponentMeasureIntern) => void; + metrics: Dict<Metric>; + paging?: Paging; + updateSelected: (component: ComponentMeasureIntern) => void; } interface State { @@ -59,7 +67,7 @@ export default class BubbleChart extends React.PureComponent<Props, State> { ratingFilters: {} }; - getMeasureVal = (component: T.ComponentMeasureEnhanced, metric: T.Metric) => { + getMeasureVal = (component: ComponentMeasureEnhanced, metric: Metric) => { const measure = component.measures.find(measure => measure.metric.key === metric.key); if (!measure) { return undefined; @@ -68,9 +76,9 @@ export default class BubbleChart extends React.PureComponent<Props, State> { }; getTooltip( - component: T.ComponentMeasureEnhanced, + component: ComponentMeasureEnhanced, values: { x: number; y: number; size: number; colors?: Array<number | undefined> }, - metrics: { x: T.Metric; y: T.Metric; size: T.Metric; colors?: T.Metric[] } + metrics: { x: Metric; y: Metric; size: Metric; colors?: Metric[] } ) { const inner = [ [component.name, isProject(component.qualifier) ? component.branch : undefined] @@ -108,8 +116,7 @@ export default class BubbleChart extends React.PureComponent<Props, State> { }); }; - handleBubbleClick = (component: T.ComponentMeasureEnhanced) => - this.props.updateSelected(component); + handleBubbleClick = (component: ComponentMeasureEnhanced) => this.props.updateSelected(component); getDescription(domain: string) { const description = `component_measures.overview.${domain}.description`; @@ -120,7 +127,7 @@ export default class BubbleChart extends React.PureComponent<Props, State> { return translatedDescription; } - renderBubbleChart(metrics: { x: T.Metric; y: T.Metric; size: T.Metric; colors?: T.Metric[] }) { + renderBubbleChart(metrics: { x: Metric; y: Metric; size: Metric; colors?: Metric[] }) { const { ratingFilters } = this.state; const items = this.props.components @@ -164,7 +171,7 @@ export default class BubbleChart extends React.PureComponent<Props, State> { } return ( - <OriginalBubbleChart<T.ComponentMeasureEnhanced> + <OriginalBubbleChart<ComponentMeasureEnhanced> formatXTick={formatXTick} formatYTick={formatYTick} height={HEIGHT} @@ -177,7 +184,7 @@ export default class BubbleChart extends React.PureComponent<Props, State> { ); } - renderChartHeader(domain: string, sizeMetric: T.Metric, colorsMetric?: T.Metric[]) { + renderChartHeader(domain: string, sizeMetric: Metric, colorsMetric?: Metric[]) { const { ratingFilters } = this.state; const { paging } = this.props; diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx index 7d0d3d5665b..0368d922b16 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx @@ -36,12 +36,13 @@ import { } from '../../../types/component'; import { MeasurePageView } from '../../../types/measures'; import { MetricKey } from '../../../types/metrics'; +import { ComponentMeasure, ComponentMeasureEnhanced, Metric } from '../../../types/types'; export interface ComponentCellProps { branchLike?: BranchLike; - component: T.ComponentMeasureEnhanced; - metric: T.Metric; - rootComponent: T.ComponentMeasure; + component: ComponentMeasureEnhanced; + metric: Metric; + rootComponent: ComponentMeasure; view: MeasurePageView; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx index 1209d04cb86..250eff12b5a 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx @@ -22,17 +22,18 @@ import { getComponentMeasureUniqueKey } from '../../../helpers/component'; import { getLocalizedMetricName } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; import { MeasurePageView } from '../../../types/measures'; +import { ComponentMeasure, ComponentMeasureEnhanced, Dict, Metric } from '../../../types/types'; import { complementary } from '../config/complementary'; import ComponentsListRow from './ComponentsListRow'; import EmptyResult from './EmptyResult'; interface Props { branchLike?: BranchLike; - components: T.ComponentMeasureEnhanced[]; - metric: T.Metric; - metrics: T.Dict<T.Metric>; - rootComponent: T.ComponentMeasure; - selectedComponent?: T.ComponentMeasureEnhanced; + components: ComponentMeasureEnhanced[]; + metric: Metric; + metrics: Dict<Metric>; + rootComponent: ComponentMeasure; + selectedComponent?: ComponentMeasureEnhanced; view: MeasurePageView; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx index ea86423dc39..e2fea247b4e 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx @@ -21,16 +21,17 @@ import classNames from 'classnames'; import * as React from 'react'; import { BranchLike } from '../../../types/branch-like'; import { MeasurePageView } from '../../../types/measures'; +import { ComponentMeasure, ComponentMeasureEnhanced, Metric } from '../../../types/types'; import ComponentCell from './ComponentCell'; import MeasureCell from './MeasureCell'; interface Props { branchLike?: BranchLike; - component: T.ComponentMeasureEnhanced; + component: ComponentMeasureEnhanced; isSelected: boolean; - otherMetrics: T.Metric[]; - metric: T.Metric; - rootComponent: T.ComponentMeasure; + otherMetrics: Metric[]; + metric: Metric; + rootComponent: ComponentMeasure; view: MeasurePageView; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx index 8eb9b7403a8..fede1808bcf 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx @@ -28,21 +28,28 @@ import { formatMeasure, isDiffMetric, isPeriodBestValue } from '../../../helpers import { scrollToElement } from '../../../helpers/scrolling'; import { BranchLike } from '../../../types/branch-like'; import { MeasurePageView } from '../../../types/measures'; +import { + ComponentMeasure, + ComponentMeasureEnhanced, + Dict, + Metric, + Paging +} from '../../../types/types'; import ComponentsList from './ComponentsList'; interface Props { branchLike?: BranchLike; - components: T.ComponentMeasureEnhanced[]; + components: ComponentMeasureEnhanced[]; defaultShowBestMeasures: boolean; fetchMore: () => void; - handleSelect: (component: T.ComponentMeasureEnhanced) => void; - handleOpen: (component: T.ComponentMeasureEnhanced) => void; + handleSelect: (component: ComponentMeasureEnhanced) => void; + handleOpen: (component: ComponentMeasureEnhanced) => void; loadingMore: boolean; - metric: T.Metric; - metrics: T.Dict<T.Metric>; - paging?: T.Paging; - rootComponent: T.ComponentMeasure; - selectedComponent?: T.ComponentMeasureEnhanced; + metric: Metric; + metrics: Dict<Metric>; + paging?: Paging; + rootComponent: ComponentMeasure; + selectedComponent?: ComponentMeasureEnhanced; selectedIdx?: number; view: MeasurePageView; } @@ -121,7 +128,7 @@ export default class FilesView extends React.PureComponent<Props, State> { this.setState({ showBestMeasures: true }); }; - hasBestValue = (component: T.ComponentMeasureEnhanced) => { + hasBestValue = (component: ComponentMeasureEnhanced) => { const { metric } = this.props; const focusedMeasure = component.measures.find(measure => measure.metric.key === metric.key); if (focusedMeasure && isDiffMetric(metric.key)) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/MeasureCell.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/MeasureCell.tsx index 8dfadf8a5e4..5f7e7725f89 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/MeasureCell.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/MeasureCell.tsx @@ -20,11 +20,12 @@ import * as React from 'react'; import Measure from '../../../components/measure/Measure'; import { isDiffMetric } from '../../../helpers/measures'; +import { ComponentMeasureEnhanced, MeasureEnhanced, Metric } from '../../../types/types'; interface Props { - component: T.ComponentMeasureEnhanced; - measure?: T.MeasureEnhanced; - metric: T.Metric; + component: ComponentMeasureEnhanced; + measure?: MeasureEnhanced; + metric: Metric; } export default function MeasureCell({ component, measure, metric }: Props) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx index 052ddfb34a4..4de48eaef18 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx @@ -31,13 +31,14 @@ import { formatMeasure, isDiffMetric } from '../../../helpers/measures'; import { isDefined } from '../../../helpers/types'; import { BranchLike } from '../../../types/branch-like'; import { MetricKey } from '../../../types/metrics'; +import { ComponentMeasureEnhanced, ComponentMeasureIntern, Metric } from '../../../types/types'; import EmptyResult from './EmptyResult'; interface Props { branchLike?: BranchLike; - components: T.ComponentMeasureEnhanced[]; - handleSelect: (component: T.ComponentMeasureIntern) => void; - metric: T.Metric; + components: ComponentMeasureEnhanced[]; + handleSelect: (component: ComponentMeasureIntern) => void; + metric: Metric; } interface State { @@ -112,7 +113,7 @@ export default class TreeMapView extends React.PureComponent<Props, State> { .domain(['ERROR', 'WARN', 'OK', 'NONE']) .range(LEVEL_COLORS); - getPercentColorScale = (metric: T.Metric) => { + getPercentColorScale = (metric: Metric) => { const color = scaleLinear<string, string>().domain([0, 25, 50, 75, 100]); color.range(metric.higherValuesAreBetter ? [...COLORS].reverse() : COLORS); return color; @@ -123,7 +124,7 @@ export default class TreeMapView extends React.PureComponent<Props, State> { .domain([1, 2, 3, 4, 5]) .range(COLORS); - getColorScale = (metric: T.Metric) => { + getColorScale = (metric: Metric) => { if (metric.type === 'LEVEL') { return this.getLevelColorScale(); } @@ -140,10 +141,10 @@ export default class TreeMapView extends React.PureComponent<Props, State> { sizeMetric, sizeValue }: { - colorMetric: T.Metric; + colorMetric: Metric; colorValue?: string; - component: T.ComponentMeasureEnhanced; - sizeMetric: T.Metric; + component: ComponentMeasureEnhanced; + sizeMetric: Metric; sizeValue: number; }) => { const formatted = diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.tsx b/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.tsx index ea1fdfb9823..6523c491d41 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.tsx @@ -30,6 +30,7 @@ import { hasMessage, translate } from '../../../helpers/l10n'; +import { MeasureEnhanced } from '../../../types/types'; import { addMeasureCategories, filterMeasures, @@ -40,7 +41,7 @@ import { import FacetMeasureValue from './FacetMeasureValue'; interface Props { - domain: { name: string; measures: T.MeasureEnhanced[] }; + domain: { name: string; measures: MeasureEnhanced[] }; onChange: (metric: string) => void; onToggle: (property: string) => void; open: boolean; @@ -63,11 +64,7 @@ export default class DomainFacet extends React.PureComponent<Props> { this.props.onToggle(this.props.domain.name); }; - hasFacetSelected = ( - domain: { name: string }, - measures: T.MeasureEnhanced[], - selected: string - ) => { + hasFacetSelected = (domain: { name: string }, measures: MeasureEnhanced[], selected: string) => { const measureSelected = measures.find(measure => measure.metric.key === selected); const overviewSelected = domain.name === selected && this.hasOverview(domain.name); return measureSelected || overviewSelected; @@ -77,7 +74,7 @@ export default class DomainFacet extends React.PureComponent<Props> { return this.props.showFullMeasures && hasBubbleChart(domain); }; - renderItemFacetStat = (item: T.MeasureEnhanced) => { + renderItemFacetStat = (item: MeasureEnhanced) => { return hasFacetStat(item.metric.key) ? ( <FacetMeasureValue displayLeak={this.props.showFullMeasures} measure={item} /> ) : null; diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.tsx b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.tsx index edbfc46005e..b50b5cb298d 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.tsx @@ -21,10 +21,11 @@ import classNames from 'classnames'; import * as React from 'react'; import Measure from '../../../components/measure/Measure'; import { isDiffMetric } from '../../../helpers/measures'; +import { MeasureEnhanced } from '../../../types/types'; interface Props { displayLeak?: boolean; - measure: T.MeasureEnhanced; + measure: MeasureEnhanced; } export default function FacetMeasureValue({ measure, displayLeak }: Props) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx index f2e9f491c1e..c6654b0a593 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx @@ -20,19 +20,20 @@ import * as React from 'react'; import A11ySkipTarget from '../../../app/components/a11y/A11ySkipTarget'; import { translate } from '../../../helpers/l10n'; +import { Dict, MeasureEnhanced } from '../../../types/types'; import { groupByDomains, KNOWN_DOMAINS, PROJECT_OVERVEW, Query } from '../utils'; import DomainFacet from './DomainFacet'; import ProjectOverviewFacet from './ProjectOverviewFacet'; interface Props { - measures: T.MeasureEnhanced[]; + measures: MeasureEnhanced[]; selectedMetric: string; showFullMeasures: boolean; updateQuery: (query: Partial<Query>) => void; } interface State { - openFacets: T.Dict<boolean>; + openFacets: Dict<boolean>; } export default class Sidebar extends React.PureComponent<Props, State> { @@ -84,7 +85,7 @@ export default class Sidebar extends React.PureComponent<Props, State> { } } -function getOpenFacets(openFacets: T.Dict<boolean>, { measures, selectedMetric }: Props) { +function getOpenFacets(openFacets: Dict<boolean>, { measures, selectedMetric }: Props) { const newOpenFacets = { ...openFacets }; const measure = measures.find(measure => measure.metric.key === selectedMetric); if (measure && measure.metric && measure.metric.domain) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/utils.ts b/server/sonar-web/src/main/js/apps/component-measures/utils.ts index 806602382b9..3db8ec9b79a 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/utils.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/utils.ts @@ -27,6 +27,15 @@ import { BranchLike } from '../../types/branch-like'; import { ComponentQualifier } from '../../types/component'; import { MeasurePageView } from '../../types/measures'; import { MetricKey } from '../../types/metrics'; +import { + ComponentMeasure, + ComponentMeasureEnhanced, + Dict, + Measure, + MeasureEnhanced, + Metric, + RawQuery +} from '../../types/types'; import { bubbles } from './config/bubbles'; import { domains } from './config/domains'; @@ -58,30 +67,30 @@ const BANNED_MEASURES = [ 'new_info_violations' ]; -export function filterMeasures(measures: T.MeasureEnhanced[]): T.MeasureEnhanced[] { +export function filterMeasures(measures: MeasureEnhanced[]): MeasureEnhanced[] { return measures.filter(measure => !BANNED_MEASURES.includes(measure.metric.key)); } export function sortMeasures( domainName: string, - measures: Array<T.MeasureEnhanced | string> -): Array<T.MeasureEnhanced | string> { + measures: Array<MeasureEnhanced | string> +): Array<MeasureEnhanced | string> { const config = domains[domainName] || {}; const configOrder = config.order || []; return sortBy(measures, [ - (item: T.MeasureEnhanced | string) => { + (item: MeasureEnhanced | string) => { if (typeof item === 'string') { return configOrder.indexOf(item); } const idx = configOrder.indexOf(item.metric.key); return idx >= 0 ? idx : configOrder.length; }, - (item: T.MeasureEnhanced | string) => + (item: MeasureEnhanced | string) => typeof item === 'string' ? item : getLocalizedMetricName(item.metric) ]); } -export function addMeasureCategories(domainName: string, measures: T.MeasureEnhanced[]) { +export function addMeasureCategories(domainName: string, measures: MeasureEnhanced[]) { const categories = domains[domainName] && domains[domainName].categories; if (categories && categories.length > 0) { return [...categories, ...measures]; @@ -90,10 +99,10 @@ export function addMeasureCategories(domainName: string, measures: T.MeasureEnha } export function enhanceComponent( - component: T.ComponentMeasure, - metric: Pick<T.Metric, 'key'> | undefined, - metrics: T.Dict<T.Metric> -): T.ComponentMeasureEnhanced { + component: ComponentMeasure, + metric: Pick<Metric, 'key'> | undefined, + metrics: Dict<Metric> +): ComponentMeasureEnhanced { if (!component.measures) { return { ...component, measures: [] }; } @@ -116,10 +125,7 @@ export function isSecurityReviewMetric(metricKey: MetricKey | string): boolean { ].includes(metricKey as MetricKey); } -export function banQualityGateMeasure({ - measures = [], - qualifier -}: T.ComponentMeasure): T.Measure[] { +export function banQualityGateMeasure({ measures = [], qualifier }: ComponentMeasure): Measure[] { const bannedMetrics: string[] = []; if (ComponentQualifier.Portfolio !== qualifier && ComponentQualifier.SubPortfolio !== qualifier) { bannedMetrics.push('alert_status'); @@ -130,14 +136,14 @@ export function banQualityGateMeasure({ return measures.filter(measure => !bannedMetrics.includes(measure.metric)); } -export const groupByDomains = memoize((measures: T.MeasureEnhanced[]) => { +export const groupByDomains = memoize((measures: MeasureEnhanced[]) => { const domains = toPairs(groupBy(measures, measure => measure.metric.domain)).map(r => ({ name: r[0], measures: r[1] })); return sortBy(domains, [ - (domain: { name: string; measures: T.MeasureEnhanced[] }) => { + (domain: { name: string; measures: MeasureEnhanced[] }) => { const idx = KNOWN_DOMAINS.indexOf(domain.name); return idx >= 0 ? idx : KNOWN_DOMAINS.length; }, @@ -169,7 +175,7 @@ export function hasFullMeasures(branch?: BranchLike) { return !branch || isBranch(branch); } -export function getMeasuresPageMetricKeys(metrics: T.Dict<T.Metric>, branch?: BranchLike) { +export function getMeasuresPageMetricKeys(metrics: Dict<Metric>, branch?: BranchLike) { const metricKeys = getDisplayMetrics(Object.values(metrics)).map(metric => metric.key); if (isPullRequest(branch)) { @@ -179,7 +185,7 @@ export function getMeasuresPageMetricKeys(metrics: T.Dict<T.Metric>, branch?: Br } } -export function getBubbleMetrics(domain: string, metrics: T.Dict<T.Metric>) { +export function getBubbleMetrics(domain: string, metrics: Dict<Metric>) { const conf = bubbles[domain]; return { x: metrics[conf.x], @@ -214,7 +220,7 @@ export interface Query { } export const parseQuery = memoize( - (urlQuery: T.RawQuery): Query => { + (urlQuery: RawQuery): Query => { const metric = parseAsString(urlQuery['metric']) || DEFAULT_METRIC; return { metric, diff --git a/server/sonar-web/src/main/js/apps/create/project/AzureProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/AzureProjectCreate.tsx index 5df872ec83c..581979a38a3 100644 --- a/server/sonar-web/src/main/js/apps/create/project/AzureProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/AzureProjectCreate.tsx @@ -30,6 +30,7 @@ import { } from '../../../api/alm-integrations'; import { AzureProject, AzureRepository } from '../../../types/alm-integration'; import { AlmSettingsInstance } from '../../../types/alm-settings'; +import { Dict } from '../../../types/types'; import AzureCreateProjectRenderer from './AzureProjectCreateRenderer'; interface Props extends Pick<WithRouterProps, 'location' | 'router'> { @@ -42,12 +43,12 @@ interface Props extends Pick<WithRouterProps, 'location' | 'router'> { interface State { importing: boolean; loading: boolean; - loadingRepositories: T.Dict<boolean>; + loadingRepositories: Dict<boolean>; patIsValid?: boolean; projects?: AzureProject[]; - repositories: T.Dict<AzureRepository[]>; + repositories: Dict<AzureRepository[]>; searching?: boolean; - searchResults?: T.Dict<AzureRepository[]>; + searchResults?: Dict<AzureRepository[]>; searchQuery?: string; selectedRepository?: AzureRepository; settings?: AlmSettingsInstance; diff --git a/server/sonar-web/src/main/js/apps/create/project/AzureProjectCreateRenderer.tsx b/server/sonar-web/src/main/js/apps/create/project/AzureProjectCreateRenderer.tsx index c026d8988a4..f8c09df1c64 100644 --- a/server/sonar-web/src/main/js/apps/create/project/AzureProjectCreateRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/AzureProjectCreateRenderer.tsx @@ -29,6 +29,7 @@ import { getBaseUrl } from '../../../helpers/system'; import { getGlobalSettingsUrl } from '../../../helpers/urls'; import { AzureProject, AzureRepository } from '../../../types/alm-integration'; import { AlmKeys, AlmSettingsInstance } from '../../../types/alm-settings'; +import { Dict } from '../../../types/types'; import { ALM_INTEGRATION } from '../../settings/components/AdditionalCategoryKeys'; import AzurePersonalAccessTokenForm from './AzurePersonalAccessTokenForm'; import AzureProjectsList from './AzureProjectsList'; @@ -39,16 +40,16 @@ export interface AzureProjectCreateRendererProps { canAdmin?: boolean; importing: boolean; loading: boolean; - loadingRepositories: T.Dict<boolean>; + loadingRepositories: Dict<boolean>; onImportRepository: () => void; onOpenProject: (key: string) => void; onPersonalAccessTokenCreate: (token: string) => void; onSearch: (query: string) => void; onSelectRepository: (repository: AzureRepository) => void; projects?: AzureProject[]; - repositories: T.Dict<AzureRepository[]>; + repositories: Dict<AzureRepository[]>; searching?: boolean; - searchResults?: T.Dict<AzureRepository[]>; + searchResults?: Dict<AzureRepository[]>; searchQuery?: string; selectedRepository?: AzureRepository; settings?: AlmSettingsInstance; diff --git a/server/sonar-web/src/main/js/apps/create/project/AzureProjectsList.tsx b/server/sonar-web/src/main/js/apps/create/project/AzureProjectsList.tsx index ffe2f5f01b3..10922f1e4b1 100644 --- a/server/sonar-web/src/main/js/apps/create/project/AzureProjectsList.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/AzureProjectsList.tsx @@ -24,17 +24,18 @@ import ListFooter from '../../../components/controls/ListFooter'; import { Alert } from '../../../components/ui/Alert'; import { translate } from '../../../helpers/l10n'; import { AzureProject, AzureRepository } from '../../../types/alm-integration'; +import { Dict } from '../../../types/types'; import AzureProjectAccordion from './AzureProjectAccordion'; import { CreateProjectModes } from './types'; export interface AzureProjectsListProps { importing: boolean; - loadingRepositories: T.Dict<boolean>; + loadingRepositories: Dict<boolean>; onOpenProject: (key: string) => void; onSelectRepository: (repository: AzureRepository) => void; projects?: AzureProject[]; - repositories: T.Dict<AzureRepository[]>; - searchResults?: T.Dict<AzureRepository[]>; + repositories: Dict<AzureRepository[]>; + searchResults?: Dict<AzureRepository[]>; searchQuery?: string; selectedRepository?: AzureRepository; } diff --git a/server/sonar-web/src/main/js/apps/create/project/BitbucketCloudProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/BitbucketCloudProjectCreate.tsx index 340008673fd..add78a12ba6 100644 --- a/server/sonar-web/src/main/js/apps/create/project/BitbucketCloudProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/BitbucketCloudProjectCreate.tsx @@ -25,6 +25,7 @@ import { } from '../../../api/alm-integrations'; import { BitbucketCloudRepository } from '../../../types/alm-integration'; import { AlmSettingsInstance } from '../../../types/alm-settings'; +import { Paging } from '../../../types/types'; import BitbucketCloudProjectCreateRenderer from './BitbucketCloudProjectCreateRender'; interface Props extends Pick<WithRouterProps, 'location' | 'router'> { @@ -39,7 +40,7 @@ interface State { isLastPage?: boolean; loading: boolean; loadingMore: boolean; - projectsPaging: Omit<T.Paging, 'total'>; + projectsPaging: Omit<Paging, 'total'>; resetPat: boolean; repositories: BitbucketCloudRepository[]; searching: boolean; diff --git a/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx b/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx index 506c1ac489a..8d44d0dc355 100644 --- a/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/CreateProjectModeSelection.tsx @@ -24,13 +24,14 @@ import ChevronsIcon from '../../../components/icons/ChevronsIcon'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getBaseUrl } from '../../../helpers/system'; import { AlmKeys } from '../../../types/alm-settings'; +import { AppState } from '../../../types/types'; import { CreateProjectModes } from './types'; export interface CreateProjectModeSelectionProps { almCounts: { [k in AlmKeys]: number; }; - appState: Pick<T.AppState, 'canAdmin'>; + appState: Pick<AppState, 'canAdmin'>; loadingBindings: boolean; onSelectMode: (mode: CreateProjectModes) => void; onConfigMode: (mode: AlmKeys) => void; diff --git a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx index de750967d72..c26eb266f13 100644 --- a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx @@ -27,6 +27,7 @@ import { withAppState } from '../../../components/hoc/withAppState'; import { translate } from '../../../helpers/l10n'; import { getProjectUrl } from '../../../helpers/urls'; import { AlmKeys, AlmSettingsInstance } from '../../../types/alm-settings'; +import { AppState, LoggedInUser } from '../../../types/types'; import AlmBindingDefinitionForm from '../../settings/components/almIntegration/AlmBindingDefinitionForm'; import AzureProjectCreate from './AzureProjectCreate'; import BitbucketCloudProjectCreate from './BitbucketCloudProjectCreate'; @@ -39,8 +40,8 @@ import './style.css'; import { CreateProjectModes } from './types'; interface Props extends Pick<WithRouterProps, 'router' | 'location'> { - appState: Pick<T.AppState, 'canAdmin' | 'branchesEnabled'>; - currentUser: T.LoggedInUser; + appState: Pick<AppState, 'canAdmin' | 'branchesEnabled'>; + currentUser: LoggedInUser; } interface State { diff --git a/server/sonar-web/src/main/js/apps/create/project/GitHubProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/GitHubProjectCreate.tsx index f49167e7ecc..f48b9bfcdb9 100644 --- a/server/sonar-web/src/main/js/apps/create/project/GitHubProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/GitHubProjectCreate.tsx @@ -29,6 +29,7 @@ import { import { getHostUrl } from '../../../helpers/urls'; import { GithubOrganization, GithubRepository } from '../../../types/alm-integration'; import { AlmKeys, AlmSettingsInstance } from '../../../types/alm-settings'; +import { Paging } from '../../../types/types'; import GitHubProjectCreateRenderer from './GitHubProjectCreateRenderer'; interface Props extends Pick<WithRouterProps, 'location' | 'router'> { @@ -44,7 +45,7 @@ interface State { loadingOrganizations: boolean; loadingRepositories: boolean; organizations: GithubOrganization[]; - repositoryPaging: T.Paging; + repositoryPaging: Paging; repositories: GithubRepository[]; searchQuery: string; selectedOrganization?: GithubOrganization; diff --git a/server/sonar-web/src/main/js/apps/create/project/GitHubProjectCreateRenderer.tsx b/server/sonar-web/src/main/js/apps/create/project/GitHubProjectCreateRenderer.tsx index 70113cbccbb..5b44a19d57c 100644 --- a/server/sonar-web/src/main/js/apps/create/project/GitHubProjectCreateRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/GitHubProjectCreateRenderer.tsx @@ -35,6 +35,7 @@ import { getBaseUrl } from '../../../helpers/system'; import { getProjectUrl } from '../../../helpers/urls'; import { GithubOrganization, GithubRepository } from '../../../types/alm-integration'; import { ComponentQualifier } from '../../../types/component'; +import { Paging } from '../../../types/types'; import CreateProjectPageHeader from './CreateProjectPageHeader'; export interface GitHubProjectCreateRendererProps { @@ -51,7 +52,7 @@ export interface GitHubProjectCreateRendererProps { onSelectRepository: (key: string) => void; organizations: GithubOrganization[]; repositories?: GithubRepository[]; - repositoryPaging: T.Paging; + repositoryPaging: Paging; searchQuery: string; selectedOrganization?: GithubOrganization; selectedRepository?: GithubRepository; diff --git a/server/sonar-web/src/main/js/apps/create/project/GitlabProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/GitlabProjectCreate.tsx index f84bd1a47f0..91702fe8295 100644 --- a/server/sonar-web/src/main/js/apps/create/project/GitlabProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/GitlabProjectCreate.tsx @@ -22,6 +22,7 @@ import { WithRouterProps } from 'react-router'; import { getGitlabProjects, importGitlabProject } from '../../../api/alm-integrations'; import { GitlabProject } from '../../../types/alm-integration'; import { AlmSettingsInstance } from '../../../types/alm-settings'; +import { Paging } from '../../../types/types'; import GitlabProjectCreateRenderer from './GitlabProjectCreateRenderer'; interface Props extends Pick<WithRouterProps, 'location' | 'router'> { @@ -36,7 +37,7 @@ interface State { loading: boolean; loadingMore: boolean; projects?: GitlabProject[]; - projectsPaging: T.Paging; + projectsPaging: Paging; resetPat: boolean; searching: boolean; searchQuery: string; diff --git a/server/sonar-web/src/main/js/apps/create/project/GitlabProjectCreateRenderer.tsx b/server/sonar-web/src/main/js/apps/create/project/GitlabProjectCreateRenderer.tsx index 2b2e761a9d1..309fae339d4 100644 --- a/server/sonar-web/src/main/js/apps/create/project/GitlabProjectCreateRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/GitlabProjectCreateRenderer.tsx @@ -22,6 +22,7 @@ import { translate } from '../../../helpers/l10n'; import { getBaseUrl } from '../../../helpers/system'; import { GitlabProject } from '../../../types/alm-integration'; import { AlmKeys, AlmSettingsInstance } from '../../../types/alm-settings'; +import { Paging } from '../../../types/types'; import CreateProjectPageHeader from './CreateProjectPageHeader'; import GitlabProjectSelectionForm from './GitlabProjectSelectionForm'; import PersonalAccessTokenForm from './PersonalAccessTokenForm'; @@ -37,7 +38,7 @@ export interface GitlabProjectCreateRendererProps { onPersonalAccessTokenCreated: () => void; onSearch: (searchQuery: string) => void; projects?: GitlabProject[]; - projectsPaging: T.Paging; + projectsPaging: Paging; resetPat: boolean; searching: boolean; searchQuery: string; diff --git a/server/sonar-web/src/main/js/apps/create/project/GitlabProjectSelectionForm.tsx b/server/sonar-web/src/main/js/apps/create/project/GitlabProjectSelectionForm.tsx index ed94e6ee0e2..94b5ef613a0 100644 --- a/server/sonar-web/src/main/js/apps/create/project/GitlabProjectSelectionForm.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/GitlabProjectSelectionForm.tsx @@ -33,6 +33,7 @@ import { translate } from '../../../helpers/l10n'; import { getProjectUrl } from '../../../helpers/urls'; import { GitlabProject } from '../../../types/alm-integration'; import { ComponentQualifier } from '../../../types/component'; +import { Paging } from '../../../types/types'; import { CreateProjectModes } from './types'; export interface GitlabProjectSelectionFormProps { @@ -42,7 +43,7 @@ export interface GitlabProjectSelectionFormProps { onLoadMore: () => void; onSearch: (searchQuery: string) => void; projects?: GitlabProject[]; - projectsPaging: T.Paging; + projectsPaging: Paging; searching: boolean; searchQuery: string; } diff --git a/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts b/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts index 48b136593c8..5ba0759d146 100644 --- a/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts +++ b/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts @@ -20,6 +20,7 @@ /* eslint-disable no-console */ import { filterContent, ParsedContent } from '../../../helpers/markdown'; import { mockDocumentationMarkdown } from '../../../helpers/testMocks'; +import { Dict } from '../../../types/types'; jest.mock('remark', () => () => ({ parse: jest.fn().mockReturnValue({}) @@ -92,7 +93,7 @@ it('should correctly handle overrides (replace & add)', () => { key: 'tata' }; - const overrides: T.Dict<ParsedContent> = {}; + const overrides: Dict<ParsedContent> = {}; overrides[foo.url] = { frontmatter: overrideFooDoc, content: overrideFooDoc.content }; overrides[`analysis/languages/${newDoc.key}`] = { frontmatter: newDoc, content: newDoc.content }; const pages = getPages(overrides); @@ -119,7 +120,7 @@ it('should not break the whole doc when one page cannot be parsed', () => { console.error = originalConsoleError; }); -function getPages(overrides: T.Dict<ParsedContent> = {}) { +function getPages(overrides: Dict<ParsedContent> = {}) { // This allows the use of out-of-scope data inside jest.mock // Usually, it is impossible as jest.mock'ed module is hoisted on the top of the file return jest.requireActual('../pages').default(overrides); diff --git a/server/sonar-web/src/main/js/apps/documentation/components/App.tsx b/server/sonar-web/src/main/js/apps/documentation/components/App.tsx index c7847f7656c..254518e5e17 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/App.tsx @@ -34,6 +34,7 @@ import { ParsedContent, separateFrontMatter } from '../../../helpers/markdown'; import { addSideBarClass, removeSideBarClass } from '../../../helpers/pages'; import { isDefined } from '../../../helpers/types'; import { InstalledPlugin, PluginType } from '../../../types/plugins'; +import { Dict } from '../../../types/types'; import { getUrlsList } from '../navTreeUtils'; import getPages from '../pages'; import '../styles.css'; @@ -121,7 +122,7 @@ export default class App extends React.PureComponent<Props, State> { path => regex.test(path) && path !== `/${LANGUAGES_BASE_URL}/overview/` ); - const parsedContent: T.Dict<ParsedContent> = {}; + const parsedContent: Dict<ParsedContent> = {}; pluginsWithDoc.filter(isDefined).forEach(plugin => { const parsed = separateFrontMatter(plugin.content); diff --git a/server/sonar-web/src/main/js/apps/documentation/components/SearchResultEntry.tsx b/server/sonar-web/src/main/js/apps/documentation/components/SearchResultEntry.tsx index ae85ebc33fb..a799e7d92f0 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/SearchResultEntry.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/SearchResultEntry.tsx @@ -20,11 +20,12 @@ import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; +import { Dict } from '../../../types/types'; import { cutWords, DocumentationEntry, highlightMarks } from '../utils'; export interface SearchResult { exactMatch?: boolean; - highlights: T.Dict<[number, number][]>; + highlights: Dict<[number, number][]>; longestTerm: string; page: DocumentationEntry; query: string; diff --git a/server/sonar-web/src/main/js/apps/documentation/components/SearchResults.tsx b/server/sonar-web/src/main/js/apps/documentation/components/SearchResults.tsx index 906ddfba954..61eae9447f1 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/SearchResults.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/SearchResults.tsx @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { DocNavigationItem } from 'Docs/@types/types'; +import { Dict, DocNavigationItem } from 'Docs/@types/types'; import { sortBy } from 'lodash'; import lunr, { LunrBuilder, LunrIndex, LunrToken } from 'lunr'; import * as React from 'react'; @@ -68,7 +68,7 @@ export default class SearchResults extends React.PureComponent<Props> { return undefined; } - const highlights: T.Dict<[number, number][]> = {}; + const highlights: Dict<[number, number][]> = {}; let longestTerm = ''; let exactMatch = false; diff --git a/server/sonar-web/src/main/js/apps/documentation/pages.ts b/server/sonar-web/src/main/js/apps/documentation/pages.ts index 47a77d52f74..be10bbc1312 100644 --- a/server/sonar-web/src/main/js/apps/documentation/pages.ts +++ b/server/sonar-web/src/main/js/apps/documentation/pages.ts @@ -20,12 +20,11 @@ import remark from 'remark'; import visit from 'unist-util-visit'; import { filterContent, ParsedContent, separateFrontMatter } from '../../helpers/markdown'; +import { Dict } from '../../types/types'; import Docs from './documentation.directory-loader'; import { DocumentationEntry, DocumentationEntryScope } from './utils'; -export default function getPages( - parsedOverrides: T.Dict<ParsedContent> = {} -): DocumentationEntry[] { +export default function getPages(parsedOverrides: Dict<ParsedContent> = {}): DocumentationEntry[] { // Get entries, merge with overrides if applicable. const pages = ((Docs as unknown) as Array<{ content: string; path: string }>).map(file => { let parsed = separateFrontMatter(file.content); diff --git a/server/sonar-web/src/main/js/apps/groups/components/App.tsx b/server/sonar-web/src/main/js/apps/groups/components/App.tsx index efa8eeb4429..3a164bc7c5a 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/App.tsx @@ -25,17 +25,18 @@ import ListFooter from '../../../components/controls/ListFooter'; import SearchBox from '../../../components/controls/SearchBox'; import { translate } from '../../../helpers/l10n'; import { omitNil } from '../../../helpers/request'; +import { Group, Paging } from '../../../types/types'; import DeleteForm from './DeleteForm'; import Form from './Form'; import Header from './Header'; import List from './List'; interface State { - groups?: T.Group[]; - editedGroup?: T.Group; - groupToBeDeleted?: T.Group; + groups?: Group[]; + editedGroup?: Group; + groupToBeDeleted?: Group; loading: boolean; - paging?: T.Paging; + paging?: Paging; query: string; } @@ -124,11 +125,11 @@ export default class App extends React.PureComponent<{}, State> { this.setState({ editedGroup: undefined }); }; - openDeleteForm = (group: T.Group) => { + openDeleteForm = (group: Group) => { this.setState({ groupToBeDeleted: group }); }; - openEditForm = (group: T.Group) => { + openEditForm = (group: Group) => { this.setState({ editedGroup: group }); }; diff --git a/server/sonar-web/src/main/js/apps/groups/components/DeleteForm.tsx b/server/sonar-web/src/main/js/apps/groups/components/DeleteForm.tsx index bae62700da5..52f865ec209 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/DeleteForm.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/DeleteForm.tsx @@ -22,9 +22,10 @@ import { ResetButtonLink, SubmitButton } from '../../../components/controls/butt import SimpleModal from '../../../components/controls/SimpleModal'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Group } from '../../../types/types'; interface Props { - group: T.Group; + group: Group; onClose: () => void; onSubmit: () => Promise<void>; } diff --git a/server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx b/server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx index 59f29c29d74..76b0bb20941 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx @@ -21,10 +21,11 @@ import * as React from 'react'; import { ButtonIcon } from '../../../components/controls/buttons'; import BulletListIcon from '../../../components/icons/BulletListIcon'; import { translate } from '../../../helpers/l10n'; +import { Group } from '../../../types/types'; import EditMembersModal from './EditMembersModal'; interface Props { - group: T.Group; + group: Group; onEdit: () => void; } diff --git a/server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx b/server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx index 619ffe94e34..e508954682c 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx @@ -27,16 +27,17 @@ import SelectList, { SelectListSearchParams } from '../../../components/controls/SelectList'; import { translate } from '../../../helpers/l10n'; +import { Group, UserSelected } from '../../../types/types'; interface Props { - group: T.Group; + group: Group; onClose: () => void; } interface State { lastSearchParams?: SelectListSearchParams; needToReload: boolean; - users: T.UserSelected[]; + users: UserSelected[]; usersTotalCount?: number; selectedUsers: string[]; } diff --git a/server/sonar-web/src/main/js/apps/groups/components/Form.tsx b/server/sonar-web/src/main/js/apps/groups/components/Form.tsx index 2efab620f3e..da5cc8c3f2a 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/Form.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/Form.tsx @@ -24,10 +24,11 @@ import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import MandatoryFieldMarker from '../../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../../helpers/l10n'; +import { Group } from '../../../types/types'; interface Props { confirmButtonText: string; - group?: T.Group; + group?: Group; header: string; onClose: () => void; onSubmit: (data: { description: string; name: string }) => Promise<void>; diff --git a/server/sonar-web/src/main/js/apps/groups/components/List.tsx b/server/sonar-web/src/main/js/apps/groups/components/List.tsx index 789811564c1..29670491a78 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/List.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/List.tsx @@ -20,12 +20,13 @@ import { sortBy } from 'lodash'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; +import { Group } from '../../../types/types'; import ListItem from './ListItem'; interface Props { - groups: T.Group[]; - onDelete: (group: T.Group) => void; - onEdit: (group: T.Group) => void; + groups: Group[]; + onDelete: (group: Group) => void; + onEdit: (group: Group) => void; onEditMembers: () => void; showAnyone: boolean; } diff --git a/server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx b/server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx index 4e90fd62a63..ea3a33fe7b3 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx @@ -23,12 +23,13 @@ import ActionsDropdown, { ActionsDropdownItem } from '../../../components/controls/ActionsDropdown'; import { translate } from '../../../helpers/l10n'; +import { Group } from '../../../types/types'; import EditMembers from './EditMembers'; export interface ListItemProps { - group: T.Group; - onDelete: (group: T.Group) => void; - onEdit: (group: T.Group) => void; + group: Group; + onDelete: (group: Group) => void; + onEdit: (group: Group) => void; onEditMembers: () => void; } diff --git a/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx b/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx index d0565a11fd2..cc521d50394 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx @@ -25,6 +25,7 @@ import { parseIssueFromResponse } from '../../../helpers/issues'; import { fetchBranchStatus } from '../../../store/rootActions'; import { getCurrentUser, Store } from '../../../store/rootReducer'; import { FetchIssuesPromise } from '../../../types/issues'; +import { RawQuery } from '../../../types/types'; const IssuesAppContainer = lazyLoadComponent(() => import('./IssuesApp'), 'IssuesAppContainer'); @@ -33,7 +34,7 @@ const mapStateToProps = (state: Store) => ({ fetchIssues }); -const fetchIssues = (query: T.RawQuery) => { +const fetchIssues = (query: RawQuery) => { return searchIssues({ ...query, additionalFields: '_all', diff --git a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx index 3e129863e3e..99005d400ce 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx @@ -37,6 +37,7 @@ import { Alert } from '../../../components/ui/Alert'; import Avatar from '../../../components/ui/Avatar'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { isLoggedIn, isUserActive } from '../../../helpers/users'; +import { Component, CurrentUser, Dict, Issue, IssueType, Paging } from '../../../types/types'; import { searchAssignees } from '../utils'; interface AssigneeOption { @@ -52,9 +53,9 @@ interface TagOption { } interface Props { - component: T.Component | undefined; - currentUser: T.CurrentUser; - fetchIssues: (x: {}) => Promise<{ issues: T.Issue[]; paging: T.Paging }>; + component: Component | undefined; + currentUser: CurrentUser; + fetchIssues: (x: {}) => Promise<{ issues: Issue[]; paging: Paging }>; onClose: () => void; onDone: () => void; } @@ -72,10 +73,10 @@ interface FormFields { interface State extends FormFields { initialTags: Array<{ label: string; value: string }>; - issues: T.Issue[]; + issues: Issue[]; // used for initial loading of issues loading: boolean; - paging?: T.Paging; + paging?: Paging; // used when submitting a form submitting: boolean; } @@ -237,8 +238,8 @@ export default class BulkChangeModal extends React.PureComponent<Props, State> { ); }; - getAvailableTransitions(issues: T.Issue[]) { - const transitions: T.Dict<number> = {}; + getAvailableTransitions(issues: Issue[]) { + const transitions: Dict<number> = {}; issues.forEach(issue => { if (issue.transitions) { issue.transitions.forEach(t => { @@ -345,7 +346,7 @@ export default class BulkChangeModal extends React.PureComponent<Props, State> { return null; } - const types: T.IssueType[] = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; + const types: IssueType[] = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; const options = types.map(type => ({ label: translate('issue.type', type), value: type })); const optionRenderer = (option: { label: string; value: string }) => ( @@ -558,7 +559,7 @@ export default class BulkChangeModal extends React.PureComponent<Props, State> { } function hasAction(action: string) { - return (issue: T.Issue) => issue.actions && issue.actions.includes(action); + return (issue: Issue) => issue.actions && issue.actions.includes(action); } function promptCreateTag(label: string) { diff --git a/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx b/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx index c9c8abcd276..1265aa1c6bc 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx @@ -23,11 +23,12 @@ import QualifierIcon from '../../../components/icons/QualifierIcon'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { collapsePath, limitComponentName } from '../../../helpers/path'; import { ComponentQualifier, isView } from '../../../types/component'; +import { Component, Issue } from '../../../types/types'; import { getSelectedLocation } from '../utils'; interface Props { - component?: T.Component; - issue: T.Issue; + component?: Component; + issue: Issue; selectedFlowIndex?: number; selectedLocationIndex?: number; } diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx index 474aacb0a11..26583678441 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx @@ -62,6 +62,15 @@ import { ReferencedRule } from '../../../types/issues'; import { SecurityStandard } from '../../../types/security'; +import { + Component, + CurrentUser, + Dict, + Issue, + Paging, + RawQuery, + UserBase +} from '../../../types/types'; import * as actions from '../actions'; import ConciseIssuesList from '../conciseIssuesList/ConciseIssuesList'; import ConciseIssuesListHeader from '../conciseIssuesList/ConciseIssuesListHeader'; @@ -92,10 +101,10 @@ import PageActions from './PageActions'; interface Props { branchLike?: BranchLike; - component?: T.Component; - currentUser: T.CurrentUser; + component?: Component; + currentUser: CurrentUser; fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => void; - fetchIssues: (query: T.RawQuery) => Promise<FetchIssuesPromise>; + fetchIssues: (query: RawQuery) => Promise<FetchIssuesPromise>; location: Location; onBranchesChange?: () => void; router: Pick<Router, 'push' | 'replace'>; @@ -107,23 +116,23 @@ export interface State { checkAll?: boolean; checked: string[]; effortTotal?: number; - facets: T.Dict<Facet>; - issues: T.Issue[]; + facets: Dict<Facet>; + issues: Issue[]; loading: boolean; - loadingFacets: T.Dict<boolean>; + loadingFacets: Dict<boolean>; loadingMore: boolean; locationsNavigator: boolean; myIssues: boolean; - openFacets: T.Dict<boolean>; - openIssue?: T.Issue; + openFacets: Dict<boolean>; + openIssue?: Issue; openPopup?: { issue: string; name: string }; - paging?: T.Paging; + paging?: Paging; query: Query; - referencedComponentsById: T.Dict<ReferencedComponent>; - referencedComponentsByKey: T.Dict<ReferencedComponent>; - referencedLanguages: T.Dict<ReferencedLanguage>; - referencedRules: T.Dict<ReferencedRule>; - referencedUsers: T.Dict<T.UserBase>; + referencedComponentsById: Dict<ReferencedComponent>; + referencedComponentsByKey: Dict<ReferencedComponent>; + referencedLanguages: Dict<ReferencedLanguage>; + referencedRules: Dict<ReferencedRule>; + referencedUsers: Dict<UserBase>; selected?: string; selectedFlowIndex?: number; selectedLocationIndex?: number; @@ -301,7 +310,7 @@ export default class App extends React.PureComponent<Props, State> { return index !== -1 ? index : undefined; } - getOpenIssue = (props: Props, issues: T.Issue[]) => { + getOpenIssue = (props: Props, issues: Issue[]) => { const open = getOpen(props.location.query); return open ? issues.find(issue => issue.key === open) : undefined; }; @@ -398,7 +407,7 @@ export default class App extends React.PureComponent<Props, State> { createdAfterIncludesTime = () => Boolean(this.props.location.query.createdAfter?.includes('T')); - fetchIssues = (additional: T.RawQuery, requestFacets = false): Promise<FetchIssuesPromise> => { + fetchIssues = (additional: RawQuery, requestFacets = false): Promise<FetchIssuesPromise> => { const { component } = this.props; const { myIssues, openFacets, query } = this.state; @@ -408,7 +417,7 @@ export default class App extends React.PureComponent<Props, State> { .join(',') : undefined; - const parameters: T.Dict<string | undefined> = { + const parameters: Dict<string | undefined> = { ...getBranchLikeQuery(this.props.branchLike), componentKeys: component && component.key, s: 'FILE_LINE', @@ -441,7 +450,7 @@ export default class App extends React.PureComponent<Props, State> { this.setState({ checked: [], loading: true }); if (openIssueKey !== undefined) { - fetchPromise = this.fetchIssuesUntil(1, (pageIssues: T.Issue[], paging: T.Paging) => { + fetchPromise = this.fetchIssuesUntil(1, (pageIssues: Issue[], paging: Paging) => { if ( paging.total <= paging.pageIndex * paging.pageSize || paging.pageIndex * paging.pageSize >= MAX_INITAL_FETCH @@ -497,9 +506,9 @@ export default class App extends React.PureComponent<Props, State> { fetchIssuesUntil = ( page: number, - done: (pageIssues: T.Issue[], paging: T.Paging) => boolean + done: (pageIssues: Issue[], paging: Paging) => boolean ): Promise<FetchIssuesPromise> => { - const recursiveFetch = (p: number, prevIssues: T.Issue[]): Promise<FetchIssuesPromise> => { + const recursiveFetch = (p: number, prevIssues: Issue[]): Promise<FetchIssuesPromise> => { return this.fetchIssuesPage(p).then(({ issues: pageIssues, paging, ...other }) => { const issues = [...prevIssues, ...pageIssues]; return done(pageIssues, paging) @@ -546,9 +555,9 @@ export default class App extends React.PureComponent<Props, State> { return Promise.reject(undefined); } - const isSameComponent = (issue: T.Issue) => issue.component === openIssue.component; + const isSameComponent = (issue: Issue) => issue.component === openIssue.component; - const done = (pageIssues: T.Issue[], p: T.Paging) => { + const done = (pageIssues: Issue[], p: Paging) => { const lastIssue = pageIssues[pageIssues.length - 1]; if (p.total <= p.pageIndex * p.pageSize) { return true; @@ -623,12 +632,12 @@ export default class App extends React.PureComponent<Props, State> { getCheckedIssues = () => { const issues = this.state.checked .map(checked => this.state.issues.find(issue => issue.key === checked)) - .filter((issue): issue is T.Issue => issue !== undefined); + .filter((issue): issue is Issue => issue !== undefined); const paging = { pageIndex: 1, pageSize: issues.length, total: issues.length }; return Promise.resolve({ issues, paging }); }; - getButtonLabel = (checked: string[], checkAll = false, paging?: T.Paging) => { + getButtonLabel = (checked: string[], checkAll = false, paging?: Paging) => { if (checked.length === 0) { return translate('bulk_change'); } @@ -768,7 +777,7 @@ export default class App extends React.PureComponent<Props, State> { })); }; - handleIssueChange = (issue: T.Issue) => { + handleIssueChange = (issue: Issue) => { this.refreshBranchStatus(); this.setState(state => ({ issues: state.issues.map(candidate => (candidate.key === issue.key ? issue : candidate)), @@ -944,7 +953,7 @@ export default class App extends React.PureComponent<Props, State> { ); } - renderSide(openIssue: T.Issue | undefined) { + renderSide(openIssue: Issue | undefined) { const { canBrowseAllChildProjects, qualifier = ComponentQualifier.Project } = this.props.component || {}; return ( @@ -1044,8 +1053,8 @@ export default class App extends React.PureComponent<Props, State> { paging, selectedIndex }: { - openIssue: T.Issue | undefined; - paging: T.Paging | undefined; + openIssue: Issue | undefined; + paging: Paging | undefined; selectedIndex: number | undefined; }) { return openIssue ? ( diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx index 783876c7ad3..29866223bda 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx @@ -19,21 +19,22 @@ */ import * as React from 'react'; import { BranchLike } from '../../../types/branch-like'; +import { Component, Issue } from '../../../types/types'; import { Query, scrollToIssue } from '../utils'; import ListItem from './ListItem'; interface Props { branchLike: BranchLike | undefined; checked: string[]; - component: T.Component | undefined; - issues: T.Issue[]; + component: Component | undefined; + issues: Issue[]; onFilterChange: (changes: Partial<Query>) => void; - onIssueChange: (issue: T.Issue) => void; + onIssueChange: (issue: Issue) => void; onIssueCheck: ((issueKey: string) => void) | undefined; onIssueClick: (issueKey: string) => void; onPopupToggle: (issue: string, popupName: string, open?: boolean) => void; openPopup: { issue: string; name: string } | undefined; - selectedIssue: T.Issue | undefined; + selectedIssue: Issue | undefined; } interface State { diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx index f09aea4e498..caf7b66f245 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx @@ -21,18 +21,19 @@ import * as React from 'react'; import SourceViewer from '../../../components/SourceViewer/SourceViewer'; import { scrollToElement } from '../../../helpers/scrolling'; import { BranchLike } from '../../../types/branch-like'; +import { Issue } from '../../../types/types'; import CrossComponentSourceViewer from '../crossComponentSourceViewer/CrossComponentSourceViewer'; import { getLocations, getSelectedLocation } from '../utils'; interface Props { branchLike: BranchLike | undefined; - issues: T.Issue[]; - loadIssues: (component: string, from: number, to: number) => Promise<T.Issue[]>; + issues: Issue[]; + loadIssues: (component: string, from: number, to: number) => Promise<Issue[]>; locationsNavigator: boolean; - onIssueChange: (issue: T.Issue) => void; + onIssueChange: (issue: Issue) => void; onIssueSelect: (issueKey: string) => void; onLocationSelect: (index: number) => void; - openIssue: T.Issue; + openIssue: Issue; selectedFlowIndex: number | undefined; selectedLocationIndex: number | undefined; } diff --git a/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx b/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx index 9900b6f07ea..685f4ac03e6 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx @@ -20,26 +20,27 @@ import * as React from 'react'; import Issue from '../../../components/issue/Issue'; import { BranchLike } from '../../../types/branch-like'; +import { Component, Issue as TypeIssue } from '../../../types/types'; import { Query } from '../utils'; import ComponentBreadcrumbs from './ComponentBreadcrumbs'; interface Props { branchLike: BranchLike | undefined; checked: boolean; - component: T.Component | undefined; - issue: T.Issue; - onChange: (issue: T.Issue) => void; + component: Component | undefined; + issue: TypeIssue; + onChange: (issue: TypeIssue) => void; onCheck: ((issueKey: string) => void) | undefined; onClick: (issueKey: string) => void; onFilterChange: (changes: Partial<Query>) => void; onPopupToggle: (issue: string, popupName: string, open?: boolean) => void; openPopup: string | undefined; - previousIssue: T.Issue | undefined; + previousIssue: TypeIssue | undefined; selected: boolean; } export default class ListItem extends React.PureComponent<Props> { - handleFilter = (property: string, issue: T.Issue) => { + handleFilter = (property: string, issue: TypeIssue) => { const { onFilterChange } = this.props; const issuesReset = { issues: [] }; diff --git a/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx b/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx index 9437e70468b..579904469c5 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx @@ -22,13 +22,14 @@ import HomePageSelect from '../../../components/controls/HomePageSelect'; import PageShortcutsTooltip from '../../../components/ui/PageShortcutsTooltip'; import { translate } from '../../../helpers/l10n'; import { isSonarCloud } from '../../../helpers/system'; +import { Paging } from '../../../types/types'; import IssuesCounter from './IssuesCounter'; import TotalEffort from './TotalEffort'; export interface PageActionsProps { canSetHome: boolean; effortTotal: number | undefined; - paging?: T.Paging; + paging?: Paging; selectedIndex?: number; } diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx index 58c14d823fb..89a73f20aa3 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx @@ -24,6 +24,7 @@ import { SubmitButton } from '../../../../components/controls/buttons'; import SelectLegacy from '../../../../components/controls/SelectLegacy'; import { mockIssue } from '../../../../helpers/testMocks'; import { change, waitAndUpdate } from '../../../../helpers/testUtils'; +import { Issue } from '../../../../types/types'; import BulkChangeModal, { MAX_PAGE_SIZE } from '../BulkChangeModal'; jest.mock('../../../../api/issues', () => ({ @@ -73,7 +74,7 @@ it('should display form when issues are present', async () => { }); it('should display warning when too many issues are passed', async () => { - const issues: T.Issue[] = []; + const issues: Issue[] = []; for (let i = MAX_PAGE_SIZE + 1; i > 0; i--) { issues.push(mockIssue()); } @@ -85,7 +86,7 @@ it('should display warning when too many issues are passed', async () => { }); it('should properly handle the search for assignee', async () => { - const issues: T.Issue[] = []; + const issues: Issue[] = []; for (let i = MAX_PAGE_SIZE + 1; i > 0; i--) { issues.push(mockIssue()); } @@ -127,7 +128,7 @@ it('should disable the submit button unless some change is configured', async () }); }); -const getWrapper = (issues: T.Issue[]) => { +const getWrapper = (issues: Issue[]) => { return shallow<BulkChangeModal>( <BulkChangeModal component={undefined} diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx index 404e5859b82..35971e463b5 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx @@ -40,6 +40,7 @@ import { } from '../../../../helpers/testMocks'; import { KEYCODE_MAP, keydown, waitAndUpdate } from '../../../../helpers/testUtils'; import { ComponentQualifier } from '../../../../types/component'; +import { Issue, Paging } from '../../../../types/types'; import { disableLocationsNavigator, enableLocationsNavigator, @@ -402,7 +403,7 @@ it('should correctly handle filter changes', () => { }); it('should fetch issues until defined', async () => { - const mockDone = (_: T.Issue[], paging: T.Paging) => + const mockDone = (_: Issue[], paging: Paging) => paging.total <= paging.pageIndex * paging.pageSize; const wrapper = shallowRender({ @@ -504,7 +505,7 @@ it('should refresh branch status if issues are updated', async () => { const instance = wrapper.instance(); await waitAndUpdate(wrapper); - const updatedIssue: T.Issue = { ...ISSUES[0], type: 'SECURITY_HOTSPOT' }; + const updatedIssue: Issue = { ...ISSUES[0], type: 'SECURITY_HOTSPOT' }; instance.handleIssueChange(updatedIssue); expect(wrapper.state().issues).toEqual([updatedIssue, ISSUES[1], ISSUES[2], ISSUES[3]]); expect(fetchBranchStatus).toBeCalledWith(branchLike, component.key); @@ -520,7 +521,7 @@ it('should update the open issue when it is changed', async () => { wrapper.setState({ openIssue: ISSUES[0] }); - const updatedIssue: T.Issue = { ...ISSUES[0], type: 'SECURITY_HOTSPOT' }; + const updatedIssue: Issue = { ...ISSUES[0], type: 'SECURITY_HOTSPOT' }; wrapper.instance().handleIssueChange(updatedIssue); expect(wrapper.state().openIssue).toBe(updatedIssue); diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssue.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssue.tsx index 5ac85daa5cb..78c07e48268 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssue.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssue.tsx @@ -18,15 +18,16 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Issue } from '../../../types/types'; import ConciseIssueBox from './ConciseIssueBox'; import ConciseIssueComponent from './ConciseIssueComponent'; interface Props { - issue: T.Issue; + issue: Issue; onFlowSelect: (index: number) => void; onLocationSelect: (index: number) => void; onSelect: (issueKey: string) => void; - previousIssue: T.Issue | undefined; + previousIssue: Issue | undefined; scroll: (element: Element) => void; selected: boolean; selectedFlowIndex: number | undefined; diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx index a63e8a7f159..e9691262f3b 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx @@ -20,11 +20,12 @@ import classNames from 'classnames'; import * as React from 'react'; import TypeHelper from '../../../components/shared/TypeHelper'; +import { Issue } from '../../../types/types'; import ConciseIssueLocations from './ConciseIssueLocations'; import ConciseIssueLocationsNavigator from './ConciseIssueLocationsNavigator'; interface Props { - issue: T.Issue; + issue: Issue; onClick: (issueKey: string) => void; onFlowSelect: (index: number) => void; onLocationSelect: (index: number) => void; diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocations.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocations.tsx index fe1b4cfad28..cd6a95ab52e 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocations.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocations.tsx @@ -19,10 +19,11 @@ */ import * as React from 'react'; import { Button } from '../../../components/controls/buttons'; +import { Issue } from '../../../types/types'; import ConciseIssueLocationBadge from './ConciseIssueLocationBadge'; interface Props { - issue: Pick<T.Issue, 'flows' | 'secondaryLocations'>; + issue: Pick<Issue, 'flows' | 'secondaryLocations'>; onFlowSelect: (index: number) => void; selectedFlowIndex: number | undefined; } diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocationsNavigator.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocationsNavigator.tsx index 7d65a636711..1dc1ef98f20 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocationsNavigator.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocationsNavigator.tsx @@ -19,12 +19,13 @@ */ import { uniq } from 'lodash'; import * as React from 'react'; +import { Issue } from '../../../types/types'; import { getLocations } from '../utils'; import ConciseIssueLocationsNavigatorLocation from './ConciseIssueLocationsNavigatorLocation'; import CrossFileLocationsNavigator from './CrossFileLocationsNavigator'; interface Props { - issue: Pick<T.Issue, 'component' | 'key' | 'flows' | 'secondaryLocations' | 'type'>; + issue: Pick<Issue, 'component' | 'key' | 'flows' | 'secondaryLocations' | 'type'>; onLocationSelect: (index: number) => void; scroll: (element: Element) => void; selectedFlowIndex: number | undefined; diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesList.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesList.tsx index 77058d1e9b4..fc05ac04ee5 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesList.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesList.tsx @@ -19,10 +19,11 @@ */ import * as React from 'react'; import { scrollToElement } from '../../../helpers/scrolling'; +import { Issue } from '../../../types/types'; import ConciseIssue from './ConciseIssue'; interface Props { - issues: T.Issue[]; + issues: Issue[]; onFlowSelect: (index: number) => void; onIssueSelect: (issueKey: string) => void; onLocationSelect: (index: number) => void; diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/CrossFileLocationsNavigator.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/CrossFileLocationsNavigator.tsx index 09d1a4db6d7..5b920f4e1b7 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/CrossFileLocationsNavigator.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/CrossFileLocationsNavigator.tsx @@ -20,11 +20,12 @@ import * as React from 'react'; import { translateWithParameters } from '../../../helpers/l10n'; import { collapsePath } from '../../../helpers/path'; +import { FlowLocation, Issue } from '../../../types/types'; import ConciseIssueLocationsNavigatorLocation from './ConciseIssueLocationsNavigatorLocation'; interface Props { - issue: Pick<T.Issue, 'key' | 'type'>; - locations: T.FlowLocation[]; + issue: Pick<Issue, 'key' | 'type'>; + locations: FlowLocation[]; onLocationSelect: (index: number) => void; scroll: (element: Element) => void; selectedLocationIndex: number | undefined; @@ -38,7 +39,7 @@ interface LocationGroup { component: string | undefined; componentName: string | undefined; firstLocationIndex: number; - locations: T.FlowLocation[]; + locations: FlowLocation[]; } const MAX_PATH_LENGTH = 15; @@ -69,10 +70,10 @@ export default class CrossFileLocationsNavigator extends React.PureComponent<Pro this.setState({ collapsed: false }); }; - groupByFile = (locations: T.FlowLocation[]) => { + groupByFile = (locations: FlowLocation[]) => { const groups: LocationGroup[] = []; - let currentLocations: T.FlowLocation[] = []; + let currentLocations: FlowLocation[] = []; let currentComponent: string | undefined; let currentComponentName: string | undefined; let currentFirstLocationIndex = 0; diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx index fd259dfa26a..ffa5c92235a 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx @@ -19,9 +19,10 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { Issue } from '../../../../types/types'; import ConciseIssue from '../ConciseIssue'; -const issue: T.Issue = { +const issue: Issue = { actions: [], component: '', componentLongName: 'src/file.js', diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssueLocationsNavigator-test.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssueLocationsNavigator-test.tsx index 454f5025682..8772152ab7b 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssueLocationsNavigator-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssueLocationsNavigator-test.tsx @@ -20,23 +20,24 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { mockIssue } from '../../../../helpers/testMocks'; +import { FlowLocation } from '../../../../types/types'; import ConciseIssueLocationsNavigator from '../ConciseIssueLocationsNavigator'; -const location1: T.FlowLocation = { +const location1: FlowLocation = { component: 'foo', componentName: 'src/foo.js', msg: 'Do not use foo', textRange: { startLine: 7, endLine: 7, startOffset: 5, endOffset: 8 } }; -const location2: T.FlowLocation = { +const location2: FlowLocation = { component: 'foo', componentName: 'src/foo.js', msg: 'Do not use foo', textRange: { startLine: 8, endLine: 8, startOffset: 0, endOffset: 5 } }; -const location3: T.FlowLocation = { +const location3: FlowLocation = { component: 'bar', componentName: 'src/bar.js', msg: 'Do not use bar', diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssuesList-test.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssuesList-test.tsx index 5627f897135..f8415993160 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssuesList-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssuesList-test.tsx @@ -19,10 +19,11 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { Issue } from '../../../../types/types'; import ConciseIssuesList from '../ConciseIssuesList'; it('should render', () => { - const issues = [{ key: 'foo' }, { key: 'bar' }] as T.Issue[]; + const issues = [{ key: 'foo' }, { key: 'bar' }] as Issue[]; expect( shallow( <ConciseIssuesList diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/CrossFileLocationsNavigator-test.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/CrossFileLocationsNavigator-test.tsx index dd7a5f92199..020732012ee 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/CrossFileLocationsNavigator-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/CrossFileLocationsNavigator-test.tsx @@ -21,23 +21,24 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { mockFlowLocation } from '../../../../helpers/testMocks'; import { click } from '../../../../helpers/testUtils'; +import { FlowLocation } from '../../../../types/types'; import CrossFileLocationsNavigator from '../CrossFileLocationsNavigator'; -const location1: T.FlowLocation = { +const location1: FlowLocation = { component: 'foo', componentName: 'src/foo.js', msg: 'Do not use foo', textRange: { startLine: 7, endLine: 7, startOffset: 5, endOffset: 8 } }; -const location2: T.FlowLocation = { +const location2: FlowLocation = { component: 'foo', componentName: 'src/foo.js', msg: 'Do not use foo', textRange: { startLine: 8, endLine: 8, startOffset: 0, endOffset: 5 } }; -const location3: T.FlowLocation = { +const location3: FlowLocation = { component: 'bar', componentName: 'src/bar.js', msg: 'Do not use bar', diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx index 17cf8de81ce..a57ae654bcb 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx @@ -26,6 +26,19 @@ import { locationsByLine } from '../../../components/SourceViewer/helpers/indexi import SourceViewerHeaderSlim from '../../../components/SourceViewer/SourceViewerHeaderSlim'; import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; +import { + Dict, + Duplication, + ExpandDirection, + FlowLocation, + Issue as TypeIssue, + IssuesByLine, + LinearIssueLocation, + Snippet, + SnippetGroup, + SourceLine, + SourceViewerFile +} from '../../../types/types'; import SnippetViewer from './SnippetViewer'; import { createSnippets, @@ -37,34 +50,34 @@ import { interface Props { branchLike: BranchLike | undefined; - duplications?: T.Duplication[]; + duplications?: Duplication[]; duplicationsByLine?: { [line: number]: number[] }; highlightedLocationMessage: { index: number; text: string | undefined } | undefined; isLastOccurenceOfPrimaryComponent: boolean; - issue: T.Issue; + issue: TypeIssue; issuePopup?: { issue: string; name: string }; - issuesByLine: T.IssuesByLine; + issuesByLine: IssuesByLine; lastSnippetGroup: boolean; - loadDuplications: (component: string, line: T.SourceLine) => void; - locations: T.FlowLocation[]; - onIssueChange: (issue: T.Issue) => void; + loadDuplications: (component: string, line: SourceLine) => void; + locations: FlowLocation[]; + onIssueChange: (issue: TypeIssue) => void; onIssuePopupToggle: (issue: string, popupName: string, open?: boolean) => void; onLocationSelect: (index: number) => void; renderDuplicationPopup: ( - component: T.SourceViewerFile, + component: SourceViewerFile, index: number, line: number ) => React.ReactNode; scroll?: (element: HTMLElement, offset: number) => void; - snippetGroup: T.SnippetGroup; + snippetGroup: SnippetGroup; } interface State { - additionalLines: { [line: number]: T.SourceLine }; + additionalLines: { [line: number]: SourceLine }; highlightedSymbols: string[]; loading: boolean; - openIssuesByLine: T.Dict<boolean>; - snippets: T.Snippet[]; + openIssuesByLine: Dict<boolean>; + snippets: Snippet[]; } export default class ComponentSourceSnippetGroupViewer extends React.PureComponent<Props, State> { @@ -163,7 +176,7 @@ export default class ComponentSourceSnippetGroupViewer extends React.PureCompone } } - expandBlock = (snippetIndex: number, direction: T.ExpandDirection): Promise<void> => { + expandBlock = (snippetIndex: number, direction: ExpandDirection): Promise<void> => { const { branchLike, snippetGroup } = this.props; const { key } = snippetGroup.component; const { snippets } = this.state; @@ -189,7 +202,7 @@ export default class ComponentSourceSnippetGroupViewer extends React.PureCompone ...getBranchLikeQuery(branchLike) }) .then(lines => - lines.reduce((lineMap: T.Dict<T.SourceLine>, line) => { + lines.reduce((lineMap: Dict<SourceLine>, line) => { line.coverageStatus = getCoverageStatus(line); lineMap[line.line] = line; return lineMap; @@ -200,8 +213,8 @@ export default class ComponentSourceSnippetGroupViewer extends React.PureCompone animateBlockExpansion( snippetIndex: number, - direction: T.ExpandDirection, - newLinesMapped: T.Dict<T.SourceLine> + direction: ExpandDirection, + newLinesMapped: Dict<SourceLine> ): Promise<void> { if (this.mounted) { const { snippets } = this.state; @@ -273,13 +286,13 @@ export default class ComponentSourceSnippetGroupViewer extends React.PureCompone ); }; - handleOpenIssues = (line: T.SourceLine) => { + handleOpenIssues = (line: SourceLine) => { this.setState(state => ({ openIssuesByLine: { ...state.openIssuesByLine, [line.line]: true } })); }; - handleCloseIssues = (line: T.SourceLine) => { + handleCloseIssues = (line: SourceLine) => { this.setState(state => ({ openIssuesByLine: { ...state.openIssuesByLine, [line.line]: false } })); @@ -294,7 +307,7 @@ export default class ComponentSourceSnippetGroupViewer extends React.PureCompone }); }; - loadDuplications = (line: T.SourceLine) => { + loadDuplications = (line: SourceLine) => { this.props.loadDuplications(this.props.snippetGroup.component.key, line); }; @@ -310,10 +323,10 @@ export default class ComponentSourceSnippetGroupViewer extends React.PureCompone snippet }: { index: number; - issuesByLine: T.IssuesByLine; + issuesByLine: IssuesByLine; lastSnippetOfLastGroup: boolean; - locationsByLine: { [line: number]: T.LinearIssueLocation[] }; - snippet: T.SourceLine[]; + locationsByLine: { [line: number]: LinearIssueLocation[] }; + snippet: SourceLine[]; }) { return ( <SnippetViewer diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx index 4b23e381d76..47da6b2d90a 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewerWrapper.tsx @@ -39,16 +39,25 @@ import { WorkspaceContext } from '../../../components/workspace/context'; import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; +import { + Dict, + DuplicatedFile, + Duplication, + FlowLocation, + Issue, + SnippetsByComponent, + SourceViewerFile +} from '../../../types/types'; import ComponentSourceSnippetGroupViewer from './ComponentSourceSnippetGroupViewer'; import { groupLocationsByComponent } from './utils'; interface Props { branchLike: BranchLike | undefined; highlightedLocationMessage?: { index: number; text: string | undefined }; - issue: T.Issue; - issues: T.Issue[]; - locations: T.FlowLocation[]; - onIssueChange: (issue: T.Issue) => void; + issue: Issue; + issues: Issue[]; + locations: FlowLocation[]; + onIssueChange: (issue: Issue) => void; onLoaded?: () => void; onLocationSelect: (index: number) => void; scroll?: (element: HTMLElement) => void; @@ -56,9 +65,9 @@ interface Props { } interface State { - components: T.Dict<T.SnippetsByComponent>; - duplicatedFiles?: T.Dict<T.DuplicatedFile>; - duplications?: T.Duplication[]; + components: Dict<SnippetsByComponent>; + duplicatedFiles?: Dict<DuplicatedFile>; + duplications?: Duplication[]; duplicationsByLine: { [line: number]: number[] }; issuePopup?: { issue: string; name: string }; loading: boolean; @@ -146,7 +155,7 @@ export default class CrossComponentSourceViewerWrapper extends React.PureCompone }); }; - renderDuplicationPopup = (component: T.SourceViewerFile, index: number, line: number) => { + renderDuplicationPopup = (component: SourceViewerFile, index: number, line: number) => { const { duplicatedFiles, duplications } = this.state; if (!component || !duplicatedFiles) { diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx index 2d14573f536..84524731d57 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx @@ -31,37 +31,48 @@ import { import { translate } from '../../../helpers/l10n'; import { scrollHorizontally } from '../../../helpers/scrolling'; import { BranchLike } from '../../../types/branch-like'; +import { + Dict, + Duplication, + ExpandDirection, + FlowLocation, + Issue, + IssuesByLine, + LinearIssueLocation, + SourceLine, + SourceViewerFile +} from '../../../types/types'; import './SnippetViewer.css'; import { inSnippet, LINES_BELOW_ISSUE } from './utils'; interface Props { branchLike: BranchLike | undefined; - component: T.SourceViewerFile; + component: SourceViewerFile; displayLineNumberOptions?: boolean; displaySCM?: boolean; - duplications?: T.Duplication[]; + duplications?: Duplication[]; duplicationsByLine?: { [line: number]: number[] }; - expandBlock: (snippetIndex: number, direction: T.ExpandDirection) => Promise<void>; - handleCloseIssues: (line: T.SourceLine) => void; - handleOpenIssues: (line: T.SourceLine) => void; + expandBlock: (snippetIndex: number, direction: ExpandDirection) => Promise<void>; + handleCloseIssues: (line: SourceLine) => void; + handleOpenIssues: (line: SourceLine) => void; handleSymbolClick: (symbols: string[]) => void; highlightedLocationMessage: { index: number; text: string | undefined } | undefined; highlightedSymbols: string[]; index: number; - issue: Pick<T.Issue, 'key' | 'textRange' | 'line'>; + issue: Pick<Issue, 'key' | 'textRange' | 'line'>; issuePopup?: { issue: string; name: string }; - issuesByLine: T.IssuesByLine; + issuesByLine: IssuesByLine; lastSnippetOfLastGroup: boolean; - loadDuplications?: (line: T.SourceLine) => void; - locations: T.FlowLocation[]; - locationsByLine: { [line: number]: T.LinearIssueLocation[] }; - onIssueChange: (issue: T.Issue) => void; + loadDuplications?: (line: SourceLine) => void; + locations: FlowLocation[]; + locationsByLine: { [line: number]: LinearIssueLocation[] }; + onIssueChange: (issue: Issue) => void; onIssuePopupToggle: (issue: string, popupName: string, open?: boolean) => void; onLocationSelect: (index: number) => void; - openIssuesByLine: T.Dict<boolean>; + openIssuesByLine: Dict<boolean>; renderDuplicationPopup: (index: number, line: number) => React.ReactNode; scroll?: (element: HTMLElement, offset?: number) => void; - snippet: T.SourceLine[]; + snippet: SourceLine[]; } export default class SnippetViewer extends React.PureComponent<Props> { @@ -101,7 +112,7 @@ export default class SnippetViewer extends React.PureComponent<Props> { } }; - expandBlock = (direction: T.ExpandDirection) => () => + expandBlock = (direction: ExpandDirection) => () => this.props.expandBlock(this.props.index, direction).then(() => { if (direction === 'down') { this.scrollToLastExpandedRow(); @@ -122,10 +133,10 @@ export default class SnippetViewer extends React.PureComponent<Props> { displayDuplications: boolean; displaySCM?: boolean; index: number; - issuesForLine: T.Issue[]; - issueLocations: T.LinearIssueLocation[]; - line: T.SourceLine; - snippet: T.SourceLine[]; + issuesForLine: Issue[]; + issueLocations: LinearIssueLocation[]; + line: SourceLine; + snippet: SourceLine[]; symbols: string[]; verticalBuffer: number; }) { diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetGroupViewer-test.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetGroupViewer-test.tsx index 899005fdf8d..2bcbde07967 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetGroupViewer-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetGroupViewer-test.tsx @@ -31,6 +31,7 @@ import { mockSourceViewerFile } from '../../../../helpers/testMocks'; import { waitAndUpdate } from '../../../../helpers/testUtils'; +import { SnippetGroup } from '../../../../types/types'; import ComponentSourceSnippetGroupViewer from '../ComponentSourceSnippetGroupViewer'; import SnippetViewer from '../SnippetViewer'; @@ -53,7 +54,7 @@ it('should render correctly with secondary locations', () => { textRange: { startLine: 7, endLine: 7, startOffset: 5, endOffset: 10 } }); - const snippetGroup: T.SnippetGroup = { + const snippetGroup: SnippetGroup = { locations: [ mockFlowLocation({ component: issue.component, @@ -84,7 +85,7 @@ it('should render correctly with flows', () => { textRange: { startLine: 7, endLine: 7, startOffset: 5, endOffset: 10 } }); - const snippetGroup: T.SnippetGroup = { + const snippetGroup: SnippetGroup = { locations: [ mockFlowLocation({ component: issue.component, @@ -155,7 +156,7 @@ it('should expand block', async () => { const issue = mockIssue(true, { textRange: { startLine: 74, endLine: 74, startOffset: 5, endOffset: 10 } }); - const snippetGroup: T.SnippetGroup = { + const snippetGroup: SnippetGroup = { locations: [ mockFlowLocation({ component: 'a', @@ -184,7 +185,7 @@ it('should expand full component', async () => { (getSources as jest.Mock).mockResolvedValueOnce( Object.values(mockSnippetsByComponent('a', times(14)).sources) ); - const snippetGroup: T.SnippetGroup = { + const snippetGroup: SnippetGroup = { locations: [ mockFlowLocation({ component: 'a', @@ -214,7 +215,7 @@ it('should get the right branch when expanding', async () => { mockSnippetsByComponent('a', [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]).sources ) ); - const snippetGroup: T.SnippetGroup = { + const snippetGroup: SnippetGroup = { locations: [mockFlowLocation()], ...mockSnippetsByComponent('a', [1, 2, 3, 4, 5, 6, 7]) }; @@ -250,7 +251,7 @@ it('should handle symbol highlighting', () => { }); it('should correctly handle lines actions', () => { - const snippetGroup: T.SnippetGroup = { + const snippetGroup: SnippetGroup = { locations: [ mockFlowLocation({ component: 'a', @@ -291,7 +292,7 @@ it('should correctly handle lines actions', () => { }); describe('getNodes', () => { - const snippetGroup: T.SnippetGroup = { + const snippetGroup: SnippetGroup = { component: mockSourceViewerFile(), locations: [], sources: [] @@ -346,7 +347,7 @@ describe('getNodes', () => { describe('getHeight', () => { jest.useFakeTimers(); - const snippetGroup: T.SnippetGroup = { + const snippetGroup: SnippetGroup = { component: mockSourceViewerFile(), locations: [], sources: [] @@ -397,7 +398,7 @@ describe('getHeight', () => { }); function shallowRender(props: Partial<ComponentSourceSnippetGroupViewer['props']> = {}) { - const snippetGroup: T.SnippetGroup = { + const snippetGroup: SnippetGroup = { component: mockSourceViewerFile(), locations: [], sources: [] diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/utils.ts b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/utils.ts index 65c15dc49f9..48ce2f36565 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/utils.ts @@ -17,13 +17,24 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { + ExpandDirection, + FlowLocation, + Issue, + LineMap, + Snippet, + SnippetGroup, + SnippetsByComponent, + SourceLine +} from '../../../types/types'; + const LINES_ABOVE = 5; const LINES_BELOW = 5; export const MERGE_DISTANCE = 11; // Merge if snippets are eleven lines away (separated by 10 lines) or fewer export const LINES_BELOW_ISSUE = 9; export const EXPAND_BY_LINES = 50; -function unknownComponent(key: string): T.SnippetsByComponent { +function unknownComponent(key: string): SnippetsByComponent { return { component: { key, @@ -42,7 +53,7 @@ function collision([startA, endA]: number[], [startB, endB]: number[]) { return !(startA > endB + MERGE_DISTANCE || endA < startB - MERGE_DISTANCE); } -export function getPrimaryLocation(issue: T.Issue): T.FlowLocation { +export function getPrimaryLocation(issue: Issue): FlowLocation { return { component: issue.component, textRange: issue.textRange || { @@ -54,7 +65,7 @@ export function getPrimaryLocation(issue: T.Issue): T.FlowLocation { }; } -function addLinesBellow(params: { issue: T.Issue; locationEnd: number }) { +function addLinesBellow(params: { issue: Issue; locationEnd: number }) { const { issue, locationEnd } = params; const issueEndLine = (issue.textRange && issue.textRange.endLine) || 0; @@ -67,9 +78,9 @@ function addLinesBellow(params: { issue: T.Issue; locationEnd: number }) { export function createSnippets(params: { component: string; - issue: T.Issue; - locations: T.FlowLocation[]; -}): T.Snippet[] { + issue: Issue; + locations: FlowLocation[]; +}): Snippet[] { const { component, issue, locations } = params; const hasSecondaryLocations = issue.secondaryLocations.length > 0; @@ -79,7 +90,7 @@ export function createSnippets(params: { // For each location: compute its range, and then compare with other ranges // to merge snippets that collide. const ranges = (addIssueLocation ? [getPrimaryLocation(issue), ...locations] : locations).reduce( - (snippets: T.Snippet[], loc, index) => { + (snippets: Snippet[], loc, index) => { const startIndex = Math.max(1, loc.textRange.startLine - LINES_ABOVE); const endIndex = addLinesBellow({ issue, locationEnd: loc.textRange.endLine }); @@ -122,7 +133,7 @@ export function createSnippets(params: { return hasSecondaryLocations ? ranges.sort((a, b) => a.start - b.start) : ranges; } -export function linesForSnippets(snippets: T.Snippet[], componentLines: T.LineMap) { +export function linesForSnippets(snippets: Snippet[], componentLines: LineMap) { return snippets .map(snippet => { const lines = []; @@ -137,13 +148,13 @@ export function linesForSnippets(snippets: T.Snippet[], componentLines: T.LineMa } export function groupLocationsByComponent( - issue: T.Issue, - locations: T.FlowLocation[], - components: { [key: string]: T.SnippetsByComponent } + issue: Issue, + locations: FlowLocation[], + components: { [key: string]: SnippetsByComponent } ) { let currentComponent = ''; - let currentGroup: T.SnippetGroup; - const groups: T.SnippetGroup[] = []; + let currentGroup: SnippetGroup; + const groups: SnippetGroup[] = []; const addGroup = (componentKey: string) => { currentGroup = { @@ -177,9 +188,9 @@ export function expandSnippet({ snippetIndex, snippets }: { - direction: T.ExpandDirection; + direction: ExpandDirection; snippetIndex: number; - snippets: T.Snippet[]; + snippets: Snippet[]; }) { const snippetToExpand = snippets.find(s => s.index === snippetIndex); if (!snippetToExpand) { @@ -206,6 +217,6 @@ export function expandSnippet({ }); } -export function inSnippet(line: number, snippet: T.SourceLine[]) { +export function inSnippet(line: number, snippet: SourceLine[]) { return line >= snippet[0].line && line <= snippet[snippet.length - 1].line; } diff --git a/server/sonar-web/src/main/js/apps/issues/redirects.ts b/server/sonar-web/src/main/js/apps/issues/redirects.ts index 35cc0eebc6b..4f424d6fd74 100644 --- a/server/sonar-web/src/main/js/apps/issues/redirects.ts +++ b/server/sonar-web/src/main/js/apps/issues/redirects.ts @@ -18,10 +18,11 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { Location } from '../../helpers/urls'; +import { RawQuery } from '../../types/types'; import { areMyIssuesSelected, parseQuery, serializeQuery } from './utils'; function parseHash(hash: string) { - const query: T.RawQuery = {}; + const query: RawQuery = {}; const parts = hash.split('|'); parts.forEach(part => { const tokens = part.split('='); diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx index 20154382029..e8f2ac769d6 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx @@ -25,6 +25,7 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; import { highlightTerm } from '../../../helpers/search'; import { isUserActive } from '../../../helpers/users'; import { Facet } from '../../../types/issues'; +import { Dict, UserBase } from '../../../types/types'; import { Query, searchAssignees } from '../utils'; interface Props { @@ -36,8 +37,8 @@ interface Props { onToggle: (property: string) => void; open: boolean; query: Query; - stats: T.Dict<number> | undefined; - referencedUsers: T.Dict<T.UserBase>; + stats: Dict<number> | undefined; + referencedUsers: Dict<UserBase>; } export default class AssigneeFacet extends React.PureComponent<Props> { @@ -79,7 +80,7 @@ export default class AssigneeFacet extends React.PureComponent<Props> { } }; - loadSearchResultCount = (assignees: T.UserBase[]) => { + loadSearchResultCount = (assignees: UserBase[]) => { return this.props.loadSearchResultCount('assignees', { assigned: undefined, assignees: assignees.map(assignee => assignee.login) @@ -118,7 +119,7 @@ export default class AssigneeFacet extends React.PureComponent<Props> { ); }; - renderSearchResult = (result: T.UserBase, query: string) => { + renderSearchResult = (result: UserBase, query: string) => { const displayName = isUserActive(result) ? result.name : translateWithParameters('user.x_deleted', result.login); @@ -142,7 +143,7 @@ export default class AssigneeFacet extends React.PureComponent<Props> { } return ( - <ListStyleFacet<T.UserBase> + <ListStyleFacet<UserBase> facetHeader={translate('issues.facet.assignees')} fetching={this.props.fetching} getFacetItemText={this.getAssigneeName} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx index 2dd7db0f760..39488507762 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx @@ -24,17 +24,18 @@ import ListStyleFacet from '../../../components/facet/ListStyleFacet'; import { translate } from '../../../helpers/l10n'; import { highlightTerm } from '../../../helpers/search'; import { Facet } from '../../../types/issues'; +import { Component, Dict } from '../../../types/types'; import { Query } from '../utils'; interface Props { - component: T.Component | undefined; + component: Component | undefined; fetching: boolean; loadSearchResultCount: (property: string, changes: Partial<Query>) => Promise<Facet>; onChange: (changes: Partial<Query>) => void; onToggle: (property: string) => void; open: boolean; query: Query; - stats: T.Dict<number> | undefined; + stats: Dict<number> | undefined; author: string[]; } diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.tsx index a69c5b1c7f1..0993c05084c 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.tsx @@ -35,10 +35,11 @@ import { parseDate } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; import { isPortfolioLike } from '../../../types/component'; +import { Component, Dict } from '../../../types/types'; import { Query } from '../utils'; interface Props { - component: T.Component | undefined; + component: Component | undefined; createdAfter: Date | undefined; createdAfterIncludesTime: boolean; createdAt: string; @@ -49,7 +50,7 @@ interface Props { onToggle: (property: string) => void; open: boolean; sinceLeakPeriod: boolean; - stats: T.Dict<number> | undefined; + stats: Dict<number> | undefined; } export class CreationDateFacet extends React.PureComponent<Props & WrappedComponentProps> { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx index a898a622af5..cc13835d859 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx @@ -25,6 +25,7 @@ import { translate } from '../../../helpers/l10n'; import { highlightTerm } from '../../../helpers/search'; import { getLanguages, Store } from '../../../store/rootReducer'; import { Facet, ReferencedLanguage } from '../../../types/issues'; +import { Dict } from '../../../types/types'; import { Query } from '../utils'; interface InstalledLanguage { @@ -41,8 +42,8 @@ interface Props { onToggle: (property: string) => void; open: boolean; query: Query; - referencedLanguages: T.Dict<ReferencedLanguage>; - stats: T.Dict<number> | undefined; + referencedLanguages: Dict<ReferencedLanguage>; + stats: Dict<number> | undefined; } class LanguageFacet extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx index 4738c61842d..465b29ba095 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx @@ -26,10 +26,11 @@ import { translate } from '../../../helpers/l10n'; import { highlightTerm } from '../../../helpers/search'; import { ComponentQualifier } from '../../../types/component'; import { Facet, ReferencedComponent } from '../../../types/issues'; +import { Component, Dict, Paging } from '../../../types/types'; import { Query } from '../utils'; interface Props { - component: T.Component | undefined; + component: Component | undefined; loadSearchResultCount: (property: string, changes: Partial<Query>) => Promise<Facet>; fetching: boolean; onChange: (changes: Partial<Query>) => void; @@ -37,8 +38,8 @@ interface Props { open: boolean; projects: string[]; query: Query; - referencedComponents: T.Dict<ReferencedComponent>; - stats: T.Dict<number> | undefined; + referencedComponents: Dict<ReferencedComponent>; + stats: Dict<number> | undefined; } interface SearchedProject { @@ -50,7 +51,7 @@ export default class ProjectFacet extends React.PureComponent<Props> { handleSearch = ( query: string, page = 1 - ): Promise<{ results: SearchedProject[]; paging: T.Paging }> => { + ): Promise<{ results: SearchedProject[]; paging: Paging }> => { const { component } = this.props; if ( component && diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/ResolutionFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/ResolutionFacet.tsx index 3d471491686..d13db6d05da 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/ResolutionFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/ResolutionFacet.tsx @@ -25,6 +25,7 @@ import FacetItem from '../../../components/facet/FacetItem'; import FacetItemsList from '../../../components/facet/FacetItemsList'; import MultipleSelectionHint from '../../../components/facet/MultipleSelectionHint'; import { translate } from '../../../helpers/l10n'; +import { Dict } from '../../../types/types'; import { formatFacetStat, Query } from '../utils'; interface Props { @@ -34,7 +35,7 @@ interface Props { open: boolean; resolved: boolean; resolutions: string[]; - stats: T.Dict<number> | undefined; + stats: Dict<number> | undefined; } const RESOLUTIONS = ['', 'FALSE-POSITIVE', 'FIXED', 'REMOVED', 'WONTFIX']; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx index 61d48932cfa..1c2075778a3 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx @@ -23,6 +23,7 @@ import { searchRules } from '../../../api/rules'; import ListStyleFacet from '../../../components/facet/ListStyleFacet'; import { translate } from '../../../helpers/l10n'; import { Facet, ReferencedRule } from '../../../types/issues'; +import { Dict, Rule } from '../../../types/types'; import { Query } from '../utils'; interface Props { @@ -33,9 +34,9 @@ interface Props { onToggle: (property: string) => void; open: boolean; query: Query; - referencedRules: T.Dict<ReferencedRule>; + referencedRules: Dict<ReferencedRule>; rules: string[]; - stats: T.Dict<number> | undefined; + stats: Dict<number> | undefined; } export default class RuleFacet extends React.PureComponent<Props> { @@ -55,7 +56,7 @@ export default class RuleFacet extends React.PureComponent<Props> { })); }; - loadSearchResultCount = (rules: T.Rule[]) => { + loadSearchResultCount = (rules: Rule[]) => { return this.props.loadSearchResultCount('rules', { rules: rules.map(rule => rule.key) }); }; @@ -70,13 +71,13 @@ export default class RuleFacet extends React.PureComponent<Props> { return langName ? `(${langName}) ${name}` : name; }; - renderSearchResult = (rule: T.Rule) => { + renderSearchResult = (rule: Rule) => { return this.formatRuleName(rule.name, rule.langName); }; render() { return ( - <ListStyleFacet<T.Rule> + <ListStyleFacet<Rule> facetHeader={translate('issues.facet.rules')} fetching={this.props.fetching} getFacetItemText={this.getRuleName} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/ScopeFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/ScopeFacet.tsx index 44d3e34dc85..f7fce703011 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/ScopeFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/ScopeFacet.tsx @@ -27,6 +27,7 @@ import MultipleSelectionHint from '../../../components/facet/MultipleSelectionHi import QualifierIcon from '../../../components/icons/QualifierIcon'; import { SOURCE_SCOPES } from '../../../helpers/constants'; import { translate } from '../../../helpers/l10n'; +import { Dict } from '../../../types/types'; import { formatFacetStat, Query } from '../utils'; export interface ScopeFacetProps { @@ -35,7 +36,7 @@ export interface ScopeFacetProps { onToggle: (property: string) => void; open: boolean; scopes: string[]; - stats: T.Dict<number> | undefined; + stats: Dict<number> | undefined; } export default function ScopeFacet(props: ScopeFacetProps) { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx index e607e0bf9b9..10e4ae10bea 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/SeverityFacet.tsx @@ -26,6 +26,7 @@ import FacetItemsList from '../../../components/facet/FacetItemsList'; import MultipleSelectionHint from '../../../components/facet/MultipleSelectionHint'; import SeverityHelper from '../../../components/shared/SeverityHelper'; import { translate } from '../../../helpers/l10n'; +import { Dict } from '../../../types/types'; import { formatFacetStat, Query } from '../utils'; interface Props { @@ -34,7 +35,7 @@ interface Props { onToggle: (property: string) => void; open: boolean; severities: string[]; - stats: T.Dict<number> | undefined; + stats: Dict<number> | undefined; } const SEVERITIES = ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR']; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx index 67666f9bc77..e86a72ec3b4 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx @@ -19,9 +19,9 @@ */ import * as React from 'react'; import { connect } from 'react-redux'; +import { isBranch, isPullRequest } from '../../../helpers/branch-like'; import { getGlobalSettingValue, Store } from '../../../store/rootReducer'; import { BranchLike } from '../../../types/branch-like'; -import { isBranch, isPullRequest } from '../../../helpers/branch-like'; import { ComponentQualifier, isApplication, isPortfolioLike } from '../../../types/component'; import { Facet, @@ -29,6 +29,7 @@ import { ReferencedLanguage, ReferencedRule } from '../../../types/issues'; +import { Component, Dict, UserBase } from '../../../types/types'; import { Query } from '../utils'; import AssigneeFacet from './AssigneeFacet'; import AuthorFacet from './AuthorFacet'; @@ -48,21 +49,21 @@ import TypeFacet from './TypeFacet'; export interface Props { branchLike?: BranchLike; - component: T.Component | undefined; + component: Component | undefined; createdAfterIncludesTime: boolean; - facets: T.Dict<Facet | undefined>; + facets: Dict<Facet | undefined>; loadSearchResultCount: (property: string, changes: Partial<Query>) => Promise<Facet>; - loadingFacets: T.Dict<boolean>; + loadingFacets: Dict<boolean>; myIssues: boolean; onFacetToggle: (property: string) => void; onFilterChange: (changes: Partial<Query>) => void; - openFacets: T.Dict<boolean>; + openFacets: Dict<boolean>; query: Query; - referencedComponentsById: T.Dict<ReferencedComponent>; - referencedComponentsByKey: T.Dict<ReferencedComponent>; - referencedLanguages: T.Dict<ReferencedLanguage>; - referencedRules: T.Dict<ReferencedRule>; - referencedUsers: T.Dict<T.UserBase>; + referencedComponentsById: Dict<ReferencedComponent>; + referencedComponentsByKey: Dict<ReferencedComponent>; + referencedLanguages: Dict<ReferencedLanguage>; + referencedRules: Dict<ReferencedRule>; + referencedUsers: Dict<UserBase>; disableDeveloperAggregatedInfo: boolean; } diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx index ae087df51be..06e7f05b4ba 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx @@ -36,12 +36,13 @@ import { } from '../../../helpers/security-standard'; import { Facet } from '../../../types/issues'; import { SecurityStandard, Standards, StandardType } from '../../../types/security'; +import { Dict } from '../../../types/types'; import { formatFacetStat, Query, STANDARDS } from '../utils'; interface Props { cwe: string[]; cweOpen: boolean; - cweStats: T.Dict<number> | undefined; + cweStats: Dict<number> | undefined; fetchingCwe: boolean; fetchingOwaspTop10: boolean; fetchingSansTop25: boolean; @@ -52,14 +53,14 @@ interface Props { open: boolean; owaspTop10: string[]; owaspTop10Open: boolean; - owaspTop10Stats: T.Dict<number> | undefined; + owaspTop10Stats: Dict<number> | undefined; query: Partial<Query>; sansTop25: string[]; sansTop25Open: boolean; - sansTop25Stats: T.Dict<number> | undefined; + sansTop25Stats: Dict<number> | undefined; sonarsourceSecurity: string[]; sonarsourceSecurityOpen: boolean; - sonarsourceSecurityStats: T.Dict<number> | undefined; + sonarsourceSecurityStats: Dict<number> | undefined; } interface State { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/StatusFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/StatusFacet.tsx index ebf1fa97c75..01a22bf23a5 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/StatusFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/StatusFacet.tsx @@ -26,6 +26,7 @@ import FacetItemsList from '../../../components/facet/FacetItemsList'; import MultipleSelectionHint from '../../../components/facet/MultipleSelectionHint'; import StatusHelper from '../../../components/shared/StatusHelper'; import { translate } from '../../../helpers/l10n'; +import { Dict } from '../../../types/types'; import { formatFacetStat, Query } from '../utils'; interface Props { @@ -33,7 +34,7 @@ interface Props { onChange: (changes: Partial<Query>) => void; onToggle: (property: string) => void; open: boolean; - stats: T.Dict<number> | undefined; + stats: Dict<number> | undefined; statuses: string[]; } diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx index 6c8f4af269c..573b961b861 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx @@ -26,10 +26,11 @@ import TagsIcon from '../../../components/icons/TagsIcon'; import { translate } from '../../../helpers/l10n'; import { highlightTerm } from '../../../helpers/search'; import { Facet } from '../../../types/issues'; +import { Component, Dict } from '../../../types/types'; import { Query } from '../utils'; interface Props { - component: T.Component | undefined; + component: Component | undefined; branch?: string; fetching: boolean; loadSearchResultCount: (property: string, changes: Partial<Query>) => Promise<Facet>; @@ -37,7 +38,7 @@ interface Props { onToggle: (property: string) => void; open: boolean; query: Query; - stats: T.Dict<number> | undefined; + stats: Dict<number> | undefined; tags: string[]; } diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx index 057d954e2de..80c6e518c7a 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx @@ -27,6 +27,7 @@ import MultipleSelectionHint from '../../../components/facet/MultipleSelectionHi import IssueTypeIcon from '../../../components/icons/IssueTypeIcon'; import { ISSUE_TYPES } from '../../../helpers/constants'; import { translate } from '../../../helpers/l10n'; +import { Dict } from '../../../types/types'; import { formatFacetStat, Query } from '../utils'; interface Props { @@ -34,7 +35,7 @@ interface Props { onChange: (changes: Partial<Query>) => void; onToggle: (property: string) => void; open: boolean; - stats: T.Dict<number> | undefined; + stats: Dict<number> | undefined; types: string[]; } diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts index e8d4f8baf0f..4b5c9f9713b 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/utils.ts @@ -36,6 +36,7 @@ import { get, save } from '../../helpers/storage'; import { isDefined } from '../../helpers/types'; import { Facet, RawFacet } from '../../types/issues'; import { SecurityStandard, StandardType } from '../../types/security'; +import { Dict, Issue, Paging, RawQuery, UserBase } from '../../types/types'; export interface Query { assigned: boolean; @@ -78,7 +79,7 @@ export const STANDARD_TYPES: StandardType[] = [ const parseAsSort = (sort: string) => (sort === 'CREATION_DATE' ? 'CREATION_DATE' : ''); const ISSUES_DEFAULT = 'sonarqube.issues.default'; -export function parseQuery(query: T.RawQuery): Query { +export function parseQuery(query: RawQuery): Query { return { assigned: parseAsBoolean(query.assigned), assignees: parseAsArray(query.assignees, parseAsString), @@ -109,13 +110,13 @@ export function parseQuery(query: T.RawQuery): Query { }; } -export function getOpen(query: T.RawQuery): string | undefined { +export function getOpen(query: RawQuery): string | undefined { return query.open; } -export const areMyIssuesSelected = (query: T.RawQuery) => query.myIssues === 'true'; +export const areMyIssuesSelected = (query: RawQuery) => query.myIssues === 'true'; -export function serializeQuery(query: Query): T.RawQuery { +export function serializeQuery(query: Query): RawQuery { const filter = { assigned: query.assigned ? undefined : 'false', assignees: serializeStringArray(query.assignees), @@ -148,15 +149,15 @@ export function serializeQuery(query: Query): T.RawQuery { return cleanQuery(filter); } -export const areQueriesEqual = (a: T.RawQuery, b: T.RawQuery) => +export const areQueriesEqual = (a: RawQuery, b: RawQuery) => queriesEqual(parseQuery(a), parseQuery(b)); -export function parseFacets(facets: RawFacet[]): T.Dict<Facet> { +export function parseFacets(facets: RawFacet[]): Dict<Facet> { if (!facets) { return {}; } - const result: T.Dict<Facet> = {}; + const result: Dict<Facet> = {}; facets.forEach(facet => { const values: Facet = {}; facet.values.forEach(value => { @@ -174,7 +175,7 @@ export function formatFacetStat(stat: number | undefined) { export const searchAssignees = ( query: string, page = 1 -): Promise<{ paging: T.Paging; results: T.UserBase[] }> => { +): Promise<{ paging: Paging; results: UserBase[] }> => { return searchUsers({ p: page, q: query }).then(({ paging, users }) => ({ paging, results: users @@ -192,7 +193,7 @@ export const saveMyIssues = (myIssues: boolean) => save(ISSUES_DEFAULT, myIssues ? LOCALSTORAGE_MY : LOCALSTORAGE_ALL); export function getLocations( - { flows, secondaryLocations }: Pick<T.Issue, 'flows' | 'secondaryLocations'>, + { flows, secondaryLocations }: Pick<Issue, 'flows' | 'secondaryLocations'>, selectedFlowIndex: number | undefined ) { if (selectedFlowIndex !== undefined) { @@ -203,7 +204,7 @@ export function getLocations( } export function getSelectedLocation( - issue: Pick<T.Issue, 'flows' | 'secondaryLocations'>, + issue: Pick<Issue, 'flows' | 'secondaryLocations'>, selectedFlowIndex: number | undefined, selectedLocationIndex: number | undefined ) { @@ -220,7 +221,7 @@ export function getSelectedLocation( } export function allLocationsEmpty( - issue: Pick<T.Issue, 'flows' | 'secondaryLocations'>, + issue: Pick<Issue, 'flows' | 'secondaryLocations'>, selectedFlowIndex: number | undefined ) { return getLocations(issue, selectedFlowIndex).every(location => !location.msg); @@ -234,7 +235,7 @@ export function scrollToIssue(issue: string, smooth = true) { } export function shouldOpenStandardsFacet( - openFacets: T.Dict<boolean>, + openFacets: Dict<boolean>, query: Partial<Query> ): boolean { return ( @@ -245,7 +246,7 @@ export function shouldOpenStandardsFacet( } export function shouldOpenStandardsChildFacet( - openFacets: T.Dict<boolean>, + openFacets: Dict<boolean>, query: Partial<Query>, standardType: SecurityStandard ): boolean { @@ -258,7 +259,7 @@ export function shouldOpenStandardsChildFacet( } export function shouldOpenSonarSourceSecurityFacet( - openFacets: T.Dict<boolean>, + openFacets: Dict<boolean>, query: Partial<Query> ): boolean { // Open it by default if the parent is open, and no other standard is open. @@ -272,7 +273,7 @@ function isFilteredBySecurityIssueTypes(query: Partial<Query>): boolean { return query.types !== undefined && query.types.includes('VULNERABILITY'); } -function isOneStandardChildFacetOpen(openFacets: T.Dict<boolean>, query: Partial<Query>): boolean { +function isOneStandardChildFacetOpen(openFacets: Dict<boolean>, query: Partial<Query>): boolean { return STANDARD_TYPES.some(standardType => shouldOpenStandardsChildFacet(openFacets, query, standardType) ); diff --git a/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx b/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx index e49721d363f..43a2c17787f 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx @@ -22,10 +22,11 @@ import { connect } from 'react-redux'; import AdminContext from '../../app/components/AdminContext'; import { getAppState, getGlobalSettingValue, Store } from '../../store/rootReducer'; import { EditionKey } from '../../types/editions'; +import { RawQuery } from '../../types/types'; import App from './App'; interface OwnProps { - location: { pathname: string; query: T.RawQuery }; + location: { pathname: string; query: RawQuery }; } interface StateToProps { diff --git a/server/sonar-web/src/main/js/apps/marketplace/utils.ts b/server/sonar-web/src/main/js/apps/marketplace/utils.ts index d6a75278316..8c4a0eca1b4 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/utils.ts +++ b/server/sonar-web/src/main/js/apps/marketplace/utils.ts @@ -20,6 +20,7 @@ import { memoize } from 'lodash'; import { cleanQuery, parseAsString, serializeString } from '../../helpers/query'; import { Plugin } from '../../types/plugins'; +import { RawQuery } from '../../types/types'; export interface Query { filter: string; @@ -45,14 +46,14 @@ export function filterPlugins(plugins: Plugin[], search?: string): Plugin[] { export const DEFAULT_FILTER = 'all'; export const parseQuery = memoize( - (urlQuery: T.RawQuery): Query => ({ + (urlQuery: RawQuery): Query => ({ filter: parseAsString(urlQuery['filter']) || DEFAULT_FILTER, search: parseAsString(urlQuery['search']) }) ); export const serializeQuery = memoize( - (query: Query): T.RawQuery => + (query: Query): RawQuery => cleanQuery({ filter: query.filter === DEFAULT_FILTER ? undefined : serializeString(query.filter), search: query.search ? serializeString(query.search) : undefined diff --git a/server/sonar-web/src/main/js/apps/overview/branches/ActivityPanel.tsx b/server/sonar-web/src/main/js/apps/overview/branches/ActivityPanel.tsx index 163d39c564e..aa70f143472 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/ActivityPanel.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/ActivityPanel.tsx @@ -32,17 +32,18 @@ import { parseDate } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; import { GraphType, MeasureHistory } from '../../../types/project-activity'; +import { Analysis as AnalysisType, Component, Metric } from '../../../types/types'; import Analysis from './Analysis'; export interface ActivityPanelProps { - analyses?: T.Analysis[]; + analyses?: AnalysisType[]; branchLike?: BranchLike; - component: Pick<T.Component, 'key' | 'qualifier'>; + component: Pick<Component, 'key' | 'qualifier'>; graph?: GraphType; leakPeriodDate?: Date; loading?: boolean; measuresHistory: MeasureHistory[]; - metrics: T.Metric[]; + metrics: Metric[]; onGraphChange: (graph: GraphType) => void; } diff --git a/server/sonar-web/src/main/js/apps/overview/branches/Analysis.tsx b/server/sonar-web/src/main/js/apps/overview/branches/Analysis.tsx index 80a7a6274b7..4daeefa495f 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/Analysis.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/Analysis.tsx @@ -22,10 +22,11 @@ import * as React from 'react'; import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; import { translate } from '../../../helpers/l10n'; import { ComponentQualifier } from '../../../types/component'; +import { Analysis as TypeAnalysis } from '../../../types/types'; import Event from './Event'; export interface AnalysisProps { - analysis: T.Analysis; + analysis: TypeAnalysis; qualifier: string; } diff --git a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx index 9ab00c04736..ecf8a51dcb5 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx @@ -49,6 +49,7 @@ import { ComponentQualifier } from '../../../types/component'; import { MetricKey } from '../../../types/metrics'; import { GraphType, MeasureHistory } from '../../../types/project-activity'; import { QualityGateStatus, QualityGateStatusCondition } from '../../../types/quality-gates'; +import { Analysis, Component, MeasureEnhanced, Metric, Period } from '../../../types/types'; import '../styles.css'; import { HISTORY_METRICS_LIST, METRICS } from '../utils'; import BranchOverviewRenderer from './BranchOverviewRenderer'; @@ -56,21 +57,21 @@ import BranchOverviewRenderer from './BranchOverviewRenderer'; interface Props { branch?: Branch; branchesEnabled?: boolean; - component: T.Component; + component: Component; projectBinding?: ProjectAlmBindingResponse; } interface State { - analyses?: T.Analysis[]; + analyses?: Analysis[]; appLeak?: ApplicationPeriod; detectedCIOnLastAnalysis?: boolean; graph: GraphType; loadingHistory?: boolean; loadingStatus?: boolean; - measures?: T.MeasureEnhanced[]; + measures?: MeasureEnhanced[]; measuresHistory?: MeasureHistory[]; - metrics?: T.Metric[]; - period?: T.Period; + metrics?: Metric[]; + period?: Period; qgStatuses?: QualityGateStatus[]; } @@ -348,10 +349,7 @@ export default class BranchOverview extends React.PureComponent<Props, State> { ); }; - getFailedConditions = ( - conditions: QualityGateStatusCondition[], - measures: T.MeasureEnhanced[] - ) => { + getFailedConditions = (conditions: QualityGateStatusCondition[], measures: MeasureEnhanced[]) => { return ( conditions .filter(c => c.level !== 'OK') diff --git a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx index d537f7d5d7a..c3be7dbff7e 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx @@ -26,6 +26,7 @@ import { Branch } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { GraphType, MeasureHistory } from '../../../types/project-activity'; import { QualityGateStatus } from '../../../types/quality-gates'; +import { Analysis, Component, MeasureEnhanced, Metric, Period } from '../../../types/types'; import ActivityPanel from './ActivityPanel'; import FirstAnalysisNextStepsNotif from './FirstAnalysisNextStepsNotif'; import { MeasuresPanel } from './MeasuresPanel'; @@ -33,20 +34,20 @@ import NoCodeWarning from './NoCodeWarning'; import QualityGatePanel from './QualityGatePanel'; export interface BranchOverviewRendererProps { - analyses?: T.Analysis[]; + analyses?: Analysis[]; appLeak?: ApplicationPeriod; branch?: Branch; branchesEnabled?: boolean; - component: T.Component; + component: Component; detectedCIOnLastAnalysis?: boolean; graph?: GraphType; loadingHistory?: boolean; loadingStatus?: boolean; - measures?: T.MeasureEnhanced[]; + measures?: MeasureEnhanced[]; measuresHistory?: MeasureHistory[]; - metrics?: T.Metric[]; + metrics?: Metric[]; onGraphChange: (graph: GraphType) => void; - period?: T.Period; + period?: Period; projectBinding?: ProjectAlmBindingResponse; projectIsEmpty?: boolean; qgStatuses?: QualityGateStatus[]; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/DebtValue.tsx b/server/sonar-web/src/main/js/apps/overview/branches/DebtValue.tsx index abf286bd08f..5a8c51c3a32 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/DebtValue.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/DebtValue.tsx @@ -24,11 +24,12 @@ import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; import { findMeasure, formatMeasure, localizeMetric } from '../../../helpers/measures'; import { BranchLike } from '../../../types/branch-like'; import { MetricKey } from '../../../types/metrics'; +import { Component, MeasureEnhanced } from '../../../types/types'; export interface DebtValueProps { branchLike?: BranchLike; - component: T.Component; - measures: T.MeasureEnhanced[]; + component: Component; + measures: MeasureEnhanced[]; useDiffMetric?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/overview/branches/DrilldownMeasureValue.tsx b/server/sonar-web/src/main/js/apps/overview/branches/DrilldownMeasureValue.tsx index c30a0ca7f04..3a6d201bada 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/DrilldownMeasureValue.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/DrilldownMeasureValue.tsx @@ -23,11 +23,12 @@ import { getLocalizedMetricName } from '../../../helpers/l10n'; import { findMeasure, formatMeasure } from '../../../helpers/measures'; import { BranchLike } from '../../../types/branch-like'; import { MetricKey } from '../../../types/metrics'; +import { Component, MeasureEnhanced } from '../../../types/types'; export interface DrilldownMeasureValueProps { branchLike?: BranchLike; - component: T.Component; - measures: T.MeasureEnhanced[]; + component: Component; + measures: MeasureEnhanced[]; metric: MetricKey; } diff --git a/server/sonar-web/src/main/js/apps/overview/branches/Event.tsx b/server/sonar-web/src/main/js/apps/overview/branches/Event.tsx index ce8440b6d3e..a33b217d70c 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/Event.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/Event.tsx @@ -21,11 +21,12 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import Level from '../../../components/ui/Level'; import { translate } from '../../../helpers/l10n'; +import { AnalysisEvent } from '../../../types/types'; import { isDefinitionChangeEvent } from '../../projectActivity/components/DefinitionChangeEventInner'; import { isRichQualityGateEvent } from '../../projectActivity/components/RichQualityGateEventInner'; interface Props { - event: T.AnalysisEvent; + event: AnalysisEvent; } export function Event({ event }: Props) { diff --git a/server/sonar-web/src/main/js/apps/overview/branches/FirstAnalysisNextStepsNotif.tsx b/server/sonar-web/src/main/js/apps/overview/branches/FirstAnalysisNextStepsNotif.tsx index 704d09759bb..5338da91e84 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/FirstAnalysisNextStepsNotif.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/FirstAnalysisNextStepsNotif.tsx @@ -26,12 +26,13 @@ import { translate } from '../../../helpers/l10n'; import { isLoggedIn } from '../../../helpers/users'; import { ProjectAlmBindingResponse } from '../../../types/alm-settings'; import { ComponentQualifier } from '../../../types/component'; +import { Component, CurrentUser } from '../../../types/types'; import { PULL_REQUEST_DECORATION_BINDING_CATEGORY } from '../../settings/components/AdditionalCategoryKeys'; export interface FirstAnalysisNextStepsNotifProps { branchesEnabled?: boolean; - component: T.Component; - currentUser: T.CurrentUser; + component: Component; + currentUser: CurrentUser; detectedCIOnLastAnalysis?: boolean; projectBinding?: ProjectAlmBindingResponse; } diff --git a/server/sonar-web/src/main/js/apps/overview/branches/LeakPeriodInfo.tsx b/server/sonar-web/src/main/js/apps/overview/branches/LeakPeriodInfo.tsx index 53e675c3f67..49b89c3783d 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/LeakPeriodInfo.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/LeakPeriodInfo.tsx @@ -20,11 +20,12 @@ import * as React from 'react'; import { isApplicationPeriod } from '../../../helpers/periods'; import { ApplicationPeriod } from '../../../types/application'; +import { Period } from '../../../types/types'; import ApplicationLeakPeriodInfo from './ApplicationLeakPeriodInfo'; import ProjectLeakPeriodInfo from './ProjectLeakPeriodInfo'; export interface LeakPeriodInfoProps { - leakPeriod: T.Period | ApplicationPeriod; + leakPeriod: Period | ApplicationPeriod; } export function LeakPeriodInfo({ leakPeriod }: LeakPeriodInfoProps) { diff --git a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx index 4edc3cba36b..dcc39f05b8b 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanel.tsx @@ -29,6 +29,7 @@ import { Branch } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { IssueType } from '../../../types/issues'; import { MetricKey } from '../../../types/metrics'; +import { Component, MeasureEnhanced, Period } from '../../../types/types'; import MeasurementLabel from '../components/MeasurementLabel'; import { MeasurementType } from '../utils'; import { DrilldownMeasureValue } from './DrilldownMeasureValue'; @@ -39,10 +40,10 @@ import MeasuresPanelNoNewCode from './MeasuresPanelNoNewCode'; export interface MeasuresPanelProps { appLeak?: ApplicationPeriod; branch?: Branch; - component: T.Component; + component: Component; loading?: boolean; - measures?: T.MeasureEnhanced[]; - period?: T.Period; + measures?: MeasureEnhanced[]; + period?: Period; } export enum MeasuresPanelTabs { diff --git a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelIssueMeasureRow.tsx b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelIssueMeasureRow.tsx index a4abcbd51a2..3f33feb1370 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelIssueMeasureRow.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelIssueMeasureRow.tsx @@ -22,6 +22,7 @@ import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { IssueType } from '../../../types/issues'; +import { Component, MeasureEnhanced } from '../../../types/types'; import IssueLabel from '../components/IssueLabel'; import IssueRating from '../components/IssueRating'; import DebtValue from './DebtValue'; @@ -29,9 +30,9 @@ import SecurityHotspotsReviewed from './SecurityHotspotsReviewed'; export interface MeasuresPanelIssueMeasureRowProps { branchLike?: BranchLike; - component: T.Component; + component: Component; isNewCodeTab: boolean; - measures: T.MeasureEnhanced[]; + measures: MeasureEnhanced[]; type: IssueType; } diff --git a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelNoNewCode.tsx b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelNoNewCode.tsx index a6eaf3cf941..57532e33143 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelNoNewCode.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/MeasuresPanelNoNewCode.tsx @@ -25,11 +25,12 @@ import { translate } from '../../../helpers/l10n'; import { getBaseUrl } from '../../../helpers/system'; import { Branch } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; +import { Component, Period } from '../../../types/types'; export interface MeasuresPanelNoNewCodeProps { branch?: Branch; - component: T.Component; - period?: T.Period; + component: Component; + period?: Period; } export default function MeasuresPanelNoNewCode(props: MeasuresPanelNoNewCodeProps) { diff --git a/server/sonar-web/src/main/js/apps/overview/branches/NoCodeWarning.tsx b/server/sonar-web/src/main/js/apps/overview/branches/NoCodeWarning.tsx index 3c03e6fe6c5..bdf4542e5c5 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/NoCodeWarning.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/NoCodeWarning.tsx @@ -24,11 +24,12 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { MetricKey } from '../../../types/metrics'; +import { Component, MeasureEnhanced } from '../../../types/types'; interface Props { branchLike?: BranchLike; - component: T.Component; - measures?: T.MeasureEnhanced[]; + component: Component; + measures?: MeasureEnhanced[]; } export function NoCodeWarning({ branchLike, component, measures }: Props) { diff --git a/server/sonar-web/src/main/js/apps/overview/branches/ProjectLeakPeriodInfo.tsx b/server/sonar-web/src/main/js/apps/overview/branches/ProjectLeakPeriodInfo.tsx index 1996f07ae95..3e7a6defbd6 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/ProjectLeakPeriodInfo.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/ProjectLeakPeriodInfo.tsx @@ -24,9 +24,10 @@ import DateFromNow from '../../../components/intl/DateFromNow'; import { formatterOption } from '../../../components/intl/DateTimeFormatter'; import { translateWithParameters } from '../../../helpers/l10n'; import { getPeriodDate, getPeriodLabel } from '../../../helpers/periods'; +import { Period } from '../../../types/types'; export interface ProjectLeakPeriodInfoProps extends WrappedComponentProps { - leakPeriod: T.Period; + leakPeriod: Period; } export function ProjectLeakPeriodInfo(props: ProjectLeakPeriodInfoProps) { diff --git a/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanel.tsx b/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanel.tsx index 2954827ba40..128d3b0b0fa 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanel.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanel.tsx @@ -25,11 +25,12 @@ import { Alert } from '../../../components/ui/Alert'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { QualityGateStatus } from '../../../types/quality-gates'; +import { Component } from '../../../types/types'; import SonarLintPromotion from '../components/SonarLintPromotion'; import QualityGatePanelSection from './QualityGatePanelSection'; export interface QualityGatePanelProps { - component: Pick<T.Component, 'key' | 'qualifier'>; + component: Pick<Component, 'key' | 'qualifier'>; loading?: boolean; qgStatuses?: QualityGateStatus[]; } diff --git a/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanelSection.tsx b/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanelSection.tsx index 3470d679423..fe441a3bbda 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanelSection.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/QualityGatePanelSection.tsx @@ -23,11 +23,12 @@ import { isDiffMetric } from '../../../helpers/measures'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { QualityGateStatus } from '../../../types/quality-gates'; +import { Component } from '../../../types/types'; import QualityGateConditions from '../components/QualityGateConditions'; export interface QualityGatePanelSectionProps { branchLike?: BranchLike; - component: Pick<T.Component, 'key' | 'qualifier'>; + component: Pick<Component, 'key' | 'qualifier'>; qgStatus: QualityGateStatus; } diff --git a/server/sonar-web/src/main/js/apps/overview/branches/SecurityHotspotsReviewed.tsx b/server/sonar-web/src/main/js/apps/overview/branches/SecurityHotspotsReviewed.tsx index 01840022a22..63ed0c15e5a 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/SecurityHotspotsReviewed.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/SecurityHotspotsReviewed.tsx @@ -23,9 +23,10 @@ import CoverageRating from '../../../components/ui/CoverageRating'; import { translate } from '../../../helpers/l10n'; import { findMeasure, formatMeasure } from '../../../helpers/measures'; import { MetricKey } from '../../../types/metrics'; +import { MeasureEnhanced } from '../../../types/types'; export interface SecurityHotspotsReviewedProps { - measures: T.MeasureEnhanced[]; + measures: MeasureEnhanced[]; useDiffMetric?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-test.tsx b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-test.tsx index 08ef85049dd..bdb0f097d2f 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-test.tsx @@ -37,6 +37,7 @@ import { waitAndUpdate } from '../../../../helpers/testUtils'; import { ComponentQualifier } from '../../../../types/component'; import { MetricKey } from '../../../../types/metrics'; import { GraphType } from '../../../../types/project-activity'; +import { Measure, Metric } from '../../../../types/types'; import BranchOverview, { BRANCH_OVERVIEW_ACTIVITY_GRAPH, NO_CI_DETECTED } from '../BranchOverview'; import BranchOverviewRenderer from '../BranchOverviewRenderer'; @@ -49,8 +50,8 @@ jest.mock('../../../../api/measures', () => { const { mockMeasure, mockMetric } = jest.requireActual('../../../../helpers/testMocks'); return { getMeasuresWithPeriodAndMetrics: jest.fn((_, metricKeys: string[]) => { - const metrics: T.Metric[] = []; - const measures: T.Measure[] = []; + const metrics: Metric[] = []; + const measures: Measure[] = []; metricKeys.forEach(key => { if (key === 'unknown_metric') { return; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/Event-test.tsx b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/Event-test.tsx index 4a67a46209e..10d651996e7 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/Event-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/Event-test.tsx @@ -19,6 +19,7 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { AnalysisEvent } from '../../../../types/types'; import { Event } from '../Event'; it('should render an event correctly', () => { @@ -34,7 +35,7 @@ it('should render a version correctly', () => { }); it('should render rich quality gate event', () => { - const event: T.AnalysisEvent = { + const event: AnalysisEvent = { category: 'QUALITY_GATE', key: 'foo1234', name: '', diff --git a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ProjectLeakPeriodInfo-test.tsx b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ProjectLeakPeriodInfo-test.tsx index efe108afacd..4f6b86d484c 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ProjectLeakPeriodInfo-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ProjectLeakPeriodInfo-test.tsx @@ -22,6 +22,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { IntlShape } from 'react-intl'; import { mockPeriod } from '../../../../helpers/testMocks'; +import { Period } from '../../../../types/types'; import { ProjectLeakPeriodInfo } from '../ProjectLeakPeriodInfo'; jest.mock('date-fns', () => { @@ -61,7 +62,7 @@ it('should render a more precise date', () => { ).toMatchSnapshot(); }); -function shallowRender(period: Partial<T.Period> = {}) { +function shallowRender(period: Partial<Period> = {}) { return shallow( <ProjectLeakPeriodInfo intl={ diff --git a/server/sonar-web/src/main/js/apps/overview/components/App.tsx b/server/sonar-web/src/main/js/apps/overview/components/App.tsx index e16b7599eb3..d95d2cfff8c 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/App.tsx @@ -26,16 +26,17 @@ import { isPullRequest } from '../../../helpers/branch-like'; import { ProjectAlmBindingResponse } from '../../../types/alm-settings'; import { BranchLike } from '../../../types/branch-like'; import { isPortfolioLike } from '../../../types/component'; +import { AppState, Component } from '../../../types/types'; import BranchOverview from '../branches/BranchOverview'; const EmptyOverview = lazyLoadComponent(() => import('./EmptyOverview')); const PullRequestOverview = lazyLoadComponent(() => import('../pullRequests/PullRequestOverview')); interface Props { - appState: Pick<T.AppState, 'branchesEnabled'>; + appState: Pick<AppState, 'branchesEnabled'>; branchLike?: BranchLike; branchLikes: BranchLike[]; - component: T.Component; + component: Component; isInProgress?: boolean; isPending?: boolean; projectBinding?: ProjectAlmBindingResponse; diff --git a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx index 0008d78886f..ac6038393d8 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx @@ -29,12 +29,13 @@ import { getCurrentUser, Store } from '../../../store/rootReducer'; import { ProjectAlmBindingResponse } from '../../../types/alm-settings'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; +import { Component, CurrentUser } from '../../../types/types'; export interface EmptyOverviewProps { branchLike?: BranchLike; branchLikes: BranchLike[]; - component: T.Component; - currentUser: T.CurrentUser; + component: Component; + currentUser: CurrentUser; hasAnalyses?: boolean; projectBinding?: ProjectAlmBindingResponse; } diff --git a/server/sonar-web/src/main/js/apps/overview/components/IssueLabel.tsx b/server/sonar-web/src/main/js/apps/overview/components/IssueLabel.tsx index 8a9db10118b..b0a2068eaa9 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/IssueLabel.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/IssueLabel.tsx @@ -27,13 +27,14 @@ import { findMeasure, formatMeasure, localizeMetric } from '../../../helpers/mea import { getComponentIssuesUrl, getComponentSecurityHotspotsUrl } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; import { IssueType } from '../../../types/issues'; +import { Component, MeasureEnhanced } from '../../../types/types'; import { getIssueIconClass, getIssueMetricKey } from '../utils'; export interface IssueLabelProps { branchLike?: BranchLike; - component: T.Component; + component: Component; helpTooltip?: string; - measures: T.MeasureEnhanced[]; + measures: MeasureEnhanced[]; type: IssueType; useDiffMetric?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/overview/components/IssueRating.tsx b/server/sonar-web/src/main/js/apps/overview/components/IssueRating.tsx index ec85ad822ee..d3238fcbaf8 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/IssueRating.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/IssueRating.tsx @@ -25,12 +25,13 @@ import Rating from '../../../components/ui/Rating'; import { findMeasure } from '../../../helpers/measures'; import { BranchLike } from '../../../types/branch-like'; import { IssueType } from '../../../types/issues'; +import { Component, MeasureEnhanced } from '../../../types/types'; import { getIssueRatingMetricKey, getIssueRatingName } from '../utils'; export interface IssueRatingProps { branchLike?: BranchLike; - component: T.Component; - measures: T.MeasureEnhanced[]; + component: Component; + measures: MeasureEnhanced[]; type: IssueType; useDiffMetric?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx index c07984784aa..57759228ef1 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx @@ -26,12 +26,13 @@ import DateFromNow from '../../../components/intl/DateFromNow'; import DateTimeFormatter, { formatterOption } from '../../../components/intl/DateTimeFormatter'; import { translateWithParameters } from '../../../helpers/l10n'; import { getPeriodDate, getPeriodLabel } from '../../../helpers/periods'; +import { Dict, Period } from '../../../types/types'; interface Props { - period: T.Period; + period: Period; } -const MODE_INCLUDES_TIME: T.Dict<boolean> = { +const MODE_INCLUDES_TIME: Dict<boolean> = { manual_baseline: true, SPECIFIC_ANALYSIS: true }; diff --git a/server/sonar-web/src/main/js/apps/overview/components/MeasurementLabel.tsx b/server/sonar-web/src/main/js/apps/overview/components/MeasurementLabel.tsx index 5e968b8b893..3ac5219934a 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/MeasurementLabel.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/MeasurementLabel.tsx @@ -24,6 +24,7 @@ import DrilldownLink from '../../../components/shared/DrilldownLink'; import { translate } from '../../../helpers/l10n'; import { findMeasure, formatMeasure } from '../../../helpers/measures'; import { BranchLike } from '../../../types/branch-like'; +import { Component, MeasureEnhanced } from '../../../types/types'; import { getMeasurementIconClass, getMeasurementLabelKeys, @@ -35,8 +36,8 @@ import { interface Props { branchLike?: BranchLike; centered?: boolean; - component: T.Component; - measures: T.MeasureEnhanced[]; + component: Component; + measures: MeasureEnhanced[]; type: MeasurementType; useDiffMetric?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/overview/components/QualityGateCondition.tsx b/server/sonar-web/src/main/js/apps/overview/components/QualityGateCondition.tsx index a3a191f3ac4..cecbbdac1f9 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/QualityGateCondition.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/QualityGateCondition.tsx @@ -35,16 +35,17 @@ import { BranchLike } from '../../../types/branch-like'; import { IssueType } from '../../../types/issues'; import { MetricKey } from '../../../types/metrics'; import { QualityGateStatusConditionEnhanced } from '../../../types/quality-gates'; +import { Component, Dict } from '../../../types/types'; interface Props { branchLike?: BranchLike; - component: Pick<T.Component, 'key'>; + component: Pick<Component, 'key'>; condition: QualityGateStatusConditionEnhanced; } export default class QualityGateCondition extends React.PureComponent<Props> { - getIssuesUrl = (sinceLeakPeriod: boolean, customQuery: T.Dict<string>) => { - const query: T.Dict<string | undefined> = { + getIssuesUrl = (sinceLeakPeriod: boolean, customQuery: Dict<string>) => { + const query: Dict<string | undefined> = { resolved: 'false', ...getBranchLikeQuery(this.props.branchLike), ...customQuery @@ -56,7 +57,7 @@ export default class QualityGateCondition extends React.PureComponent<Props> { }; getUrlForSecurityHotspot(sinceLeakPeriod: boolean) { - const query: T.Dict<string | undefined> = { + const query: Dict<string | undefined> = { ...getBranchLikeQuery(this.props.branchLike) }; if (sinceLeakPeriod) { @@ -96,7 +97,7 @@ export default class QualityGateCondition extends React.PureComponent<Props> { const metricKey = condition.measure.metric.key; - const METRICS_TO_URL_MAPPING: T.Dict<() => Location> = { + const METRICS_TO_URL_MAPPING: Dict<() => Location> = { [MetricKey.reliability_rating]: () => this.getUrlForBugsOrVulnerabilities(IssueType.Bug, false), [MetricKey.new_reliability_rating]: () => diff --git a/server/sonar-web/src/main/js/apps/overview/components/QualityGateConditions.tsx b/server/sonar-web/src/main/js/apps/overview/components/QualityGateConditions.tsx index 77e6323bb87..5cd2452c863 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/QualityGateConditions.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/QualityGateConditions.tsx @@ -24,13 +24,14 @@ import ChevronDownIcon from '../../../components/icons/ChevronDownIcon'; import { translateWithParameters } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; import { QualityGateStatusConditionEnhanced } from '../../../types/quality-gates'; +import { Component } from '../../../types/types'; import QualityGateCondition from './QualityGateCondition'; const LEVEL_ORDER = ['ERROR', 'WARN']; export interface QualityGateConditionsProps { branchLike?: BranchLike; - component: Pick<T.Component, 'key'>; + component: Pick<Component, 'key'>; collapsible?: boolean; failedConditions: QualityGateStatusConditionEnhanced[]; } diff --git a/server/sonar-web/src/main/js/apps/overview/components/SonarLintPromotion.tsx b/server/sonar-web/src/main/js/apps/overview/components/SonarLintPromotion.tsx index 32a6ce2a627..7796778e690 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/SonarLintPromotion.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/SonarLintPromotion.tsx @@ -24,9 +24,10 @@ import SonarLintIcon from '../../../components/icons/SonarLintIcon'; import { translate } from '../../../helpers/l10n'; import { MetricKey } from '../../../types/metrics'; import { QualityGateStatusCondition } from '../../../types/quality-gates'; +import { CurrentUser } from '../../../types/types'; export interface SonarLintPromotionProps { - currentUser: T.CurrentUser; + currentUser: CurrentUser; qgConditions?: QualityGateStatusCondition[]; } diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx index 76929c951e9..44a2e8eac02 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx @@ -21,6 +21,7 @@ import { differenceInDays } from 'date-fns'; import { shallow } from 'enzyme'; import * as React from 'react'; import { IntlShape } from 'react-intl'; +import { Period } from '../../../../types/types'; import { LeakPeriodLegend } from '../LeakPeriodLegend'; jest.mock('date-fns', () => { @@ -60,7 +61,7 @@ it('should render a more precise date', () => { ).toMatchSnapshot(); }); -function getWrapper(period: Partial<T.Period> = {}) { +function getWrapper(period: Partial<Period> = {}) { return shallow( <LeakPeriodLegend intl={ diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/AfterMergeEstimate.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/AfterMergeEstimate.tsx index 333f4947b1e..437a0499532 100644 --- a/server/sonar-web/src/main/js/apps/overview/pullRequests/AfterMergeEstimate.tsx +++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/AfterMergeEstimate.tsx @@ -21,11 +21,12 @@ import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { findMeasure, formatMeasure } from '../../../helpers/measures'; +import { MeasureEnhanced } from '../../../types/types'; import { getMeasurementAfterMergeMetricKey, MeasurementType } from '../utils'; export interface AfterMergeEstimateProps { className?: string; - measures: T.MeasureEnhanced[]; + measures: MeasureEnhanced[]; type: MeasurementType; } diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/LargeQualityGateBadge.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/LargeQualityGateBadge.tsx index 307c163b893..e9cc50fa1b1 100644 --- a/server/sonar-web/src/main/js/apps/overview/pullRequests/LargeQualityGateBadge.tsx +++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/LargeQualityGateBadge.tsx @@ -26,10 +26,11 @@ import HelpTooltip from '../../../components/controls/HelpTooltip'; import HelpIcon from '../../../components/icons/HelpIcon'; import { translate } from '../../../helpers/l10n'; import { getQualityGatesUrl, getQualityGateUrl } from '../../../helpers/urls'; +import { Component, Status } from '../../../types/types'; interface Props { - component: T.Component; - level?: T.Status; + component: Component; + level?: Status; } export function LargeQualityGateBadge({ component, level }: Props) { diff --git a/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx b/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx index d6a0cdcb7ef..270f52aea34 100644 --- a/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/pullRequests/PullRequestOverview.tsx @@ -33,6 +33,7 @@ import { getBranchStatusByBranchLike, Store } from '../../../store/rootReducer'; import { BranchLike, PullRequest } from '../../../types/branch-like'; import { IssueType } from '../../../types/issues'; import { QualityGateStatusCondition } from '../../../types/quality-gates'; +import { Component, MeasureEnhanced, Status } from '../../../types/types'; import IssueLabel from '../components/IssueLabel'; import IssueRating from '../components/IssueRating'; import MeasurementLabel from '../components/MeasurementLabel'; @@ -46,7 +47,7 @@ import LargeQualityGateBadge from './LargeQualityGateBadge'; interface StateProps { conditions?: QualityGateStatusCondition[]; ignoredConditions?: boolean; - status?: T.Status; + status?: Status; } interface DispatchProps { @@ -55,14 +56,14 @@ interface DispatchProps { interface OwnProps { branchLike: PullRequest; - component: T.Component; + component: Component; } type Props = StateProps & DispatchProps & OwnProps; interface State { loading: boolean; - measures: T.MeasureEnhanced[]; + measures: MeasureEnhanced[]; } export class PullRequestOverview extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.tsx index 4a2c0629eb5..c6ed95e5993 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.tsx @@ -28,13 +28,14 @@ import ActionsDropdown, { ActionsDropdownItem } from '../../../components/contro import { Router, withRouter } from '../../../components/hoc/withRouter'; import QualifierIcon from '../../../components/icons/QualifierIcon'; import { translate } from '../../../helpers/l10n'; +import { PermissionTemplate } from '../../../types/types'; import { PERMISSION_TEMPLATES_PATH } from '../utils'; import DeleteForm from './DeleteForm'; import Form from './Form'; interface Props { fromDetails?: boolean; - permissionTemplate: T.PermissionTemplate; + permissionTemplate: PermissionTemplate; refresh: () => void; router: Pick<Router, 'replace'>; topQualifiers: string[]; diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/App.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/App.tsx index 1502c621064..bd212fcf492 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/App.tsx @@ -25,6 +25,7 @@ import { getPermissionTemplates } from '../../../api/permissions'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import { translate } from '../../../helpers/l10n'; import { getAppState, Store } from '../../../store/rootReducer'; +import { Permission, PermissionTemplate } from '../../../types/types'; import '../../permissions/styles.css'; import { mergeDefaultsToTemplates, mergePermissionsToTemplates, sortPermissions } from '../utils'; import Home from './Home'; @@ -37,8 +38,8 @@ interface Props { interface State { ready: boolean; - permissions: T.Permission[]; - permissionTemplates: T.PermissionTemplate[]; + permissions: Permission[]; + permissionTemplates: PermissionTemplate[]; } export class App extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/Defaults.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/Defaults.tsx index 6989f2ac20d..4281bf6640b 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/Defaults.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/Defaults.tsx @@ -20,9 +20,10 @@ import { sortBy } from 'lodash'; import * as React from 'react'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { PermissionTemplate } from '../../../types/types'; interface Props { - template: T.PermissionTemplate; + template: PermissionTemplate; } export default function Defaults({ template }: Props) { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/DeleteForm.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/DeleteForm.tsx index e7ccb518868..f4bd8ef0967 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/DeleteForm.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/DeleteForm.tsx @@ -22,11 +22,12 @@ import { ResetButtonLink, SubmitButton } from '../../../components/controls/butt import SimpleModal from '../../../components/controls/SimpleModal'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { PermissionTemplate } from '../../../types/types'; interface Props { onClose: () => void; onSubmit: () => Promise<void>; - permissionTemplate: T.PermissionTemplate; + permissionTemplate: PermissionTemplate; } export default function DeleteForm({ onClose, onSubmit, permissionTemplate: t }: Props) { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/Home.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/Home.tsx index 398a06773bb..a5bbfd3d39e 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/Home.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/Home.tsx @@ -20,12 +20,13 @@ import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { translate } from '../../../helpers/l10n'; +import { Permission, PermissionTemplate } from '../../../types/types'; import Header from './Header'; import List from './List'; interface Props { - permissionTemplates: T.PermissionTemplate[]; - permissions: T.Permission[]; + permissionTemplates: PermissionTemplate[]; + permissions: Permission[]; ready: boolean; refresh: () => Promise<void>; topQualifiers: string[]; diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/List.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/List.tsx index 526d8802e81..b208770810f 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/List.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/List.tsx @@ -18,12 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Permission, PermissionTemplate } from '../../../types/types'; import ListHeader from './ListHeader'; import ListItem from './ListItem'; interface Props { - permissionTemplates: T.PermissionTemplate[]; - permissions: T.Permission[]; + permissionTemplates: PermissionTemplate[]; + permissions: Permission[]; refresh: () => Promise<void>; topQualifiers: string[]; } diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/ListHeader.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/ListHeader.tsx index 3ce076cdb3e..e633c1a23e9 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/ListHeader.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/ListHeader.tsx @@ -22,13 +22,14 @@ import InstanceMessage from '../../../components/common/InstanceMessage'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import { Alert } from '../../../components/ui/Alert'; import { translate } from '../../../helpers/l10n'; +import { Permission } from '../../../types/types'; interface Props { - permissions: T.Permission[]; + permissions: Permission[]; } export default class ListHeader extends React.PureComponent<Props> { - renderTooltip(permission: T.Permission) { + renderTooltip(permission: Permission) { return permission.key === 'user' || permission.key === 'codeviewer' ? ( <div> <InstanceMessage message={translate('projects_role', permission.key, 'desc')} /> diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/ListItem.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/ListItem.tsx index 7c4383463fa..a88771782a1 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/ListItem.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/ListItem.tsx @@ -18,13 +18,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { PermissionTemplate } from '../../../types/types'; import ActionsCell from './ActionsCell'; import NameCell from './NameCell'; import PermissionCell from './PermissionCell'; interface Props { refresh: () => Promise<void>; - template: T.PermissionTemplate; + template: PermissionTemplate; topQualifiers: string[]; } diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.tsx index d1c52770255..1da9847cc47 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.tsx @@ -19,11 +19,12 @@ */ import * as React from 'react'; import { Link } from 'react-router'; +import { PermissionTemplate } from '../../../types/types'; import { PERMISSION_TEMPLATES_PATH } from '../utils'; import Defaults from './Defaults'; interface Props { - template: T.PermissionTemplate; + template: PermissionTemplate; } export default function NameCell({ template }: Props) { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/Template.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/Template.tsx index a865e508377..05450518584 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/Template.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/Template.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import * as api from '../../../api/permissions'; import { translate } from '../../../helpers/l10n'; +import { PermissionGroup, PermissionTemplate, PermissionUser } from '../../../types/types'; import HoldersList from '../../permissions/shared/components/HoldersList'; import SearchForm from '../../permissions/shared/components/SearchForm'; import { @@ -32,17 +33,17 @@ import TemplateHeader from './TemplateHeader'; interface Props { refresh: () => void; - template: T.PermissionTemplate; + template: PermissionTemplate; topQualifiers: string[]; } interface State { filter: string; - groups: T.PermissionGroup[]; + groups: PermissionGroup[]; loading: boolean; query: string; selectedPermission?: string; - users: T.PermissionUser[]; + users: PermissionUser[]; } export default class Template extends React.PureComponent<Props, State> { @@ -95,7 +96,7 @@ export default class Template extends React.PureComponent<Props, State> { }); }; - handleToggleUser = (user: T.PermissionUser, permission: string) => { + handleToggleUser = (user: PermissionUser, permission: string) => { if (user.login === '<creator>') { return this.handleToggleProjectCreator(user, permission); } @@ -113,7 +114,7 @@ export default class Template extends React.PureComponent<Props, State> { return request.then(() => this.requestHolders()).then(this.props.refresh); }; - handleToggleProjectCreator = (user: T.PermissionUser, permission: string) => { + handleToggleProjectCreator = (user: PermissionUser, permission: string) => { const { template } = this.props; const hasPermission = user.permissions.includes(permission); const request = hasPermission @@ -122,7 +123,7 @@ export default class Template extends React.PureComponent<Props, State> { return request.then(() => this.requestHolders()).then(this.props.refresh); }; - handleToggleGroup = (group: T.PermissionGroup, permission: string) => { + handleToggleGroup = (group: PermissionGroup, permission: string) => { const { template } = this.props; const hasPermission = group.permissions.includes(permission); const data = { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/TemplateDetails.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/TemplateDetails.tsx index 564c118fd24..478cc307dd1 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/TemplateDetails.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/TemplateDetails.tsx @@ -18,10 +18,11 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { PermissionTemplate } from '../../../types/types'; import Defaults from './Defaults'; interface Props { - template: T.PermissionTemplate; + template: PermissionTemplate; } export default function TemplateDetails({ template }: Props) { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/TemplateHeader.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/TemplateHeader.tsx index c0cb3b92d3d..446d07f9644 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/TemplateHeader.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/TemplateHeader.tsx @@ -20,13 +20,14 @@ import * as React from 'react'; import { Link } from 'react-router'; import { translate } from '../../../helpers/l10n'; +import { PermissionTemplate } from '../../../types/types'; import { PERMISSION_TEMPLATES_PATH } from '../utils'; import ActionsCell from './ActionsCell'; interface Props { loading: boolean; refresh: () => void; - template: T.PermissionTemplate; + template: PermissionTemplate; topQualifiers: string[]; } diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/Defaults-test.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/Defaults-test.tsx index 988f38e143c..4e5ac549534 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/Defaults-test.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/Defaults-test.tsx @@ -19,9 +19,10 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { PermissionTemplate } from '../../../../types/types'; import Defaults from '../Defaults'; -const SAMPLE: T.PermissionTemplate = { +const SAMPLE: PermissionTemplate = { createdAt: '2018-01-01', defaultFor: [], id: 'id', diff --git a/server/sonar-web/src/main/js/apps/permission-templates/utils.ts b/server/sonar-web/src/main/js/apps/permission-templates/utils.ts index 159470adc43..0225794fa86 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/utils.ts +++ b/server/sonar-web/src/main/js/apps/permission-templates/utils.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { sortBy } from 'lodash'; +import { Permission, PermissionTemplate } from '../../types/types'; export const PERMISSIONS_ORDER = [ 'user', @@ -30,14 +31,14 @@ export const PERMISSIONS_ORDER = [ export const PERMISSION_TEMPLATES_PATH = '/permission_templates'; -export function sortPermissions(permissions: T.Permission[]) { +export function sortPermissions(permissions: Permission[]) { return sortBy(permissions, p => PERMISSIONS_ORDER.indexOf(p.key)); } export function mergePermissionsToTemplates( - permissionTemplates: T.PermissionTemplate[], - basePermissions: T.Permission[] -): T.PermissionTemplate[] { + permissionTemplates: PermissionTemplate[], + basePermissions: Permission[] +): PermissionTemplate[] { return permissionTemplates.map(permissionTemplate => { // it's important to keep the order of the permission template's permissions // the same as the order of base permissions @@ -53,9 +54,9 @@ export function mergePermissionsToTemplates( } export function mergeDefaultsToTemplates( - permissionTemplates: T.PermissionTemplate[], + permissionTemplates: PermissionTemplate[], defaultTemplates: Array<{ templateId: string; qualifier: string }> = [] -): T.PermissionTemplate[] { +): PermissionTemplate[] { return permissionTemplates.map(permissionTemplate => { const defaultFor: string[] = []; diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx b/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx index fa35299f732..68a985e89e0 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx @@ -22,6 +22,7 @@ import { connect } from 'react-redux'; import ListFooter from '../../../../components/controls/ListFooter'; import { getAppState, Store } from '../../../../store/rootReducer'; import { ComponentQualifier } from '../../../../types/component'; +import { AppState, Paging, PermissionGroup, PermissionUser } from '../../../../types/types'; import HoldersList from '../../shared/components/HoldersList'; import SearchForm from '../../shared/components/SearchForm'; import { @@ -31,15 +32,15 @@ import { } from '../../utils'; interface StateProps { - appState: Pick<T.AppState, 'qualifiers'>; + appState: Pick<AppState, 'qualifiers'>; } interface OwnProps { filter: string; grantPermissionToGroup: (groupName: string, permission: string) => Promise<void>; grantPermissionToUser: (login: string, permission: string) => Promise<void>; - groups: T.PermissionGroup[]; - groupsPaging?: T.Paging; + groups: PermissionGroup[]; + groupsPaging?: Paging; loadHolders: () => void; loading?: boolean; onLoadMore: () => void; @@ -48,14 +49,14 @@ interface OwnProps { query: string; revokePermissionFromGroup: (groupName: string, permission: string) => Promise<void>; revokePermissionFromUser: (login: string, permission: string) => Promise<void>; - users: T.PermissionUser[]; - usersPaging?: T.Paging; + users: PermissionUser[]; + usersPaging?: Paging; } type Props = StateProps & OwnProps; export class AllHoldersList extends React.PureComponent<Props> { - handleToggleUser = (user: T.PermissionUser, permission: string) => { + handleToggleUser = (user: PermissionUser, permission: string) => { const hasPermission = user.permissions.includes(permission); if (hasPermission) { return this.props.revokePermissionFromUser(user.login, permission); @@ -64,7 +65,7 @@ export class AllHoldersList extends React.PureComponent<Props> { } }; - handleToggleGroup = (group: T.PermissionGroup, permission: string) => { + handleToggleGroup = (group: PermissionGroup, permission: string) => { const hasPermission = group.permissions.includes(permission); if (hasPermission) { diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/App.tsx b/server/sonar-web/src/main/js/apps/permissions/global/components/App.tsx index d500c870b98..e51350c3583 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/global/components/App.tsx @@ -23,18 +23,19 @@ import { Helmet } from 'react-helmet-async'; import * as api from '../../../../api/permissions'; import Suggestions from '../../../../app/components/embed-docs-modal/Suggestions'; import { translate } from '../../../../helpers/l10n'; +import { Paging, PermissionGroup, PermissionUser } from '../../../../types/types'; import '../../styles.css'; import AllHoldersList from './AllHoldersList'; import PageHeader from './PageHeader'; interface State { filter: 'all' | 'groups' | 'users'; - groups: T.PermissionGroup[]; - groupsPaging?: T.Paging; + groups: PermissionGroup[]; + groupsPaging?: Paging; loading: boolean; query: string; - users: T.PermissionUser[]; - usersPaging?: T.Paging; + users: PermissionUser[]; + usersPaging?: Paging; } export default class App extends React.PureComponent<{}, State> { @@ -63,7 +64,7 @@ export default class App extends React.PureComponent<{}, State> { loadUsersAndGroups = (userPage?: number, groupsPage?: number) => { const { filter, query } = this.state; - const getUsers: Promise<{ paging?: T.Paging; users: T.PermissionUser[] }> = + const getUsers: Promise<{ paging?: Paging; users: PermissionUser[] }> = filter !== 'groups' ? api.getGlobalPermissionsUsers({ q: query || undefined, @@ -71,7 +72,7 @@ export default class App extends React.PureComponent<{}, State> { }) : Promise.resolve({ paging: undefined, users: [] }); - const getGroups: Promise<{ paging?: T.Paging; groups: T.PermissionGroup[] }> = + const getGroups: Promise<{ paging?: Paging; groups: PermissionGroup[] }> = filter !== 'users' ? api.getGlobalPermissionsGroups({ q: query || undefined, @@ -124,7 +125,7 @@ export default class App extends React.PureComponent<{}, State> { this.setState({ query }, this.loadHolders); }; - addPermissionToGroup = (groups: T.PermissionGroup[], group: string, permission: string) => { + addPermissionToGroup = (groups: PermissionGroup[], group: string, permission: string) => { return groups.map(candidate => candidate.name === group ? { ...candidate, permissions: [...candidate.permissions, permission] } @@ -132,7 +133,7 @@ export default class App extends React.PureComponent<{}, State> { ); }; - addPermissionToUser = (users: T.PermissionUser[], user: string, permission: string) => { + addPermissionToUser = (users: PermissionUser[], user: string, permission: string) => { return users.map(candidate => candidate.login === user ? { ...candidate, permissions: [...candidate.permissions, permission] } @@ -140,7 +141,7 @@ export default class App extends React.PureComponent<{}, State> { ); }; - removePermissionFromGroup = (groups: T.PermissionGroup[], group: string, permission: string) => { + removePermissionFromGroup = (groups: PermissionGroup[], group: string, permission: string) => { return groups.map(candidate => candidate.name === group ? { ...candidate, permissions: without(candidate.permissions, permission) } @@ -148,7 +149,7 @@ export default class App extends React.PureComponent<{}, State> { ); }; - removePermissionFromUser = (users: T.PermissionUser[], user: string, permission: string) => { + removePermissionFromUser = (users: PermissionUser[], user: string, permission: string) => { return users.map(candidate => candidate.login === user ? { ...candidate, permissions: without(candidate.permissions, permission) } diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.tsx b/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.tsx index f082f4702be..744b9945156 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.tsx @@ -20,17 +20,24 @@ import { without } from 'lodash'; import * as React from 'react'; import ListFooter from '../../../../components/controls/ListFooter'; +import { + Component, + Paging, + PermissionGroup, + PermissionUser, + Visibility +} from '../../../../types/types'; import HoldersList from '../../shared/components/HoldersList'; import SearchForm from '../../shared/components/SearchForm'; import { convertToPermissionDefinitions, PERMISSIONS_ORDER_BY_QUALIFIER } from '../../utils'; interface Props { - component: T.Component; + component: Component; filter: string; grantPermissionToGroup: (group: string, permission: string) => Promise<void>; grantPermissionToUser: (user: string, permission: string) => Promise<void>; - groups: T.PermissionGroup[]; - groupsPaging?: T.Paging; + groups: PermissionGroup[]; + groupsPaging?: Paging; onLoadMore: () => void; onFilterChange: (filter: string) => void; onPermissionSelect: (permissions?: string) => void; @@ -39,13 +46,13 @@ interface Props { revokePermissionFromGroup: (group: string, permission: string) => Promise<void>; revokePermissionFromUser: (user: string, permission: string) => Promise<void>; selectedPermission?: string; - users: T.PermissionUser[]; - usersPaging?: T.Paging; - visibility?: T.Visibility; + users: PermissionUser[]; + usersPaging?: Paging; + visibility?: Visibility; } export default class AllHoldersList extends React.PureComponent<Props> { - handleToggleUser = (user: T.PermissionUser, permission: string) => { + handleToggleUser = (user: PermissionUser, permission: string) => { const hasPermission = user.permissions.includes(permission); if (hasPermission) { @@ -55,7 +62,7 @@ export default class AllHoldersList extends React.PureComponent<Props> { } }; - handleToggleGroup = (group: T.PermissionGroup, permission: string) => { + handleToggleGroup = (group: PermissionGroup, permission: string) => { const hasPermission = group.permissions.includes(permission); if (hasPermission) { diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/App.tsx b/server/sonar-web/src/main/js/apps/permissions/project/components/App.tsx index 9b3fa2b5df4..5a318e7dbb8 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/App.tsx @@ -23,26 +23,27 @@ import { Helmet } from 'react-helmet-async'; import * as api from '../../../../api/permissions'; import VisibilitySelector from '../../../../components/common/VisibilitySelector'; import { translate } from '../../../../helpers/l10n'; +import { Component, Paging, PermissionGroup, PermissionUser } from '../../../../types/types'; import '../../styles.css'; import AllHoldersList from './AllHoldersList'; import PageHeader from './PageHeader'; import PublicProjectDisclaimer from './PublicProjectDisclaimer'; interface Props { - component: T.Component; - onComponentChange: (changes: Partial<T.Component>) => void; + component: Component; + onComponentChange: (changes: Partial<Component>) => void; } interface State { disclaimer: boolean; filter: string; - groups: T.PermissionGroup[]; - groupsPaging?: T.Paging; + groups: PermissionGroup[]; + groupsPaging?: Paging; loading: boolean; query: string; selectedPermission?: string; - users: T.PermissionUser[]; - usersPaging?: T.Paging; + users: PermissionUser[]; + usersPaging?: Paging; } export default class App extends React.PureComponent<Props, State> { @@ -79,7 +80,7 @@ export default class App extends React.PureComponent<Props, State> { const { component } = this.props; const { filter, query, selectedPermission } = this.state; - const getUsers: Promise<{ paging?: T.Paging; users: T.PermissionUser[] }> = + const getUsers: Promise<{ paging?: Paging; users: PermissionUser[] }> = filter !== 'groups' ? api.getPermissionsUsersForComponent({ projectKey: component.key, @@ -89,7 +90,7 @@ export default class App extends React.PureComponent<Props, State> { }) : Promise.resolve({ paging: undefined, users: [] }); - const getGroups: Promise<{ paging?: T.Paging; groups: T.PermissionGroup[] }> = + const getGroups: Promise<{ paging?: Paging; groups: PermissionGroup[] }> = filter !== 'users' ? api.getPermissionsGroupsForComponent({ projectKey: component.key, diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/ApplyTemplate.tsx b/server/sonar-web/src/main/js/apps/permissions/project/components/ApplyTemplate.tsx index 15df2627efd..fb40ec73f7e 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/ApplyTemplate.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/ApplyTemplate.tsx @@ -27,6 +27,7 @@ import DeferredSpinner from '../../../../components/ui/DeferredSpinner'; import MandatoryFieldMarker from '../../../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../../../components/ui/MandatoryFieldsExplanation'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; +import { PermissionTemplate } from '../../../../types/types'; interface Props { onApply?: () => void; @@ -38,7 +39,7 @@ interface State { done: boolean; loading: boolean; permissionTemplate?: string; - permissionTemplates?: T.PermissionTemplate[]; + permissionTemplates?: PermissionTemplate[]; } export default class ApplyTemplate extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx index 242eebafe26..1adc92fb2fc 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx @@ -21,10 +21,11 @@ import * as React from 'react'; import { Button } from '../../../../components/controls/buttons'; import { translate } from '../../../../helpers/l10n'; import { isApplication, isPortfolioLike } from '../../../../types/component'; +import { Component } from '../../../../types/types'; import ApplyTemplate from './ApplyTemplate'; interface Props { - component: T.Component; + component: Component; loadHolders: () => void; loading: boolean; } diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/GroupHolder.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/GroupHolder.tsx index 98c52700247..8a93bf269ea 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/GroupHolder.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/GroupHolder.tsx @@ -20,13 +20,14 @@ import { without } from 'lodash'; import * as React from 'react'; import GroupIcon from '../../../../components/icons/GroupIcon'; +import { PermissionDefinitions, PermissionGroup } from '../../../../types/types'; import { isPermissionDefinitionGroup } from '../../utils'; import PermissionCell from './PermissionCell'; interface Props { - group: T.PermissionGroup; - onToggle: (group: T.PermissionGroup, permission: string) => Promise<void>; - permissions: T.PermissionDefinitions; + group: PermissionGroup; + onToggle: (group: PermissionGroup, permission: string) => Promise<void>; + permissions: PermissionDefinitions; selectedPermission?: string; } diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.tsx index bcce4e0b0b7..b4ce6650e9a 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.tsx @@ -20,6 +20,12 @@ import { partition, sortBy } from 'lodash'; import * as React from 'react'; import { translate } from '../../../../helpers/l10n'; +import { + Dict, + PermissionDefinitions, + PermissionGroup, + PermissionUser +} from '../../../../types/types'; import { isPermissionDefinitionGroup } from '../../utils'; import GroupHolder from './GroupHolder'; import PermissionHeader from './PermissionHeader'; @@ -27,20 +33,20 @@ import UserHolder from './UserHolder'; interface Props { filter?: string; - groups: T.PermissionGroup[]; + groups: PermissionGroup[]; loading?: boolean; onSelectPermission?: (permission: string) => void; - onToggleGroup: (group: T.PermissionGroup, permission: string) => Promise<void>; - onToggleUser: (user: T.PermissionUser, permission: string) => Promise<void>; - permissions: T.PermissionDefinitions; + onToggleGroup: (group: PermissionGroup, permission: string) => Promise<void>; + onToggleUser: (user: PermissionUser, permission: string) => Promise<void>; + permissions: PermissionDefinitions; query?: string; selectedPermission?: string; showPublicProjectsWarning?: boolean; - users: T.PermissionUser[]; + users: PermissionUser[]; } interface State { - initialPermissionsCount: T.Dict<number>; + initialPermissionsCount: Dict<number>; } export default class HoldersList extends React.PureComponent<Props, State> { state: State = { initialPermissionsCount: {} }; @@ -50,11 +56,11 @@ export default class HoldersList extends React.PureComponent<Props, State> { } } - isPermissionUser(item: T.PermissionGroup | T.PermissionUser): item is T.PermissionUser { - return (item as T.PermissionUser).login !== undefined; + isPermissionUser(item: PermissionGroup | PermissionUser): item is PermissionUser { + return (item as PermissionUser).login !== undefined; } - handleGroupToggle = (group: T.PermissionGroup, permission: string) => { + handleGroupToggle = (group: PermissionGroup, permission: string) => { const key = group.id || group.name; if (this.state.initialPermissionsCount[key] === undefined) { this.setState(state => ({ @@ -67,7 +73,7 @@ export default class HoldersList extends React.PureComponent<Props, State> { return this.props.onToggleGroup(group, permission); }; - handleUserToggle = (user: T.PermissionUser, permission: string) => { + handleUserToggle = (user: PermissionUser, permission: string) => { if (this.state.initialPermissionsCount[user.login] === undefined) { this.setState(state => ({ initialPermissionsCount: { @@ -79,7 +85,7 @@ export default class HoldersList extends React.PureComponent<Props, State> { return this.props.onToggleUser(user, permission); }; - getItemInitialPermissionsCount = (item: T.PermissionGroup | T.PermissionUser) => { + getItemInitialPermissionsCount = (item: PermissionGroup | PermissionUser) => { const key = this.isPermissionUser(item) ? item.login : item.id || item.name; return this.state.initialPermissionsCount[key] !== undefined ? this.state.initialPermissionsCount[key] @@ -95,7 +101,7 @@ export default class HoldersList extends React.PureComponent<Props, State> { ); } - renderItem(item: T.PermissionUser | T.PermissionGroup, permissions: T.PermissionDefinitions) { + renderItem(item: PermissionUser | PermissionGroup, permissions: PermissionDefinitions) { return this.isPermissionUser(item) ? ( <UserHolder key={`user-${item.login}`} diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionCell.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionCell.tsx index 66d667f147b..2a240cfa0c8 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionCell.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionCell.tsx @@ -20,13 +20,19 @@ import classNames from 'classnames'; import * as React from 'react'; import Checkbox from '../../../../components/controls/Checkbox'; +import { + PermissionDefinition, + PermissionDefinitionGroup, + PermissionGroup, + PermissionUser +} from '../../../../types/types'; import { isPermissionDefinitionGroup } from '../../utils'; interface Props { loading: string[]; onCheck: (checked: boolean, permission?: string) => void; - permission: T.PermissionDefinition | T.PermissionDefinitionGroup; - permissionItem: T.PermissionGroup | T.PermissionUser; + permission: PermissionDefinition | PermissionDefinitionGroup; + permissionItem: PermissionGroup | PermissionUser; selectedPermission?: string; } diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx index e0012f41af1..ed44cf2d870 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx @@ -24,11 +24,12 @@ import HelpTooltip from '../../../../components/controls/HelpTooltip'; import Tooltip from '../../../../components/controls/Tooltip'; import { Alert } from '../../../../components/ui/Alert'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; +import { PermissionDefinition, PermissionDefinitionGroup } from '../../../../types/types'; import { isPermissionDefinitionGroup } from '../../utils'; interface Props { onSelectPermission?: (permission: string) => void; - permission: T.PermissionDefinition | T.PermissionDefinitionGroup; + permission: PermissionDefinition | PermissionDefinitionGroup; selectedPermission?: string; showPublicProjectsWarning?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/UserHolder.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/UserHolder.tsx index 8f767da002f..6345c4af12c 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/UserHolder.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/UserHolder.tsx @@ -21,14 +21,15 @@ import { without } from 'lodash'; import * as React from 'react'; import Avatar from '../../../../components/ui/Avatar'; import { translate } from '../../../../helpers/l10n'; +import { PermissionDefinitions, PermissionUser } from '../../../../types/types'; import { isPermissionDefinitionGroup } from '../../utils'; import PermissionCell from './PermissionCell'; interface Props { - onToggle: (user: T.PermissionUser, permission: string) => Promise<void>; - permissions: T.PermissionDefinitions; + onToggle: (user: PermissionUser, permission: string) => Promise<void>; + permissions: PermissionDefinitions; selectedPermission?: string; - user: T.PermissionUser; + user: PermissionUser; } interface State { diff --git a/server/sonar-web/src/main/js/apps/permissions/utils.ts b/server/sonar-web/src/main/js/apps/permissions/utils.ts index 1fd5ab17dd4..ba61c427d98 100644 --- a/server/sonar-web/src/main/js/apps/permissions/utils.ts +++ b/server/sonar-web/src/main/js/apps/permissions/utils.ts @@ -19,6 +19,7 @@ */ import { hasMessage, translate } from '../../helpers/l10n'; import { isSonarCloud } from '../../helpers/system'; +import { Dict, PermissionDefinition, PermissionDefinitionGroup } from '../../types/types'; export const PERMISSIONS_ORDER_FOR_PROJECT_TEMPLATE = [ 'user', @@ -40,7 +41,7 @@ export const PERMISSIONS_ORDER_FOR_VIEW = ['user', 'admin']; export const PERMISSIONS_ORDER_FOR_DEV = ['user', 'admin']; -export const PERMISSIONS_ORDER_BY_QUALIFIER: T.Dict<string[]> = { +export const PERMISSIONS_ORDER_BY_QUALIFIER: Dict<string[]> = { TRK: PERMISSIONS_ORDER_FOR_PROJECT_TEMPLATE, VW: PERMISSIONS_ORDER_FOR_VIEW, SVW: PERMISSIONS_ORDER_FOR_VIEW, @@ -91,7 +92,7 @@ export function filterPermissions( export function convertToPermissionDefinitions( permissions: Array<string | { category: string; permissions: string[] }>, l10nPrefix: string -): Array<T.PermissionDefinition | T.PermissionDefinitionGroup> { +): Array<PermissionDefinition | PermissionDefinitionGroup> { return permissions.map(permission => { if (typeof permission === 'object') { return { @@ -106,7 +107,7 @@ export function convertToPermissionDefinitions( } export function isPermissionDefinitionGroup( - permission?: T.PermissionDefinition | T.PermissionDefinitionGroup -): permission is T.PermissionDefinitionGroup { - return Boolean(permission && (permission as T.PermissionDefinitionGroup).category); + permission?: PermissionDefinition | PermissionDefinitionGroup +): permission is PermissionDefinitionGroup { + return Boolean(permission && (permission as PermissionDefinitionGroup).category); } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/actions.ts b/server/sonar-web/src/main/js/apps/projectActivity/actions.ts index d2d95457753..eba87d060f0 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/actions.ts +++ b/server/sonar-web/src/main/js/apps/projectActivity/actions.ts @@ -17,9 +17,10 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { AnalysisEvent } from '../../types/types'; import { State } from './components/ProjectActivityAppContainer'; -export function addCustomEvent(analysis: string, event: T.AnalysisEvent) { +export function addCustomEvent(analysis: string, event: AnalysisEvent) { return (state: State) => ({ analyses: state.analyses.map(item => { if (item.key !== analysis) { @@ -41,7 +42,7 @@ export function deleteEvent(analysis: string, event: string) { }); } -export function changeEvent(analysis: string, event: T.AnalysisEvent) { +export function changeEvent(analysis: string, event: AnalysisEvent) { return (state: State) => ({ analyses: state.analyses.map(item => { if (item.key !== analysis) { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx index 32b6759c9cb..71384fdb2d9 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx @@ -28,11 +28,12 @@ import { translate } from '../../../helpers/l10n'; import { limitComponentName } from '../../../helpers/path'; import { getProjectUrl } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; +import { AnalysisEvent } from '../../../types/types'; -export type DefinitionChangeEvent = T.AnalysisEvent & - Required<Pick<T.AnalysisEvent, 'definitionChange'>>; +export type DefinitionChangeEvent = AnalysisEvent & + Required<Pick<AnalysisEvent, 'definitionChange'>>; -export function isDefinitionChangeEvent(event: T.AnalysisEvent): event is DefinitionChangeEvent { +export function isDefinitionChangeEvent(event: AnalysisEvent): event is DefinitionChangeEvent { return event.category === 'DEFINITION_CHANGE' && event.definitionChange !== undefined; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/Event.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/Event.tsx index a90c8bd379c..658e9d9cf45 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/Event.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/Event.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import { DeleteButton, EditButton } from '../../../components/controls/buttons'; import { translate } from '../../../helpers/l10n'; +import { AnalysisEvent } from '../../../types/types'; import EventInner from './EventInner'; import ChangeEventForm from './forms/ChangeEventForm'; import RemoveEventForm from './forms/RemoveEventForm'; @@ -27,7 +28,7 @@ import RemoveEventForm from './forms/RemoveEventForm'; export interface EventProps { analysisKey: string; canAdmin?: boolean; - event: T.AnalysisEvent; + event: AnalysisEvent; isFirst?: boolean; onChange?: (event: string, name: string) => Promise<void>; onDelete?: (analysisKey: string, event: string) => Promise<void>; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.tsx index 1180aa9d6c3..6502ec138b0 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.tsx @@ -21,11 +21,12 @@ import * as React from 'react'; import { ComponentContext } from '../../../app/components/ComponentContext'; import Tooltip from '../../../components/controls/Tooltip'; import { translate } from '../../../helpers/l10n'; +import { AnalysisEvent } from '../../../types/types'; import { DefinitionChangeEventInner, isDefinitionChangeEvent } from './DefinitionChangeEventInner'; import { isRichQualityGateEvent, RichQualityGateEventInner } from './RichQualityGateEventInner'; export interface EventInnerProps { - event: T.AnalysisEvent; + event: AnalysisEvent; readonly?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/Events.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/Events.tsx index 5839141e24b..37968a03603 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/Events.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/Events.tsx @@ -19,12 +19,13 @@ */ import { sortBy } from 'lodash'; import * as React from 'react'; +import { AnalysisEvent } from '../../../types/types'; import Event from './Event'; export interface EventsProps { analysisKey: string; canAdmin?: boolean; - events: T.AnalysisEvent[]; + events: AnalysisEvent[]; isFirst?: boolean; onChange?: (event: string, name: string) => Promise<void>; onDelete?: (analysis: string, event: string) => Promise<void>; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.tsx index 7354797aef6..e82919c15d0 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.tsx @@ -26,13 +26,14 @@ import DateFormatter from '../../../components/intl/DateFormatter'; import { toShortNotSoISOString } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; import { ComponentQualifier } from '../../../types/component'; +import { ParsedAnalysis } from '../../../types/types'; import { activityQueryChanged, getAnalysesByVersionByDay, Query } from '../utils'; import ProjectActivityAnalysis from './ProjectActivityAnalysis'; interface Props { addCustomEvent: (analysis: string, name: string, category?: string) => Promise<void>; addVersion: (analysis: string, version: string) => Promise<void>; - analyses: T.ParsedAnalysis[]; + analyses: ParsedAnalysis[]; analysesLoading: boolean; canAdmin?: boolean; canDeleteAnalyses?: boolean; @@ -127,11 +128,11 @@ export default class ProjectActivityAnalysesList extends React.PureComponent<Pro this.props.updateQuery({ selectedDate: date }); }; - shouldRenderBaselineMarker(analysis: T.ParsedAnalysis): boolean { + shouldRenderBaselineMarker(analysis: ParsedAnalysis): boolean { return Boolean(this.props.leakPeriodDate && isEqual(this.props.leakPeriodDate, analysis.date)); } - renderAnalysis(analysis: T.ParsedAnalysis) { + renderAnalysis(analysis: ParsedAnalysis) { const firstAnalysisKey = this.props.analyses[0].key; const selectedDate = this.props.query.selectedDate diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.tsx index 9c8b6df8e11..5d6a5f36c9d 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.tsx @@ -30,6 +30,7 @@ import { PopupPlacement } from '../../../components/ui/popups'; import { parseDate } from '../../../helpers/dates'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { scrollToElement } from '../../../helpers/scrolling'; +import { ParsedAnalysis } from '../../../types/types'; import Events from './Events'; import AddEventForm from './forms/AddEventForm'; import RemoveAnalysisForm from './forms/RemoveAnalysisForm'; @@ -37,7 +38,7 @@ import RemoveAnalysisForm from './forms/RemoveAnalysisForm'; export interface ProjectActivityAnalysisProps { addCustomEvent: (analysis: string, name: string, category?: string) => Promise<void>; addVersion: (analysis: string, version: string) => Promise<void>; - analysis: T.ParsedAnalysis; + analysis: ParsedAnalysis; canAdmin?: boolean; canDeleteAnalyses?: boolean; canCreateVersion: boolean; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx index b119bcbd6c6..5d7695f87bb 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx @@ -24,6 +24,7 @@ import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import { parseDate } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; import { MeasureHistory } from '../../../types/project-activity'; +import { Component, Metric, ParsedAnalysis } from '../../../types/types'; import { Query } from '../utils'; import './projectActivity.css'; import ProjectActivityAnalysesList from './ProjectActivityAnalysesList'; @@ -33,15 +34,15 @@ import ProjectActivityPageHeader from './ProjectActivityPageHeader'; interface Props { addCustomEvent: (analysis: string, name: string, category?: string) => Promise<void>; addVersion: (analysis: string, version: string) => Promise<void>; - analyses: T.ParsedAnalysis[]; + analyses: ParsedAnalysis[]; analysesLoading: boolean; changeEvent: (event: string, name: string) => Promise<void>; deleteAnalysis: (analysis: string) => Promise<void>; deleteEvent: (analysis: string, event: string) => Promise<void>; graphLoading: boolean; initializing: boolean; - project: Pick<T.Component, 'configuration' | 'key' | 'leakPeriodDate' | 'qualifier'>; - metrics: T.Metric[]; + project: Pick<Component, 'configuration' | 'key' | 'leakPeriodDate' | 'qualifier'>; + metrics: Metric[]; measuresHistory: MeasureHistory[]; query: Query; updateQuery: (changes: Partial<Query>) => void; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx index ce321125b04..7f033af879c 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx @@ -34,6 +34,7 @@ import { parseDate } from '../../../helpers/dates'; import { BranchLike } from '../../../types/branch-like'; import { MetricKey } from '../../../types/metrics'; import { GraphType, MeasureHistory } from '../../../types/project-activity'; +import { Component, Metric, Paging, ParsedAnalysis, RawQuery } from '../../../types/types'; import * as actions from '../actions'; import { customMetricsChanged, @@ -46,17 +47,17 @@ import ProjectActivityApp from './ProjectActivityApp'; interface Props { branchLike?: BranchLike; - component: T.Component; + component: Component; location: Location; router: Pick<InjectedRouter, 'push' | 'replace'>; } export interface State { - analyses: T.ParsedAnalysis[]; + analyses: ParsedAnalysis[]; analysesLoading: boolean; graphLoading: boolean; initialized: boolean; - metrics: T.Metric[]; + metrics: Metric[]; measuresHistory: MeasureHistory[]; query: Query; } @@ -160,7 +161,7 @@ export default class ProjectActivityAppContainer extends React.PureComponent<Pro }); }; - fetchActivity = (project: string, p: number, ps: number, additional?: T.RawQuery) => { + fetchActivity = (project: string, p: number, ps: number, additional?: RawQuery) => { const parameters = { project, p, ps, ...getBranchLikeQuery(this.props.branchLike) }; return api .getProjectActivity({ ...additional, ...parameters }) @@ -168,7 +169,7 @@ export default class ProjectActivityAppContainer extends React.PureComponent<Pro analyses: analyses.map(analysis => ({ ...analysis, date: parseDate(analysis.date) - })) as T.ParsedAnalysis[], + })) as ParsedAnalysis[], paging })); }; @@ -213,8 +214,8 @@ export default class ProjectActivityAppContainer extends React.PureComponent<Pro loadAllActivities = ( project: string, - prevResult?: { analyses: T.ParsedAnalysis[]; paging: T.Paging } - ): Promise<{ analyses: T.ParsedAnalysis[]; paging: T.Paging }> => { + prevResult?: { analyses: ParsedAnalysis[]; paging: Paging } + ): Promise<{ analyses: ParsedAnalysis[]; paging: Paging }> => { if ( prevResult && prevResult.paging.pageIndex * prevResult.paging.pageSize >= prevResult.paging.total @@ -233,7 +234,7 @@ export default class ProjectActivityAppContainer extends React.PureComponent<Pro }); }; - getTopLevelComponent = (component: T.Component) => { + getTopLevelComponent = (component: Component) => { let current = component.breadcrumbs.length - 1; while ( current > 0 && @@ -244,13 +245,13 @@ export default class ProjectActivityAppContainer extends React.PureComponent<Pro return component.breadcrumbs[current].key; }; - filterMetrics({ qualifier }: T.Component, metrics: T.Metric[]) { + filterMetrics({ qualifier }: Component, metrics: Metric[]) { return ['VW', 'SVW'].includes(qualifier) ? metrics.filter(metric => metric.key !== MetricKey.security_hotspots_reviewed) : metrics.filter(metric => metric.key !== MetricKey.security_review_rating); } - firstLoadData(query: Query, component: T.Component) { + firstLoadData(query: Query, component: Component) { const graphMetrics = getHistoryMetrics(query.graph || DEFAULT_GRAPH, query.customMetrics); const topLevelComponent = this.getTopLevelComponent(component); Promise.all([ diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx index aec1139cf01..7aeb04fe0a9 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx @@ -32,15 +32,16 @@ import { splitSeriesInGraphs } from '../../../components/activity-graph/utils'; import { GraphType, MeasureHistory, Point, Serie } from '../../../types/project-activity'; +import { Metric, ParsedAnalysis } from '../../../types/types'; import { datesQueryChanged, historyQueryChanged, Query } from '../utils'; import { PROJECT_ACTIVITY_GRAPH } from './ProjectActivityAppContainer'; interface Props { - analyses: T.ParsedAnalysis[]; + analyses: ParsedAnalysis[]; leakPeriodDate?: Date; loading: boolean; measuresHistory: MeasureHistory[]; - metrics: T.Metric[]; + metrics: Metric[]; project: string; query: Query; updateQuery: (changes: Partial<Query>) => void; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.tsx index 0bccf88b719..85bbdc6e657 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.tsx @@ -19,11 +19,12 @@ */ import * as React from 'react'; import ListFooter from '../../../components/controls/ListFooter'; +import { Paging } from '../../../types/types'; interface Props { analyses: unknown[]; fetchMoreActivity: () => void; - paging?: T.Paging; + paging?: Paging; } export default function ProjectActivityPageFooter({ analyses, fetchMoreActivity, paging }: Props) { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx index fe17c39eb29..1cc93b7e0f7 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx @@ -21,6 +21,7 @@ import classNames from 'classnames'; import * as React from 'react'; import SelectLegacy from '../../../components/controls/SelectLegacy'; import { translate } from '../../../helpers/l10n'; +import { Component } from '../../../types/types'; import { APPLICATION_EVENT_TYPES, EVENT_TYPES, Query } from '../utils'; import ProjectActivityDateInput from './ProjectActivityDateInput'; import ProjectActivityEventSelectOption from './ProjectActivityEventSelectOption'; @@ -28,7 +29,7 @@ import ProjectActivityEventSelectOption from './ProjectActivityEventSelectOption interface Props { category?: string; from?: Date; - project: Pick<T.Component, 'qualifier'>; + project: Pick<Component, 'qualifier'>; to?: Date; updateQuery: (changes: Partial<Query>) => void; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/RichQualityGateEventInner.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/RichQualityGateEventInner.tsx index 253dfc700f1..1991885adce 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/RichQualityGateEventInner.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/RichQualityGateEventInner.tsx @@ -25,10 +25,11 @@ import DropdownIcon from '../../../components/icons/DropdownIcon'; import Level from '../../../components/ui/Level'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getProjectUrl } from '../../../helpers/urls'; +import { AnalysisEvent } from '../../../types/types'; -export type RichQualityGateEvent = T.AnalysisEvent & Required<Pick<T.AnalysisEvent, 'qualityGate'>>; +export type RichQualityGateEvent = AnalysisEvent & Required<Pick<AnalysisEvent, 'qualityGate'>>; -export function isRichQualityGateEvent(event: T.AnalysisEvent): event is RichQualityGateEvent { +export function isRichQualityGateEvent(event: AnalysisEvent): event is RichQualityGateEvent { return event.category === 'QUALITY_GATE' && event.qualityGate !== undefined; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.tsx index 715b9c53e48..0d33785909e 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddEventForm.tsx @@ -20,11 +20,12 @@ import * as React from 'react'; import ConfirmModal from '../../../../components/controls/ConfirmModal'; import { translate } from '../../../../helpers/l10n'; +import { ParsedAnalysis } from '../../../../types/types'; interface Props { addEvent: (analysis: string, name: string, category?: string) => Promise<void>; addEventButtonText: string; - analysis: T.ParsedAnalysis; + analysis: ParsedAnalysis; onClose: () => void; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.tsx index e21cb74372d..adfcca6e019 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.tsx @@ -20,10 +20,11 @@ import * as React from 'react'; import ConfirmModal from '../../../../components/controls/ConfirmModal'; import { translate } from '../../../../helpers/l10n'; +import { AnalysisEvent } from '../../../../types/types'; interface Props { changeEvent: (event: string, name: string) => Promise<void>; - event: T.AnalysisEvent; + event: AnalysisEvent; header: string; onClose: () => void; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.tsx index ddb2a25ba8b..4cbfa8ec157 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveAnalysisForm.tsx @@ -20,9 +20,10 @@ import * as React from 'react'; import ConfirmModal from '../../../../components/controls/ConfirmModal'; import { translate } from '../../../../helpers/l10n'; +import { ParsedAnalysis } from '../../../../types/types'; interface Props { - analysis: T.ParsedAnalysis; + analysis: ParsedAnalysis; deleteAnalysis: (analysis: string) => Promise<void>; onClose: () => void; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.tsx index 3934f697e27..69ede5e897d 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.tsx @@ -20,10 +20,11 @@ import * as React from 'react'; import ConfirmModal from '../../../../components/controls/ConfirmModal'; import { translate } from '../../../../helpers/l10n'; +import { AnalysisEvent } from '../../../../types/types'; export interface RemoveEventFormProps { analysisKey: string; - event: T.AnalysisEvent; + event: AnalysisEvent; header: string; removeEventQuestion: string; onClose: () => void; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/utils.ts b/server/sonar-web/src/main/js/apps/projectActivity/utils.ts index 86dae218145..e8fceb3327e 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/utils.ts +++ b/server/sonar-web/src/main/js/apps/projectActivity/utils.ts @@ -31,6 +31,7 @@ import { serializeStringArray } from '../../helpers/query'; import { GraphType } from '../../types/project-activity'; +import { Dict, ParsedAnalysis, RawQuery } from '../../types/types'; export interface Query { category: string; @@ -66,13 +67,13 @@ export function selectedDateQueryChanged(prevQuery: Query, nextQuery: Query) { } interface AnalysesByDay { - byDay: T.Dict<T.ParsedAnalysis[]>; + byDay: Dict<ParsedAnalysis[]>; version: string | null; key: string | null; } export function getAnalysesByVersionByDay( - analyses: T.ParsedAnalysis[], + analyses: ParsedAnalysis[], query: Pick<Query, 'category' | 'from' | 'to'> ) { return analyses.reduce<AnalysesByDay[]>((acc, analysis) => { @@ -115,7 +116,7 @@ export function getAnalysesByVersionByDay( }, []); } -export function parseQuery(urlQuery: T.RawQuery): Query { +export function parseQuery(urlQuery: RawQuery): Query { return { category: parseAsString(urlQuery['category']), customMetrics: parseAsArray(urlQuery['custom_metrics'], parseAsString), @@ -127,7 +128,7 @@ export function parseQuery(urlQuery: T.RawQuery): Query { }; } -export function serializeQuery(query: Query): T.RawQuery { +export function serializeQuery(query: Query): RawQuery { return cleanQuery({ category: serializeString(query.category), from: serializeDate(query.from), @@ -136,7 +137,7 @@ export function serializeQuery(query: Query): T.RawQuery { }); } -export function serializeUrlQuery(query: Query): T.RawQuery { +export function serializeUrlQuery(query: Query): RawQuery { return cleanQuery({ category: serializeString(query.category), custom_metrics: serializeStringArray(query.customMetrics), diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx index 3a751aecc1f..4f957e4b686 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/App.tsx @@ -27,6 +27,12 @@ import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { isBranch, sortBranches } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { Branch, BranchLike } from '../../../types/branch-like'; +import { + Component, + NewCodePeriod, + NewCodePeriodSettingType, + ParsedAnalysis +} from '../../../types/types'; import '../styles.css'; import { getSettingValue } from '../utils'; import AppHeader from './AppHeader'; @@ -38,27 +44,27 @@ interface Props { branchLikes: BranchLike[]; branchesEnabled?: boolean; canAdmin?: boolean; - component: T.Component; + component: Component; } interface State { analysis?: string; branchList: Branch[]; - currentSetting?: T.NewCodePeriodSettingType; + currentSetting?: NewCodePeriodSettingType; currentSettingValue?: string; days: string; - generalSetting?: T.NewCodePeriod; + generalSetting?: NewCodePeriod; loading: boolean; overrideGeneralSetting?: boolean; referenceBranch?: string; saving: boolean; - selected?: T.NewCodePeriodSettingType; + selected?: NewCodePeriodSettingType; success?: boolean; } const DEFAULT_NUMBER_OF_DAYS = '30'; -const DEFAULT_GENERAL_SETTING: { type: T.NewCodePeriodSettingType } = { +const DEFAULT_GENERAL_SETTING: { type: NewCodePeriodSettingType } = { type: 'PREVIOUS_VERSION' }; @@ -91,9 +97,9 @@ export default class App extends React.PureComponent<Props, State> { } getUpdatedState(params: { - currentSetting?: T.NewCodePeriodSettingType; + currentSetting?: NewCodePeriodSettingType; currentSettingValue?: string; - generalSetting: T.NewCodePeriod; + generalSetting: NewCodePeriod; }) { const { currentSetting, currentSettingValue, generalSetting } = params; const { referenceBranch } = this.state; @@ -173,7 +179,7 @@ export default class App extends React.PureComponent<Props, State> { ); }; - handleSelectAnalysis = (analysis: T.ParsedAnalysis) => this.setState({ analysis: analysis.key }); + handleSelectAnalysis = (analysis: ParsedAnalysis) => this.setState({ analysis: analysis.key }); handleSelectDays = (days: string) => this.setState({ days }); @@ -187,7 +193,7 @@ export default class App extends React.PureComponent<Props, State> { this.getUpdatedState({ generalSetting, currentSetting, currentSettingValue }) ); - handleSelectSetting = (selected?: T.NewCodePeriodSettingType) => this.setState({ selected }); + handleSelectSetting = (selected?: NewCodePeriodSettingType) => this.setState({ selected }); handleToggleSpecificSetting = (overrideGeneralSetting: boolean) => this.setState({ overrideGeneralSetting }); diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingAnalysis.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingAnalysis.tsx index 0dd4a639f45..cba5518a9f4 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingAnalysis.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingAnalysis.tsx @@ -20,10 +20,11 @@ import * as React from 'react'; import RadioCard from '../../../components/controls/RadioCard'; import { translate } from '../../../helpers/l10n'; +import { NewCodePeriodSettingType } from '../../../types/types'; export interface Props { disabled?: boolean; - onSelect: (selection: T.NewCodePeriodSettingType) => void; + onSelect: (selection: NewCodePeriodSettingType) => void; selected: boolean; } diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingDays.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingDays.tsx index a0f88c0fc16..d555d6338e8 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingDays.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingDays.tsx @@ -22,6 +22,7 @@ import RadioCard from '../../../components/controls/RadioCard'; import ValidationInput from '../../../components/controls/ValidationInput'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../../helpers/l10n'; +import { NewCodePeriodSettingType } from '../../../types/types'; export interface Props { className?: string; @@ -30,7 +31,7 @@ export interface Props { isChanged: boolean; isValid: boolean; onChangeDays: (value: string) => void; - onSelect: (selection: T.NewCodePeriodSettingType) => void; + onSelect: (selection: NewCodePeriodSettingType) => void; selected: boolean; } diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingPreviousVersion.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingPreviousVersion.tsx index 9a24385d5ee..2b1ee54ad8d 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingPreviousVersion.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingPreviousVersion.tsx @@ -20,11 +20,12 @@ import * as React from 'react'; import RadioCard from '../../../components/controls/RadioCard'; import { translate } from '../../../helpers/l10n'; +import { NewCodePeriodSettingType } from '../../../types/types'; export interface Props { disabled?: boolean; isDefault?: boolean; - onSelect: (selection: T.NewCodePeriodSettingType) => void; + onSelect: (selection: NewCodePeriodSettingType) => void; selected: boolean; } diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingReferenceBranch.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingReferenceBranch.tsx index 9e932cd4996..e31c3caf12d 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingReferenceBranch.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingReferenceBranch.tsx @@ -25,6 +25,7 @@ import AlertErrorIcon from '../../../components/icons/AlertErrorIcon'; import MandatoryFieldMarker from '../../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { NewCodePeriodSettingType } from '../../../types/types'; export interface BaselineSettingReferenceBranchProps { branchList: BranchOption[]; @@ -32,7 +33,7 @@ export interface BaselineSettingReferenceBranchProps { configuredBranchName?: string; disabled?: boolean; onChangeReferenceBranch: (value: string) => void; - onSelect: (selection: T.NewCodePeriodSettingType) => void; + onSelect: (selection: NewCodePeriodSettingType) => void; referenceBranch: string; selected: boolean; settingLevel: 'project' | 'branch'; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisList.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisList.tsx index dcf12cd846b..8ae05b89402 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisList.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisList.tsx @@ -23,17 +23,18 @@ import * as React from 'react'; import { getProjectActivity } from '../../../api/projectActivity'; import { parseDate, toShortNotSoISOString } from '../../../helpers/dates'; import { scrollToElement } from '../../../helpers/scrolling'; +import { Analysis, Dict, ParsedAnalysis } from '../../../types/types'; import BranchAnalysisListRenderer from './BranchAnalysisListRenderer'; interface Props { analysis: string; branch: string; component: string; - onSelectAnalysis: (analysis: T.ParsedAnalysis) => void; + onSelectAnalysis: (analysis: ParsedAnalysis) => void; } interface State { - analyses: T.ParsedAnalysis[]; + analyses: ParsedAnalysis[]; loading: boolean; range: number; scroll: number; @@ -43,7 +44,7 @@ const STICKY_BADGE_SCROLL_OFFSET = 10; export default class BranchAnalysisList extends React.PureComponent<Props, State> { mounted = false; - badges: T.Dict<HTMLDivElement> = {}; + badges: Dict<HTMLDivElement> = {}; scrollableNode?: HTMLDivElement; state: State = { analyses: [], @@ -82,7 +83,7 @@ export default class BranchAnalysisList extends React.PureComponent<Props, State branch, project: component, from: range ? toShortNotSoISOString(subDays(new Date(), range)) : undefined - }).then((result: { analyses: T.Analysis[] }) => { + }).then((result: { analyses: Analysis[] }) => { // If the selected analysis wasn't found in the default 30 days range, redo the search if (initial && analysis && !result.analyses.find(a => a.key === analysis)) { this.handleRangeChange({ value: 0 }); @@ -94,7 +95,7 @@ export default class BranchAnalysisList extends React.PureComponent<Props, State analyses: result.analyses.map(analysis => ({ ...analysis, date: parseDate(analysis.date) - })) as T.ParsedAnalysis[], + })) as ParsedAnalysis[], loading: false }, () => { diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisListRenderer.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisListRenderer.tsx index 7ebb4cf9fc8..c81b95fa6be 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisListRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisListRenderer.tsx @@ -27,15 +27,16 @@ import TimeFormatter from '../../../components/intl/TimeFormatter'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { parseDate, toShortNotSoISOString } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; +import { ParsedAnalysis } from '../../../types/types'; import Events from '../../projectActivity/components/Events'; import { getAnalysesByVersionByDay } from '../../projectActivity/utils'; export interface BranchAnalysisListRendererProps { - analyses: T.ParsedAnalysis[]; + analyses: ParsedAnalysis[]; handleRangeChange: ({ value }: { value: number }) => void; handleScroll: (e: React.SyntheticEvent<HTMLDivElement>) => void; loading: boolean; - onSelectAnalysis: (analysis: T.ParsedAnalysis) => void; + onSelectAnalysis: (analysis: ParsedAnalysis) => void; range: number; registerBadgeNode: (version: string) => (el: HTMLDivElement) => void; registerScrollableNode: (el: HTMLDivElement) => void; @@ -44,9 +45,9 @@ export interface BranchAnalysisListRendererProps { } function renderAnalysis(args: { - analysis: T.ParsedAnalysis; + analysis: ParsedAnalysis; isFirst: boolean; - onSelectAnalysis: (analysis: T.ParsedAnalysis) => void; + onSelectAnalysis: (analysis: ParsedAnalysis) => void; selectedAnalysisKey: string; }) { const { analysis, isFirst, onSelectAnalysis, selectedAnalysisKey } = args; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchBaselineSettingModal.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchBaselineSettingModal.tsx index 2fb28321fe1..37629eeb5c3 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchBaselineSettingModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchBaselineSettingModal.tsx @@ -25,6 +25,7 @@ import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { toNotSoISOString } from '../../../helpers/dates'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { Branch, BranchWithNewCodePeriod } from '../../../types/branch-like'; +import { NewCodePeriod, NewCodePeriodSettingType, ParsedAnalysis } from '../../../types/types'; import { getSettingValue, validateSetting } from '../utils'; import BaselineSettingAnalysis from './BaselineSettingAnalysis'; import BaselineSettingDays from './BaselineSettingDays'; @@ -36,7 +37,7 @@ interface Props { branch: BranchWithNewCodePeriod; branchList: Branch[]; component: string; - onClose: (branch?: string, newSetting?: T.NewCodePeriod) => void; + onClose: (branch?: string, newSetting?: NewCodePeriod) => void; } interface State { @@ -45,7 +46,7 @@ interface State { days: string; referenceBranch: string; saving: boolean; - selected?: T.NewCodePeriodSettingType; + selected?: NewCodePeriodSettingType; } export default class BranchBaselineSettingModal extends React.PureComponent<Props, State> { @@ -74,7 +75,7 @@ export default class BranchBaselineSettingModal extends React.PureComponent<Prop this.mounted = false; } - getValueFromProps(type: T.NewCodePeriodSettingType) { + getValueFromProps(type: NewCodePeriodSettingType) { return this.props.branch.newCodePeriod && this.props.branch.newCodePeriod.type === type ? this.props.branch.newCodePeriod.value : null; @@ -123,14 +124,14 @@ export default class BranchBaselineSettingModal extends React.PureComponent<Prop requestClose = () => this.props.onClose(); - handleSelectAnalysis = (analysis: T.ParsedAnalysis) => + handleSelectAnalysis = (analysis: ParsedAnalysis) => this.setState({ analysis: analysis.key, analysisDate: analysis.date }); handleSelectDays = (days: string) => this.setState({ days }); handleSelectReferenceBranch = (referenceBranch: string) => this.setState({ referenceBranch }); - handleSelectSetting = (selected: T.NewCodePeriodSettingType) => this.setState({ selected }); + handleSelectSetting = (selected: NewCodePeriodSettingType) => this.setState({ selected }); render() { const { branch, branchList } = this.props; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchList.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchList.tsx index f91052b6517..201152ddd38 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchList.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchList.tsx @@ -23,13 +23,14 @@ import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { isBranch, sortBranches } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { Branch, BranchLike, BranchWithNewCodePeriod } from '../../../types/branch-like'; +import { Component, NewCodePeriod } from '../../../types/types'; import BranchBaselineSettingModal from './BranchBaselineSettingModal'; import BranchListRow from './BranchListRow'; interface Props { branchList: Branch[]; - component: T.Component; - inheritedSetting: T.NewCodePeriod; + component: Component; + inheritedSetting: NewCodePeriod; } interface State { @@ -88,7 +89,7 @@ export default class BranchList extends React.PureComponent<Props, State> { ); } - updateBranchNewCodePeriod = (branch: string, newSetting: T.NewCodePeriod | undefined) => { + updateBranchNewCodePeriod = (branch: string, newSetting: NewCodePeriod | undefined) => { const { branches } = this.state; const updated = branches.find(b => b.name === branch); @@ -102,7 +103,7 @@ export default class BranchList extends React.PureComponent<Props, State> { this.setState({ editedBranch: branch }); }; - closeEditModal = (branch?: string, newSetting?: T.NewCodePeriod) => { + closeEditModal = (branch?: string, newSetting?: NewCodePeriod) => { if (branch) { this.setState({ branches: this.updateBranchNewCodePeriod(branch, newSetting), diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchListRow.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchListRow.tsx index 0b45d2f1c48..0cb9e14f733 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchListRow.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchListRow.tsx @@ -25,16 +25,17 @@ import WarningIcon from '../../../components/icons/WarningIcon'; import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { BranchWithNewCodePeriod } from '../../../types/branch-like'; +import { NewCodePeriod } from '../../../types/types'; export interface BranchListRowProps { branch: BranchWithNewCodePeriod; existingBranches: Array<string>; - inheritedSetting: T.NewCodePeriod; + inheritedSetting: NewCodePeriod; onOpenEditModal: (branch: BranchWithNewCodePeriod) => void; onResetToDefault: (branchName: string) => void; } -function renderNewCodePeriodSetting(newCodePeriod: T.NewCodePeriod) { +function renderNewCodePeriodSetting(newCodePeriod: NewCodePeriod) { switch (newCodePeriod.type) { case 'SPECIFIC_ANALYSIS': return ( @@ -60,7 +61,7 @@ function renderNewCodePeriodSetting(newCodePeriod: T.NewCodePeriod) { function branchInheritsItselfAsReference( branch: BranchWithNewCodePeriod, - inheritedSetting: T.NewCodePeriod + inheritedSetting: NewCodePeriod ) { return ( !branch.newCodePeriod && diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx index c001b46f4c1..fdf84f077fa 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx @@ -25,6 +25,7 @@ import { Alert } from '../../../components/ui/Alert'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { Branch } from '../../../types/branch-like'; +import { NewCodePeriod, NewCodePeriodSettingType, ParsedAnalysis } from '../../../types/types'; import { validateSetting } from '../utils'; import BaselineSettingAnalysis from './BaselineSettingAnalysis'; import BaselineSettingDays from './BaselineSettingDays'; @@ -38,24 +39,24 @@ export interface ProjectBaselineSelectorProps { branchList: Branch[]; branchesEnabled?: boolean; component: string; - currentSetting?: T.NewCodePeriodSettingType; + currentSetting?: NewCodePeriodSettingType; currentSettingValue?: string; days: string; - generalSetting: T.NewCodePeriod; + generalSetting: NewCodePeriod; onCancel: () => void; - onSelectAnalysis: (analysis: T.ParsedAnalysis) => void; + onSelectAnalysis: (analysis: ParsedAnalysis) => void; onSelectDays: (value: string) => void; onSelectReferenceBranch: (value: string) => void; - onSelectSetting: (value?: T.NewCodePeriodSettingType) => void; + onSelectSetting: (value?: NewCodePeriodSettingType) => void; onSubmit: (e: React.SyntheticEvent<HTMLFormElement>) => void; onToggleSpecificSetting: (selection: boolean) => void; referenceBranch?: string; saving: boolean; - selected?: T.NewCodePeriodSettingType; + selected?: NewCodePeriodSettingType; overrideGeneralSetting: boolean; } -function renderGeneralSetting(generalSetting: T.NewCodePeriod) { +function renderGeneralSetting(generalSetting: NewCodePeriod) { let setting: string; let description: string; if (generalSetting.type === 'NUMBER_OF_DAYS') { diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/utils.ts b/server/sonar-web/src/main/js/apps/projectBaseline/utils.ts index 3828c93cf5c..358d7dae269 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/utils.ts +++ b/server/sonar-web/src/main/js/apps/projectBaseline/utils.ts @@ -1,3 +1,5 @@ +import { NewCodePeriodSettingType } from '../../types/types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -32,7 +34,7 @@ export function getSettingValue({ analysis?: string; days?: string; referenceBranch?: string; - type?: T.NewCodePeriodSettingType; + type?: NewCodePeriodSettingType; }) { switch (type) { case 'NUMBER_OF_DAYS': @@ -48,12 +50,12 @@ export function getSettingValue({ export function validateSetting(state: { analysis?: string; - currentSetting?: T.NewCodePeriodSettingType; + currentSetting?: NewCodePeriodSettingType; currentSettingValue?: string; days: string; overrideGeneralSetting?: boolean; referenceBranch?: string; - selected?: T.NewCodePeriodSettingType; + selected?: NewCodePeriodSettingType; }) { const { analysis = '', diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx index 072a6c557ee..b714be89593 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx @@ -20,12 +20,13 @@ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; +import { Component } from '../../../types/types'; import BranchLikeTabs from './BranchLikeTabs'; import LifetimeInformation from './LifetimeInformation'; export interface AppProps { branchLikes: BranchLike[]; - component: T.Component; + component: Component; onBranchesChange: () => void; } diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx index ba2402fc380..b0d958fb32f 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeRow.tsx @@ -30,11 +30,12 @@ import { } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; +import { Component } from '../../../types/types'; import BranchPurgeSetting from './BranchPurgeSetting'; export interface BranchLikeRowProps { branchLike: BranchLike; - component: T.Component; + component: Component; displayPurgeSetting?: boolean; onDelete: () => void; onRename: () => void; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx index 746a7edec53..1eedf684334 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTable.tsx @@ -22,11 +22,12 @@ import HelpTooltip from '../../../components/controls/HelpTooltip'; import { getBranchLikeKey } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; +import { Component } from '../../../types/types'; import BranchLikeRow from './BranchLikeRow'; export interface BranchLikeTableProps { branchLikes: BranchLike[]; - component: T.Component; + component: Component; displayPurgeSetting?: boolean; onDelete: (branchLike: BranchLike) => void; onRename: (branchLike: BranchLike) => void; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx index d4707949acb..ee70a0185c5 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchLikeTabs.tsx @@ -30,13 +30,14 @@ import { } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; +import { Component } from '../../../types/types'; import BranchLikeTable from './BranchLikeTable'; import DeleteBranchModal from './DeleteBranchModal'; import RenameBranchModal from './RenameBranchModal'; interface Props { branchLikes: BranchLike[]; - component: T.Component; + component: Component; onBranchesChange: () => void; } diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx index ea204c09cd5..63d510fe7b0 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx @@ -25,10 +25,11 @@ import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { isMainBranch } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { Branch } from '../../../types/branch-like'; +import { Component } from '../../../types/types'; interface Props { branch: Branch; - component: T.Component; + component: Component; } interface State { diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx index 79180d0edce..403befd3e7f 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx @@ -24,10 +24,11 @@ import Modal from '../../../components/controls/Modal'; import { getBranchLikeDisplayName, isPullRequest } from '../../../helpers/branch-like'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; +import { Component } from '../../../types/types'; interface Props { branchLike: BranchLike; - component: T.Component; + component: Component; onClose: () => void; onDelete: () => void; } diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx index 5b0403f627f..31059f77e7a 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx @@ -25,10 +25,11 @@ import MandatoryFieldMarker from '../../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../../helpers/l10n'; import { MainBranch } from '../../../types/branch-like'; +import { Component } from '../../../types/types'; interface Props { branch: MainBranch; - component: T.Component; + component: Component; onClose: () => void; onRename: () => void; } diff --git a/server/sonar-web/src/main/js/apps/projectDeletion/App.tsx b/server/sonar-web/src/main/js/apps/projectDeletion/App.tsx index 9fd50d11b03..fecc91be0c1 100644 --- a/server/sonar-web/src/main/js/apps/projectDeletion/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectDeletion/App.tsx @@ -20,11 +20,12 @@ import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { translate } from '../../helpers/l10n'; +import { Component } from '../../types/types'; import Form from './Form'; import Header from './Header'; interface Props { - component: Pick<T.Component, 'key' | 'name' | 'qualifier'>; + component: Pick<Component, 'key' | 'name' | 'qualifier'>; } export default function App(props: Props) { diff --git a/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx b/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx index 8c97d9d87e3..2a3680c7a18 100644 --- a/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx +++ b/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx @@ -26,9 +26,10 @@ import ConfirmButton from '../../components/controls/ConfirmButton'; import { Router, withRouter } from '../../components/hoc/withRouter'; import { translate, translateWithParameters } from '../../helpers/l10n'; import { isApplication, isPortfolioLike } from '../../types/component'; +import { Component } from '../../types/types'; interface Props { - component: Pick<T.Component, 'key' | 'name' | 'qualifier'>; + component: Pick<Component, 'key' | 'name' | 'qualifier'>; router: Pick<Router, 'replace'>; } diff --git a/server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx b/server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx index a20e57b22ff..3db2b1798a9 100644 --- a/server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx +++ b/server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx @@ -19,9 +19,10 @@ */ import * as React from 'react'; import { translate } from '../../helpers/l10n'; +import { Component } from '../../types/types'; interface Props { - component: Pick<T.Component, 'qualifier'>; + component: Pick<Component, 'qualifier'>; } export default function Header(props: Props) { diff --git a/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx b/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx index 8414da52c12..20666cb9192 100644 --- a/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx @@ -25,6 +25,7 @@ import { withAppState } from '../../components/hoc/withAppState'; import { translate } from '../../helpers/l10n'; import { DumpStatus, DumpTask } from '../../types/project-dump'; import { TaskStatuses, TaskTypes } from '../../types/tasks'; +import { AppState, Component } from '../../types/types'; import Export from './components/Export'; import Import from './components/Import'; import './styles.css'; @@ -32,8 +33,8 @@ import './styles.css'; const POLL_INTERNAL = 5000; interface Props { - appState: Pick<T.AppState, 'projectImportFeatureEnabled'>; - component: T.Component; + appState: Pick<AppState, 'projectImportFeatureEnabled'>; + component: Component; } interface State { diff --git a/server/sonar-web/src/main/js/apps/projectKey/Key.tsx b/server/sonar-web/src/main/js/apps/projectKey/Key.tsx index df70da33abb..0b146dbd23a 100644 --- a/server/sonar-web/src/main/js/apps/projectKey/Key.tsx +++ b/server/sonar-web/src/main/js/apps/projectKey/Key.tsx @@ -23,10 +23,11 @@ import { withRouter, WithRouterProps } from 'react-router'; import { changeKey } from '../../api/components'; import RecentHistory from '../../app/components/RecentHistory'; import { translate } from '../../helpers/l10n'; +import { Component } from '../../types/types'; import UpdateForm from './UpdateForm'; interface Props { - component: Pick<T.Component, 'key' | 'name'>; + component: Pick<Component, 'key' | 'name'>; } export class Key extends React.PureComponent<Props & WithRouterProps> { diff --git a/server/sonar-web/src/main/js/apps/projectKey/UpdateForm.tsx b/server/sonar-web/src/main/js/apps/projectKey/UpdateForm.tsx index 1cb39eb737b..2f66aa36d45 100644 --- a/server/sonar-web/src/main/js/apps/projectKey/UpdateForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectKey/UpdateForm.tsx @@ -25,9 +25,10 @@ import MandatoryFieldsExplanation from '../../components/ui/MandatoryFieldsExpla import { translate, translateWithParameters } from '../../helpers/l10n'; import { validateProjectKey } from '../../helpers/projects'; import { ProjectKeyValidationResult } from '../../types/component'; +import { Component } from '../../types/types'; export interface UpdateFormProps { - component: Pick<T.Component, 'key' | 'name'>; + component: Pick<Component, 'key' | 'name'>; onKeyChange: (newKey: string) => Promise<void>; } diff --git a/server/sonar-web/src/main/js/apps/projectLinks/App.tsx b/server/sonar-web/src/main/js/apps/projectLinks/App.tsx index 82cc8f6c8a1..d494e1540d2 100644 --- a/server/sonar-web/src/main/js/apps/projectLinks/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectLinks/App.tsx @@ -22,15 +22,16 @@ import { Helmet } from 'react-helmet-async'; import { createLink, deleteLink, getProjectLinks } from '../../api/projectLinks'; import DeferredSpinner from '../../components/ui/DeferredSpinner'; import { translate } from '../../helpers/l10n'; +import { Component, ProjectLink } from '../../types/types'; import Header from './Header'; import Table from './Table'; interface Props { - component: Pick<T.Component, 'key'>; + component: Pick<Component, 'key'>; } interface State { - links?: T.ProjectLink[]; + links?: ProjectLink[]; loading: boolean; } diff --git a/server/sonar-web/src/main/js/apps/projectLinks/LinkRow.tsx b/server/sonar-web/src/main/js/apps/projectLinks/LinkRow.tsx index 955a2dffd26..4983ddbb4af 100644 --- a/server/sonar-web/src/main/js/apps/projectLinks/LinkRow.tsx +++ b/server/sonar-web/src/main/js/apps/projectLinks/LinkRow.tsx @@ -24,14 +24,15 @@ import ConfirmButton from '../../components/controls/ConfirmButton'; import ProjectLinkIcon from '../../components/icons/ProjectLinkIcon'; import { translate, translateWithParameters } from '../../helpers/l10n'; import { getLinkName, isProvided } from '../../helpers/projectLinks'; +import { ProjectLink } from '../../types/types'; interface Props { - link: T.ProjectLink; + link: ProjectLink; onDelete: (linkId: string) => Promise<void>; } export default class LinkRow extends React.PureComponent<Props> { - renderNameForProvided = (link: T.ProjectLink) => { + renderNameForProvided = (link: ProjectLink) => { return ( <div className="display-inline-block text-top"> <div> @@ -44,7 +45,7 @@ export default class LinkRow extends React.PureComponent<Props> { ); }; - renderName = (link: T.ProjectLink) => { + renderName = (link: ProjectLink) => { return ( <div> <ProjectLinkIcon className="little-spacer-right" type={link.type} /> @@ -59,7 +60,7 @@ export default class LinkRow extends React.PureComponent<Props> { ); }; - renderDeleteButton = (link: T.ProjectLink) => { + renderDeleteButton = (link: ProjectLink) => { if (isProvided(link)) { return null; } diff --git a/server/sonar-web/src/main/js/apps/projectLinks/Table.tsx b/server/sonar-web/src/main/js/apps/projectLinks/Table.tsx index 7d33bb5997c..0313d912599 100644 --- a/server/sonar-web/src/main/js/apps/projectLinks/Table.tsx +++ b/server/sonar-web/src/main/js/apps/projectLinks/Table.tsx @@ -20,10 +20,11 @@ import * as React from 'react'; import { translate } from '../../helpers/l10n'; import { orderLinks } from '../../helpers/projectLinks'; +import { ProjectLink } from '../../types/types'; import LinkRow from './LinkRow'; interface Props { - links: T.ProjectLink[]; + links: ProjectLink[]; onDelete: (linkId: string) => Promise<void>; } diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateApp.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateApp.tsx index 08468d1fb8e..5deabd5bfb5 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateApp.tsx @@ -29,17 +29,18 @@ import { import addGlobalSuccessMessage from '../../app/utils/addGlobalSuccessMessage'; import handleRequiredAuthorization from '../../app/utils/handleRequiredAuthorization'; import { translate } from '../../helpers/l10n'; +import { Component, QualityGate } from '../../types/types'; import { USE_SYSTEM_DEFAULT } from './constants'; import ProjectQualityGateAppRenderer from './ProjectQualityGateAppRenderer'; interface Props { - component: T.Component; + component: Component; onComponentChange: (changes: {}) => void; } interface State { - allQualityGates?: T.QualityGate[]; - currentQualityGate?: T.QualityGate; + allQualityGates?: QualityGate[]; + currentQualityGate?: QualityGate; loading: boolean; selectedQualityGateId: string; submitting: boolean; @@ -72,7 +73,7 @@ export default class ProjectQualityGateApp extends React.PureComponent<Props, St return !!hasPermission; }; - isUsingDefault = async (qualityGate: T.QualityGate) => { + isUsingDefault = async (qualityGate: QualityGate) => { const { component } = this.props; if (!qualityGate.isDefault) { diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateAppRenderer.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateAppRenderer.tsx index adc0763cbf5..012db878b07 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityGate/ProjectQualityGateAppRenderer.tsx @@ -31,12 +31,13 @@ import SelectLegacy from '../../components/controls/SelectLegacy'; import { Alert } from '../../components/ui/Alert'; import { translate } from '../../helpers/l10n'; import { isDiffMetric } from '../../helpers/measures'; +import { QualityGate } from '../../types/types'; import BuiltInQualityGateBadge from '../quality-gates/components/BuiltInQualityGateBadge'; import { USE_SYSTEM_DEFAULT } from './constants'; export interface ProjectQualityGateAppRendererProps { - allQualityGates?: T.QualityGate[]; - currentQualityGate?: T.QualityGate; + allQualityGates?: QualityGate[]; + currentQualityGate?: QualityGate; loading: boolean; onSelect: (id: string) => void; onSubmit: () => void; @@ -44,7 +45,7 @@ export interface ProjectQualityGateAppRendererProps { submitting: boolean; } -function hasConditionOnNewCode(qualityGate: T.QualityGate): boolean { +function hasConditionOnNewCode(qualityGate: QualityGate): boolean { return !!qualityGate.conditions?.some(condition => isDiffMetric(condition.metric)); } diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/ProjectQualityProfilesApp.tsx b/server/sonar-web/src/main/js/apps/projectQualityProfiles/ProjectQualityProfilesApp.tsx index 81b7af22f5d..06abdead367 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/ProjectQualityProfilesApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/ProjectQualityProfilesApp.tsx @@ -30,11 +30,12 @@ import addGlobalSuccessMessage from '../../app/utils/addGlobalSuccessMessage'; import handleRequiredAuthorization from '../../app/utils/handleRequiredAuthorization'; import { translateWithParameters } from '../../helpers/l10n'; import { isDefined } from '../../helpers/types'; +import { Component } from '../../types/types'; import ProjectQualityProfilesAppRenderer from './ProjectQualityProfilesAppRenderer'; import { ProjectProfile } from './types'; interface Props { - component: T.Component; + component: Component; } interface State { diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/ProjectQualityProfilesAppRenderer.tsx b/server/sonar-web/src/main/js/apps/projectQualityProfiles/ProjectQualityProfilesAppRenderer.tsx index 024ca06fab3..2a3f057c49f 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/ProjectQualityProfilesAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/ProjectQualityProfilesAppRenderer.tsx @@ -30,6 +30,7 @@ import EditIcon from '../../components/icons/EditIcon'; import PlusCircleIcon from '../../components/icons/PlusCircleIcon'; import { translate } from '../../helpers/l10n'; import { getRulesUrl } from '../../helpers/urls'; +import { Component } from '../../types/types'; import BuiltInQualityProfileBadge from '../quality-profiles/components/BuiltInQualityProfileBadge'; import AddLanguageModal from './components/AddLanguageModal'; import SetQualityProfileModal from './components/SetQualityProfileModal'; @@ -37,7 +38,7 @@ import { ProjectProfile } from './types'; export interface ProjectQualityProfilesAppRendererProps { allProfiles?: Profile[]; - component: T.Component; + component: Component; loading: boolean; onAddLanguage: (key: string) => Promise<void>; onCloseModal: () => void; diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/AddLanguageModal.tsx b/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/AddLanguageModal.tsx index c01da6619fb..58433a959ca 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/AddLanguageModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/AddLanguageModal.tsx @@ -29,12 +29,13 @@ import SimpleModal from '../../../components/controls/SimpleModal'; import { translate } from '../../../helpers/l10n'; import { getQualityProfileUrl } from '../../../helpers/urls'; import { Store } from '../../../store/rootReducer'; +import { Dict, Languages } from '../../../types/types'; export interface AddLanguageModalProps { - languages: T.Languages; + languages: Languages; onClose: () => void; onSubmit: (key: string) => Promise<void>; - profilesByLanguage: T.Dict<Profile[]>; + profilesByLanguage: Dict<Profile[]>; unavailableLanguages: string[]; } diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/SetQualityProfileModal.tsx b/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/SetQualityProfileModal.tsx index a8b021b014e..7d12696199e 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/SetQualityProfileModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/components/SetQualityProfileModal.tsx @@ -28,12 +28,13 @@ import SimpleModal from '../../../components/controls/SimpleModal'; import { Alert } from '../../../components/ui/Alert'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getQualityProfileUrl } from '../../../helpers/urls'; +import { Component } from '../../../types/types'; import BuiltInQualityProfileBadge from '../../quality-profiles/components/BuiltInQualityProfileBadge'; import { USE_SYSTEM_DEFAULT } from '../constants'; export interface SetQualityProfileModalProps { availableProfiles: Profile[]; - component: T.Component; + component: Component; currentProfile: Profile; onClose: () => void; onSubmit: (newKey: string | undefined, oldKey: string) => Promise<void>; diff --git a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx index 4034a6fd592..816f39f48a4 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx @@ -33,6 +33,7 @@ import { addSideBarClass, removeSideBarClass } from '../../../helpers/pages'; import { get, save } from '../../../helpers/storage'; import { isLoggedIn } from '../../../helpers/users'; import { ComponentQualifier } from '../../../types/component'; +import { CurrentUser, RawQuery } from '../../../types/types'; import { hasFilterParams, hasVisualizationParams, parseUrlQuery, Query } from '../query'; import '../styles.css'; import { Facets, Project } from '../types'; @@ -43,7 +44,7 @@ import PageSidebar from './PageSidebar'; import ProjectsList from './ProjectsList'; interface Props { - currentUser: T.CurrentUser; + currentUser: CurrentUser; isFavorite: boolean; location: Pick<Location, 'pathname' | 'query'>; qualifiers: ComponentQualifier[]; @@ -216,7 +217,7 @@ export class AllProjects extends React.PureComponent<Props, State> { } }; - updateLocationQuery = (newQuery: T.RawQuery) => { + updateLocationQuery = (newQuery: RawQuery) => { const query = omitBy({ ...this.props.location.query, ...newQuery }, x => !x); this.props.router.push({ pathname: this.props.location.pathname, query }); }; diff --git a/server/sonar-web/src/main/js/apps/projects/components/ApplicationCreation.tsx b/server/sonar-web/src/main/js/apps/projects/components/ApplicationCreation.tsx index b652a99505b..ac77f57192b 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ApplicationCreation.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ApplicationCreation.tsx @@ -29,11 +29,12 @@ import { getComponentAdminUrl, getComponentOverviewUrl } from '../../../helpers/ import { hasGlobalPermission } from '../../../helpers/users'; import { ComponentQualifier } from '../../../types/component'; import { Permissions } from '../../../types/permissions'; +import { AppState, LoggedInUser } from '../../../types/types'; export interface ApplicationCreationProps { - appState: Pick<T.AppState, 'qualifiers'>; + appState: Pick<AppState, 'qualifiers'>; className?: string; - currentUser: T.LoggedInUser; + currentUser: LoggedInUser; router: Router; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx b/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx index 68329e25c0a..8d6ac8a797e 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx @@ -23,11 +23,12 @@ import { withCurrentUser } from '../../../components/hoc/withCurrentUser'; import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; import { get } from '../../../helpers/storage'; import { hasGlobalPermission, isLoggedIn } from '../../../helpers/users'; +import { CurrentUser } from '../../../types/types'; import { PROJECTS_ALL, PROJECTS_DEFAULT_FILTER, PROJECTS_FAVORITE } from '../utils'; import AllProjectsContainer from './AllProjectsContainer'; interface Props { - currentUser: T.CurrentUser; + currentUser: CurrentUser; location: Pick<Location, 'pathname' | 'query'>; router: Pick<Router, 'replace'>; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx b/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx index c1fc2b8209e..907e07834f2 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx @@ -24,9 +24,10 @@ import { withRouter } from '../../../components/hoc/withRouter'; import { translate } from '../../../helpers/l10n'; import { hasGlobalPermission, isLoggedIn } from '../../../helpers/users'; import { Permissions } from '../../../types/permissions'; +import { CurrentUser } from '../../../types/types'; export interface EmptyInstanceProps { - currentUser: T.CurrentUser; + currentUser: CurrentUser; router: WithRouterProps['router']; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx b/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx index 7a017538197..235c3b2cd8f 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx @@ -22,11 +22,12 @@ import { IndexLink, Link } from 'react-router'; import { translate } from '../../../helpers/l10n'; import { save } from '../../../helpers/storage'; import { isLoggedIn } from '../../../helpers/users'; +import { CurrentUser, RawQuery } from '../../../types/types'; import { PROJECTS_ALL, PROJECTS_DEFAULT_FILTER, PROJECTS_FAVORITE } from '../utils'; interface Props { - currentUser: T.CurrentUser; - query?: T.RawQuery; + currentUser: CurrentUser; + query?: RawQuery; } export default class FavoriteFilter extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx index 8d9e1fbcbc8..1d88553877d 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx @@ -23,6 +23,7 @@ import HomePageSelect from '../../../components/controls/HomePageSelect'; import Tooltip from '../../../components/controls/Tooltip'; import { translate } from '../../../helpers/l10n'; import { isLoggedIn } from '../../../helpers/users'; +import { CurrentUser, RawQuery } from '../../../types/types'; import SearchFilterContainer from '../filters/SearchFilterContainer'; import { Project } from '../types'; import ApplicationCreation from './ApplicationCreation'; @@ -31,13 +32,13 @@ import ProjectCreationMenu from './ProjectCreationMenu'; import ProjectsSortingSelect from './ProjectsSortingSelect'; interface Props { - currentUser: T.CurrentUser; + currentUser: CurrentUser; loading: boolean; onPerspectiveChange: (x: { view: string; visualization?: string }) => void; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; onSortChange: (sort: string, desc: boolean) => void; projects?: Project[]; - query: T.RawQuery; + query: RawQuery; selectedSort: string; total?: number; view: string; diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx b/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx index 13872969632..dc4cd58fbe4 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/PageSidebar.tsx @@ -20,6 +20,7 @@ import { flatMap } from 'lodash'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; +import { RawQuery } from '../../../types/types'; import CoverageFilter from '../filters/CoverageFilter'; import DuplicationsFilter from '../filters/DuplicationsFilter'; import LanguagesFilterContainer from '../filters/LanguagesFilterContainer'; @@ -46,8 +47,8 @@ export interface PageSidebarProps { applicationsEnabled: boolean; facets?: Facets; onClearAll: () => void; - onQueryChange: (change: T.RawQuery) => void; - query: T.RawQuery; + onQueryChange: (change: RawQuery) => void; + query: RawQuery; view: string; visualization: string; } @@ -59,7 +60,7 @@ export default function PageSidebar(props: PageSidebarProps) { const maxFacetValue = getMaxFacetValue(facets); const facetProps = { onQueryChange, maxFacetValue }; - let linkQuery: T.RawQuery | undefined = undefined; + let linkQuery: RawQuery | undefined = undefined; if (view !== 'overall') { linkQuery = { view }; diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenu.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenu.tsx index d43ce028420..f75875da77e 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenu.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCreationMenu.tsx @@ -30,11 +30,12 @@ import { translate } from '../../../helpers/l10n'; import { hasGlobalPermission } from '../../../helpers/users'; import { AlmKeys, AlmSettingsInstance } from '../../../types/alm-settings'; import { Permissions } from '../../../types/permissions'; +import { LoggedInUser } from '../../../types/types'; import ProjectCreationMenuItem from './ProjectCreationMenuItem'; interface Props { className?: string; - currentUser: T.LoggedInUser; + currentUser: LoggedInUser; } interface State { diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectsList.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectsList.tsx index 8e265138f43..d2f93deca14 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectsList.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectsList.tsx @@ -23,6 +23,7 @@ import { List, ListRowProps } from 'react-virtualized/dist/commonjs/List'; import { WindowScroller } from 'react-virtualized/dist/commonjs/WindowScroller'; import EmptySearch from '../../../components/common/EmptySearch'; import { translate } from '../../../helpers/l10n'; +import { CurrentUser } from '../../../types/types'; import { Query } from '../query'; import { Project } from '../types'; import EmptyFavoriteSearch from './EmptyFavoriteSearch'; @@ -35,7 +36,7 @@ const PROJECT_CARD_MARGIN = 20; interface Props { cardType?: string; - currentUser: T.CurrentUser; + currentUser: CurrentUser; handleFavorite: (component: string, isFavorite: boolean) => void; isFavorite: boolean; isFiltered: boolean; diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx index 6709060a2ff..eccc586ea73 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/AllProjects-test.tsx @@ -21,6 +21,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { get, save } from '../../../../helpers/storage'; import { ComponentQualifier } from '../../../../types/component'; +import { Dict } from '../../../../types/types'; import { AllProjects, LS_PROJECTS_SORT, @@ -110,7 +111,7 @@ it('fetches projects', () => { }); it('redirects to the saved search', () => { - const localeStorageMock: T.Dict<string> = { + const localeStorageMock: Dict<string> = { [LS_PROJECTS_VIEW]: 'leak', [LS_PROJECTS_SORT]: 'coverage', [LS_PROJECTS_VISUALIZATION]: 'security' diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx index 01a5c463cd4..5ed9e6e8ad9 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx @@ -29,6 +29,7 @@ import { } from '../../../../helpers/testMocks'; import { waitAndUpdate } from '../../../../helpers/testUtils'; import { hasGlobalPermission } from '../../../../helpers/users'; +import { CurrentUser } from '../../../../types/types'; import { DefaultPageSelector } from '../DefaultPageSelector'; jest.mock( @@ -46,7 +47,7 @@ jest.mock('../../../../helpers/storage', () => ({ jest.mock('../../../../helpers/users', () => ({ hasGlobalPermission: jest.fn().mockReturnValue(false), - isLoggedIn: jest.fn((u: T.CurrentUser) => u.isLoggedIn) + isLoggedIn: jest.fn((u: CurrentUser) => u.isLoggedIn) })); jest.mock('../../../../api/components', () => ({ diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx index 96758862825..624d6021173 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx @@ -35,6 +35,7 @@ import { getProjectUrl } from '../../../../helpers/urls'; import { isLoggedIn } from '../../../../helpers/users'; import { ComponentQualifier } from '../../../../types/component'; import { MetricKey } from '../../../../types/metrics'; +import { CurrentUser } from '../../../../types/types'; import { Project } from '../../types'; import './ProjectCard.css'; import ProjectCardLanguagesContainer from './ProjectCardLanguagesContainer'; @@ -43,7 +44,7 @@ import ProjectCardMeasures from './ProjectCardMeasures'; import ProjectCardQualityGate from './ProjectCardQualityGate'; interface Props { - currentUser: T.CurrentUser; + currentUser: CurrentUser; handleFavorite: (component: string, isFavorite: boolean) => void; height: number; project: Project; diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardLanguages.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardLanguages.tsx index 567ca229559..77309ffdbb3 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardLanguages.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardLanguages.tsx @@ -20,11 +20,12 @@ import { sortBy } from 'lodash'; import * as React from 'react'; import { translate } from '../../../../helpers/l10n'; +import { Languages } from '../../../../types/types'; interface Props { className?: string; distribution?: string; - languages: T.Languages; + languages: Languages; } export default function ProjectCardLanguages({ className, distribution, languages }: Props) { @@ -46,7 +47,7 @@ export default function ProjectCardLanguages({ className, distribution, language ); } -function getLanguageName(languages: T.Languages, key: string): string { +function getLanguageName(languages: Languages, key: string): string { if (key === '<null>') { return translate('unknown'); } diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx index 1694baf44b1..6a71ccc1f93 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx @@ -29,12 +29,13 @@ import { translate, translateWithParameters } from '../../../../helpers/l10n'; import { isDefined } from '../../../../helpers/types'; import { ComponentQualifier } from '../../../../types/component'; import { MetricKey } from '../../../../types/metrics'; +import { Dict } from '../../../../types/types'; import { formatDuration } from '../../utils'; import ProjectCardMeasure from './ProjectCardMeasure'; export interface ProjectCardMeasuresProps { isNewCode: boolean; - measures: T.Dict<string | undefined>; + measures: Dict<string | undefined>; componentQualifier: ComponentQualifier; newCodeStartingDate?: string; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx index d6cf7f5744b..87cbce08c4b 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx @@ -23,6 +23,7 @@ import PrivacyBadgeContainer from '../../../../../components/common/PrivacyBadge import TagsList from '../../../../../components/tags/TagsList'; import { mockCurrentUser, mockLoggedInUser } from '../../../../../helpers/testMocks'; import { ComponentQualifier } from '../../../../../types/component'; +import { CurrentUser } from '../../../../../types/types'; import { Project } from '../../../types'; import ProjectCard from '../ProjectCard'; import ProjectCardQualityGate from '../ProjectCardQualityGate'; @@ -108,7 +109,7 @@ it('should display applications', () => { ).toMatchSnapshot('with project count'); }); -function shallowRender(project: Project, user: T.CurrentUser = USER_LOGGED_OUT, type?: string) { +function shallowRender(project: Project, user: CurrentUser = USER_LOGGED_OUT, type?: string) { return shallow( <ProjectCard currentUser={user} diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCardMeasures-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCardMeasures-test.tsx index 788f567050f..93ebaefec6f 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCardMeasures-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCardMeasures-test.tsx @@ -22,6 +22,7 @@ import * as React from 'react'; import CoverageRating from '../../../../../components/ui/CoverageRating'; import { ComponentQualifier } from '../../../../../types/component'; import { MetricKey } from '../../../../../types/metrics'; +import { Dict } from '../../../../../types/types'; import ProjectCardMeasures, { ProjectCardMeasuresProps } from '../ProjectCardMeasures'; jest.mock('date-fns', () => ({ @@ -59,7 +60,7 @@ describe('New code measures', () => { }); function shallowRender( - measuresOverride: T.Dict<string | undefined> = {}, + measuresOverride: Dict<string | undefined> = {}, props: Partial<ProjectCardMeasuresProps> = {} ) { const measures = { diff --git a/server/sonar-web/src/main/js/apps/projects/filters/CoverageFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/CoverageFilter.tsx index 4e1463002db..69ad7754ac9 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/CoverageFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/CoverageFilter.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import CoverageRating from '../../../components/ui/CoverageRating'; import { translate } from '../../../helpers/l10n'; import { getCoverageRatingAverageValue, getCoverageRatingLabel } from '../../../helpers/ratings'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import Filter from './Filter'; import FilterHeader from './FilterHeader'; @@ -29,7 +30,7 @@ export interface Props { className?: string; facet?: Facet; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; property?: string; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/DuplicationsFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/DuplicationsFilter.tsx index 8ad097a9826..05869513cd5 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/DuplicationsFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/DuplicationsFilter.tsx @@ -24,6 +24,7 @@ import { getDuplicationsRatingAverageValue, getDuplicationsRatingLabel } from '../../../helpers/ratings'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import Filter from './Filter'; import FilterHeader from './FilterHeader'; @@ -32,7 +33,7 @@ export interface Props { className?: string; facet?: Facet; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; property?: string; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/Filter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/Filter.tsx index 85a15f0e7b5..710133a1af7 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/Filter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/Filter.tsx @@ -21,6 +21,7 @@ import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; export type Option = string | number; @@ -28,7 +29,7 @@ export type Option = string | number; interface Props { property: string; className?: string; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; options: Option[]; renderOption: (option: Option, isSelected: boolean) => React.ReactNode; diff --git a/server/sonar-web/src/main/js/apps/projects/filters/IssuesFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/IssuesFilter.tsx index ade2ba79d85..aa0e5cda137 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/IssuesFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/IssuesFilter.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import Rating from '../../../components/ui/Rating'; import { translate } from '../../../helpers/l10n'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import Filter from './Filter'; import FilterHeader from './FilterHeader'; @@ -30,7 +31,7 @@ interface Props { headerDetail?: React.ReactNode; maxFacetValue?: number; name: string; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; property: string; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx index e3786e0f5b1..9e6b5f23883 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx @@ -21,6 +21,7 @@ import { difference, sortBy } from 'lodash'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { getLanguageByKey } from '../../../store/languages'; +import { Dict, Languages, RawQuery } from '../../../types/types'; import { Facet } from '../types'; import Filter from './Filter'; import FilterHeader from './FilterHeader'; @@ -29,11 +30,11 @@ import SearchableFilterOption from './SearchableFilterOption'; interface Props { facet?: Facet; - languages: T.Languages; + languages: Languages; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; property?: string; - query: T.Dict<any>; + query: Dict<any>; value?: string[]; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx index 73a3c437eca..b688cd21434 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/MaintainabilityFilter.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import CodeSmellIcon from '../../../components/icons/CodeSmellIcon'; import { translate } from '../../../helpers/l10n'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import IssuesFilter from './IssuesFilter'; @@ -28,7 +29,7 @@ interface Props { facet?: Facet; headerDetail?: React.ReactNode; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/NewLinesFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/NewLinesFilter.tsx index 73b9dceb8dc..a87dade56df 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/NewLinesFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/NewLinesFilter.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { getSizeRatingLabel } from '../../../helpers/ratings'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import Filter from './Filter'; import FilterHeader from './FilterHeader'; @@ -28,7 +29,7 @@ export interface Props { className?: string; facet?: Facet; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; property?: string; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/NewMaintainabilityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/NewMaintainabilityFilter.tsx index c151cb3c6fc..17ed7eb724f 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/NewMaintainabilityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/NewMaintainabilityFilter.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import CodeSmellIcon from '../../../components/icons/CodeSmellIcon'; import { translate } from '../../../helpers/l10n'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import IssuesFilter from './IssuesFilter'; @@ -27,7 +28,7 @@ interface Props { className?: string; facet?: Facet; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/NewReliabilityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/NewReliabilityFilter.tsx index 423e5fd205b..62994683e66 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/NewReliabilityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/NewReliabilityFilter.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import BugIcon from '../../../components/icons/BugIcon'; import { translate } from '../../../helpers/l10n'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import IssuesFilter from './IssuesFilter'; @@ -27,7 +28,7 @@ interface Props { className?: string; facet?: Facet; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/NewSecurityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/NewSecurityFilter.tsx index 64614768687..bc08d8fee98 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/NewSecurityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/NewSecurityFilter.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import VulnerabilityIcon from '../../../components/icons/VulnerabilityIcon'; import { translate } from '../../../helpers/l10n'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import IssuesFilter from './IssuesFilter'; @@ -27,7 +28,7 @@ interface Props { className?: string; facet?: Facet; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/QualifierFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/QualifierFilter.tsx index 84812b36415..a78fa08c5f0 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/QualifierFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/QualifierFilter.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import QualifierIcon from '../../../components/icons/QualifierIcon'; import { translate } from '../../../helpers/l10n'; import { ComponentQualifier } from '../../../types/component'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import Filter from './Filter'; import FilterHeader from './FilterHeader'; @@ -28,7 +29,7 @@ import FilterHeader from './FilterHeader'; export interface QualifierFilterProps { facet?: Facet; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; value: ComponentQualifier | undefined; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx index fd857bf2f80..b078c0a9bf1 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/QualityGateFilter.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import Level from '../../../components/ui/Level'; import { translate } from '../../../helpers/l10n'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import Filter from './Filter'; import FilterHeader from './FilterHeader'; @@ -29,7 +30,7 @@ export interface Props { className?: string; facet?: Facet; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx index 2f4f683241e..db278caa5a7 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/ReliabilityFilter.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import BugIcon from '../../../components/icons/BugIcon'; import { translate } from '../../../helpers/l10n'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import IssuesFilter from './IssuesFilter'; @@ -28,7 +29,7 @@ interface Props { facet?: Facet; headerDetail?: React.ReactNode; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx index 61a7e51d413..000195204cb 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/SearchableFilterFooter.tsx @@ -20,16 +20,17 @@ import * as React from 'react'; import SelectLegacy from '../../../components/controls/SelectLegacy'; import { translate } from '../../../helpers/l10n'; +import { Dict, RawQuery } from '../../../types/types'; interface Props { isFavorite?: boolean; isLoading?: boolean; onInputChange?: (query: string) => void; onOpen?: () => void; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; options: Array<{ label: string; value: string }>; property: string; - query: T.Dict<any>; + query: Dict<any>; } export default class SearchableFilterFooter extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx index a553d205870..fc475918ceb 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/SecurityFilter.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import VulnerabilityIcon from '../../../components/icons/VulnerabilityIcon'; import { translate } from '../../../helpers/l10n'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import IssuesFilter from './IssuesFilter'; @@ -28,7 +29,7 @@ interface Props { facet?: Facet; headerDetail?: React.ReactNode; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SecurityReviewFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/SecurityReviewFilter.tsx index 816b7428e33..c36d18f7dcb 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SecurityReviewFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/SecurityReviewFilter.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import SecurityHotspotIcon from '../../../components/icons/SecurityHotspotIcon'; import Rating from '../../../components/ui/Rating'; import { translate } from '../../../helpers/l10n'; +import { Dict, RawQuery } from '../../../types/types'; import { Facet } from '../types'; import Filter from './Filter'; import FilterHeader from './FilterHeader'; @@ -29,12 +30,12 @@ export interface Props { className?: string; facet?: Facet; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; property?: string; value?: any; } -const labels: T.Dict<string> = { +const labels: Dict<string> = { 1: '≥ 80%', 2: '70% - 80%', 3: '50% - 70%', diff --git a/server/sonar-web/src/main/js/apps/projects/filters/SizeFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/SizeFilter.tsx index 9df9a168890..906d7fee9bf 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/SizeFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/SizeFilter.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import SizeRating from '../../../components/ui/SizeRating'; import { translate } from '../../../helpers/l10n'; import { getSizeRatingAverageValue, getSizeRatingLabel } from '../../../helpers/ratings'; +import { RawQuery } from '../../../types/types'; import { Facet } from '../types'; import Filter from './Filter'; import FilterHeader from './FilterHeader'; @@ -29,7 +30,7 @@ export interface Props { className?: string; facet?: Facet; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; property?: string; value?: any; } diff --git a/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.tsx index c7175a3cc3b..6bfd1e91aa8 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/TagsFilter.tsx @@ -21,6 +21,7 @@ import { debounce, difference, size, sortBy } from 'lodash'; import * as React from 'react'; import { searchProjectTags } from '../../../api/components'; import { translate } from '../../../helpers/l10n'; +import { Dict, RawQuery } from '../../../types/types'; import { Facet } from '../types'; import Filter from './Filter'; import FilterHeader from './FilterHeader'; @@ -30,9 +31,9 @@ import SearchableFilterOption from './SearchableFilterOption'; interface Props { facet?: Facet; maxFacetValue?: number; - onQueryChange: (change: T.RawQuery) => void; + onQueryChange: (change: RawQuery) => void; property?: string; - query: T.Dict<any>; + query: Dict<any>; value?: string[]; } diff --git a/server/sonar-web/src/main/js/apps/projects/query.ts b/server/sonar-web/src/main/js/apps/projects/query.ts index 97e0eee257f..51334cee3d2 100644 --- a/server/sonar-web/src/main/js/apps/projects/query.ts +++ b/server/sonar-web/src/main/js/apps/projects/query.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { ComponentQualifier } from '../../types/component'; +import { Dict, RawQuery } from '../../types/types'; import { VISUALIZATIONS } from './utils'; type Level = 'ERROR' | 'WARN' | 'OK'; @@ -48,7 +49,7 @@ export interface Query { [x: string]: string | number | string[] | undefined; } -export function parseUrlQuery(urlQuery: T.RawQuery): Query { +export function parseUrlQuery(urlQuery: RawQuery): Query { return { gate: getAsLevel(urlQuery['gate']), reliability: getAsNumericRating(urlQuery['reliability']), @@ -239,7 +240,7 @@ function convertSize(metric: string, size: number): string { } function mapPropertyToMetric(property?: string): string | undefined { - const map: T.Dict<string> = { + const map: Dict<string> = { analysis_date: 'analysisDate', reliability: 'reliability_rating', new_reliability: 'new_reliability_rating', diff --git a/server/sonar-web/src/main/js/apps/projects/types.ts b/server/sonar-web/src/main/js/apps/projects/types.ts index 704412a23f5..257a88aeb67 100644 --- a/server/sonar-web/src/main/js/apps/projects/types.ts +++ b/server/sonar-web/src/main/js/apps/projects/types.ts @@ -18,18 +18,19 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { ComponentQualifier } from '../../types/component'; +import { Dict, Visibility } from '../../types/types'; export interface Project { analysisDate?: string; isFavorite?: boolean; key: string; leakPeriodDate?: string; - measures: T.Dict<string>; + measures: Dict<string>; name: string; projects?: number; qualifier: ComponentQualifier; tags: string[]; - visibility: T.Visibility; + visibility: Visibility; needIssueSync?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/projects/utils.ts b/server/sonar-web/src/main/js/apps/projects/utils.ts index d9c0446d643..947389d5099 100644 --- a/server/sonar-web/src/main/js/apps/projects/utils.ts +++ b/server/sonar-web/src/main/js/apps/projects/utils.ts @@ -24,6 +24,7 @@ import { translate, translateWithParameters } from '../../helpers/l10n'; import { isDiffMetric } from '../../helpers/measures'; import { RequestData } from '../../helpers/request'; import { MetricKey } from '../../types/metrics'; +import { Dict } from '../../types/types'; import { convertToFilter, Query } from './query'; interface SortingOption { @@ -59,7 +60,7 @@ export const SORTING_LEAK_METRICS: SortingOption[] = [ { value: 'new_lines', class: 'projects-leak-sorting-option' } ]; -export const SORTING_SWITCH: T.Dict<string> = { +export const SORTING_SWITCH: Dict<string> = { analysis_date: 'analysis_date', name: 'name', reliability: 'new_reliability', @@ -128,7 +129,7 @@ const LEAK_METRICS = [ MetricKey.projects ]; -const METRICS_BY_VISUALIZATION: T.Dict<string[]> = { +const METRICS_BY_VISUALIZATION: Dict<string[]> = { risk: [ MetricKey.reliability_rating, MetricKey.security_rating, @@ -214,7 +215,7 @@ export function fetchProjects(query: Query, isFavorite: boolean, pageIndex = 1) return { facets: getFacetsMap(facets), projects: components.map(component => { - const componentMeasures: T.Dict<string> = {}; + const componentMeasures: Dict<string> = {}; measures .filter(measure => measure.component === component.key) .forEach(measure => { @@ -276,14 +277,14 @@ export function fetchProjectMeasures(projects: Array<{ key: string }>, query: Qu } function mapFacetValues(values: Array<{ val: string; count: number }>) { - const map: T.Dict<number> = {}; + const map: Dict<number> = {}; values.forEach(value => { map[value.val] = value.count; }); return map; } -const propertyToMetricMap: T.Dict<string | undefined> = { +const propertyToMetricMap: Dict<string | undefined> = { analysis_date: 'analysisDate', reliability: 'reliability_rating', new_reliability: 'new_reliability_rating', @@ -309,7 +310,7 @@ const propertyToMetricMap: T.Dict<string | undefined> = { const metricToPropertyMap = invert(propertyToMetricMap); function getFacetsMap(facets: Facet[]) { - const map: T.Dict<T.Dict<number>> = {}; + const map: Dict<Dict<number>> = {}; facets.forEach(facet => { const property = metricToPropertyMap[facet.property]; const { values } = facet; diff --git a/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.tsx b/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.tsx index db77fa42331..65b8ae39a05 100644 --- a/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.tsx +++ b/server/sonar-web/src/main/js/apps/projects/visualizations/Visualizations.tsx @@ -19,6 +19,7 @@ */ import * as React from 'react'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Dict } from '../../../types/types'; import { Project } from '../types'; import { localizeSorting } from '../utils'; import Coverage from './Coverage'; @@ -37,7 +38,7 @@ interface Props { export default class Visualizations extends React.PureComponent<Props> { renderVisualization(projects: Project[]) { - const visualizationToComponent: T.Dict<any> = { + const visualizationToComponent: Dict<any> = { risk: Risk, reliability: Reliability, security: Security, diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/App.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/App.tsx index c3c7d9ce91f..5f12052689a 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/App.tsx @@ -32,20 +32,21 @@ import { hasGlobalPermission } from '../../helpers/users'; import { getAppState, getCurrentUser, Store } from '../../store/rootReducer'; import { Permissions } from '../../types/permissions'; import { SettingsKey } from '../../types/settings'; +import { AppState, LoggedInUser, Visibility } from '../../types/types'; import CreateProjectForm from './CreateProjectForm'; import Header from './Header'; import Projects from './Projects'; import Search from './Search'; export interface Props { - currentUser: T.LoggedInUser; - appState: Pick<T.AppState, 'qualifiers'>; + currentUser: LoggedInUser; + appState: Pick<AppState, 'qualifiers'>; } interface State { analyzedBefore?: Date; createProjectForm: boolean; - defaultProjectVisibility?: T.Visibility; + defaultProjectVisibility?: Visibility; page: number; projects: Project[]; provisioned: boolean; @@ -54,7 +55,7 @@ interface State { ready: boolean; selection: string[]; total: number; - visibility?: T.Visibility; + visibility?: Visibility; } const PAGE_SIZE = 50; @@ -92,11 +93,11 @@ export class App extends React.PureComponent<Props, State> { const results = await getValues({ keys: SettingsKey.DefaultProjectVisibility }); if (this.mounted && results.length > 0 && results[0].value) { - this.setState({ defaultProjectVisibility: results[0].value as T.Visibility }); + this.setState({ defaultProjectVisibility: results[0].value as Visibility }); } }; - handleDefaultProjectVisibilityChange = async (visibility: T.Visibility) => { + handleDefaultProjectVisibilityChange = async (visibility: Visibility) => { await changeProjectDefaultVisibility(visibility); if (this.mounted) { @@ -155,7 +156,7 @@ export class App extends React.PureComponent<Props, State> { ); }; - onVisibilityChanged = (newVisibility: T.Visibility | 'all') => { + onVisibilityChanged = (newVisibility: Visibility | 'all') => { this.setState( { ready: false, @@ -262,7 +263,7 @@ export class App extends React.PureComponent<Props, State> { const mapStateToProps = (state: Store) => ({ appState: getAppState(state), - currentUser: getCurrentUser(state) as T.LoggedInUser + currentUser: getCurrentUser(state) as LoggedInUser }); export default connect(mapStateToProps)(App); diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx index 284f42c0e2f..f2f28010c3e 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx @@ -27,6 +27,7 @@ import MandatoryFieldMarker from '../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../components/ui/MandatoryFieldsExplanation'; import { toNotSoISOString } from '../../helpers/dates'; import { translate, translateWithParameters } from '../../helpers/l10n'; +import { PermissionTemplate } from '../../types/types'; export interface Props { analyzedBefore: Date | undefined; @@ -42,7 +43,7 @@ interface State { done: boolean; loading: boolean; permissionTemplate?: string; - permissionTemplates?: T.PermissionTemplate[]; + permissionTemplates?: PermissionTemplate[]; submitting: boolean; } diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/ChangeDefaultVisibilityForm.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/ChangeDefaultVisibilityForm.tsx index 06fe0785b93..406956ce2b3 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/ChangeDefaultVisibilityForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/ChangeDefaultVisibilityForm.tsx @@ -23,15 +23,16 @@ import Modal from '../../components/controls/Modal'; import Radio from '../../components/controls/Radio'; import { Alert } from '../../components/ui/Alert'; import { translate } from '../../helpers/l10n'; +import { Visibility } from '../../types/types'; export interface Props { - defaultVisibility: T.Visibility; + defaultVisibility: Visibility; onClose: () => void; - onConfirm: (visiblity: T.Visibility) => void; + onConfirm: (visiblity: Visibility) => void; } interface State { - visibility: T.Visibility; + visibility: Visibility; } export default class ChangeDefaultVisibilityForm extends React.PureComponent<Props, State> { @@ -45,7 +46,7 @@ export default class ChangeDefaultVisibilityForm extends React.PureComponent<Pro this.props.onClose(); }; - handleVisibilityChange = (visibility: T.Visibility) => { + handleVisibilityChange = (visibility: Visibility) => { this.setState({ visibility }); }; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/CreateProjectForm.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/CreateProjectForm.tsx index b9b7f1aa40c..0d1abe85f31 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/CreateProjectForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/CreateProjectForm.tsx @@ -29,9 +29,10 @@ import MandatoryFieldMarker from '../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../helpers/l10n'; import { getProjectUrl } from '../../helpers/urls'; +import { Visibility } from '../../types/types'; interface Props { - defaultProjectVisibility?: T.Visibility; + defaultProjectVisibility?: Visibility; onClose: () => void; onProjectCreated: () => void; } @@ -41,7 +42,7 @@ interface State { key: string; loading: boolean; name: string; - visibility?: T.Visibility; + visibility?: Visibility; // add index declaration to be able to do `this.setState({ [name]: value });` [x: string]: any; } @@ -82,7 +83,7 @@ export default class CreateProjectForm extends React.PureComponent<Props, State> this.setState({ [name]: value }); }; - handleVisibilityChange = (visibility: T.Visibility) => { + handleVisibilityChange = (visibility: Visibility) => { this.setState({ visibility }); }; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx index 186366ffc0f..233d2bc204c 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx @@ -20,13 +20,14 @@ import * as React from 'react'; import { Button, EditButton } from '../../components/controls/buttons'; import { translate } from '../../helpers/l10n'; +import { Visibility } from '../../types/types'; import ChangeDefaultVisibilityForm from './ChangeDefaultVisibilityForm'; export interface Props { - defaultProjectVisibility?: T.Visibility; + defaultProjectVisibility?: Visibility; hasProvisionPermission?: boolean; onProjectCreate: () => void; - onChangeDefaultProjectVisibility: (visibility: T.Visibility) => void; + onChangeDefaultProjectVisibility: (visibility: Visibility) => void; } interface State { diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRow.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRow.tsx index 6bcb30683f8..0e603ac00da 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRow.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRow.tsx @@ -26,11 +26,12 @@ import Tooltip from '../../components/controls/Tooltip'; import QualifierIcon from '../../components/icons/QualifierIcon'; import DateFormatter from '../../components/intl/DateFormatter'; import { getComponentOverviewUrl } from '../../helpers/urls'; +import { LoggedInUser } from '../../types/types'; import './ProjectRow.css'; import ProjectRowActions from './ProjectRowActions'; interface Props { - currentUser: Pick<T.LoggedInUser, 'login'>; + currentUser: Pick<LoggedInUser, 'login'>; onProjectCheck: (project: Project, checked: boolean) => void; project: Project; selected: boolean; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx index 8110759fa59..55c24867648 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/ProjectRowActions.tsx @@ -24,11 +24,12 @@ import ActionsDropdown, { ActionsDropdownItem } from '../../components/controls/ import DeferredSpinner from '../../components/ui/DeferredSpinner'; import { translate } from '../../helpers/l10n'; import { getComponentPermissionsUrl } from '../../helpers/urls'; +import { LoggedInUser } from '../../types/types'; import ApplyTemplate from '../permissions/project/components/ApplyTemplate'; import RestoreAccessModal from './RestoreAccessModal'; export interface Props { - currentUser: Pick<T.LoggedInUser, 'login'>; + currentUser: Pick<LoggedInUser, 'login'>; project: Project; } diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Projects.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Projects.tsx index a5b575c8bae..10baa2205b4 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Projects.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Projects.tsx @@ -21,10 +21,11 @@ import classNames from 'classnames'; import * as React from 'react'; import { Project } from '../../api/components'; import { translate } from '../../helpers/l10n'; +import { LoggedInUser } from '../../types/types'; import ProjectRow from './ProjectRow'; interface Props { - currentUser: Pick<T.LoggedInUser, 'login'>; + currentUser: Pick<LoggedInUser, 'login'>; onProjectDeselected: (project: string) => void; onProjectSelected: (project: string) => void; projects: Project[]; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/RestoreAccessModal.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/RestoreAccessModal.tsx index c651f31e4c5..488efd48966 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/RestoreAccessModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/RestoreAccessModal.tsx @@ -24,9 +24,10 @@ import { grantPermissionToUser } from '../../api/permissions'; import { ResetButtonLink, SubmitButton } from '../../components/controls/buttons'; import Modal from '../../components/controls/Modal'; import { translate } from '../../helpers/l10n'; +import { LoggedInUser } from '../../types/types'; interface Props { - currentUser: Pick<T.LoggedInUser, 'login'>; + currentUser: Pick<LoggedInUser, 'login'>; onClose: () => void; onRestoreAccess: () => void; project: Project; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx index 289a64ba123..c7932a0a25c 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx @@ -28,6 +28,7 @@ import SearchBox from '../../components/controls/SearchBox'; import SelectLegacy from '../../components/controls/SelectLegacy'; import QualifierIcon from '../../components/icons/QualifierIcon'; import { translate } from '../../helpers/l10n'; +import { Visibility } from '../../types/types'; import BulkApplyTemplateModal from './BulkApplyTemplateModal'; import DeleteModal from './DeleteModal'; @@ -49,7 +50,7 @@ export interface Props { selection: any[]; topLevelQualifiers: string[]; total: number; - visibility?: T.Visibility; + visibility?: Visibility; } interface State { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/App.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/App.tsx index e2bd83f3f84..7ff06229f15 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/App.tsx @@ -33,6 +33,7 @@ import { removeWhitePageClass } from '../../../helpers/pages'; import { getQualityGateUrl } from '../../../helpers/urls'; +import { QualityGate } from '../../../types/types'; import '../styles.css'; import Details from './Details'; import List from './List'; @@ -41,7 +42,7 @@ import ListHeader from './ListHeader'; interface State { canCreate: boolean; loading: boolean; - qualityGates: T.QualityGate[]; + qualityGates: QualityGate[]; } class App extends React.PureComponent<Pick<WithRouterProps, 'params' | 'router'>, State> { @@ -86,12 +87,12 @@ class App extends React.PureComponent<Pick<WithRouterProps, 'params' | 'router'> ); }; - openDefault(qualityGates: T.QualityGate[]) { + openDefault(qualityGates: QualityGate[]) { const defaultQualityGate = qualityGates.find(gate => Boolean(gate.isDefault))!; this.props.router.replace(getQualityGateUrl(String(defaultQualityGate.id))); } - handleSetDefault = (qualityGate: T.QualityGate) => { + handleSetDefault = (qualityGate: QualityGate) => { this.setState(({ qualityGates }) => { return { qualityGates: qualityGates.map(candidate => { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx index c03a1bc871f..7a6bc628c0f 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx @@ -24,16 +24,17 @@ import { DeleteButton, EditButton } from '../../../components/controls/buttons'; import ConfirmModal from '../../../components/controls/ConfirmModal'; import { getLocalizedMetricName, translate, translateWithParameters } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; +import { Condition as ConditionType, Metric, QualityGate } from '../../../types/types'; import { getLocalizedMetricNameNoDiffMetric } from '../utils'; import ConditionModal from './ConditionModal'; interface Props { - condition: T.Condition; + condition: ConditionType; canEdit: boolean; - metric: T.Metric; - onRemoveCondition: (Condition: T.Condition) => void; - onSaveCondition: (newCondition: T.Condition, oldCondition: T.Condition) => void; - qualityGate: T.QualityGate; + metric: Metric; + onRemoveCondition: (Condition: ConditionType) => void; + onSaveCondition: (newCondition: ConditionType, oldCondition: ConditionType) => void; + qualityGate: QualityGate; updated?: boolean; } @@ -51,7 +52,7 @@ export default class Condition extends React.PureComponent<Props, State> { }; } - handleUpdateCondition = (newCondition: T.Condition) => { + handleUpdateCondition = (newCondition: ConditionType) => { this.props.onSaveCondition(newCondition, this.props.condition); }; @@ -71,7 +72,7 @@ export default class Condition extends React.PureComponent<Props, State> { this.setState({ deleteFormOpen: false }); }; - removeCondition = (condition: T.Condition) => { + removeCondition = (condition: ConditionType) => { deleteCondition({ id: condition.id }).then( () => this.props.onRemoveCondition(condition), () => {} diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx index c28d5966448..cb13248790e 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx @@ -24,25 +24,26 @@ import Radio from '../../../components/controls/Radio'; import { Alert } from '../../../components/ui/Alert'; import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; import { isDiffMetric } from '../../../helpers/measures'; +import { Condition, Metric, QualityGate } from '../../../types/types'; import { getPossibleOperators } from '../utils'; import ConditionOperator from './ConditionOperator'; import MetricSelect from './MetricSelect'; import ThresholdInput from './ThresholdInput'; interface Props { - condition?: T.Condition; - metric?: T.Metric; - metrics?: T.Metric[]; + condition?: Condition; + metric?: Metric; + metrics?: Metric[]; header: string; - onAddCondition: (condition: T.Condition) => void; + onAddCondition: (condition: Condition) => void; onClose: () => void; - qualityGate: T.QualityGate; + qualityGate: QualityGate; } interface State { error: string; errorMessage?: string; - metric?: T.Metric; + metric?: Metric; op?: string; scope: 'new' | 'overall'; } @@ -58,7 +59,7 @@ export default class ConditionModal extends React.PureComponent<Props, State> { }; } - getSinglePossibleOperator(metric: T.Metric) { + getSinglePossibleOperator(metric: Metric) { const operators = getPossibleOperators(metric); return Array.isArray(operators) ? undefined : operators; } @@ -66,7 +67,7 @@ export default class ConditionModal extends React.PureComponent<Props, State> { handleFormSubmit = () => { if (this.state.metric) { const { condition, qualityGate } = this.props; - const newCondition: T.Omit<T.Condition, 'id'> = { + const newCondition: Omit<Condition, 'id'> = { metric: this.state.metric.key, op: this.getSinglePossibleOperator(this.state.metric) || this.state.op, error: this.state.error @@ -94,7 +95,7 @@ export default class ConditionModal extends React.PureComponent<Props, State> { }); }; - handleMetricChange = (metric: T.Metric) => { + handleMetricChange = (metric: Metric) => { this.setState({ metric, op: undefined, error: '' }); }; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionOperator.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionOperator.tsx index 3f70f2149e6..0b249ad49d2 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionOperator.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionOperator.tsx @@ -20,10 +20,11 @@ import * as React from 'react'; import SelectLegacy from '../../../components/controls/SelectLegacy'; import { translate } from '../../../helpers/l10n'; +import { Metric } from '../../../types/types'; import { getPossibleOperators } from '../utils'; interface Props { - metric: T.Metric; + metric: Metric; onOperatorChange: (op: string) => void; op?: string; } @@ -33,7 +34,7 @@ export default class ConditionOperator extends React.PureComponent<Props> { this.props.onOperatorChange(value); }; - getLabel(op: string, metric: T.Metric) { + getLabel(op: string, metric: Metric) { return metric.type === 'RATING' ? translate('quality_gates.operator', op, 'rating') : translate('quality_gates.operator', op); diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx index 6d5d1fd5fd9..43c01d8f9b2 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx @@ -27,18 +27,25 @@ import { Alert } from '../../../components/ui/Alert'; import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; import { isDiffMetric } from '../../../helpers/measures'; import { MetricKey } from '../../../types/metrics'; +import { + AppState, + Condition as ConditionType, + Dict, + Metric, + QualityGate +} from '../../../types/types'; import Condition from './Condition'; import ConditionModal from './ConditionModal'; interface Props { - appState: Pick<T.AppState, 'branchesEnabled'>; + appState: Pick<AppState, 'branchesEnabled'>; canEdit: boolean; - conditions: T.Condition[]; - metrics: T.Dict<T.Metric>; - onAddCondition: (condition: T.Condition) => void; - onRemoveCondition: (Condition: T.Condition) => void; - onSaveCondition: (newCondition: T.Condition, oldCondition: T.Condition) => void; - qualityGate: T.QualityGate; + conditions: ConditionType[]; + metrics: Dict<Metric>; + onAddCondition: (condition: ConditionType) => void; + onRemoveCondition: (Condition: ConditionType) => void; + onSaveCondition: (newCondition: ConditionType, oldCondition: ConditionType) => void; + qualityGate: QualityGate; updatedConditionId?: number; } @@ -51,7 +58,7 @@ const FORBIDDEN_METRICS: string[] = [ ]; export class Conditions extends React.PureComponent<Props> { - renderConditionsTable = (conditions: T.Condition[], scope: 'new' | 'overall') => { + renderConditionsTable = (conditions: ConditionType[], scope: 'new' | 'overall') => { const { qualityGate, metrics, @@ -111,7 +118,7 @@ export class Conditions extends React.PureComponent<Props> { isDiffMetric(condition.metric) ); - const duplicates: T.Condition[] = []; + const duplicates: ConditionType[] = []; const savedConditions = existingConditions.filter(condition => condition.id != null); savedConditions.forEach(condition => { const sameCount = savedConditions.filter(sample => sample.metric === condition.metric).length; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx index fbace702f0e..7176ad5626f 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx @@ -25,11 +25,12 @@ import MandatoryFieldMarker from '../../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../../helpers/l10n'; import { getQualityGateUrl } from '../../../helpers/urls'; +import { QualityGate } from '../../../types/types'; interface Props { onClose: () => void; onCopy: () => Promise<void>; - qualityGate: T.QualityGate; + qualityGate: QualityGate; router: Pick<Router, 'push'>; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DeleteQualityGateForm.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/DeleteQualityGateForm.tsx index db52e78926a..db949d401d1 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DeleteQualityGateForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DeleteQualityGateForm.tsx @@ -24,10 +24,11 @@ import ConfirmButton from '../../../components/controls/ConfirmButton'; import { Router, withRouter } from '../../../components/hoc/withRouter'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getQualityGatesUrl } from '../../../helpers/urls'; +import { QualityGate } from '../../../types/types'; interface Props { onDelete: () => Promise<void>; - qualityGate: T.QualityGate; + qualityGate: QualityGate; router: Pick<Router, 'push'>; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Details.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Details.tsx index 9b7f5c7cd33..b7a10ee2de6 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Details.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Details.tsx @@ -26,19 +26,20 @@ import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate } from '../../../helpers/l10n'; import { fetchMetrics } from '../../../store/rootActions'; import { getMetrics, Store } from '../../../store/rootReducer'; +import { Condition, Dict, Metric, QualityGate } from '../../../types/types'; import { addCondition, checkIfDefault, deleteCondition, replaceCondition } from '../utils'; import DetailsContent from './DetailsContent'; import DetailsHeader from './DetailsHeader'; interface OwnProps { id: string; - onSetDefault: (qualityGate: T.QualityGate) => void; - qualityGates: T.QualityGate[]; + onSetDefault: (qualityGate: QualityGate) => void; + qualityGates: QualityGate[]; refreshQualityGates: () => Promise<void>; } interface StateToProps { - metrics: T.Dict<T.Metric>; + metrics: Dict<Metric>; } interface DispatchToProps { @@ -49,7 +50,7 @@ type Props = StateToProps & DispatchToProps & OwnProps; interface State { loading: boolean; - qualityGate?: T.QualityGate; + qualityGate?: QualityGate; updatedConditionId?: number; } @@ -90,7 +91,7 @@ export class Details extends React.PureComponent<Props, State> { ); }; - handleAddCondition = (condition: T.Condition) => { + handleAddCondition = (condition: Condition) => { this.setState(({ qualityGate }) => { if (!qualityGate) { return null; @@ -103,7 +104,7 @@ export class Details extends React.PureComponent<Props, State> { }); }; - handleSaveCondition = (newCondition: T.Condition, oldCondition: T.Condition) => { + handleSaveCondition = (newCondition: Condition, oldCondition: Condition) => { this.setState(({ qualityGate }) => { if (!qualityGate) { return null; @@ -116,7 +117,7 @@ export class Details extends React.PureComponent<Props, State> { }); }; - handleRemoveCondition = (condition: T.Condition) => { + handleRemoveCondition = (condition: Condition) => { this.setState(({ qualityGate }) => { if (!qualityGate) { return null; @@ -135,7 +136,7 @@ export class Details extends React.PureComponent<Props, State> { return null; } this.props.onSetDefault(qualityGate); - const newQualityGate: T.QualityGate = { + const newQualityGate: QualityGate = { ...qualityGate, actions: { ...qualityGate.actions, delete: false, setAsDefault: false } }; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.tsx index 07fc3d5179c..9fe3cd10007 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.tsx @@ -21,17 +21,18 @@ import * as React from 'react'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import { Alert } from '../../../components/ui/Alert'; import { translate } from '../../../helpers/l10n'; +import { Condition, Dict, Metric, QualityGate } from '../../../types/types'; import Conditions from './Conditions'; import Projects from './Projects'; import QualityGatePermissions from './QualityGatePermissions'; export interface DetailsContentProps { isDefault?: boolean; - metrics: T.Dict<T.Metric>; - onAddCondition: (condition: T.Condition) => void; - onRemoveCondition: (Condition: T.Condition) => void; - onSaveCondition: (newCondition: T.Condition, oldCondition: T.Condition) => void; - qualityGate: T.QualityGate; + metrics: Dict<Metric>; + onAddCondition: (condition: Condition) => void; + onRemoveCondition: (Condition: Condition) => void; + onSaveCondition: (newCondition: Condition, oldCondition: Condition) => void; + qualityGate: QualityGate; updatedConditionId?: number; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.tsx index 5bd11877f2a..f84de737e80 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.tsx @@ -23,6 +23,7 @@ import { Button } from '../../../components/controls/buttons'; import ModalButton from '../../../components/controls/ModalButton'; import Tooltip from '../../../components/controls/Tooltip'; import { translate } from '../../../helpers/l10n'; +import { QualityGate } from '../../../types/types'; import BuiltInQualityGateBadge from './BuiltInQualityGateBadge'; import CopyQualityGateForm from './CopyQualityGateForm'; import DeleteQualityGateForm from './DeleteQualityGateForm'; @@ -30,7 +31,7 @@ import RenameQualityGateForm from './RenameQualityGateForm'; interface Props { onSetDefault: () => void; - qualityGate: T.QualityGate; + qualityGate: QualityGate; refreshItem: () => Promise<void>; refreshList: () => Promise<void>; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/List.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/List.tsx index 873cb4e4870..e7dca0aaa67 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/List.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/List.tsx @@ -21,10 +21,11 @@ import * as React from 'react'; import { Link } from 'react-router'; import { translate } from '../../../helpers/l10n'; import { getQualityGateUrl } from '../../../helpers/urls'; +import { QualityGate } from '../../../types/types'; import BuiltInQualityGateBadge from './BuiltInQualityGateBadge'; interface Props { - qualityGates: T.QualityGate[]; + qualityGates: QualityGate[]; } export default function List({ qualityGates }: Props) { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/MetricSelect.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/MetricSelect.tsx index 089d6fafce2..7a213d430a5 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/MetricSelect.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/MetricSelect.tsx @@ -21,12 +21,13 @@ import { sortBy } from 'lodash'; import * as React from 'react'; import SelectLegacy from '../../../components/controls/SelectLegacy'; import { getLocalizedMetricDomain, translate } from '../../../helpers/l10n'; +import { Metric } from '../../../types/types'; import { getLocalizedMetricNameNoDiffMetric } from '../utils'; interface Props { - metric?: T.Metric; - metrics: T.Metric[]; - onMetricChange: (metric: T.Metric) => void; + metric?: Metric; + metrics: Metric[]; + onMetricChange: (metric: Metric) => void; } interface Option { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/PermissionItem.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/PermissionItem.tsx index 4c3067e598a..9d2558a05cc 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/PermissionItem.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/PermissionItem.tsx @@ -22,10 +22,11 @@ import { DeleteButton } from '../../../components/controls/buttons'; import GroupIcon from '../../../components/icons/GroupIcon'; import Avatar from '../../../components/ui/Avatar'; import { Group, isUser } from '../../../types/quality-gates'; +import { UserBase } from '../../../types/types'; export interface PermissionItemProps { - onClickDelete: (item: T.UserBase | Group) => void; - item: T.UserBase | Group; + onClickDelete: (item: UserBase | Group) => void; + item: UserBase | Group; } export default function PermissionItem(props: PermissionItemProps) { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx index ef0b28780ac..f7a57ab5233 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx @@ -29,10 +29,11 @@ import SelectList, { SelectListSearchParams } from '../../../components/controls/SelectList'; import { translate } from '../../../helpers/l10n'; +import { QualityGate } from '../../../types/types'; interface Props { canEdit?: boolean; - qualityGate: T.QualityGate; + qualityGate: QualityGate; } interface State { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissions.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissions.tsx index 2391486abe1..9844c11fd07 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissions.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissions.tsx @@ -28,10 +28,11 @@ import { searchUsers } from '../../../api/quality-gates'; import { Group, isUser, SearchPermissionsParameters } from '../../../types/quality-gates'; +import { QualityGate, UserBase } from '../../../types/types'; import QualityGatePermissionsRenderer from './QualityGatePermissionsRenderer'; interface Props { - qualityGate: T.QualityGate; + qualityGate: QualityGate; } interface State { @@ -39,8 +40,8 @@ interface State { submitting: boolean; loading: boolean; showAddModal: boolean; - permissionToDelete?: T.UserBase | Group; - users: T.UserBase[]; + permissionToDelete?: UserBase | Group; + users: UserBase[]; } export default class QualityGatePermissions extends React.Component<Props, State> { @@ -95,7 +96,7 @@ export default class QualityGatePermissions extends React.Component<Props, State this.setState({ showAddModal: true }); }; - handleSubmitAddPermission = async (item: T.UserBase | Group) => { + handleSubmitAddPermission = async (item: UserBase | Group) => { const { qualityGate } = this.props; this.setState({ submitting: true }); @@ -135,11 +136,11 @@ export default class QualityGatePermissions extends React.Component<Props, State this.setState({ permissionToDelete: undefined }); }; - handleClickDeletePermission = (permissionToDelete?: T.UserBase | Group) => { + handleClickDeletePermission = (permissionToDelete?: UserBase | Group) => { this.setState({ permissionToDelete }); }; - handleConfirmDeletePermission = async (item: T.UserBase | Group) => { + handleConfirmDeletePermission = async (item: UserBase | Group) => { const { qualityGate } = this.props; let error = false; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissionsAddModal.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissionsAddModal.tsx index a4ae9357c1b..18155f51d33 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissionsAddModal.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissionsAddModal.tsx @@ -21,20 +21,21 @@ import { debounce } from 'lodash'; import * as React from 'react'; import { searchGroups, searchUsers } from '../../../api/quality-gates'; import { Group, SearchPermissionsParameters } from '../../../types/quality-gates'; +import { QualityGate, UserBase } from '../../../types/types'; import QualityGatePermissionsAddModalRenderer from './QualityGatePermissionsAddModalRenderer'; interface Props { onClose: () => void; - onSubmit: (selection: T.UserBase | Group) => void; - qualityGate: T.QualityGate; + onSubmit: (selection: UserBase | Group) => void; + qualityGate: QualityGate; submitting: boolean; } interface State { loading: boolean; query?: string; - searchResults: Array<T.UserBase | Group>; - selection?: T.UserBase | Group; + searchResults: Array<UserBase | Group>; + selection?: UserBase | Group; } const DEBOUNCE_DELAY = 250; @@ -91,7 +92,7 @@ export default class QualityGatePermissionsAddModal extends React.Component<Prop } }; - handleSelection = (selection: T.UserBase | Group) => { + handleSelection = (selection: UserBase | Group) => { this.setState({ selection }); }; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissionsAddModalRenderer.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissionsAddModalRenderer.tsx index bf1dc1944a5..efbb83991fd 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissionsAddModalRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissionsAddModalRenderer.tsx @@ -25,20 +25,21 @@ import GroupIcon from '../../../components/icons/GroupIcon'; import Avatar from '../../../components/ui/Avatar'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { Group, isUser } from '../../../types/quality-gates'; +import { UserBase } from '../../../types/types'; export interface QualityGatePermissionsAddModalRendererProps { onClose: () => void; onInputChange: (query: string) => void; onSubmit: (event: React.SyntheticEvent<HTMLFormElement>) => void; - onSelection: (selection: T.UserBase | Group) => void; + onSelection: (selection: UserBase | Group) => void; submitting: boolean; loading: boolean; query: string; - searchResults: Array<T.UserBase | Group>; - selection?: T.UserBase | Group; + searchResults: Array<UserBase | Group>; + selection?: UserBase | Group; } -type Option = (T.UserBase | Group) & { value: string }; +type Option = (UserBase | Group) & { value: string }; export default function QualityGatePermissionsAddModalRenderer( props: QualityGatePermissionsAddModalRendererProps diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissionsRenderer.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissionsRenderer.tsx index aab84606c75..74dfc7a3851 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissionsRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatePermissionsRenderer.tsx @@ -24,6 +24,7 @@ import ConfirmModal from '../../../components/controls/ConfirmModal'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate } from '../../../helpers/l10n'; import { Group, isUser } from '../../../types/quality-gates'; +import { QualityGate, UserBase } from '../../../types/types'; import PermissionItem from './PermissionItem'; import QualityGatePermissionsAddModal from './QualityGatePermissionsAddModal'; @@ -32,15 +33,15 @@ export interface QualityGatePermissionsRendererProps { loading: boolean; onClickAddPermission: () => void; onCloseAddPermission: () => void; - onSubmitAddPermission: (item: T.UserBase | Group) => void; + onSubmitAddPermission: (item: UserBase | Group) => void; onCloseDeletePermission: () => void; - onConfirmDeletePermission: (item: T.UserBase | Group) => void; - onClickDeletePermission: (item: T.UserBase | Group) => void; - permissionToDelete?: T.UserBase | Group; - qualityGate: T.QualityGate; + onConfirmDeletePermission: (item: UserBase | Group) => void; + onClickDeletePermission: (item: UserBase | Group) => void; + permissionToDelete?: UserBase | Group; + qualityGate: QualityGate; showAddModal: boolean; submitting: boolean; - users: T.UserBase[]; + users: UserBase[]; } export default function QualityGatePermissionsRenderer(props: QualityGatePermissionsRendererProps) { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/RenameQualityGateForm.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/RenameQualityGateForm.tsx index 8113666ba3e..45dad5c864e 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/RenameQualityGateForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/RenameQualityGateForm.tsx @@ -23,11 +23,12 @@ import ConfirmModal from '../../../components/controls/ConfirmModal'; import MandatoryFieldMarker from '../../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../../helpers/l10n'; +import { QualityGate } from '../../../types/types'; interface Props { onClose: () => void; onRename: () => Promise<void>; - qualityGate: T.QualityGate; + qualityGate: QualityGate; } interface State { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/ThresholdInput.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/ThresholdInput.tsx index 1776243fe98..a2af32073f2 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/ThresholdInput.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/ThresholdInput.tsx @@ -19,11 +19,12 @@ */ import * as React from 'react'; import SelectLegacy from '../../../components/controls/SelectLegacy'; +import { Metric } from '../../../types/types'; interface Props { name: string; value: string; - metric: T.Metric; + metric: Metric; onChange: (value: string) => void; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/utils.ts b/server/sonar-web/src/main/js/apps/quality-gates/utils.ts index 146f820c9d3..edba64a5b11 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/utils.ts +++ b/server/sonar-web/src/main/js/apps/quality-gates/utils.ts @@ -21,29 +21,30 @@ import getStore from '../../app/utils/getStore'; import { getLocalizedMetricName } from '../../helpers/l10n'; import { isDiffMetric } from '../../helpers/measures'; import { getMetricByKey } from '../../store/rootReducer'; +import { Condition, Metric, QualityGate } from '../../types/types'; -export function checkIfDefault(qualityGate: T.QualityGate, list: T.QualityGate[]): boolean { +export function checkIfDefault(qualityGate: QualityGate, list: QualityGate[]): boolean { const finding = list.find(candidate => candidate.id === qualityGate.id); return (finding && finding.isDefault) || false; } -export function addCondition(qualityGate: T.QualityGate, condition: T.Condition): T.QualityGate { +export function addCondition(qualityGate: QualityGate, condition: Condition): QualityGate { const oldConditions = qualityGate.conditions || []; const conditions = [...oldConditions, condition]; return { ...qualityGate, conditions }; } -export function deleteCondition(qualityGate: T.QualityGate, condition: T.Condition): T.QualityGate { +export function deleteCondition(qualityGate: QualityGate, condition: Condition): QualityGate { const conditions = qualityGate.conditions && qualityGate.conditions.filter(candidate => candidate !== condition); return { ...qualityGate, conditions }; } export function replaceCondition( - qualityGate: T.QualityGate, - newCondition: T.Condition, - oldCondition: T.Condition -): T.QualityGate { + qualityGate: QualityGate, + newCondition: Condition, + oldCondition: Condition +): QualityGate { const conditions = qualityGate.conditions && qualityGate.conditions.map(candidate => { @@ -52,7 +53,7 @@ export function replaceCondition( return { ...qualityGate, conditions }; } -export function getPossibleOperators(metric: T.Metric) { +export function getPossibleOperators(metric: Metric) { if (metric.direction === 1) { return 'LT'; } else if (metric.direction === -1) { @@ -66,7 +67,7 @@ export function metricKeyExists(key: string) { return getMetricByKey(getStore().getState(), key) !== undefined; } -function getNoDiffMetric(metric: T.Metric) { +function getNoDiffMetric(metric: Metric) { const store = getStore().getState(); const regularMetricKey = metric.key.replace(/^new_/, ''); if (isDiffMetric(metric.key) && metricKeyExists(regularMetricKey)) { @@ -78,6 +79,6 @@ function getNoDiffMetric(metric: T.Metric) { } } -export function getLocalizedMetricNameNoDiffMetric(metric: T.Metric) { +export function getLocalizedMetricNameNoDiffMetric(metric: Metric) { return getLocalizedMetricName(getNoDiffMetric(metric)); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.tsx index ef0d100ba13..44bfa0560b2 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.tsx @@ -18,11 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Dict } from '../../../types/types'; import ParameterChange from './ParameterChange'; import SeverityChange from './SeverityChange'; interface Props { - changes: T.Dict<string | null>; + changes: Dict<string | null>; } export default function ChangesList({ changes }: Props) { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultActivation.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultActivation.tsx index c74b3c05461..2b09c0fd60f 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultActivation.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResultActivation.tsx @@ -24,6 +24,7 @@ import { Button } from '../../../components/controls/buttons'; import { lazyLoadComponent } from '../../../components/lazyLoadComponent'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate } from '../../../helpers/l10n'; +import { RuleDetails } from '../../../types/types'; const ActivationFormModal = lazyLoadComponent( () => import('../../coding-rules/components/ActivationFormModal'), @@ -37,7 +38,7 @@ interface Props { } interface State { - rule?: T.RuleDetails; + rule?: RuleDetails; state: 'closed' | 'opening' | 'open'; } @@ -73,7 +74,7 @@ export default class ComparisonResultActivation extends React.PureComponent<Prop this.setState({ state: 'closed' }); }; - isOpen(state: State): state is { state: 'open'; rule: T.RuleDetails } { + isOpen(state: State): state is { state: 'open'; rule: RuleDetails } { return state.state === 'open'; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx index 172fde88c4e..8265721ef32 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx @@ -25,10 +25,11 @@ import ChevronRightIcon from '../../../components/icons/ChevronRightIcon'; import SeverityIcon from '../../../components/icons/SeverityIcon'; import { translateWithParameters } from '../../../helpers/l10n'; import { getRulesUrl } from '../../../helpers/urls'; +import { Dict } from '../../../types/types'; import ComparisonEmpty from './ComparisonEmpty'; import ComparisonResultActivation from './ComparisonResultActivation'; -type Params = T.Dict<string>; +type Params = Dict<string>; interface Props extends CompareResponse { leftProfile: Profile; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx index 883481de687..2f7ee6c757a 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx @@ -22,13 +22,14 @@ import { Helmet } from 'react-helmet-async'; import { Actions, getExporters, searchQualityProfiles } from '../../../api/quality-profiles'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import { translate } from '../../../helpers/l10n'; +import { Languages } from '../../../types/types'; import '../styles.css'; import { Exporter, Profile } from '../types'; import { sortProfiles } from '../utils'; interface Props { children: React.ReactElement<any>; - languages: T.Languages; + languages: Languages; } interface State { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx index 1ff81921b64..bbb0f39c358 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx @@ -22,6 +22,7 @@ import * as React from 'react'; import { getProfileInheritance } from '../../../api/quality-profiles'; import { Button } from '../../../components/controls/buttons'; import { translate } from '../../../helpers/l10n'; +import { ProfileInheritanceDetails } from '../../../types/types'; import { Profile } from '../types'; import ChangeParentForm from './ChangeParentForm'; import ProfileInheritanceBox from './ProfileInheritanceBox'; @@ -33,11 +34,11 @@ interface Props { } interface State { - ancestors?: T.ProfileInheritanceDetails[]; - children?: T.ProfileInheritanceDetails[]; + ancestors?: ProfileInheritanceDetails[]; + children?: ProfileInheritanceDetails[]; formOpen: boolean; loading: boolean; - profile?: T.ProfileInheritanceDetails; + profile?: ProfileInheritanceDetails; } export default class ProfileInheritance extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx index d3fad78f1d1..3113a7b8c28 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx @@ -21,6 +21,7 @@ import classNames from 'classnames'; import * as React from 'react'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { ProfileInheritanceDetails } from '../../../types/types'; import BuiltInQualityProfileBadge from '../components/BuiltInQualityProfileBadge'; import ProfileLink from '../components/ProfileLink'; @@ -30,7 +31,7 @@ interface Props { displayLink?: boolean; extendsBuiltIn?: boolean; language: string; - profile: T.ProfileInheritanceDetails; + profile: ProfileInheritanceDetails; type?: string; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx index b3f42f3adfc..01d64856682 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx @@ -26,6 +26,7 @@ import { } from '../../../api/quality-profiles'; import { Button } from '../../../components/controls/buttons'; import { translate } from '../../../helpers/l10n'; +import { UserSelected } from '../../../types/types'; import { Profile } from '../types'; import ProfilePermissionsForm from './ProfilePermissionsForm'; import ProfilePermissionsGroup from './ProfilePermissionsGroup'; @@ -43,7 +44,7 @@ interface State { addUserForm: boolean; groups?: Group[]; loading: boolean; - users?: T.UserSelected[]; + users?: UserSelected[]; } export default class ProfilePermissions extends React.PureComponent<Props, State> { @@ -101,7 +102,7 @@ export default class ProfilePermissions extends React.PureComponent<Props, State } }; - handleUserAdd = (addedUser: T.UserSelected) => { + handleUserAdd = (addedUser: UserSelected) => { if (this.mounted) { this.setState((state: State) => ({ addUserForm: false, @@ -110,7 +111,7 @@ export default class ProfilePermissions extends React.PureComponent<Props, State } }; - handleUserDelete = (removedUser: T.UserSelected) => { + handleUserDelete = (removedUser: UserSelected) => { if (this.mounted) { this.setState((state: State) => ({ users: state.users && state.users.filter(user => user !== removedUser) @@ -118,7 +119,7 @@ export default class ProfilePermissions extends React.PureComponent<Props, State } }; - handleGroupAdd = (addedGroup: T.Group) => { + handleGroupAdd = (addedGroup: Group) => { if (this.mounted) { this.setState((state: State) => ({ addUserForm: false, @@ -127,7 +128,7 @@ export default class ProfilePermissions extends React.PureComponent<Props, State } }; - handleGroupDelete = (removedGroup: T.Group) => { + handleGroupDelete = (removedGroup: Group) => { if (this.mounted) { this.setState((state: State) => ({ groups: state.groups && state.groups.filter(group => group !== removedGroup) diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx index 216aadd8f06..361bae1eccf 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx @@ -28,18 +28,19 @@ import { import { ResetButtonLink, SubmitButton } from '../../../components/controls/buttons'; import Modal from '../../../components/controls/Modal'; import { translate } from '../../../helpers/l10n'; +import { UserSelected } from '../../../types/types'; import { Group } from './ProfilePermissions'; import ProfilePermissionsFormSelect from './ProfilePermissionsFormSelect'; interface Props { onClose: () => void; onGroupAdd: (group: Group) => void; - onUserAdd: (user: T.UserSelected) => void; + onUserAdd: (user: UserSelected) => void; profile: { language: string; name: string }; } interface State { - selected?: T.UserSelected | Group; + selected?: UserSelected | Group; submitting: boolean; } @@ -61,7 +62,7 @@ export default class ProfilePermissionsForm extends React.PureComponent<Props, S } }; - handleUserAdd = (user: T.UserSelected) => { + handleUserAdd = (user: UserSelected) => { const { profile: { language, name } } = this.props; @@ -88,8 +89,8 @@ export default class ProfilePermissionsForm extends React.PureComponent<Props, S const { selected } = this.state; if (selected) { this.setState({ submitting: true }); - if ((selected as T.UserSelected).login !== undefined) { - this.handleUserAdd(selected as T.UserSelected); + if ((selected as UserSelected).login !== undefined) { + this.handleUserAdd(selected as UserSelected); } else { this.handleGroupAdd(selected as Group); } @@ -113,7 +114,7 @@ export default class ProfilePermissionsForm extends React.PureComponent<Props, S ]); }; - handleValueChange = (selected: T.UserSelected | Group) => { + handleValueChange = (selected: UserSelected | Group) => { this.setState({ selected }); }; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsFormSelect.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsFormSelect.tsx index df95a313f11..08a848ce414 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsFormSelect.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsFormSelect.tsx @@ -23,9 +23,10 @@ import SelectLegacy from '../../../components/controls/SelectLegacy'; import GroupIcon from '../../../components/icons/GroupIcon'; import Avatar from '../../../components/ui/Avatar'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { UserSelected } from '../../../types/types'; import { Group } from './ProfilePermissions'; -type Option = T.UserSelected | Group; +type Option = UserSelected | Group; type OptionWithValue = Option & { value: string }; interface Props { @@ -112,8 +113,8 @@ export default class ProfilePermissionsFormSelect extends React.PureComponent<Pr } } -function isUser(option: Option): option is T.UserSelected { - return (option as T.UserSelected).login !== undefined; +function isUser(option: Option): option is UserSelected { + return (option as UserSelected).login !== undefined; } function getStringValue(option: Option) { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsUser.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsUser.tsx index 899c3f906cf..0eb0d015887 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsUser.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsUser.tsx @@ -24,11 +24,12 @@ import { DeleteButton, ResetButtonLink, SubmitButton } from '../../../components import SimpleModal, { ChildrenProps } from '../../../components/controls/SimpleModal'; import Avatar from '../../../components/ui/Avatar'; import { translate } from '../../../helpers/l10n'; +import { UserSelected } from '../../../types/types'; interface Props { - onDelete: (user: T.UserSelected) => void; + onDelete: (user: UserSelected) => void; profile: { language: string; name: string }; - user: T.UserSelected; + user: UserSelected; } interface State { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx index c1be69c17e7..bad314f084c 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx @@ -26,6 +26,7 @@ import { Button } from '../../../components/controls/buttons'; import Tooltip from '../../../components/controls/Tooltip'; import { translate } from '../../../helpers/l10n'; import { getRulesUrl } from '../../../helpers/urls'; +import { Dict } from '../../../types/types'; import { Profile } from '../types'; import ProfileRulesDeprecatedWarning from './ProfileRulesDeprecatedWarning'; import ProfileRulesRowOfType from './ProfileRulesRowOfType'; @@ -45,8 +46,8 @@ interface ByType { interface State { activatedTotal: number | null; - activatedByType: T.Dict<ByType>; - allByType: T.Dict<ByType>; + activatedByType: Dict<ByType>; + allByType: Dict<ByType>; compareToSonarWay: { profile: string; profileName: string; missingRuleCount: number } | null; total: number | null; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsForm-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsForm-test.tsx index 42d21ab29a2..d0ae297ef8d 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsForm-test.tsx @@ -22,6 +22,7 @@ import * as React from 'react'; import { addGroup, addUser, searchGroups, searchUsers } from '../../../../api/quality-profiles'; import { mockGroup, mockUser } from '../../../../helpers/testMocks'; import { submit, waitAndUpdate } from '../../../../helpers/testUtils'; +import { UserSelected } from '../../../../types/types'; import ProfilePermissionsForm from '../ProfilePermissionsForm'; import ProfilePermissionsFormSelect from '../ProfilePermissionsFormSelect'; @@ -43,7 +44,7 @@ it('correctly adds users', async () => { const onUserAdd = jest.fn(); const wrapper = shallowRender({ onUserAdd }); - const user: T.UserSelected = { ...mockUser(), name: 'John doe', active: true, selected: true }; + const user: UserSelected = { ...mockUser(), name: 'John doe', active: true, selected: true }; wrapper.instance().handleValueChange(user); expect(wrapper.find(ProfilePermissionsFormSelect).prop('selected')).toBe(user); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx index 7ba649fe3c3..57b11605b55 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfilePermissionsUser-test.tsx @@ -21,6 +21,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { removeUser } from '../../../../api/quality-profiles'; import { click } from '../../../../helpers/testUtils'; +import { UserSelected } from '../../../../types/types'; import ProfilePermissionsUser from '../ProfilePermissionsUser'; jest.mock('../../../../api/quality-profiles', () => ({ @@ -28,7 +29,7 @@ jest.mock('../../../../api/quality-profiles', () => ({ })); const profile = { language: 'js', name: 'Sonar way' }; -const user: T.UserSelected = { login: 'luke', name: 'Luke Skywalker', selected: true }; +const user: UserSelected = { login: 'luke', name: 'Luke Skywalker', selected: true }; beforeEach(() => { jest.clearAllMocks(); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx index e22e81e2460..03c084b8498 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx @@ -25,17 +25,18 @@ import { toShortNotSoISOString } from '../../../helpers/dates'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; import { getRulesUrl } from '../../../helpers/urls'; +import { Dict, Rule, RuleActivation } from '../../../types/types'; const RULES_LIMIT = 10; -function parseRules(rules: T.Rule[], actives?: T.Dict<T.RuleActivation[]>): ExtendedRule[] { +function parseRules(rules: Rule[], actives?: Dict<RuleActivation[]>): ExtendedRule[] { return rules.map(rule => { const activations = actives && actives[rule.key]; return { ...rule, activations: activations ? activations.length : 0 }; }); } -interface ExtendedRule extends T.Rule { +interface ExtendedRule extends Rule { activations: number; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx index c1256df0850..8e3e02902fa 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesList.tsx @@ -23,12 +23,13 @@ import * as React from 'react'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import { Alert } from '../../../components/ui/Alert'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Dict, Language } from '../../../types/types'; import { Profile } from '../types'; import ProfilesListHeader from './ProfilesListHeader'; import ProfilesListRow from './ProfilesListRow'; interface Props { - languages: T.Language[]; + languages: Language[]; location: Pick<Location, 'query'>; profiles: Profile[]; updateProfiles: () => Promise<void>; @@ -95,10 +96,7 @@ export default class ProfilesList extends React.PureComponent<Props> { const { profiles, languages } = this.props; const { language } = this.props.location.query; - const profilesIndex: T.Dict<Profile[]> = groupBy<Profile>( - profiles, - profile => profile.language - ); + const profilesIndex: Dict<Profile[]> = groupBy<Profile>(profiles, profile => profile.language); const profilesToShow = language ? pick(profilesIndex, language) : profilesIndex; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/types.ts b/server/sonar-web/src/main/js/apps/quality-profiles/types.ts index 03c64fcac44..6c6e9c17008 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/types.ts +++ b/server/sonar-web/src/main/js/apps/quality-profiles/types.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { Profile as BaseProfile } from '../../api/quality-profiles'; +import { Dict } from '../../types/types'; export interface Profile extends BaseProfile { depth: number; @@ -34,7 +35,7 @@ export interface ProfileChangelogEvent { action: string; authorName: string; date: string; - params?: T.Dict<string | null>; + params?: Dict<string | null>; ruleKey: string; ruleName: string; } diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx index 12a879b338e..4d6f1f2a08e 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx @@ -40,6 +40,7 @@ import { HotspotStatusFilter, RawHotspot } from '../../types/security-hotspots'; +import { Component, CurrentUser, Dict } from '../../types/types'; import SecurityHotspotsAppRenderer from './SecurityHotspotsAppRenderer'; import './styles.css'; import { SECURITY_STANDARDS } from './utils'; @@ -52,8 +53,8 @@ interface DispatchProps { interface OwnProps { branchLike?: BranchLike; - currentUser: T.CurrentUser; - component: T.Component; + currentUser: CurrentUser; + component: Component; location: Location; router: Router; } @@ -270,7 +271,7 @@ export class SecurityHotspotsApp extends React.PureComponent<Props, State> { } if (filterByCategory || filterByCWE || filterByFile) { - const hotspotFilters: T.Dict<string> = {}; + const hotspotFilters: Dict<string> = {}; if (filterByCategory) { hotspotFilters[filterByCategory.standard] = filterByCategory.category; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsAppRenderer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsAppRenderer.tsx index 8976984bdde..a9e353e1771 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsAppRenderer.tsx @@ -29,6 +29,7 @@ import { scrollToElement } from '../../helpers/scrolling'; import { BranchLike } from '../../types/branch-like'; import { SecurityStandard, Standards } from '../../types/security'; import { HotspotFilters, HotspotStatusFilter, RawHotspot } from '../../types/security-hotspots'; +import { Component, StandardSecurityCategories } from '../../types/types'; import EmptyHotspotsPage from './components/EmptyHotspotsPage'; import FilterBar from './components/FilterBar'; import HotspotList from './components/HotspotList'; @@ -38,7 +39,7 @@ import './styles.css'; export interface SecurityHotspotsAppRendererProps { branchLike?: BranchLike; - component: T.Component; + component: Component; filterByCategory?: { standard: SecurityStandard; category: string; @@ -60,7 +61,7 @@ export interface SecurityHotspotsAppRendererProps { onSwitchStatusFilter: (option: HotspotStatusFilter) => void; onUpdateHotspot: (hotspotKey: string) => Promise<void>; selectedHotspot: RawHotspot | undefined; - securityCategories: T.StandardSecurityCategories; + securityCategories: StandardSecurityCategories; standards: Standards; } diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/utils-test.ts index 295b6bc6714..2f45f29a9da 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/utils-test.ts @@ -27,6 +27,7 @@ import { ReviewHistoryType, RiskExposure } from '../../../types/security-hotspots'; +import { IssueChangelog } from '../../../types/types'; import { getHotspotReviewHistory, getStatusAndResolutionFromStatusOption, @@ -152,7 +153,7 @@ describe('mapRules', () => { describe('getHotspotReviewHistory', () => { it('should properly create the review history', () => { - const changelogElement: T.IssueChangelog = { + const changelogElement: IssueChangelog = { creationDate: '2018-10-01', isUserActive: true, user: 'me', diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/FilterBar.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/FilterBar.tsx index ffbb0d81a72..9c5df620fc3 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/FilterBar.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/FilterBar.tsx @@ -29,10 +29,11 @@ import { translate } from '../../../helpers/l10n'; import { isLoggedIn } from '../../../helpers/users'; import { ComponentQualifier } from '../../../types/component'; import { HotspotFilters, HotspotStatusFilter } from '../../../types/security-hotspots'; +import { Component, CurrentUser } from '../../../types/types'; export interface FilterBarProps { - currentUser: T.CurrentUser; - component: T.Component; + currentUser: CurrentUser; + component: Component; filters: HotspotFilters; hotspotsReviewedMeasure?: string; isStaticListOfHotspots: boolean; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotList.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotList.tsx index 3f73800926e..25683e66923 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotList.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotList.tsx @@ -25,6 +25,7 @@ import SecurityHotspotIcon from '../../../components/icons/SecurityHotspotIcon'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { addSideBarClass, removeSideBarClass } from '../../../helpers/pages'; import { HotspotStatusFilter, RawHotspot, RiskExposure } from '../../../types/security-hotspots'; +import { Dict, StandardSecurityCategories } from '../../../types/types'; import { groupByCategory, RISK_EXPOSURE_LEVELS } from '../utils'; import HotspotCategory from './HotspotCategory'; import './HotspotList.css'; @@ -36,13 +37,13 @@ interface Props { loadingMore: boolean; onHotspotClick: (hotspot: RawHotspot) => void; onLoadMore: () => void; - securityCategories: T.StandardSecurityCategories; + securityCategories: StandardSecurityCategories; selectedHotspot: RawHotspot; statusFilter: HotspotStatusFilter; } interface State { - expandedCategories: T.Dict<boolean>; + expandedCategories: Dict<boolean>; groupedHotspots: Array<{ risk: RiskExposure; categories: Array<{ key: string; hotspots: RawHotspot[]; title: string }>; @@ -88,7 +89,7 @@ export default class HotspotList extends React.Component<Props, State> { removeSideBarClass(); } - groupHotspots = (hotspots: RawHotspot[], securityCategories: T.StandardSecurityCategories) => { + groupHotspots = (hotspots: RawHotspot[], securityCategories: StandardSecurityCategories) => { const risks = groupBy(hotspots, h => h.vulnerabilityProbability); return RISK_EXPOSURE_LEVELS.map(risk => ({ diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotReviewHistoryAndComments.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotReviewHistoryAndComments.tsx index b358850b3ca..cfac5a9fb5e 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotReviewHistoryAndComments.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotReviewHistoryAndComments.tsx @@ -28,10 +28,11 @@ import { Button } from '../../../components/controls/buttons'; import { translate } from '../../../helpers/l10n'; import { isLoggedIn } from '../../../helpers/users'; import { Hotspot } from '../../../types/security-hotspots'; +import { CurrentUser } from '../../../types/types'; import HotspotReviewHistory from './HotspotReviewHistory'; interface Props { - currentUser: T.CurrentUser; + currentUser: CurrentUser; hotspot: Hotspot; commentTextRef: React.RefObject<HTMLTextAreaElement>; onCommentUpdate: () => void; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainer.tsx index c8fad003104..d438c65123d 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainer.tsx @@ -24,12 +24,13 @@ import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { BranchLike } from '../../../types/branch-like'; import { ComponentQualifier } from '../../../types/component'; import { Hotspot } from '../../../types/security-hotspots'; +import { Component, ExpandDirection, SourceLine } from '../../../types/types'; import { constructSourceViewerFile } from '../utils'; import HotspotSnippetContainerRenderer from './HotspotSnippetContainerRenderer'; interface Props { branchLike?: BranchLike; - component: T.Component; + component: Component; hotspot: Hotspot; } @@ -37,7 +38,7 @@ interface State { highlightedSymbols: string[]; lastLine?: number; loading: boolean; - sourceLines: T.SourceLine[]; + sourceLines: SourceLine[]; } const BUFFER_LINES = 5; @@ -66,7 +67,7 @@ export default class HotspotSnippetContainer extends React.Component<Props, Stat this.mounted = false; } - checkLastLine(lines: T.SourceLine[], target: number): number | undefined { + checkLastLine(lines: SourceLine[], target: number): number | undefined { if (lines.length < 1) { return undefined; } @@ -100,7 +101,7 @@ export default class HotspotSnippetContainer extends React.Component<Props, Stat from, to, ...getBranchLikeQuery(branchLike) - }).catch(() => [] as T.SourceLine[]); + }).catch(() => [] as SourceLine[]); if (this.mounted) { const lastLine = this.checkLastLine(sourceLines, to); @@ -111,7 +112,7 @@ export default class HotspotSnippetContainer extends React.Component<Props, Stat } } - handleExpansion = (direction: T.ExpandDirection) => { + handleExpansion = (direction: ExpandDirection) => { const { branchLike, hotspot } = this.props; const { sourceLines } = this.state; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainerRenderer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainerRenderer.tsx index 975abfb7dbf..176eb60a749 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainerRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotSnippetContainerRenderer.tsx @@ -24,6 +24,12 @@ import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; import { Hotspot } from '../../../types/security-hotspots'; +import { + ExpandDirection, + LinearIssueLocation, + SourceLine, + SourceViewerFile +} from '../../../types/types'; import SnippetViewer from '../../issues/crossComponentSourceViewer/SnippetViewer'; export interface HotspotSnippetContainerRendererProps { @@ -32,11 +38,11 @@ export interface HotspotSnippetContainerRendererProps { highlightedSymbols: string[]; hotspot: Hotspot; loading: boolean; - locations: { [line: number]: T.LinearIssueLocation[] }; - onExpandBlock: (direction: T.ExpandDirection) => Promise<void>; + locations: { [line: number]: LinearIssueLocation[] }; + onExpandBlock: (direction: ExpandDirection) => Promise<void>; onSymbolClick: (symbols: string[]) => void; - sourceLines: T.SourceLine[]; - sourceViewerFile: T.SourceViewerFile; + sourceLines: SourceLine[]; + sourceViewerFile: SourceViewerFile; } const noop = () => undefined; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.tsx index 6751bb68ab7..d96a5a74a13 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.tsx @@ -26,17 +26,18 @@ import { HotspotStatusFilter, HotspotStatusOption } from '../../../types/security-hotspots'; +import { Component, StandardSecurityCategories } from '../../../types/types'; import { getStatusFilterFromStatusOption } from '../utils'; import HotspotViewerRenderer from './HotspotViewerRenderer'; interface Props { branchLike?: BranchLike; - component: T.Component; + component: Component; hotspotKey: string; hotspotsReviewedMeasure?: string; onSwitchStatusFilter: (option: HotspotStatusFilter) => void; onUpdateHotspot: (hotspotKey: string) => Promise<void>; - securityCategories: T.StandardSecurityCategories; + securityCategories: StandardSecurityCategories; } interface State { diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewerRenderer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewerRenderer.tsx index 8b0e0a1bf3c..ce30e9a574b 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewerRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewerRenderer.tsx @@ -35,6 +35,7 @@ import { import { isLoggedIn } from '../../../helpers/users'; import { BranchLike } from '../../../types/branch-like'; import { Hotspot, HotspotStatusOption } from '../../../types/security-hotspots'; +import { Component, CurrentUser, StandardSecurityCategories } from '../../../types/types'; import Assignee from './assignee/Assignee'; import HotspotOpenInIdeButton from './HotspotOpenInIdeButton'; import HotspotReviewHistoryAndComments from './HotspotReviewHistoryAndComments'; @@ -46,8 +47,8 @@ import StatusUpdateSuccessModal from './StatusUpdateSuccessModal'; export interface HotspotViewerRendererProps { branchLike?: BranchLike; - component: T.Component; - currentUser: T.CurrentUser; + component: Component; + currentUser: CurrentUser; hotspot?: Hotspot; hotspotsReviewedMeasure?: string; lastStatusChangedTo?: HotspotStatusOption; @@ -58,7 +59,7 @@ export interface HotspotViewerRendererProps { onShowCommentForm: () => void; onSwitchFilterToStatusOfUpdatedHotspot: () => void; showStatusUpdateSuccessModal: boolean; - securityCategories: T.StandardSecurityCategories; + securityCategories: StandardSecurityCategories; } export function HotspotViewerRenderer(props: HotspotViewerRendererProps) { diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/Assignee.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/Assignee.tsx index dbc6c822822..31f38449e4f 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/Assignee.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/Assignee.tsx @@ -24,10 +24,11 @@ import { withCurrentUser } from '../../../../components/hoc/withCurrentUser'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; import { isLoggedIn } from '../../../../helpers/users'; import { Hotspot, HotspotStatus } from '../../../../types/security-hotspots'; +import { CurrentUser, UserActive } from '../../../../types/types'; import AssigneeRenderer from './AssigneeRenderer'; interface Props { - currentUser: T.CurrentUser; + currentUser: CurrentUser; hotspot: Hotspot; onAssigneeChange: () => void; @@ -61,7 +62,7 @@ export class Assignee extends React.PureComponent<Props, State> { this.setState({ editing: false }); }; - handleAssign = (newAssignee: T.UserActive) => { + handleAssign = (newAssignee: UserActive) => { this.setState({ loading: true }); assignSecurityHotspot(this.props.hotspot.key, { assignee: newAssignee?.login diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeRenderer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeRenderer.tsx index 78235489ac5..fd9c476240f 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeRenderer.tsx @@ -23,6 +23,7 @@ import EscKeydownHandler from '../../../../components/controls/EscKeydownHandler import OutsideClickHandler from '../../../../components/controls/OutsideClickHandler'; import DeferredSpinner from '../../../../components/ui/DeferredSpinner'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; +import { LoggedInUser, UserActive, UserBase } from '../../../../types/types'; import AssigneeSelection from './AssigneeSelection'; export interface AssigneeRendererProps { @@ -30,10 +31,10 @@ export interface AssigneeRendererProps { editing: boolean; loading: boolean; - assignee?: T.UserBase; - loggedInUser?: T.LoggedInUser; + assignee?: UserBase; + loggedInUser?: LoggedInUser; - onAssign: (user: T.UserActive) => void; + onAssign: (user: UserActive) => void; onEnterEditionMode: () => void; onExitEditionMode: () => void; } diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeSelection.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeSelection.tsx index 4469a4d3d6b..7e46c9ca59c 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeSelection.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeSelection.tsx @@ -23,22 +23,23 @@ import { searchUsers } from '../../../../api/users'; import { KeyboardCodes } from '../../../../helpers/keycodes'; import { translate } from '../../../../helpers/l10n'; import { isUserActive } from '../../../../helpers/users'; +import { LoggedInUser, UserActive } from '../../../../types/types'; import AssigneeSelectionRenderer from './AssigneeSelectionRenderer'; interface Props { allowCurrentUserSelection: boolean; - loggedInUser: T.LoggedInUser; - onSelect: (user: T.UserActive) => void; + loggedInUser: LoggedInUser; + onSelect: (user: UserActive) => void; } interface State { - highlighted?: T.UserActive; + highlighted?: UserActive; loading: boolean; query?: string; - suggestedUsers: T.UserActive[]; + suggestedUsers: UserActive[]; } -const UNASSIGNED: T.UserActive = { login: '', name: translate('unassigned') }; +const UNASSIGNED: UserActive = { login: '', name: translate('unassigned') }; export default class AssigneeSelection extends React.PureComponent<Props, State> { mounted = false; @@ -92,7 +93,7 @@ export default class AssigneeSelection extends React.PureComponent<Props, State> this.setState({ loading: false, query, - suggestedUsers: (result.users.filter(isUserActive) as T.UserActive[]).concat(UNASSIGNED) + suggestedUsers: (result.users.filter(isUserActive) as UserActive[]).concat(UNASSIGNED) }); } }) diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeSelectionRenderer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeSelectionRenderer.tsx index a7add0ef13e..f958dcb6d94 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeSelectionRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/AssigneeSelectionRenderer.tsx @@ -25,16 +25,17 @@ import Avatar from '../../../../components/ui/Avatar'; import DeferredSpinner from '../../../../components/ui/DeferredSpinner'; import { PopupPlacement } from '../../../../components/ui/popups'; import { translate } from '../../../../helpers/l10n'; +import { UserActive } from '../../../../types/types'; import './AssigneeSelection.css'; export interface HotspotAssigneeSelectRendererProps { - highlighted?: T.UserActive; + highlighted?: UserActive; loading: boolean; onKeyDown: (event: React.KeyboardEvent) => void; onSearch: (query: string) => void; - onSelect: (user?: T.UserActive) => void; + onSelect: (user?: UserActive) => void; query?: string; - suggestedUsers?: T.UserActive[]; + suggestedUsers?: UserActive[]; } export default function AssigneeSelectionRenderer(props: HotspotAssigneeSelectRendererProps) { diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/Assignee-test.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/Assignee-test.tsx index ce18db2a847..a882f9760cf 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/Assignee-test.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/Assignee-test.tsx @@ -25,6 +25,7 @@ import { mockHotspot } from '../../../../../helpers/mocks/security-hotspots'; import { mockCurrentUser, mockUser } from '../../../../../helpers/testMocks'; import { waitAndUpdate } from '../../../../../helpers/testUtils'; import { HotspotStatus } from '../../../../../types/security-hotspots'; +import { UserActive } from '../../../../../types/types'; import { Assignee } from '../Assignee'; import AssigneeRenderer from '../AssigneeRenderer'; @@ -58,9 +59,9 @@ it('should handle edition event correctly', () => { }); it.each([ - ['assign to user', mockUser() as T.UserActive], - ['unassign', { login: '', name: 'unassigned' } as T.UserActive] -])('should handle %s event', async (_, user: T.UserActive) => { + ['assign to user', mockUser() as UserActive], + ['unassign', { login: '', name: 'unassigned' } as UserActive] +])('should handle %s event', async (_, user: UserActive) => { const hotspot = mockHotspot(); const onAssigneeChange = jest.fn(); diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/AssigneeRenderer-test.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/AssigneeRenderer-test.tsx index 7d5e5140cc6..7766cbb21b4 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/AssigneeRenderer-test.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/AssigneeRenderer-test.tsx @@ -23,6 +23,7 @@ import { EditButton } from '../../../../../components/controls/buttons'; import OutsideClickHandler from '../../../../../components/controls/OutsideClickHandler'; import { mockLoggedInUser, mockUser } from '../../../../../helpers/testMocks'; import { click } from '../../../../../helpers/testUtils'; +import { UserActive } from '../../../../../types/types'; import AssigneeRenderer, { AssigneeRendererProps } from '../AssigneeRenderer'; import AssigneeSelection from '../AssigneeSelection'; @@ -57,7 +58,7 @@ it('should propagate calls correctly', () => { wrapper .find(AssigneeSelection) .props() - .onSelect(newAssignee as T.UserActive); + .onSelect(newAssignee as UserActive); expect(onAssign).toHaveBeenCalledWith(newAssignee); wrapper diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/AssigneeSelection-test.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/AssigneeSelection-test.tsx index 73fa3302350..5b200d3c85f 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/AssigneeSelection-test.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/AssigneeSelection-test.tsx @@ -23,6 +23,7 @@ import { searchUsers } from '../../../../../api/users'; import { KeyboardCodes } from '../../../../../helpers/keycodes'; import { mockLoggedInUser, mockUser } from '../../../../../helpers/testMocks'; import { waitAndUpdate } from '../../../../../helpers/testUtils'; +import { UserActive } from '../../../../../types/types'; import AssigneeSelection from '../AssigneeSelection'; jest.mock('../../../../../api/users', () => ({ @@ -36,9 +37,9 @@ it('should render correctly', () => { it('should handle keydown', () => { const mockEvent = (code: KeyboardCodes) => ({ preventDefault: jest.fn(), nativeEvent: { code } }); const suggestedUsers = [ - mockUser({ login: '1' }) as T.UserActive, - mockUser({ login: '2' }) as T.UserActive, - mockUser({ login: '3' }) as T.UserActive + mockUser({ login: '1' }) as UserActive, + mockUser({ login: '2' }) as UserActive, + mockUser({ login: '3' }) as UserActive ]; const onSelect = jest.fn(); diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/AssigneeSelectionRenderer-test.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/AssigneeSelectionRenderer-test.tsx index e0694d8ef2b..a4a49944f80 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/AssigneeSelectionRenderer-test.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/assignee/__tests__/AssigneeSelectionRenderer-test.tsx @@ -20,6 +20,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { mockUser } from '../../../../../helpers/testMocks'; +import { UserActive } from '../../../../../types/types'; import AssigneeSelectionRenderer, { HotspotAssigneeSelectRendererProps } from '../AssigneeSelectionRenderer'; @@ -28,17 +29,17 @@ it('should render correctly', () => { expect(shallowRender()).toMatchSnapshot(); expect(shallowRender({ loading: true })).toMatchSnapshot('loading'); - const highlightedUser = mockUser({ login: 'highlighted' }) as T.UserActive; + const highlightedUser = mockUser({ login: 'highlighted' }) as UserActive; expect( shallowRender({ highlighted: highlightedUser, - suggestedUsers: [mockUser() as T.UserActive, highlightedUser] + suggestedUsers: [mockUser() as UserActive, highlightedUser] }) ).toMatchSnapshot('open with results'); }); it('should call onSelect when clicked', () => { - const user = mockUser() as T.UserActive; + const user = mockUser() as UserActive; const onSelect = jest.fn(); const wrapper = shallowRender({ onSelect, diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/Status.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/Status.tsx index 689eb93c302..918fd20945a 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/Status.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/Status.tsx @@ -29,12 +29,13 @@ import { PopupPlacement } from '../../../../components/ui/popups'; import { translate } from '../../../../helpers/l10n'; import { isLoggedIn } from '../../../../helpers/users'; import { Hotspot, HotspotStatusOption } from '../../../../types/security-hotspots'; +import { CurrentUser } from '../../../../types/types'; import { getStatusOptionFromStatusAndResolution } from '../../utils'; import StatusDescription from './StatusDescription'; import StatusSelection from './StatusSelection'; export interface StatusProps { - currentUser: T.CurrentUser; + currentUser: CurrentUser; hotspot: Hotspot; onStatusChange: (statusOption: HotspotStatusOption) => Promise<void>; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/utils.ts b/server/sonar-web/src/main/js/apps/security-hotspots/utils.ts index ecde73f591e..86f7536c134 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/utils.ts +++ b/server/sonar-web/src/main/js/apps/security-hotspots/utils.ts @@ -36,6 +36,7 @@ import { ReviewHistoryType, RiskExposure } from '../../types/security-hotspots'; +import { Dict, SourceViewerFile, StandardSecurityCategories } from '../../types/types'; export const RISK_EXPOSURE_LEVELS = [RiskExposure.HIGH, RiskExposure.MEDIUM, RiskExposure.LOW]; export const SECURITY_STANDARDS = [ @@ -52,8 +53,8 @@ export const SECURITY_STANDARD_RENDERER = { [SecurityStandard.CWE]: renderCWECategory }; -export function mapRules(rules: Array<{ key: string; name: string }>): T.Dict<string> { - return rules.reduce((ruleMap: T.Dict<string>, r) => { +export function mapRules(rules: Array<{ key: string; name: string }>): Dict<string> { + return rules.reduce((ruleMap: Dict<string>, r) => { ruleMap[r.key] = r.name; return ruleMap; }, {}); @@ -61,7 +62,7 @@ export function mapRules(rules: Array<{ key: string; name: string }>): T.Dict<st export function groupByCategory( hotspots: RawHotspot[] = [], - securityCategories: T.StandardSecurityCategories + securityCategories: StandardSecurityCategories ) { const groups = groupBy(hotspots, h => h.securityCategory); @@ -72,10 +73,7 @@ export function groupByCategory( })); } -export function sortHotspots( - hotspots: RawHotspot[], - securityCategories: T.Dict<{ title: string }> -) { +export function sortHotspots(hotspots: RawHotspot[], securityCategories: Dict<{ title: string }>) { return sortBy(hotspots, [ h => RISK_EXPOSURE_LEVELS.indexOf(h.vulnerabilityProbability), h => getCategoryTitle(h.securityCategory, securityCategories), @@ -83,14 +81,14 @@ export function sortHotspots( ]); } -function getCategoryTitle(key: string, securityCategories: T.StandardSecurityCategories) { +function getCategoryTitle(key: string, securityCategories: StandardSecurityCategories) { return securityCategories[key] ? securityCategories[key].title : key; } export function constructSourceViewerFile( { component, project }: Hotspot, lines?: number -): T.SourceViewerFile { +): SourceViewerFile { return { key: component.key, measures: { lines: lines ? lines.toString() : undefined }, diff --git a/server/sonar-web/src/main/js/apps/sessions/components/Login.tsx b/server/sonar-web/src/main/js/apps/sessions/components/Login.tsx index 2658732ff13..d2153b4f832 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/Login.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/Login.tsx @@ -23,6 +23,7 @@ import GlobalMessagesContainer from '../../../app/components/GlobalMessagesConta import { Alert } from '../../../components/ui/Alert'; import { translate } from '../../../helpers/l10n'; import { Store } from '../../../store/rootReducer'; +import { IdentityProvider } from '../../../types/types'; import './Login.css'; import LoginForm from './LoginForm'; import OAuthProviders from './OAuthProviders'; @@ -30,7 +31,7 @@ import OAuthProviders from './OAuthProviders'; export interface LoginProps { authorizationError?: boolean; authenticationError?: boolean; - identityProviders: T.IdentityProvider[]; + identityProviders: IdentityProvider[]; onSubmit: (login: string, password: string) => Promise<void>; returnTo: string; } diff --git a/server/sonar-web/src/main/js/apps/sessions/components/LoginContainer.tsx b/server/sonar-web/src/main/js/apps/sessions/components/LoginContainer.tsx index f30ee82f972..eb9ad108f79 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/LoginContainer.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/LoginContainer.tsx @@ -23,6 +23,7 @@ import { connect } from 'react-redux'; import { getIdentityProviders } from '../../../api/users'; import { getReturnUrl } from '../../../helpers/urls'; import { doLogin } from '../../../store/rootActions'; +import { IdentityProvider } from '../../../types/types'; import Login from './Login'; interface OwnProps { @@ -38,7 +39,7 @@ interface DispatchToProps { type Props = OwnProps & DispatchToProps; interface State { - identityProviders?: T.IdentityProvider[]; + identityProviders?: IdentityProvider[]; } export class LoginContainer extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/apps/sessions/components/OAuthProviders.tsx b/server/sonar-web/src/main/js/apps/sessions/components/OAuthProviders.tsx index 59724f58607..566e6af463e 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/OAuthProviders.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/OAuthProviders.tsx @@ -24,12 +24,13 @@ import HelpTooltip from '../../../components/controls/HelpTooltip'; import IdentityProviderLink from '../../../components/controls/IdentityProviderLink'; import { translateWithParameters } from '../../../helpers/l10n'; import { getBaseUrl } from '../../../helpers/system'; +import { IdentityProvider } from '../../../types/types'; import './OAuthProviders.css'; interface Props { className?: string; formatLabel?: (name: string) => React.ReactNode; - identityProviders: T.IdentityProvider[]; + identityProviders: IdentityProvider[]; returnTo: string; } @@ -51,7 +52,7 @@ export default function OAuthProviders(props: Props) { interface ItemProps { format: (name: string) => React.ReactNode; - identityProvider: T.IdentityProvider; + identityProvider: IdentityProvider; returnTo: string; } diff --git a/server/sonar-web/src/main/js/apps/settings/components/AdditionalCategories.tsx b/server/sonar-web/src/main/js/apps/settings/components/AdditionalCategories.tsx index aa946fabeae..bcb0db78471 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/AdditionalCategories.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/AdditionalCategories.tsx @@ -19,6 +19,7 @@ */ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; +import { Component } from '../../../types/types'; import { ALM_INTEGRATION, ANALYSIS_SCOPE_CATEGORY, @@ -33,7 +34,7 @@ import NewCodePeriod from './NewCodePeriod'; import PullRequestDecorationBinding from './pullRequestDecorationBinding/PRDecorationBinding'; export interface AdditionalCategoryComponentProps { - component: T.Component | undefined; + component: Component | undefined; selectedCategory: string; } diff --git a/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.tsx b/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.tsx index 70d39c40770..88419881a33 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.tsx @@ -24,6 +24,7 @@ import { connect } from 'react-redux'; import { IndexLink } from 'react-router'; import { getGlobalSettingsUrl, getProjectSettingsUrl } from '../../../helpers/urls'; import { getAppState, getSettingsAppAllCategories, Store } from '../../../store/rootReducer'; +import { Component } from '../../../types/types'; import { getCategoryName } from '../utils'; import { ADDITIONAL_CATEGORIES } from './AdditionalCategories'; import CATEGORY_OVERRIDES from './CategoryOverrides'; @@ -31,7 +32,7 @@ import CATEGORY_OVERRIDES from './CategoryOverrides'; export interface CategoriesListProps { branchesEnabled?: boolean; categories: string[]; - component?: T.Component; + component?: Component; defaultCategory: string; selectedCategory: string; } diff --git a/server/sonar-web/src/main/js/apps/settings/components/CategoryDefinitionsList.tsx b/server/sonar-web/src/main/js/apps/settings/components/CategoryDefinitionsList.tsx index f36d33c40d1..a0b789a0666 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/CategoryDefinitionsList.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/CategoryDefinitionsList.tsx @@ -19,12 +19,13 @@ */ import { connect } from 'react-redux'; import { getSettingsAppSettingsForCategory, Store } from '../../../store/rootReducer'; +import { Component } from '../../../types/types'; import { fetchValues } from '../store/actions'; import SubCategoryDefinitionsList from './SubCategoryDefinitionsList'; interface Props { category: string; - component?: T.Component; + component?: Component; } const mapStateToProps = (state: Store, ownProps: Props) => ({ diff --git a/server/sonar-web/src/main/js/apps/settings/components/CategoryOverrides.ts b/server/sonar-web/src/main/js/apps/settings/components/CategoryOverrides.ts index 95d249719cb..f5e76d6f647 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/CategoryOverrides.ts +++ b/server/sonar-web/src/main/js/apps/settings/components/CategoryOverrides.ts @@ -17,9 +17,10 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { Dict } from '../../../types/types'; import { LANGUAGES_CATEGORY } from './AdditionalCategoryKeys'; -const CATEGORY_OVERRIDES: T.Dict<string> = { +const CATEGORY_OVERRIDES: Dict<string> = { abap: LANGUAGES_CATEGORY, apex: LANGUAGES_CATEGORY, 'c / c++ / objective-c': LANGUAGES_CATEGORY, diff --git a/server/sonar-web/src/main/js/apps/settings/components/Definition.tsx b/server/sonar-web/src/main/js/apps/settings/components/Definition.tsx index 0bc426876f8..cdbdab94747 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/Definition.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/Definition.tsx @@ -31,6 +31,7 @@ import { Store } from '../../../store/rootReducer'; import { Setting } from '../../../types/settings'; +import { Component } from '../../../types/types'; import { checkValue, resetValue, saveValue } from '../store/actions'; import { cancelChange, changeValue, passValidation } from '../store/settingsPage'; import { @@ -47,7 +48,7 @@ interface Props { changeValue: (key: string, value: any) => void; changedValue: any; checkValue: (key: string) => boolean; - component?: T.Component; + component?: Component; loading: boolean; passValidation: (key: string) => void; resetValue: (key: string, component?: string) => Promise<void>; diff --git a/server/sonar-web/src/main/js/apps/settings/components/DefinitionsList.tsx b/server/sonar-web/src/main/js/apps/settings/components/DefinitionsList.tsx index 8f810e009f0..2824d1c41af 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/DefinitionsList.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/DefinitionsList.tsx @@ -19,10 +19,11 @@ */ import * as React from 'react'; import { Setting } from '../../../types/settings'; +import { Component } from '../../../types/types'; import Definition from './Definition'; interface Props { - component?: T.Component; + component?: Component; scrollToDefinition: (element: HTMLLIElement) => void; settings: Setting[]; } diff --git a/server/sonar-web/src/main/js/apps/settings/components/EmailForm.tsx b/server/sonar-web/src/main/js/apps/settings/components/EmailForm.tsx index 544a42df889..990a9f84e92 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/EmailForm.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/EmailForm.tsx @@ -27,9 +27,10 @@ import MandatoryFieldMarker from '../../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { parseError } from '../../../helpers/request'; +import { LoggedInUser } from '../../../types/types'; interface Props { - currentUser: T.LoggedInUser; + currentUser: LoggedInUser; } interface State { diff --git a/server/sonar-web/src/main/js/apps/settings/components/NewCodePeriod.tsx b/server/sonar-web/src/main/js/apps/settings/components/NewCodePeriod.tsx index ac5b327ae95..caf5fed3395 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/NewCodePeriod.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/NewCodePeriod.tsx @@ -25,17 +25,18 @@ import { ResetButtonLink, SubmitButton } from '../../../components/controls/butt import AlertSuccessIcon from '../../../components/icons/AlertSuccessIcon'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate } from '../../../helpers/l10n'; +import { NewCodePeriodSettingType } from '../../../types/types'; import BaselineSettingDays from '../../projectBaseline/components/BaselineSettingDays'; import BaselineSettingPreviousVersion from '../../projectBaseline/components/BaselineSettingPreviousVersion'; import { validateDays } from '../../projectBaseline/utils'; interface State { - currentSetting?: T.NewCodePeriodSettingType; + currentSetting?: NewCodePeriodSettingType; days: string; loading: boolean; currentSettingValue?: string | number; saving: boolean; - selected?: T.NewCodePeriodSettingType; + selected?: NewCodePeriodSettingType; success: boolean; } @@ -81,7 +82,7 @@ export default class NewCodePeriod extends React.PureComponent<{}, State> { this.setState({ days, success: false }); }; - onSelectSetting = (selected: T.NewCodePeriodSettingType) => { + onSelectSetting = (selected: NewCodePeriodSettingType) => { this.setState({ selected, success: false }); }; diff --git a/server/sonar-web/src/main/js/apps/settings/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/settings/components/PageHeader.tsx index b18ad5646fb..b8f11a64b68 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/PageHeader.tsx @@ -20,10 +20,11 @@ import * as React from 'react'; import InstanceMessage from '../../../components/common/InstanceMessage'; import { translate } from '../../../helpers/l10n'; +import { Component } from '../../../types/types'; import SettingsSearch from './SettingsSearch'; export interface PageHeaderProps { - component?: T.Component; + component?: Component; } export default function PageHeader({ component }: PageHeaderProps) { diff --git a/server/sonar-web/src/main/js/apps/settings/components/SettingsApp.tsx b/server/sonar-web/src/main/js/apps/settings/components/SettingsApp.tsx index 5149787010a..e9875254569 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/SettingsApp.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/SettingsApp.tsx @@ -32,6 +32,7 @@ import { removeWhitePageClass } from '../../../helpers/pages'; import { getSettingsAppDefaultCategory, Store } from '../../../store/rootReducer'; +import { Component } from '../../../types/types'; import { fetchSettings } from '../store/actions'; import '../styles.css'; import { ADDITIONAL_CATEGORIES } from './AdditionalCategories'; @@ -41,7 +42,7 @@ import CATEGORY_OVERRIDES from './CategoryOverrides'; import PageHeader from './PageHeader'; interface Props { - component?: T.Component; + component?: Component; defaultCategory: string; fetchSettings(component?: string): Promise<void>; } diff --git a/server/sonar-web/src/main/js/apps/settings/components/SettingsSearch.tsx b/server/sonar-web/src/main/js/apps/settings/components/SettingsSearch.tsx index d868ed7ad30..3acbafbf1ca 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/SettingsSearch.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/SettingsSearch.tsx @@ -26,6 +26,7 @@ import { withRouter } from '../../../components/hoc/withRouter'; import { KeyboardCodes } from '../../../helpers/keycodes'; import { getSettingsAppAllDefinitions, Store } from '../../../store/rootReducer'; import { SettingCategoryDefinition } from '../../../types/settings'; +import { Component, Dict } from '../../../types/types'; import { ADDITIONAL_PROJECT_SETTING_DEFINITIONS, ADDITIONAL_SETTING_DEFINITIONS, @@ -35,7 +36,7 @@ import SettingsSearchRenderer from './SettingsSearchRenderer'; interface Props { className?: string; - component?: T.Component; + component?: Component; definitions: SettingCategoryDefinition[]; router: InjectedRouter; } @@ -50,7 +51,7 @@ interface State { const DEBOUNCE_DELAY = 250; export class SettingsSearch extends React.Component<Props, State> { - definitionsByKey: T.Dict<SettingCategoryDefinition>; + definitionsByKey: Dict<SettingCategoryDefinition>; index: LunrIndex; state: State = { searchQuery: '', diff --git a/server/sonar-web/src/main/js/apps/settings/components/SettingsSearchRenderer.tsx b/server/sonar-web/src/main/js/apps/settings/components/SettingsSearchRenderer.tsx index f9d100058d3..ea2c8b29700 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/SettingsSearchRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/SettingsSearchRenderer.tsx @@ -26,11 +26,12 @@ import SearchBox from '../../../components/controls/SearchBox'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { scrollToElement } from '../../../helpers/scrolling'; import { SettingCategoryDefinition } from '../../../types/settings'; +import { Component } from '../../../types/types'; import { buildSettingLink, isRealSettingKey } from '../utils'; export interface SettingsSearchRendererProps { className?: string; - component?: T.Component; + component?: Component; results?: SettingCategoryDefinition[]; searchQuery: string; selectedResult?: string; diff --git a/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.tsx b/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.tsx index be3b88a7c78..36cbd7fa95c 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.tsx @@ -23,13 +23,14 @@ import { Location, withRouter } from '../../../components/hoc/withRouter'; import { sanitizeStringRestricted } from '../../../helpers/sanitize'; import { scrollToElement } from '../../../helpers/scrolling'; import { SettingWithCategory } from '../../../types/settings'; +import { Component } from '../../../types/types'; import { getSubCategoryDescription, getSubCategoryName } from '../utils'; import DefinitionsList from './DefinitionsList'; import EmailForm from './EmailForm'; export interface SubCategoryDefinitionsListProps { category: string; - component?: T.Component; + component?: Component; fetchValues: Function; location: Location; settings: Array<SettingWithCategory>; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx index 043efedf2df..1f8537cf92f 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx @@ -34,10 +34,11 @@ import { AlmSettingsBindingStatus, AlmSettingsBindingStatusType } from '../../../../types/alm-settings'; +import { AppState, Dict } from '../../../../types/types'; import AlmIntegrationRenderer from './AlmIntegrationRenderer'; interface Props extends Pick<WithRouterProps, 'location' | 'router'> { - appState: Pick<T.AppState, 'branchesEnabled' | 'multipleAlmEnabled'>; + appState: Pick<AppState, 'branchesEnabled' | 'multipleAlmEnabled'>; } export type AlmTabs = AlmKeys.Azure | AlmKeys.GitHub | AlmKeys.GitLab | AlmKeys.BitbucketServer; @@ -46,7 +47,7 @@ interface State { currentAlmTab: AlmTabs; definitionKeyForDeletion?: string; definitions: AlmSettingsBindingDefinitions; - definitionStatus: T.Dict<AlmSettingsBindingStatus>; + definitionStatus: Dict<AlmSettingsBindingStatus>; loadingAlmDefinitions: boolean; loadingProjectCount: boolean; projectCount?: number; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegrationRenderer.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegrationRenderer.tsx index 04bd555a4be..6f34fbfd50e 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegrationRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegrationRenderer.tsx @@ -26,6 +26,7 @@ import { AlmSettingsBindingDefinitions, AlmSettingsBindingStatus } from '../../../../types/alm-settings'; +import { Dict } from '../../../../types/types'; import { AlmTabs } from './AlmIntegration'; import AlmTab from './AlmTab'; import DeleteModal from './DeleteModal'; @@ -35,7 +36,7 @@ export interface AlmIntegrationRendererProps { currentAlmTab: AlmTabs; definitionKeyForDeletion?: string; definitions: AlmSettingsBindingDefinitions; - definitionStatus: T.Dict<AlmSettingsBindingStatus>; + definitionStatus: Dict<AlmSettingsBindingStatus>; loadingAlmDefinitions: boolean; loadingProjectCount: boolean; multipleAlmEnabled: boolean; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmTab.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmTab.tsx index 1dd264c83b7..364ab25d34d 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmTab.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmTab.tsx @@ -23,6 +23,7 @@ import { AlmBindingDefinitionBase, AlmSettingsBindingStatus } from '../../../../types/alm-settings'; +import { Dict } from '../../../../types/types'; import { AlmTabs } from './AlmIntegration'; import AlmTabRenderer from './AlmTabRenderer'; @@ -30,7 +31,7 @@ interface Props { almTab: AlmTabs; branchesEnabled: boolean; definitions: AlmBindingDefinition[]; - definitionStatus: T.Dict<AlmSettingsBindingStatus>; + definitionStatus: Dict<AlmSettingsBindingStatus>; loadingAlmDefinitions: boolean; loadingProjectCount: boolean; multipleAlmEnabled: boolean; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmTabRenderer.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmTabRenderer.tsx index 8712e292617..730133ef526 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmTabRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmTabRenderer.tsx @@ -28,6 +28,7 @@ import { AlmSettingsBindingStatus, isBitbucketCloudBindingDefinition } from '../../../../types/alm-settings'; +import { Dict } from '../../../../types/types'; import { ALM_INTEGRATION } from '../AdditionalCategoryKeys'; import CategoryDefinitionsList from '../CategoryDefinitionsList'; import AlmBindingDefinitionBox from './AlmBindingDefinitionBox'; @@ -38,7 +39,7 @@ import CreationTooltip from './CreationTooltip'; export interface AlmTabRendererProps { almTab: AlmTabs; branchesEnabled: boolean; - definitionStatus: T.Dict<AlmSettingsBindingStatus>; + definitionStatus: Dict<AlmSettingsBindingStatus>; editDefinition?: boolean; editedDefinition?: AlmBindingDefinition; definitions: AlmBindingDefinition[]; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/CreationTooltip.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/CreationTooltip.tsx index fc23742666c..87f93b38da3 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/CreationTooltip.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/CreationTooltip.tsx @@ -25,10 +25,11 @@ import { getEdition, getEditionUrl } from '../../../../helpers/editions'; import { translate } from '../../../../helpers/l10n'; import { AlmKeys } from '../../../../types/alm-settings'; import { EditionKey } from '../../../../types/editions'; +import { AppState } from '../../../../types/types'; export interface CreationTooltipProps { alm: AlmKeys; - appState: T.AppState; + appState: AppState; children: React.ReactElement<{}>; preventCreation: boolean; } diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/AlmSpecificForm.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/AlmSpecificForm.tsx index ddd645f28a0..b46b54472e3 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/AlmSpecificForm.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/AlmSpecificForm.tsx @@ -31,11 +31,12 @@ import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../../../types/alm-settings'; +import { Dict } from '../../../../types/types'; export interface AlmSpecificFormProps { alm: AlmKeys; instances: AlmSettingsInstance[]; - formData: T.Omit<ProjectAlmBindingResponse, 'alm'>; + formData: Omit<ProjectAlmBindingResponse, 'alm'>; onFieldChange: (id: keyof ProjectAlmBindingResponse, value: string | boolean) => void; monorepoEnabled: boolean; } @@ -47,7 +48,7 @@ interface LabelProps { interface CommonFieldProps extends LabelProps { help?: boolean; - helpParams?: T.Dict<string | JSX.Element>; + helpParams?: Dict<string | JSX.Element>; helpExample?: JSX.Element; onFieldChange: (id: keyof ProjectAlmBindingResponse, value: string | boolean) => void; propKey: keyof ProjectAlmBindingResponse; diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/PRDecorationBinding.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/PRDecorationBinding.tsx index 6a3271221c1..7cbc4b356fc 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/PRDecorationBinding.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/PRDecorationBinding.tsx @@ -43,17 +43,18 @@ import { } from '../../../../types/alm-settings'; import { EditionKey } from '../../../../types/editions'; import { Permissions } from '../../../../types/permissions'; +import { Component, CurrentUser } from '../../../../types/types'; import PRDecorationBindingRenderer from './PRDecorationBindingRenderer'; -type FormData = T.Omit<ProjectAlmBindingResponse, 'alm'>; +type FormData = Omit<ProjectAlmBindingResponse, 'alm'>; interface StateProps { monorepoEnabled: boolean; } interface Props { - component: T.Component; - currentUser: T.CurrentUser; + component: Component; + currentUser: CurrentUser; } interface State { @@ -71,7 +72,7 @@ interface State { } const REQUIRED_FIELDS_BY_ALM: { - [almKey in AlmKeys]: Array<keyof T.Omit<FormData, 'key'>>; + [almKey in AlmKeys]: Array<keyof Omit<FormData, 'key'>>; } = { [AlmKeys.Azure]: ['repository', 'slug'], [AlmKeys.BitbucketServer]: ['repository', 'slug'], @@ -174,7 +175,7 @@ export class PRDecorationBinding extends React.PureComponent<Props & StateProps, submitProjectAlmBinding( alm: AlmKeys, key: string, - almSpecificFields?: T.Omit<FormData, 'key'> + almSpecificFields?: Omit<FormData, 'key'> ): Promise<void> { const almSetting = key; const project = this.props.component.key; diff --git a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/PRDecorationBindingRenderer.tsx b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/PRDecorationBindingRenderer.tsx index 352cc27c1d6..2a440c25b26 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/PRDecorationBindingRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/PRDecorationBindingRenderer.tsx @@ -39,7 +39,7 @@ import { ALM_INTEGRATION } from '../AdditionalCategoryKeys'; import AlmSpecificForm from './AlmSpecificForm'; export interface PRDecorationBindingRendererProps { - formData: T.Omit<ProjectAlmBindingResponse, 'alm'>; + formData: Omit<ProjectAlmBindingResponse, 'alm'>; instances: AlmSettingsInstance[]; isChanged: boolean; isConfigured: boolean; diff --git a/server/sonar-web/src/main/js/apps/settings/store/definitions.ts b/server/sonar-web/src/main/js/apps/settings/store/definitions.ts index 8e1af16c1db..729640cfac4 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/definitions.ts +++ b/server/sonar-web/src/main/js/apps/settings/store/definitions.ts @@ -20,6 +20,7 @@ import { keyBy, sortBy, uniqBy } from 'lodash'; import { ActionType } from '../../../store/utils/actions'; import { SettingCategoryDefinition } from '../../../types/settings'; +import { Dict } from '../../../types/types'; import { DEFAULT_CATEGORY, getCategoryName } from '../utils'; const enum Actions { @@ -28,7 +29,7 @@ const enum Actions { type Action = ActionType<typeof receiveDefinitions, Actions.ReceiveDefinitions>; -export type State = T.Dict<SettingCategoryDefinition>; +export type State = Dict<SettingCategoryDefinition>; export function receiveDefinitions(definitions: SettingCategoryDefinition[]) { return { type: Actions.ReceiveDefinitions, definitions }; diff --git a/server/sonar-web/src/main/js/apps/settings/store/settingsPage.ts b/server/sonar-web/src/main/js/apps/settings/store/settingsPage.ts index 43797087936..045b7647f02 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/settingsPage.ts +++ b/server/sonar-web/src/main/js/apps/settings/store/settingsPage.ts @@ -20,6 +20,7 @@ import { omit } from 'lodash'; import { combineReducers } from 'redux'; import { ActionType } from '../../../store/utils/actions'; +import { Dict } from '../../../types/types'; const enum Actions { CancelChange = 'settingsPage/CANCEL_CHANGE', @@ -39,9 +40,9 @@ type Action = | ActionType<typeof stopLoading, Actions.StopLoading>; export interface State { - changedValues: T.Dict<any>; - loading: T.Dict<boolean>; - validationMessages: T.Dict<string>; + changedValues: Dict<any>; + loading: Dict<boolean>; + validationMessages: Dict<string>; } export function cancelChange(key: string) { diff --git a/server/sonar-web/src/main/js/apps/settings/store/values.ts b/server/sonar-web/src/main/js/apps/settings/store/values.ts index 1146d12b359..f421230d705 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/values.ts +++ b/server/sonar-web/src/main/js/apps/settings/store/values.ts @@ -22,6 +22,7 @@ import { combineReducers } from 'redux'; import { Action as AppStateAction, Actions as AppStateActions } from '../../../store/appState'; import { ActionType } from '../../../store/utils/actions'; import { SettingValue } from '../../../types/settings'; +import { Dict } from '../../../types/types'; enum Actions { receiveValues = 'RECEIVE_VALUES' @@ -29,10 +30,10 @@ enum Actions { type Action = ActionType<typeof receiveValues, Actions.receiveValues>; -type SettingsState = T.Dict<SettingValue>; +type SettingsState = Dict<SettingValue>; export interface State { - components: T.Dict<SettingsState>; + components: Dict<SettingsState>; global: SettingsState; } diff --git a/server/sonar-web/src/main/js/apps/settings/utils.ts b/server/sonar-web/src/main/js/apps/settings/utils.ts index dcb442a7570..ba23c0f1d08 100644 --- a/server/sonar-web/src/main/js/apps/settings/utils.ts +++ b/server/sonar-web/src/main/js/apps/settings/utils.ts @@ -22,6 +22,7 @@ import { hasMessage, translate } from '../../helpers/l10n'; import { getGlobalSettingsUrl, getProjectSettingsUrl } from '../../helpers/urls'; import { AlmKeys } from '../../types/alm-settings'; import { Setting, SettingCategoryDefinition, SettingDefinition } from '../../types/settings'; +import { Component, Dict } from '../../types/types'; export const DEFAULT_CATEGORY = 'general'; @@ -108,7 +109,7 @@ export function getEmptyValue(item: SettingDefinition | SettingCategoryDefinitio } if (item.type === 'PROPERTY_SET') { - const value: T.Dict<string> = {}; + const value: Dict<string> = {}; item.fields.forEach(field => (value[field.key] = getEmptyValue(field))); return [value]; } @@ -170,7 +171,7 @@ export function isRealSettingKey(key: string) { export function buildSettingLink( definition: SettingCategoryDefinition, - component?: T.Component + component?: Component ): LocationDescriptor { const { category, key } = definition; @@ -181,7 +182,7 @@ export function buildSettingLink( }; } - const query: T.Dict<string> = {}; + const query: Dict<string> = {}; if (key.startsWith('sonar.auth.gitlab')) { query.alm = 'gitlab'; diff --git a/server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts index 3194894a6ab..accdb5de9b5 100644 --- a/server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/system/__tests__/utils-test.ts @@ -19,6 +19,7 @@ */ import { mockClusterSysInfo, mockStandaloneSysInfo } from '../../../helpers/testMocks'; +import { SysInfoBase, SysInfoStandalone } from '../../../types/types'; import * as u from '../utils'; describe('parseQuery', () => { @@ -68,7 +69,7 @@ describe('getSystemLogsLevel', () => { }) ) ).toBe('INFO'); - expect(u.getSystemLogsLevel({} as T.SysInfoStandalone)).toBe('INFO'); + expect(u.getSystemLogsLevel({} as SysInfoStandalone)).toBe('INFO'); }); }); @@ -169,13 +170,13 @@ describe('getNodeName', () => { describe('getHealthCauses', () => { it('should return the correct information', () => { - expect(u.getHealthCauses({ 'Health Causes': ['Foo'] } as T.SysInfoBase)).toEqual(['Foo']); + expect(u.getHealthCauses({ 'Health Causes': ['Foo'] } as SysInfoBase)).toEqual(['Foo']); }); }); describe('getHealth', () => { it('should return the correct information', () => { - expect(u.getHealth({ Health: 'GREEN' } as T.SysInfoBase)).toEqual('GREEN'); + expect(u.getHealth({ Health: 'GREEN' } as SysInfoBase)).toEqual('GREEN'); }); }); diff --git a/server/sonar-web/src/main/js/apps/system/components/App.tsx b/server/sonar-web/src/main/js/apps/system/components/App.tsx index 7e5cdc02608..45532818e90 100644 --- a/server/sonar-web/src/main/js/apps/system/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/App.tsx @@ -24,6 +24,7 @@ import { getSystemInfo } from '../../../api/system'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import UpdateNotification from '../../../app/components/update-notification/UpdateNotification'; import { translate } from '../../../helpers/l10n'; +import { SysInfoCluster, SysInfoStandalone } from '../../../types/types'; import '../styles.css'; import { getClusterVersion, @@ -43,7 +44,7 @@ type Props = WithRouterProps; interface State { loading: boolean; - sysInfoData?: T.SysInfoCluster | T.SysInfoStandalone; + sysInfoData?: SysInfoCluster | SysInfoStandalone; } export class App extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx b/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx index 28b52667d18..b1bdf0109a1 100644 --- a/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx @@ -20,6 +20,7 @@ import { sortBy } from 'lodash'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; +import { SysInfoAppNode, SysInfoCluster, SysInfoSearchNode } from '../../../types/types'; import { getAppNodes, getClusterMainCardSection, @@ -33,7 +34,7 @@ import HealthCard from './info-items/HealthCard'; interface Props { expandedCards: string[]; - sysInfoData: T.SysInfoCluster; + sysInfoData: SysInfoCluster; toggleCard: (toggledCard: string) => void; } @@ -53,7 +54,7 @@ export default function ClusterSysInfos({ expandedCards, sysInfoData, toggleCard <li className="note system-info-health-title"> {translate('system.application_nodes_title')} </li> - {sortBy(getAppNodes(sysInfoData), getNodeName).map((node: T.SysInfoAppNode) => ( + {sortBy(getAppNodes(sysInfoData), getNodeName).map((node: SysInfoAppNode) => ( <HealthCard health={getHealth(node)} healthCauses={getHealthCauses(node)} @@ -65,7 +66,7 @@ export default function ClusterSysInfos({ expandedCards, sysInfoData, toggleCard /> ))} <li className="note system-info-health-title">{translate('system.search_nodes_title')}</li> - {sortBy(getSearchNodes(sysInfoData), getNodeName).map((node: T.SysInfoSearchNode) => ( + {sortBy(getSearchNodes(sysInfoData), getNodeName).map((node: SysInfoSearchNode) => ( <HealthCard key={getNodeName(node)} name={getNodeName(node)} diff --git a/server/sonar-web/src/main/js/apps/system/components/StandaloneSysInfos.tsx b/server/sonar-web/src/main/js/apps/system/components/StandaloneSysInfos.tsx index 650d10fcde1..b39595cb16f 100644 --- a/server/sonar-web/src/main/js/apps/system/components/StandaloneSysInfos.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/StandaloneSysInfos.tsx @@ -19,6 +19,7 @@ */ import { map } from 'lodash'; import * as React from 'react'; +import { SysInfoStandalone } from '../../../types/types'; import { getHealth, getHealthCauses, @@ -30,7 +31,7 @@ import HealthCard from './info-items/HealthCard'; interface Props { expandedCards: string[]; - sysInfoData: T.SysInfoStandalone; + sysInfoData: SysInfoStandalone; toggleCard: (toggledCard: string) => void; } diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx index 5c403aadf4f..175143c3f32 100644 --- a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx @@ -22,18 +22,19 @@ import * as React from 'react'; import BoxedGroupAccordion from '../../../../components/controls/BoxedGroupAccordion'; import { Alert } from '../../../../components/ui/Alert'; import { translate } from '../../../../helpers/l10n'; +import { HealthType, SysInfoValueObject } from '../../../../types/types'; import { getLogsLevel, groupSections, LOGS_LEVELS } from '../../utils'; import HealthItem from './HealthItem'; import Section from './Section'; interface Props { biggerHealth?: boolean; - health?: T.HealthType; + health?: HealthType; healthCauses?: string[]; onClick: (toggledCard: string) => void; open: boolean; name: string; - sysInfoData: T.SysInfoValueObject; + sysInfoData: SysInfoValueObject; } export default function HealthCard({ diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx index f6022748fb5..56442b15ee8 100644 --- a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx @@ -20,10 +20,11 @@ import classNames from 'classnames'; import * as React from 'react'; import { Alert } from '../../../../components/ui/Alert'; +import { HealthType } from '../../../../types/types'; interface Props { className?: string; - health: T.HealthType; + health: HealthType; healthCause: string; } diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx index 3c9fa6acebd..70b0209aa80 100644 --- a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx @@ -22,13 +22,14 @@ import * as React from 'react'; import StatusIndicator from '../../../../components/common/StatusIndicator'; import Tooltip from '../../../../components/controls/Tooltip'; import { translateWithParameters } from '../../../../helpers/l10n'; +import { HealthType } from '../../../../types/types'; import HealthCauseItem from './HealthCauseItem'; interface Props { biggerHealth?: boolean; name?: string; className?: string; - health: T.HealthType; + health: HealthType; healthCauses?: string[]; } diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx index 34087dcf973..85a9a0c1895 100644 --- a/server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx @@ -19,11 +19,12 @@ */ import { map } from 'lodash'; import * as React from 'react'; +import { SysInfoValueObject } from '../../../../types/types'; import SysInfoItem from './SysInfoItem'; interface Props { name?: string; - items: T.SysInfoValueObject; + items: SysInfoValueObject; } export default function Section({ name, items }: Props) { diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx index 4cd91ec7c53..aa299cc81da 100644 --- a/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx @@ -20,17 +20,18 @@ import { map } from 'lodash'; import * as React from 'react'; import { translate } from '../../../../helpers/l10n'; +import { HealthType, SysInfoValue } from '../../../../types/types'; import { HEALTH_FIELD, STATE_FIELD } from '../../utils'; import HealthItem from './HealthItem'; export interface Props { name: string; - value: T.SysInfoValue; + value: SysInfoValue; } export default function SysInfoItem({ name, value }: Props) { if (name === HEALTH_FIELD || name === STATE_FIELD) { - return <HealthItem className="no-margin" health={value as T.HealthType} />; + return <HealthItem className="no-margin" health={value as HealthType} />; } if (value instanceof Array) { return <code>{JSON.stringify(value)}</code>; diff --git a/server/sonar-web/src/main/js/apps/system/utils.ts b/server/sonar-web/src/main/js/apps/system/utils.ts index a9857503449..93978f0d9af 100644 --- a/server/sonar-web/src/main/js/apps/system/utils.ts +++ b/server/sonar-web/src/main/js/apps/system/utils.ts @@ -20,6 +20,17 @@ import { each, memoize, omit, omitBy, pickBy, sortBy } from 'lodash'; import { formatMeasure } from '../../helpers/measures'; import { cleanQuery, parseAsArray, parseAsString, serializeStringArray } from '../../helpers/query'; +import { + RawQuery, + SysInfoAppNode, + SysInfoBase, + SysInfoCluster, + SysInfoLogging, + SysInfoSearchNode, + SysInfoSection, + SysInfoStandalone, + SysInfoValueObject +} from '../../types/types'; export interface Query { expandedCards: string[]; @@ -51,7 +62,7 @@ export const VERSION_FIELD = 'Version'; export const WEB_LOGGING_FIELD = 'Web Logging'; export const WEB_PREFIX = 'Web'; -export function ignoreInfoFields(sysInfoObject: T.SysInfoValueObject) { +export function ignoreInfoFields(sysInfoObject: SysInfoValueObject) { return omit(sysInfoObject, [ ALMS_FIELD, BUNDLED_FIELD, @@ -65,15 +76,15 @@ export function ignoreInfoFields(sysInfoObject: T.SysInfoValueObject) { ]); } -export function getHealth(sysInfoObject: T.SysInfoBase) { +export function getHealth(sysInfoObject: SysInfoBase) { return sysInfoObject[HEALTH_FIELD]; } -export function getHealthCauses(sysInfoObject: T.SysInfoBase) { +export function getHealthCauses(sysInfoObject: SysInfoBase) { return sysInfoObject[HEALTH_CAUSES_FIELD]; } -export function getLogsLevel(sysInfoObject?: T.SysInfoValueObject): string { +export function getLogsLevel(sysInfoObject?: SysInfoValueObject): string { if (sysInfoObject !== undefined) { if (isLogInfoBlock(sysInfoObject)) { return sysInfoObject[LOGS_LEVEL_FIELD]; @@ -90,46 +101,44 @@ export function getLogsLevel(sysInfoObject?: T.SysInfoValueObject): string { return DEFAULT_LOG_LEVEL; } -export function getAppNodes(sysInfoData: T.SysInfoCluster): T.SysInfoAppNode[] { +export function getAppNodes(sysInfoData: SysInfoCluster): SysInfoAppNode[] { return sysInfoData[APP_NODES_FIELD]; } -export function getSearchNodes(sysInfoData: T.SysInfoCluster): T.SysInfoSearchNode[] { +export function getSearchNodes(sysInfoData: SysInfoCluster): SysInfoSearchNode[] { return sysInfoData[SEARCH_NODES_FIELD]; } export function isCluster( - sysInfoData: T.SysInfoCluster | T.SysInfoStandalone -): sysInfoData is T.SysInfoCluster { + sysInfoData: SysInfoCluster | SysInfoStandalone +): sysInfoData is SysInfoCluster { return sysInfoData[SYSTEM_FIELD] && sysInfoData[SYSTEM_FIELD][HA_FIELD] === true; } -export function isLogInfoBlock( - sysInfoObject: T.SysInfoValueObject -): sysInfoObject is T.SysInfoLogging { +export function isLogInfoBlock(sysInfoObject: SysInfoValueObject): sysInfoObject is SysInfoLogging { return sysInfoObject[LOGS_LEVEL_FIELD] !== undefined; } export function hasLoggingInfo( - sysInfoObject: T.SysInfoValueObject -): sysInfoObject is T.SysInfoStandalone | T.SysInfoAppNode { + sysInfoObject: SysInfoValueObject +): sysInfoObject is SysInfoStandalone | SysInfoAppNode { return Boolean(sysInfoObject[WEB_LOGGING_FIELD] || sysInfoObject[CE_LOGGING_FIELD]); } -export function getServerId(sysInfoData: T.SysInfoCluster | T.SysInfoStandalone): string { +export function getServerId(sysInfoData: SysInfoCluster | SysInfoStandalone): string { return sysInfoData && sysInfoData[SYSTEM_FIELD][SERVER_ID_FIELD]; } -export function getVersion(sysInfoData: T.SysInfoStandalone): string | undefined { +export function getVersion(sysInfoData: SysInfoStandalone): string | undefined { return sysInfoData && sysInfoData[SYSTEM_FIELD][VERSION_FIELD]; } -export function getClusterVersion(sysInfoData: T.SysInfoCluster): string | undefined { +export function getClusterVersion(sysInfoData: SysInfoCluster): string | undefined { const appNodes = getAppNodes(sysInfoData); return appNodes.length > 0 ? appNodes[0][SYSTEM_FIELD][VERSION_FIELD] : undefined; } -export function getSystemLogsLevel(sysInfoData: T.SysInfoCluster | T.SysInfoStandalone): string { +export function getSystemLogsLevel(sysInfoData: SysInfoCluster | SysInfoStandalone): string { if (isCluster(sysInfoData)) { const logLevels = sortBy(getAppNodes(sysInfoData).map(getLogsLevel), logLevel => LOGS_LEVELS.indexOf(logLevel) @@ -140,20 +149,20 @@ export function getSystemLogsLevel(sysInfoData: T.SysInfoCluster | T.SysInfoStan } } -export function getNodeName(nodeInfo: T.SysInfoAppNode | T.SysInfoSearchNode): string { +export function getNodeName(nodeInfo: SysInfoAppNode | SysInfoSearchNode): string { return nodeInfo[NAME_FIELD]; } -function getSystemData(sysInfoData: T.SysInfoBase): T.SysInfoValueObject { - const statData: T.SysInfoValueObject = {}; - const statistics = sysInfoData[STATS_FIELD] as T.SysInfoValueObject; // TODO +function getSystemData(sysInfoData: SysInfoBase): SysInfoValueObject { + const statData: SysInfoValueObject = {}; + const statistics = sysInfoData[STATS_FIELD] as SysInfoValueObject; // TODO if (statistics) { statData['Lines of Code'] = formatMeasure(statistics[NCLOC_FIELD] as number, 'INT'); } return { ...sysInfoData[SYSTEM_FIELD], ...statData }; } -export function getClusterMainCardSection(sysInfoData: T.SysInfoCluster): T.SysInfoValueObject { +export function getClusterMainCardSection(sysInfoData: SysInfoCluster): SysInfoValueObject { return { ...getSystemData(sysInfoData), ...omit(sysInfoData, [ @@ -167,7 +176,7 @@ export function getClusterMainCardSection(sysInfoData: T.SysInfoCluster): T.SysI }; } -export function getStandaloneMainSections(sysInfoData: T.SysInfoBase): T.SysInfoValueObject { +export function getStandaloneMainSections(sysInfoData: SysInfoBase): SysInfoValueObject { return { ...getSystemData(sysInfoData), ...(omitBy( @@ -178,19 +187,19 @@ export function getStandaloneMainSections(sysInfoData: T.SysInfoBase): T.SysInfo key.startsWith(CE_FIELD_PREFIX) || key.startsWith(SEARCH_PREFIX) || key.startsWith(WEB_PREFIX) - ) as T.SysInfoValueObject) + ) as SysInfoValueObject) }; } -export function getStandaloneSecondarySections(sysInfoData: T.SysInfoBase): T.SysInfoSection { +export function getStandaloneSecondarySections(sysInfoData: SysInfoBase): SysInfoSection { return { - Web: pickBy(sysInfoData, (_, key) => key.startsWith(WEB_PREFIX)) as T.SysInfoValueObject, + Web: pickBy(sysInfoData, (_, key) => key.startsWith(WEB_PREFIX)) as SysInfoValueObject, 'Compute Engine': pickBy(sysInfoData, (_, key) => key.startsWith(CE_FIELD_PREFIX) - ) as T.SysInfoValueObject, + ) as SysInfoValueObject, 'Search Engine': pickBy(sysInfoData, (_, key) => key.startsWith(SEARCH_PREFIX) - ) as T.SysInfoValueObject + ) as SysInfoValueObject }; } @@ -203,9 +212,9 @@ export function getFileNameSuffix(suffix?: string) { ); } -export function groupSections(sysInfoData: T.SysInfoValueObject) { - const mainSection: T.SysInfoValueObject = {}; - const sections: T.SysInfoSection = {}; +export function groupSections(sysInfoData: SysInfoValueObject) { + const mainSection: SysInfoValueObject = {}; + const sections: SysInfoSection = {}; each(sysInfoData, (item, key) => { if (typeof item !== 'object' || item instanceof Array) { mainSection[key] = item; @@ -217,13 +226,13 @@ export function groupSections(sysInfoData: T.SysInfoValueObject) { } export const parseQuery = memoize( - (urlQuery: T.RawQuery): Query => ({ + (urlQuery: RawQuery): Query => ({ expandedCards: parseAsArray(urlQuery.expand, parseAsString) }) ); export const serializeQuery = memoize( - (query: Query): T.RawQuery => + (query: Query): RawQuery => cleanQuery({ expand: serializeStringArray(query.expandedCards) }) diff --git a/server/sonar-web/src/main/js/apps/tutorials/components/TutorialsApp.tsx b/server/sonar-web/src/main/js/apps/tutorials/components/TutorialsApp.tsx index 15e0ed88dae..56fca606181 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/components/TutorialsApp.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/components/TutorialsApp.tsx @@ -23,10 +23,11 @@ import TutorialSelection from '../../../components/tutorials/TutorialSelection'; import handleRequiredAuthentication from '../../../helpers/handleRequiredAuthentication'; import { isLoggedIn } from '../../../helpers/users'; import { ProjectAlmBindingResponse } from '../../../types/alm-settings'; +import { Component, CurrentUser } from '../../../types/types'; export interface TutorialsAppProps { - component: T.Component; - currentUser: T.CurrentUser; + component: Component; + currentUser: CurrentUser; projectBinding?: ProjectAlmBindingResponse; } diff --git a/server/sonar-web/src/main/js/apps/users/UsersApp.tsx b/server/sonar-web/src/main/js/apps/users/UsersApp.tsx index 83b6c6d1f31..8c7ee82c99c 100644 --- a/server/sonar-web/src/main/js/apps/users/UsersApp.tsx +++ b/server/sonar-web/src/main/js/apps/users/UsersApp.tsx @@ -25,6 +25,7 @@ import ListFooter from '../../components/controls/ListFooter'; import { withCurrentUser } from '../../components/hoc/withCurrentUser'; import { Location, Router, withRouter } from '../../components/hoc/withRouter'; import { translate } from '../../helpers/l10n'; +import { IdentityProvider, Paging, User } from '../../types/types'; import Header from './Header'; import Search from './Search'; import UsersList from './UsersList'; @@ -37,10 +38,10 @@ interface Props { } interface State { - identityProviders: T.IdentityProvider[]; + identityProviders: IdentityProvider[]; loading: boolean; - paging?: T.Paging; - users: T.User[]; + paging?: Paging; + users: User[]; } export class UsersApp extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/apps/users/UsersList.tsx b/server/sonar-web/src/main/js/apps/users/UsersList.tsx index a12eb00d3ea..ce4d76e9f06 100644 --- a/server/sonar-web/src/main/js/apps/users/UsersList.tsx +++ b/server/sonar-web/src/main/js/apps/users/UsersList.tsx @@ -19,14 +19,15 @@ */ import * as React from 'react'; import { translate } from '../../helpers/l10n'; +import { IdentityProvider, User } from '../../types/types'; import UserListItem from './components/UserListItem'; interface Props { currentUser: { isLoggedIn: boolean; login?: string }; - identityProviders: T.IdentityProvider[]; + identityProviders: IdentityProvider[]; onUpdateUsers: () => void; updateTokensCount: (login: string, tokensCount: number) => void; - users: T.User[]; + users: User[]; } export default function UsersList({ diff --git a/server/sonar-web/src/main/js/apps/users/components/DeactivateForm.tsx b/server/sonar-web/src/main/js/apps/users/components/DeactivateForm.tsx index ff9cac6acd6..186ab9240ad 100644 --- a/server/sonar-web/src/main/js/apps/users/components/DeactivateForm.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/DeactivateForm.tsx @@ -22,11 +22,12 @@ import { deactivateUser } from '../../../api/users'; import { ResetButtonLink, SubmitButton } from '../../../components/controls/buttons'; import Modal from '../../../components/controls/Modal'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { UserActive } from '../../../types/types'; export interface Props { onClose: () => void; onUpdateUsers: () => void; - user: T.UserActive; + user: UserActive; } interface State { diff --git a/server/sonar-web/src/main/js/apps/users/components/GroupsForm.tsx b/server/sonar-web/src/main/js/apps/users/components/GroupsForm.tsx index a61d96e1ae0..0a5eeca46a6 100644 --- a/server/sonar-web/src/main/js/apps/users/components/GroupsForm.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/GroupsForm.tsx @@ -27,11 +27,12 @@ import SelectList, { SelectListSearchParams } from '../../../components/controls/SelectList'; import { translate } from '../../../helpers/l10n'; +import { User } from '../../../types/types'; interface Props { onClose: () => void; onUpdateUsers: () => void; - user: T.User; + user: User; } interface State { diff --git a/server/sonar-web/src/main/js/apps/users/components/PasswordForm.tsx b/server/sonar-web/src/main/js/apps/users/components/PasswordForm.tsx index 6dd4d5adbcd..d428a60162b 100644 --- a/server/sonar-web/src/main/js/apps/users/components/PasswordForm.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/PasswordForm.tsx @@ -28,11 +28,12 @@ import MandatoryFieldMarker from '../../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../../helpers/l10n'; import { parseError } from '../../../helpers/request'; +import { User } from '../../../types/types'; interface Props { isCurrentUser: boolean; onClose: () => void; - user: T.User; + user: User; } interface State { diff --git a/server/sonar-web/src/main/js/apps/users/components/TokensForm.tsx b/server/sonar-web/src/main/js/apps/users/components/TokensForm.tsx index 4f4ce1b6dfb..c9a72b57ae6 100644 --- a/server/sonar-web/src/main/js/apps/users/components/TokensForm.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/TokensForm.tsx @@ -22,6 +22,7 @@ import { generateToken, getTokens } from '../../../api/user-tokens'; import { SubmitButton } from '../../../components/controls/buttons'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate } from '../../../helpers/l10n'; +import { UserToken } from '../../../types/types'; import TokensFormItem, { TokenDeleteConfirmation } from './TokensFormItem'; import TokensFormNewToken from './TokensFormNewToken'; @@ -36,7 +37,7 @@ interface State { loading: boolean; newToken?: { name: string; token: string }; newTokenName: string; - tokens: T.UserToken[]; + tokens: UserToken[]; } export default class TokensForm extends React.PureComponent<Props, State> { @@ -104,7 +105,7 @@ export default class TokensForm extends React.PureComponent<Props, State> { } }; - handleRevokeToken = (revokedToken: T.UserToken) => { + handleRevokeToken = (revokedToken: UserToken) => { this.setState( state => ({ tokens: state.tokens.filter(token => token.name !== revokedToken.name) diff --git a/server/sonar-web/src/main/js/apps/users/components/TokensFormItem.tsx b/server/sonar-web/src/main/js/apps/users/components/TokensFormItem.tsx index 4c8fc26c29f..3cd5689bb39 100644 --- a/server/sonar-web/src/main/js/apps/users/components/TokensFormItem.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/TokensFormItem.tsx @@ -28,14 +28,15 @@ import DateFromNow from '../../../components/intl/DateFromNow'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate } from '../../../helpers/l10n'; import { limitComponentName } from '../../../helpers/path'; +import { UserToken } from '../../../types/types'; export type TokenDeleteConfirmation = 'inline' | 'modal'; interface Props { deleteConfirmation: TokenDeleteConfirmation; login: string; - onRevokeToken: (token: T.UserToken) => void; - token: T.UserToken; + onRevokeToken: (token: UserToken) => void; + token: UserToken; } interface State { diff --git a/server/sonar-web/src/main/js/apps/users/components/TokensFormModal.tsx b/server/sonar-web/src/main/js/apps/users/components/TokensFormModal.tsx index bb9e48a4feb..99f4b441f78 100644 --- a/server/sonar-web/src/main/js/apps/users/components/TokensFormModal.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/TokensFormModal.tsx @@ -22,10 +22,11 @@ import { FormattedMessage } from 'react-intl'; import { ResetButtonLink } from '../../../components/controls/buttons'; import Modal from '../../../components/controls/Modal'; import { translate } from '../../../helpers/l10n'; +import { User } from '../../../types/types'; import TokensForm from './TokensForm'; interface Props { - user: T.User; + user: User; onClose: () => void; updateTokensCount: (login: string, tokensCount: number) => void; } diff --git a/server/sonar-web/src/main/js/apps/users/components/UserActions.tsx b/server/sonar-web/src/main/js/apps/users/components/UserActions.tsx index e58df4f9e09..a2db1575421 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UserActions.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/UserActions.tsx @@ -24,6 +24,7 @@ import ActionsDropdown, { } from '../../../components/controls/ActionsDropdown'; import { translate } from '../../../helpers/l10n'; import { isUserActive } from '../../../helpers/users'; +import { User } from '../../../types/types'; import DeactivateForm from './DeactivateForm'; import PasswordForm from './PasswordForm'; import UserForm from './UserForm'; @@ -31,7 +32,7 @@ import UserForm from './UserForm'; interface Props { isCurrentUser: boolean; onUpdateUsers: () => void; - user: T.User; + user: User; } interface State { diff --git a/server/sonar-web/src/main/js/apps/users/components/UserForm.tsx b/server/sonar-web/src/main/js/apps/users/components/UserForm.tsx index 55193531878..34317250372 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UserForm.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/UserForm.tsx @@ -28,12 +28,13 @@ import MandatoryFieldMarker from '../../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { parseError } from '../../../helpers/request'; +import { User } from '../../../types/types'; import UserScmAccountInput from './UserScmAccountInput'; export interface Props { onClose: () => void; onUpdateUsers: () => void; - user?: T.User; + user?: User; } interface State { diff --git a/server/sonar-web/src/main/js/apps/users/components/UserGroups.tsx b/server/sonar-web/src/main/js/apps/users/components/UserGroups.tsx index e525bdeb7fa..6c084e871a0 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UserGroups.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/UserGroups.tsx @@ -21,12 +21,13 @@ import * as React from 'react'; import { ButtonIcon } from '../../../components/controls/buttons'; import BulletListIcon from '../../../components/icons/BulletListIcon'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { User } from '../../../types/types'; import GroupsForm from './GroupsForm'; interface Props { groups: string[]; onUpdateUsers: () => void; - user: T.User; + user: User; } interface State { diff --git a/server/sonar-web/src/main/js/apps/users/components/UserListItem.tsx b/server/sonar-web/src/main/js/apps/users/components/UserListItem.tsx index dd728bf3f9c..596c7332a71 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UserListItem.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/UserListItem.tsx @@ -23,6 +23,7 @@ import BulletListIcon from '../../../components/icons/BulletListIcon'; import DateFromNow from '../../../components/intl/DateFromNow'; import Avatar from '../../../components/ui/Avatar'; import { translate } from '../../../helpers/l10n'; +import { IdentityProvider, User } from '../../../types/types'; import TokensFormModal from './TokensFormModal'; import UserActions from './UserActions'; import UserGroups from './UserGroups'; @@ -30,11 +31,11 @@ import UserListItemIdentity from './UserListItemIdentity'; import UserScmAccounts from './UserScmAccounts'; interface Props { - identityProvider?: T.IdentityProvider; + identityProvider?: IdentityProvider; isCurrentUser: boolean; onUpdateUsers: () => void; updateTokensCount: (login: string, tokensCount: number) => void; - user: T.User; + user: User; } interface State { diff --git a/server/sonar-web/src/main/js/apps/users/components/UserListItemIdentity.tsx b/server/sonar-web/src/main/js/apps/users/components/UserListItemIdentity.tsx index 7ad86650cb6..a3408a5175f 100644 --- a/server/sonar-web/src/main/js/apps/users/components/UserListItemIdentity.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/UserListItemIdentity.tsx @@ -21,10 +21,11 @@ import * as React from 'react'; import { colors } from '../../../app/theme'; import { getTextColor } from '../../../helpers/colors'; import { getBaseUrl } from '../../../helpers/system'; +import { IdentityProvider, User } from '../../../types/types'; export interface Props { - identityProvider?: T.IdentityProvider; - user: T.User; + identityProvider?: IdentityProvider; + user: User; } export default function UserListItemIdentity({ identityProvider, user }: Props) { diff --git a/server/sonar-web/src/main/js/apps/users/components/__tests__/TokensFormItem-test.tsx b/server/sonar-web/src/main/js/apps/users/components/__tests__/TokensFormItem-test.tsx index 310642b9948..1b93097d0d7 100644 --- a/server/sonar-web/src/main/js/apps/users/components/__tests__/TokensFormItem-test.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/__tests__/TokensFormItem-test.tsx @@ -21,6 +21,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { revokeToken } from '../../../../api/user-tokens'; import { click, waitAndUpdate } from '../../../../helpers/testUtils'; +import { UserToken } from '../../../../types/types'; import TokensFormItem from '../TokensFormItem'; jest.mock('../../../../components/intl/DateFormatter'); @@ -31,7 +32,7 @@ jest.mock('../../../../api/user-tokens', () => ({ revokeToken: jest.fn().mockResolvedValue(undefined) })); -const userToken: T.UserToken = { +const userToken: UserToken = { name: 'foo', createdAt: '2019-01-15T15:06:33+0100', lastConnectionDate: '2019-01-18T15:06:33+0100' diff --git a/server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItem-test.tsx b/server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItem-test.tsx index 742b4ff7a01..8cb2d13f360 100644 --- a/server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItem-test.tsx +++ b/server/sonar-web/src/main/js/apps/users/components/__tests__/UserListItem-test.tsx @@ -20,12 +20,13 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { click } from '../../../../helpers/testUtils'; +import { User } from '../../../../types/types'; import UserListItem from '../UserListItem'; jest.mock('../../../../components/intl/DateFromNow'); jest.mock('../../../../components/intl/DateTimeFormatter'); -const user: T.User = { +const user: User = { active: true, lastConnectionDate: '2019-01-18T15:06:33+0100', local: false, diff --git a/server/sonar-web/src/main/js/apps/users/utils.ts b/server/sonar-web/src/main/js/apps/users/utils.ts index e5b1d89655b..ac6280ab292 100644 --- a/server/sonar-web/src/main/js/apps/users/utils.ts +++ b/server/sonar-web/src/main/js/apps/users/utils.ts @@ -19,19 +19,20 @@ */ import { memoize } from 'lodash'; import { cleanQuery, parseAsString, serializeString } from '../../helpers/query'; +import { RawQuery } from '../../types/types'; export interface Query { search: string; } export const parseQuery = memoize( - (urlQuery: T.RawQuery): Query => ({ + (urlQuery: RawQuery): Query => ({ search: parseAsString(urlQuery['search']) }) ); export const serializeQuery = memoize( - (query: Query): T.RawQuery => + (query: Query): RawQuery => cleanQuery({ search: query.search ? serializeString(query.search) : undefined }) diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Action.tsx b/server/sonar-web/src/main/js/apps/web-api/components/Action.tsx index cda482e9f61..2777316dd1c 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Action.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/Action.tsx @@ -22,6 +22,7 @@ import * as React from 'react'; import { Link } from 'react-router'; import LinkIcon from '../../../components/icons/LinkIcon'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { WebApi } from '../../../types/types'; import { getActionKey, serializeQuery } from '../utils'; import ActionChangelog from './ActionChangelog'; import DeprecatedBadge from './DeprecatedBadge'; @@ -30,8 +31,8 @@ import Params from './Params'; import ResponseExample from './ResponseExample'; interface Props { - action: T.WebApi.Action; - domain: T.WebApi.Domain; + action: WebApi.Action; + domain: WebApi.Domain; showDeprecated: boolean; showInternal: boolean; } diff --git a/server/sonar-web/src/main/js/apps/web-api/components/ActionChangelog.tsx b/server/sonar-web/src/main/js/apps/web-api/components/ActionChangelog.tsx index 856ccbef995..e7d8198cfcb 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/ActionChangelog.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/ActionChangelog.tsx @@ -18,9 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { WebApi } from '../../../types/types'; interface Props { - changelog: T.WebApi.Changelog[]; + changelog: WebApi.Changelog[]; } export default function ActionChangelog({ changelog }: Props) { diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Domain.tsx b/server/sonar-web/src/main/js/apps/web-api/components/Domain.tsx index 47b72c9a46e..9be6638e723 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Domain.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/Domain.tsx @@ -18,13 +18,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { WebApi } from '../../../types/types'; import { actionsFilter, getActionKey, Query } from '../utils'; import Action from './Action'; import DeprecatedBadge from './DeprecatedBadge'; import InternalBadge from './InternalBadge'; interface Props { - domain: T.WebApi.Domain; + domain: WebApi.Domain; query: Query; } diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Menu.tsx b/server/sonar-web/src/main/js/apps/web-api/components/Menu.tsx index c39bf9b2eb1..82fa81f2a9f 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Menu.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/Menu.tsx @@ -20,12 +20,13 @@ import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; +import { WebApi } from '../../../types/types'; import { actionsFilter, isDomainPathActive, Query, serializeQuery } from '../utils'; import DeprecatedBadge from './DeprecatedBadge'; import InternalBadge from './InternalBadge'; interface Props { - domains: T.WebApi.Domain[]; + domains: WebApi.Domain[]; query: Query; splat: string; } @@ -39,7 +40,7 @@ export default function Menu(props: Props) { }) .filter(domain => domain.filteredActions.length); - const renderDomain = (domain: T.WebApi.Domain) => { + const renderDomain = (domain: WebApi.Domain) => { const internal = !domain.actions.find(action => !action.internal); return ( <Link diff --git a/server/sonar-web/src/main/js/apps/web-api/components/Params.tsx b/server/sonar-web/src/main/js/apps/web-api/components/Params.tsx index 41746a001d7..8b2a4202170 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/Params.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/Params.tsx @@ -19,17 +19,18 @@ */ import * as React from 'react'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { WebApi } from '../../../types/types'; import DeprecatedBadge from './DeprecatedBadge'; import InternalBadge from './InternalBadge'; interface Props { - params: T.WebApi.Param[]; + params: WebApi.Param[]; showDeprecated: boolean; showInternal: boolean; } export default class Params extends React.PureComponent<Props> { - renderKey(param: T.WebApi.Param) { + renderKey(param: WebApi.Param) { return ( <td className="markdown" style={{ width: 180 }}> <code>{param.key}</code> @@ -69,7 +70,7 @@ export default class Params extends React.PureComponent<Props> { ); } - renderConstraint(param: T.WebApi.Param, field: keyof T.WebApi.Param, label: string) { + renderConstraint(param: WebApi.Param, field: keyof WebApi.Param, label: string) { const value = param[field]; if (value !== undefined) { return ( diff --git a/server/sonar-web/src/main/js/apps/web-api/components/ResponseExample.tsx b/server/sonar-web/src/main/js/apps/web-api/components/ResponseExample.tsx index ade727b8772..393de0a3c45 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/ResponseExample.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/ResponseExample.tsx @@ -19,14 +19,15 @@ */ import * as React from 'react'; import { fetchResponseExample as fetchResponseExampleApi } from '../../../api/web-api'; +import { WebApi } from '../../../types/types'; interface Props { - action: T.WebApi.Action; - domain: T.WebApi.Domain; + action: WebApi.Action; + domain: WebApi.Domain; } interface State { - responseExample?: T.WebApi.Example; + responseExample?: WebApi.Example; } export default class ResponseExample extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.tsx b/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.tsx index fda24c8f547..6f9cb520f5a 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/WebApiApp.tsx @@ -28,6 +28,7 @@ import ScreenPositionHelper from '../../../components/common/ScreenPositionHelpe import { translate } from '../../../helpers/l10n'; import { addSideBarClass, removeSideBarClass } from '../../../helpers/pages'; import { scrollToElement } from '../../../helpers/scrolling'; +import { WebApi } from '../../../types/types'; import '../styles/web-api.css'; import { getActionKey, @@ -44,7 +45,7 @@ import Search from './Search'; type Props = WithRouterProps; interface State { - domains: T.WebApi.Domain[]; + domains: WebApi.Domain[]; } export class WebApiApp extends React.PureComponent<Props, State> { @@ -78,7 +79,7 @@ export class WebApiApp extends React.PureComponent<Props, State> { ); } - parseDomains(domains: any[]): T.WebApi.Domain[] { + parseDomains(domains: any[]): WebApi.Domain[] { return domains.map(domain => { const deprecated = getLatestDeprecatedAction(domain); const internal = !domain.actions.find((action: any) => !action.internal); @@ -199,7 +200,7 @@ export class WebApiApp extends React.PureComponent<Props, State> { export default withRouter(WebApiApp); /** Checks if all actions are deprecated, and returns the latest deprecated one */ -function getLatestDeprecatedAction(domain: Pick<T.WebApi.Domain, 'actions'>) { +function getLatestDeprecatedAction(domain: Pick<WebApi.Domain, 'actions'>) { const noVersion = { major: 0, minor: 0 }; const allActionsDeprecated = domain.actions.every( ({ deprecatedSince }) => deprecatedSince !== undefined diff --git a/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Menu-test.tsx b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Menu-test.tsx index b47e77c8cd1..4e4f46952e1 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Menu-test.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Menu-test.tsx @@ -19,9 +19,10 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { WebApi } from '../../../../types/types'; import Menu from '../Menu'; -const ACTION: T.WebApi.Action = { +const ACTION: WebApi.Action = { key: 'foo', changelog: [], description: 'Foo Desc', @@ -29,12 +30,12 @@ const ACTION: T.WebApi.Action = { internal: false, post: false }; -const DOMAIN1: T.WebApi.Domain = { +const DOMAIN1: WebApi.Domain = { actions: [ACTION], path: 'foo', description: 'API Foo' }; -const DOMAIN2: T.WebApi.Domain = { +const DOMAIN2: WebApi.Domain = { actions: [ACTION], path: 'bar', description: 'API Bar' @@ -51,7 +52,7 @@ const SEARCH_FOO = { search: 'Foo', deprecated: false, internal: false }; const SEARCH_BAR = { search: 'Bar', deprecated: false, internal: false }; it('should render deprecated domains', () => { - const domain: T.WebApi.Domain = { + const domain: WebApi.Domain = { ...DOMAIN2, deprecatedSince: '5.0', actions: [{ ...ACTION, deprecatedSince: '5.0' }] @@ -61,7 +62,7 @@ it('should render deprecated domains', () => { }); it('should not render deprecated domains', () => { - const domain: T.WebApi.Domain = { + const domain: WebApi.Domain = { ...DOMAIN2, deprecatedSince: '5.0', actions: [{ ...ACTION, deprecatedSince: '5.0' }] @@ -71,7 +72,7 @@ it('should not render deprecated domains', () => { }); it('should render internal domains', () => { - const domain: T.WebApi.Domain = { + const domain: WebApi.Domain = { ...DOMAIN2, internal: true, actions: [{ ...ACTION, internal: true }] @@ -81,7 +82,7 @@ it('should render internal domains', () => { }); it('should not render internal domains', () => { - const domain: T.WebApi.Domain = { + const domain: WebApi.Domain = { ...DOMAIN2, internal: true, actions: [{ ...ACTION, internal: true }] @@ -91,7 +92,7 @@ it('should not render internal domains', () => { }); it('should render only domains with an action matching the query', () => { - const domain: T.WebApi.Domain = { + const domain: WebApi.Domain = { ...DOMAIN2, actions: [{ ...ACTION, key: 'bar', description: 'Bar Desc' }] }; @@ -100,7 +101,7 @@ it('should render only domains with an action matching the query', () => { }); it('should also render domains with an actions description matching the query', () => { - const domain: T.WebApi.Domain = { + const domain: WebApi.Domain = { ...DOMAIN1, path: 'baz', description: 'API Baz', diff --git a/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Params-test.tsx b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Params-test.tsx index 218aff10dbf..a12c09bff6a 100644 --- a/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Params-test.tsx +++ b/server/sonar-web/src/main/js/apps/web-api/components/__tests__/Params-test.tsx @@ -19,9 +19,10 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { WebApi } from '../../../../types/types'; import Params from '../Params'; -const DEFAULT_PARAM: T.WebApi.Param = { +const DEFAULT_PARAM: WebApi.Param = { key: 'foo', description: 'Foo desc', internal: false, @@ -56,7 +57,7 @@ it('should render deprecated key', () => { }); it('should render different value constraints', () => { - const param: T.WebApi.Param = { + const param: WebApi.Param = { ...DEFAULT_PARAM, defaultValue: 'def', exampleValue: 'foo', diff --git a/server/sonar-web/src/main/js/apps/web-api/utils.ts b/server/sonar-web/src/main/js/apps/web-api/utils.ts index 86329e02465..7655e3c53dd 100644 --- a/server/sonar-web/src/main/js/apps/web-api/utils.ts +++ b/server/sonar-web/src/main/js/apps/web-api/utils.ts @@ -24,6 +24,7 @@ import { parseAsString, serializeString } from '../../helpers/query'; +import { RawQuery, WebApi } from '../../types/types'; export interface Query { search: string; @@ -31,7 +32,7 @@ export interface Query { internal: boolean; } -export function actionsFilter(query: Query, domain: T.WebApi.Domain, action: T.WebApi.Action) { +export function actionsFilter(query: Query, domain: WebApi.Domain, action: WebApi.Action) { const lowSearchQuery = query.search.toLowerCase(); return ( (query.internal || !action.internal) && @@ -63,7 +64,7 @@ export const isDomainPathActive = (path: string, splat: string) => { }; export const parseQuery = memoize( - (urlQuery: T.RawQuery): Query => ({ + (urlQuery: RawQuery): Query => ({ search: parseAsString(urlQuery['query']), deprecated: parseAsOptionalBoolean(urlQuery['deprecated']) || false, internal: parseAsOptionalBoolean(urlQuery['internal']) || false @@ -71,7 +72,7 @@ export const parseQuery = memoize( ); export const serializeQuery = memoize( - (query: Partial<Query>): T.RawQuery => + (query: Partial<Query>): RawQuery => cleanQuery({ query: query.search ? serializeString(query.search) : undefined, deprecated: query.deprecated || undefined, diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/App.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/App.tsx index 4ba44aab5d4..29299bb45fa 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/App.tsx @@ -22,17 +22,18 @@ import { Helmet } from 'react-helmet-async'; import { createWebhook, deleteWebhook, searchWebhooks, updateWebhook } from '../../../api/webhooks'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import { translate } from '../../../helpers/l10n'; +import { LightComponent, Webhook } from '../../../types/types'; import PageActions from './PageActions'; import PageHeader from './PageHeader'; import WebhooksList from './WebhooksList'; interface Props { - component?: T.LightComponent; + component?: LightComponent; } interface State { loading: boolean; - webhooks: T.Webhook[]; + webhooks: Webhook[]; } export default class App extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/CreateWebhookForm.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/CreateWebhookForm.tsx index cfeb285deed..323abe9b924 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/CreateWebhookForm.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/CreateWebhookForm.tsx @@ -24,11 +24,12 @@ import ValidationModal from '../../../components/controls/ValidationModal'; import MandatoryFieldMarker from '../../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../../helpers/l10n'; +import { Webhook } from '../../../types/types'; interface Props { onClose: () => void; onDone: (data: Values) => Promise<void>; - webhook?: T.Webhook; + webhook?: Webhook; } interface Values { diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/DeleteWebhookForm.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/DeleteWebhookForm.tsx index b543fbc1242..38d3d9f60b4 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/DeleteWebhookForm.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/DeleteWebhookForm.tsx @@ -22,11 +22,12 @@ import { ResetButtonLink, SubmitButton } from '../../../components/controls/butt import SimpleModal from '../../../components/controls/SimpleModal'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Webhook } from '../../../types/types'; interface Props { onClose: () => void; onSubmit: () => Promise<void>; - webhook: T.Webhook; + webhook: Webhook; } export default function DeleteWebhookForm({ onClose, onSubmit, webhook }: Props) { diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/DeliveriesForm.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/DeliveriesForm.tsx index ffd7c4d39d6..1e89a7d979b 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/DeliveriesForm.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/DeliveriesForm.tsx @@ -24,17 +24,18 @@ import ListFooter from '../../../components/controls/ListFooter'; import Modal from '../../../components/controls/Modal'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Paging, Webhook, WebhookDelivery } from '../../../types/types'; import DeliveryAccordion from './DeliveryAccordion'; interface Props { onClose: () => void; - webhook: T.Webhook; + webhook: Webhook; } interface State { - deliveries: T.WebhookDelivery[]; + deliveries: WebhookDelivery[]; loading: boolean; - paging?: T.Paging; + paging?: Paging; } const PAGE_SIZE = 10; diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/DeliveryAccordion.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/DeliveryAccordion.tsx index 42c74882ba9..3b2c62ab95c 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/DeliveryAccordion.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/DeliveryAccordion.tsx @@ -23,10 +23,11 @@ import BoxedGroupAccordion from '../../../components/controls/BoxedGroupAccordio import AlertErrorIcon from '../../../components/icons/AlertErrorIcon'; import AlertSuccessIcon from '../../../components/icons/AlertSuccessIcon'; import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; +import { WebhookDelivery } from '../../../types/types'; import DeliveryItem from './DeliveryItem'; interface Props { - delivery: T.WebhookDelivery; + delivery: WebhookDelivery; } interface State { diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/DeliveryItem.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/DeliveryItem.tsx index bfa6d026a17..65a077cabfb 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/DeliveryItem.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/DeliveryItem.tsx @@ -22,10 +22,11 @@ import CodeSnippet from '../../../components/common/CodeSnippet'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; +import { WebhookDelivery } from '../../../types/types'; interface Props { className?: string; - delivery: T.WebhookDelivery; + delivery: WebhookDelivery; loading: boolean; payload: string | undefined; } diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/LatestDeliveryForm.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/LatestDeliveryForm.tsx index 012b9466a50..8bf16263158 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/LatestDeliveryForm.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/LatestDeliveryForm.tsx @@ -22,12 +22,13 @@ import { getDelivery } from '../../../api/webhooks'; import { ResetButtonLink } from '../../../components/controls/buttons'; import Modal from '../../../components/controls/Modal'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Webhook, WebhookDelivery } from '../../../types/types'; import DeliveryItem from './DeliveryItem'; interface Props { - delivery: T.WebhookDelivery; + delivery: WebhookDelivery; onClose: () => void; - webhook: T.Webhook; + webhook: Webhook; } interface State { diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/WebhookActions.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/WebhookActions.tsx index 5b09c83230e..3837343b040 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/WebhookActions.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/WebhookActions.tsx @@ -23,6 +23,7 @@ import ActionsDropdown, { ActionsDropdownItem } from '../../../components/controls/ActionsDropdown'; import { translate } from '../../../helpers/l10n'; +import { Webhook } from '../../../types/types'; import CreateWebhookForm from './CreateWebhookForm'; import DeleteWebhookForm from './DeleteWebhookForm'; import DeliveriesForm from './DeliveriesForm'; @@ -30,7 +31,7 @@ import DeliveriesForm from './DeliveriesForm'; interface Props { onDelete: (webhook: string) => Promise<void>; onUpdate: (data: { webhook: string; name: string; url: string }) => Promise<void>; - webhook: T.Webhook; + webhook: Webhook; } interface State { diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/WebhookItem.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/WebhookItem.tsx index 22f864d2809..2c3b738f198 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/WebhookItem.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/WebhookItem.tsx @@ -19,13 +19,14 @@ */ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; +import { Webhook } from '../../../types/types'; import WebhookActions from './WebhookActions'; import WebhookItemLatestDelivery from './WebhookItemLatestDelivery'; interface Props { onDelete: (webhook: string) => Promise<void>; onUpdate: (data: { webhook: string; name: string; url: string }) => Promise<void>; - webhook: T.Webhook; + webhook: Webhook; } export default function WebhookItem({ onDelete, onUpdate, webhook }: Props) { diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/WebhookItemLatestDelivery.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/WebhookItemLatestDelivery.tsx index e8e671c10e3..88e4656f583 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/WebhookItemLatestDelivery.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/WebhookItemLatestDelivery.tsx @@ -24,10 +24,11 @@ import AlertSuccessIcon from '../../../components/icons/AlertSuccessIcon'; import BulletListIcon from '../../../components/icons/BulletListIcon'; import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; import { translate } from '../../../helpers/l10n'; +import { Webhook } from '../../../types/types'; import LatestDeliveryForm from './LatestDeliveryForm'; interface Props { - webhook: T.Webhook; + webhook: Webhook; } interface State { diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/WebhooksList.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/WebhooksList.tsx index 40f8815a9a9..40ae1294aad 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/WebhooksList.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/WebhooksList.tsx @@ -20,12 +20,13 @@ import { sortBy } from 'lodash'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; +import { Webhook } from '../../../types/types'; import WebhookItem from './WebhookItem'; interface Props { onDelete: (webhook: string) => Promise<void>; onUpdate: (data: { webhook: string; name: string; url: string }) => Promise<void>; - webhooks: T.Webhook[]; + webhooks: Webhook[]; } export default class WebhooksList extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx index 949673bb7b1..fb1d304694c 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx @@ -29,6 +29,17 @@ import { Alert } from '../../components/ui/Alert'; import { getBranchLikeQuery, isSameBranchLike } from '../../helpers/branch-like'; import { translate } from '../../helpers/l10n'; import { BranchLike } from '../../types/branch-like'; +import { + Dict, + DuplicatedFile, + Duplication, + FlowLocation, + Issue, + LinearIssueLocation, + Measure, + SourceLine, + SourceViewerFile +} from '../../types/types'; import { WorkspaceContext } from '../workspace/context'; import DuplicationPopup from './components/DuplicationPopup'; import { @@ -56,7 +67,7 @@ export interface Props { aroundLine?: number; branchLike: BranchLike | undefined; component: string; - componentMeasures?: T.Measure[]; + componentMeasures?: Measure[]; displayAllIssues?: boolean; displayIssueLocationsCount?: boolean; displayIssueLocationsLink?: boolean; @@ -64,27 +75,27 @@ export interface Props { highlightedLine?: number; // `undefined` elements mean they are located in a different file, // but kept to maintaint the location indexes - highlightedLocations?: (T.FlowLocation | undefined)[]; + highlightedLocations?: (FlowLocation | undefined)[]; highlightedLocationMessage?: { index: number; text: string | undefined }; loadComponent?: ( component: string, branchLike: BranchLike | undefined - ) => Promise<T.SourceViewerFile>; + ) => Promise<SourceViewerFile>; loadIssues?: ( component: string, from: number, to: number, branchLike: BranchLike | undefined - ) => Promise<T.Issue[]>; + ) => Promise<Issue[]>; loadSources?: ( component: string, from: number, to: number, branchLike: BranchLike | undefined - ) => Promise<T.SourceLine[]>; - onLoaded?: (component: T.SourceViewerFile, sources: T.SourceLine[], issues: T.Issue[]) => void; + ) => Promise<SourceLine[]>; + onLoaded?: (component: SourceViewerFile, sources: SourceLine[], issues: Issue[]) => void; onLocationSelect?: (index: number) => void; - onIssueChange?: (issue: T.Issue) => void; + onIssueChange?: (issue: Issue) => void; onIssueSelect?: (issueKey: string) => void; onIssueUnselect?: () => void; scroll?: (element: HTMLElement) => void; @@ -95,16 +106,16 @@ export interface Props { } interface State { - component?: T.SourceViewerFile; - duplicatedFiles?: T.Dict<T.DuplicatedFile>; - duplications?: T.Duplication[]; + component?: SourceViewerFile; + duplicatedFiles?: Dict<DuplicatedFile>; + duplications?: Duplication[]; duplicationsByLine: { [line: number]: number[] }; hasSourcesAfter: boolean; highlightedSymbols: string[]; - issueLocationsByLine: { [line: number]: T.LinearIssueLocation[] }; + issueLocationsByLine: { [line: number]: LinearIssueLocation[] }; issuePopup?: { issue: string; name: string }; - issues?: T.Issue[]; - issuesByLine: { [line: number]: T.Issue[] }; + issues?: Issue[]; + issuesByLine: { [line: number]: Issue[] }; loading: boolean; loadingSourcesAfter: boolean; loadingSourcesBefore: boolean; @@ -113,7 +124,7 @@ interface State { openIssuesByLine: { [line: number]: boolean }; selectedIssue?: string; sourceRemoved: boolean; - sources?: T.SourceLine[]; + sources?: SourceLine[]; symbolsByLine: { [line: number]: string[] }; } @@ -214,7 +225,7 @@ export default class SourceViewerBase extends React.PureComponent<Props, State> return this.props.loadSources || defaultLoadSources; } - computeCoverageStatus(lines: T.SourceLine[]) { + computeCoverageStatus(lines: SourceLine[]) { return lines.map(line => ({ ...line, coverageStatus: getCoverageStatus(line) })); } @@ -233,7 +244,7 @@ export default class SourceViewerBase extends React.PureComponent<Props, State> this.setState({ loading: true }); const to = (this.props.aroundLine || 0) + LINES; - const loadIssues = (component: T.SourceViewerFile, sources: T.SourceLine[]) => { + const loadIssues = (component: SourceViewerFile, sources: SourceLine[]) => { this.loadIssues(this.props.component, 1, to, this.props.branchLike).then( issues => { if (this.mounted) { @@ -284,7 +295,7 @@ export default class SourceViewerBase extends React.PureComponent<Props, State> } }; - const onFailLoadSources = (response: Response, component: T.SourceViewerFile) => { + const onFailLoadSources = (response: Response, component: SourceViewerFile) => { // TODO handle other statuses if (this.mounted) { if (response.status === 403) { @@ -295,7 +306,7 @@ export default class SourceViewerBase extends React.PureComponent<Props, State> } }; - const onResolve = (component: T.SourceViewerFile) => { + const onResolve = (component: SourceViewerFile) => { const sourcesRequest = component.q === 'FIL' || component.q === 'UTS' ? this.loadSources() : Promise.resolve([]); sourcesRequest.then( @@ -361,7 +372,7 @@ export default class SourceViewerBase extends React.PureComponent<Props, State> ); } - loadSources = (): Promise<T.SourceLine[]> => { + loadSources = (): Promise<SourceLine[]> => { return new Promise((resolve, reject) => { const onFailLoadSources = (response: Response) => { // TODO handle other statuses @@ -525,19 +536,19 @@ export default class SourceViewerBase extends React.PureComponent<Props, State> } }; - handleOpenIssues = (line: T.SourceLine) => { + handleOpenIssues = (line: SourceLine) => { this.setState(state => ({ openIssuesByLine: { ...state.openIssuesByLine, [line.line]: true } })); }; - handleCloseIssues = (line: T.SourceLine) => { + handleCloseIssues = (line: SourceLine) => { this.setState(state => ({ openIssuesByLine: { ...state.openIssuesByLine, [line.line]: false } })); }; - handleIssueChange = (issue: T.Issue) => { + handleIssueChange = (issue: Issue) => { this.setState(({ issues = [] }) => { const newIssues = issues.map(candidate => (candidate.key === issue.key ? issue : candidate)); return { issues: newIssues, issuesByLine: issuesByLine(newIssues) }; @@ -572,7 +583,7 @@ export default class SourceViewerBase extends React.PureComponent<Props, State> ); }; - renderCode(sources: T.SourceLine[]) { + renderCode(sources: SourceLine[]) { const hasSourcesBefore = sources.length > 0 && sources[0].line > 1; return ( <SourceViewerCode @@ -618,7 +629,7 @@ export default class SourceViewerBase extends React.PureComponent<Props, State> ); } - renderHeader(branchLike: BranchLike | undefined, sourceViewerFile: T.SourceViewerFile) { + renderHeader(branchLike: BranchLike | undefined, sourceViewerFile: SourceViewerFile) { return this.props.slimHeader ? ( <SourceViewerHeaderSlim branchLike={branchLike} sourceViewerFile={sourceViewerFile} /> ) : ( @@ -682,7 +693,7 @@ export default class SourceViewerBase extends React.PureComponent<Props, State> function defaultLoadComponent( component: string, branchLike: BranchLike | undefined -): Promise<T.SourceViewerFile> { +): Promise<SourceViewerFile> { return Promise.all([ getComponentForSourceViewer({ component, ...getBranchLikeQuery(branchLike) }), getComponentData({ component, ...getBranchLikeQuery(branchLike) }) diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx index d108b1442f9..06e55ef452b 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx @@ -22,6 +22,13 @@ import { Button } from '../../components/controls/buttons'; import { translate } from '../../helpers/l10n'; import { BranchLike } from '../../types/branch-like'; import { MetricKey } from '../../types/metrics'; +import { + Duplication, + FlowLocation, + Issue, + LinearIssueLocation, + SourceLine +} from '../../types/types'; import Line from './components/Line'; import { getSecondaryIssueLocationsForLine } from './helpers/issueLocations'; import { @@ -46,7 +53,7 @@ interface Props { displayIssueLocationsCount?: boolean; displayIssueLocationsLink?: boolean; displayLocationMarkers?: boolean; - duplications: T.Duplication[] | undefined; + duplications: Duplication[] | undefined; duplicationsByLine: { [line: number]: number[] }; hasSourcesAfter: boolean; hasSourcesBefore: boolean; @@ -54,22 +61,22 @@ interface Props { highlightedLocationMessage: { index: number; text: string | undefined } | undefined; // `undefined` elements mean they are located in a different file, // but kept to maintain the location indexes - highlightedLocations: (T.FlowLocation | undefined)[] | undefined; + highlightedLocations: (FlowLocation | undefined)[] | undefined; highlightedSymbols: string[]; - issueLocationsByLine: { [line: number]: T.LinearIssueLocation[] }; + issueLocationsByLine: { [line: number]: LinearIssueLocation[] }; issuePopup: { issue: string; name: string } | undefined; - issues: T.Issue[] | undefined; - issuesByLine: { [line: number]: T.Issue[] }; - loadDuplications: (line: T.SourceLine) => void; + issues: Issue[] | undefined; + issuesByLine: { [line: number]: Issue[] }; + loadDuplications: (line: SourceLine) => void; loadingSourcesAfter: boolean; loadingSourcesBefore: boolean; loadSourcesAfter: () => void; loadSourcesBefore: () => void; - onIssueChange: (issue: T.Issue) => void; + onIssueChange: (issue: Issue) => void; onIssuePopupToggle: (issue: string, popupName: string, open?: boolean) => void; - onIssuesClose: (line: T.SourceLine) => void; + onIssuesClose: (line: SourceLine) => void; onIssueSelect: (issueKey: string) => void; - onIssuesOpen: (line: T.SourceLine) => void; + onIssuesOpen: (line: SourceLine) => void; onIssueUnselect: () => void; onLocationSelect: ((index: number) => void) | undefined; onSymbolClick: (symbols: string[]) => void; @@ -78,7 +85,7 @@ interface Props { scroll?: (element: HTMLElement) => void; metricKey?: string; selectedIssue: string | undefined; - sources: T.SourceLine[]; + sources: SourceLine[]; symbolsByLine: { [line: number]: string[] }; } @@ -91,15 +98,15 @@ export default class SourceViewerCode extends React.PureComponent<Props> { } } - getDuplicationsForLine = (line: T.SourceLine): number[] => { + getDuplicationsForLine = (line: SourceLine): number[] => { return this.props.duplicationsByLine[line.line] || EMPTY_ARRAY; }; - getIssuesForLine = (line: T.SourceLine): T.Issue[] => { + getIssuesForLine = (line: SourceLine): Issue[] => { return this.props.issuesByLine[line.line] || EMPTY_ARRAY; }; - getIssueLocationsForLine = (line: T.SourceLine): T.LinearIssueLocation[] => { + getIssueLocationsForLine = (line: SourceLine): LinearIssueLocation[] => { return this.props.issueLocationsByLine[line.line] || EMPTY_ARRAY; }; @@ -110,7 +117,7 @@ export default class SourceViewerCode extends React.PureComponent<Props> { displayDuplications, displayIssues }: { - line: T.SourceLine; + line: SourceLine; index: number; displayCoverage: boolean; displayDuplications: boolean; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerContext.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerContext.tsx index 546f7d01c8f..e9273583f0b 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerContext.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerContext.tsx @@ -19,13 +19,14 @@ */ import * as React from 'react'; import { BranchLike } from '../../types/branch-like'; +import { SourceViewerFile } from '../../types/types'; interface SourceViewerContextShape { branchLike?: BranchLike; - file: T.SourceViewerFile; + file: SourceViewerFile; } export const SourceViewerContext = React.createContext<SourceViewerContextShape>({ branchLike: {} as BranchLike, - file: {} as T.SourceViewerFile + file: {} as SourceViewerFile }); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx index 2ea560e1937..2ea13fcc33d 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx @@ -41,15 +41,16 @@ import { } from '../../helpers/urls'; import { BranchLike } from '../../types/branch-like'; import { ComponentQualifier } from '../../types/component'; +import { IssueType, Measure, SourceViewerFile } from '../../types/types'; import { WorkspaceContextShape } from '../workspace/context'; import MeasuresOverlay from './components/MeasuresOverlay'; interface Props { branchLike: BranchLike | undefined; - componentMeasures?: T.Measure[]; + componentMeasures?: Measure[]; openComponent: WorkspaceContextShape['openComponent']; showMeasures?: boolean; - sourceViewerFile: T.SourceViewerFile; + sourceViewerFile: SourceViewerFile; } interface State { @@ -82,7 +83,7 @@ export default class SourceViewerHeader extends React.PureComponent<Props, State <> <div className="source-viewer-header-measure-separator" /> - {ISSUE_TYPES.map((type: T.IssueType) => { + {ISSUE_TYPES.map((type: IssueType) => { const params = { ...getBranchLikeQuery(branchLike), files: sourceViewerFile.path, diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx index f0c70947618..1587c00ee2d 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeaderSlim.tsx @@ -31,6 +31,7 @@ import { collapsedDirFromPath, fileFromPath } from '../../helpers/path'; import { getBranchLikeUrl, getComponentIssuesUrl, getPathUrlAsString } from '../../helpers/urls'; import { BranchLike } from '../../types/branch-like'; import { ComponentQualifier } from '../../types/component'; +import { SourceViewerFile } from '../../types/types'; import './SourceViewerHeaderSlim.css'; export interface Props { @@ -40,7 +41,7 @@ export interface Props { linkToProject?: boolean; loading?: boolean; onExpand?: () => void; - sourceViewerFile: T.SourceViewerFile; + sourceViewerFile: SourceViewerFile; } export default function SourceViewerHeaderSlim(props: Props) { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeader-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeader-test.tsx index 2daf53f6013..1a879dcb4c8 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeader-test.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerHeader-test.tsx @@ -22,6 +22,7 @@ import * as React from 'react'; import { mockMainBranch } from '../../../helpers/mocks/branch-like'; import { mockSourceViewerFile } from '../../../helpers/testMocks'; import { MetricKey } from '../../../types/metrics'; +import { Measure } from '../../../types/types'; import SourceViewerHeader from '../SourceViewerHeader'; it('should render correctly for a regular file', () => { @@ -38,7 +39,7 @@ it('should render correctly for a unit test', () => { }); it('should render correctly if issue details are passed', () => { - const componentMeasures: T.Measure[] = [ + const componentMeasures: Measure[] = [ { metric: MetricKey.code_smells, value: '1' }, { metric: MetricKey.file_complexity_distribution, value: '42' }, // unused, should be ignored { metric: MetricKey.security_hotspots, value: '2' }, diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx index 3071fbe2ed6..746344a4e07 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/DuplicationPopup.tsx @@ -27,15 +27,16 @@ import { translate } from '../../../helpers/l10n'; import { collapsedDirFromPath, fileFromPath } from '../../../helpers/path'; import { getProjectUrl } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; +import { Dict, DuplicatedFile, DuplicationBlock, SourceViewerFile } from '../../../types/types'; import { WorkspaceContextShape } from '../../workspace/context'; interface Props { - blocks: T.DuplicationBlock[]; + blocks: DuplicationBlock[]; branchLike: BranchLike | undefined; - duplicatedFiles?: T.Dict<T.DuplicatedFile>; + duplicatedFiles?: Dict<DuplicatedFile>; inRemovedComponent: boolean; openComponent: WorkspaceContextShape['openComponent']; - sourceViewerFile: T.SourceViewerFile; + sourceViewerFile: SourceViewerFile; } export default class DuplicationPopup extends React.PureComponent<Props> { @@ -64,7 +65,7 @@ export default class DuplicationPopup extends React.PureComponent<Props> { } }; - renderDuplication(file: T.DuplicatedFile, children: React.ReactNode, line?: number) { + renderDuplication(file: DuplicatedFile, children: React.ReactNode, line?: number) { return this.shouldLink() ? ( <a data-key={file.key} diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx index 58b835d88c8..4aa2507a885 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.tsx @@ -21,6 +21,7 @@ import classNames from 'classnames'; import { times } from 'lodash'; import * as React from 'react'; import { BranchLike } from '../../../types/branch-like'; +import { Issue, LinearIssueLocation, SourceLine } from '../../../types/types'; import './Line.css'; import LineCode from './LineCode'; import LineCoverage from './LineCoverage'; @@ -46,26 +47,26 @@ interface Props { highlighted: boolean; highlightedLocationMessage: { index: number; text: string | undefined } | undefined; highlightedSymbols: string[] | undefined; - issueLocations: T.LinearIssueLocation[]; + issueLocations: LinearIssueLocation[]; issuePopup: { issue: string; name: string } | undefined; - issues: T.Issue[]; + issues: Issue[]; last: boolean; - line: T.SourceLine; - loadDuplications: (line: T.SourceLine) => void; - onIssueChange: (issue: T.Issue) => void; + line: SourceLine; + loadDuplications: (line: SourceLine) => void; + onIssueChange: (issue: Issue) => void; onIssuePopupToggle: (issueKey: string, popupName: string, open?: boolean) => void; - onIssuesClose: (line: T.SourceLine) => void; + onIssuesClose: (line: SourceLine) => void; onIssueSelect: (issueKey: string) => void; - onIssuesOpen: (line: T.SourceLine) => void; + onIssuesOpen: (line: SourceLine) => void; onIssueUnselect: () => void; onLocationSelect: ((x: number) => void) | undefined; onSymbolClick: (symbols: string[]) => void; openIssues: boolean; - previousLine: T.SourceLine | undefined; + previousLine: SourceLine | undefined; renderDuplicationPopup: (index: number, line: number) => React.ReactNode; scroll?: (element: HTMLElement) => void; scrollToUncoveredLine?: boolean; - secondaryIssueLocations: T.LinearIssueLocation[]; + secondaryIssueLocations: LinearIssueLocation[]; selectedIssue: string | undefined; verticalBuffer?: number; } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx index bcf53776df9..3509f570bd4 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx @@ -20,6 +20,7 @@ import classNames from 'classnames'; import * as React from 'react'; import { BranchLike } from '../../../types/branch-like'; +import { Issue, LinearIssueLocation, SourceLine } from '../../../types/types'; import LocationIndex from '../../common/LocationIndex'; import LocationMessage from '../../common/LocationMessage'; import { @@ -37,18 +38,18 @@ interface Props { displayLocationMarkers?: boolean; highlightedLocationMessage: { index: number; text: string | undefined } | undefined; highlightedSymbols: string[] | undefined; - issueLocations: T.LinearIssueLocation[]; + issueLocations: LinearIssueLocation[]; issuePopup: { issue: string; name: string } | undefined; - issues: T.Issue[]; - line: T.SourceLine; - onIssueChange: (issue: T.Issue) => void; + issues: Issue[]; + line: SourceLine; + onIssueChange: (issue: Issue) => void; onIssuePopupToggle: (issue: string, popupName: string, open?: boolean) => void; onIssueSelect: (issueKey: string) => void; onLocationSelect: ((index: number) => void) | undefined; onSymbolClick: (symbols: Array<string>) => void; padding?: number; scroll?: (element: HTMLElement) => void; - secondaryIssueLocations: T.LinearIssueLocation[]; + secondaryIssueLocations: LinearIssueLocation[]; selectedIssue: string | undefined; showIssues?: boolean; } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.tsx index 0d36d7830ff..14b8d00874c 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.tsx @@ -20,9 +20,10 @@ import * as React from 'react'; import Tooltip from '../../../components/controls/Tooltip'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { SourceLine } from '../../../types/types'; export interface LineCoverageProps { - line: T.SourceLine; + line: SourceLine; scroll?: (element: HTMLElement) => void; scrollToUncoveredLine?: boolean; } @@ -49,7 +50,7 @@ export function LineCoverage({ line, scroll, scrollToUncoveredLine }: LineCovera ); } -function getStatusTooltip(line: T.SourceLine) { +function getStatusTooltip(line: SourceLine) { if (line.coverageStatus === 'uncovered') { if (line.conditions) { return translateWithParameters('source_viewer.tooltip.uncovered.conditions', line.conditions); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplicationBlock.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplicationBlock.tsx index 225edce276a..6a9cead37eb 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplicationBlock.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplicationBlock.tsx @@ -24,13 +24,14 @@ import Toggler from '../../../components/controls/Toggler'; import Tooltip from '../../../components/controls/Tooltip'; import { PopupPlacement } from '../../../components/ui/popups'; import { translate } from '../../../helpers/l10n'; +import { SourceLine } from '../../../types/types'; export interface LineDuplicationBlockProps { blocksLoaded: boolean; duplicated: boolean; index: number; - line: T.SourceLine; - onClick?: (line: T.SourceLine) => void; + line: SourceLine; + onClick?: (line: SourceLine) => void; renderDuplicationPopup: (index: number, line: number) => React.ReactNode; } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.tsx index 91e1191eedb..e5418fba9ce 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.tsx @@ -24,11 +24,12 @@ import Tooltip from '../../../components/controls/Tooltip'; import IssueIcon from '../../../components/icons/IssueIcon'; import { sortByType } from '../../../helpers/issues'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Issue, SourceLine } from '../../../types/types'; export interface LineIssuesIndicatorProps { - issues: T.Issue[]; + issues: Issue[]; issuesOpen?: boolean; - line: T.SourceLine; + line: SourceLine; onClick: () => void; } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.tsx index 19d3860bb84..fcc3720b382 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesList.tsx @@ -19,6 +19,7 @@ */ import * as React from 'react'; import { BranchLike } from '../../../types/branch-like'; +import { Issue as TypeIssue } from '../../../types/types'; import Issue from '../../issue/Issue'; interface Props { @@ -26,8 +27,8 @@ interface Props { displayIssueLocationsCount?: boolean; displayIssueLocationsLink?: boolean; issuePopup: { issue: string; name: string } | undefined; - issues: T.Issue[]; - onIssueChange: (issue: T.Issue) => void; + issues: TypeIssue[]; + onIssueChange: (issue: TypeIssue) => void; onIssueClick: (issueKey: string) => void; onIssuePopupToggle: (issue: string, popupName: string, open?: boolean) => void; selectedIssue: string | undefined; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineNumber.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineNumber.tsx index 31be34e3965..2842ae963cf 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineNumber.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineNumber.tsx @@ -20,12 +20,13 @@ import * as React from 'react'; import Toggler from '../../../components/controls/Toggler'; import { translateWithParameters } from '../../../helpers/l10n'; +import { SourceLine } from '../../../types/types'; import LineOptionsPopup from './LineOptionsPopup'; export interface LineNumberProps { displayOptions: boolean; firstLineNumber: number; - line: T.SourceLine; + line: SourceLine; } export function LineNumber({ displayOptions, firstLineNumber, line }: LineNumberProps) { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineOptionsPopup.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineOptionsPopup.tsx index 7bd16b97b50..321cdbc8ed7 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineOptionsPopup.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineOptionsPopup.tsx @@ -22,12 +22,13 @@ import { DropdownOverlay } from '../../../components/controls/Dropdown'; import { PopupPlacement } from '../../../components/ui/popups'; import { translate } from '../../../helpers/l10n'; import { getCodeUrl, getPathUrlAsString } from '../../../helpers/urls'; +import { SourceLine } from '../../../types/types'; import { ActionsDropdownItem } from '../../controls/ActionsDropdown'; import { SourceViewerContext } from '../SourceViewerContext'; export interface LineOptionsPopupProps { firstLineNumber: number; - line: T.SourceLine; + line: SourceLine; } export function LineOptionsPopup({ firstLineNumber, line }: LineOptionsPopupProps) { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineSCM.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineSCM.tsx index f4b892213a1..ff7f294d915 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineSCM.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineSCM.tsx @@ -21,11 +21,12 @@ import * as React from 'react'; import Dropdown from '../../../components/controls/Dropdown'; import { PopupPlacement } from '../../../components/ui/popups'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { SourceLine } from '../../../types/types'; import SCMPopup from './SCMPopup'; export interface LineSCMProps { - line: T.SourceLine; - previousLine: T.SourceLine | undefined; + line: SourceLine; + previousLine: SourceLine | undefined; } export function LineSCM({ line, previousLine }: LineSCMProps) { @@ -63,7 +64,7 @@ export function LineSCM({ line, previousLine }: LineSCMProps) { } } -function isSCMChanged(s: T.SourceLine, p: T.SourceLine | undefined) { +function isSCMChanged(s: SourceLine, p: SourceLine | undefined) { let changed = true; if (p != null && s.scmRevision != null && p.scmRevision != null) { changed = s.scmRevision !== p.scmRevision || s.scmDate !== p.scmDate; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx index dbcce374910..209674e7344 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlay.tsx @@ -39,6 +39,8 @@ import { } from '../../../helpers/measures'; import { getBranchLikeUrl } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; +import { IssueType as IssueTypeEnum } from '../../../types/issues'; +import { FacetValue, IssueType, MeasureEnhanced, SourceViewerFile } from '../../../types/types'; import Measure from '../../measure/Measure'; import SeverityHelper from '../../shared/SeverityHelper'; import CoverageRating from '../../ui/CoverageRating'; @@ -47,20 +49,20 @@ import MeasuresOverlayMeasure from './MeasuresOverlayMeasure'; interface Props { branchLike: BranchLike | undefined; onClose: () => void; - sourceViewerFile: T.SourceViewerFile; + sourceViewerFile: SourceViewerFile; } interface Measures { - [metricKey: string]: T.MeasureEnhanced; + [metricKey: string]: MeasureEnhanced; } interface State { loading: boolean; measures: Measures; - severitiesFacet?: T.FacetValue[]; + severitiesFacet?: FacetValue[]; showAllMeasures: boolean; - tagsFacet?: T.FacetValue[]; - typesFacet?: T.FacetValue<T.IssueType>[]; + tagsFacet?: FacetValue[]; + typesFacet?: FacetValue<IssueType>[]; } export default class MeasuresOverlay extends React.PureComponent<Props, State> { @@ -124,7 +126,7 @@ export default class MeasuresOverlay extends React.PureComponent<Props, State> { return { severitiesFacet: severitiesFacet && severitiesFacet.values, tagsFacet: tagsFacet && tagsFacet.values, - typesFacet: typesFacet && (typesFacet.values as T.FacetValue<T.IssueType>[]) + typesFacet: typesFacet && (typesFacet.values as FacetValue<IssueType>[]) }; }); }; @@ -135,7 +137,7 @@ export default class MeasuresOverlay extends React.PureComponent<Props, State> { this.setState({ showAllMeasures: true }); }; - renderMeasure = (measure: T.MeasureEnhanced | undefined) => { + renderMeasure = (measure: MeasureEnhanced | undefined) => { return measure ? <MeasuresOverlayMeasure key={measure.metric.key} measure={measure} /> : null; }; @@ -162,7 +164,7 @@ export default class MeasuresOverlay extends React.PureComponent<Props, State> { ); }; - renderBigMeasure = (measure: T.MeasureEnhanced | undefined) => { + renderBigMeasure = (measure: MeasureEnhanced | undefined) => { return measure ? ( <div className="measure measure-big" data-metric={measure.metric.key}> <span className="measure-value"> @@ -190,7 +192,7 @@ export default class MeasuresOverlay extends React.PureComponent<Props, State> { <> {typesFacet && ( <div className="measures"> - {sortBy(typesFacet, f => ISSUE_TYPES.indexOf(f.val)).map(f => ( + {sortBy(typesFacet, f => ISSUE_TYPES.indexOf(f.val as IssueTypeEnum)).map(f => ( <div className="measure measure-one-line" key={f.val}> <span className="measure-name"> <IssueTypeIcon className="little-spacer-right" query={f.val} /> @@ -327,7 +329,7 @@ export default class MeasuresOverlay extends React.PureComponent<Props, State> { ); }; - renderDomain = (domain: string, measures: T.MeasureEnhanced[]) => { + renderDomain = (domain: string, measures: MeasureEnhanced[]) => { return ( <div className="measures-viewer-card" key={domain}> <div className="measures"> diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayMeasure.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayMeasure.tsx index 5931b6e9ccf..e75807e663f 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayMeasure.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayMeasure.tsx @@ -21,10 +21,11 @@ import * as React from 'react'; import IssueTypeIcon from '../../../components/icons/IssueTypeIcon'; import { getLocalizedMetricName } from '../../../helpers/l10n'; import { isMetricKey, MetricKey } from '../../../types/metrics'; +import { Metric } from '../../../types/types'; import Measure from '../../measure/Measure'; export interface MeasureWithMetric { - metric: T.Metric; + metric: Metric; value?: string; } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/SCMPopup.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/SCMPopup.tsx index b9a23093708..347ca9d56bf 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/SCMPopup.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/SCMPopup.tsx @@ -20,10 +20,11 @@ import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../../helpers/l10n'; +import { SourceLine } from '../../../types/types'; import DateFormatter from '../../intl/DateFormatter'; export interface SCMPopupProps { - line: T.SourceLine; + line: SourceLine; } export function SCMPopup({ line }: SCMPopupProps) { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineIssuesList-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineIssuesList-test.tsx index 4b9dd3f991c..17666dd9599 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineIssuesList-test.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineIssuesList-test.tsx @@ -19,9 +19,10 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { Issue } from '../../../../types/types'; import LineIssuesList from '../LineIssuesList'; -const issueBase: T.Issue = { +const issueBase: Issue = { actions: [], component: '', componentLongName: '', @@ -45,7 +46,7 @@ const issueBase: T.Issue = { }; it('render issues list', () => { - const issues: T.Issue[] = [ + const issues: Issue[] = [ { ...issueBase, key: 'foo' }, { ...issueBase, key: 'bar' } ]; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx index e000aea59e2..01a2346121d 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlay-test.tsx @@ -22,6 +22,7 @@ import * as React from 'react'; import { mockBranch } from '../../../../helpers/mocks/branch-like'; import { click, waitAndUpdate } from '../../../../helpers/testUtils'; import { MetricKey } from '../../../../types/metrics'; +import { SourceViewerFile } from '../../../../types/types'; import MeasuresOverlay from '../MeasuresOverlay'; jest.mock('../../../../api/issues', () => ({ @@ -139,7 +140,7 @@ jest.mock('../../../../api/metrics', () => ({ ]) })); -const sourceViewerFile: T.SourceViewerFile = { +const sourceViewerFile: SourceViewerFile = { key: 'component-key', measures: {}, path: 'src/file.js', diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/duplications.ts b/server/sonar-web/src/main/js/components/SourceViewer/helpers/duplications.ts index ed1d94b6909..9f6eaed3a32 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/duplications.ts +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/duplications.ts @@ -17,8 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +import { Duplication, DuplicationBlock } from '../../../types/types'; + // TODO Test this function, but I don't get the logic behind it -export function filterDuplicationBlocksByLine(blocks: T.DuplicationBlock[], line: number) { +export function filterDuplicationBlocksByLine(blocks: DuplicationBlock[], line: number) { /* eslint-disable no-underscore-dangle */ let foundOne = false; return blocks.filter(b => { @@ -36,12 +39,12 @@ export function filterDuplicationBlocksByLine(blocks: T.DuplicationBlock[], line } export function getDuplicationBlocksForIndex( - duplications: T.Duplication[] | undefined, + duplications: Duplication[] | undefined, index: number ) { return (duplications && duplications[index] && duplications[index].blocks) || []; } -export function isDuplicationBlockInRemovedComponent(blocks: T.DuplicationBlock[]) { +export function isDuplicationBlockInRemovedComponent(blocks: DuplicationBlock[]) { return blocks.some(b => b._ref === undefined); // eslint-disable-line no-underscore-dangle } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/getCoverageStatus.ts b/server/sonar-web/src/main/js/components/SourceViewer/helpers/getCoverageStatus.ts index 01cafe5ba0f..d3413444a21 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/getCoverageStatus.ts +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/getCoverageStatus.ts @@ -1,3 +1,5 @@ +import { SourceLine, SourceLineCoverageStatus } from '../../../types/types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -17,8 +19,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export default function getCoverageStatus(s: T.SourceLine): T.SourceLineCoverageStatus | undefined { - let status: T.SourceLineCoverageStatus | undefined; +export default function getCoverageStatus(s: SourceLine): SourceLineCoverageStatus | undefined { + let status: SourceLineCoverageStatus | undefined; if (s.lineHits != null && s.lineHits > 0) { status = 'partially-covered'; } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/highlight.ts b/server/sonar-web/src/main/js/components/SourceViewer/helpers/highlight.ts index 81449947672..f2fc860d8ad 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/highlight.ts +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/highlight.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { uniq } from 'lodash'; +import { LinearIssueLocation } from '../../../types/types'; export interface Token { className: string; @@ -83,7 +84,7 @@ function part(str: string, from: number, to: number, acc: number): string { */ export function highlightIssueLocations( tokens: Token[], - issueLocations: T.LinearIssueLocation[], + issueLocations: LinearIssueLocation[], rootClassName: string = ISSUE_LOCATION_CLASS ): Token[] { issueLocations.forEach(location => { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.ts b/server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.ts index 3dc6c118ccd..fbc09b52359 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.ts +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.ts @@ -18,11 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { flatten } from 'lodash'; +import { Duplication, Issue, LinearIssueLocation, SourceLine } from '../../../types/types'; import { splitByTokens } from './highlight'; import { getLinearLocations } from './issueLocations'; -export function issuesByLine(issues: T.Issue[]) { - const index: { [line: number]: T.Issue[] } = {}; +export function issuesByLine(issues: Issue[]) { + const index: { [line: number]: Issue[] } = {}; issues.forEach(issue => { const line = issue.textRange ? issue.textRange.endLine : 0; if (!(line in index)) { @@ -34,9 +35,9 @@ export function issuesByLine(issues: T.Issue[]) { } export function issuesByComponentAndLine( - issues: T.Issue[] = [] -): { [component: string]: { [line: number]: T.Issue[] } } { - return issues.reduce((mapping: { [component: string]: { [line: number]: T.Issue[] } }, issue) => { + issues: Issue[] = [] +): { [component: string]: { [line: number]: Issue[] } } { + return issues.reduce((mapping: { [component: string]: { [line: number]: Issue[] } }, issue) => { mapping[issue.component] = mapping[issue.component] || {}; const line = issue.textRange ? issue.textRange.endLine : 0; mapping[issue.component][line] = mapping[issue.component][line] || []; @@ -45,8 +46,8 @@ export function issuesByComponentAndLine( }, {}); } -export function locationsByLine(issues: Pick<T.Issue, 'textRange'>[]) { - const index: { [line: number]: T.LinearIssueLocation[] } = {}; +export function locationsByLine(issues: Pick<Issue, 'textRange'>[]) { + const index: { [line: number]: LinearIssueLocation[] } = {}; issues.forEach(issue => { getLinearLocations(issue.textRange).forEach(location => { if (!(location.line in index)) { @@ -58,7 +59,7 @@ export function locationsByLine(issues: Pick<T.Issue, 'textRange'>[]) { return index; } -export function duplicationsByLine(duplications: T.Duplication[] | undefined) { +export function duplicationsByLine(duplications: Duplication[] | undefined) { if (duplications == null) { return {}; } @@ -82,7 +83,7 @@ export function duplicationsByLine(duplications: T.Duplication[] | undefined) { return duplicationsByLine; } -export function symbolsByLine(sources: T.SourceLine[]) { +export function symbolsByLine(sources: SourceLine[]) { const index: { [line: number]: string[] } = {}; sources.forEach(line => { const tokens = splitByTokens(line.code || ''); diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/issueLocations.ts b/server/sonar-web/src/main/js/components/SourceViewer/helpers/issueLocations.ts index 1043bb28cf1..4d9584822ab 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/issueLocations.ts +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/issueLocations.ts @@ -1,3 +1,5 @@ +import { FlowLocation, LinearIssueLocation, SourceLine, TextRange } from '../../../types/types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -17,7 +19,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export function getLinearLocations(textRange: T.TextRange | undefined): T.LinearIssueLocation[] { +export function getLinearLocations(textRange: TextRange | undefined): LinearIssueLocation[] { if (!textRange) { return []; } @@ -34,14 +36,14 @@ export function getLinearLocations(textRange: T.TextRange | undefined): T.Linear } export function getSecondaryIssueLocationsForLine( - line: T.SourceLine, - highlightedLocations: (T.FlowLocation | undefined)[] | undefined -): T.LinearIssueLocation[] { + line: SourceLine, + highlightedLocations: (FlowLocation | undefined)[] | undefined +): LinearIssueLocation[] { if (!highlightedLocations) { return []; } return highlightedLocations.reduce((locations, location) => { - const linearLocations: T.LinearIssueLocation[] = location + const linearLocations: LinearIssueLocation[] = location ? getLinearLocations(location.textRange) .filter(l => l.line === line.line) .map(l => ({ diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/lines.ts b/server/sonar-web/src/main/js/components/SourceViewer/helpers/lines.ts index 799513ba3d4..2ca758c9ef1 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/lines.ts +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/lines.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { intersection } from 'lodash'; +import { Issue, LinearIssueLocation } from '../../../types/types'; export function optimizeHighlightedSymbols( symbolsForLine: string[] = [], @@ -30,7 +31,7 @@ export function optimizeHighlightedSymbols( export function optimizeLocationMessage( highlightedLocationMessage: { index: number; text: string | undefined } | undefined, - optimizedSecondaryIssueLocations: T.LinearIssueLocation[] + optimizedSecondaryIssueLocations: LinearIssueLocation[] ) { return highlightedLocationMessage != null && optimizedSecondaryIssueLocations.some( @@ -40,7 +41,7 @@ export function optimizeLocationMessage( : undefined; } -export function optimizeSelectedIssue(selectedIssue: string | undefined, issuesForLine: T.Issue[]) { +export function optimizeSelectedIssue(selectedIssue: string | undefined, issuesForLine: Issue[]) { return selectedIssue !== undefined && issuesForLine.find(issue => issue.key === selectedIssue) ? selectedIssue : undefined; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts index c8ba6e03598..2fced3c4059 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.ts @@ -21,6 +21,7 @@ import { searchIssues } from '../../../api/issues'; import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { parseIssueFromResponse } from '../../../helpers/issues'; import { BranchLike } from '../../../types/branch-like'; +import { Issue, RawQuery } from '../../../types/types'; // maximum possible value const PAGE_SIZE = 500; @@ -35,11 +36,7 @@ function buildQuery(component: string, branchLike: BranchLike | undefined) { }; } -export function loadPage( - query: T.RawQuery, - page: number, - pageSize = PAGE_SIZE -): Promise<T.Issue[]> { +export function loadPage(query: RawQuery, page: number, pageSize = PAGE_SIZE): Promise<Issue[]> { return searchIssues({ ...query, p: page, @@ -50,11 +47,11 @@ export function loadPage( } export function loadPageAndNext( - query: T.RawQuery, + query: RawQuery, toLine: number, page: number, pageSize = PAGE_SIZE -): Promise<T.Issue[]> { +): Promise<Issue[]> { return loadPage(query, page).then(issues => { if (issues.length === 0) { return []; @@ -80,7 +77,7 @@ export default function loadIssues( _fromLine: number, toLine: number, branchLike: BranchLike | undefined -): Promise<T.Issue[]> { +): Promise<Issue[]> { const query = buildQuery(component, branchLike); return new Promise(resolve => { loadPageAndNext(query, toLine, 1).then(issues => { diff --git a/server/sonar-web/src/main/js/components/activity-graph/AddGraphMetric.tsx b/server/sonar-web/src/main/js/components/activity-graph/AddGraphMetric.tsx index 6f50f63de03..7e313936705 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/AddGraphMetric.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/AddGraphMetric.tsx @@ -24,12 +24,13 @@ import Dropdown from '../../components/controls/Dropdown'; import DropdownIcon from '../../components/icons/DropdownIcon'; import { getLocalizedMetricName, translate } from '../../helpers/l10n'; import { isDiffMetric } from '../../helpers/measures'; +import { Metric } from '../../types/types'; import AddGraphMetricPopup from './AddGraphMetricPopup'; interface Props { addMetric: (metric: string) => void; className?: string; - metrics: T.Metric[]; + metrics: Metric[]; metricsTypeFilter?: string[]; removeMetric: (metric: string) => void; selectedMetrics: string[]; @@ -81,7 +82,7 @@ export default class AddGraphMetric extends React.PureComponent<Props, State> { .map(metric => metric.key); }; - getSelectedMetricsElements = (metrics: T.Metric[], selectedMetrics?: string[]) => { + getSelectedMetricsElements = (metrics: Metric[], selectedMetrics?: string[]) => { const selected = selectedMetrics || this.props.selectedMetrics; return metrics.filter(metric => selected.includes(metric.key)).map(metric => metric.key); }; diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphHistory.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphHistory.tsx index af55a9814a6..ce93bbc2c4d 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphHistory.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphHistory.tsx @@ -22,12 +22,13 @@ import { AutoSizer } from 'react-virtualized/dist/commonjs/AutoSizer'; import AdvancedTimeline from '../../components/charts/AdvancedTimeline'; import { formatMeasure, getShortType } from '../../helpers/measures'; import { MeasureHistory, Serie } from '../../types/project-activity'; +import { AnalysisEvent } from '../../types/types'; import GraphsLegendCustom from './GraphsLegendCustom'; import GraphsLegendStatic from './GraphsLegendStatic'; import GraphsTooltips from './GraphsTooltips'; interface Props { - events: T.AnalysisEvent[]; + events: AnalysisEvent[]; graph: string; graphEndDate?: Date; graphStartDate?: Date; diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsHeader.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsHeader.tsx index e783b394cef..a2ad51be507 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsHeader.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsHeader.tsx @@ -21,6 +21,7 @@ import classNames from 'classnames'; import * as React from 'react'; import { translate } from '../../helpers/l10n'; import { GraphType } from '../../types/project-activity'; +import { Metric } from '../../types/types'; import SelectLegacy from '../controls/SelectLegacy'; import AddGraphMetric from './AddGraphMetric'; import './styles.css'; @@ -31,7 +32,7 @@ interface Props { className?: string; removeCustomMetric?: (metric: string) => void; graph: GraphType; - metrics: T.Metric[]; + metrics: Metric[]; metricsTypeFilter?: string[]; selectedMetrics?: string[]; updateGraph: (graphType: string) => void; diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsHistory.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsHistory.tsx index 29d351983c5..e4f4894ebd6 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsHistory.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsHistory.tsx @@ -23,12 +23,13 @@ import DeferredSpinner from '../../components/ui/DeferredSpinner'; import { translate } from '../../helpers/l10n'; import { getBaseUrl } from '../../helpers/system'; import { GraphType, MeasureHistory, Serie } from '../../types/project-activity'; +import { ParsedAnalysis } from '../../types/types'; import GraphHistory from './GraphHistory'; import './styles.css'; import { getSeriesMetricType, hasHistoryData, isCustomGraph } from './utils'; interface Props { - analyses: T.ParsedAnalysis[]; + analyses: ParsedAnalysis[]; graph: GraphType; graphs: Serie[][]; graphEndDate?: Date; diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltips.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltips.tsx index 5fefe862278..4e175e2de88 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltips.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltips.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import { Popup, PopupPlacement } from '../../components/ui/popups'; import { isDefined } from '../../helpers/types'; import { MeasureHistory, Serie } from '../../types/project-activity'; +import { AnalysisEvent } from '../../types/types'; import DateTimeFormatter from '../intl/DateTimeFormatter'; import GraphsTooltipsContent from './GraphsTooltipsContent'; import GraphsTooltipsContentCoverage from './GraphsTooltipsContentCoverage'; @@ -30,7 +31,7 @@ import GraphsTooltipsContentIssues from './GraphsTooltipsContentIssues'; import { DEFAULT_GRAPH } from './utils'; interface Props { - events: T.AnalysisEvent[]; + events: AnalysisEvent[]; formatValue: (tick: number | string) => string; graph: string; graphWidth: number; diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentEvents.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentEvents.tsx index 98c07f2dc2c..b905ed858df 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentEvents.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentEvents.tsx @@ -19,10 +19,11 @@ */ import * as React from 'react'; import EventInner from '../../apps/projectActivity/components/EventInner'; +import { AnalysisEvent } from '../../types/types'; interface Props { addSeparator: boolean; - events: T.AnalysisEvent[]; + events: AnalysisEvent[]; } export default function GraphsTooltipsContentEvents({ addSeparator, events }: Props) { diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentIssues.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentIssues.tsx index 14bb68e56b9..7b5b4c6dc71 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentIssues.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentIssues.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import ChartLegendIcon from '../../components/icons/ChartLegendIcon'; import Rating from '../../components/ui/Rating'; import { MeasureHistory } from '../../types/project-activity'; +import { Dict } from '../../types/types'; export interface GraphsTooltipsContentIssuesProps { index: number; @@ -31,7 +32,7 @@ export interface GraphsTooltipsContentIssuesProps { value: string; } -const METRIC_RATING: T.Dict<string> = { +const METRIC_RATING: Dict<string> = { bugs: 'reliability_rating', vulnerabilities: 'security_rating', code_smells: 'sqale_rating' diff --git a/server/sonar-web/src/main/js/components/activity-graph/utils.ts b/server/sonar-web/src/main/js/components/activity-graph/utils.ts index c0d44ce9c41..e79c9e4e82f 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/utils.ts +++ b/server/sonar-web/src/main/js/components/activity-graph/utils.ts @@ -23,16 +23,17 @@ import { localizeMetric } from '../../helpers/measures'; import { get, save } from '../../helpers/storage'; import { MetricKey } from '../../types/metrics'; import { GraphType, MeasureHistory, Serie } from '../../types/project-activity'; +import { Dict, Metric } from '../../types/types'; export const DEFAULT_GRAPH = GraphType.issues; -const GRAPHS_METRICS_DISPLAYED: T.Dict<string[]> = { +const GRAPHS_METRICS_DISPLAYED: Dict<string[]> = { [GraphType.issues]: [MetricKey.bugs, MetricKey.code_smells, MetricKey.vulnerabilities], [GraphType.coverage]: [MetricKey.lines_to_cover, MetricKey.uncovered_lines], [GraphType.duplications]: [MetricKey.ncloc, MetricKey.duplicated_lines] }; -const GRAPHS_METRICS: T.Dict<string[]> = { +const GRAPHS_METRICS: Dict<string[]> = { [GraphType.issues]: GRAPHS_METRICS_DISPLAYED[GraphType.issues].concat([ MetricKey.reliability_rating, MetricKey.security_rating, @@ -106,7 +107,7 @@ export function generateCoveredLinesMetric( export function generateSeries( measuresHistory: MeasureHistory[], graph: GraphType, - metrics: T.Metric[] | T.Dict<T.Metric>, + metrics: Metric[] | Dict<Metric>, displayedMetrics: string[] ): Serie[] { if (displayedMetrics.length <= 0 || measuresHistory === undefined) { @@ -158,7 +159,7 @@ export function getActivityGraph( }; } -function findMetric(key: string, metrics: T.Metric[] | T.Dict<T.Metric>) { +function findMetric(key: string, metrics: Metric[] | Dict<Metric>) { if (Array.isArray(metrics)) { return metrics.find(metric => metric.key === key); } diff --git a/server/sonar-web/src/main/js/components/charts/AdvancedTimeline.tsx b/server/sonar-web/src/main/js/components/charts/AdvancedTimeline.tsx index 86afbce4763..58a1557c988 100644 --- a/server/sonar-web/src/main/js/components/charts/AdvancedTimeline.tsx +++ b/server/sonar-web/src/main/js/components/charts/AdvancedTimeline.tsx @@ -25,6 +25,7 @@ import { flatten, isEqual, sortBy, throttle, uniq } from 'lodash'; import * as React from 'react'; import { colors, rawSizes } from '../../app/theme'; import { isDefined } from '../../helpers/types'; +import { Chart } from '../../types/types'; import './AdvancedTimeline.css'; import './LineChart.css'; @@ -44,7 +45,7 @@ export interface Props { metricType: string; padding: number[]; selectedDate?: Date; - series: T.Chart.Serie[]; + series: Chart.Serie[]; showAreas?: boolean; startDate?: Date; updateSelectedDate?: (selectedDate?: Date) => void; @@ -140,7 +141,7 @@ export default class AdvancedTimeline extends React.PureComponent<Props, State> .range([availableHeight, 0]); }; - getYScale = (props: Props, availableHeight: number, flatData: T.Chart.Point[]): YScale => { + getYScale = (props: Props, availableHeight: number, flatData: Chart.Point[]): YScale => { if (props.metricType === 'RATING') { return this.getRatingScale(availableHeight); } else if (props.metricType === 'LEVEL') { @@ -152,11 +153,7 @@ export default class AdvancedTimeline extends React.PureComponent<Props, State> .nice(); }; - getXScale = ( - { startDate, endDate }: Props, - availableWidth: number, - flatData: T.Chart.Point[] - ) => { + getXScale = ({ startDate, endDate }: Props, availableWidth: number, flatData: Chart.Point[]) => { const dateRange = extent(flatData, d => d.x) as [Date, Date]; const start = startDate && startDate > dateRange[0] ? startDate : dateRange[0]; const end = endDate && endDate < dateRange[1] ? endDate : dateRange[1]; @@ -266,7 +263,7 @@ export default class AdvancedTimeline extends React.PureComponent<Props, State> if (state.mouseOver && firstSerie) { const { updateTooltip } = this.props; const date = state.xScale.invert(xPos); - const bisectX = bisector<T.Chart.Point, Date>(d => d.x).right; + const bisectX = bisector<Chart.Point, Date>(d => d.x).right; let idx = bisectX(firstSerie.data, date); if (idx >= 0) { const previousPoint = firstSerie.data[idx - 1]; @@ -450,7 +447,7 @@ export default class AdvancedTimeline extends React.PureComponent<Props, State> }; renderLines = () => { - const lineGenerator = d3Line<T.Chart.Point>() + const lineGenerator = d3Line<Chart.Point>() .defined(d => Boolean(d.y || d.y === 0)) .x(d => this.state.xScale(d.x)) .y(d => this.state.yScale(d.y)); @@ -504,7 +501,7 @@ export default class AdvancedTimeline extends React.PureComponent<Props, State> }; renderAreas = () => { - const areaGenerator = area<T.Chart.Point>() + const areaGenerator = area<Chart.Point>() .defined(d => Boolean(d.y || d.y === 0)) .x(d => this.state.xScale(d.x)) .y1(d => this.state.yScale(d.y)) diff --git a/server/sonar-web/src/main/js/components/charts/LanguageDistribution.tsx b/server/sonar-web/src/main/js/components/charts/LanguageDistribution.tsx index 3aeda4d3b43..83df85e75b1 100644 --- a/server/sonar-web/src/main/js/components/charts/LanguageDistribution.tsx +++ b/server/sonar-web/src/main/js/components/charts/LanguageDistribution.tsx @@ -25,10 +25,11 @@ import { translate } from '../../helpers/l10n'; import { formatMeasure } from '../../helpers/measures'; import { getLanguages, Store } from '../../store/rootReducer'; import { MetricType } from '../../types/metrics'; +import { Languages } from '../../types/types'; interface LanguageDistributionProps { distribution: string; - languages: T.Languages; + languages: Languages; } const NUMBER_FORMAT_THRESHOLD = 1000; diff --git a/server/sonar-web/src/main/js/components/charts/TreeMap.tsx b/server/sonar-web/src/main/js/components/charts/TreeMap.tsx index 30eef58f938..d7e6b4664d3 100644 --- a/server/sonar-web/src/main/js/components/charts/TreeMap.tsx +++ b/server/sonar-web/src/main/js/components/charts/TreeMap.tsx @@ -21,6 +21,7 @@ import { hierarchy as d3Hierarchy, treemap as d3Treemap } from 'd3-hierarchy'; import * as React from 'react'; import { formatMeasure, localizeMetric } from '../../helpers/measures'; import { Location } from '../../helpers/urls'; +import { ComponentMeasureEnhanced } from '../../types/types'; import './TreeMap.css'; import TreeMapRect from './TreeMapRect'; @@ -35,7 +36,7 @@ export interface TreeMapItem { metric?: { key: string; type: string }; size: number; tooltip?: React.ReactNode; - component: T.ComponentMeasureEnhanced; + component: ComponentMeasureEnhanced; } interface HierarchicalTreemapItem extends TreeMapItem { @@ -45,7 +46,7 @@ interface HierarchicalTreemapItem extends TreeMapItem { interface Props { height: number; items: TreeMapItem[]; - onRectangleClick?: (item: T.ComponentMeasureEnhanced) => void; + onRectangleClick?: (item: ComponentMeasureEnhanced) => void; width: number; } @@ -65,7 +66,7 @@ export default class TreeMap extends React.PureComponent<Props> { return prefix.substr(0, prefix.length - lastPrefixPart.length); }; - handleClick = (component: T.ComponentMeasureEnhanced) => { + handleClick = (component: ComponentMeasureEnhanced) => { if (this.props.onRectangleClick) { this.props.onRectangleClick(component); } diff --git a/server/sonar-web/src/main/js/components/charts/ZoomTimeLine.tsx b/server/sonar-web/src/main/js/components/charts/ZoomTimeLine.tsx index 41542eda4bf..b05a64c85a0 100644 --- a/server/sonar-web/src/main/js/components/charts/ZoomTimeLine.tsx +++ b/server/sonar-web/src/main/js/components/charts/ZoomTimeLine.tsx @@ -25,6 +25,7 @@ import { flatten, sortBy, throttle } from 'lodash'; import * as React from 'react'; import Draggable, { DraggableBounds, DraggableCore, DraggableData } from 'react-draggable'; import { colors } from '../../app/theme'; +import { Chart } from '../../types/types'; import './LineChart.css'; import './ZoomTimeLine.css'; @@ -35,7 +36,7 @@ export interface Props { leakPeriodDate?: Date; metricType: string; padding: number[]; - series: T.Chart.Serie[]; + series: Chart.Serie[]; showAreas?: boolean; showXTicks: boolean; startDate?: Date; @@ -79,7 +80,7 @@ export default class ZoomTimeLine extends React.PureComponent<Props, State> { .range([availableHeight, 0]); }; - getYScale = (availableHeight: number, flatData: T.Chart.Point[]): YScale => { + getYScale = (availableHeight: number, flatData: Chart.Point[]): YScale => { if (this.props.metricType === 'RATING') { return this.getRatingScale(availableHeight); } else if (this.props.metricType === 'LEVEL') { @@ -91,7 +92,7 @@ export default class ZoomTimeLine extends React.PureComponent<Props, State> { .nice(); }; - getXScale = (availableWidth: number, flatData: T.Chart.Point[]): XScale => { + getXScale = (availableWidth: number, flatData: Chart.Point[]): XScale => { return scaleTime() .domain(extent(flatData, d => d.x) as [Date, Date]) .range([0, availableWidth]) @@ -233,7 +234,7 @@ export default class ZoomTimeLine extends React.PureComponent<Props, State> { }; renderLines = (xScale: XScale, yScale: YScale) => { - const lineGenerator = d3Line<T.Chart.Point>() + const lineGenerator = d3Line<Chart.Point>() .defined(d => Boolean(d.y || d.y === 0)) .x(d => xScale(d.x)) .y(d => yScale(d.y)); @@ -254,7 +255,7 @@ export default class ZoomTimeLine extends React.PureComponent<Props, State> { }; renderAreas = (xScale: XScale, yScale: YScale) => { - const areaGenerator = area<T.Chart.Point>() + const areaGenerator = area<Chart.Point>() .defined(d => Boolean(d.y || d.y === 0)) .x(d => xScale(d.x)) .y1(d => yScale(d.y)) diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/AdvancedTimeline-test.tsx b/server/sonar-web/src/main/js/components/charts/__tests__/AdvancedTimeline-test.tsx index 47a07318c08..1531d6f34a9 100644 --- a/server/sonar-web/src/main/js/components/charts/__tests__/AdvancedTimeline-test.tsx +++ b/server/sonar-web/src/main/js/components/charts/__tests__/AdvancedTimeline-test.tsx @@ -19,6 +19,7 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { Chart } from '../../../types/types'; import AdvancedTimeline from '../AdvancedTimeline'; const newCodeLegendClass = '.new-code-legend'; @@ -283,7 +284,7 @@ function shallowRender(props?: Partial<AdvancedTimeline['props']>) { ); } -function mockData(i: number, date: string): T.Chart.Serie { +function mockData(i: number, date: string): Chart.Serie { return { name: `t${i}`, type: 'type', diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx b/server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx index 967b075314f..72965fc6960 100644 --- a/server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx +++ b/server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx @@ -27,6 +27,7 @@ import { mockComponentMeasureEnhanced } from '../../../helpers/mocks/component'; import { mockHtmlElement } from '../../../helpers/mocks/dom'; import { mockEvent } from '../../../helpers/testMocks'; import { click } from '../../../helpers/testUtils'; +import { ComponentMeasureEnhanced } from '../../../types/types'; import BubbleChart from '../BubbleChart'; jest.mock('react-virtualized/dist/commonjs/AutoSizer', () => ({ @@ -136,8 +137,8 @@ it('should correctly handle zooming', () => { }); }); -function shallowRender(props: Partial<BubbleChart<T.ComponentMeasureEnhanced>['props']> = {}) { - return shallow<BubbleChart<T.ComponentMeasureEnhanced>>( +function shallowRender(props: Partial<BubbleChart<ComponentMeasureEnhanced>['props']> = {}) { + return shallow<BubbleChart<ComponentMeasureEnhanced>>( <BubbleChart height={100} items={[ diff --git a/server/sonar-web/src/main/js/components/common/AnalysisWarningsModal.tsx b/server/sonar-web/src/main/js/components/common/AnalysisWarningsModal.tsx index a426bcc7bf6..06e7a880ce5 100644 --- a/server/sonar-web/src/main/js/components/common/AnalysisWarningsModal.tsx +++ b/server/sonar-web/src/main/js/components/common/AnalysisWarningsModal.tsx @@ -26,11 +26,12 @@ import DeferredSpinner from '../../components/ui/DeferredSpinner'; import { translate } from '../../helpers/l10n'; import { sanitizeStringRestricted } from '../../helpers/sanitize'; import { TaskWarning } from '../../types/tasks'; +import { CurrentUser } from '../../types/types'; import { withCurrentUser } from '../hoc/withCurrentUser'; interface Props { componentKey?: string; - currentUser: T.CurrentUser; + currentUser: CurrentUser; onClose: () => void; onWarningDismiss?: () => void; taskId?: string; diff --git a/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx b/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx index 9515fc39afe..08d11a9ce98 100644 --- a/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx +++ b/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx @@ -21,11 +21,12 @@ import classNames from 'classnames'; import * as React from 'react'; import Tooltip from '../../components/controls/Tooltip'; import { translate } from '../../helpers/l10n'; +import { Visibility } from '../../types/types'; interface PrivacyBadgeContainerProps { className?: string; qualifier: string; - visibility: T.Visibility; + visibility: Visibility; } export default function PrivacyBadgeContainer({ diff --git a/server/sonar-web/src/main/js/components/common/ResetPasswordForm.tsx b/server/sonar-web/src/main/js/components/common/ResetPasswordForm.tsx index d25834908cd..e8b47242af3 100644 --- a/server/sonar-web/src/main/js/components/common/ResetPasswordForm.tsx +++ b/server/sonar-web/src/main/js/components/common/ResetPasswordForm.tsx @@ -24,10 +24,11 @@ import { Alert } from '../../components/ui/Alert'; import MandatoryFieldMarker from '../../components/ui/MandatoryFieldMarker'; import MandatoryFieldsExplanation from '../../components/ui/MandatoryFieldsExplanation'; import { translate } from '../../helpers/l10n'; +import { LoggedInUser } from '../../types/types'; interface Props { className?: string; - user: T.LoggedInUser; + user: LoggedInUser; onPasswordChange?: () => void; } diff --git a/server/sonar-web/src/main/js/components/common/RestartButton.tsx b/server/sonar-web/src/main/js/components/common/RestartButton.tsx index 612d4caf6d5..bcc04b880a1 100644 --- a/server/sonar-web/src/main/js/components/common/RestartButton.tsx +++ b/server/sonar-web/src/main/js/components/common/RestartButton.tsx @@ -23,11 +23,12 @@ import { restart } from '../../api/system'; import { Button } from '../../components/controls/buttons'; import ConfirmButton from '../../components/controls/ConfirmButton'; import { translate } from '../../helpers/l10n'; +import { SysStatus } from '../../types/types'; interface Props { className?: string; fetchSystemStatus: () => void; - systemStatus: T.SysStatus; + systemStatus: SysStatus; } export default class RestartButton extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx b/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx index 1432f8df59e..064e638da6e 100644 --- a/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx +++ b/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx @@ -21,13 +21,14 @@ import classNames from 'classnames'; import * as React from 'react'; import Radio from '../../components/controls/Radio'; import { translate } from '../../helpers/l10n'; +import { Visibility } from '../../types/types'; interface Props { canTurnToPrivate?: boolean; className?: string; - onChange: (visibility: T.Visibility) => void; + onChange: (visibility: Visibility) => void; showDetails?: boolean; - visibility?: T.Visibility; + visibility?: Visibility; } export default class VisibilitySelector extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/components/controls/ComponentReportActions.tsx b/server/sonar-web/src/main/js/components/controls/ComponentReportActions.tsx index cda9d227437..fa1ca1e896e 100644 --- a/server/sonar-web/src/main/js/components/controls/ComponentReportActions.tsx +++ b/server/sonar-web/src/main/js/components/controls/ComponentReportActions.tsx @@ -31,14 +31,15 @@ import { Store } from '../../store/rootReducer'; import { Branch } from '../../types/branch-like'; import { ComponentQualifier } from '../../types/component'; import { ComponentReportStatus } from '../../types/component-report'; +import { AppState, Component, CurrentUser } from '../../types/types'; import { withCurrentUser } from '../hoc/withCurrentUser'; import ComponentReportActionsRenderer from './ComponentReportActionsRenderer'; interface Props { - appState: Pick<T.AppState, 'qualifiers'>; - component: T.Component; + appState: Pick<AppState, 'qualifiers'>; + component: Component; branch?: Branch; - currentUser: T.CurrentUser; + currentUser: CurrentUser; } interface State { diff --git a/server/sonar-web/src/main/js/components/controls/ComponentReportActionsRenderer.tsx b/server/sonar-web/src/main/js/components/controls/ComponentReportActionsRenderer.tsx index ed1d82e8df9..723c7287539 100644 --- a/server/sonar-web/src/main/js/components/controls/ComponentReportActionsRenderer.tsx +++ b/server/sonar-web/src/main/js/components/controls/ComponentReportActionsRenderer.tsx @@ -25,9 +25,10 @@ import Dropdown from '../../components/controls/Dropdown'; import DropdownIcon from '../../components/icons/DropdownIcon'; import { translate, translateWithParameters } from '../../helpers/l10n'; import { Branch } from '../../types/branch-like'; +import { Component } from '../../types/types'; export interface ComponentReportActionsRendererProps { - component: T.Component; + component: Component; branch?: Branch; frequency: string; subscribed: boolean; diff --git a/server/sonar-web/src/main/js/components/controls/DateInput.tsx b/server/sonar-web/src/main/js/components/controls/DateInput.tsx index c0e0517ceeb..cbbc7a491f7 100644 --- a/server/sonar-web/src/main/js/components/controls/DateInput.tsx +++ b/server/sonar-web/src/main/js/components/controls/DateInput.tsx @@ -217,7 +217,7 @@ function NullComponent() { return null; } -type InputWrapperProps = T.Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value'> & +type InputWrapperProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value'> & WrappedComponentProps & { innerRef: React.Ref<HTMLInputElement>; value: Date | undefined; diff --git a/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx b/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx index 02b8f33ef44..7badef4259b 100644 --- a/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx +++ b/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx @@ -27,21 +27,22 @@ import { translate } from '../../helpers/l10n'; import { isLoggedIn } from '../../helpers/users'; import { getCurrentUser, Store } from '../../store/rootReducer'; import { setHomePage } from '../../store/users'; +import { CurrentUser, HomePage } from '../../types/types'; interface StateProps { - currentUser: T.CurrentUser; + currentUser: CurrentUser; } interface DispatchProps { - setHomePage: (homepage: T.HomePage) => void; + setHomePage: (homepage: HomePage) => void; } interface Props extends StateProps, DispatchProps { className?: string; - currentPage: T.HomePage; + currentPage: HomePage; } -export const DEFAULT_HOMEPAGE: T.HomePage = { type: 'PROJECTS' }; +export const DEFAULT_HOMEPAGE: HomePage = { type: 'PROJECTS' }; export class HomePageSelect extends React.PureComponent<Props> { handleClick = () => { @@ -95,7 +96,7 @@ const mapDispatchToProps: DispatchProps = { setHomePage }; export default connect(mapStateToProps, mapDispatchToProps)(HomePageSelect); -function isSameHomePage(a: T.HomePage, b: T.HomePage) { +function isSameHomePage(a: HomePage, b: HomePage) { return ( a.type === b.type && (a as any).branch === (b as any).branch && diff --git a/server/sonar-web/src/main/js/components/controls/ValidationForm.tsx b/server/sonar-web/src/main/js/components/controls/ValidationForm.tsx index 37e7127014a..29ecd999872 100644 --- a/server/sonar-web/src/main/js/components/controls/ValidationForm.tsx +++ b/server/sonar-web/src/main/js/components/controls/ValidationForm.tsx @@ -20,7 +20,7 @@ import { Formik, FormikActions, FormikProps } from 'formik'; import * as React from 'react'; -export type ChildrenProps<V> = T.Omit<FormikProps<V>, 'handleSubmit'>; +export type ChildrenProps<V> = Omit<FormikProps<V>, 'handleSubmit'>; interface Props<V> { children: (props: ChildrenProps<V>) => React.ReactNode; diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/HomePageSelect-test.tsx b/server/sonar-web/src/main/js/components/controls/__tests__/HomePageSelect-test.tsx index 360f3f1ad5e..2ab071da5c5 100644 --- a/server/sonar-web/src/main/js/components/controls/__tests__/HomePageSelect-test.tsx +++ b/server/sonar-web/src/main/js/components/controls/__tests__/HomePageSelect-test.tsx @@ -22,6 +22,7 @@ import * as React from 'react'; import { ButtonLink } from '../../../components/controls/buttons'; import { mockCurrentUser, mockLoggedInUser } from '../../../helpers/testMocks'; import { click, waitAndUpdate } from '../../../helpers/testUtils'; +import { HomePage } from '../../../types/types'; import { DEFAULT_HOMEPAGE, HomePageSelect } from '../HomePageSelect'; it('should render correctly', () => { @@ -40,7 +41,7 @@ it('should render correctly', () => { it('should correctly call webservices', async () => { const setHomePage = jest.fn(); - const currentPage: T.HomePage = { type: 'MY_ISSUES' }; + const currentPage: HomePage = { type: 'MY_ISSUES' }; const wrapper = shallowRender({ setHomePage, currentPage }); // Set homepage. diff --git a/server/sonar-web/src/main/js/components/controls/buttons.tsx b/server/sonar-web/src/main/js/components/controls/buttons.tsx index d2f39a0a7fd..7527d654e7b 100644 --- a/server/sonar-web/src/main/js/components/controls/buttons.tsx +++ b/server/sonar-web/src/main/js/components/controls/buttons.tsx @@ -91,12 +91,12 @@ export function ButtonLink({ className, ...props }: ButtonProps) { return <Button {...props} className={classNames('button-link', className)} />; } -export function SubmitButton(props: T.Omit<ButtonProps, 'type'>) { +export function SubmitButton(props: Omit<ButtonProps, 'type'>) { // do not prevent default to actually submit a form return <Button {...props} preventDefault={false} type="submit" />; } -export function ResetButtonLink(props: T.Omit<ButtonProps, 'type'>) { +export function ResetButtonLink(props: Omit<ButtonProps, 'type'>) { return <ButtonLink {...props} type="reset" />; } diff --git a/server/sonar-web/src/main/js/components/docs/DocLink.tsx b/server/sonar-web/src/main/js/components/docs/DocLink.tsx index ff51324b907..3cc0e2c8a7d 100644 --- a/server/sonar-web/src/main/js/components/docs/DocLink.tsx +++ b/server/sonar-web/src/main/js/components/docs/DocLink.tsx @@ -21,10 +21,11 @@ import * as React from 'react'; import { Link } from 'react-router'; import DetachIcon from '../../components/icons/DetachIcon'; import { isSonarCloud } from '../../helpers/system'; +import { AppState } from '../../types/types'; import { withAppState } from '../hoc/withAppState'; interface OwnProps { - appState: Pick<T.AppState, 'canAdmin'>; + appState: Pick<AppState, 'canAdmin'>; customProps?: { [k: string]: any; }; diff --git a/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx b/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx index 9d98c570e30..ebe7a85d0e5 100644 --- a/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx +++ b/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx @@ -26,6 +26,7 @@ import remark from 'remark'; import remarkCustomBlocks from 'remark-custom-blocks'; import remarkRehype from 'remark-rehype'; import { scrollToElement } from '../../helpers/scrolling'; +import { Dict } from '../../types/types'; import DocCollapsibleBlock from './DocCollapsibleBlock'; import DocImg from './DocImg'; import DocLink from './DocLink'; @@ -34,7 +35,7 @@ import DocToc from './DocToc'; import DocTooltipLink from './DocTooltipLink'; interface Props { - childProps?: T.Dict<string>; + childProps?: Dict<string>; className?: string; content: string; isTooltip?: boolean; @@ -118,8 +119,8 @@ export default class DocMarkdownBlock extends React.PureComponent<Props> { } function withChildProps<P>( - WrappedComponent: React.ComponentType<P & { customProps?: T.Dict<any> }>, - childProps?: T.Dict<any> + WrappedComponent: React.ComponentType<P & { customProps?: Dict<any> }>, + childProps?: Dict<any> ) { return function withChildProps(props: P) { return <WrappedComponent customProps={childProps} {...props} />; diff --git a/server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx b/server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx index b2d853e180f..af58e7ccdb9 100644 --- a/server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx +++ b/server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx @@ -21,9 +21,10 @@ import { forEach } from 'lodash'; import * as React from 'react'; import { Link } from 'react-router'; import DetachIcon from '../../components/icons/DetachIcon'; +import { Dict } from '../../types/types'; interface OwnProps { - customProps?: T.Dict<string>; + customProps?: Dict<string>; } type Props = OwnProps & React.AnchorHTMLAttributes<HTMLAnchorElement>; diff --git a/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx b/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx index bd4933f3ab6..8c727e619c2 100644 --- a/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx +++ b/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx @@ -27,6 +27,7 @@ import { Alert } from '../../components/ui/Alert'; import { translate } from '../../helpers/l10n'; import { formatMeasure } from '../../helpers/measures'; import { queriesEqual } from '../../helpers/query'; +import { Dict, Paging, RawQuery } from '../../types/types'; import FacetBox from './FacetBox'; import FacetHeader from './FacetHeader'; import FacetItem from './FacetItem'; @@ -37,7 +38,7 @@ import MultipleSelectionHint from './MultipleSelectionHint'; interface SearchResponse<S> { maxResults?: boolean; results: S[]; - paging?: T.Paging; + paging?: Paging; } export interface Props<S> { @@ -49,23 +50,23 @@ export interface Props<S> { getFacetItemText: (item: string) => string; getSearchResultKey: (result: S) => string; getSearchResultText: (result: S) => string; - loadSearchResultCount?: (result: S[]) => Promise<T.Dict<number>>; + loadSearchResultCount?: (result: S[]) => Promise<Dict<number>>; maxInitialItems: number; maxItems: number; minSearchLength: number; - onChange: (changes: T.Dict<string | string[]>) => void; + onChange: (changes: Dict<string | string[]>) => void; onClear?: () => void; onItemClick?: (itemValue: string, multiple: boolean) => void; onSearch: (query: string, page?: number) => Promise<SearchResponse<S>>; onToggle: (property: string) => void; open: boolean; property: string; - query?: T.RawQuery; + query?: RawQuery; renderFacetItem: (item: string) => React.ReactNode; renderSearchResult: (result: S, query: string) => React.ReactNode; searchPlaceholder: string; getSortedItems?: () => string[]; - stats: T.Dict<number> | undefined; + stats: Dict<number> | undefined; values: string[]; } @@ -74,9 +75,9 @@ interface State<S> { query: string; searching: boolean; searchMaxResults?: boolean; - searchPaging?: T.Paging; + searchPaging?: Paging; searchResults?: S[]; - searchResultsCounts: T.Dict<number>; + searchResultsCounts: Dict<number>; showFullList: boolean; } diff --git a/server/sonar-web/src/main/js/components/hoc/__tests__/withCurrentUser-test.tsx b/server/sonar-web/src/main/js/components/hoc/__tests__/withCurrentUser-test.tsx index 6ccddfec322..581fe01ebe2 100644 --- a/server/sonar-web/src/main/js/components/hoc/__tests__/withCurrentUser-test.tsx +++ b/server/sonar-web/src/main/js/components/hoc/__tests__/withCurrentUser-test.tsx @@ -20,9 +20,10 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { mockStore } from '../../../helpers/testMocks'; +import { CurrentUser } from '../../../types/types'; import { withCurrentUser } from '../withCurrentUser'; -class X extends React.Component<{ currentUser: T.CurrentUser }> { +class X extends React.Component<{ currentUser: CurrentUser }> { render() { return <div />; } diff --git a/server/sonar-web/src/main/js/components/hoc/__tests__/withKeyboardNavigation-test.tsx b/server/sonar-web/src/main/js/components/hoc/__tests__/withKeyboardNavigation-test.tsx index ac05b25a60f..1ee5e7e2361 100644 --- a/server/sonar-web/src/main/js/components/hoc/__tests__/withKeyboardNavigation-test.tsx +++ b/server/sonar-web/src/main/js/components/hoc/__tests__/withKeyboardNavigation-test.tsx @@ -22,11 +22,12 @@ import * as React from 'react'; import { KeyboardCodes } from '../../../helpers/keycodes'; import { mockComponent } from '../../../helpers/mocks/component'; import { KEYCODE_MAP, keydown } from '../../../helpers/testUtils'; +import { ComponentMeasure } from '../../../types/types'; import withKeyboardNavigation, { WithKeyboardNavigationProps } from '../withKeyboardNavigation'; class X extends React.Component<{ - components?: T.ComponentMeasure[]; - selected?: T.ComponentMeasure; + components?: ComponentMeasure[]; + selected?: ComponentMeasure; }> { render() { return <div />; diff --git a/server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx b/server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx index d258303c773..4b7840d0114 100644 --- a/server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx +++ b/server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx @@ -20,11 +20,12 @@ import * as React from 'react'; import handleRequiredAuthentication from '../../helpers/handleRequiredAuthentication'; import { isLoggedIn } from '../../helpers/users'; +import { CurrentUser } from '../../types/types'; import { getWrappedDisplayName } from './utils'; import { withCurrentUser } from './withCurrentUser'; export function whenLoggedIn<P>(WrappedComponent: React.ComponentType<P>) { - class Wrapper extends React.Component<P & { currentUser: T.CurrentUser }> { + class Wrapper extends React.Component<P & { currentUser: CurrentUser }> { static displayName = getWrappedDisplayName(WrappedComponent, 'whenLoggedIn'); componentDidMount() { diff --git a/server/sonar-web/src/main/js/components/hoc/withAppState.tsx b/server/sonar-web/src/main/js/components/hoc/withAppState.tsx index 0866eb92087..e0c32a70f77 100644 --- a/server/sonar-web/src/main/js/components/hoc/withAppState.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withAppState.tsx @@ -20,12 +20,13 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { getAppState, Store } from '../../store/rootReducer'; +import { AppState } from '../../types/types'; import { getWrappedDisplayName } from './utils'; export function withAppState<P>( - WrappedComponent: React.ComponentType<P & { appState: Partial<T.AppState> }> + WrappedComponent: React.ComponentType<P & { appState: Partial<AppState> }> ) { - class Wrapper extends React.Component<P & { appState: T.AppState }> { + class Wrapper extends React.Component<P & { appState: AppState }> { static displayName = getWrappedDisplayName(WrappedComponent, 'withAppState'); render() { diff --git a/server/sonar-web/src/main/js/components/hoc/withCurrentUser.tsx b/server/sonar-web/src/main/js/components/hoc/withCurrentUser.tsx index f08a11783b8..dd69ef91a44 100644 --- a/server/sonar-web/src/main/js/components/hoc/withCurrentUser.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withCurrentUser.tsx @@ -20,12 +20,13 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { getCurrentUser, Store } from '../../store/rootReducer'; +import { CurrentUser } from '../../types/types'; import { getWrappedDisplayName } from './utils'; export function withCurrentUser<P>( - WrappedComponent: React.ComponentType<P & { currentUser: T.CurrentUser }> + WrappedComponent: React.ComponentType<P & { currentUser: CurrentUser }> ) { - class Wrapper extends React.Component<P & { currentUser: T.CurrentUser }> { + class Wrapper extends React.Component<P & { currentUser: CurrentUser }> { static displayName = getWrappedDisplayName(WrappedComponent, 'withCurrentUser'); render() { diff --git a/server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx b/server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx index cebddd9aa14..ee15abb0c36 100644 --- a/server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx @@ -21,17 +21,18 @@ import key from 'keymaster'; import * as React from 'react'; import PageActions from '../../components/ui/PageActions'; import { getComponentMeasureUniqueKey } from '../../helpers/component'; +import { ComponentMeasure } from '../../types/types'; import { getWrappedDisplayName } from './utils'; export interface WithKeyboardNavigationProps { - components?: T.ComponentMeasure[]; + components?: ComponentMeasure[]; cycle?: boolean; isFile?: boolean; onEndOfList?: () => void; onGoToParent?: () => void; - onHighlight?: (item: T.ComponentMeasure) => void; - onSelect?: (item: T.ComponentMeasure) => void; - selected?: T.ComponentMeasure; + onHighlight?: (item: ComponentMeasure) => void; + onSelect?: (item: ComponentMeasure) => void; + selected?: ComponentMeasure; } const KEY_SCOPE = 'key_nav'; @@ -126,7 +127,7 @@ export default function withKeyboardNavigation<P>( const { selected } = this.props; if (selected !== undefined) { - this.props.onSelect(selected as T.ComponentMeasure); + this.props.onSelect(selected as ComponentMeasure); } }; diff --git a/server/sonar-web/src/main/js/components/hoc/withNotifications.tsx b/server/sonar-web/src/main/js/components/hoc/withNotifications.tsx index 7a4b2087d02..b6aae46c857 100644 --- a/server/sonar-web/src/main/js/components/hoc/withNotifications.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withNotifications.tsx @@ -20,24 +20,25 @@ import { uniqWith } from 'lodash'; import * as React from 'react'; import { addNotification, getNotifications, removeNotification } from '../../api/notifications'; +import { Notification } from '../../types/types'; import { getWrappedDisplayName } from './utils'; interface State { channels: string[]; globalTypes: string[]; loading: boolean; - notifications: T.Notification[]; + notifications: Notification[]; perProjectTypes: string[]; } export interface WithNotificationsProps { - addNotification: (added: T.Notification) => void; + addNotification: (added: Notification) => void; channels: string[]; globalTypes: string[]; loading: boolean; - notifications: T.Notification[]; + notifications: Notification[]; perProjectTypes: string[]; - removeNotification: (removed: T.Notification) => void; + removeNotification: (removed: Notification) => void; } export function withNotifications<P>( @@ -85,14 +86,14 @@ export function withNotifications<P>( ); }; - addNotificationToState = (added: T.Notification) => { + addNotificationToState = (added: Notification) => { this.setState(state => { const notifications = uniqWith([...state.notifications, added], this.areNotificationsEqual); return { notifications }; }); }; - removeNotificationFromState = (removed: T.Notification) => { + removeNotificationFromState = (removed: Notification) => { this.setState(state => { const notifications = state.notifications.filter( notification => !this.areNotificationsEqual(notification, removed) @@ -101,7 +102,7 @@ export function withNotifications<P>( }); }; - addNotification = (added: T.Notification) => { + addNotification = (added: Notification) => { // optimistic update this.addNotificationToState(added); @@ -112,7 +113,7 @@ export function withNotifications<P>( }); }; - removeNotification = (removed: T.Notification) => { + removeNotification = (removed: Notification) => { // optimistic update this.removeNotificationFromState(removed); @@ -123,7 +124,7 @@ export function withNotifications<P>( }); }; - areNotificationsEqual = (a: T.Notification, b: T.Notification) => { + areNotificationsEqual = (a: Notification, b: Notification) => { return a.channel === b.channel && a.type === b.type && a.project === b.project; }; diff --git a/server/sonar-web/src/main/js/components/hoc/withRouter.tsx b/server/sonar-web/src/main/js/components/hoc/withRouter.tsx index ed03762fddc..7d06624bfa0 100644 --- a/server/sonar-web/src/main/js/components/hoc/withRouter.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withRouter.tsx @@ -30,6 +30,6 @@ interface InjectedProps { export function withRouter<P extends InjectedProps>( WrappedComponent: React.ComponentType<P & InjectedProps> -): React.ComponentType<T.Omit<P, keyof InjectedProps>> { +): React.ComponentType<Omit<P, keyof InjectedProps>> { return originalWithRouter(WrappedComponent as any); } diff --git a/server/sonar-web/src/main/js/components/icons/IssueIcon.tsx b/server/sonar-web/src/main/js/components/icons/IssueIcon.tsx index e78a91bbc44..b3921530bd2 100644 --- a/server/sonar-web/src/main/js/components/icons/IssueIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons/IssueIcon.tsx @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IssueType } from '../../types/types'; import BugIcon from './BugIcon'; import CodeSmellIcon from './CodeSmellIcon'; import { IconProps } from './Icon'; @@ -25,7 +26,7 @@ import SecurityHotspotIcon from './SecurityHotspotIcon'; import VulnerabilityIcon from './VulnerabilityIcon'; interface Props extends IconProps { - type: T.IssueType; + type: IssueType; } export default function IssueIcon({ type, ...iconProps }: Props) { diff --git a/server/sonar-web/src/main/js/components/icons/IssueTypeIcon.tsx b/server/sonar-web/src/main/js/components/icons/IssueTypeIcon.tsx index 9815ce40a84..bf593add8b2 100644 --- a/server/sonar-web/src/main/js/components/icons/IssueTypeIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons/IssueTypeIcon.tsx @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { IssueType } from '../../types/types'; import { IconProps } from './Icon'; import IssueIcon from './IssueIcon'; @@ -26,7 +27,7 @@ export interface Props extends IconProps { } export default function IssueTypeIcon({ query, ...iconProps }: Props) { - let type: T.IssueType; + let type: IssueType; switch (query.toLowerCase()) { case 'bug': diff --git a/server/sonar-web/src/main/js/components/icons/QualifierIcon.tsx b/server/sonar-web/src/main/js/components/icons/QualifierIcon.tsx index 9044dd99080..b4ad6845960 100644 --- a/server/sonar-web/src/main/js/components/icons/QualifierIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons/QualifierIcon.tsx @@ -19,9 +19,10 @@ */ import * as React from 'react'; import { colors } from '../../app/theme'; +import { Dict } from '../../types/types'; import Icon, { IconProps } from './Icon'; -const qualifierIcons: T.Dict<(props: IconProps) => React.ReactElement> = { +const qualifierIcons: Dict<(props: IconProps) => React.ReactElement> = { app: ApplicationIcon, brc: SubProjectIcon, dev: DeveloperIcon, diff --git a/server/sonar-web/src/main/js/components/icons/SeverityIcon.tsx b/server/sonar-web/src/main/js/components/icons/SeverityIcon.tsx index 044ed7edca0..ae613d2a588 100644 --- a/server/sonar-web/src/main/js/components/icons/SeverityIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons/SeverityIcon.tsx @@ -19,13 +19,14 @@ */ import * as React from 'react'; import { colors } from '../../app/theme'; +import { Dict } from '../../types/types'; import Icon, { IconProps } from './Icon'; interface Props extends IconProps { severity: string | null | undefined; } -const severityIcons: T.Dict<(props: IconProps) => React.ReactElement> = { +const severityIcons: Dict<(props: IconProps) => React.ReactElement> = { blocker: BlockerSeverityIcon, critical: CriticalSeverityIcon, major: MajorSeverityIcon, diff --git a/server/sonar-web/src/main/js/components/icons/StatusIcon.tsx b/server/sonar-web/src/main/js/components/icons/StatusIcon.tsx index 713a92cdcec..f7cb9e352b0 100644 --- a/server/sonar-web/src/main/js/components/icons/StatusIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons/StatusIcon.tsx @@ -19,13 +19,14 @@ */ import * as React from 'react'; import { colors } from '../../app/theme'; +import { Dict } from '../../types/types'; import Icon, { IconProps } from './Icon'; interface Props extends IconProps { status: string; } -const statusIcons: T.Dict<(props: IconProps) => React.ReactElement> = { +const statusIcons: Dict<(props: IconProps) => React.ReactElement> = { open: OpenStatusIcon, confirmed: ConfirmedStatusIcon, reopened: ReopenedStatusIcon, diff --git a/server/sonar-web/src/main/js/components/icons/TestStatusIcon.tsx b/server/sonar-web/src/main/js/components/icons/TestStatusIcon.tsx index 6555744c948..c6b35c106cf 100644 --- a/server/sonar-web/src/main/js/components/icons/TestStatusIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons/TestStatusIcon.tsx @@ -19,13 +19,14 @@ */ import * as React from 'react'; import { colors } from '../../app/theme'; +import { Dict } from '../../types/types'; import Icon, { IconProps } from './Icon'; interface Props extends IconProps { status: string; } -const statusIcons: T.Dict<(props: IconProps) => React.ReactElement> = { +const statusIcons: Dict<(props: IconProps) => React.ReactElement> = { ok: OkTestStatusIcon, failure: FailureTestStatusIcon, error: ErrorTestStatusIcon, diff --git a/server/sonar-web/src/main/js/components/icons/__tests__/IssueIcon-test.tsx b/server/sonar-web/src/main/js/components/icons/__tests__/IssueIcon-test.tsx index 852beec5385..95b6a728d3a 100644 --- a/server/sonar-web/src/main/js/components/icons/__tests__/IssueIcon-test.tsx +++ b/server/sonar-web/src/main/js/components/icons/__tests__/IssueIcon-test.tsx @@ -19,6 +19,7 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { IssueType } from '../../../types/types'; import IssueIcon from '../IssueIcon'; it('should render correctly', () => { @@ -28,6 +29,6 @@ it('should render correctly', () => { expect(shallowRender('SECURITY_HOTSPOT')).toMatchSnapshot(); }); -function shallowRender(type: T.IssueType) { +function shallowRender(type: IssueType) { return shallow(<IssueIcon type={type} />); } diff --git a/server/sonar-web/src/main/js/components/issue/Issue.tsx b/server/sonar-web/src/main/js/components/issue/Issue.tsx index 0b965122f28..aee59853916 100644 --- a/server/sonar-web/src/main/js/components/issue/Issue.tsx +++ b/server/sonar-web/src/main/js/components/issue/Issue.tsx @@ -21,6 +21,7 @@ import key from 'keymaster'; import * as React from 'react'; import { setIssueAssignee } from '../../api/issues'; import { BranchLike } from '../../types/branch-like'; +import { Issue as TypeIssue } from '../../types/types'; import { updateIssue } from './actions'; import './Issue.css'; import IssueView from './IssueView'; @@ -30,11 +31,11 @@ interface Props { checked?: boolean; displayLocationsCount?: boolean; displayLocationsLink?: boolean; - issue: T.Issue; - onChange: (issue: T.Issue) => void; + issue: TypeIssue; + onChange: (issue: TypeIssue) => void; onCheck?: (issue: string) => void; onClick: (issueKey: string) => void; - onFilter?: (property: string, issue: T.Issue) => void; + onFilter?: (property: string, issue: TypeIssue) => void; onPopupToggle: (issue: string, popupName: string, open?: boolean) => void; openPopup?: string; selected: boolean; diff --git a/server/sonar-web/src/main/js/components/issue/IssueView.tsx b/server/sonar-web/src/main/js/components/issue/IssueView.tsx index 30b4e9d5ed8..12aa0538fba 100644 --- a/server/sonar-web/src/main/js/components/issue/IssueView.tsx +++ b/server/sonar-web/src/main/js/components/issue/IssueView.tsx @@ -23,6 +23,7 @@ import { deleteIssueComment, editIssueComment } from '../../api/issues'; import Checkbox from '../../components/controls/Checkbox'; import { translate } from '../../helpers/l10n'; import { BranchLike } from '../../types/branch-like'; +import { Issue } from '../../types/types'; import { updateIssue } from './actions'; import IssueActionsBar from './components/IssueActionsBar'; import IssueCommentLine from './components/IssueCommentLine'; @@ -34,12 +35,12 @@ interface Props { currentPopup?: string; displayLocationsCount?: boolean; displayLocationsLink?: boolean; - issue: T.Issue; + issue: Issue; onAssign: (login: string) => void; - onChange: (issue: T.Issue) => void; + onChange: (issue: Issue) => void; onCheck?: (issue: string) => void; onClick: (issueKey: string) => void; - onFilter?: (property: string, issue: T.Issue) => void; + onFilter?: (property: string, issue: Issue) => void; selected: boolean; togglePopup: (popup: string, show: boolean | void) => void; } diff --git a/server/sonar-web/src/main/js/components/issue/actions.ts b/server/sonar-web/src/main/js/components/issue/actions.ts index e8f5fb113ba..471cd84b9ca 100644 --- a/server/sonar-web/src/main/js/components/issue/actions.ts +++ b/server/sonar-web/src/main/js/components/issue/actions.ts @@ -20,12 +20,13 @@ import throwGlobalError from '../../app/utils/throwGlobalError'; import { parseIssueFromResponse } from '../../helpers/issues'; import { IssueResponse } from '../../types/issues'; +import { Issue } from '../../types/types'; export const updateIssue = ( - onChange: (issue: T.Issue) => void, + onChange: (issue: Issue) => void, resultPromise: Promise<IssueResponse>, - oldIssue?: T.Issue, - newIssue?: T.Issue + oldIssue?: Issue, + newIssue?: Issue ) => { const optimisticUpdate = oldIssue !== undefined && newIssue !== undefined; if (optimisticUpdate) { diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx index 33558cf7f7d..dcb5875a097 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { IssueResponse } from '../../../types/issues'; +import { Issue, RawQuery } from '../../../types/types'; import { updateIssue } from '../actions'; import IssueAssign from './IssueAssign'; import IssueCommentAction from './IssueCommentAction'; @@ -29,10 +30,10 @@ import IssueTransition from './IssueTransition'; import IssueType from './IssueType'; interface Props { - issue: T.Issue; + issue: Issue; currentPopup?: string; onAssign: (login: string) => void; - onChange: (issue: T.Issue) => void; + onChange: (issue: Issue) => void; togglePopup: (popup: string, show?: boolean) => void; } @@ -48,9 +49,9 @@ export default class IssueActionsBar extends React.PureComponent<Props, State> { }; setIssueProperty = ( - property: keyof T.Issue, + property: keyof Issue, popup: string, - apiCall: (query: T.RawQuery) => Promise<IssueResponse>, + apiCall: (query: RawQuery) => Promise<IssueResponse>, value: string ) => { const { issue } = this.props; @@ -74,7 +75,7 @@ export default class IssueActionsBar extends React.PureComponent<Props, State> { this.props.togglePopup('comment', open); }; - handleTransition = (issue: T.Issue) => { + handleTransition = (issue: Issue) => { this.props.onChange(issue); if ( issue.resolution === 'FALSE-POSITIVE' || diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueAssign.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueAssign.tsx index 418d68047a9..c62aaca9217 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueAssign.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueAssign.tsx @@ -22,12 +22,13 @@ import { ButtonLink } from '../../../components/controls/buttons'; import Toggler from '../../../components/controls/Toggler'; import DropdownIcon from '../../../components/icons/DropdownIcon'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Issue } from '../../../types/types'; import Avatar from '../../ui/Avatar'; import SetAssigneePopup from '../popups/SetAssigneePopup'; interface Props { isOpen: boolean; - issue: T.Issue; + issue: Issue; canAssign: boolean; onAssign: (login: string) => void; togglePopup: (popup: string, show?: boolean) => void; diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.tsx index a7b11c014e8..2be9b9187aa 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.tsx @@ -21,12 +21,13 @@ import * as React from 'react'; import { ButtonLink } from '../../../components/controls/buttons'; import Toggler from '../../../components/controls/Toggler'; import DropdownIcon from '../../../components/icons/DropdownIcon'; +import { Issue } from '../../../types/types'; import DateFromNow from '../../intl/DateFromNow'; import ChangelogPopup from '../popups/ChangelogPopup'; interface Props { isOpen: boolean; - issue: Pick<T.Issue, 'author' | 'creationDate' | 'key'>; + issue: Pick<Issue, 'author' | 'creationDate' | 'key'>; creationDate: string; togglePopup: (popup: string, show?: boolean) => void; } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueChangelogDiff.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueChangelogDiff.tsx index 16fb333578a..7da6900cb8a 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueChangelogDiff.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueChangelogDiff.tsx @@ -20,9 +20,10 @@ import * as React from 'react'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; +import { IssueChangelogDiff as TypeIssueChangelogDiff } from '../../../types/types'; interface Props { - diff: T.IssueChangelogDiff; + diff: TypeIssueChangelogDiff; } export default function IssueChangelogDiff({ diff }: Props) { diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.tsx index 25bdb8465a0..f92aaa1a923 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.tsx @@ -22,6 +22,7 @@ import { addIssueComment } from '../../../api/issues'; import { ButtonLink } from '../../../components/controls/buttons'; import Toggler from '../../../components/controls/Toggler'; import { translate } from '../../../helpers/l10n'; +import { Issue } from '../../../types/types'; import { updateIssue } from '../actions'; import CommentPopup from '../popups/CommentPopup'; @@ -30,7 +31,7 @@ interface Props { commentPlaceholder: string; currentPopup?: string; issueKey: string; - onChange: (issue: T.Issue) => void; + onChange: (issue: Issue) => void; toggleComment: (open?: boolean, placeholder?: string, autoTriggered?: boolean) => void; } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.tsx index 301a32889b4..5df50bc604f 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.tsx @@ -23,13 +23,14 @@ import Toggler from '../../../components/controls/Toggler'; import { PopupPlacement } from '../../../components/ui/popups'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { sanitizeString } from '../../../helpers/sanitize'; +import { IssueComment } from '../../../types/types'; import DateFromNow from '../../intl/DateFromNow'; import Avatar from '../../ui/Avatar'; import CommentDeletePopup from '../popups/CommentDeletePopup'; import CommentPopup from '../popups/CommentPopup'; interface Props { - comment: T.IssueComment; + comment: IssueComment; onDelete: (comment: string) => void; onEdit: (comment: string, text: string) => void; } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.tsx index c5f001d36e4..113e0836e11 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.tsx @@ -24,17 +24,18 @@ import Toggler from '../../../components/controls/Toggler'; import DropdownIcon from '../../../components/icons/DropdownIcon'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { IssueResponse } from '../../../types/issues'; +import { Issue, RawQuery } from '../../../types/types'; import SeverityHelper from '../../shared/SeverityHelper'; import SetSeverityPopup from '../popups/SetSeverityPopup'; interface Props { canSetSeverity: boolean; isOpen: boolean; - issue: Pick<T.Issue, 'severity'>; + issue: Pick<Issue, 'severity'>; setIssueProperty: ( - property: keyof T.Issue, + property: keyof Issue, popup: string, - apiCall: (query: T.RawQuery) => Promise<IssueResponse>, + apiCall: (query: RawQuery) => Promise<IssueResponse>, value: string ) => void; togglePopup: (popup: string, show?: boolean) => void; diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTags.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueTags.tsx index f5d4ee9fdeb..7e5094594b4 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTags.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTags.tsx @@ -22,6 +22,7 @@ import { setIssueTags } from '../../../api/issues'; import { ButtonLink } from '../../../components/controls/buttons'; import Toggler from '../../../components/controls/Toggler'; import { translate } from '../../../helpers/l10n'; +import { Issue } from '../../../types/types'; import TagsList from '../../tags/TagsList'; import { updateIssue } from '../actions'; import SetIssueTagsPopup from '../popups/SetIssueTagsPopup'; @@ -29,8 +30,8 @@ import SetIssueTagsPopup from '../popups/SetIssueTagsPopup'; interface Props { canSetTags: boolean; isOpen: boolean; - issue: Pick<T.Issue, 'key' | 'tags'>; - onChange: (issue: T.Issue) => void; + issue: Pick<Issue, 'key' | 'tags'>; + onChange: (issue: Issue) => void; togglePopup: (popup: string, show?: boolean) => void; } @@ -45,8 +46,8 @@ export default class IssueTags extends React.PureComponent<Props> { updateIssue( this.props.onChange, setIssueTags({ issue: issue.key, tags: tags.join(',') }), - issue as T.Issue, - newIssue as T.Issue + issue as Issue, + newIssue as Issue ); }; diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx index 2b3bb81a35b..9582675c452 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx @@ -27,6 +27,7 @@ import { formatMeasure } from '../../../helpers/measures'; import { getComponentIssuesUrl } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; import { RuleStatus } from '../../../types/rules'; +import { Issue } from '../../../types/types'; import LocationIndex from '../../common/LocationIndex'; import { WorkspaceContext } from '../../workspace/context'; import IssueChangelog from './IssueChangelog'; @@ -38,8 +39,8 @@ export interface IssueTitleBarProps { currentPopup?: string; displayLocationsCount?: boolean; displayLocationsLink?: boolean; - issue: T.Issue; - onFilter?: (property: string, issue: T.Issue) => void; + issue: Issue; + onFilter?: (property: string, issue: Issue) => void; togglePopup: (popup: string, show?: boolean) => void; } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTransition.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueTransition.tsx index 0371babb273..0fecacdc262 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTransition.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTransition.tsx @@ -23,6 +23,7 @@ import { ButtonLink } from '../../../components/controls/buttons'; import Toggler from '../../../components/controls/Toggler'; import DropdownIcon from '../../../components/icons/DropdownIcon'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Issue } from '../../../types/types'; import StatusHelper from '../../shared/StatusHelper'; import { updateIssue } from '../actions'; import SetTransitionPopup from '../popups/SetTransitionPopup'; @@ -30,8 +31,8 @@ import SetTransitionPopup from '../popups/SetTransitionPopup'; interface Props { hasTransitions: boolean; isOpen: boolean; - issue: Pick<T.Issue, 'fromHotspot' | 'key' | 'resolution' | 'status' | 'transitions' | 'type'>; - onChange: (issue: T.Issue) => void; + issue: Pick<Issue, 'fromHotspot' | 'key' | 'resolution' | 'status' | 'transitions' | 'type'>; + onChange: (issue: Issue) => void; togglePopup: (popup: string, show?: boolean) => void; } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueType.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueType.tsx index 8dc32e2ce15..c19f4ce4f82 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueType.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueType.tsx @@ -26,16 +26,17 @@ import DropdownIcon from '../../../components/icons/DropdownIcon'; import IssueTypeIcon from '../../../components/icons/IssueTypeIcon'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { IssueResponse } from '../../../types/issues'; +import { Issue, RawQuery } from '../../../types/types'; import SetTypePopup from '../popups/SetTypePopup'; interface Props { canSetType: boolean; isOpen: boolean; - issue: Pick<T.Issue, 'type'>; + issue: Pick<Issue, 'type'>; setIssueProperty: ( - property: keyof T.Issue, + property: keyof Issue, popup: string, - apiCall: (query: T.RawQuery) => Promise<IssueResponse>, + apiCall: (query: RawQuery) => Promise<IssueResponse>, value: string ) => void; togglePopup: (popup: string, show?: boolean) => void; diff --git a/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.tsx b/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.tsx index 097e398b946..5e488c44656 100644 --- a/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.tsx @@ -23,17 +23,18 @@ import Toggler from '../../../components/controls/Toggler'; import DropdownIcon from '../../../components/icons/DropdownIcon'; import FilterIcon from '../../../components/icons/FilterIcon'; import { translate } from '../../../helpers/l10n'; +import { Issue } from '../../../types/types'; import SimilarIssuesPopup from '../popups/SimilarIssuesPopup'; interface Props { isOpen: boolean; - issue: T.Issue; + issue: Issue; togglePopup: (popup: string, show?: boolean) => void; - onFilter?: (property: string, issue: T.Issue) => void; + onFilter?: (property: string, issue: Issue) => void; } export default class SimilarIssuesFilter extends React.PureComponent<Props> { - handleFilter = (property: string, issue: T.Issue) => { + handleFilter = (property: string, issue: Issue) => { this.togglePopup(false); if (this.props.onFilter) { this.props.onFilter(property, issue); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueActionsBar-test.tsx b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueActionsBar-test.tsx index d7541328b2b..78803b44497 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueActionsBar-test.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueActionsBar-test.tsx @@ -20,6 +20,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { mockIssue } from '../../../../helpers/testMocks'; +import { Issue } from '../../../../types/types'; import IssueActionsBar from '../IssueActionsBar'; jest.mock('../../actions', () => ({ updateIssue: jest.fn() })); @@ -73,7 +74,7 @@ it('should render effort correctly', () => { }); describe('callback', () => { - const issue: T.Issue = mockIssue(); + const issue: Issue = mockIssue(); const onChangeMock = jest.fn(); const togglePopupMock = jest.fn(); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelogDiff-test.tsx b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelogDiff-test.tsx index 11282cd938e..bddba7e08e1 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelogDiff-test.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueChangelogDiff-test.tsx @@ -19,6 +19,7 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; +import { IssueChangelogDiff as TypeIssueChangelogDiff } from '../../../../types/types'; import IssueChangelogDiff from '../IssueChangelogDiff'; it('should render correctly', () => { @@ -77,6 +78,6 @@ it('should render correctly effort diff', () => { expect(shallowRender({ diff: { key: 'effort', oldValue: '10' } })).toMatchSnapshot(); }); -function shallowRender(props: Partial<{ diff: T.IssueChangelogDiff }> = {}) { +function shallowRender(props: Partial<{ diff: TypeIssueChangelogDiff }> = {}) { return shallow(<IssueChangelogDiff diff={{ key: 'foo' }} {...props} />); } diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.tsx b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.tsx index 5888cba29dc..a597420ecce 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.tsx @@ -20,9 +20,10 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { click } from '../../../../helpers/testUtils'; +import { IssueComment } from '../../../../types/types'; import IssueCommentLine from '../IssueCommentLine'; -const comment: T.IssueComment = { +const comment: IssueComment = { author: 'john.doe', authorActive: true, authorAvatar: 'gravatarhash', diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueType-test.tsx b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueType-test.tsx index 0e555b9d9d6..5fec51cfe61 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueType-test.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueType-test.tsx @@ -20,9 +20,10 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { click } from '../../../../helpers/testUtils'; +import { Issue } from '../../../../types/types'; import IssueType from '../IssueType'; -const issue: Pick<T.Issue, 'type'> = { type: 'BUG' }; +const issue: Pick<Issue, 'type'> = { type: 'BUG' }; it('should render without the action when the correct rights are missing', () => { expect(shallowRender({ canSetType: false })).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.tsx index eb240165cee..b9608832d2d 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.tsx @@ -22,16 +22,17 @@ import { getIssueChangelog } from '../../../api/issues'; import { DropdownOverlay } from '../../../components/controls/Dropdown'; import { PopupPlacement } from '../../../components/ui/popups'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Issue, IssueChangelog } from '../../../types/types'; import DateTimeFormatter from '../../intl/DateTimeFormatter'; import Avatar from '../../ui/Avatar'; import IssueChangelogDiff from '../components/IssueChangelogDiff'; interface Props { - issue: Pick<T.Issue, 'author' | 'creationDate' | 'key'>; + issue: Pick<Issue, 'author' | 'creationDate' | 'key'>; } interface State { - changelog: T.IssueChangelog[]; + changelog: IssueChangelog[]; } export default class ChangelogPopup extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx index 4481dacee72..209d19909f9 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx @@ -23,10 +23,11 @@ import { DropdownOverlay } from '../../../components/controls/Dropdown'; import { PopupPlacement } from '../../../components/ui/popups'; import { KeyboardCodes } from '../../../helpers/keycodes'; import { translate } from '../../../helpers/l10n'; +import { IssueComment } from '../../../types/types'; import FormattingTips from '../../common/FormattingTips'; export interface CommentPopupProps { - comment?: Pick<T.IssueComment, 'markdown'>; + comment?: Pick<IssueComment, 'markdown'>; onComment: (text: string) => void; toggleComment: (visible: boolean) => void; placeholder: string; diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx index 725fa526e5f..f80f5abde43 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx @@ -24,26 +24,27 @@ import { DropdownOverlay } from '../../../components/controls/Dropdown'; import SearchBox from '../../../components/controls/SearchBox'; import { translate } from '../../../helpers/l10n'; import { isLoggedIn, isUserActive } from '../../../helpers/users'; +import { CurrentUser, UserActive, UserBase } from '../../../types/types'; import SelectList from '../../common/SelectList'; import SelectListItem from '../../common/SelectListItem'; import { withCurrentUser } from '../../hoc/withCurrentUser'; import Avatar from '../../ui/Avatar'; interface Props { - currentUser: T.CurrentUser; + currentUser: CurrentUser; onSelect: (login: string) => void; } interface State { currentUser: string; query: string; - users: T.UserActive[]; + users: UserActive[]; } const LIST_SIZE = 10; export class SetAssigneePopup extends React.PureComponent<Props, State> { - defaultUsersArray: T.UserActive[]; + defaultUsersArray: UserActive[]; constructor(props: Props) { super(props); @@ -64,7 +65,7 @@ export class SetAssigneePopup extends React.PureComponent<Props, State> { searchUsers({ q: query, ps: LIST_SIZE }).then(this.handleSearchResult, () => {}); }; - handleSearchResult = ({ users }: { users: T.UserBase[] }) => { + handleSearchResult = ({ users }: { users: UserBase[] }) => { const activeUsers = users.filter(isUserActive); this.setState({ users: activeUsers, diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.tsx index 28e153b03f8..3308ca9721d 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.tsx @@ -21,11 +21,12 @@ import * as React from 'react'; import { DropdownOverlay } from '../../../components/controls/Dropdown'; import SeverityIcon from '../../../components/icons/SeverityIcon'; import { translate } from '../../../helpers/l10n'; +import { Issue } from '../../../types/types'; import SelectList from '../../common/SelectList'; import SelectListItem from '../../common/SelectListItem'; type Props = { - issue: Pick<T.Issue, 'severity'>; + issue: Pick<Issue, 'severity'>; onSelect: (severity: string) => void; }; diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetTransitionPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SetTransitionPopup.tsx index 4fa4cf0fc52..6083634025d 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetTransitionPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SetTransitionPopup.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { DropdownOverlay } from '../../../components/controls/Dropdown'; import { hasMessage, translate } from '../../../helpers/l10n'; +import { IssueType } from '../../../types/types'; import SelectList from '../../common/SelectList'; import SelectListItem from '../../common/SelectListItem'; @@ -28,7 +29,7 @@ export interface Props { fromHotspot: boolean; onSelect: (transition: string) => void; transitions: string[]; - type: T.IssueType; + type: IssueType; } export default function SetTransitionPopup({ fromHotspot, onSelect, transitions, type }: Props) { diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.tsx index 7cb044ffe98..3234fb1ea05 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.tsx @@ -21,12 +21,13 @@ import * as React from 'react'; import { DropdownOverlay } from '../../../components/controls/Dropdown'; import IssueTypeIcon from '../../../components/icons/IssueTypeIcon'; import { translate } from '../../../helpers/l10n'; +import { Issue, IssueType } from '../../../types/types'; import SelectList from '../../common/SelectList'; import SelectListItem from '../../common/SelectListItem'; interface Props { - issue: Pick<T.Issue, 'type'>; - onSelect: (type: T.IssueType) => void; + issue: Pick<Issue, 'type'>; + onSelect: (type: IssueType) => void; } const TYPES = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; diff --git a/server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.tsx index ea5636b26d8..a43e8bfb95e 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.tsx @@ -24,6 +24,7 @@ import QualifierIcon from '../../../components/icons/QualifierIcon'; import TagsIcon from '../../../components/icons/TagsIcon'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { fileFromPath, limitComponentName } from '../../../helpers/path'; +import { Issue } from '../../../types/types'; import SelectList from '../../common/SelectList'; import SelectListItem from '../../common/SelectListItem'; import SeverityHelper from '../../shared/SeverityHelper'; @@ -31,8 +32,8 @@ import StatusHelper from '../../shared/StatusHelper'; import Avatar from '../../ui/Avatar'; interface Props { - issue: T.Issue; - onFilter: (property: string, issue: T.Issue) => void; + issue: Issue; + onFilter: (property: string, issue: Issue) => void; } export default class SimilarIssuesPopup extends React.PureComponent<Props> { diff --git a/server/sonar-web/src/main/js/components/measure/utils.ts b/server/sonar-web/src/main/js/components/measure/utils.ts index ff4635a077a..f741b05f3cd 100644 --- a/server/sonar-web/src/main/js/components/measure/utils.ts +++ b/server/sonar-web/src/main/js/components/measure/utils.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getRatingTooltip as nextGetRatingTooltip, isDiffMetric } from '../../helpers/measures'; +import { Dict, Measure, MeasureEnhanced, MeasureIntern, Metric } from '../../types/types'; const KNOWN_RATINGS = [ 'sqale_rating', @@ -27,7 +28,7 @@ const KNOWN_RATINGS = [ 'security_review_rating' ]; -export function enhanceMeasure(measure: T.Measure, metrics: T.Dict<T.Metric>): T.MeasureEnhanced { +export function enhanceMeasure(measure: Measure, metrics: Dict<Metric>): MeasureEnhanced { return { ...measure, metric: metrics[measure.metric], @@ -35,7 +36,7 @@ export function enhanceMeasure(measure: T.Measure, metrics: T.Dict<T.Metric>): T }; } -export function getLeakValue(measure: T.MeasureIntern | undefined): string | undefined { +export function getLeakValue(measure: MeasureIntern | undefined): string | undefined { return measure?.period?.value; } diff --git a/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx b/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx index 4c173463dbc..b7ccf9c106b 100644 --- a/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx +++ b/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx @@ -22,6 +22,7 @@ import { Link } from 'react-router'; import { getBranchLikeQuery } from '../../helpers/branch-like'; import { getComponentDrilldownUrl, getComponentIssuesUrl } from '../../helpers/urls'; import { BranchLike } from '../../types/branch-like'; +import { Dict } from '../../types/types'; const ISSUE_MEASURES = [ 'violations', @@ -48,7 +49,7 @@ const ISSUE_MEASURES = [ 'new_vulnerabilities' ]; -const issueParamsPerMetric: T.Dict<T.Dict<string>> = { +const issueParamsPerMetric: Dict<Dict<string>> = { blocker_violations: { resolved: 'false', severities: 'BLOCKER' }, new_blocker_violations: { resolved: 'false', severities: 'BLOCKER' }, critical_violations: { resolved: 'false', severities: 'CRITICAL' }, @@ -86,7 +87,7 @@ export default class DrilldownLink extends React.PureComponent<Props> { }; propsToIssueParams = () => { - const params: T.Dict<string | boolean> = { + const params: Dict<string | boolean> = { ...(issueParamsPerMetric[this.props.metric] || { resolved: 'false' }) }; diff --git a/server/sonar-web/src/main/js/components/shared/TypeHelper.tsx b/server/sonar-web/src/main/js/components/shared/TypeHelper.tsx index d3502aac741..3747f399691 100644 --- a/server/sonar-web/src/main/js/components/shared/TypeHelper.tsx +++ b/server/sonar-web/src/main/js/components/shared/TypeHelper.tsx @@ -20,10 +20,11 @@ import * as React from 'react'; import IssueTypeIcon from '../../components/icons/IssueTypeIcon'; import { translate } from '../../helpers/l10n'; +import { IssueType, RuleType } from '../../types/types'; interface Props { className?: string; - type: T.IssueType | T.RuleType; + type: IssueType | RuleType; } export default function TypeHelper(props: Props) { diff --git a/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx b/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx index 2379c9f0e15..ff94de66c55 100644 --- a/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx @@ -24,13 +24,14 @@ import { getValues } from '../../api/settings'; import { getHostUrl } from '../../helpers/urls'; import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../types/alm-settings'; import { SettingsKey } from '../../types/settings'; +import { Component, LoggedInUser } from '../../types/types'; import { withRouter } from '../hoc/withRouter'; import TutorialSelectionRenderer from './TutorialSelectionRenderer'; import { TutorialModes } from './types'; interface Props extends Pick<WithRouterProps, 'router' | 'location'> { - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; projectBinding?: ProjectAlmBindingResponse; willRefreshAutomatically?: boolean; } diff --git a/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx b/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx index 09d4f3b5908..79365b55e68 100644 --- a/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx @@ -22,6 +22,7 @@ import EllipsisIcon from '../../components/icons/EllipsisIcon'; import { translate } from '../../helpers/l10n'; import { getBaseUrl } from '../../helpers/system'; import { AlmKeys, AlmSettingsInstance, ProjectAlmBindingResponse } from '../../types/alm-settings'; +import { Component, LoggedInUser } from '../../types/types'; import AzurePipelinesTutorial from './azure-pipelines/AzurePipelinesTutorial'; import BitbucketPipelinesTutorial from './bitbucket-pipelines/BitbucketPipelinesTutorial'; import GitHubActionTutorial from './github-action/GitHubActionTutorial'; @@ -33,8 +34,8 @@ import { TutorialModes } from './types'; export interface TutorialSelectionRendererProps { almBinding?: AlmSettingsInstance; baseUrl: string; - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; loading: boolean; onSelectTutorial: (mode: TutorialModes) => void; projectBinding?: ProjectAlmBindingResponse; diff --git a/server/sonar-web/src/main/js/components/tutorials/__tests__/utils-test.ts b/server/sonar-web/src/main/js/components/tutorials/__tests__/utils-test.ts index 907ef19d6ef..97da8d76972 100644 --- a/server/sonar-web/src/main/js/components/tutorials/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/components/tutorials/__tests__/utils-test.ts @@ -22,13 +22,14 @@ import { mockProjectBitbucketCloudBindingResponse, mockProjectGithubBindingResponse } from '../../../helpers/mocks/alm-settings'; +import { UserToken } from '../../../types/types'; import { buildBitbucketCloudLink, buildGithubLink, getUniqueTokenName } from '../utils'; describe('getUniqueTokenName', () => { const initialTokenName = 'Analyze "lightsaber"'; it('should return the given name when the user has no token', () => { - const userTokens: T.UserToken[] = []; + const userTokens: UserToken[] = []; expect(getUniqueTokenName(userTokens, initialTokenName)).toBe(initialTokenName); }); diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/AzurePipelinesTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/AzurePipelinesTutorial.tsx index 114bdf13839..e35e1d2e10d 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/AzurePipelinesTutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/AzurePipelinesTutorial.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import { Button } from '../../../components/controls/buttons'; import { translate } from '../../../helpers/l10n'; import { AlmKeys } from '../../../types/alm-settings'; +import { Component, LoggedInUser } from '../../../types/types'; import AllSetStep from '../components/AllSetStep'; import FinishButton from '../components/FinishButton'; import Step from '../components/Step'; @@ -31,8 +32,8 @@ import ServiceEndpointStepContent from './ServiceEndpointStepContent'; export interface AzurePipelinesTutorialProps { alm?: AlmKeys; baseUrl: string; - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; willRefreshAutomatically?: boolean; } diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/BranchAnalysisStepContent.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/BranchAnalysisStepContent.tsx index f621a8f2732..14c8abe1535 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/BranchAnalysisStepContent.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/BranchAnalysisStepContent.tsx @@ -21,13 +21,14 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { translate } from '../../../helpers/l10n'; import { getLanguages, Store } from '../../../store/rootReducer'; +import { Component, Languages } from '../../../types/types'; import RenderOptions from '../components/RenderOptions'; import { BuildTools } from '../types'; import AnalysisCommand from './commands/AnalysisCommand'; export interface BranchesAnalysisStepProps { - languages: T.Languages; - component: T.Component; + languages: Languages; + component: Component; onStepValidationChange: (isValid: boolean) => void; } diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/ServiceEndpointStepContent.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/ServiceEndpointStepContent.tsx index 18663b7871e..4ab594e9e61 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/ServiceEndpointStepContent.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/ServiceEndpointStepContent.tsx @@ -22,13 +22,14 @@ import { FormattedMessage } from 'react-intl'; import { Button } from '../../../components/controls/buttons'; import { ClipboardIconButton } from '../../../components/controls/clipboard'; import { translate } from '../../../helpers/l10n'; +import { Component, LoggedInUser } from '../../../types/types'; import EditTokenModal from '../components/EditTokenModal'; import SentenceWithHighlights from '../components/SentenceWithHighlights'; export interface ServiceEndpointStepProps { baseUrl: string; - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; } export default function ServiceEndpointStepContent(props: ServiceEndpointStepProps) { diff --git a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/PublishSteps.tsx b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/PublishSteps.tsx index 85a29d9ddd3..f54f9f9ffa2 100644 --- a/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/PublishSteps.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/azure-pipelines/commands/PublishSteps.tsx @@ -25,11 +25,12 @@ import { Alert } from '../../../../components/ui/Alert'; import { ALM_DOCUMENTATION_PATHS } from '../../../../helpers/constants'; import { translate } from '../../../../helpers/l10n'; import { AlmKeys } from '../../../../types/alm-settings'; +import { AppState } from '../../../../types/types'; import { withAppState } from '../../../hoc/withAppState'; import SentenceWithHighlights from '../../components/SentenceWithHighlights'; export interface PublishStepsProps { - appState: T.AppState; + appState: AppState; } export function PublishSteps(props: PublishStepsProps) { const { diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx index b5a79c1d500..5ae65fee0c1 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx @@ -19,6 +19,7 @@ */ import { Dictionary } from 'lodash'; import * as React from 'react'; +import { AppState, Component } from '../../../types/types'; import { withAppState } from '../../hoc/withAppState'; import { CompilationInfo } from '../components/CompilationInfo'; import CreateYmlFile from '../components/CreateYmlFile'; @@ -31,9 +32,9 @@ import othersExample from './commands/Others'; import { PreambuleYaml } from './PreambuleYaml'; export interface AnalysisCommandProps { - appState: T.AppState; + appState: AppState; buildTool: BuildTools; - component: T.Component; + component: Component; } const YamlTemplate: Dictionary<(branchesEnabled?: boolean, projectKey?: string) => string> = { diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx index 01233e4c91f..169a03a1790 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx @@ -24,6 +24,7 @@ import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../../types/alm-settings'; +import { Component, LoggedInUser } from '../../../types/types'; import AllSetStep from '../components/AllSetStep'; import FinishButton from '../components/FinishButton'; import GithubCFamilyExampleRepositories from '../components/GithubCFamilyExampleRepositories'; @@ -42,8 +43,8 @@ export enum Steps { export interface BitbucketPipelinesTutorialProps { almBinding?: AlmSettingsInstance; baseUrl: string; - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; projectBinding?: ProjectAlmBindingResponse; willRefreshAutomatically?: boolean; } diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx index 0e95539c785..315ca308242 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { ClipboardIconButton } from '../../../components/controls/clipboard'; import { translate } from '../../../helpers/l10n'; +import { Component } from '../../../types/types'; import CodeSnippet from '../../common/CodeSnippet'; import DefaultProjectKey from '../components/DefaultProjectKey'; import { BuildTools } from '../types'; @@ -28,7 +29,7 @@ import { buildGradleSnippet } from '../utils'; export interface PreambuleYamlProps { buildTool: BuildTools; - component: T.Component; + component: Component; } export function PreambuleYaml(props: PreambuleYamlProps) { diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/RepositoryVariables.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/RepositoryVariables.tsx index 840b3a258ef..d749df345dc 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/RepositoryVariables.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/RepositoryVariables.tsx @@ -23,6 +23,7 @@ import { Button } from '../../../components/controls/buttons'; import { ClipboardIconButton } from '../../../components/controls/clipboard'; import { translate } from '../../../helpers/l10n'; import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../../types/alm-settings'; +import { Component, LoggedInUser } from '../../../types/types'; import SentenceWithHighlights from '../components/SentenceWithHighlights'; import TokenStepGenerator from '../components/TokenStepGenerator'; import { buildBitbucketCloudLink } from '../utils'; @@ -30,8 +31,8 @@ import { buildBitbucketCloudLink } from '../utils'; export interface RepositoryVariablesProps { almBinding?: AlmSettingsInstance; baseUrl: string; - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; onDone: () => void; projectBinding?: ProjectAlmBindingResponse; } diff --git a/server/sonar-web/src/main/js/components/tutorials/components/AllSet.tsx b/server/sonar-web/src/main/js/components/tutorials/components/AllSet.tsx index fa744dacabd..b296d17d138 100644 --- a/server/sonar-web/src/main/js/components/tutorials/components/AllSet.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/components/AllSet.tsx @@ -21,12 +21,13 @@ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { getBaseUrl } from '../../../helpers/system'; import { AlmKeys } from '../../../types/alm-settings'; +import { AppState } from '../../../types/types'; import { withAppState } from '../../hoc/withAppState'; import SentenceWithHighlights from './SentenceWithHighlights'; export interface AllSetProps { alm: AlmKeys; - appState: T.AppState; + appState: AppState; willRefreshAutomatically?: boolean; } diff --git a/server/sonar-web/src/main/js/components/tutorials/components/DefaultProjectKey.tsx b/server/sonar-web/src/main/js/components/tutorials/components/DefaultProjectKey.tsx index 70f457f5798..04007b89546 100644 --- a/server/sonar-web/src/main/js/components/tutorials/components/DefaultProjectKey.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/components/DefaultProjectKey.tsx @@ -18,11 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Component } from '../../../types/types'; import CodeSnippet from '../../common/CodeSnippet'; import SentenceWithFilename from './SentenceWithFilename'; export interface DefaultProjectKeyProps { - component: T.Component; + component: Component; } const sonarProjectSnippet = (key: string) => `sonar.projectKey=${key}`; diff --git a/server/sonar-web/src/main/js/components/tutorials/components/EditTokenModal.tsx b/server/sonar-web/src/main/js/components/tutorials/components/EditTokenModal.tsx index 0812e977c29..68defb2dce0 100644 --- a/server/sonar-web/src/main/js/components/tutorials/components/EditTokenModal.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/components/EditTokenModal.tsx @@ -27,6 +27,7 @@ import SimpleModal from '../../../components/controls/SimpleModal'; import { Alert } from '../../../components/ui/Alert'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Component, LoggedInUser } from '../../../types/types'; import { getUniqueTokenName } from '../utils'; interface State { @@ -36,8 +37,8 @@ interface State { } interface Props { - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; onClose: (token?: string) => void; } diff --git a/server/sonar-web/src/main/js/components/tutorials/components/SentenceWithHighlights.tsx b/server/sonar-web/src/main/js/components/tutorials/components/SentenceWithHighlights.tsx index 46281bed618..79f2c2f7078 100644 --- a/server/sonar-web/src/main/js/components/tutorials/components/SentenceWithHighlights.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/components/SentenceWithHighlights.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { translate } from '../../../helpers/l10n'; +import { Dict } from '../../../types/types'; export interface SentenceWithHighlightsProps { highlightKeys: string[]; @@ -32,7 +33,7 @@ export default function SentenceWithHighlights({ translationKey, highlightPrefixKeys }: SentenceWithHighlightsProps) { - const values: T.Dict<JSX.Element> = {}; + const values: Dict<JSX.Element> = {}; const transhighlightPrefixKeys = highlightPrefixKeys || translationKey; highlightKeys.forEach(key => { diff --git a/server/sonar-web/src/main/js/components/tutorials/components/TokenStepGenerator.tsx b/server/sonar-web/src/main/js/components/tutorials/components/TokenStepGenerator.tsx index 822850e309e..a2b927d9740 100644 --- a/server/sonar-web/src/main/js/components/tutorials/components/TokenStepGenerator.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/components/TokenStepGenerator.tsx @@ -21,11 +21,12 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Button } from '../../../components/controls/buttons'; import { translate } from '../../../helpers/l10n'; +import { Component, LoggedInUser } from '../../../types/types'; import EditTokenModal from './EditTokenModal'; export interface TokenStepGeneratorProps { - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; } export default function TokenStepGenerator(props: TokenStepGeneratorProps) { diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx index e21a74c8dc1..70dbb232bf7 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { AppState, Component } from '../../../types/types'; import { withAppState } from '../../hoc/withAppState'; import { BuildTools } from '../types'; import CFamily from './commands/CFamily'; @@ -27,9 +28,9 @@ import JavaMaven from './commands/JavaMaven'; import Others from './commands/Others'; export interface AnalysisCommandProps { - appState: T.AppState; + appState: AppState; buildTool: BuildTools; - component: T.Component; + component: Component; onDone: () => void; } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx index 51a728699dc..502c4e875dd 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx @@ -24,6 +24,7 @@ import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../../types/alm-settings'; +import { Component, LoggedInUser } from '../../../types/types'; import AllSetStep from '../components/AllSetStep'; import Step from '../components/Step'; import YamlFileStep from '../components/YamlFileStep'; @@ -39,8 +40,8 @@ export enum Steps { export interface GitHubActionTutorialProps { almBinding?: AlmSettingsInstance; baseUrl: string; - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; projectBinding?: ProjectAlmBindingResponse; willRefreshAutomatically?: boolean; } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/SecretStep.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/SecretStep.tsx index a3e2c0146ec..7abca84d894 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/SecretStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/SecretStep.tsx @@ -23,6 +23,7 @@ import { Button } from '../../../components/controls/buttons'; import { ClipboardIconButton } from '../../../components/controls/clipboard'; import { translate } from '../../../helpers/l10n'; import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../../types/alm-settings'; +import { Component, LoggedInUser } from '../../../types/types'; import SentenceWithHighlights from '../components/SentenceWithHighlights'; import TokenStepGenerator from '../components/TokenStepGenerator'; import { buildGithubLink } from '../utils'; @@ -30,8 +31,8 @@ import { buildGithubLink } from '../utils'; export interface SecretStepProps { almBinding?: AlmSettingsInstance; baseUrl: string; - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; projectBinding?: ProjectAlmBindingResponse; onDone: () => void; } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CFamily.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CFamily.tsx index 987115d5339..4ac20465b5c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CFamily.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CFamily.tsx @@ -19,6 +19,7 @@ */ import * as React from 'react'; import { translate } from '../../../../helpers/l10n'; +import { Component } from '../../../../types/types'; import { CompilationInfo } from '../../components/CompilationInfo'; import CreateYmlFile from '../../components/CreateYmlFile'; import DefaultProjectKey from '../../components/DefaultProjectKey'; @@ -29,7 +30,7 @@ import { OSs, TutorialModes } from '../../types'; export interface CFamilyProps { branchesEnabled?: boolean; - component: T.Component; + component: Component; onDone: () => void; } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/DotNet.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/DotNet.tsx index 003e26868a3..96caae8bc43 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/DotNet.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/DotNet.tsx @@ -18,12 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Component } from '../../../../types/types'; import CreateYmlFile from '../../components/CreateYmlFile'; import FinishButton from '../../components/FinishButton'; export interface DotNetProps { branchesEnabled?: boolean; - component: T.Component; + component: Component; onDone: () => void; } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Gradle.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Gradle.tsx index a40b93b6156..0b1c13c9add 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Gradle.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Gradle.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { ClipboardIconButton } from '../../../../components/controls/clipboard'; import { translate } from '../../../../helpers/l10n'; +import { Component } from '../../../../types/types'; import CodeSnippet from '../../../common/CodeSnippet'; import CreateYmlFile from '../../components/CreateYmlFile'; import FinishButton from '../../components/FinishButton'; @@ -28,7 +29,7 @@ import { buildGradleSnippet } from '../../utils'; export interface GradleProps { branchesEnabled?: boolean; - component: T.Component; + component: Component; onDone: () => void; } const gradleYamlTemplate = (branchesEnabled: boolean) => `name: Build diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/JavaMaven.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/JavaMaven.tsx index 0fd75b17c48..75d5af8acde 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/JavaMaven.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/JavaMaven.tsx @@ -18,12 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Component } from '../../../../types/types'; import CreateYmlFile from '../../components/CreateYmlFile'; import FinishButton from '../../components/FinishButton'; export interface JavaMavenProps { branchesEnabled?: boolean; - component: T.Component; + component: Component; onDone: () => void; } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx index 425f10557f9..c7fd423f87f 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx @@ -18,13 +18,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Component } from '../../../../types/types'; import CreateYmlFile from '../../components/CreateYmlFile'; import DefaultProjectKey from '../../components/DefaultProjectKey'; import FinishButton from '../../components/FinishButton'; export interface OthersProps { branchesEnabled?: boolean; - component: T.Component; + component: Component; onDone: () => void; } diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/EnvironmentVariablesStep.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/EnvironmentVariablesStep.tsx index a0ccf13f7b1..32bf04e91fe 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/EnvironmentVariablesStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/EnvironmentVariablesStep.tsx @@ -22,13 +22,14 @@ import { FormattedMessage } from 'react-intl'; import { Button } from '../../../components/controls/buttons'; import { ClipboardIconButton } from '../../../components/controls/clipboard'; import { translate } from '../../../helpers/l10n'; +import { Component, LoggedInUser } from '../../../types/types'; import Step from '../components/Step'; import TokenStepGenerator from '../components/TokenStepGenerator'; export interface EnvironmentVariablesStepProps { baseUrl: string; - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; finished: boolean; onDone: () => void; onOpen: () => void; diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/GitLabCITutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/GitLabCITutorial.tsx index 83103e54ada..8472b9953be 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/GitLabCITutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/GitLabCITutorial.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; import { AlmKeys } from '../../../types/alm-settings'; +import { Component, LoggedInUser } from '../../../types/types'; import AllSetStep from '../components/AllSetStep'; import { BuildTools } from '../types'; import EnvironmentVariablesStep from './EnvironmentVariablesStep'; @@ -35,8 +36,8 @@ export enum Steps { export interface GitLabCITutorialProps { baseUrl: string; - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; willRefreshAutomatically?: boolean; } diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/ProjectKeyStep.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/ProjectKeyStep.tsx index d29d65253b1..e11016e31b3 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/ProjectKeyStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/ProjectKeyStep.tsx @@ -22,6 +22,7 @@ import { FormattedMessage } from 'react-intl'; import { Button } from '../../../components/controls/buttons'; import { ClipboardIconButton } from '../../../components/controls/clipboard'; import { translate } from '../../../helpers/l10n'; +import { Component } from '../../../types/types'; import CodeSnippet from '../../common/CodeSnippet'; import { withCLanguageFeature } from '../../hoc/withCLanguageFeature'; import RenderOptions from '../components/RenderOptions'; @@ -30,7 +31,7 @@ import { BuildTools } from '../types'; export interface ProjectKeyStepProps { buildTool?: BuildTools; - component: T.Component; + component: Component; finished: boolean; hasCLanguageFeature: boolean; onDone: () => void; diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx index d8866314d8a..1e72a440cd6 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { ClipboardIconButton } from '../../../components/controls/clipboard'; import { translate } from '../../../helpers/l10n'; +import { AppState } from '../../../types/types'; import { withAppState } from '../../hoc/withAppState'; import FinishButton from '../components/FinishButton'; import GithubCFamilyExampleRepositories from '../components/GithubCFamilyExampleRepositories'; @@ -29,7 +30,7 @@ import { BuildTools, TutorialModes } from '../types'; import PipeCommand from './commands/PipeCommand'; export interface YmlFileStepProps { - appState: T.AppState; + appState: AppState; buildTool?: BuildTools; finished: boolean; onDone: () => void; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsTutorial.tsx index e7e5de36c31..775daa44cbf 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsTutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsTutorial.tsx @@ -27,6 +27,7 @@ import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../../types/alm-settings'; +import { Component, CurrentUserSetting } from '../../../types/types'; import AllSetStep from '../components/AllSetStep'; import JenkinsfileStep from './JenkinsfileStep'; import MultiBranchPipelineStep from './MultiBranchPipelineStep'; @@ -39,9 +40,9 @@ export interface JenkinsTutorialProps { almBinding?: AlmSettingsInstance; baseUrl: string; branchesEnabled: boolean; - component: T.Component; + component: Component; projectBinding?: ProjectAlmBindingResponse; - setCurrentUserSetting: (setting: T.CurrentUserSetting) => void; + setCurrentUserSetting: (setting: CurrentUserSetting) => void; skipPreReqs: boolean; willRefreshAutomatically?: boolean; } diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsfileStep.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsfileStep.tsx index e47e66b1677..59fe516b498 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsfileStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsfileStep.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import { Alert } from '../../../components/ui/Alert'; import { translate } from '../../../helpers/l10n'; +import { Component } from '../../../types/types'; import { withCLanguageFeature } from '../../hoc/withCLanguageFeature'; import RenderOptions from '../components/RenderOptions'; import Step from '../components/Step'; @@ -32,7 +33,7 @@ import Other from './buildtool-steps/Other'; export interface JenkinsfileStepProps { baseUrl: string; - component: T.Component; + component: Component; hasCLanguageFeature: boolean; finished: boolean; onDone: () => void; @@ -42,7 +43,7 @@ export interface JenkinsfileStepProps { export interface LanguageProps { onDone: () => void; - component: T.Component; + component: Component; baseUrl: string; } diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNet.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNet.tsx index de4e4b75140..54732ec3f45 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNet.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNet.tsx @@ -19,6 +19,7 @@ */ import * as React from 'react'; import { translate } from '../../../../helpers/l10n'; +import { Component } from '../../../../types/types'; import FinishButton from '../../components/FinishButton'; import RenderOptions from '../../components/RenderOptions'; import { OSs } from '../../types'; @@ -27,7 +28,7 @@ import DotNetCore from './DotNetCore'; import DotNetFramework from './DotNetFramework'; export interface DotNetCoreFrameworkProps { - component: T.Component; + component: Component; os: OSDotNet; } diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/DoneNextSteps.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/DoneNextSteps.tsx index 5043267237f..d9a34eb2691 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/DoneNextSteps.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/DoneNextSteps.tsx @@ -21,9 +21,10 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; import { translate } from '../../../helpers/l10n'; +import { Component } from '../../../types/types'; export interface DoneNextStepsProps { - component: T.Component; + component: Component; } export default function DoneNextSteps({ component }: DoneNextStepsProps) { diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/ManualTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/ManualTutorial.tsx index 2b262228165..d3b40348e37 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/ManualTutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/ManualTutorial.tsx @@ -19,6 +19,7 @@ */ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; +import { Component, LoggedInUser } from '../../../types/types'; import InstanceMessage from '../../common/InstanceMessage'; import ProjectAnalysisStep from './ProjectAnalysisStep'; import TokenStep from './TokenStep'; @@ -29,8 +30,8 @@ export enum Steps { } interface Props { - component: T.Component; - currentUser: T.LoggedInUser; + component: Component; + currentUser: LoggedInUser; } interface State { diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/ProjectAnalysisStep.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/ProjectAnalysisStep.tsx index 285cbea5683..adbcb653d04 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/ProjectAnalysisStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/ProjectAnalysisStep.tsx @@ -19,13 +19,14 @@ */ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; +import { Component } from '../../../types/types'; import Step from '../components/Step'; import { ManualTutorialConfig } from '../types'; import BuildToolForm from './BuildToolForm'; import AnalysisCommand from './commands/AnalysisCommand'; interface Props { - component: T.Component; + component: Component; onFinish?: (projectKey?: string) => void; open: boolean; stepNumber: number; diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/TokenStep.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/TokenStep.tsx index 0be6726f953..a026bd6b677 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/TokenStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/TokenStep.tsx @@ -25,12 +25,13 @@ import { Button, DeleteButton, SubmitButton } from '../../../components/controls import Radio from '../../../components/controls/Radio'; import AlertSuccessIcon from '../../../components/icons/AlertSuccessIcon'; import { translate } from '../../../helpers/l10n'; +import { LoggedInUser, UserToken } from '../../../types/types'; import AlertErrorIcon from '../../icons/AlertErrorIcon'; import Step from '../components/Step'; import { getUniqueTokenName } from '../utils'; interface Props { - currentUser: Pick<T.LoggedInUser, 'login'>; + currentUser: Pick<LoggedInUser, 'login'>; finished: boolean; initialTokenName?: string; open: boolean; @@ -45,7 +46,7 @@ interface State { selection: string; tokenName?: string; token?: string; - tokens?: T.UserToken[]; + tokens?: UserToken[]; } export default class TokenStep extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/TokenStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/TokenStep-test.tsx index c7106339c46..452ff0c1f43 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/TokenStep-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/__tests__/TokenStep-test.tsx @@ -20,6 +20,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { change, click, submit, waitAndUpdate } from '../../../../helpers/testUtils'; +import { LoggedInUser } from '../../../../types/types'; import TokenStep from '../TokenStep'; jest.mock('../../../../api/user-tokens', () => ({ @@ -28,7 +29,7 @@ jest.mock('../../../../api/user-tokens', () => ({ revokeToken: () => Promise.resolve() })); -const currentUser: Pick<T.LoggedInUser, 'login'> = { login: 'user' }; +const currentUser: Pick<LoggedInUser, 'login'> = { login: 'user' }; it('generates token', async () => { const wrapper = shallow( diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/AnalysisCommand.tsx index 5bdbc8dd825..f99a87f0d5b 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/AnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/AnalysisCommand.tsx @@ -19,6 +19,7 @@ */ import * as React from 'react'; import { getHostUrl } from '../../../../helpers/urls'; +import { Component } from '../../../../types/types'; import { BuildTools, ManualTutorialConfig } from '../../types'; import ClangGCCCustom from './ClangGCCCommand'; import DotNet from './DotNet'; @@ -27,7 +28,7 @@ import JavaMaven from './JavaMaven'; import Other from './Other'; export interface AnalysisCommandProps { - component: T.Component; + component: Component; languageConfig: ManualTutorialConfig; token?: string; } diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/ClangGCCCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/ClangGCCCommand.tsx index 19cba151e1b..670e66c7ccc 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/ClangGCCCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/ClangGCCCommand.tsx @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Component } from '../../../../types/types'; import { CompilationInfo } from '../../components/CompilationInfo'; import { OSs } from '../../types'; import DownloadBuildWrapper from './DownloadBuildWrapper'; @@ -26,7 +27,7 @@ import ExecBuildWrapper from './ExecBuildWrapper'; import ExecScanner from './ExecScanner'; export interface ClangGCCCustomProps { - component: T.Component; + component: Component; host: string; os: OSs; token: string; diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNet.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNet.tsx index 1ba53cf6225..ee4f13ec659 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNet.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNet.tsx @@ -18,12 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Component } from '../../../../types/types'; import RenderOptions from '../../components/RenderOptions'; import DotNetCore from './DotNetCore'; import DotNetFramework from './DotNetFramework'; export interface DotNetProps { - component: T.Component; + component: Component; host: string; token: string; } diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNetExecute.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNetExecute.tsx index 5a4bc942d95..4074e8c7338 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNetExecute.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/DotNetExecute.tsx @@ -22,13 +22,14 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; import { translate } from '../../../../helpers/l10n'; +import { Component } from '../../../../types/types'; import CodeSnippet from '../../../common/CodeSnippet'; import InstanceMessage from '../../../common/InstanceMessage'; import DoneNextSteps from '../DoneNextSteps'; export interface DotNetExecuteProps { commands: string[]; - component: T.Component; + component: Component; } export default function DotNetExecute({ commands, component }: DotNetExecuteProps) { diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/ExecScanner.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/ExecScanner.tsx index cd2632eb7a6..48504610f47 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/ExecScanner.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/ExecScanner.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; import { translate } from '../../../../helpers/l10n'; +import { Component } from '../../../../types/types'; import CodeSnippet from '../../../common/CodeSnippet'; import InstanceMessage from '../../../common/InstanceMessage'; import { OSs } from '../../types'; @@ -28,7 +29,7 @@ import { quote } from '../../utils'; import DoneNextSteps from '../DoneNextSteps'; export interface ExecScannerProps { - component: T.Component; + component: Component; host: string; os: OSs; token: string; diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/JavaGradle.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/JavaGradle.tsx index 13572d1258d..c3c1923ee93 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/JavaGradle.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/JavaGradle.tsx @@ -21,12 +21,13 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; import { translate } from '../../../../helpers/l10n'; +import { Component } from '../../../../types/types'; import CodeSnippet from '../../../common/CodeSnippet'; import InstanceMessage from '../../../common/InstanceMessage'; import DoneNextSteps from '../DoneNextSteps'; export interface JavaGradleProps { - component: T.Component; + component: Component; host: string; token: string; } diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/JavaMaven.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/JavaMaven.tsx index 0ae0a0f2667..7326d8f744a 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/JavaMaven.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/JavaMaven.tsx @@ -21,12 +21,13 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; import { translate } from '../../../../helpers/l10n'; +import { Component } from '../../../../types/types'; import CodeSnippet from '../../../common/CodeSnippet'; import InstanceMessage from '../../../common/InstanceMessage'; import DoneNextSteps from '../DoneNextSteps'; export interface JavaMavenProps { - component: T.Component; + component: Component; host: string; token: string; } diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/Other.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/Other.tsx index ac53a410e21..c73fcace930 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/Other.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/Other.tsx @@ -18,12 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { Component } from '../../../../types/types'; import { OSs } from '../../types'; import DownloadScanner from './DownloadScanner'; import ExecScanner from './ExecScanner'; export interface OtherProps { - component: T.Component; + component: Component; host: string; os: OSs; token: string; diff --git a/server/sonar-web/src/main/js/components/tutorials/utils.ts b/server/sonar-web/src/main/js/components/tutorials/utils.ts index 66b2839c244..43bfa55db04 100644 --- a/server/sonar-web/src/main/js/components/tutorials/utils.ts +++ b/server/sonar-web/src/main/js/components/tutorials/utils.ts @@ -19,6 +19,7 @@ */ import { convertGithubApiUrlToLink, stripTrailingSlash } from '../../helpers/urls'; import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../types/alm-settings'; +import { UserToken } from '../../types/types'; export function quote(os: string): (s: string) => string { return os === 'win' ? (s: string) => `"${s}"` : (s: string) => s; @@ -36,7 +37,7 @@ sonarqube { }`; } -export function getUniqueTokenName(tokens: T.UserToken[], initialTokenName = '') { +export function getUniqueTokenName(tokens: UserToken[], initialTokenName = '') { const hasToken = (name: string) => tokens.find(token => token.name === name) !== undefined; if (!hasToken(initialTokenName)) { diff --git a/server/sonar-web/src/main/js/components/ui/Alert.tsx b/server/sonar-web/src/main/js/components/ui/Alert.tsx index da30e8e1144..cb4149e4a25 100644 --- a/server/sonar-web/src/main/js/components/ui/Alert.tsx +++ b/server/sonar-web/src/main/js/components/ui/Alert.tsx @@ -23,6 +23,7 @@ import classNames from 'classnames'; import * as React from 'react'; import { colors, sizes } from '../../app/theme'; import { translate } from '../../helpers/l10n'; +import { Dict } from '../../types/types'; import AlertErrorIcon from '../icons/AlertErrorIcon'; import AlertSuccessIcon from '../icons/AlertSuccessIcon'; import AlertWarnIcon from '../icons/AlertWarnIcon'; @@ -101,7 +102,7 @@ const StyledAlert = styled.div<{ isInline: boolean; variantInfo: AlertVariantInf `; function getAlertVariantInfo(variant: AlertVariant): AlertVariantInformation { - const variantList: T.Dict<AlertVariantInformation> = { + const variantList: Dict<AlertVariantInformation> = { error: { icon: <AlertErrorIcon fill={colors.alertIconError} />, color: colors.alertTextError, diff --git a/server/sonar-web/src/main/js/components/upgrade/SystemUpgradeForm.tsx b/server/sonar-web/src/main/js/components/upgrade/SystemUpgradeForm.tsx index 985f8d4600f..35a6bbcd1b1 100644 --- a/server/sonar-web/src/main/js/components/upgrade/SystemUpgradeForm.tsx +++ b/server/sonar-web/src/main/js/components/upgrade/SystemUpgradeForm.tsx @@ -22,6 +22,7 @@ import * as React from 'react'; import { translate } from '../../helpers/l10n'; import { EditionKey } from '../../types/editions'; import { SystemUpgrade } from '../../types/system'; +import { AppState } from '../../types/types'; import { ResetButtonLink } from '../controls/buttons'; import Modal from '../controls/Modal'; import { withAppState } from '../hoc/withAppState'; @@ -30,7 +31,7 @@ import SystemUpgradeItem from './SystemUpgradeItem'; import { UpdateUseCase } from './utils'; interface Props { - appState: Pick<T.AppState, 'edition' | 'version'>; + appState: Pick<AppState, 'edition' | 'version'>; onClose: () => void; systemUpgrades: SystemUpgrade[][]; latestLTS: string; diff --git a/server/sonar-web/src/main/js/components/workspace/Workspace.tsx b/server/sonar-web/src/main/js/components/workspace/Workspace.tsx index 50c6711867b..70451a10e27 100644 --- a/server/sonar-web/src/main/js/components/workspace/Workspace.tsx +++ b/server/sonar-web/src/main/js/components/workspace/Workspace.tsx @@ -21,6 +21,7 @@ import { omit, uniqBy } from 'lodash'; import * as React from 'react'; import { getRulesApp } from '../../api/rules'; import { get, save } from '../../helpers/storage'; +import { Dict } from '../../types/types'; import { lazyLoadComponent } from '../lazyLoadComponent'; import { ComponentDescriptor, RuleDescriptor, WorkspaceContext } from './context'; import './styles.css'; @@ -39,7 +40,7 @@ const WorkspaceComponentViewer = lazyLoadComponent( interface State { components: ComponentDescriptor[]; - externalRulesRepoNames: T.Dict<string>; + externalRulesRepoNames: Dict<string>; height: number; maximized?: boolean; open: { component?: string; rule?: string }; @@ -86,7 +87,7 @@ export default class Workspace extends React.PureComponent<{}, State> { fetchRuleNames = async () => { const { repositories } = await getRulesApp(); - const externalRulesRepoNames: T.Dict<string> = {}; + const externalRulesRepoNames: Dict<string> = {}; repositories .filter(({ key }) => key.startsWith('external_')) .forEach(({ key, name }) => { diff --git a/server/sonar-web/src/main/js/components/workspace/WorkspaceComponentViewer.tsx b/server/sonar-web/src/main/js/components/workspace/WorkspaceComponentViewer.tsx index e6faee49b8f..02541b49b57 100644 --- a/server/sonar-web/src/main/js/components/workspace/WorkspaceComponentViewer.tsx +++ b/server/sonar-web/src/main/js/components/workspace/WorkspaceComponentViewer.tsx @@ -25,12 +25,13 @@ import { isPullRequest } from '../../helpers/branch-like'; import { scrollToElement } from '../../helpers/scrolling'; import { fetchBranchStatus } from '../../store/rootActions'; import { BranchLike } from '../../types/branch-like'; +import { Issue, SourceViewerFile } from '../../types/types'; import SourceViewer from '../SourceViewer/SourceViewer'; import { ComponentDescriptor } from './context'; import WorkspaceComponentTitle from './WorkspaceComponentTitle'; import WorkspaceHeader, { Props as WorkspaceHeaderProps } from './WorkspaceHeader'; -export interface Props extends T.Omit<WorkspaceHeaderProps, 'children' | 'onClose'> { +export interface Props extends Omit<WorkspaceHeaderProps, 'children' | 'onClose'> { component: ComponentDescriptor; fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>; height: number; @@ -62,11 +63,11 @@ export class WorkspaceComponentViewer extends React.PureComponent<Props> { this.props.onClose(this.props.component.key); }; - handleIssueChange = (_: T.Issue) => { + handleIssueChange = (_: Issue) => { this.refreshBranchStatus(); }; - handleLoaded = (component: T.SourceViewerFile) => { + handleLoaded = (component: SourceViewerFile) => { this.props.onLoad({ key: this.props.component.key, name: component.path, diff --git a/server/sonar-web/src/main/js/components/workspace/WorkspaceRuleDetails.tsx b/server/sonar-web/src/main/js/components/workspace/WorkspaceRuleDetails.tsx index c9ba62a3b55..9a57404ea6b 100644 --- a/server/sonar-web/src/main/js/components/workspace/WorkspaceRuleDetails.tsx +++ b/server/sonar-web/src/main/js/components/workspace/WorkspaceRuleDetails.tsx @@ -24,6 +24,7 @@ import RuleDetailsDescription from '../../apps/coding-rules/components/RuleDetai import RuleDetailsMeta from '../../apps/coding-rules/components/RuleDetailsMeta'; import '../../apps/coding-rules/styles.css'; import DeferredSpinner from '../../components/ui/DeferredSpinner'; +import { Dict, RuleDetails } from '../../types/types'; interface Props { onLoad: (details: { name: string }) => void; @@ -32,8 +33,8 @@ interface Props { interface State { loading: boolean; - referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; - ruleDetails?: T.RuleDetails; + referencedRepositories: Dict<{ key: string; language: string; name: string }>; + ruleDetails?: RuleDetails; } export default class WorkspaceRuleDetails extends React.PureComponent<Props, State> { diff --git a/server/sonar-web/src/main/js/components/workspace/WorkspaceRuleViewer.tsx b/server/sonar-web/src/main/js/components/workspace/WorkspaceRuleViewer.tsx index 0e59f8be83f..8d99b9ba40e 100644 --- a/server/sonar-web/src/main/js/components/workspace/WorkspaceRuleViewer.tsx +++ b/server/sonar-web/src/main/js/components/workspace/WorkspaceRuleViewer.tsx @@ -23,7 +23,7 @@ import WorkspaceHeader, { Props as WorkspaceHeaderProps } from './WorkspaceHeade import WorkspaceRuleDetails from './WorkspaceRuleDetails'; import WorkspaceRuleTitle from './WorkspaceRuleTitle'; -export interface Props extends T.Omit<WorkspaceHeaderProps, 'children' | 'onClose'> { +export interface Props extends Omit<WorkspaceHeaderProps, 'children' | 'onClose'> { rule: RuleDescriptor; height: number; onClose: (componentKey: string) => void; diff --git a/server/sonar-web/src/main/js/components/workspace/context.ts b/server/sonar-web/src/main/js/components/workspace/context.ts index a7ae908d22a..7491c6770d2 100644 --- a/server/sonar-web/src/main/js/components/workspace/context.ts +++ b/server/sonar-web/src/main/js/components/workspace/context.ts @@ -19,6 +19,7 @@ */ import { createContext } from 'react'; import { BranchLike } from '../../types/branch-like'; +import { Dict } from '../../types/types'; export interface ComponentDescriptor { branchLike: BranchLike | undefined; @@ -34,7 +35,7 @@ export interface RuleDescriptor { } export interface WorkspaceContextShape { - externalRulesRepoNames: T.Dict<string>; + externalRulesRepoNames: Dict<string>; openComponent: (component: ComponentDescriptor) => void; openRule: (rule: RuleDescriptor) => void; } diff --git a/server/sonar-web/src/main/js/helpers/__tests__/request-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/request-test.ts index 55818d0e7d9..89fab57bd62 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/request-test.ts +++ b/server/sonar-web/src/main/js/helpers/__tests__/request-test.ts @@ -20,6 +20,7 @@ /* eslint-disable no-await-in-loop */ +import { Dict } from '../../types/types'; import handleRequiredAuthentication from '../handleRequiredAuthentication'; import { checkStatus, @@ -345,7 +346,7 @@ describe('isSuccessStatus', () => { }); }); -function mockResponse(headers: T.Dict<string> = {}, status = HttpStatus.Ok, value?: any): Response { +function mockResponse(headers: Dict<string> = {}, status = HttpStatus.Ok, value?: any): Response { const body = value && value instanceof Object ? JSON.stringify(value) : value; const response = new Response(body, { headers, status }); response.json = jest.fn().mockResolvedValue(value); diff --git a/server/sonar-web/src/main/js/helpers/component.ts b/server/sonar-web/src/main/js/helpers/component.ts index c3820cb2a2d..7e702b2acbf 100644 --- a/server/sonar-web/src/main/js/helpers/component.ts +++ b/server/sonar-web/src/main/js/helpers/component.ts @@ -18,8 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { ComponentMeasure, ComponentMeasureEnhanced } from '../types/types'; + export function getComponentMeasureUniqueKey( - component?: T.ComponentMeasure | T.ComponentMeasureEnhanced + component?: ComponentMeasure | ComponentMeasureEnhanced ) { return component ? [component.key, component.branch].filter(s => !!s).join('/') : undefined; } diff --git a/server/sonar-web/src/main/js/helpers/constants.ts b/server/sonar-web/src/main/js/helpers/constants.ts index 96f776c6af8..8ccab49087f 100644 --- a/server/sonar-web/src/main/js/helpers/constants.ts +++ b/server/sonar-web/src/main/js/helpers/constants.ts @@ -21,10 +21,11 @@ import { colors } from '../app/theme'; import { AlmKeys } from '../types/alm-settings'; import { ComponentQualifier } from '../types/component'; import { IssueScope, IssueType } from '../types/issues'; +import { RuleType } from '../types/types'; export const SEVERITIES = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']; export const STATUSES = ['OPEN', 'REOPENED', 'CONFIRMED', 'RESOLVED', 'CLOSED']; -export const ISSUE_TYPES: T.IssueType[] = [ +export const ISSUE_TYPES: IssueType[] = [ IssueType.Bug, IssueType.Vulnerability, IssueType.CodeSmell, @@ -34,7 +35,7 @@ export const SOURCE_SCOPES = [ { scope: IssueScope.Main, qualifier: ComponentQualifier.File }, { scope: IssueScope.Test, qualifier: ComponentQualifier.TestFile } ]; -export const RULE_TYPES: T.RuleType[] = ['BUG', 'VULNERABILITY', 'CODE_SMELL', 'SECURITY_HOTSPOT']; +export const RULE_TYPES: RuleType[] = ['BUG', 'VULNERABILITY', 'CODE_SMELL', 'SECURITY_HOTSPOT']; export const RULE_STATUSES = ['READY', 'BETA', 'DEPRECATED']; export const CHART_COLORS_RANGE_PERCENT = [ diff --git a/server/sonar-web/src/main/js/helpers/cookies.ts b/server/sonar-web/src/main/js/helpers/cookies.ts index d717044f4b0..3a4aef6b501 100644 --- a/server/sonar-web/src/main/js/helpers/cookies.ts +++ b/server/sonar-web/src/main/js/helpers/cookies.ts @@ -18,11 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { memoize } from 'lodash'; +import { Dict } from '../types/types'; const parseCookies = memoize( - (documentCookie: string): T.Dict<string> => { + (documentCookie: string): Dict<string> => { const rawCookies = documentCookie.split('; '); - const cookies: T.Dict<string> = {}; + const cookies: Dict<string> = {}; rawCookies.forEach(candidate => { const [key, value] = candidate.split('='); cookies[key] = value; diff --git a/server/sonar-web/src/main/js/helpers/extensionsHandler.ts b/server/sonar-web/src/main/js/helpers/extensionsHandler.ts index 078cc9ca6e3..1af989fd0c2 100644 --- a/server/sonar-web/src/main/js/helpers/extensionsHandler.ts +++ b/server/sonar-web/src/main/js/helpers/extensionsHandler.ts @@ -20,11 +20,12 @@ // Do not import dependencies in this helper, to keep initial bundle load as small as possible import { ExtensionRegistryEntry, ExtensionStartMethod } from '../types/extension'; +import { Dict } from '../types/types'; import { getEnhancedWindow } from './browser'; const WEB_ANALYTICS_EXTENSION = 'sq-web-analytics'; -const extensions: T.Dict<ExtensionRegistryEntry> = {}; +const extensions: Dict<ExtensionRegistryEntry> = {}; function registerExtension(key: string, start: ExtensionStartMethod, providesCSSFile = false) { extensions[key] = { start, providesCSSFile }; diff --git a/server/sonar-web/src/main/js/helpers/issues.ts b/server/sonar-web/src/main/js/helpers/issues.ts index 75d2dfb0c58..fb5ed0ec043 100644 --- a/server/sonar-web/src/main/js/helpers/issues.ts +++ b/server/sonar-web/src/main/js/helpers/issues.ts @@ -24,6 +24,7 @@ import SecurityHotspotIcon from '../components/icons/SecurityHotspotIcon'; import VulnerabilityIcon from '../components/icons/VulnerabilityIcon'; import { IssueType, RawIssue } from '../types/issues'; import { MetricKey } from '../types/metrics'; +import { Dict, FlowLocation, Issue, TextRange, UserBase } from '../types/types'; import { ISSUE_TYPES } from './constants'; interface Rule {} @@ -33,17 +34,17 @@ interface Component { name: string; } -export function sortByType<T extends Pick<T.Issue, 'type'>>(issues: T[]): T[] { - return sortBy(issues, issue => ISSUE_TYPES.indexOf(issue.type)); +export function sortByType<T extends Pick<Issue, 'type'>>(issues: T[]): T[] { + return sortBy(issues, issue => ISSUE_TYPES.indexOf(issue.type as IssueType)); } function injectRelational( - issue: T.Dict<any>, + issue: Dict<any>, source: any[] | undefined, baseField: string, lookupField: string ) { - const newFields: T.Dict<any> = {}; + const newFields: Dict<any> = {}; const baseValue = issue[baseField]; if (baseValue !== undefined && source !== undefined) { const lookupValue = source.find(candidate => candidate[lookupField] === baseValue); @@ -57,7 +58,7 @@ function injectRelational( return newFields; } -function injectCommentsRelational(issue: RawIssue, users?: T.UserBase[]) { +function injectCommentsRelational(issue: RawIssue, users?: UserBase[]) { if (!issue.comments) { return {}; } @@ -73,15 +74,15 @@ function injectCommentsRelational(issue: RawIssue, users?: T.UserBase[]) { function prepareClosed( issue: RawIssue, - secondaryLocations: T.FlowLocation[], - flows: T.FlowLocation[][] + secondaryLocations: FlowLocation[], + flows: FlowLocation[][] ) { return issue.status === 'CLOSED' ? { flows: [], line: undefined, textRange: undefined, secondaryLocations: [] } : { flows, secondaryLocations }; } -function ensureTextRange(issue: RawIssue): { textRange?: T.TextRange } { +function ensureTextRange(issue: RawIssue): { textRange?: TextRange } { return issue.line && !issue.textRange ? { textRange: { @@ -94,7 +95,7 @@ function ensureTextRange(issue: RawIssue): { textRange?: T.TextRange } { : {}; } -function reverseLocations(locations: T.FlowLocation[]): T.FlowLocation[] { +function reverseLocations(locations: FlowLocation[]): FlowLocation[] { const x = [...locations]; x.reverse(); return x; @@ -103,8 +104,8 @@ function reverseLocations(locations: T.FlowLocation[]): T.FlowLocation[] { function splitFlows( issue: RawIssue, components: Component[] = [] -): { secondaryLocations: T.FlowLocation[]; flows: T.FlowLocation[][] } { - const parsedFlows: T.FlowLocation[][] = (issue.flows || []) +): { secondaryLocations: FlowLocation[]; flows: FlowLocation[][] } { + const parsedFlows: FlowLocation[][] = (issue.flows || []) .filter(flow => flow.locations !== undefined) .map(flow => flow.locations!.filter(location => location.textRange != null)) .map(flow => @@ -121,7 +122,7 @@ function splitFlows( : { secondaryLocations: [], flows: parsedFlows.map(reverseLocations) }; } -function orderLocations(locations: T.FlowLocation[]) { +function orderLocations(locations: FlowLocation[]) { return sortBy( locations, location => location.textRange && location.textRange.startLine, @@ -132,9 +133,9 @@ function orderLocations(locations: T.FlowLocation[]) { export function parseIssueFromResponse( issue: RawIssue, components?: Component[], - users?: T.UserBase[], + users?: UserBase[], rules?: Rule[] -): T.Issue { +): Issue { const { secondaryLocations, flows } = splitFlows(issue, components); return { ...issue, @@ -146,7 +147,7 @@ export function parseIssueFromResponse( ...injectCommentsRelational(issue, users), ...prepareClosed(issue, secondaryLocations, flows), ...ensureTextRange(issue) - } as T.Issue; + } as Issue; } export const ISSUETYPE_METRIC_KEYS_MAP = { diff --git a/server/sonar-web/src/main/js/helpers/l10n.ts b/server/sonar-web/src/main/js/helpers/l10n.ts index a57732333ca..cf01bde7d68 100644 --- a/server/sonar-web/src/main/js/helpers/l10n.ts +++ b/server/sonar-web/src/main/js/helpers/l10n.ts @@ -19,10 +19,11 @@ */ import { fetchL10nBundle } from '../api/l10n'; import { L10nBundle, L10nBundleRequestParams } from '../types/l10n'; +import { Dict } from '../types/types'; import { toNotSoISOString } from './dates'; import { get as loadFromLocalStorage, save as saveInLocalStorage } from './storage'; -export type Messages = T.Dict<string>; +export type Messages = Dict<string>; export const DEFAULT_LOCALE = 'en'; export const DEFAULT_MESSAGES = { diff --git a/server/sonar-web/src/main/js/helpers/measures.ts b/server/sonar-web/src/main/js/helpers/measures.ts index 86451fc6e0b..27347cb7b69 100644 --- a/server/sonar-web/src/main/js/helpers/measures.ts +++ b/server/sonar-web/src/main/js/helpers/measures.ts @@ -22,13 +22,14 @@ import { QualityGateStatusCondition, QualityGateStatusConditionEnhanced } from '../types/quality-gates'; +import { Dict, Measure, MeasureEnhanced, Metric } from '../types/types'; import { getCurrentLocale, translate, translateWithParameters } from './l10n'; import { isDefined } from './types'; export function enhanceMeasuresWithMetrics( - measures: T.Measure[], - metrics: T.Metric[] -): T.MeasureEnhanced[] { + measures: Measure[], + metrics: Metric[] +): MeasureEnhanced[] { return measures .map(measure => { const metric = metrics.find(metric => metric.key === measure.metric); @@ -39,7 +40,7 @@ export function enhanceMeasuresWithMetrics( export function enhanceConditionWithMeasure( condition: QualityGateStatusCondition, - measures: T.MeasureEnhanced[] + measures: MeasureEnhanced[] ): QualityGateStatusConditionEnhanced | undefined { const measure = measures.find(m => m.metric.key === condition.metric); @@ -53,7 +54,7 @@ export function enhanceConditionWithMeasure( return measure && { ...condition, period, measure }; } -export function isPeriodBestValue(measure: T.Measure | T.MeasureEnhanced): boolean { +export function isPeriodBestValue(measure: Measure | MeasureEnhanced): boolean { return measure.period?.bestValue || false; } @@ -124,11 +125,11 @@ export function getRatingTooltip(metricKey: MetricKey | string, value: number | : translate('metric', finalMetricKey, 'tooltip', ratingLetter); } -export function getDisplayMetrics(metrics: T.Metric[]) { +export function getDisplayMetrics(metrics: Metric[]) { return metrics.filter(metric => !metric.hidden && !['DATA', 'DISTRIB'].includes(metric.type)); } -export function findMeasure(measures: T.MeasureEnhanced[], metric: MetricKey | string) { +export function findMeasure(measures: MeasureEnhanced[], metric: MetricKey | string) { return measures.find(measure => measure.metric.key === metric); } @@ -196,7 +197,7 @@ function useFormatter( } function getFormatter(type: string): Formatter { - const FORMATTERS: T.Dict<Formatter> = { + const FORMATTERS: Dict<Formatter> = { INT: intFormatter, SHORT_INT: shortIntFormatter, FLOAT: floatFormatter, diff --git a/server/sonar-web/src/main/js/helpers/mocks/component.ts b/server/sonar-web/src/main/js/helpers/mocks/component.ts index 19149a524c2..08074edb344 100644 --- a/server/sonar-web/src/main/js/helpers/mocks/component.ts +++ b/server/sonar-web/src/main/js/helpers/mocks/component.ts @@ -17,11 +17,12 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { ComponentQualifier, TreeComponent } from '../../types/component'; +import { ComponentQualifier, TreeComponent, Visibility } from '../../types/component'; import { MetricKey } from '../../types/metrics'; +import { Component, ComponentMeasure, ComponentMeasureEnhanced } from '../../types/types'; import { mockMeasureEnhanced } from '../testMocks'; -export function mockComponent(overrides: Partial<T.Component> = {}): T.Component { +export function mockComponent(overrides: Partial<Component> = {}): Component { return { breadcrumbs: [], key: 'my-project', @@ -46,15 +47,15 @@ export function mockTreeComponent(overrides: Partial<TreeComponent>): TreeCompon key: 'my-key', qualifier: ComponentQualifier.Project, name: 'component', - visibility: 'public', + visibility: Visibility.Public, ...overrides }; } export function mockComponentMeasure( file = false, - overrides: Partial<T.ComponentMeasure> = {} -): T.ComponentMeasure { + overrides: Partial<ComponentMeasure> = {} +): ComponentMeasure { if (file) { return { key: 'foo:src/index.tsx', @@ -75,10 +76,10 @@ export function mockComponentMeasure( } export function mockComponentMeasureEnhanced( - overrides: Partial<T.ComponentMeasureEnhanced> = {} -): T.ComponentMeasureEnhanced { + overrides: Partial<ComponentMeasureEnhanced> = {} +): ComponentMeasureEnhanced { return { - ...mockComponentMeasure(false, overrides as T.ComponentMeasure), + ...mockComponentMeasure(false, overrides as ComponentMeasure), leak: undefined, measures: [mockMeasureEnhanced()], value: undefined, diff --git a/server/sonar-web/src/main/js/helpers/mocks/issues.ts b/server/sonar-web/src/main/js/helpers/mocks/issues.ts index 034eb0af139..a2c4bf1a2a2 100644 --- a/server/sonar-web/src/main/js/helpers/mocks/issues.ts +++ b/server/sonar-web/src/main/js/helpers/mocks/issues.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { ReferencedRule } from '../../types/issues'; +import { IssueChangelog } from '../../types/types'; export function mockReferencedRule(overrides: Partial<ReferencedRule> = {}): ReferencedRule { return { @@ -27,7 +28,7 @@ export function mockReferencedRule(overrides: Partial<ReferencedRule> = {}): Ref }; } -export function mockIssueChangelog(overrides: Partial<T.IssueChangelog> = {}): T.IssueChangelog { +export function mockIssueChangelog(overrides: Partial<IssueChangelog> = {}): IssueChangelog { return { creationDate: '2018-10-01', isUserActive: true, diff --git a/server/sonar-web/src/main/js/helpers/mocks/permissions.ts b/server/sonar-web/src/main/js/helpers/mocks/permissions.ts index 815074d0fd9..59564250d93 100644 --- a/server/sonar-web/src/main/js/helpers/mocks/permissions.ts +++ b/server/sonar-web/src/main/js/helpers/mocks/permissions.ts @@ -17,9 +17,10 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { PermissionGroup, PermissionUser } from '../../types/types'; import { mockUser } from '../testMocks'; -export function mockPermissionGroup(overrides: Partial<T.PermissionGroup> = {}): T.PermissionGroup { +export function mockPermissionGroup(overrides: Partial<PermissionGroup> = {}): PermissionGroup { return { name: 'sonar-admins', permissions: ['provisioning'], @@ -27,7 +28,7 @@ export function mockPermissionGroup(overrides: Partial<T.PermissionGroup> = {}): }; } -export function mockPermissionUser(overrides: Partial<T.PermissionUser> = {}): T.PermissionUser { +export function mockPermissionUser(overrides: Partial<PermissionUser> = {}): PermissionUser { return { ...mockUser(), active: true, diff --git a/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts b/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts index 546a32c7799..3ea683465a6 100644 --- a/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts +++ b/server/sonar-web/src/main/js/helpers/mocks/quality-gates.ts @@ -25,9 +25,10 @@ import { QualityGateStatusCondition, QualityGateStatusConditionEnhanced } from '../../types/quality-gates'; +import { QualityGate } from '../../types/types'; import { mockMeasureEnhanced, mockMetric } from '../testMocks'; -export function mockQualityGate(overrides: Partial<T.QualityGate> = {}): T.QualityGate { +export function mockQualityGate(overrides: Partial<QualityGate> = {}): QualityGate { return { id: '1', name: 'qualitygate', diff --git a/server/sonar-web/src/main/js/helpers/mocks/users.ts b/server/sonar-web/src/main/js/helpers/mocks/users.ts index b1bd18b7566..358cc54a42c 100644 --- a/server/sonar-web/src/main/js/helpers/mocks/users.ts +++ b/server/sonar-web/src/main/js/helpers/mocks/users.ts @@ -18,7 +18,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export function mockUserBase(overrides: Partial<T.UserBase> = {}): T.UserBase { +import { UserBase } from '../../types/types'; + +export function mockUserBase(overrides: Partial<UserBase> = {}): UserBase { return { login: 'userlogin', ...overrides diff --git a/server/sonar-web/src/main/js/helpers/periods.ts b/server/sonar-web/src/main/js/helpers/periods.ts index 63892450b9c..b776d0f966f 100644 --- a/server/sonar-web/src/main/js/helpers/periods.ts +++ b/server/sonar-web/src/main/js/helpers/periods.ts @@ -20,9 +20,10 @@ import { parseDate } from '../helpers/dates'; import { translate, translateWithParameters } from '../helpers/l10n'; import { ApplicationPeriod } from '../types/application'; +import { Period } from '../types/types'; export function getPeriodLabel( - period: T.Period | undefined, + period: Period | undefined, dateFormatter: (date: string) => string ) { if (!period) { @@ -63,7 +64,7 @@ export function getPeriodDate(period?: { date?: string }): Date | undefined { } export function isApplicationPeriod( - period: T.Period | ApplicationPeriod + period: Period | ApplicationPeriod ): period is ApplicationPeriod { return (period as ApplicationPeriod).project !== undefined; } diff --git a/server/sonar-web/src/main/js/helpers/projectLinks.ts b/server/sonar-web/src/main/js/helpers/projectLinks.ts index cf567cdb4cd..30d9b6fa637 100644 --- a/server/sonar-web/src/main/js/helpers/projectLinks.ts +++ b/server/sonar-web/src/main/js/helpers/projectLinks.ts @@ -19,11 +19,12 @@ */ import { partition, sortBy } from 'lodash'; import { translate } from '../helpers/l10n'; +import { ProjectLink } from '../types/types'; const PROVIDED_TYPES = ['homepage', 'ci', 'issue', 'scm', 'scm_dev']; -type NameAndType = Pick<T.ProjectLink, 'name' | 'type'>; +type NameAndType = Pick<ProjectLink, 'name' | 'type'>; -export function isProvided(link: Pick<T.ProjectLink, 'type'>) { +export function isProvided(link: Pick<ProjectLink, 'type'>) { return PROVIDED_TYPES.includes(link.type); } diff --git a/server/sonar-web/src/main/js/helpers/query.ts b/server/sonar-web/src/main/js/helpers/query.ts index bc5fa4dd6d2..9df3777d6f7 100644 --- a/server/sonar-web/src/main/js/helpers/query.ts +++ b/server/sonar-web/src/main/js/helpers/query.ts @@ -18,9 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { isEqual, isNil, omitBy } from 'lodash'; +import { RawQuery } from '../types/types'; import { isValidDate, parseDate, toNotSoISOString, toShortNotSoISOString } from './dates'; -export function queriesEqual(a: T.RawQuery, b: T.RawQuery): boolean { +export function queriesEqual(a: RawQuery, b: RawQuery): boolean { const keysA = Object.keys(a); const keysB = Object.keys(b); @@ -31,7 +32,7 @@ export function queriesEqual(a: T.RawQuery, b: T.RawQuery): boolean { return keysA.every(key => isEqual(a[key], b[key])); } -export function cleanQuery(query: T.RawQuery): T.RawQuery { +export function cleanQuery(query: RawQuery): RawQuery { return omitBy(query, isNil); } diff --git a/server/sonar-web/src/main/js/helpers/request.ts b/server/sonar-web/src/main/js/helpers/request.ts index 029ac9c37c4..7b342bf52c4 100644 --- a/server/sonar-web/src/main/js/helpers/request.ts +++ b/server/sonar-web/src/main/js/helpers/request.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { isNil, omitBy } from 'lodash'; +import { Dict } from '../types/types'; import { getCookie } from './cookies'; import { translate } from './l10n'; import { stringify } from './stringify-queryparams'; @@ -39,14 +40,14 @@ export function getCSRFTokenValue(): string { /** * Return an object containing a special http request header used to prevent CSRF attacks. */ -export function getCSRFToken(): T.Dict<string> { +export function getCSRFToken(): Dict<string> { // Fetch API in Edge doesn't work with empty header, // so we ensure non-empty value const value = getCSRFTokenValue(); return value ? { [getCSRFTokenName()]: value } : {}; } -export type RequestData = T.Dict<any>; +export type RequestData = Dict<any>; export function omitNil(obj: RequestData): RequestData { return omitBy(obj, isNil); diff --git a/server/sonar-web/src/main/js/helpers/strings.ts b/server/sonar-web/src/main/js/helpers/strings.ts index 7b701a7f7bd..a44a024ac0b 100644 --- a/server/sonar-web/src/main/js/helpers/strings.ts +++ b/server/sonar-web/src/main/js/helpers/strings.ts @@ -17,6 +17,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +import { Dict } from '../types/types'; + /* * Latinize string by removing all diacritics * From http://stackoverflow.com/questions/990904/javascript-remove-accents-in-strings @@ -393,7 +396,7 @@ const defaultDiacriticsRemovalap = [ } ]; -const diacriticsMap: T.Dict<string> = {}; +const diacriticsMap: Dict<string> = {}; defaultDiacriticsRemovalap.forEach(defaultDiacritic => defaultDiacritic.letters.split('').forEach(letter => { diacriticsMap[letter] = defaultDiacritic.base; diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts index 1e77d0f4920..29b6497b232 100644 --- a/server/sonar-web/src/main/js/helpers/testMocks.ts +++ b/server/sonar-web/src/main/js/helpers/testMocks.ts @@ -25,8 +25,41 @@ import { DocumentationEntry } from '../apps/documentation/utils'; import { Exporter, Profile } from '../apps/quality-profiles/types'; import { DumpStatus, DumpTask } from '../types/project-dump'; import { TaskStatuses } from '../types/tasks'; - -export function mockAlmApplication(overrides: Partial<T.AlmApplication> = {}): T.AlmApplication { +import { + AlmApplication, + Analysis, + AnalysisEvent, + AppState, + Condition, + CurrentUser, + FlowLocation, + Group, + HealthType, + IdentityProvider, + Issue, + Language, + LoggedInUser, + Measure, + MeasureEnhanced, + Metric, + Paging, + ParsedAnalysis, + Period, + ProfileInheritanceDetails, + Rule, + RuleActivation, + RuleDetails, + RuleParameter, + SnippetsByComponent, + SourceLine, + SourceViewerFile, + SysInfoBase, + SysInfoCluster, + SysInfoStandalone, + User +} from '../types/types'; + +export function mockAlmApplication(overrides: Partial<AlmApplication> = {}): AlmApplication { return { backgroundColor: '#444444', iconPath: '/images/sonarcloud/github-white.svg', @@ -37,7 +70,7 @@ export function mockAlmApplication(overrides: Partial<T.AlmApplication> = {}): T }; } -export function mockAnalysis(overrides: Partial<T.Analysis> = {}): T.Analysis { +export function mockAnalysis(overrides: Partial<Analysis> = {}): Analysis { return { date: '2017-03-01T09:36:01+0100', events: [], @@ -47,7 +80,7 @@ export function mockAnalysis(overrides: Partial<T.Analysis> = {}): T.Analysis { }; } -export function mockParsedAnalysis(overrides: Partial<T.ParsedAnalysis> = {}): T.ParsedAnalysis { +export function mockParsedAnalysis(overrides: Partial<ParsedAnalysis> = {}): ParsedAnalysis { return { date: new Date('2017-03-01T09:37:01+0100'), events: [], @@ -57,7 +90,7 @@ export function mockParsedAnalysis(overrides: Partial<T.ParsedAnalysis> = {}): T }; } -export function mockAnalysisEvent(overrides: Partial<T.AnalysisEvent> = {}): T.AnalysisEvent { +export function mockAnalysisEvent(overrides: Partial<AnalysisEvent> = {}): AnalysisEvent { return { category: 'QUALITY_GATE', key: 'E11', @@ -83,7 +116,7 @@ export function mockAnalysisEvent(overrides: Partial<T.AnalysisEvent> = {}): T.A }; } -export function mockAppState(overrides: Partial<T.AppState> = {}): T.AppState { +export function mockAppState(overrides: Partial<AppState> = {}): AppState { return { edition: 'community', productionDatabase: true, @@ -94,9 +127,9 @@ export function mockAppState(overrides: Partial<T.AppState> = {}): T.AppState { }; } -export function mockBaseSysInfo(overrides: Partial<any> = {}): T.SysInfoBase { +export function mockBaseSysInfo(overrides: Partial<any> = {}): SysInfoBase { return { - Health: 'GREEN' as T.HealthType, + Health: 'GREEN' as HealthType, 'Health Causes': [], System: { Version: '7.8' @@ -122,7 +155,7 @@ export function mockBaseSysInfo(overrides: Partial<any> = {}): T.SysInfoBase { }; } -export function mockClusterSysInfo(overrides: Partial<any> = {}): T.SysInfoCluster { +export function mockClusterSysInfo(overrides: Partial<any> = {}): SysInfoCluster { const baseInfo = mockBaseSysInfo(overrides); return { ...baseInfo, @@ -139,7 +172,7 @@ export function mockClusterSysInfo(overrides: Partial<any> = {}): T.SysInfoClust { Name: 'server9.example.com', Host: '10.0.0.0', - Health: 'GREEN' as T.HealthType, + Health: 'GREEN' as HealthType, 'Health Causes': [], System: { Version: '7.8' @@ -182,7 +215,7 @@ export function mockClusterSysInfo(overrides: Partial<any> = {}): T.SysInfoClust { Name: 'server9.example.com', Host: '10.0.0.0', - Health: 'GREEN' as T.HealthType, + Health: 'GREEN' as HealthType, 'Health Causes': [], System: { Version: '7.8' @@ -257,7 +290,7 @@ export function mockClusterSysInfo(overrides: Partial<any> = {}): T.SysInfoClust }; } -export function mockCondition(overrides: Partial<T.Condition> = {}): T.Condition { +export function mockCondition(overrides: Partial<Condition> = {}): Condition { return { error: '10', id: 1, @@ -270,8 +303,8 @@ export function mockCondition(overrides: Partial<T.Condition> = {}): T.Condition export function mockSnippetsByComponent( component = 'main.js', lines: number[] = [16] -): T.SnippetsByComponent { - const sources = lines.reduce((lines: { [key: number]: T.SourceLine }, line) => { +): SnippetsByComponent { + const sources = lines.reduce((lines: { [key: number]: SourceLine }, line) => { lines[line] = mockSourceLine({ line }); return lines; }, {}); @@ -284,7 +317,7 @@ export function mockSnippetsByComponent( }; } -export function mockSourceLine(overrides: Partial<T.SourceLine> = {}): T.SourceLine { +export function mockSourceLine(overrides: Partial<SourceLine> = {}): SourceLine { return { line: 16, code: '<span class="k">import</span> java.util.<span class="sym-9 sym">ArrayList</span>;', @@ -299,14 +332,14 @@ export function mockSourceLine(overrides: Partial<T.SourceLine> = {}): T.SourceL }; } -export function mockCurrentUser(overrides: Partial<T.CurrentUser> = {}): T.CurrentUser { +export function mockCurrentUser(overrides: Partial<CurrentUser> = {}): CurrentUser { return { isLoggedIn: false, ...overrides }; } -export function mockLoggedInUser(overrides: Partial<T.LoggedInUser> = {}): T.LoggedInUser { +export function mockLoggedInUser(overrides: Partial<LoggedInUser> = {}): LoggedInUser { return { groups: [], isLoggedIn: true, @@ -317,7 +350,7 @@ export function mockLoggedInUser(overrides: Partial<T.LoggedInUser> = {}): T.Log }; } -export function mockGroup(overrides: Partial<T.Group> = {}): T.Group { +export function mockGroup(overrides: Partial<Group> = {}): Group { return { id: 1, membersCount: 1, @@ -336,8 +369,8 @@ export function mockEvent(overrides = {}) { } as any; } -export function mockIssue(withLocations = false, overrides: Partial<T.Issue> = {}) { - const issue: T.Issue = { +export function mockIssue(withLocations = false, overrides: Partial<Issue> = {}) { + const issue: Issue = { actions: [], component: 'main.js', componentLongName: 'main.js', @@ -391,9 +424,7 @@ export function mockLocation(overrides: Partial<Location> = {}): Location { }; } -export function mockMetric( - overrides: Partial<Pick<T.Metric, 'key' | 'name' | 'type'>> = {} -): T.Metric { +export function mockMetric(overrides: Partial<Pick<Metric, 'key' | 'name' | 'type'>> = {}): Metric { const key = overrides.key || 'coverage'; const name = overrides.name || key[0].toUpperCase() + key.substr(1); const type = overrides.type || 'PERCENT'; @@ -405,7 +436,7 @@ export function mockMetric( }; } -export function mockMeasure(overrides: Partial<T.Measure> = {}): T.Measure { +export function mockMeasure(overrides: Partial<Measure> = {}): Measure { return { bestValue: true, metric: 'bugs', @@ -419,7 +450,7 @@ export function mockMeasure(overrides: Partial<T.Measure> = {}): T.Measure { }; } -export function mockMeasureEnhanced(overrides: Partial<T.MeasureEnhanced> = {}): T.MeasureEnhanced { +export function mockMeasureEnhanced(overrides: Partial<MeasureEnhanced> = {}): MeasureEnhanced { return { bestValue: true, leak: '1', @@ -434,7 +465,7 @@ export function mockMeasureEnhanced(overrides: Partial<T.MeasureEnhanced> = {}): }; } -export function mockPeriod(overrides: Partial<T.Period> = {}): T.Period { +export function mockPeriod(overrides: Partial<Period> = {}): Period { return { date: '2019-04-23T02:12:32+0100', index: 0, @@ -462,8 +493,8 @@ export function mockQualityProfile(overrides: Partial<Profile> = {}): Profile { } export function mockQualityProfileInheritance( - overrides: Partial<T.ProfileInheritanceDetails> = {} -): T.ProfileInheritanceDetails { + overrides: Partial<ProfileInheritanceDetails> = {} +): ProfileInheritanceDetails { return { activeRuleCount: 4, isBuiltIn: false, @@ -511,7 +542,7 @@ export function mockRouter(overrides: { push?: Function; replace?: Function } = } as InjectedRouter; } -export function mockRule(overrides: Partial<T.Rule> = {}): T.Rule { +export function mockRule(overrides: Partial<Rule> = {}): Rule { return { key: 'javascript:S1067', lang: 'js', @@ -523,10 +554,10 @@ export function mockRule(overrides: Partial<T.Rule> = {}): T.Rule { tags: ['x'], type: 'CODE_SMELL', ...overrides - } as T.Rule; + } as Rule; } -export function mockRuleActivation(overrides: Partial<T.RuleActivation> = {}): T.RuleActivation { +export function mockRuleActivation(overrides: Partial<RuleActivation> = {}): RuleActivation { return { createdAt: '2020-02-01', inherit: 'NONE', @@ -537,7 +568,7 @@ export function mockRuleActivation(overrides: Partial<T.RuleActivation> = {}): T }; } -export function mockRuleDetails(overrides: Partial<T.RuleDetails> = {}): T.RuleDetails { +export function mockRuleDetails(overrides: Partial<RuleDetails> = {}): RuleDetails { return { key: 'squid:S1337', repo: 'squid', @@ -570,9 +601,7 @@ export function mockRuleDetails(overrides: Partial<T.RuleDetails> = {}): T.RuleD }; } -export function mockRuleDetailsParameter( - overrides: Partial<T.RuleParameter> = {} -): T.RuleParameter { +export function mockRuleDetailsParameter(overrides: Partial<RuleParameter> = {}): RuleParameter { return { defaultValue: '1', htmlDesc: 'description', @@ -582,9 +611,7 @@ export function mockRuleDetailsParameter( }; } -export function mockSourceViewerFile( - overrides: Partial<T.SourceViewerFile> = {} -): T.SourceViewerFile { +export function mockSourceViewerFile(overrides: Partial<SourceViewerFile> = {}): SourceViewerFile { return { key: 'foo', measures: { @@ -602,7 +629,7 @@ export function mockSourceViewerFile( }; } -export function mockStandaloneSysInfo(overrides: Partial<any> = {}): T.SysInfoStandalone { +export function mockStandaloneSysInfo(overrides: Partial<any> = {}): SysInfoStandalone { const baseInfo = mockBaseSysInfo(overrides); return { ...baseInfo, @@ -659,7 +686,7 @@ export function mockStore(state: any = {}, reducer = (state: any) => state): Sto return createStore(reducer, state); } -export function mockUser(overrides: Partial<T.User> = {}): T.User { +export function mockUser(overrides: Partial<User> = {}): User { return { active: true, local: true, @@ -705,7 +732,7 @@ export function mockDocumentationEntry( }; } -export function mockLanguage(overrides: Partial<T.Language> = {}): T.Language { +export function mockLanguage(overrides: Partial<Language> = {}): Language { return { key: 'css', name: 'CSS', @@ -713,7 +740,7 @@ export function mockLanguage(overrides: Partial<T.Language> = {}): T.Language { }; } -export function mockFlowLocation(overrides: Partial<T.FlowLocation> = {}): T.FlowLocation { +export function mockFlowLocation(overrides: Partial<FlowLocation> = {}): FlowLocation { return { component: 'main.js', textRange: { @@ -726,9 +753,7 @@ export function mockFlowLocation(overrides: Partial<T.FlowLocation> = {}): T.Flo }; } -export function mockIdentityProvider( - overrides: Partial<T.IdentityProvider> = {} -): T.IdentityProvider { +export function mockIdentityProvider(overrides: Partial<IdentityProvider> = {}): IdentityProvider { return { backgroundColor: '#000000', iconPath: '/path/icon.svg', @@ -749,7 +774,7 @@ export function mockRef( } as React.RefObject<HTMLElement>; } -export function mockPaging(overrides: Partial<T.Paging> = {}): T.Paging { +export function mockPaging(overrides: Partial<Paging> = {}): Paging { return { pageIndex: 1, pageSize: 100, diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts index ee616508baa..85816bd3e70 100644 --- a/server/sonar-web/src/main/js/helpers/urls.ts +++ b/server/sonar-web/src/main/js/helpers/urls.ts @@ -24,13 +24,14 @@ import { ComponentQualifier, isApplication, isPortfolioLike } from '../types/com import { MeasurePageView } from '../types/measures'; import { GraphType } from '../types/project-activity'; import { SecurityStandard } from '../types/security'; +import { Dict, HomePage } from '../types/types'; import { getBranchLikeQuery, isBranch, isMainBranch, isPullRequest } from './branch-like'; import { IS_SSR } from './browser'; import { getBaseUrl } from './system'; export interface Location { pathname: string; - query?: T.Dict<string | undefined | number>; + query?: Dict<string | undefined | number>; } type Query = Location['query']; @@ -246,7 +247,7 @@ export function getQualityGatesUrl(): Location { export function getGlobalSettingsUrl( category?: string, - query?: T.Dict<string | undefined | number> + query?: Dict<string | undefined | number> ): Location { return { pathname: '/admin/settings', @@ -296,7 +297,7 @@ export function getCodeUrl( }; } -export function getHomePageUrl(homepage: T.HomePage) { +export function getHomePageUrl(homepage: HomePage) { switch (homepage.type) { case 'APPLICATION': return homepage.branch diff --git a/server/sonar-web/src/main/js/helpers/users.ts b/server/sonar-web/src/main/js/helpers/users.ts index ca64aa53277..0bec8925c3f 100644 --- a/server/sonar-web/src/main/js/helpers/users.ts +++ b/server/sonar-web/src/main/js/helpers/users.ts @@ -1,3 +1,5 @@ +import { CurrentUser, LoggedInUser, UserActive, UserBase } from '../types/types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -17,17 +19,17 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -export function hasGlobalPermission(user: T.CurrentUser, permission: string): boolean { +export function hasGlobalPermission(user: CurrentUser, permission: string): boolean { if (!user.permissions) { return false; } return user.permissions.global.includes(permission); } -export function isLoggedIn(user: T.CurrentUser): user is T.LoggedInUser { +export function isLoggedIn(user: CurrentUser): user is LoggedInUser { return user.isLoggedIn; } -export function isUserActive(user: T.UserBase): user is T.UserActive { +export function isUserActive(user: UserBase): user is UserActive { return user.active !== false && Boolean(user.name); } diff --git a/server/sonar-web/src/main/js/store/__tests__/branches-test.ts b/server/sonar-web/src/main/js/store/__tests__/branches-test.ts index 9b71e91540f..497d597a581 100644 --- a/server/sonar-web/src/main/js/store/__tests__/branches-test.ts +++ b/server/sonar-web/src/main/js/store/__tests__/branches-test.ts @@ -22,13 +22,14 @@ import { mockBranch, mockPullRequest } from '../../helpers/mocks/branch-like'; import { mockQualityGateStatusCondition } from '../../helpers/mocks/quality-gates'; import { BranchLike } from '../../types/branch-like'; import { QualityGateStatusCondition } from '../../types/quality-gates'; +import { Status } from '../../types/types'; import reducer, { getBranchStatusByBranchLike, registerBranchStatusAction, State } from '../branches'; -type TestArgs = [BranchLike, string, T.Status, QualityGateStatusCondition[], boolean?]; +type TestArgs = [BranchLike, string, Status, QualityGateStatusCondition[], boolean?]; const FAILING_CONDITION = mockQualityGateStatusCondition(); const COMPONENT = 'foo'; diff --git a/server/sonar-web/src/main/js/store/__tests__/users-test.tsx b/server/sonar-web/src/main/js/store/__tests__/users-test.tsx index 2547c9aca88..0e4995bcfba 100644 --- a/server/sonar-web/src/main/js/store/__tests__/users-test.tsx +++ b/server/sonar-web/src/main/js/store/__tests__/users-test.tsx @@ -20,6 +20,7 @@ import { mockCurrentUser, mockLoggedInUser, mockUser } from '../../helpers/testMocks'; import { isLoggedIn } from '../../helpers/users'; +import { CurrentUserSetting, HomePage, LoggedInUser } from '../../types/types'; import reducer, { getCurrentUser, getCurrentUserSetting, @@ -42,39 +43,39 @@ describe('reducer and actions', () => { }); it('should allow to set the homepage', () => { - const homepage: T.HomePage = { type: 'PROJECTS' }; + const homepage: HomePage = { type: 'PROJECTS' }; const currentUser = mockLoggedInUser({ homepage: undefined }); const initialState: State = createState({ currentUser }); const newState = reducer(initialState, setHomePageAction(homepage)); expect(newState).toEqual( - createState({ currentUser: { ...currentUser, homepage } as T.LoggedInUser }) + createState({ currentUser: { ...currentUser, homepage } as LoggedInUser }) ); }); it('should allow to set a user setting', () => { - const setting1: T.CurrentUserSetting = { key: 'notifications.optOut', value: '1' }; - const setting2: T.CurrentUserSetting = { key: 'notifications.readDate', value: '2' }; - const setting3: T.CurrentUserSetting = { key: 'notifications.optOut', value: '2' }; + const setting1: CurrentUserSetting = { key: 'notifications.optOut', value: '1' }; + const setting2: CurrentUserSetting = { key: 'notifications.readDate', value: '2' }; + const setting3: CurrentUserSetting = { key: 'notifications.optOut', value: '2' }; const currentUser = mockLoggedInUser(); const initialState: State = createState({ currentUser }); const newState = reducer(initialState, setCurrentUserSettingAction(setting1)); expect(newState).toEqual( - createState({ currentUser: { ...currentUser, settings: [setting1] } as T.LoggedInUser }) + createState({ currentUser: { ...currentUser, settings: [setting1] } as LoggedInUser }) ); const newerState = reducer(newState, setCurrentUserSettingAction(setting2)); expect(newerState).toEqual( createState({ - currentUser: { ...currentUser, settings: [setting1, setting2] } as T.LoggedInUser + currentUser: { ...currentUser, settings: [setting1, setting2] } as LoggedInUser }) ); const newestState = reducer(newerState, setCurrentUserSettingAction(setting3)); expect(newestState).toEqual( createState({ - currentUser: { ...currentUser, settings: [setting3, setting2] } as T.LoggedInUser + currentUser: { ...currentUser, settings: [setting3, setting2] } as LoggedInUser }) ); }); diff --git a/server/sonar-web/src/main/js/store/appState.ts b/server/sonar-web/src/main/js/store/appState.ts index 2dda669acaa..01cf1a57979 100644 --- a/server/sonar-web/src/main/js/store/appState.ts +++ b/server/sonar-web/src/main/js/store/appState.ts @@ -17,6 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { AppState, Extension } from '../types/types'; import { ActionType } from './utils/actions'; export const enum Actions { @@ -30,11 +31,11 @@ export type Action = | ActionType<typeof setAdminPages, Actions.SetAdminPages> | ActionType<typeof requireAuthorization, Actions.RequireAuthorization>; -export function setAppState(appState: T.AppState) { +export function setAppState(appState: AppState) { return { type: Actions.SetAppState, appState }; } -export function setAdminPages(adminPages: T.Extension[]) { +export function setAdminPages(adminPages: Extension[]) { return { type: Actions.SetAdminPages, adminPages }; } @@ -42,7 +43,7 @@ export function requireAuthorization() { return { type: Actions.RequireAuthorization }; } -const defaultValue: T.AppState = { +const defaultValue: AppState = { authenticationError: false, authorizationError: false, edition: undefined, @@ -52,7 +53,7 @@ const defaultValue: T.AppState = { version: '' }; -export default function(state: T.AppState = defaultValue, action: Action): T.AppState { +export default function(state: AppState = defaultValue, action: Action): AppState { if (action.type === Actions.SetAppState) { return { ...state, ...action.appState }; } diff --git a/server/sonar-web/src/main/js/store/branches.ts b/server/sonar-web/src/main/js/store/branches.ts index baa8facef04..0acfbf7b6a2 100644 --- a/server/sonar-web/src/main/js/store/branches.ts +++ b/server/sonar-web/src/main/js/store/branches.ts @@ -20,16 +20,17 @@ import { getBranchLikeKey } from '../helpers/branch-like'; import { BranchLike } from '../types/branch-like'; import { QualityGateStatusCondition } from '../types/quality-gates'; +import { Dict, Status } from '../types/types'; import { ActionType } from './utils/actions'; export interface BranchStatusData { conditions?: QualityGateStatusCondition[]; ignoredConditions?: boolean; - status?: T.Status; + status?: Status; } export interface State { - byComponent: T.Dict<T.Dict<BranchStatusData>>; + byComponent: Dict<Dict<BranchStatusData>>; } const enum Actions { @@ -41,7 +42,7 @@ type Action = ActionType<typeof registerBranchStatusAction, Actions.RegisterBran export function registerBranchStatusAction( branchLike: BranchLike, component: string, - status: T.Status, + status: Status, conditions?: QualityGateStatusCondition[], ignoredConditions?: boolean ) { diff --git a/server/sonar-web/src/main/js/store/languages.ts b/server/sonar-web/src/main/js/store/languages.ts index 06a7a0b7051..d7f2e556141 100644 --- a/server/sonar-web/src/main/js/store/languages.ts +++ b/server/sonar-web/src/main/js/store/languages.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { keyBy } from 'lodash'; +import { Languages } from '../types/types'; import { ActionType } from './utils/actions'; export function receiveLanguages(languages: Array<{ key: string; name: string }>) { @@ -26,7 +27,7 @@ export function receiveLanguages(languages: Array<{ key: string; name: string }> type Action = ActionType<typeof receiveLanguages, 'RECEIVE_LANGUAGES'>; -export default function(state: T.Languages = {}, action: Action): T.Languages { +export default function(state: Languages = {}, action: Action): Languages { if (action.type === 'RECEIVE_LANGUAGES') { return keyBy(action.languages, 'key'); } @@ -34,10 +35,10 @@ export default function(state: T.Languages = {}, action: Action): T.Languages { return state; } -export function getLanguages(state: T.Languages) { +export function getLanguages(state: Languages) { return state; } -export function getLanguageByKey(state: T.Languages, key: string) { +export function getLanguageByKey(state: Languages, key: string) { return state[key]; } diff --git a/server/sonar-web/src/main/js/store/metrics.ts b/server/sonar-web/src/main/js/store/metrics.ts index f4024268ae4..615daddc787 100644 --- a/server/sonar-web/src/main/js/store/metrics.ts +++ b/server/sonar-web/src/main/js/store/metrics.ts @@ -19,15 +19,16 @@ */ import { keyBy } from 'lodash'; import { combineReducers } from 'redux'; +import { Dict, Metric } from '../types/types'; import { ActionType } from './utils/actions'; -export function receiveMetrics(metrics: T.Metric[]) { +export function receiveMetrics(metrics: Metric[]) { return { type: 'RECEIVE_METRICS', metrics }; } type Action = ActionType<typeof receiveMetrics, 'RECEIVE_METRICS'>; -export type State = { byKey: T.Dict<T.Metric>; keys: string[] }; +export type State = { byKey: Dict<Metric>; keys: string[] }; const byKey = (state: State['byKey'] = {}, action: Action) => { if (action.type === 'RECEIVE_METRICS') { diff --git a/server/sonar-web/src/main/js/store/rootActions.ts b/server/sonar-web/src/main/js/store/rootActions.ts index 5d802c4a96d..3a47ad4fac9 100644 --- a/server/sonar-web/src/main/js/store/rootActions.ts +++ b/server/sonar-web/src/main/js/store/rootActions.ts @@ -26,6 +26,7 @@ import { getQualityGateProjectStatus } from '../api/quality-gates'; import { getBranchLikeQuery } from '../helpers/branch-like'; import { extractStatusConditionsFromProjectStatus } from '../helpers/qualityGates'; import { BranchLike } from '../types/branch-like'; +import { Status } from '../types/types'; import { requireAuthorization as requireAuthorizationAction } from './appState'; import { registerBranchStatusAction } from './branches'; import { addGlobalErrorMessage } from './globalMessages'; @@ -103,7 +104,7 @@ export function requireAuthorization(router: Pick<InjectedRouter, 'replace'>) { return requireAuthorizationAction(); } -export function registerBranchStatus(branchLike: BranchLike, component: string, status: T.Status) { +export function registerBranchStatus(branchLike: BranchLike, component: string, status: Status) { return (dispatch: Dispatch) => { dispatch(registerBranchStatusAction(branchLike, component, status)); }; diff --git a/server/sonar-web/src/main/js/store/rootReducer.ts b/server/sonar-web/src/main/js/store/rootReducer.ts index 5ec1467a7f0..37db13aabab 100644 --- a/server/sonar-web/src/main/js/store/rootReducer.ts +++ b/server/sonar-web/src/main/js/store/rootReducer.ts @@ -20,6 +20,7 @@ import { combineReducers } from 'redux'; import settingsApp, * as fromSettingsApp from '../apps/settings/store/rootReducer'; import { BranchLike } from '../types/branch-like'; +import { AppState, CurrentUserSettingNames, Languages } from '../types/types'; import appState from './appState'; import branches, * as fromBranches from './branches'; import globalMessages, * as fromGlobalMessages from './globalMessages'; @@ -28,10 +29,10 @@ import metrics, * as fromMetrics from './metrics'; import users, * as fromUsers from './users'; export type Store = { - appState: T.AppState; + appState: AppState; branches: fromBranches.State; globalMessages: fromGlobalMessages.State; - languages: T.Languages; + languages: Languages; metrics: fromMetrics.State; users: fromUsers.State; @@ -63,7 +64,7 @@ export function getLanguages(state: Store) { return fromLanguages.getLanguages(state.languages); } -export function getCurrentUserSetting(state: Store, key: T.CurrentUserSettingNames) { +export function getCurrentUserSetting(state: Store, key: CurrentUserSettingNames) { return fromUsers.getCurrentUserSetting(state.users, key); } diff --git a/server/sonar-web/src/main/js/store/users.ts b/server/sonar-web/src/main/js/store/users.ts index e637a551f63..287a8a2fa62 100644 --- a/server/sonar-web/src/main/js/store/users.ts +++ b/server/sonar-web/src/main/js/store/users.ts @@ -21,6 +21,14 @@ import { uniq } from 'lodash'; import { combineReducers, Dispatch } from 'redux'; import * as api from '../api/users'; import { isLoggedIn } from '../helpers/users'; +import { + CurrentUser, + CurrentUserSetting, + CurrentUserSettingNames, + Dict, + HomePage, + LoggedInUser +} from '../types/types'; import { ActionType } from './utils/actions'; const enum Actions { @@ -37,20 +45,20 @@ type Action = | ActionType<typeof setSonarlintAd, Actions.SetSonarlintAd>; export interface State { - usersByLogin: T.Dict<any>; + usersByLogin: Dict<any>; userLogins: string[]; - currentUser: T.CurrentUser; + currentUser: CurrentUser; } -export function receiveCurrentUser(user: T.CurrentUser) { +export function receiveCurrentUser(user: CurrentUser) { return { type: Actions.ReceiveCurrentUser, user }; } -export function setHomePageAction(homepage: T.HomePage) { +export function setHomePageAction(homepage: HomePage) { return { type: Actions.SetHomePageAction, homepage }; } -export function setCurrentUserSettingAction(setting: T.CurrentUserSetting) { +export function setCurrentUserSettingAction(setting: CurrentUserSetting) { return { type: Actions.SetCurrentUserSetting, setting }; } @@ -58,7 +66,7 @@ export function setSonarlintAd() { return { type: Actions.SetSonarlintAd }; } -export function setHomePage(homepage: T.HomePage) { +export function setHomePage(homepage: HomePage) { return (dispatch: Dispatch) => { api.setHomePage(homepage).then( () => { @@ -69,7 +77,7 @@ export function setHomePage(homepage: T.HomePage) { }; } -export function setCurrentUserSetting(setting: T.CurrentUserSetting) { +export function setCurrentUserSetting(setting: CurrentUserSetting) { return (dispatch: Dispatch, getState: () => { users: State }) => { const oldSetting = getCurrentUserSetting(getState().users, setting.key); dispatch(setCurrentUserSettingAction(setting)); @@ -106,10 +114,10 @@ function currentUser( return action.user; } if (action.type === Actions.SetHomePageAction && isLoggedIn(state)) { - return { ...state, homepage: action.homepage } as T.LoggedInUser; + return { ...state, homepage: action.homepage } as LoggedInUser; } if (action.type === Actions.SetCurrentUserSetting && isLoggedIn(state)) { - let settings: T.CurrentUserSetting[]; + let settings: CurrentUserSetting[]; if (state.settings) { settings = [...state.settings]; const index = settings.findIndex(setting => setting.key === action.setting.key); @@ -121,10 +129,10 @@ function currentUser( } else { settings = [action.setting]; } - return { ...state, settings } as T.LoggedInUser; + return { ...state, settings } as LoggedInUser; } if (action.type === Actions.SetSonarlintAd && isLoggedIn(state)) { - return { ...state, sonarLintAdSeen: true } as T.LoggedInUser; + return { ...state, sonarLintAdSeen: true } as LoggedInUser; } return state; } @@ -135,7 +143,7 @@ export function getCurrentUser(state: State) { return state.currentUser; } -export function getCurrentUserSetting(state: State, key: T.CurrentUserSettingNames) { +export function getCurrentUserSetting(state: State, key: CurrentUserSettingNames) { let setting; if (isLoggedIn(state.currentUser) && state.currentUser.settings) { setting = state.currentUser.settings.find(setting => setting.key === key); diff --git a/server/sonar-web/src/main/js/store/utils/actions.ts b/server/sonar-web/src/main/js/store/utils/actions.ts index 8419e6de5ba..0a768a2a24e 100644 --- a/server/sonar-web/src/main/js/store/utils/actions.ts +++ b/server/sonar-web/src/main/js/store/utils/actions.ts @@ -19,4 +19,4 @@ */ type ActionCreator = (...args: any[]) => { type: string }; -export type ActionType<F extends ActionCreator, T> = T.Omit<ReturnType<F>, 'type'> & { type: T }; +export type ActionType<F extends ActionCreator, T> = Omit<ReturnType<F>, 'type'> & { type: T }; diff --git a/server/sonar-web/src/main/js/types/alm-integration.ts b/server/sonar-web/src/main/js/types/alm-integration.ts index cbd73502383..9f6e39ebd0d 100644 --- a/server/sonar-web/src/main/js/types/alm-integration.ts +++ b/server/sonar-web/src/main/js/types/alm-integration.ts @@ -1,3 +1,5 @@ +import { Dict } from './types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -52,7 +54,7 @@ export interface BitbucketCloudRepository { workspace: string; } -export type BitbucketProjectRepositories = T.Dict<{ +export type BitbucketProjectRepositories = Dict<{ allShown: boolean; repositories: BitbucketRepository[]; }>; diff --git a/server/sonar-web/src/main/js/types/branch-like.ts b/server/sonar-web/src/main/js/types/branch-like.ts index 3741e8b8000..418093b27a9 100644 --- a/server/sonar-web/src/main/js/types/branch-like.ts +++ b/server/sonar-web/src/main/js/types/branch-like.ts @@ -1,3 +1,5 @@ +import { NewCodePeriod, Status } from './types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -22,7 +24,7 @@ export interface Branch { excludedFromPurge: boolean; isMain: boolean; name: string; - status?: { qualityGateStatus: T.Status }; + status?: { qualityGateStatus: Status }; } export interface MainBranch extends Branch { @@ -35,7 +37,7 @@ export interface PullRequest { branch: string; key: string; isOrphan?: true; - status?: { qualityGateStatus: T.Status }; + status?: { qualityGateStatus: Status }; target: string; title: string; url?: string; @@ -58,5 +60,5 @@ export interface BranchLikeTree { export type BranchParameters = { branch?: string } | { pullRequest?: string }; export interface BranchWithNewCodePeriod extends Branch { - newCodePeriod?: T.NewCodePeriod; + newCodePeriod?: NewCodePeriod; } diff --git a/server/sonar-web/src/main/js/types/browser.ts b/server/sonar-web/src/main/js/types/browser.ts index 7757a3364f3..83e5898412c 100644 --- a/server/sonar-web/src/main/js/types/browser.ts +++ b/server/sonar-web/src/main/js/types/browser.ts @@ -19,10 +19,11 @@ */ import { ExtensionStartMethod } from './extension'; import { InstanceType } from './system'; +import { SysStatus } from './types'; export interface EnhancedWindow extends Window { baseUrl: string; - serverStatus: T.SysStatus; + serverStatus: SysStatus; instance: InstanceType; official: boolean; diff --git a/server/sonar-web/src/main/js/types/coding-rules.ts b/server/sonar-web/src/main/js/types/coding-rules.ts index 9ede5aebb51..c0d1597a2cc 100644 --- a/server/sonar-web/src/main/js/types/coding-rules.ts +++ b/server/sonar-web/src/main/js/types/coding-rules.ts @@ -1,3 +1,5 @@ +import { Dict, Rule, RuleActivation } from './types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -23,10 +25,10 @@ export interface GetRulesAppResponse { } export interface SearchRulesResponse { - actives?: T.Dict<T.RuleActivation[]>; + actives?: Dict<RuleActivation[]>; facets?: { property: string; values: { count: number; val: string }[] }[]; p: number; ps: number; - rules: T.Rule[]; + rules: Rule[]; total: number; } diff --git a/server/sonar-web/src/main/js/types/component.ts b/server/sonar-web/src/main/js/types/component.ts index 1e843536ee7..e6ffc524cb7 100644 --- a/server/sonar-web/src/main/js/types/component.ts +++ b/server/sonar-web/src/main/js/types/component.ts @@ -1,3 +1,5 @@ +import { LightComponent } from './types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -42,14 +44,14 @@ export enum ProjectKeyValidationResult { OnlyDigits = 'only_digits' } -export interface TreeComponent extends T.LightComponent { +export interface TreeComponent extends LightComponent { id?: string; name: string; path?: string; refId?: string; refKey?: string; tags?: string[]; - visibility: T.Visibility; + visibility: Visibility; } export interface TreeComponentWithPath extends TreeComponent { diff --git a/server/sonar-web/src/main/js/types/extension.ts b/server/sonar-web/src/main/js/types/extension.ts index 30630dd2fc3..c768bc9834b 100644 --- a/server/sonar-web/src/main/js/types/extension.ts +++ b/server/sonar-web/src/main/js/types/extension.ts @@ -22,6 +22,7 @@ import { Store as ReduxStore } from 'redux'; import { Location, Router } from '../components/hoc/withRouter'; import { Store } from '../store/rootReducer'; import { L10nBundle } from './l10n'; +import { CurrentUser, Dict } from './types'; export enum AdminPageExtension { GovernanceConsole = 'governance/views_console' @@ -39,17 +40,17 @@ export interface ExtensionStartMethod { export interface ExtensionStartMethodParameter { store: ReduxStore<Store, any>; el: HTMLElement | undefined | null; - currentUser: T.CurrentUser; + currentUser: CurrentUser; intl: IntlShape; location: Location; router: Router; theme: { - colors: T.Dict<string>; - sizes: T.Dict<string>; - rawSizes: T.Dict<number>; - fonts: T.Dict<string>; - zIndexes: T.Dict<string>; - others: T.Dict<string>; + colors: Dict<string>; + sizes: Dict<string>; + rawSizes: Dict<number>; + fonts: Dict<string>; + zIndexes: Dict<string>; + others: Dict<string>; }; baseUrl: string; l10nBundle: L10nBundle; diff --git a/server/sonar-web/src/main/js/types/issues.ts b/server/sonar-web/src/main/js/types/issues.ts index b7252e20dad..de5beae1a32 100644 --- a/server/sonar-web/src/main/js/types/issues.ts +++ b/server/sonar-web/src/main/js/types/issues.ts @@ -1,3 +1,5 @@ +import { FlowLocation, Issue, Paging, TextRange, UserBase } from './types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -45,7 +47,7 @@ export interface RawIssue { component: string; flows?: Array<{ // `componentName` is not available in RawIssue - locations?: Array<T.Omit<T.FlowLocation, 'componentName'>>; + locations?: Array<Omit<FlowLocation, 'componentName'>>; }>; key: string; line?: number; @@ -54,14 +56,14 @@ export interface RawIssue { severity: string; status: string; subProject?: string; - textRange?: T.TextRange; + textRange?: TextRange; } export interface IssueResponse { components?: Array<{ key: string; name: string }>; issue: RawIssue; rules?: Array<{}>; - users?: Array<T.UserBase>; + users?: Array<UserBase>; } export interface RawIssuesResponse { @@ -70,20 +72,20 @@ export interface RawIssuesResponse { facets: RawFacet[]; issues: RawIssue[]; languages: ReferencedLanguage[]; - paging: T.Paging; + paging: Paging; rules?: Array<{}>; - users?: Array<T.UserBase>; + users?: Array<UserBase>; } export interface FetchIssuesPromise { components: ReferencedComponent[]; effortTotal: number; facets: RawFacet[]; - issues: T.Issue[]; + issues: Issue[]; languages: ReferencedLanguage[]; - paging: T.Paging; + paging: Paging; rules: ReferencedRule[]; - users: T.UserBase[]; + users: UserBase[]; } export interface ReferencedComponent { diff --git a/server/sonar-web/src/main/js/types/l10n.ts b/server/sonar-web/src/main/js/types/l10n.ts index 11d5cbbf11f..b34fae733aa 100644 --- a/server/sonar-web/src/main/js/types/l10n.ts +++ b/server/sonar-web/src/main/js/types/l10n.ts @@ -1,3 +1,5 @@ +import { Dict } from './types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -24,11 +26,11 @@ export interface L10nBundleRequestParams { export interface L10nBundleRequestResponse { effectiveLocale: string; - messages: T.Dict<string>; + messages: Dict<string>; } export interface L10nBundle { timestamp?: string; locale?: string; - messages?: T.Dict<string>; + messages?: Dict<string>; } diff --git a/server/sonar-web/src/main/js/types/measures.ts b/server/sonar-web/src/main/js/types/measures.ts index cc48756a394..6d95de4c879 100644 --- a/server/sonar-web/src/main/js/types/measures.ts +++ b/server/sonar-web/src/main/js/types/measures.ts @@ -1,3 +1,5 @@ +import { ComponentMeasure, Metric, Period, PeriodMeasure } from './types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -20,18 +22,18 @@ export interface MeasuresForProjects { component: string; metric: string; - period?: T.PeriodMeasure; + period?: PeriodMeasure; value?: string; } export interface MeasuresAndMetaWithMetrics { - component: T.ComponentMeasure; - metrics: T.Metric[]; + component: ComponentMeasure; + metrics: Metric[]; } export interface MeasuresAndMetaWithPeriod { - component: T.ComponentMeasure; - period: T.Period; + component: ComponentMeasure; + period: Period; } export type MeasurePageView = 'list' | 'tree' | 'treemap'; diff --git a/server/sonar-web/src/main/js/types/quality-gates.ts b/server/sonar-web/src/main/js/types/quality-gates.ts index 1814b8fc89d..6edefb593af 100644 --- a/server/sonar-web/src/main/js/types/quality-gates.ts +++ b/server/sonar-web/src/main/js/types/quality-gates.ts @@ -18,11 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { BranchLike } from './branch-like'; +import { MeasureEnhanced, Metric, Status, UserBase } from './types'; export interface QualityGateProjectStatus { conditions?: QualityGateProjectStatusCondition[]; ignoredConditions: boolean; - status: T.Status; + status: Status; } export interface QualityGateProjectStatusCondition { @@ -31,13 +32,13 @@ export interface QualityGateProjectStatusCondition { errorThreshold: string; metricKey: string; periodIndex: number; - status: T.Status; + status: Status; } export interface QualityGateApplicationStatus { - metrics: T.Metric[]; + metrics: Metric[]; projects: QualityGateApplicationStatusChildProject[]; - status: T.Status; + status: Status; } export interface QualityGateApplicationStatusCondition { @@ -46,7 +47,7 @@ export interface QualityGateApplicationStatusCondition { metric: string; periodIndex?: number; onLeak?: boolean; - status: T.Status; + status: Status; value: string; warningThreshold?: string; } @@ -55,7 +56,7 @@ export interface QualityGateApplicationStatusChildProject { conditions: QualityGateApplicationStatusCondition[]; key: string; name: string; - status: T.Status; + status: Status; } export interface QualityGateStatus { @@ -63,14 +64,14 @@ export interface QualityGateStatus { ignoredConditions?: boolean; key: string; name: string; - status: T.Status; + status: Status; branchLike?: BranchLike; } export interface QualityGateStatusCondition { actual?: string; error?: string; - level: T.Status; + level: Status; metric: string; op: string; period?: number; @@ -78,7 +79,7 @@ export interface QualityGateStatusCondition { } export interface QualityGateStatusConditionEnhanced extends QualityGateStatusCondition { - measure: T.MeasureEnhanced; + measure: MeasureEnhanced; } export interface SearchPermissionsParameters { @@ -101,6 +102,6 @@ export interface Group { name: string; } -export function isUser(item: T.UserBase | Group): item is T.UserBase { - return item && (item as T.UserBase).login !== undefined; +export function isUser(item: UserBase | Group): item is UserBase { + return item && (item as UserBase).login !== undefined; } diff --git a/server/sonar-web/src/main/js/types/security-hotspots.ts b/server/sonar-web/src/main/js/types/security-hotspots.ts index 557f92ac3ec..581269468c1 100644 --- a/server/sonar-web/src/main/js/types/security-hotspots.ts +++ b/server/sonar-web/src/main/js/types/security-hotspots.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { ComponentQualifier } from './component'; +import { IssueChangelog, IssueChangelogDiff, Paging, TextRange, UserBase } from './types'; export enum RiskExposure { LOW = 'LOW', @@ -73,11 +74,11 @@ export interface RawHotspot { export interface Hotspot { assignee?: string; - assigneeUser?: T.UserBase; + assigneeUser?: UserBase; author: string; - authorUser: T.UserBase; + authorUser: UserBase; canChangeStatus: boolean; - changelog: T.IssueChangelog[]; + changelog: IssueChangelog[]; comment: HotspotComment[]; component: HotspotComponent; creationDate: string; @@ -88,9 +89,9 @@ export interface Hotspot { resolution?: HotspotResolution; rule: HotspotRule; status: HotspotStatus; - textRange?: T.TextRange; + textRange?: TextRange; updateDate: string; - users: T.UserBase[]; + users: UserBase[]; } export interface HotspotComponent { @@ -129,14 +130,14 @@ export interface HotspotComment { updatable: boolean; createdAt: string; login: string; - user: T.UserBase; + user: UserBase; } export interface ReviewHistoryElement { type: ReviewHistoryType; date: string; - user: Pick<T.UserBase, 'active' | 'avatar' | 'name'>; - diffs?: T.IssueChangelogDiff[]; + user: Pick<UserBase, 'active' | 'avatar' | 'name'>; + diffs?: IssueChangelogDiff[]; html?: string; key?: string; updatable?: boolean; @@ -152,7 +153,7 @@ export enum ReviewHistoryType { export interface HotspotSearchResponse { components?: { key: string; qualifier: string; name: string }[]; hotspots: RawHotspot[]; - paging: T.Paging; + paging: Paging; } export interface HotspotSetStatusRequest { diff --git a/server/sonar-web/src/main/js/types/security.ts b/server/sonar-web/src/main/js/types/security.ts index 152401d913d..a12cd3b3940 100644 --- a/server/sonar-web/src/main/js/types/security.ts +++ b/server/sonar-web/src/main/js/types/security.ts @@ -1,3 +1,5 @@ +import { Dict } from './types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -27,5 +29,5 @@ export enum SecurityStandard { export type StandardType = SecurityStandard; export type Standards = { - [key in StandardType]: T.Dict<{ title: string; description?: string }>; + [key in StandardType]: Dict<{ title: string; description?: string }>; }; diff --git a/server/sonar-web/src/main/js/types/settings.ts b/server/sonar-web/src/main/js/types/settings.ts index 2d50a443fe2..f47940461e9 100644 --- a/server/sonar-web/src/main/js/types/settings.ts +++ b/server/sonar-web/src/main/js/types/settings.ts @@ -1,3 +1,5 @@ +import { Dict } from './types'; + /* * SonarQube * Copyright (C) 2009-2021 SonarSource SA @@ -69,10 +71,10 @@ export interface SettingValueResponse { } export interface SettingValue { - fieldValues?: Array<T.Dict<string>>; + fieldValues?: Array<Dict<string>>; inherited?: boolean; key: string; - parentFieldValues?: Array<T.Dict<string>>; + parentFieldValues?: Array<Dict<string>>; parentValue?: string; parentValues?: string[]; value?: string; diff --git a/server/sonar-web/src/main/js/types/types.d.ts b/server/sonar-web/src/main/js/types/types.d.ts deleted file mode 100644 index b4700e156fb..00000000000 --- a/server/sonar-web/src/main/js/types/types.d.ts +++ /dev/null @@ -1,970 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -declare namespace T { - // Type ordered alphabetically to prevent merge conflicts - export type Dict<T> = { [key: string]: T }; - export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; - - export interface A11ySkipLink { - key: string; - label: string; - weight?: number; - } - - export interface AlmApplication extends IdentityProvider { - installationUrl: string; - } - - export interface AlmRepository { - label: string; - installationKey: string; - linkedProjectKey?: string; - linkedProjectName?: string; - private?: boolean; - } - - export interface AlmUnboundApplication { - installationId: string; - key: string; - name: string; - } - - interface BaseAnalysis { - buildString?: string; - detectedCI?: string; - events: AnalysisEvent[]; - key: string; - manualNewCodePeriodBaseline?: boolean; - projectVersion?: string; - } - - export interface Analysis extends BaseAnalysis { - date: string; - } - - export interface ParsedAnalysis extends BaseAnalysis { - date: Date; - } - - export interface AnalysisEvent { - category: string; - description?: string; - key: string; - name: string; - qualityGate?: { - failing: Array<{ branch: string; key: string; name: string }>; - status: string; - stillFailing: boolean; - }; - definitionChange?: { - projects: Array<{ - branch?: string; - changeType: string; - key: string; - name: string; - newBranch?: string; - oldBranch?: string; - }>; - }; - } - - export interface AppState { - adminPages?: Extension[]; - authenticationError?: boolean; - authorizationError?: boolean; - branchesEnabled?: boolean; - canAdmin?: boolean; - edition: 'community' | 'developer' | 'enterprise' | 'datacenter' | undefined; - globalPages?: Extension[]; - projectImportFeatureEnabled?: boolean; - instanceUsesDefaultAdminCredentials?: boolean; - multipleAlmEnabled?: boolean; - needIssueSync?: boolean; - productionDatabase: boolean; - qualifiers: string[]; - settings: T.Dict<string>; - standalone?: boolean; - version: string; - webAnalyticsJsPath?: string; - } - - export interface Breadcrumb { - key: string; - name: string; - qualifier: string; - } - - export namespace Chart { - export interface Point { - x: Date; - y: number | string | undefined; - } - - export interface Serie { - data: Point[]; - name: string; - translatedName: string; - type: string; - } - } - - export interface Component extends LightComponent { - alm?: { key: string; url: string }; - analysisDate?: string; - breadcrumbs: Breadcrumb[]; - canBrowseAllChildProjects?: boolean; - configuration?: ComponentConfiguration; - description?: string; - extensions?: Extension[]; - isFavorite?: boolean; - leakPeriodDate?: string; - name: string; - needIssueSync?: boolean; - path?: string; - refKey?: string; - qualityProfiles?: ComponentQualityProfile[]; - qualityGate?: { isDefault?: boolean; key: string; name: string }; - tags?: string[]; - version?: string; - visibility?: Visibility; - } - - interface ComponentConfiguration { - canApplyPermissionTemplate?: boolean; - canBrowseProject?: boolean; - canUpdateProjectVisibilityToPrivate?: boolean; - extensions?: Extension[]; - showBackgroundTasks?: boolean; - showHistory?: boolean; - showLinks?: boolean; - showQualityGates?: boolean; - showQualityProfiles?: boolean; - showPermissions?: boolean; - showSettings?: boolean; - showUpdateKey?: boolean; - } - - export interface ComponentQualityProfile { - deleted?: boolean; - key: string; - language: string; - name: string; - } - - export interface ComponentMeasureIntern { - branch?: string; - description?: string; - isFavorite?: boolean; - isRecentlyBrowsed?: boolean; - canBrowseAllChildProjects?: boolean; - key: string; - match?: string; - name: string; - path?: string; - project?: string; - qualifier: string; - refKey?: string; - } - - export interface ComponentMeasure extends ComponentMeasureIntern { - measures?: Measure[]; - } - - export interface ComponentMeasureEnhanced extends ComponentMeasureIntern { - value?: string; - leak?: string; - measures: MeasureEnhanced[]; - } - - export interface Condition { - error: string; - id: number; - metric: string; - op?: string; - } - - export interface CoveredFile { - key: string; - longName: string; - coveredLines: number; - } - - export interface Coupon { - billing?: { - address?: string; - country?: string; - email?: string; - name?: string; - use?: string; - }; - maxNcloc: number; - planActiveUntil: string; - } - - export interface CurrentUser { - isLoggedIn: boolean; - permissions?: { global: string[] }; - usingSonarLintConnectedMode?: boolean; - } - - export interface CurrentUserSetting { - key: CurrentUserSettingNames; - value: string; - } - - type CurrentUserSettingNames = - | 'notifications.optOut' - | 'notifications.readDate' - | 'tutorials.jenkins.skipBitbucketPreReqs'; - - export interface CustomMeasure { - createdAt?: string; - description?: string; - id: string; - metric: { - key: string; - name: string; - domain?: string; - type: string; - }; - projectKey: string; - pending?: boolean; - user: T.UserBase; - value: string; - updatedAt?: string; - } - - export interface Duplication { - blocks: DuplicationBlock[]; - } - - export interface DuplicationBlock { - _ref?: string; - from: number; - size: number; - } - - export interface DuplicatedFile { - key: string; - name: string; - project: string; - projectName: string; - subProject?: string; - subProjectName?: string; - } - - export type ExpandDirection = 'up' | 'down'; - - export interface Extension { - key: string; - name: string; - } - - export interface FacetValue<T = string> { - count: number; - val: T; - } - - export interface FlowLocation { - component: string; - componentName?: string; - index?: number; - msg?: string; - textRange: TextRange; - } - - export interface Group { - default?: boolean; - description?: string; - id: number; - membersCount: number; - name: string; - } - - export type HealthType = 'RED' | 'YELLOW' | 'GREEN'; - - export type HomePage = - | { type: 'APPLICATION'; branch: string | undefined; component: string } - | { type: 'ISSUES' } - | { type: 'MY_ISSUES' } - | { type: 'MY_PROJECTS' } - | { type: 'PORTFOLIO'; component: string } - | { type: 'PORTFOLIOS' } - | { type: 'PROJECT'; branch: string | undefined; component: string } - | { type: 'PROJECTS' }; - - export type HomePageType = - | 'APPLICATION' - | 'ISSUES' - | 'MY_ISSUES' - | 'MY_PROJECTS' - | 'PORTFOLIO' - | 'PORTFOLIOS' - | 'PROJECT' - | 'PROJECTS'; - - export interface IdentityProvider { - backgroundColor: string; - helpMessage?: string; - iconPath: string; - key: string; - name: string; - } - - export interface Issue { - actions: string[]; - assignee?: string; - assigneeActive?: boolean; - assigneeAvatar?: string; - assigneeLogin?: string; - assigneeName?: string; - author?: string; - branch?: string; - comments?: IssueComment[]; - component: string; - componentLongName: string; - componentQualifier: string; - componentUuid: string; - creationDate: string; - effort?: string; - externalRuleEngine?: string; - fromExternalRule?: boolean; - quickFixAvailable?: boolean; - key: string; - flows: FlowLocation[][]; - fromHotspot: boolean; - line?: number; - message: string; - project: string; - projectName: string; - projectKey: string; - pullRequest?: string; - resolution?: string; - rule: string; - ruleName: string; - ruleStatus?: string; - secondaryLocations: FlowLocation[]; - severity: string; - status: string; - subProject?: string; - subProjectName?: string; - tags?: string[]; - textRange?: TextRange; - transitions: string[]; - type: T.IssueType; - } - - export interface IssueChangelog { - avatar?: string; - creationDate: string; - diffs: IssueChangelogDiff[]; - user: string; - isUserActive: boolean; - userName: string; - } - - export interface IssueChangelogDiff { - key: string; - newValue?: string; - oldValue?: string; - } - - export interface IssueComment { - author?: string; - authorActive?: boolean; - authorAvatar?: string; - authorLogin?: string; - authorName?: string; - createdAt: string; - htmlText: string; - key: string; - markdown: string; - updatable: boolean; - } - - export interface IssuesByLine { - [key: number]: Issue[]; - } - - export type IssueType = 'BUG' | 'VULNERABILITY' | 'CODE_SMELL' | 'SECURITY_HOTSPOT'; - - export interface Language { - key: string; - name: string; - } - - export type Languages = T.Dict<Language>; - - export interface LightComponent { - key: string; - qualifier: string; - } - - export interface LinearIssueLocation { - from: number; - index?: number; - line: number; - startLine?: number; - text?: string; - to: number; - } - - export interface LineMap { - [line: number]: SourceLine; - } - - export interface LinePopup { - index?: number; - line: number; - name: string; - open?: boolean; - } - - export interface LoggedInUser extends CurrentUser, UserActive { - externalIdentity?: string; - externalProvider?: string; - groups: string[]; - homepage?: HomePage; - isLoggedIn: true; - local?: boolean; - scmAccounts: string[]; - settings?: CurrentUserSetting[]; - sonarLintAdSeen?: boolean; - } - - export interface Measure extends MeasureIntern { - metric: string; - } - - export interface MeasureEnhanced extends MeasureIntern { - metric: Metric; - leak?: string; - } - - interface MeasureIntern { - bestValue?: boolean; - period?: PeriodMeasure; - value?: string; - } - - export interface Metric { - bestValue?: string; - custom?: boolean; - decimalScale?: number; - description?: string; - direction?: number; - domain?: string; - hidden?: boolean; - higherValuesAreBetter?: boolean; - id: string; - key: string; - name: string; - qualitative?: boolean; - type: string; - worstValue?: string; - } - - export interface MyProject { - description?: string; - key: string; - lastAnalysisDate?: string; - links: Array<{ - name: string; - type: string; - href: string; - }>; - name: string; - qualityGate?: string; - } - - export interface NewCodePeriod { - type?: NewCodePeriodSettingType; - value?: string; - effectiveValue?: string; - inherited?: boolean; - } - - export interface NewCodePeriodBranch { - projectKey: string; - branchKey: string; - inherited?: boolean; - type?: NewCodePeriodSettingType; - value?: string; - effectiveValue?: string; - } - - export type NewCodePeriodSettingType = - | 'PREVIOUS_VERSION' - | 'NUMBER_OF_DAYS' - | 'SPECIFIC_ANALYSIS' - | 'REFERENCE_BRANCH'; - - export interface Notification { - channel: string; - project?: string; - projectName?: string; - type: string; - } - - export interface NotificationProject { - project: string; - projectName: string; - } - - export interface Paging { - pageIndex: number; - pageSize: number; - total: number; - } - - export interface Period { - date: string; - index?: number; - mode: PeriodMode | NewCodePeriodSettingType; - modeParam?: string; - parameter?: string; - } - - export interface PeriodMeasure { - bestValue?: boolean; - index: number; - value: string; - } - - /* - * These are old baseline setting types, necessary for - * backward compatibility. - */ - export type PeriodMode = - | 'days' - | 'date' - | 'version' - | 'previous_analysis' - | 'previous_version' - | 'manual_baseline'; - - export interface Permission { - description: string; - key: string; - name: string; - } - - export interface PermissionDefinition { - key: string; - name: string; - description: string; - } - - export type PermissionDefinitions = Array<PermissionDefinition | PermissionDefinitionGroup>; - - export interface PermissionDefinitionGroup { - category: string; - permissions: PermissionDefinition[]; - } - - export interface PermissionGroup { - description?: string; - id?: string; - name: string; - permissions: string[]; - } - - export interface PermissionUser extends UserActive { - permissions: string[]; - } - - export interface PermissionTemplate { - defaultFor: string[]; - id: string; - name: string; - description?: string; - projectKeyPattern?: string; - createdAt: string; - updatedAt?: string; - permissions: Array<{ - key: string; - usersCount: number; - groupsCount: number; - withProjectCreator?: boolean; - }>; - } - - export interface ProfileInheritanceDetails { - activeRuleCount: number; - isBuiltIn: boolean; - key: string; - name: string; - overridingRuleCount?: number; - } - - export interface ProjectLink { - id: string; - name?: string; - type: string; - url: string; - } - - export interface QualityGate { - actions?: { - associateProjects?: boolean; - copy?: boolean; - delegate?: boolean; - delete?: boolean; - manageConditions?: boolean; - rename?: boolean; - setAsDefault?: boolean; - }; - conditions?: Condition[]; - id: string; - isBuiltIn?: boolean; - isDefault?: boolean; - name: string; - } - - export type RawQuery = T.Dict<any>; - - export interface Rule { - isTemplate?: boolean; - key: string; - lang?: string; - langName?: string; - name: string; - params?: RuleParameter[]; - severity: string; - status: string; - sysTags?: string[]; - tags?: string[]; - type: RuleType; - } - - export interface RuleActivation { - createdAt: string; - inherit: RuleInheritance; - params: { key: string; value: string }[]; - qProfile: string; - severity: string; - } - - export interface RuleDetails extends Rule { - createdAt: string; - debtOverloaded?: boolean; - debtRemFnCoeff?: string; - debtRemFnOffset?: string; - debtRemFnType?: string; - defaultDebtRemFnOffset?: string; - defaultDebtRemFnType?: string; - defaultRemFnBaseEffort?: string; - defaultRemFnType?: string; - effortToFixDescription?: string; - htmlDesc?: string; - htmlNote?: string; - internalKey?: string; - isExternal?: boolean; - mdDesc?: string; - mdNote?: string; - remFnBaseEffort?: string; - remFnOverloaded?: boolean; - remFnType?: string; - repo: string; - scope?: RuleScope; - templateKey?: string; - } - - export type RuleInheritance = 'NONE' | 'INHERITED' | 'OVERRIDES'; - - export interface RuleParameter { - defaultValue?: string; - htmlDesc?: string; - key: string; - type: string; - } - - export type RuleScope = 'MAIN' | 'TEST' | 'ALL'; - - export type RuleType = 'BUG' | 'VULNERABILITY' | 'CODE_SMELL' | 'SECURITY_HOTSPOT' | 'UNKNOWN'; - - export interface Snippet { - start: number; - end: number; - index: number; - toDelete?: boolean; - } - - export interface SnippetGroup extends SnippetsByComponent { - locations: T.FlowLocation[]; - } - export interface SnippetsByComponent { - component: SourceViewerFile; - sources: { [line: number]: SourceLine }; - } - - export interface SourceLine { - code?: string; - conditions?: number; - coverageStatus?: SourceLineCoverageStatus; - coveredConditions?: number; - duplicated?: boolean; - isNew?: boolean; - line: number; - lineHits?: number; - scmAuthor?: string; - scmDate?: string; - scmRevision?: string; - } - - export type SourceLineCoverageStatus = 'uncovered' | 'partially-covered' | 'covered'; - - export interface SourceViewerFile { - fav?: boolean; - key: string; - leakPeriodDate?: string; - measures: { - coverage?: string; - duplicationDensity?: string; - issues?: string; - lines?: string; - tests?: string; - }; - path: string; - project: string; - projectName: string; - q: string; - subProject?: string; - subProjectName?: string; - uuid: string; - } - - export type StandardSecurityCategories = T.Dict<{ title: string; description?: string }>; - - export type Status = 'ERROR' | 'OK'; - - export interface SubscriptionPlan { - maxNcloc: number; - price: number; - } - - export interface SuggestionLink { - link: string; - scope?: 'sonarcloud'; - text: string; - } - - export interface SysInfoAppNode extends SysInfoBase { - 'Compute Engine Logging': SysInfoLogging; - Name: string; - 'Web Logging': SysInfoLogging; - } - - export interface SysInfoBase extends SysInfoValueObject { - Health: HealthType; - 'Health Causes': string[]; - Plugins?: Dict<string>; - System: { - Version: string; - }; - } - - export interface SysInfoCluster extends SysInfoBase { - 'Application Nodes': SysInfoAppNode[]; - 'Search Nodes': SysInfoSearchNode[]; - Settings: Dict<string>; - Statistics?: { - ncloc: number; - }; - System: { - 'High Availability': true; - 'Server ID': string; - Version: string; - }; - } - - export interface SysInfoLogging extends Dict<string> { - 'Logs Level': string; - } - - export interface SysInfoSearchNode extends SysInfoValueObject { - Name: string; - } - - export interface SysInfoSection extends Dict<SysInfoValueObject> {} - - export interface SysInfoStandalone extends SysInfoBase { - 'Compute Engine Logging': SysInfoLogging; - Settings: Dict<string>; - Statistics?: { - ncloc: number; - } & Dict<string | number>; - System: { - 'High Availability': false; - 'Server ID': string; - Version: string; - }; - 'Web Logging': SysInfoLogging; - } - - export type SysInfoValue = - | boolean - | string - | number - | undefined - | HealthType - | SysInfoValueObject - | SysInfoValueArray; - - export interface SysInfoValueArray extends Array<SysInfoValue> {} - - export interface SysInfoValueObject extends Dict<SysInfoValue> {} - - export type SysStatus = - | 'STARTING' - | 'UP' - | 'DOWN' - | 'RESTARTING' - | 'DB_MIGRATION_NEEDED' - | 'DB_MIGRATION_RUNNING'; - - export interface TestCase { - coveredLines: number; - durationInMs: number; - fileId: string; - fileKey: string; - fileName: string; - id: string; - message?: string; - name: string; - stacktrace?: string; - status: string; - } - - export interface TextRange { - startLine: number; - startOffset: number; - endLine: number; - endOffset: number; - } - - export interface User extends UserBase { - externalIdentity?: string; - externalProvider?: string; - groups?: string[]; - lastConnectionDate?: string; - local: boolean; - scmAccounts?: string[]; - tokensCount?: number; - } - - export interface UserActive extends UserBase { - active?: true; - name: string; - } - - export interface UserBase { - active?: boolean; - avatar?: string; - email?: string; - login: string; - name?: string; - } - - export interface UserSelected extends UserActive { - selected: boolean; - } - - export interface UserToken { - name: string; - createdAt: string; - lastConnectionDate?: string; - } - - export interface NewUserToken extends UserToken { - login: string; - token: string; - } - - export type Visibility = 'public' | 'private'; - - export interface Webhook { - key: string; - latestDelivery?: WebhookDelivery; - name: string; - secret?: string; - url: string; - } - - export interface WebhookDelivery { - at: string; - durationMs: number; - httpStatus?: number; - id: string; - success: boolean; - } - - export namespace WebApi { - export interface Action { - key: string; - changelog: Changelog[]; - description: string; - deprecatedSince?: string; - hasResponseExample: boolean; - internal: boolean; - params?: Param[]; - post: boolean; - since?: string; - } - - export interface Changelog { - description: string; - version: string; - } - - export interface Domain { - actions: Action[]; - deprecatedSince?: string; - description: string; - internal?: boolean; - path: string; - since?: string; - } - - export interface Example { - example: string; - format: string; - } - - export interface Param { - defaultValue?: string; - deprecatedKey?: string; - deprecatedKeySince?: string; - deprecatedSince?: string; - description: string; - exampleValue?: string; - internal: boolean; - key: string; - maximumLength?: number; - maximumValue?: number; - maxValuesAllowed?: number; - minimumLength?: number; - minimumValue?: number; - possibleValues?: string[]; - required: boolean; - since?: string; - } - } -} diff --git a/server/sonar-web/src/main/js/types/types.ts b/server/sonar-web/src/main/js/types/types.ts new file mode 100644 index 00000000000..d53d311dd44 --- /dev/null +++ b/server/sonar-web/src/main/js/types/types.ts @@ -0,0 +1,968 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +export type Dict<T> = { [key: string]: T }; +export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; + +export interface A11ySkipLink { + key: string; + label: string; + weight?: number; +} + +export interface AlmApplication extends IdentityProvider { + installationUrl: string; +} + +export interface AlmRepository { + label: string; + installationKey: string; + linkedProjectKey?: string; + linkedProjectName?: string; + private?: boolean; +} + +export interface AlmUnboundApplication { + installationId: string; + key: string; + name: string; +} + +interface BaseAnalysis { + buildString?: string; + detectedCI?: string; + events: AnalysisEvent[]; + key: string; + manualNewCodePeriodBaseline?: boolean; + projectVersion?: string; +} + +export interface Analysis extends BaseAnalysis { + date: string; +} + +export interface ParsedAnalysis extends BaseAnalysis { + date: Date; +} + +export interface AnalysisEvent { + category: string; + description?: string; + key: string; + name: string; + qualityGate?: { + failing: Array<{ branch: string; key: string; name: string }>; + status: string; + stillFailing: boolean; + }; + definitionChange?: { + projects: Array<{ + branch?: string; + changeType: string; + key: string; + name: string; + newBranch?: string; + oldBranch?: string; + }>; + }; +} + +export interface AppState { + adminPages?: Extension[]; + authenticationError?: boolean; + authorizationError?: boolean; + branchesEnabled?: boolean; + canAdmin?: boolean; + edition: 'community' | 'developer' | 'enterprise' | 'datacenter' | undefined; + globalPages?: Extension[]; + projectImportFeatureEnabled?: boolean; + instanceUsesDefaultAdminCredentials?: boolean; + multipleAlmEnabled?: boolean; + needIssueSync?: boolean; + productionDatabase: boolean; + qualifiers: string[]; + settings: Dict<string>; + standalone?: boolean; + version: string; + webAnalyticsJsPath?: string; +} + +export interface Breadcrumb { + key: string; + name: string; + qualifier: string; +} + +export namespace Chart { + export interface Point { + x: Date; + y: number | string | undefined; + } + + export interface Serie { + data: Point[]; + name: string; + translatedName: string; + type: string; + } +} + +export interface Component extends LightComponent { + alm?: { key: string; url: string }; + analysisDate?: string; + breadcrumbs: Breadcrumb[]; + canBrowseAllChildProjects?: boolean; + configuration?: ComponentConfiguration; + description?: string; + extensions?: Extension[]; + isFavorite?: boolean; + leakPeriodDate?: string; + name: string; + needIssueSync?: boolean; + path?: string; + refKey?: string; + qualityProfiles?: ComponentQualityProfile[]; + qualityGate?: { isDefault?: boolean; key: string; name: string }; + tags?: string[]; + version?: string; + visibility?: Visibility; +} + +interface ComponentConfiguration { + canApplyPermissionTemplate?: boolean; + canBrowseProject?: boolean; + canUpdateProjectVisibilityToPrivate?: boolean; + extensions?: Extension[]; + showBackgroundTasks?: boolean; + showHistory?: boolean; + showLinks?: boolean; + showQualityGates?: boolean; + showQualityProfiles?: boolean; + showPermissions?: boolean; + showSettings?: boolean; + showUpdateKey?: boolean; +} + +export interface ComponentQualityProfile { + deleted?: boolean; + key: string; + language: string; + name: string; +} + +export interface ComponentMeasureIntern { + branch?: string; + description?: string; + isFavorite?: boolean; + isRecentlyBrowsed?: boolean; + canBrowseAllChildProjects?: boolean; + key: string; + match?: string; + name: string; + path?: string; + project?: string; + qualifier: string; + refKey?: string; +} + +export interface ComponentMeasure extends ComponentMeasureIntern { + measures?: Measure[]; +} + +export interface ComponentMeasureEnhanced extends ComponentMeasureIntern { + value?: string; + leak?: string; + measures: MeasureEnhanced[]; +} + +export interface Condition { + error: string; + id: number; + metric: string; + op?: string; +} + +export interface CoveredFile { + key: string; + longName: string; + coveredLines: number; +} + +export interface Coupon { + billing?: { + address?: string; + country?: string; + email?: string; + name?: string; + use?: string; + }; + maxNcloc: number; + planActiveUntil: string; +} + +export interface CurrentUser { + isLoggedIn: boolean; + permissions?: { global: string[] }; + usingSonarLintConnectedMode?: boolean; +} + +export interface CurrentUserSetting { + key: CurrentUserSettingNames; + value: string; +} + +export type CurrentUserSettingNames = + | 'notifications.optOut' + | 'notifications.readDate' + | 'tutorials.jenkins.skipBitbucketPreReqs'; + +export interface CustomMeasure { + createdAt?: string; + description?: string; + id: string; + metric: { + key: string; + name: string; + domain?: string; + type: string; + }; + projectKey: string; + pending?: boolean; + user: UserBase; + value: string; + updatedAt?: string; +} + +export interface Duplication { + blocks: DuplicationBlock[]; +} + +export interface DuplicationBlock { + _ref?: string; + from: number; + size: number; +} + +export interface DuplicatedFile { + key: string; + name: string; + project: string; + projectName: string; + subProject?: string; + subProjectName?: string; +} + +export type ExpandDirection = 'up' | 'down'; + +export interface Extension { + key: string; + name: string; +} + +export interface FacetValue<T = string> { + count: number; + val: T; +} + +export interface FlowLocation { + component: string; + componentName?: string; + index?: number; + msg?: string; + textRange: TextRange; +} + +export interface Group { + default?: boolean; + description?: string; + id: number; + membersCount: number; + name: string; +} + +export type HealthType = 'RED' | 'YELLOW' | 'GREEN'; + +export type HomePage = + | { type: 'APPLICATION'; branch: string | undefined; component: string } + | { type: 'ISSUES' } + | { type: 'MY_ISSUES' } + | { type: 'MY_PROJECTS' } + | { type: 'PORTFOLIO'; component: string } + | { type: 'PORTFOLIOS' } + | { type: 'PROJECT'; branch: string | undefined; component: string } + | { type: 'PROJECTS' }; + +export type HomePageType = + | 'APPLICATION' + | 'ISSUES' + | 'MY_ISSUES' + | 'MY_PROJECTS' + | 'PORTFOLIO' + | 'PORTFOLIOS' + | 'PROJECT' + | 'PROJECTS'; + +export interface IdentityProvider { + backgroundColor: string; + helpMessage?: string; + iconPath: string; + key: string; + name: string; +} + +export interface Issue { + actions: string[]; + assignee?: string; + assigneeActive?: boolean; + assigneeAvatar?: string; + assigneeLogin?: string; + assigneeName?: string; + author?: string; + branch?: string; + comments?: IssueComment[]; + component: string; + componentLongName: string; + componentQualifier: string; + componentUuid: string; + creationDate: string; + effort?: string; + externalRuleEngine?: string; + fromExternalRule?: boolean; + quickFixAvailable?: boolean; + key: string; + flows: FlowLocation[][]; + fromHotspot: boolean; + line?: number; + message: string; + project: string; + projectName: string; + projectKey: string; + pullRequest?: string; + resolution?: string; + rule: string; + ruleName: string; + ruleStatus?: string; + secondaryLocations: FlowLocation[]; + severity: string; + status: string; + subProject?: string; + subProjectName?: string; + tags?: string[]; + textRange?: TextRange; + transitions: string[]; + type: IssueType; +} + +export interface IssueChangelog { + avatar?: string; + creationDate: string; + diffs: IssueChangelogDiff[]; + user: string; + isUserActive: boolean; + userName: string; +} + +export interface IssueChangelogDiff { + key: string; + newValue?: string; + oldValue?: string; +} + +export interface IssueComment { + author?: string; + authorActive?: boolean; + authorAvatar?: string; + authorLogin?: string; + authorName?: string; + createdAt: string; + htmlText: string; + key: string; + markdown: string; + updatable: boolean; +} + +export interface IssuesByLine { + [key: number]: Issue[]; +} + +export type IssueType = 'BUG' | 'VULNERABILITY' | 'CODE_SMELL' | 'SECURITY_HOTSPOT'; + +export interface Language { + key: string; + name: string; +} + +export type Languages = Dict<Language>; + +export interface LightComponent { + key: string; + qualifier: string; +} + +export interface LinearIssueLocation { + from: number; + index?: number; + line: number; + startLine?: number; + text?: string; + to: number; +} + +export interface LineMap { + [line: number]: SourceLine; +} + +export interface LinePopup { + index?: number; + line: number; + name: string; + open?: boolean; +} + +export interface LoggedInUser extends CurrentUser, UserActive { + externalIdentity?: string; + externalProvider?: string; + groups: string[]; + homepage?: HomePage; + isLoggedIn: true; + local?: boolean; + scmAccounts: string[]; + settings?: CurrentUserSetting[]; + sonarLintAdSeen?: boolean; +} + +export interface Measure extends MeasureIntern { + metric: string; +} + +export interface MeasureEnhanced extends MeasureIntern { + metric: Metric; + leak?: string; +} + +export interface MeasureIntern { + bestValue?: boolean; + period?: PeriodMeasure; + value?: string; +} + +export interface Metric { + bestValue?: string; + custom?: boolean; + decimalScale?: number; + description?: string; + direction?: number; + domain?: string; + hidden?: boolean; + higherValuesAreBetter?: boolean; + id: string; + key: string; + name: string; + qualitative?: boolean; + type: string; + worstValue?: string; +} + +export interface MyProject { + description?: string; + key: string; + lastAnalysisDate?: string; + links: Array<{ + name: string; + type: string; + href: string; + }>; + name: string; + qualityGate?: string; +} + +export interface NewCodePeriod { + type?: NewCodePeriodSettingType; + value?: string; + effectiveValue?: string; + inherited?: boolean; +} + +export interface NewCodePeriodBranch { + projectKey: string; + branchKey: string; + inherited?: boolean; + type?: NewCodePeriodSettingType; + value?: string; + effectiveValue?: string; +} + +export type NewCodePeriodSettingType = + | 'PREVIOUS_VERSION' + | 'NUMBER_OF_DAYS' + | 'SPECIFIC_ANALYSIS' + | 'REFERENCE_BRANCH'; + +export interface Notification { + channel: string; + project?: string; + projectName?: string; + type: string; +} + +export interface NotificationProject { + project: string; + projectName: string; +} + +export interface Paging { + pageIndex: number; + pageSize: number; + total: number; +} + +export interface Period { + date: string; + index?: number; + mode: PeriodMode | NewCodePeriodSettingType; + modeParam?: string; + parameter?: string; +} + +export interface PeriodMeasure { + bestValue?: boolean; + index: number; + value: string; +} + +/* + * These are old baseline setting types, necessary for + * backward compatibility. + */ +export type PeriodMode = + | 'days' + | 'date' + | 'version' + | 'previous_analysis' + | 'previous_version' + | 'manual_baseline'; + +export interface Permission { + description: string; + key: string; + name: string; +} + +export interface PermissionDefinition { + key: string; + name: string; + description: string; +} + +export type PermissionDefinitions = Array<PermissionDefinition | PermissionDefinitionGroup>; + +export interface PermissionDefinitionGroup { + category: string; + permissions: PermissionDefinition[]; +} + +export interface PermissionGroup { + description?: string; + id?: string; + name: string; + permissions: string[]; +} + +export interface PermissionUser extends UserActive { + permissions: string[]; +} + +export interface PermissionTemplate { + defaultFor: string[]; + id: string; + name: string; + description?: string; + projectKeyPattern?: string; + createdAt: string; + updatedAt?: string; + permissions: Array<{ + key: string; + usersCount: number; + groupsCount: number; + withProjectCreator?: boolean; + }>; +} + +export interface ProfileInheritanceDetails { + activeRuleCount: number; + isBuiltIn: boolean; + key: string; + name: string; + overridingRuleCount?: number; +} + +export interface ProjectLink { + id: string; + name?: string; + type: string; + url: string; +} + +export interface QualityGate { + actions?: { + associateProjects?: boolean; + copy?: boolean; + delegate?: boolean; + delete?: boolean; + manageConditions?: boolean; + rename?: boolean; + setAsDefault?: boolean; + }; + conditions?: Condition[]; + id: string; + isBuiltIn?: boolean; + isDefault?: boolean; + name: string; +} + +export type RawQuery = Dict<any>; + +export interface Rule { + isTemplate?: boolean; + key: string; + lang?: string; + langName?: string; + name: string; + params?: RuleParameter[]; + severity: string; + status: string; + sysTags?: string[]; + tags?: string[]; + type: RuleType; +} + +export interface RuleActivation { + createdAt: string; + inherit: RuleInheritance; + params: { key: string; value: string }[]; + qProfile: string; + severity: string; +} + +export interface RuleDetails extends Rule { + createdAt: string; + debtOverloaded?: boolean; + debtRemFnCoeff?: string; + debtRemFnOffset?: string; + debtRemFnType?: string; + defaultDebtRemFnOffset?: string; + defaultDebtRemFnType?: string; + defaultRemFnBaseEffort?: string; + defaultRemFnType?: string; + effortToFixDescription?: string; + htmlDesc?: string; + htmlNote?: string; + internalKey?: string; + isExternal?: boolean; + mdDesc?: string; + mdNote?: string; + remFnBaseEffort?: string; + remFnOverloaded?: boolean; + remFnType?: string; + repo: string; + scope?: RuleScope; + templateKey?: string; +} + +export type RuleInheritance = 'NONE' | 'INHERITED' | 'OVERRIDES'; + +export interface RuleParameter { + defaultValue?: string; + htmlDesc?: string; + key: string; + type: string; +} + +export type RuleScope = 'MAIN' | 'TEST' | 'ALL'; + +export type RuleType = 'BUG' | 'VULNERABILITY' | 'CODE_SMELL' | 'SECURITY_HOTSPOT' | 'UNKNOWN'; + +export interface Snippet { + start: number; + end: number; + index: number; + toDelete?: boolean; +} + +export interface SnippetGroup extends SnippetsByComponent { + locations: FlowLocation[]; +} +export interface SnippetsByComponent { + component: SourceViewerFile; + sources: { [line: number]: SourceLine }; +} + +export interface SourceLine { + code?: string; + conditions?: number; + coverageStatus?: SourceLineCoverageStatus; + coveredConditions?: number; + duplicated?: boolean; + isNew?: boolean; + line: number; + lineHits?: number; + scmAuthor?: string; + scmDate?: string; + scmRevision?: string; +} + +export type SourceLineCoverageStatus = 'uncovered' | 'partially-covered' | 'covered'; + +export interface SourceViewerFile { + fav?: boolean; + key: string; + leakPeriodDate?: string; + measures: { + coverage?: string; + duplicationDensity?: string; + issues?: string; + lines?: string; + tests?: string; + }; + path: string; + project: string; + projectName: string; + q: string; + subProject?: string; + subProjectName?: string; + uuid: string; +} + +export type StandardSecurityCategories = Dict<{ title: string; description?: string }>; + +export type Status = 'ERROR' | 'OK'; + +export interface SubscriptionPlan { + maxNcloc: number; + price: number; +} + +export interface SuggestionLink { + link: string; + scope?: 'sonarcloud'; + text: string; +} + +export interface SysInfoAppNode extends SysInfoBase { + 'Compute Engine Logging': SysInfoLogging; + Name: string; + 'Web Logging': SysInfoLogging; +} + +export interface SysInfoBase extends SysInfoValueObject { + Health: HealthType; + 'Health Causes': string[]; + Plugins?: Dict<string>; + System: { + Version: string; + }; +} + +export interface SysInfoCluster extends SysInfoBase { + 'Application Nodes': SysInfoAppNode[]; + 'Search Nodes': SysInfoSearchNode[]; + Settings: Dict<string>; + Statistics?: { + ncloc: number; + }; + System: { + 'High Availability': true; + 'Server ID': string; + Version: string; + }; +} + +export interface SysInfoLogging extends Dict<string> { + 'Logs Level': string; +} + +export interface SysInfoSearchNode extends SysInfoValueObject { + Name: string; +} + +export interface SysInfoSection extends Dict<SysInfoValueObject> {} + +export interface SysInfoStandalone extends SysInfoBase { + 'Compute Engine Logging': SysInfoLogging; + Settings: Dict<string>; + Statistics?: { + ncloc: number; + } & Dict<string | number>; + System: { + 'High Availability': false; + 'Server ID': string; + Version: string; + }; + 'Web Logging': SysInfoLogging; +} + +export type SysInfoValue = + | boolean + | string + | number + | undefined + | HealthType + | SysInfoValueObject + | SysInfoValueArray; + +export interface SysInfoValueArray extends Array<SysInfoValue> {} + +export interface SysInfoValueObject extends Dict<SysInfoValue> {} + +export type SysStatus = + | 'STARTING' + | 'UP' + | 'DOWN' + | 'RESTARTING' + | 'DB_MIGRATION_NEEDED' + | 'DB_MIGRATION_RUNNING'; + +export interface TestCase { + coveredLines: number; + durationInMs: number; + fileId: string; + fileKey: string; + fileName: string; + id: string; + message?: string; + name: string; + stacktrace?: string; + status: string; +} + +export interface TextRange { + startLine: number; + startOffset: number; + endLine: number; + endOffset: number; +} + +export interface User extends UserBase { + externalIdentity?: string; + externalProvider?: string; + groups?: string[]; + lastConnectionDate?: string; + local: boolean; + scmAccounts?: string[]; + tokensCount?: number; +} + +export interface UserActive extends UserBase { + active?: true; + name: string; +} + +export interface UserBase { + active?: boolean; + avatar?: string; + email?: string; + login: string; + name?: string; +} + +export interface UserSelected extends UserActive { + selected: boolean; +} + +export interface UserToken { + name: string; + createdAt: string; + lastConnectionDate?: string; +} + +export interface NewUserToken extends UserToken { + login: string; + token: string; +} + +export type Visibility = 'public' | 'private'; + +export interface Webhook { + key: string; + latestDelivery?: WebhookDelivery; + name: string; + secret?: string; + url: string; +} + +export interface WebhookDelivery { + at: string; + durationMs: number; + httpStatus?: number; + id: string; + success: boolean; +} + +export namespace WebApi { + export interface Action { + key: string; + changelog: Changelog[]; + description: string; + deprecatedSince?: string; + hasResponseExample: boolean; + internal: boolean; + params?: Param[]; + post: boolean; + since?: string; + } + + export interface Changelog { + description: string; + version: string; + } + + export interface Domain { + actions: Action[]; + deprecatedSince?: string; + description: string; + internal?: boolean; + path: string; + since?: string; + } + + export interface Example { + example: string; + format: string; + } + + export interface Param { + defaultValue?: string; + deprecatedKey?: string; + deprecatedKeySince?: string; + deprecatedSince?: string; + description: string; + exampleValue?: string; + internal: boolean; + key: string; + maximumLength?: number; + maximumValue?: number; + maxValuesAllowed?: number; + minimumLength?: number; + minimumValue?: number; + possibleValues?: string[]; + required: boolean; + since?: string; + } +} |