From dca8354af94e9feb46ea2312857e000aaa232372 Mon Sep 17 00:00:00 2001 From: philippe-perrin-sonarsource Date: Thu, 27 Jan 2022 11:06:59 +0100 Subject: [PATCH] SONAR-15945 Get rid of T namespace in sonar-web --- .../src/main/js/api/alm-integrations.ts | 5 +- .../sonar-web/src/main/js/api/components.ts | 44 +- server/sonar-web/src/main/js/api/issues.ts | 9 +- server/sonar-web/src/main/js/api/languages.ts | 3 +- server/sonar-web/src/main/js/api/measures.ts | 3 +- server/sonar-web/src/main/js/api/metrics.ts | 7 +- server/sonar-web/src/main/js/api/nav.ts | 3 +- .../src/main/js/api/newCodePeriod.ts | 7 +- .../src/main/js/api/notifications.ts | 3 +- .../sonar-web/src/main/js/api/permissions.ts | 21 +- .../src/main/js/api/projectActivity.ts | 3 +- .../sonar-web/src/main/js/api/projectLinks.ts | 5 +- .../src/main/js/api/quality-gates.ts | 21 +- .../src/main/js/api/quality-profiles.ts | 21 +- server/sonar-web/src/main/js/api/rules.ts | 7 +- .../src/main/js/api/security-hotspots.ts | 3 +- server/sonar-web/src/main/js/api/system.ts | 7 +- .../sonar-web/src/main/js/api/time-machine.ts | 3 +- .../sonar-web/src/main/js/api/user-tokens.ts | 5 +- .../sonar-web/src/main/js/api/user_groups.ts | 7 +- server/sonar-web/src/main/js/api/users.ts | 24 +- server/sonar-web/src/main/js/api/web-api.ts | 5 +- server/sonar-web/src/main/js/api/webhooks.ts | 11 +- .../main/js/app/components/AdminContainer.tsx | 7 +- .../main/js/app/components/AdminContext.tsx | 3 +- .../js/app/components/ComponentContainer.tsx | 25 +- .../js/app/components/ComponentContext.tsx | 3 +- .../src/main/js/app/components/Landing.tsx | 3 +- .../app/components/NonAdminPagesContainer.tsx | 3 +- .../js/app/components/PluginRiskConsent.tsx | 3 +- .../app/components/ProjectAdminContainer.tsx | 3 +- .../main/js/app/components/ResetPassword.tsx | 3 +- .../main/js/app/components/StartupModal.tsx | 3 +- .../__tests__/ComponentContainer-test.tsx | 3 +- .../app/components/__tests__/Landing-test.tsx | 3 +- .../__tests__/StartupModal-test.tsx | 3 +- .../js/app/components/a11y/A11yContext.tsx | 7 +- .../js/app/components/a11y/A11yProvider.tsx | 7 +- .../js/app/components/a11y/A11ySkipTarget.tsx | 7 +- .../embed-docs-modal/EmbedDocsPopup.tsx | 3 +- .../embed-docs-modal/SuggestionsContext.ts | 3 +- .../embed-docs-modal/SuggestionsProvider.tsx | 7 +- .../app/components/extensions/Extension.tsx | 7 +- .../extensions/GlobalAdminPageExtension.tsx | 3 +- .../extensions/GlobalPageExtension.tsx | 3 +- .../components/extensions/PortfolioPage.tsx | 3 +- .../extensions/ProjectAdminPageExtension.tsx | 3 +- .../extensions/ProjectPageExtension.tsx | 3 +- .../indexation/IndexationContextProvider.tsx | 3 +- .../indexation/IndexationNotification.tsx | 3 +- .../PageUnavailableDueToIndexation.tsx | 3 +- .../components/nav/component/Breadcrumb.tsx | 3 +- .../components/nav/component/ComponentNav.tsx | 5 +- .../nav/component/ComponentNavBgTaskNotif.tsx | 3 +- .../component/ComponentNavLicenseNotif.tsx | 3 +- .../ComponentNavProjectBindingErrorNotif.tsx | 3 +- .../app/components/nav/component/Header.tsx | 5 +- .../components/nav/component/HeaderMeta.tsx | 9 +- .../js/app/components/nav/component/Menu.tsx | 7 +- .../branch-like/BranchLikeNavigation.tsx | 5 +- .../branch-like/CurrentBranchLike.tsx | 3 +- .../nav/component/branch-like/Menu.tsx | 3 +- .../nav/component/branch-like/MenuItem.tsx | 3 +- .../component/branch-like/MenuItemList.tsx | 3 +- .../projectInformation/ProjectInformation.tsx | 9 +- .../ProjectInformationRenderer.tsx | 5 +- .../projectInformation/badges/BadgeParams.tsx | 3 +- .../badges/ProjectBadges.tsx | 5 +- .../badges/__tests__/BadgeParams-test.tsx | 5 +- .../projectInformation/meta/MetaLink.tsx | 3 +- .../projectInformation/meta/MetaLinks.tsx | 5 +- .../meta/MetaQualityProfiles.tsx | 11 +- .../projectInformation/meta/MetaSize.tsx | 5 +- .../projectInformation/meta/MetaTags.tsx | 3 +- .../notifications/ProjectNotifications.tsx | 3 +- .../app/components/nav/global/GlobalNav.tsx | 5 +- .../components/nav/global/GlobalNavMenu.tsx | 7 +- .../components/nav/global/GlobalNavUser.tsx | 5 +- .../settings/PendingPluginsActionNotif.tsx | 3 +- .../components/nav/settings/SettingsNav.tsx | 7 +- .../PromotionNotification.tsx | 3 +- .../main/js/app/components/search/Search.tsx | 7 +- .../js/app/components/search/SearchResult.tsx | 3 +- .../UpdateNotification.tsx | 9 +- server/sonar-web/src/main/js/app/index.ts | 3 +- .../src/main/js/app/utils/getStore.ts | 5 +- .../src/main/js/app/utils/startReactApp.tsx | 5 +- .../js/apps/account/components/Account.tsx | 5 +- .../js/apps/account/components/Security.tsx | 5 +- .../js/apps/account/components/UserCard.tsx | 3 +- .../notifications/GlobalNotifications.tsx | 7 +- .../notifications/NotificationsList.tsx | 7 +- .../account/notifications/ProjectModal.tsx | 13 +- .../notifications/ProjectNotifications.tsx | 9 +- .../apps/account/notifications/Projects.tsx | 21 +- .../notifications/SonarCloudNotifications.tsx | 3 +- .../main/js/apps/account/profile/Profile.tsx | 3 +- .../account/profile/UserExternalIdentity.tsx | 5 +- .../js/apps/account/projects/ProjectCard.tsx | 5 +- .../js/apps/account/projects/Projects.tsx | 3 +- .../account/projects/ProjectsContainer.tsx | 3 +- .../projects/__tests__/ProjectCard-test.tsx | 3 +- .../components/BackgroundTasksApp.tsx | 3 +- .../components/StatPendingTime.tsx | 3 +- .../background-tasks/components/Stats.tsx | 3 +- .../js/apps/code/__tests__/buckets-test.tsx | 7 +- .../sonar-web/src/main/js/apps/code/bucket.ts | 23 +- .../js/apps/code/components/Breadcrumbs.tsx | 5 +- .../main/js/apps/code/components/CodeApp.tsx | 25 +- .../js/apps/code/components/Component.tsx | 9 +- .../apps/code/components/ComponentMeasure.tsx | 5 +- .../js/apps/code/components/ComponentName.tsx | 9 +- .../js/apps/code/components/ComponentPin.tsx | 3 +- .../js/apps/code/components/Components.tsx | 11 +- .../apps/code/components/ComponentsHeader.tsx | 5 +- .../main/js/apps/code/components/Search.tsx | 5 +- .../code/components/SourceViewerWrapper.tsx | 5 +- .../sonar-web/src/main/js/apps/code/utils.ts | 19 +- .../components/ActivationButton.tsx | 5 +- .../components/ActivationFormModal.tsx | 11 +- .../js/apps/coding-rules/components/App.tsx | 35 +- .../coding-rules/components/BulkChange.tsx | 5 +- .../components/BulkChangeModal.tsx | 5 +- .../components/CustomRuleButton.tsx | 9 +- .../components/CustomRuleFormModal.tsx | 15 +- .../js/apps/coding-rules/components/Facet.tsx | 5 +- .../coding-rules/components/FacetsList.tsx | 5 +- .../components/InheritanceFacet.tsx | 7 +- .../coding-rules/components/PageActions.tsx | 3 +- .../coding-rules/components/ProfileFacet.tsx | 3 +- .../components/RepositoryFacet.tsx | 5 +- .../coding-rules/components/RuleDetails.tsx | 11 +- .../components/RuleDetailsCustomRules.tsx | 9 +- .../components/RuleDetailsDescription.tsx | 5 +- .../components/RuleDetailsIssues.tsx | 5 +- .../components/RuleDetailsMeta.tsx | 5 +- .../components/RuleDetailsParameters.tsx | 5 +- .../components/RuleDetailsProfiles.tsx | 22 +- .../components/RuleInheritanceIcon.tsx | 3 +- .../coding-rules/components/RuleListItem.tsx | 3 +- .../components/SimilarRulesFilter.tsx | 3 +- .../coding-rules/components/TemplateFacet.tsx | 2 +- .../components/__tests__/PageActions-test.tsx | 3 +- .../components/__tests__/RuleDetails-test.tsx | 3 +- .../__tests__/RuleDetailsDescription-test.tsx | 7 +- .../__tests__/RuleDetailsMeta-test.tsx | 7 +- .../src/main/js/apps/coding-rules/query.ts | 21 +- .../src/main/js/apps/coding-rules/routes.ts | 5 +- .../__tests__/utils-test.ts | 3 +- .../component-measures/components/App.tsx | 22 +- .../components/Breadcrumb.tsx | 5 +- .../components/Breadcrumbs.tsx | 9 +- .../components/LeakPeriodLegend.tsx | 5 +- .../components/MeasureContent.tsx | 43 +- .../components/MeasureHeader.tsx | 9 +- .../components/MeasureOverview.tsx | 28 +- .../components/MeasureOverviewContainer.tsx | 20 +- .../components/MeasureViewSelect.tsx | 3 +- .../__tests__/LeakPeriodLegend-test.tsx | 7 +- .../__tests__/MeasureHeader-test.tsx | 3 +- .../config/complementary.ts | 4 +- .../drilldown/BubbleChart.tsx | 33 +- .../drilldown/ComponentCell.tsx | 7 +- .../drilldown/ComponentsList.tsx | 11 +- .../drilldown/ComponentsListRow.tsx | 9 +- .../drilldown/FilesView.tsx | 25 +- .../drilldown/MeasureCell.tsx | 7 +- .../drilldown/TreeMapView.tsx | 17 +- .../sidebar/DomainFacet.tsx | 11 +- .../sidebar/FacetMeasureValue.tsx | 3 +- .../component-measures/sidebar/Sidebar.tsx | 7 +- .../main/js/apps/component-measures/utils.ts | 44 +- .../create/project/AzureProjectCreate.tsx | 7 +- .../project/AzureProjectCreateRenderer.tsx | 7 +- .../apps/create/project/AzureProjectsList.tsx | 7 +- .../project/BitbucketCloudProjectCreate.tsx | 3 +- .../project/CreateProjectModeSelection.tsx | 3 +- .../apps/create/project/CreateProjectPage.tsx | 5 +- .../create/project/GitHubProjectCreate.tsx | 3 +- .../project/GitHubProjectCreateRenderer.tsx | 3 +- .../create/project/GitlabProjectCreate.tsx | 3 +- .../project/GitlabProjectCreateRenderer.tsx | 3 +- .../project/GitlabProjectSelectionForm.tsx | 3 +- .../documentation/__tests__/pages-test.ts | 5 +- .../js/apps/documentation/components/App.tsx | 3 +- .../components/SearchResultEntry.tsx | 3 +- .../components/SearchResults.tsx | 4 +- .../src/main/js/apps/documentation/pages.ts | 5 +- .../main/js/apps/groups/components/App.tsx | 13 +- .../js/apps/groups/components/DeleteForm.tsx | 3 +- .../js/apps/groups/components/EditMembers.tsx | 3 +- .../groups/components/EditMembersModal.tsx | 5 +- .../main/js/apps/groups/components/Form.tsx | 3 +- .../main/js/apps/groups/components/List.tsx | 7 +- .../js/apps/groups/components/ListItem.tsx | 7 +- .../apps/issues/components/AppContainer.tsx | 3 +- .../issues/components/BulkChangeModal.tsx | 19 +- .../components/ComponentBreadcrumbs.tsx | 5 +- .../js/apps/issues/components/IssuesApp.tsx | 65 +- .../js/apps/issues/components/IssuesList.tsx | 9 +- .../issues/components/IssuesSourceViewer.tsx | 9 +- .../js/apps/issues/components/ListItem.tsx | 11 +- .../js/apps/issues/components/PageActions.tsx | 3 +- .../__tests__/BulkChangeModal-test.tsx | 7 +- .../components/__tests__/IssuesApp-test.tsx | 7 +- .../issues/conciseIssuesList/ConciseIssue.tsx | 5 +- .../conciseIssuesList/ConciseIssueBox.tsx | 3 +- .../ConciseIssueLocations.tsx | 3 +- .../ConciseIssueLocationsNavigator.tsx | 3 +- .../conciseIssuesList/ConciseIssuesList.tsx | 3 +- .../CrossFileLocationsNavigator.tsx | 11 +- .../__tests__/ConciseIssue-test.tsx | 3 +- .../ConciseIssueLocationsNavigator-test.tsx | 7 +- .../__tests__/ConciseIssuesList-test.tsx | 3 +- .../CrossFileLocationsNavigator-test.tsx | 7 +- .../ComponentSourceSnippetGroupViewer.tsx | 55 +- .../CrossComponentSourceViewerWrapper.tsx | 25 +- .../SnippetViewer.tsx | 47 +- ...ComponentSourceSnippetGroupViewer-test.tsx | 19 +- .../crossComponentSourceViewer/utils.ts | 43 +- .../src/main/js/apps/issues/redirects.ts | 3 +- .../js/apps/issues/sidebar/AssigneeFacet.tsx | 11 +- .../js/apps/issues/sidebar/AuthorFacet.tsx | 5 +- .../apps/issues/sidebar/CreationDateFacet.tsx | 5 +- .../js/apps/issues/sidebar/LanguageFacet.tsx | 5 +- .../js/apps/issues/sidebar/ProjectFacet.tsx | 9 +- .../apps/issues/sidebar/ResolutionFacet.tsx | 3 +- .../main/js/apps/issues/sidebar/RuleFacet.tsx | 11 +- .../js/apps/issues/sidebar/ScopeFacet.tsx | 3 +- .../js/apps/issues/sidebar/SeverityFacet.tsx | 3 +- .../main/js/apps/issues/sidebar/Sidebar.tsx | 21 +- .../js/apps/issues/sidebar/StandardFacet.tsx | 9 +- .../js/apps/issues/sidebar/StatusFacet.tsx | 3 +- .../main/js/apps/issues/sidebar/TagFacet.tsx | 5 +- .../main/js/apps/issues/sidebar/TypeFacet.tsx | 3 +- .../src/main/js/apps/issues/utils.ts | 31 +- .../main/js/apps/marketplace/AppContainer.tsx | 3 +- .../src/main/js/apps/marketplace/utils.ts | 5 +- .../apps/overview/branches/ActivityPanel.tsx | 7 +- .../js/apps/overview/branches/Analysis.tsx | 3 +- .../apps/overview/branches/BranchOverview.tsx | 16 +- .../branches/BranchOverviewRenderer.tsx | 11 +- .../js/apps/overview/branches/DebtValue.tsx | 5 +- .../branches/DrilldownMeasureValue.tsx | 5 +- .../main/js/apps/overview/branches/Event.tsx | 3 +- .../branches/FirstAnalysisNextStepsNotif.tsx | 5 +- .../apps/overview/branches/LeakPeriodInfo.tsx | 3 +- .../apps/overview/branches/MeasuresPanel.tsx | 7 +- .../branches/MeasuresPanelIssueMeasureRow.tsx | 5 +- .../branches/MeasuresPanelNoNewCode.tsx | 5 +- .../apps/overview/branches/NoCodeWarning.tsx | 5 +- .../branches/ProjectLeakPeriodInfo.tsx | 3 +- .../overview/branches/QualityGatePanel.tsx | 3 +- .../branches/QualityGatePanelSection.tsx | 3 +- .../branches/SecurityHotspotsReviewed.tsx | 3 +- .../__tests__/BranchOverview-test.tsx | 5 +- .../branches/__tests__/Event-test.tsx | 3 +- .../__tests__/ProjectLeakPeriodInfo-test.tsx | 3 +- .../main/js/apps/overview/components/App.tsx | 5 +- .../overview/components/EmptyOverview.tsx | 5 +- .../apps/overview/components/IssueLabel.tsx | 5 +- .../apps/overview/components/IssueRating.tsx | 5 +- .../overview/components/LeakPeriodLegend.tsx | 5 +- .../overview/components/MeasurementLabel.tsx | 5 +- .../components/QualityGateCondition.tsx | 11 +- .../components/QualityGateConditions.tsx | 3 +- .../components/SonarLintPromotion.tsx | 3 +- .../__tests__/LeakPeriodLegend-test.tsx | 3 +- .../pullRequests/AfterMergeEstimate.tsx | 3 +- .../pullRequests/LargeQualityGateBadge.tsx | 5 +- .../pullRequests/PullRequestOverview.tsx | 7 +- .../components/ActionsCell.tsx | 3 +- .../permission-templates/components/App.tsx | 5 +- .../components/Defaults.tsx | 3 +- .../components/DeleteForm.tsx | 3 +- .../permission-templates/components/Home.tsx | 5 +- .../permission-templates/components/List.tsx | 5 +- .../components/ListHeader.tsx | 5 +- .../components/ListItem.tsx | 3 +- .../components/NameCell.tsx | 3 +- .../components/Template.tsx | 13 +- .../components/TemplateDetails.tsx | 3 +- .../components/TemplateHeader.tsx | 3 +- .../components/__tests__/Defaults-test.tsx | 3 +- .../js/apps/permission-templates/utils.ts | 13 +- .../global/components/AllHoldersList.tsx | 15 +- .../permissions/global/components/App.tsx | 21 +- .../project/components/AllHoldersList.tsx | 23 +- .../permissions/project/components/App.tsx | 17 +- .../project/components/ApplyTemplate.tsx | 3 +- .../project/components/PageHeader.tsx | 3 +- .../shared/components/GroupHolder.tsx | 7 +- .../shared/components/HoldersList.tsx | 30 +- .../shared/components/PermissionCell.tsx | 10 +- .../shared/components/PermissionHeader.tsx | 3 +- .../shared/components/UserHolder.tsx | 7 +- .../src/main/js/apps/permissions/utils.ts | 11 +- .../main/js/apps/projectActivity/actions.ts | 5 +- .../components/DefinitionChangeEventInner.tsx | 7 +- .../apps/projectActivity/components/Event.tsx | 3 +- .../projectActivity/components/EventInner.tsx | 3 +- .../projectActivity/components/Events.tsx | 3 +- .../ProjectActivityAnalysesList.tsx | 7 +- .../components/ProjectActivityAnalysis.tsx | 3 +- .../components/ProjectActivityApp.tsx | 7 +- .../ProjectActivityAppContainer.tsx | 21 +- .../components/ProjectActivityGraphs.tsx | 5 +- .../components/ProjectActivityPageFooter.tsx | 3 +- .../components/ProjectActivityPageHeader.tsx | 3 +- .../components/RichQualityGateEventInner.tsx | 5 +- .../components/forms/AddEventForm.tsx | 3 +- .../components/forms/ChangeEventForm.tsx | 3 +- .../components/forms/RemoveAnalysisForm.tsx | 3 +- .../components/forms/RemoveEventForm.tsx | 3 +- .../src/main/js/apps/projectActivity/utils.ts | 11 +- .../apps/projectBaseline/components/App.tsx | 24 +- .../components/BaselineSettingAnalysis.tsx | 3 +- .../components/BaselineSettingDays.tsx | 3 +- .../BaselineSettingPreviousVersion.tsx | 3 +- .../BaselineSettingReferenceBranch.tsx | 3 +- .../components/BranchAnalysisList.tsx | 11 +- .../components/BranchAnalysisListRenderer.tsx | 9 +- .../components/BranchBaselineSettingModal.tsx | 11 +- .../projectBaseline/components/BranchList.tsx | 9 +- .../components/BranchListRow.tsx | 7 +- .../components/ProjectBaselineSelector.tsx | 13 +- .../src/main/js/apps/projectBaseline/utils.ts | 8 +- .../apps/projectBranches/components/App.tsx | 3 +- .../components/BranchLikeRow.tsx | 3 +- .../components/BranchLikeTable.tsx | 3 +- .../components/BranchLikeTabs.tsx | 3 +- .../components/BranchPurgeSetting.tsx | 3 +- .../components/DeleteBranchModal.tsx | 3 +- .../components/RenameBranchModal.tsx | 3 +- .../src/main/js/apps/projectDeletion/App.tsx | 3 +- .../src/main/js/apps/projectDeletion/Form.tsx | 3 +- .../main/js/apps/projectDeletion/Header.tsx | 3 +- .../js/apps/projectDump/ProjectDumpApp.tsx | 5 +- .../src/main/js/apps/projectKey/Key.tsx | 3 +- .../main/js/apps/projectKey/UpdateForm.tsx | 3 +- .../src/main/js/apps/projectLinks/App.tsx | 5 +- .../src/main/js/apps/projectLinks/LinkRow.tsx | 9 +- .../src/main/js/apps/projectLinks/Table.tsx | 3 +- .../ProjectQualityGateApp.tsx | 9 +- .../ProjectQualityGateAppRenderer.tsx | 7 +- .../ProjectQualityProfilesApp.tsx | 3 +- .../ProjectQualityProfilesAppRenderer.tsx | 3 +- .../components/AddLanguageModal.tsx | 5 +- .../components/SetQualityProfileModal.tsx | 3 +- .../apps/projects/components/AllProjects.tsx | 5 +- .../components/ApplicationCreation.tsx | 5 +- .../components/DefaultPageSelector.tsx | 3 +- .../projects/components/EmptyInstance.tsx | 3 +- .../projects/components/FavoriteFilter.tsx | 5 +- .../apps/projects/components/PageHeader.tsx | 7 +- .../apps/projects/components/PageSidebar.tsx | 7 +- .../components/ProjectCreationMenu.tsx | 3 +- .../apps/projects/components/ProjectsList.tsx | 3 +- .../components/__tests__/AllProjects-test.tsx | 3 +- .../__tests__/DefaultPageSelector-test.tsx | 3 +- .../components/project-card/ProjectCard.tsx | 3 +- .../project-card/ProjectCardLanguages.tsx | 5 +- .../project-card/ProjectCardMeasures.tsx | 3 +- .../__tests__/ProjectCard-test.tsx | 3 +- .../__tests__/ProjectCardMeasures-test.tsx | 3 +- .../apps/projects/filters/CoverageFilter.tsx | 3 +- .../projects/filters/DuplicationsFilter.tsx | 3 +- .../main/js/apps/projects/filters/Filter.tsx | 3 +- .../js/apps/projects/filters/IssuesFilter.tsx | 3 +- .../apps/projects/filters/LanguagesFilter.tsx | 7 +- .../filters/MaintainabilityFilter.tsx | 3 +- .../apps/projects/filters/NewLinesFilter.tsx | 3 +- .../filters/NewMaintainabilityFilter.tsx | 3 +- .../projects/filters/NewReliabilityFilter.tsx | 3 +- .../projects/filters/NewSecurityFilter.tsx | 3 +- .../apps/projects/filters/QualifierFilter.tsx | 3 +- .../projects/filters/QualityGateFilter.tsx | 3 +- .../projects/filters/ReliabilityFilter.tsx | 3 +- .../filters/SearchableFilterFooter.tsx | 5 +- .../apps/projects/filters/SecurityFilter.tsx | 3 +- .../projects/filters/SecurityReviewFilter.tsx | 5 +- .../js/apps/projects/filters/SizeFilter.tsx | 3 +- .../js/apps/projects/filters/TagsFilter.tsx | 5 +- .../src/main/js/apps/projects/query.ts | 5 +- .../src/main/js/apps/projects/types.ts | 5 +- .../src/main/js/apps/projects/utils.ts | 13 +- .../visualizations/Visualizations.tsx | 3 +- .../main/js/apps/projectsManagement/App.tsx | 17 +- .../BulkApplyTemplateModal.tsx | 3 +- .../ChangeDefaultVisibilityForm.tsx | 9 +- .../projectsManagement/CreateProjectForm.tsx | 7 +- .../js/apps/projectsManagement/Header.tsx | 5 +- .../js/apps/projectsManagement/ProjectRow.tsx | 3 +- .../projectsManagement/ProjectRowActions.tsx | 3 +- .../js/apps/projectsManagement/Projects.tsx | 3 +- .../projectsManagement/RestoreAccessModal.tsx | 3 +- .../js/apps/projectsManagement/Search.tsx | 3 +- .../js/apps/quality-gates/components/App.tsx | 7 +- .../quality-gates/components/Condition.tsx | 15 +- .../components/ConditionModal.tsx | 19 +- .../components/ConditionOperator.tsx | 5 +- .../quality-gates/components/Conditions.tsx | 25 +- .../components/CopyQualityGateForm.tsx | 3 +- .../components/DeleteQualityGateForm.tsx | 3 +- .../apps/quality-gates/components/Details.tsx | 17 +- .../components/DetailsContent.tsx | 11 +- .../components/DetailsHeader.tsx | 3 +- .../js/apps/quality-gates/components/List.tsx | 3 +- .../quality-gates/components/MetricSelect.tsx | 7 +- .../components/PermissionItem.tsx | 5 +- .../quality-gates/components/Projects.tsx | 3 +- .../components/QualityGatePermissions.tsx | 13 +- .../QualityGatePermissionsAddModal.tsx | 11 +- ...QualityGatePermissionsAddModalRenderer.tsx | 9 +- .../QualityGatePermissionsRenderer.tsx | 13 +- .../components/RenameQualityGateForm.tsx | 3 +- .../components/ThresholdInput.tsx | 3 +- .../src/main/js/apps/quality-gates/utils.ts | 21 +- .../changelog/ChangesList.tsx | 3 +- .../compare/ComparisonResultActivation.tsx | 5 +- .../compare/ComparisonResults.tsx | 3 +- .../apps/quality-profiles/components/App.tsx | 3 +- .../details/ProfileInheritance.tsx | 7 +- .../details/ProfileInheritanceBox.tsx | 3 +- .../details/ProfilePermissions.tsx | 11 +- .../details/ProfilePermissionsForm.tsx | 13 +- .../details/ProfilePermissionsFormSelect.tsx | 7 +- .../details/ProfilePermissionsUser.tsx | 5 +- .../quality-profiles/details/ProfileRules.tsx | 5 +- .../__tests__/ProfilePermissionsForm-test.tsx | 3 +- .../__tests__/ProfilePermissionsUser-test.tsx | 3 +- .../quality-profiles/home/EvolutionRules.tsx | 5 +- .../quality-profiles/home/ProfilesList.tsx | 8 +- .../main/js/apps/quality-profiles/types.ts | 3 +- .../security-hotspots/SecurityHotspotsApp.tsx | 7 +- .../SecurityHotspotsAppRenderer.tsx | 5 +- .../security-hotspots/__tests__/utils-test.ts | 3 +- .../components/FilterBar.tsx | 5 +- .../components/HotspotList.tsx | 7 +- .../HotspotReviewHistoryAndComments.tsx | 3 +- .../components/HotspotSnippetContainer.tsx | 11 +- .../HotspotSnippetContainerRenderer.tsx | 14 +- .../components/HotspotViewer.tsx | 5 +- .../components/HotspotViewerRenderer.tsx | 7 +- .../components/assignee/Assignee.tsx | 5 +- .../components/assignee/AssigneeRenderer.tsx | 7 +- .../components/assignee/AssigneeSelection.tsx | 13 +- .../assignee/AssigneeSelectionRenderer.tsx | 7 +- .../assignee/__tests__/Assignee-test.tsx | 7 +- .../__tests__/AssigneeRenderer-test.tsx | 3 +- .../__tests__/AssigneeSelection-test.tsx | 7 +- .../AssigneeSelectionRenderer-test.tsx | 7 +- .../components/status/Status.tsx | 3 +- .../main/js/apps/security-hotspots/utils.ts | 16 +- .../js/apps/sessions/components/Login.tsx | 3 +- .../sessions/components/LoginContainer.tsx | 3 +- .../sessions/components/OAuthProviders.tsx | 5 +- .../components/AdditionalCategories.tsx | 3 +- .../settings/components/AllCategoriesList.tsx | 3 +- .../components/CategoryDefinitionsList.tsx | 3 +- .../settings/components/CategoryOverrides.ts | 3 +- .../apps/settings/components/Definition.tsx | 3 +- .../settings/components/DefinitionsList.tsx | 3 +- .../js/apps/settings/components/EmailForm.tsx | 3 +- .../settings/components/NewCodePeriod.tsx | 7 +- .../apps/settings/components/PageHeader.tsx | 3 +- .../apps/settings/components/SettingsApp.tsx | 3 +- .../settings/components/SettingsSearch.tsx | 5 +- .../components/SettingsSearchRenderer.tsx | 3 +- .../components/SubCategoryDefinitionsList.tsx | 3 +- .../almIntegration/AlmIntegration.tsx | 5 +- .../almIntegration/AlmIntegrationRenderer.tsx | 3 +- .../components/almIntegration/AlmTab.tsx | 3 +- .../almIntegration/AlmTabRenderer.tsx | 3 +- .../almIntegration/CreationTooltip.tsx | 3 +- .../AlmSpecificForm.tsx | 5 +- .../PRDecorationBinding.tsx | 11 +- .../PRDecorationBindingRenderer.tsx | 2 +- .../js/apps/settings/store/definitions.ts | 3 +- .../js/apps/settings/store/settingsPage.ts | 7 +- .../src/main/js/apps/settings/store/values.ts | 5 +- .../src/main/js/apps/settings/utils.ts | 7 +- .../js/apps/system/__tests__/utils-test.ts | 7 +- .../main/js/apps/system/components/App.tsx | 3 +- .../system/components/ClusterSysInfos.tsx | 7 +- .../system/components/StandaloneSysInfos.tsx | 3 +- .../components/info-items/HealthCard.tsx | 5 +- .../components/info-items/HealthCauseItem.tsx | 3 +- .../components/info-items/HealthItem.tsx | 3 +- .../system/components/info-items/Section.tsx | 3 +- .../components/info-items/SysInfoItem.tsx | 5 +- .../src/main/js/apps/system/utils.ts | 75 +- .../tutorials/components/TutorialsApp.tsx | 5 +- .../src/main/js/apps/users/UsersApp.tsx | 7 +- .../src/main/js/apps/users/UsersList.tsx | 5 +- .../apps/users/components/DeactivateForm.tsx | 3 +- .../js/apps/users/components/GroupsForm.tsx | 3 +- .../js/apps/users/components/PasswordForm.tsx | 3 +- .../js/apps/users/components/TokensForm.tsx | 5 +- .../apps/users/components/TokensFormItem.tsx | 5 +- .../apps/users/components/TokensFormModal.tsx | 3 +- .../js/apps/users/components/UserActions.tsx | 3 +- .../js/apps/users/components/UserForm.tsx | 3 +- .../js/apps/users/components/UserGroups.tsx | 3 +- .../js/apps/users/components/UserListItem.tsx | 5 +- .../users/components/UserListItemIdentity.tsx | 5 +- .../__tests__/TokensFormItem-test.tsx | 3 +- .../__tests__/UserListItem-test.tsx | 3 +- .../sonar-web/src/main/js/apps/users/utils.ts | 5 +- .../js/apps/web-api/components/Action.tsx | 5 +- .../web-api/components/ActionChangelog.tsx | 3 +- .../js/apps/web-api/components/Domain.tsx | 3 +- .../main/js/apps/web-api/components/Menu.tsx | 5 +- .../js/apps/web-api/components/Params.tsx | 7 +- .../web-api/components/ResponseExample.tsx | 7 +- .../js/apps/web-api/components/WebApiApp.tsx | 7 +- .../components/__tests__/Menu-test.tsx | 19 +- .../components/__tests__/Params-test.tsx | 5 +- .../src/main/js/apps/web-api/utils.ts | 7 +- .../main/js/apps/webhooks/components/App.tsx | 5 +- .../webhooks/components/CreateWebhookForm.tsx | 3 +- .../webhooks/components/DeleteWebhookForm.tsx | 3 +- .../webhooks/components/DeliveriesForm.tsx | 7 +- .../webhooks/components/DeliveryAccordion.tsx | 3 +- .../apps/webhooks/components/DeliveryItem.tsx | 3 +- .../components/LatestDeliveryForm.tsx | 5 +- .../webhooks/components/WebhookActions.tsx | 3 +- .../apps/webhooks/components/WebhookItem.tsx | 3 +- .../components/WebhookItemLatestDelivery.tsx | 3 +- .../apps/webhooks/components/WebhooksList.tsx | 3 +- .../SourceViewer/SourceViewerBase.tsx | 61 +- .../SourceViewer/SourceViewerCode.tsx | 35 +- .../SourceViewer/SourceViewerContext.tsx | 5 +- .../SourceViewer/SourceViewerHeader.tsx | 7 +- .../SourceViewer/SourceViewerHeaderSlim.tsx | 3 +- .../__tests__/SourceViewerHeader-test.tsx | 3 +- .../components/DuplicationPopup.tsx | 9 +- .../SourceViewer/components/Line.tsx | 19 +- .../SourceViewer/components/LineCode.tsx | 11 +- .../SourceViewer/components/LineCoverage.tsx | 5 +- .../components/LineDuplicationBlock.tsx | 5 +- .../components/LineIssuesIndicator.tsx | 5 +- .../components/LineIssuesList.tsx | 5 +- .../SourceViewer/components/LineNumber.tsx | 3 +- .../components/LineOptionsPopup.tsx | 3 +- .../SourceViewer/components/LineSCM.tsx | 7 +- .../components/MeasuresOverlay.tsx | 22 +- .../components/MeasuresOverlayMeasure.tsx | 3 +- .../SourceViewer/components/SCMPopup.tsx | 3 +- .../__tests__/LineIssuesList-test.tsx | 5 +- .../__tests__/MeasuresOverlay-test.tsx | 3 +- .../SourceViewer/helpers/duplications.ts | 9 +- .../SourceViewer/helpers/getCoverageStatus.ts | 6 +- .../SourceViewer/helpers/highlight.ts | 3 +- .../SourceViewer/helpers/indexing.ts | 19 +- .../SourceViewer/helpers/issueLocations.ts | 12 +- .../components/SourceViewer/helpers/lines.ts | 5 +- .../SourceViewer/helpers/loadIssues.ts | 13 +- .../activity-graph/AddGraphMetric.tsx | 5 +- .../activity-graph/GraphHistory.tsx | 3 +- .../activity-graph/GraphsHeader.tsx | 3 +- .../activity-graph/GraphsHistory.tsx | 3 +- .../activity-graph/GraphsTooltips.tsx | 3 +- .../GraphsTooltipsContentEvents.tsx | 3 +- .../GraphsTooltipsContentIssues.tsx | 3 +- .../js/components/activity-graph/utils.ts | 9 +- .../js/components/charts/AdvancedTimeline.tsx | 17 +- .../charts/LanguageDistribution.tsx | 3 +- .../src/main/js/components/charts/TreeMap.tsx | 7 +- .../js/components/charts/ZoomTimeLine.tsx | 11 +- .../__tests__/AdvancedTimeline-test.tsx | 3 +- .../charts/__tests__/BubbleChart-test.tsx | 5 +- .../common/AnalysisWarningsModal.tsx | 3 +- .../common/PrivacyBadgeContainer.tsx | 3 +- .../components/common/ResetPasswordForm.tsx | 3 +- .../js/components/common/RestartButton.tsx | 3 +- .../components/common/VisibilitySelector.tsx | 5 +- .../controls/ComponentReportActions.tsx | 7 +- .../ComponentReportActionsRenderer.tsx | 3 +- .../main/js/components/controls/DateInput.tsx | 2 +- .../js/components/controls/HomePageSelect.tsx | 11 +- .../js/components/controls/ValidationForm.tsx | 2 +- .../__tests__/HomePageSelect-test.tsx | 3 +- .../main/js/components/controls/buttons.tsx | 4 +- .../src/main/js/components/docs/DocLink.tsx | 3 +- .../js/components/docs/DocMarkdownBlock.tsx | 7 +- .../js/components/docs/DocTooltipLink.tsx | 3 +- .../js/components/facet/ListStyleFacet.tsx | 15 +- .../hoc/__tests__/withCurrentUser-test.tsx | 3 +- .../__tests__/withKeyboardNavigation-test.tsx | 5 +- .../main/js/components/hoc/whenLoggedIn.tsx | 3 +- .../main/js/components/hoc/withAppState.tsx | 5 +- .../js/components/hoc/withCurrentUser.tsx | 5 +- .../components/hoc/withKeyboardNavigation.tsx | 11 +- .../js/components/hoc/withNotifications.tsx | 19 +- .../src/main/js/components/hoc/withRouter.tsx | 2 +- .../main/js/components/icons/IssueIcon.tsx | 3 +- .../js/components/icons/IssueTypeIcon.tsx | 3 +- .../js/components/icons/QualifierIcon.tsx | 3 +- .../main/js/components/icons/SeverityIcon.tsx | 3 +- .../main/js/components/icons/StatusIcon.tsx | 3 +- .../js/components/icons/TestStatusIcon.tsx | 3 +- .../icons/__tests__/IssueIcon-test.tsx | 3 +- .../src/main/js/components/issue/Issue.tsx | 7 +- .../main/js/components/issue/IssueView.tsx | 7 +- .../src/main/js/components/issue/actions.ts | 7 +- .../issue/components/IssueActionsBar.tsx | 11 +- .../issue/components/IssueAssign.tsx | 3 +- .../issue/components/IssueChangelog.tsx | 3 +- .../issue/components/IssueChangelogDiff.tsx | 3 +- .../issue/components/IssueCommentAction.tsx | 3 +- .../issue/components/IssueCommentLine.tsx | 3 +- .../issue/components/IssueSeverity.tsx | 7 +- .../components/issue/components/IssueTags.tsx | 9 +- .../issue/components/IssueTitleBar.tsx | 5 +- .../issue/components/IssueTransition.tsx | 5 +- .../components/issue/components/IssueType.tsx | 7 +- .../issue/components/SimilarIssuesFilter.tsx | 7 +- .../__tests__/IssueActionsBar-test.tsx | 3 +- .../__tests__/IssueChangelogDiff-test.tsx | 3 +- .../__tests__/IssueCommentLine-test.tsx | 3 +- .../components/__tests__/IssueType-test.tsx | 3 +- .../issue/popups/ChangelogPopup.tsx | 5 +- .../components/issue/popups/CommentPopup.tsx | 3 +- .../issue/popups/SetAssigneePopup.tsx | 9 +- .../issue/popups/SetSeverityPopup.tsx | 3 +- .../issue/popups/SetTransitionPopup.tsx | 3 +- .../components/issue/popups/SetTypePopup.tsx | 5 +- .../issue/popups/SimilarIssuesPopup.tsx | 5 +- .../src/main/js/components/measure/utils.ts | 5 +- .../js/components/shared/DrilldownLink.tsx | 5 +- .../main/js/components/shared/TypeHelper.tsx | 3 +- .../tutorials/TutorialSelection.tsx | 5 +- .../tutorials/TutorialSelectionRenderer.tsx | 5 +- .../tutorials/__tests__/utils-test.ts | 3 +- .../AzurePipelinesTutorial.tsx | 5 +- .../BranchAnalysisStepContent.tsx | 5 +- .../ServiceEndpointStepContent.tsx | 5 +- .../azure-pipelines/commands/PublishSteps.tsx | 3 +- .../bitbucket-pipelines/AnalysisCommand.tsx | 5 +- .../BitbucketPipelinesTutorial.tsx | 5 +- .../bitbucket-pipelines/PreambuleYaml.tsx | 3 +- .../RepositoryVariables.tsx | 5 +- .../tutorials/components/AllSet.tsx | 3 +- .../components/DefaultProjectKey.tsx | 3 +- .../tutorials/components/EditTokenModal.tsx | 5 +- .../components/SentenceWithHighlights.tsx | 3 +- .../components/TokenStepGenerator.tsx | 5 +- .../github-action/AnalysisCommand.tsx | 5 +- .../github-action/GitHubActionTutorial.tsx | 5 +- .../tutorials/github-action/SecretStep.tsx | 5 +- .../github-action/commands/CFamily.tsx | 3 +- .../github-action/commands/DotNet.tsx | 3 +- .../github-action/commands/Gradle.tsx | 3 +- .../github-action/commands/JavaMaven.tsx | 3 +- .../github-action/commands/Others.tsx | 3 +- .../gitlabci/EnvironmentVariablesStep.tsx | 5 +- .../tutorials/gitlabci/GitLabCITutorial.tsx | 5 +- .../tutorials/gitlabci/ProjectKeyStep.tsx | 3 +- .../tutorials/gitlabci/YmlFileStep.tsx | 3 +- .../tutorials/jenkins/JenkinsTutorial.tsx | 5 +- .../tutorials/jenkins/JenkinsfileStep.tsx | 5 +- .../jenkins/buildtool-steps/DotNet.tsx | 3 +- .../tutorials/manual/DoneNextSteps.tsx | 3 +- .../tutorials/manual/ManualTutorial.tsx | 5 +- .../tutorials/manual/ProjectAnalysisStep.tsx | 3 +- .../components/tutorials/manual/TokenStep.tsx | 5 +- .../manual/__tests__/TokenStep-test.tsx | 3 +- .../manual/commands/AnalysisCommand.tsx | 3 +- .../manual/commands/ClangGCCCommand.tsx | 3 +- .../tutorials/manual/commands/DotNet.tsx | 3 +- .../manual/commands/DotNetExecute.tsx | 3 +- .../tutorials/manual/commands/ExecScanner.tsx | 3 +- .../tutorials/manual/commands/JavaGradle.tsx | 3 +- .../tutorials/manual/commands/JavaMaven.tsx | 3 +- .../tutorials/manual/commands/Other.tsx | 3 +- .../src/main/js/components/tutorials/utils.ts | 3 +- .../src/main/js/components/ui/Alert.tsx | 3 +- .../components/upgrade/SystemUpgradeForm.tsx | 3 +- .../js/components/workspace/Workspace.tsx | 5 +- .../workspace/WorkspaceComponentViewer.tsx | 7 +- .../workspace/WorkspaceRuleDetails.tsx | 5 +- .../workspace/WorkspaceRuleViewer.tsx | 2 +- .../main/js/components/workspace/context.ts | 3 +- .../main/js/helpers/__tests__/request-test.ts | 3 +- .../src/main/js/helpers/component.ts | 4 +- .../src/main/js/helpers/constants.ts | 5 +- .../sonar-web/src/main/js/helpers/cookies.ts | 5 +- .../src/main/js/helpers/extensionsHandler.ts | 3 +- .../sonar-web/src/main/js/helpers/issues.ts | 31 +- server/sonar-web/src/main/js/helpers/l10n.ts | 3 +- .../sonar-web/src/main/js/helpers/measures.ts | 17 +- .../src/main/js/helpers/mocks/component.ts | 17 +- .../src/main/js/helpers/mocks/issues.ts | 3 +- .../src/main/js/helpers/mocks/permissions.ts | 5 +- .../main/js/helpers/mocks/quality-gates.ts | 3 +- .../src/main/js/helpers/mocks/users.ts | 4 +- .../sonar-web/src/main/js/helpers/periods.ts | 5 +- .../src/main/js/helpers/projectLinks.ts | 5 +- server/sonar-web/src/main/js/helpers/query.ts | 5 +- .../sonar-web/src/main/js/helpers/request.ts | 5 +- .../sonar-web/src/main/js/helpers/strings.ts | 5 +- .../src/main/js/helpers/testMocks.ts | 117 ++- server/sonar-web/src/main/js/helpers/urls.ts | 7 +- server/sonar-web/src/main/js/helpers/users.ts | 8 +- .../main/js/store/__tests__/branches-test.ts | 3 +- .../main/js/store/__tests__/users-test.tsx | 17 +- .../sonar-web/src/main/js/store/appState.ts | 9 +- .../sonar-web/src/main/js/store/branches.ts | 7 +- .../sonar-web/src/main/js/store/languages.ts | 7 +- server/sonar-web/src/main/js/store/metrics.ts | 5 +- .../src/main/js/store/rootActions.ts | 3 +- .../src/main/js/store/rootReducer.ts | 7 +- server/sonar-web/src/main/js/store/users.ts | 32 +- .../src/main/js/store/utils/actions.ts | 2 +- .../src/main/js/types/alm-integration.ts | 4 +- .../src/main/js/types/branch-like.ts | 8 +- server/sonar-web/src/main/js/types/browser.ts | 3 +- .../src/main/js/types/coding-rules.ts | 6 +- .../sonar-web/src/main/js/types/component.ts | 6 +- .../sonar-web/src/main/js/types/extension.ts | 15 +- server/sonar-web/src/main/js/types/issues.ts | 18 +- server/sonar-web/src/main/js/types/l10n.ts | 6 +- .../sonar-web/src/main/js/types/measures.ts | 12 +- .../src/main/js/types/quality-gates.ts | 23 +- .../src/main/js/types/security-hotspots.ts | 19 +- .../sonar-web/src/main/js/types/security.ts | 4 +- .../sonar-web/src/main/js/types/settings.ts | 6 +- server/sonar-web/src/main/js/types/types.d.ts | 970 ------------------ server/sonar-web/src/main/js/types/types.ts | 968 +++++++++++++++++ 730 files changed, 3945 insertions(+), 3014 deletions(-) delete mode 100644 server/sonar-web/src/main/js/types/types.d.ts create mode 100644 server/sonar-web/src/main/js/types/types.ts 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 { 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( 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 { +): Promise { return getJSON('/api/components/app', data); } export function getSources( data: { key: string; from?: number; to?: number } & BranchParameters -): Promise { +): Promise { return getJSON('/api/sources/lines', data).then(r => r.sources); } export function getDuplications( data: { key: string } & BranchParameters -): Promise<{ duplications: T.Duplication[]; files: T.Dict }> { +): Promise<{ duplications: Duplication[]; files: Dict }> { 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> { +export function getIssueFlowSnippets(issueKey: string): Promise> { 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, line: T.SourceLine) => { + (lineMap: Dict, 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 { +export function getLanguages(): Promise { 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 { +): Promise { 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 { +}): Promise { return inner(data); function inner( data: { p?: number; ps?: number } = { ps: 500 }, prev?: MetricsResponse - ): Promise { + ): Promise { 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; +type NavComponent = Omit; 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> { +}): Promise> { 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 { 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 { return post('/api/projects/update_visibility', { project, visibility }).catch(throwGlobalError); } export function changeProjectDefaultVisibility( - projectVisibility: T.Visibility + projectVisibility: Visibility ): Promise { 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 { +export function getProjectLinks(projectKey: string): Promise { 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 { +}): Promise { 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 { +export function fetchQualityGate(data: { id: number | string }): Promise { return getJSON('/api/qualitygates/show', data).catch(throwGlobalError); } -export function createQualityGate(data: { name: string }): Promise { +export function createQualityGate(data: { name: string }): Promise { return postJSON('/api/qualitygates/create', data).catch(throwGlobalError); } @@ -52,7 +53,7 @@ export function renameQualityGate(data: { id: string; name: string }): Promise { +export function copyQualityGate(data: { id: string; name: string }): Promise { return postJSON('/api/qualitygates/copy', data).catch(throwGlobalError); } @@ -63,12 +64,12 @@ export function setQualityGateAsDefault(data: { id: string }): Promise -): Promise { + } & Omit +): Promise { return postJSON('/api/qualitygates/create_condition', data).catch(throwGlobalError); } -export function updateCondition(data: T.Condition): Promise { +export function updateCondition(data: Condition): Promise { return postJSON('/api/qualitygates/update_condition', data).catch(throwGlobalError); } @@ -76,7 +77,7 @@ export function deleteCondition(data: { id: number }): Promise { return post('/api/qualitygates/delete_condition', data); } -export function getGateForProject(data: { project: string }): Promise { +export function getGateForProject(data: { project: string }): Promise { 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; severity: string }; - right: { params: T.Dict; severity: string }; + left: { params: Dict; severity: string }; + right: { params: Dict; 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 { @@ -244,7 +245,7 @@ export function searchUsers(parameters: SearchUsersGroupsParameters): Promise; - 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; + params?: Dict; 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 { 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 { +}): Promise { 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 { +}): Promise { 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 { 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 { return post('/api/system/change_log_level', { level }).catch(throwGlobalError); } -export function getSystemInfo(): Promise { +export function getSystemInfo(): Promise { 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 { 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 { +export function getTokens(login: string): Promise { return getJSON('/api/user_tokens/search', { login }).then(r => r.userTokens, throwGlobalError); } -export function generateToken(data: { name: string; login?: string }): Promise { +export function generateToken(data: { name: string; login?: string }): Promise { 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 { +}): Promise { 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 { +export function createGroup(data: { description?: string; name: string }): Promise { 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 { +export function getCurrentUser(): Promise { 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 { +}): Promise { return postJSON('/api/users/update', { ...data, scmAccount: data.scmAccount.length > 0 ? data.scmAccount : '' }); } -export function deactivateUser(data: { login: string }): Promise { +export function deactivateUser(data: { login: string }): Promise { return postJSON('/api/users/deactivate', data).catch(throwGlobalError); } -export function setHomePage(homepage: T.HomePage): Promise { +export function setHomePage(homepage: HomePage): Promise { return post('/api/users/set_homepage', homepage).catch(throwGlobalError); } -export function setUserSetting(setting: T.CurrentUserSetting): Promise { +export function setUserSetting(setting: CurrentUserSetting): Promise { 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 { .catch(throwGlobalError); } -export function fetchResponseExample(domain: string, action: string): Promise { +export function fetchResponseExample(domain: string, action: string): Promise { 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 { +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; + appState: Pick; 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 { 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; + appState: Pick; children: React.ReactElement; location: Pick; - registerBranchStatus: (branchLike: BranchLike, component: string, status: T.Status) => void; + registerBranchStatus: (branchLike: BranchLike, component: string, status: Status) => void; requireAuthorization: (router: Pick) => void; router: Pick; } @@ -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 { } }; - 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 { ); }; - 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 { } }; - 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 { } }; - 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 { 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 { needsAnotherCheck = ( shouldFetchComponent: boolean, - component: T.Component | undefined, + component: Component | undefined, newTasksInProgress: Task[] ) => { return ( @@ -354,7 +355,7 @@ export class ComponentContainer extends React.PureComponent { 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 { }); }; - handleComponentChange = (changes: Partial) => { + handleComponentChange = (changes: Partial) => { 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({ 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({ 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 { @@ -55,7 +56,7 @@ export class A11ySkipTargetInner extends React.PureComponent 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 { return
  • {text}
  • ; } - 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({ 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; +type SuggestionsJson = Dict; 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; + options?: Dict; 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; + appState: Pick; } 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; + component?: Pick; } 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) => void; + onComponentChange: (changes: Partial) => 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 { - 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; + appState: Pick; 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; + appState: Pick; 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 { ); }; - 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; + appState: Pick; 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; 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; + metrics: Dict; } 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; + metrics: Dict; options: BadgeOptions; type: BadgeType; updateOptions: (options: Partial) => 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; - component: T.Component; + metrics: Dict; + 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 { 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; + deprecatedByKey: Dict; } export class MetaQualityProfiles extends React.PureComponent { @@ -60,7 +61,7 @@ export class MetaQualityProfiles extends React.PureComponent { if (this.mounted) { - const deprecatedByKey: T.Dict = {}; + const deprecatedByKey: Dict = {}; responses.forEach((count, i) => { const profileKey = existingProfiles[i].key; deprecatedByKey[profileKey] = count; @@ -87,7 +88,7 @@ export class MetaQualityProfiles extends React.PureComponent 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; - currentUser: T.CurrentUser; + appState: Pick; + 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; - currentUser: T.CurrentUser; + appState: Pick; + currentUser: CurrentUser; location: { pathname: string }; } @@ -118,7 +119,7 @@ export default class GlobalNavMenu extends React.PureComponent { ); } - renderGlobalPageLink = ({ key, name }: T.Extension) => { + renderGlobalPageLink = ({ key, name }: Extension) => { return (
  • {name} 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; } @@ -46,7 +47,7 @@ export class GlobalNavUser extends React.PureComponent { }; renderAuthenticated() { - const currentUser = this.props.currentUser as T.LoggedInUser; + const currentUser = this.props.currentUser as LoggedInUser; return ( void; pending: PendingPluginResult; refreshPending: () => void; - systemStatus: T.SysStatus; + systemStatus: SysStatus; } export default class PendingPluginsActionNotif extends React.PureComponent { 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 { @@ -81,7 +82,7 @@ export default class SettingsNav extends React.PureComponent { return this.isSomethingActive(urls); } - renderExtension = ({ key, name }: T.Extension) => { + renderExtension = ({ key, name }: Extension) => { return (
  • 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 { input?: HTMLInputElement | null; node?: HTMLElement | null; - nodes: T.Dict; + nodes: Dict; 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; + [x: string]: Dict; }; -const MAP_VARIANT: T.Dict = { +const MAP_VARIANT: Dict = { [UpdateUseCase.NewMinorVersion]: 'info', [UpdateUseCase.NewPatch]: 'warning', [UpdateUseCase.PreLTS]: 'warning', @@ -48,8 +49,8 @@ const MAP_VARIANT: T.Dict = { interface Props { dismissable: boolean; - appState: Pick; - currentUser: T.CurrentUser; + appState: Pick; + 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 = new Promise(resolve => { + const appStatePromise: Promise = 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; -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 { @@ -54,7 +55,7 @@ export class Account extends React.PureComponent {
    - +
    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 { 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 { @@ -151,7 +152,7 @@ export default class ProjectModal extends React.PureComponent { ); }; - 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 { 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 { 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 { 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 { 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 { 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 = {}) { +function shallowRender(project: Partial = {}) { return shallow(); } 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 & { id: string }; // id should be removed when api/ce/activity accept a component key instead of an id + component?: Pick & { id: string }; // id should be removed when api/ce/activity accept a component key instead of an id location: Location; router: Pick; } 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; + component?: Pick; 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; + component?: Pick; 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 = {}; -let childrenBucket: T.Dict<{ - children: T.ComponentMeasure[]; + +import { Breadcrumb, ComponentMeasure, Dict } from '../../types/types'; + +let bucket: Dict = {}; +let childrenBucket: Dict<{ + children: ComponentMeasure[]; page: number; total: number; }> = {}; -let breadcrumbsBucket: T.Dict = {}; +let breadcrumbsBucket: Dict = {}; -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; + metrics: Dict; } interface DispatchToProps { @@ -61,7 +62,7 @@ interface DispatchToProps { interface OwnProps { branchLike?: BranchLike; - component: T.Component; + component: Component; location: Pick; router: Pick; } @@ -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 { } }; - 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 { 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 { 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; - onIssueChange?: (issue: T.Issue) => void; + onIssueChange?: (issue: Issue) => void; } export class SourceViewerWrapper extends React.PureComponent { 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 { +): Promise { 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; 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; profiles: Profile[]; - rule: T.Rule | T.RuleDetails; + rule: Rule | RuleDetails; } interface State { - params: T.Dict; + params: Dict; profile: string; severity: string; submitting: boolean; @@ -69,7 +70,7 @@ export default class ActivationFormModal extends React.PureComponent { - const params: T.Dict = {}; + const params: Dict = {}; 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; - referencedRepositories: T.Dict<{ key: string; language: string; name: string }>; - rules: T.Rule[]; + referencedProfiles: Dict; + referencedRepositories: Dict<{ key: string; language: string; name: string }>; + rules: Rule[]; selected?: string; usingPermalink?: boolean; } @@ -184,7 +193,7 @@ export class App extends React.PureComponent { 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 { ); }; - 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 { } ); - 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 { 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 { } } -function parseActives(rawActives: T.Dict) { +function parseActives(rawActives: Dict) { const actives: Actives = {}; for (const [rule, activations] of Object.entries(rawActives)) { actives[rule] = {}; @@ -686,7 +695,7 @@ function parseActives(rawActives: T.Dict) { function parseFacets(rawFacets: { property: string; values: { count: number; val: string }[] }[]) { const facets: Facets = {}; for (const rawFacet of rawFacets) { - const values: T.Dict = {}; + const values: Dict = {}; 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; + referencedProfiles: Dict; 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; + referencedProfiles: Dict; 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 } }; - 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; + params: Dict; reactivating: boolean; severity: string; status: string; @@ -59,7 +60,7 @@ export default class CustomRuleFormModal extends React.PureComponent = {}; + const params: Dict = {}; 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 ); - renderTypeOption = ({ value }: { value: T.RuleType }) => { + renderTypeOption = ({ value }: { value: RuleType }) => { return ; }; @@ -277,7 +278,7 @@ export default class CustomRuleFormModal extends React.PureComponent ); - renderParameterField = (param: T.RuleParameter) => ( + renderParameterField = (param: RuleParameter) => (
  • {translate('system.application_nodes_title')}
  • - {sortBy(getAppNodes(sysInfoData), getNodeName).map((node: T.SysInfoAppNode) => ( + {sortBy(getAppNodes(sysInfoData), getNodeName).map((node: SysInfoAppNode) => ( ))}
  • {translate('system.search_nodes_title')}
  • - {sortBy(getSearchNodes(sysInfoData), getNodeName).map((node: T.SysInfoSearchNode) => ( + {sortBy(getSearchNodes(sysInfoData), getNodeName).map((node: SysInfoSearchNode) => ( 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 ; + return ; } if (value instanceof Array) { return {JSON.stringify(value)}; 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 { 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 { @@ -104,7 +105,7 @@ export default class TokensForm extends React.PureComponent { } }; - 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 ( { - renderKey(param: T.WebApi.Param) { + renderKey(param: WebApi.Param) { return ( {param.key} @@ -69,7 +70,7 @@ export default class Params extends React.PureComponent { ); } - 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 { 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 { @@ -78,7 +79,7 @@ export class WebApiApp extends React.PureComponent { ); } - 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 { export default withRouter(WebApiApp); /** Checks if all actions are deprecated, and returns the latest deprecated one */ -function getLatestDeprecatedAction(domain: Pick) { +function getLatestDeprecatedAction(domain: Pick) { 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): T.RawQuery => + (query: Partial): 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 { 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; - 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; - 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; onUpdate: (data: { webhook: string; name: string; url: string }) => Promise; - 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; onUpdate: (data: { webhook: string; name: string; url: string }) => Promise; - 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; onUpdate: (data: { webhook: string; name: string; url: string }) => Promise; - webhooks: T.Webhook[]; + webhooks: Webhook[]; } export default class WebhooksList extends React.PureComponent { 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; + ) => Promise; loadIssues?: ( component: string, from: number, to: number, branchLike: BranchLike | undefined - ) => Promise; + ) => Promise; loadSources?: ( component: string, from: number, to: number, branchLike: BranchLike | undefined - ) => Promise; - onLoaded?: (component: T.SourceViewerFile, sources: T.SourceLine[], issues: T.Issue[]) => void; + ) => Promise; + 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; - duplications?: T.Duplication[]; + component?: SourceViewerFile; + duplicatedFiles?: Dict; + 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 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 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 } }; - 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 } }; - 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 ); } - loadSources = (): Promise => { + loadSources = (): Promise => { return new Promise((resolve, reject) => { const onFailLoadSources = (response: Response) => { // TODO handle other statuses @@ -525,19 +536,19 @@ export default class SourceViewerBase extends React.PureComponent } }; - 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 ); }; - renderCode(sources: T.SourceLine[]) { + renderCode(sources: SourceLine[]) { const hasSourcesBefore = sources.length > 0 && sources[0].line > 1; return ( ); } - renderHeader(branchLike: BranchLike | undefined, sourceViewerFile: T.SourceViewerFile) { + renderHeader(branchLike: BranchLike | undefined, sourceViewerFile: SourceViewerFile) { return this.props.slimHeader ? ( ) : ( @@ -682,7 +693,7 @@ export default class SourceViewerBase extends React.PureComponent function defaultLoadComponent( component: string, branchLike: BranchLike | undefined -): Promise { +): Promise { 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 { } } - 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 { 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({ 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
    - {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; + duplicatedFiles?: Dict; inRemovedComponent: boolean; openComponent: WorkspaceContextShape['openComponent']; - sourceViewerFile: T.SourceViewerFile; + sourceViewerFile: SourceViewerFile; } export default class DuplicationPopup extends React.PureComponent { @@ -64,7 +65,7 @@ export default class DuplicationPopup extends React.PureComponent { } }; - renderDuplication(file: T.DuplicatedFile, children: React.ReactNode, line?: number) { + renderDuplication(file: DuplicatedFile, children: React.ReactNode, line?: number) { return this.shouldLink() ? ( 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) => 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[]; + tagsFacet?: FacetValue[]; + typesFacet?: FacetValue[]; } export default class MeasuresOverlay extends React.PureComponent { @@ -124,7 +126,7 @@ export default class MeasuresOverlay extends React.PureComponent { return { severitiesFacet: severitiesFacet && severitiesFacet.values, tagsFacet: tagsFacet && tagsFacet.values, - typesFacet: typesFacet && (typesFacet.values as T.FacetValue[]) + typesFacet: typesFacet && (typesFacet.values as FacetValue[]) }; }); }; @@ -135,7 +137,7 @@ export default class MeasuresOverlay extends React.PureComponent { this.setState({ showAllMeasures: true }); }; - renderMeasure = (measure: T.MeasureEnhanced | undefined) => { + renderMeasure = (measure: MeasureEnhanced | undefined) => { return measure ? : null; }; @@ -162,7 +164,7 @@ export default class MeasuresOverlay extends React.PureComponent { ); }; - renderBigMeasure = (measure: T.MeasureEnhanced | undefined) => { + renderBigMeasure = (measure: MeasureEnhanced | undefined) => { return measure ? (
    @@ -190,7 +192,7 @@ export default class MeasuresOverlay extends React.PureComponent { <> {typesFacet && (
    - {sortBy(typesFacet, f => ISSUE_TYPES.indexOf(f.val)).map(f => ( + {sortBy(typesFacet, f => ISSUE_TYPES.indexOf(f.val as IssueTypeEnum)).map(f => (
    @@ -327,7 +329,7 @@ export default class MeasuresOverlay extends React.PureComponent { ); }; - renderDomain = (domain: string, measures: T.MeasureEnhanced[]) => { + renderDomain = (domain: string, measures: MeasureEnhanced[]) => { return (
    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[]) { - const index: { [line: number]: T.LinearIssueLocation[] } = {}; +export function locationsByLine(issues: Pick[]) { + 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[]) { 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 { +export function loadPage(query: RawQuery, page: number, pageSize = PAGE_SIZE): Promise { 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 { +): Promise { 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 { +): Promise { 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 { .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 = { +const METRIC_RATING: Dict = { 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 = { +const GRAPHS_METRICS_DISPLAYED: Dict = { [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 = { +const GRAPHS_METRICS: Dict = { [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, + metrics: Metric[] | Dict, 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) { +function findMetric(key: string, metrics: Metric[] | Dict) { 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 .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 .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 if (state.mouseOver && firstSerie) { const { updateTooltip } = this.props; const date = state.xScale.invert(xPos); - const bisectX = bisector(d => d.x).right; + const bisectX = bisector(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 }; renderLines = () => { - const lineGenerator = d3Line() + const lineGenerator = d3Line() .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 }; renderAreas = () => { - const areaGenerator = area() + const areaGenerator = area() .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 { 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 { .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 { .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 { }; renderLines = (xScale: XScale, yScale: YScale) => { - const lineGenerator = d3Line() + const lineGenerator = d3Line() .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 { }; renderAreas = (xScale: XScale, yScale: YScale) => { - const areaGenerator = area() + const areaGenerator = area() .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) { ); } -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['props']> = {}) { - return shallow>( +function shallowRender(props: Partial['props']> = {}) { + return shallow>( 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 { 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 { 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; - component: T.Component; + appState: Pick; + 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, 'value'> & +type InputWrapperProps = Omit, 'value'> & WrappedComponentProps & { innerRef: React.Ref; 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 { 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 = T.Omit, 'handleSubmit'>; +export type ChildrenProps = Omit, 'handleSubmit'>; interface Props { children: (props: ChildrenProps) => 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