From 41c98779d38bda9fdfdca182a5f20c73fcff9a84 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 5 Dec 2018 17:32:18 +0100 Subject: [PATCH] create global type definitions (#1017) --- .../src/main/js/components/Configuration.tsx | 3 +- .../src/main/js/components/LoginForm.tsx | 3 +- .../src/main/js/components/QGWidget.tsx | 3 +- .../src/main/js/components/Widget.tsx | 5 +- server/sonar-vsts/tsconfig.json | 2 +- .../src/main/js/api/alm-integration.ts | 19 +- server/sonar-web/src/main/js/api/billing.ts | 3 +- server/sonar-web/src/main/js/api/branches.ts | 5 +- server/sonar-web/src/main/js/api/ce.ts | 7 +- .../sonar-web/src/main/js/api/components.ts | 57 +- server/sonar-web/src/main/js/api/issues.ts | 3 +- server/sonar-web/src/main/js/api/languages.ts | 3 +- server/sonar-web/src/main/js/api/measures.ts | 22 +- server/sonar-web/src/main/js/api/metrics.ts | 9 +- server/sonar-web/src/main/js/api/nav.ts | 5 +- .../src/main/js/api/notifications.ts | 3 +- .../src/main/js/api/organizations.ts | 29 +- .../sonar-web/src/main/js/api/permissions.ts | 21 +- .../src/main/js/api/projectActivity.ts | 5 +- .../sonar-web/src/main/js/api/projectLinks.ts | 5 +- .../src/main/js/api/quality-gates.ts | 21 +- .../src/main/js/api/quality-profiles.ts | 5 +- server/sonar-web/src/main/js/api/rules.ts | 11 +- .../src/main/js/api/security-reports.ts | 3 +- server/sonar-web/src/main/js/api/settings.ts | 21 +- server/sonar-web/src/main/js/api/tests.ts | 7 +- .../sonar-web/src/main/js/api/time-machine.ts | 7 +- .../sonar-web/src/main/js/api/user_groups.ts | 7 +- server/sonar-web/src/main/js/api/users.ts | 15 +- server/sonar-web/src/main/js/api/webhooks.ts | 11 +- .../main/js/app/components/AdminContainer.tsx | 5 +- .../src/main/js/app/components/App.tsx | 5 +- .../js/app/components/ComponentContainer.tsx | 55 +- .../js/app/components/ComponentContext.tsx | 5 +- .../main/js/app/components/GlobalFooter.tsx | 4 +- .../app/components/GlobalFooterContainer.tsx | 3 +- .../src/main/js/app/components/Landing.tsx | 3 +- .../app/components/ProjectAdminContainer.tsx | 7 +- .../main/js/app/components/StartupModal.tsx | 10 +- .../__tests__/ComponentContainer-test.tsx | 40 +- .../__tests__/StartupModal-test.tsx | 3 +- .../app/components/extensions/Extension.tsx | 3 +- .../extensions/GlobalAdminPageExtension.tsx | 3 +- .../extensions/GlobalPageExtension.tsx | 3 +- .../extensions/OrganizationPageExtension.tsx | 3 +- .../extensions/ProjectAdminPageExtension.tsx | 3 +- .../extensions/ProjectPageExtension.tsx | 3 +- .../components/nav/component/ComponentNav.tsx | 11 +- .../nav/component/ComponentNavBgTaskNotif.tsx | 5 +- .../nav/component/ComponentNavBranch.tsx | 7 +- .../component/ComponentNavBranchesMenu.tsx | 15 +- .../ComponentNavBranchesMenuItem.tsx | 7 +- .../nav/component/ComponentNavHeader.tsx | 11 +- .../component/ComponentNavLicenseNotif.tsx | 3 +- .../nav/component/ComponentNavMenu.tsx | 7 +- .../nav/component/ComponentNavMeta.tsx | 26 +- .../ComponentNavBgTaskNotif-test.tsx | 7 +- .../__tests__/ComponentNavBranch-test.tsx | 32 +- .../ComponentNavBranchesMenu-test.tsx | 22 +- .../ComponentNavBranchesMenuItem-test.tsx | 11 +- .../__tests__/ComponentNavHeader-test.tsx | 9 +- .../ComponentNavLicenseNotif-test.tsx | 3 +- .../__tests__/ComponentNavMenu-test.tsx | 9 +- .../__tests__/ComponentNavMeta-test.tsx | 11 +- .../app/components/nav/global/GlobalNav.tsx | 5 +- .../components/nav/global/GlobalNavMenu.tsx | 7 +- .../components/nav/global/GlobalNavPlus.tsx | 5 +- .../components/nav/global/GlobalNavUser.tsx | 7 +- .../nav/global/GlobalNavUserContainer.tsx | 3 +- .../global/__tests__/GlobalNavPlus-test.tsx | 3 +- .../global/__tests__/GlobalNavUser-test.tsx | 9 +- .../components/nav/settings/SettingsNav.tsx | 5 +- .../main/js/app/components/search/Search.tsx | 5 +- .../js/app/components/search/SearchResult.tsx | 3 +- server/sonar-web/src/main/js/app/types.d.ts | 865 +++++++++++++++++ server/sonar-web/src/main/js/app/types.ts | 916 ------------------ .../src/main/js/app/utils/getStore.ts | 5 +- .../src/main/js/app/utils/startReactApp.tsx | 5 +- .../js/apps/about/components/AboutApp.tsx | 12 +- .../apps/about/components/AboutStandards.tsx | 3 +- .../apps/about/components/EntryIssueTypes.tsx | 15 +- .../main/js/apps/about/sonarcloud/Contact.tsx | 3 +- .../sonarcloud/components/SQPageContainer.tsx | 5 +- .../js/apps/account/components/Account.tsx | 5 +- .../js/apps/account/components/Password.tsx | 3 +- .../js/apps/account/components/Security.tsx | 5 +- .../js/apps/account/components/UserCard.tsx | 3 +- .../notifications/GlobalNotifications.tsx | 7 +- .../account/notifications/Notifications.tsx | 13 +- .../notifications/NotificationsList.tsx | 7 +- .../notifications/ProjectNotifications.tsx | 7 +- .../apps/account/notifications/Projects.tsx | 7 +- .../organizations/OrganizationCard.tsx | 3 +- .../organizations/OrganizationsList.tsx | 3 +- .../organizations/UserOrganizations.tsx | 3 +- .../main/js/apps/account/profile/Profile.tsx | 5 +- .../account/profile/UserExternalIdentity.tsx | 5 +- .../apps/account/profile/UserScmAccounts.tsx | 3 +- .../js/apps/account/projects/ProjectCard.tsx | 3 +- .../js/apps/account/projects/Projects.tsx | 3 +- .../account/projects/ProjectsContainer.tsx | 3 +- .../components/BackgroundTasksApp.tsx | 7 +- .../background-tasks/components/Footer.tsx | 3 +- .../components/ScannerContext.tsx | 3 +- .../components/Stacktrace.tsx | 3 +- .../apps/background-tasks/components/Task.tsx | 9 +- .../components/TaskActions.tsx | 7 +- .../components/TaskComponent.tsx | 5 +- .../background-tasks/components/Tasks.tsx | 7 +- .../components/__tests__/TaskActions-test.tsx | 3 +- .../main/js/apps/background-tasks/utils.ts | 3 +- .../js/apps/code/__tests__/buckets-test.tsx | 7 +- .../sonar-web/src/main/js/apps/code/bucket.ts | 19 +- .../src/main/js/apps/code/components/App.tsx | 17 +- .../js/apps/code/components/Breadcrumbs.tsx | 7 +- .../js/apps/code/components/Component.tsx | 11 +- .../js/apps/code/components/ComponentLink.tsx | 5 +- .../apps/code/components/ComponentMeasure.tsx | 5 +- .../js/apps/code/components/ComponentName.tsx | 11 +- .../js/apps/code/components/ComponentPin.tsx | 5 +- .../js/apps/code/components/Components.tsx | 13 +- .../apps/code/components/ComponentsHeader.tsx | 5 +- .../main/js/apps/code/components/Search.tsx | 7 +- .../components/__tests__/Components-test.tsx | 3 +- .../sonar-web/src/main/js/apps/code/utils.ts | 45 +- .../components/ActivationButton.tsx | 5 +- .../components/ActivationFormModal.tsx | 7 +- .../js/apps/coding-rules/components/App.tsx | 28 +- .../coding-rules/components/BulkChange.tsx | 3 +- .../components/BulkChangeModal.tsx | 3 +- .../components/CustomRuleButton.tsx | 9 +- .../components/CustomRuleFormModal.tsx | 11 +- .../components/InheritanceFacet.tsx | 9 +- .../coding-rules/components/PageActions.tsx | 3 +- .../coding-rules/components/RuleDetails.tsx | 7 +- .../components/RuleDetailsCustomRules.tsx | 9 +- .../components/RuleDetailsDescription.tsx | 5 +- .../components/RuleDetailsIssues.tsx | 7 +- .../components/RuleDetailsMeta.tsx | 5 +- .../components/RuleDetailsParameters.tsx | 5 +- .../components/RuleDetailsProfiles.tsx | 27 +- .../components/RuleInheritanceIcon.tsx | 5 +- .../coding-rules/components/RuleListItem.tsx | 9 +- .../components/SimilarRulesFilter.tsx | 3 +- .../coding-rules/components/TemplateFacet.tsx | 3 +- .../coding-rules/components/TypeFacet.tsx | 3 +- .../__tests__/RuleDetailsDescription-test.tsx | 16 +- .../__tests__/RuleDetailsIssues-test.tsx | 7 +- .../__tests__/RuleDetailsMeta-test.tsx | 20 +- .../__tests__/RuleListItem-test.tsx | 5 +- .../src/main/js/apps/coding-rules/query.ts | 17 +- .../component-measures/components/App.tsx | 32 +- .../components/AppContainer.tsx | 31 +- .../components/Breadcrumb.tsx | 3 +- .../components/Breadcrumbs.tsx | 9 +- .../components/LeakPeriodLegend.tsx | 7 +- .../components/MeasureContent.tsx | 36 +- .../components/MeasureContentContainer.tsx | 30 +- .../components/MeasureFavoriteContainer.tsx | 5 +- .../components/MeasureHeader.tsx | 13 +- .../components/MeasureOverview.tsx | 25 +- .../components/MeasureOverviewContainer.tsx | 13 +- .../components/MeasureViewSelect.tsx | 3 +- .../components/PageActions.tsx | 3 +- .../__tests__/LeakPeriodLegend-test.tsx | 11 +- .../__tests__/MeasureHeader-test.tsx | 5 +- .../__tests__/MeasureViewSelect-test.tsx | 3 +- .../drilldown/BubbleChart.tsx | 21 +- .../component-measures/drilldown/CodeView.tsx | 17 +- .../drilldown/ComponentCell.tsx | 9 +- .../drilldown/ComponentsList.tsx | 11 +- .../drilldown/ComponentsListRow.tsx | 11 +- .../drilldown/FilesView.tsx | 23 +- .../drilldown/MeasureCell.tsx | 7 +- .../drilldown/TreeMapView.tsx | 15 +- .../sidebar/DomainFacet.tsx | 11 +- .../sidebar/FacetMeasureValue.tsx | 3 +- .../component-measures/sidebar/Sidebar.tsx | 3 +- .../main/js/apps/component-measures/utils.ts | 44 +- .../create/components/OrganizationSelect.tsx | 7 +- .../organization/AutoOrganizationBind.tsx | 5 +- .../organization/AutoOrganizationCreate.tsx | 25 +- .../AutoPersonalOrganizationBind.tsx | 18 +- .../create/organization/BillingFormShim.tsx | 5 +- .../organization/CreateOrganization.tsx | 43 +- .../organization/ManualOrganizationCreate.tsx | 9 +- .../organization/OrganizationDetailsForm.tsx | 5 +- .../organization/OrganizationDetailsStep.tsx | 3 +- .../js/apps/create/organization/PlanStep.tsx | 3 +- .../organization/RemoteOrganizationChoose.tsx | 18 +- .../__tests__/CreateOrganization-test.tsx | 3 +- .../apps/create/project/AlmRepositoryItem.tsx | 7 +- .../apps/create/project/AutoProjectCreate.tsx | 7 +- .../apps/create/project/CreateProjectPage.tsx | 7 +- .../create/project/ManualProjectCreate.tsx | 7 +- .../apps/create/project/OrganizationInput.tsx | 5 +- .../create/project/RemoteRepositories.tsx | 9 +- .../__tests__/CreateProjectPage-test.tsx | 3 +- .../apps/custom-measures/components/App.tsx | 5 +- .../custom-measures/components/DeleteForm.tsx | 3 +- .../apps/custom-measures/components/Form.tsx | 5 +- .../apps/custom-measures/components/Item.tsx | 3 +- .../apps/custom-measures/components/List.tsx | 3 +- .../components/MeasureDate.tsx | 3 +- .../js/apps/custom-metrics/components/App.tsx | 7 +- .../custom-metrics/components/DeleteForm.tsx | 3 +- .../apps/custom-metrics/components/Form.tsx | 3 +- .../apps/custom-metrics/components/Item.tsx | 3 +- .../apps/custom-metrics/components/List.tsx | 3 +- .../main/js/apps/groups/components/App.tsx | 5 +- .../js/apps/groups/components/DeleteForm.tsx | 3 +- .../js/apps/groups/components/EditMembers.tsx | 3 +- .../groups/components/EditMembersModal.tsx | 3 +- .../main/js/apps/groups/components/Form.tsx | 3 +- .../main/js/apps/groups/components/List.tsx | 3 +- .../js/apps/groups/components/ListItem.tsx | 3 +- .../js/apps/issues/IssuesPageSelector.tsx | 3 +- .../main/js/apps/issues/components/App.tsx | 44 +- .../apps/issues/components/AppContainer.tsx | 5 +- .../issues/components/BulkChangeModal.tsx | 17 +- .../components/ComponentBreadcrumbs.tsx | 7 +- .../js/apps/issues/components/IssuesList.tsx | 11 +- .../issues/components/IssuesSourceViewer.tsx | 9 +- .../js/apps/issues/components/ListItem.tsx | 13 +- .../js/apps/issues/components/PageActions.tsx | 7 +- .../issues/components/__tests__/App-test.tsx | 9 +- .../__tests__/BulkChangeModal-test.tsx | 5 +- .../__tests__/ComponentBreadcrumbs-test.tsx | 5 +- .../issues/conciseIssuesList/ConciseIssue.tsx | 5 +- .../conciseIssuesList/ConciseIssueBox.tsx | 3 +- .../ConciseIssueLocations.tsx | 3 +- .../ConciseIssueLocationsNavigator.tsx | 3 +- .../conciseIssuesList/ConciseIssuesList.tsx | 3 +- .../ConciseIssuesListHeader.tsx | 3 +- .../CrossFileLocationsNavigator.tsx | 11 +- .../__tests__/ConciseIssue-test.tsx | 5 +- .../ConciseIssueLocationsNavigator-test.tsx | 7 +- .../__tests__/ConciseIssuesList-test.tsx | 3 +- .../CrossFileLocationsNavigator-test.tsx | 7 +- .../js/apps/issues/sidebar/AuthorFacet.tsx | 3 +- .../apps/issues/sidebar/CreationDateFacet.tsx | 3 +- .../js/apps/issues/sidebar/ProjectFacet.tsx | 5 +- .../main/js/apps/issues/sidebar/RuleFacet.tsx | 7 +- .../main/js/apps/issues/sidebar/Sidebar.tsx | 3 +- .../main/js/apps/issues/sidebar/TagFacet.tsx | 3 +- .../main/js/apps/issues/sidebar/TypeFacet.tsx | 9 +- .../src/main/js/apps/issues/utils.ts | 9 +- .../src/main/js/apps/marketplace/App.tsx | 4 +- .../main/js/apps/marketplace/AppContainer.tsx | 3 +- .../main/js/apps/marketplace/EditionBoxes.tsx | 4 +- .../src/main/js/apps/marketplace/Header.tsx | 5 +- .../marketplace/components/EditionBox.tsx | 4 +- .../src/main/js/apps/marketplace/utils.ts | 2 +- .../organizationMembers/AddMemberForm.tsx | 9 +- .../ManageMemberGroupsForm.tsx | 9 +- .../apps/organizationMembers/MembersList.tsx | 11 +- .../organizationMembers/MembersListItem.tsx | 11 +- .../OrganizationMembers.tsx | 20 +- .../OrganizationMembersContainer.tsx | 3 +- .../organizationMembers/RemoveMemberForm.tsx | 7 +- .../__tests__/OrganizationMembers-test.tsx | 7 +- .../src/main/js/apps/organizations/actions.ts | 9 +- .../OrganizationAccessContainer.tsx | 5 +- .../components/OrganizationContainer.tsx | 5 +- .../components/OrganizationDelete.tsx | 3 +- .../components/OrganizationEdit.tsx | 5 +- .../components/OrganizationGroupCheckbox.tsx | 3 +- .../components/OrganizationJustCreated.tsx | 3 +- .../components/OrganizationPage.tsx | 9 +- .../components/OrganizationProjects.tsx | 3 +- .../OrganizationAccessContainer-test.tsx | 7 +- .../OrganizationJustCreated-test.tsx | 3 +- .../navigation/OrganizationNavigation.tsx | 7 +- .../OrganizationNavigationAdministration.tsx | 3 +- .../OrganizationNavigationExtensions.tsx | 3 +- .../OrganizationNavigationHeader.tsx | 5 +- .../OrganizationNavigationHeaderContainer.tsx | 3 +- .../OrganizationNavigationMenuContainer.tsx | 7 +- .../navigation/OrganizationNavigationMeta.tsx | 11 +- .../__tests__/OrganizationNavigation-test.tsx | 3 +- ...anizationNavigationAdministration-test.tsx | 3 +- .../OrganizationNavigationHeader-test.tsx | 13 +- ...ganizationNavigationMenuContainer-test.tsx | 5 +- .../OrganizationNavigationMeta-test.tsx | 5 +- .../js/apps/overview/badges/BadgeParams.tsx | 3 +- .../js/apps/overview/badges/BadgesModal.tsx | 5 +- .../badges/__tests__/BadgeParams-test.tsx | 5 +- .../badges/__tests__/BadgesModal-test.tsx | 5 +- .../main/js/apps/overview/components/App.tsx | 9 +- .../ApplicationLeakPeriodLegend.tsx | 5 +- .../overview/components/EmptyOverview.tsx | 5 +- .../overview/components/LeakPeriodLegend.tsx | 9 +- .../apps/overview/components/OverviewApp.tsx | 13 +- .../components/SonarCloudEmptyOverview.tsx | 11 +- .../components/__tests__/App-test.tsx | 3 +- .../__tests__/EmptyOverview-test.tsx | 3 +- .../__tests__/LeakPeriodLegend-test.tsx | 15 +- .../SonarCloudEmptyOverview-test.tsx | 3 +- .../js/apps/overview/events/AnalysesList.tsx | 11 +- .../main/js/apps/overview/events/Analysis.tsx | 3 +- .../main/js/apps/overview/events/Event.tsx | 3 +- .../overview/main/BugsAndVulnerabilities.tsx | 11 +- .../main/js/apps/overview/main/CodeSmells.tsx | 5 +- .../main/js/apps/overview/main/enhance.tsx | 15 +- .../js/apps/overview/meta/MetaContainer.tsx | 25 +- .../main/js/apps/overview/meta/MetaLink.tsx | 3 +- .../main/js/apps/overview/meta/MetaLinks.tsx | 5 +- .../overview/meta/MetaQualityProfiles.tsx | 7 +- .../main/js/apps/overview/meta/MetaSize.tsx | 9 +- .../main/js/apps/overview/meta/MetaTags.tsx | 3 +- .../qualityGate/ApplicationQualityGate.tsx | 7 +- .../ApplicationQualityGateProject.tsx | 3 +- .../apps/overview/qualityGate/QualityGate.tsx | 9 +- .../qualityGate/QualityGateCondition.tsx | 21 +- .../qualityGate/QualityGateConditions.tsx | 7 +- .../src/main/js/apps/overview/utils.ts | 3 +- .../components/ActionsCell.tsx | 3 +- .../components/DeleteForm.tsx | 3 +- .../global/components/AllHoldersList.tsx | 23 +- .../permissions/global/components/App.tsx | 23 +- .../project/components/AllHoldersList.tsx | 25 +- .../permissions/project/components/App.tsx | 37 +- .../project/components/ApplyTemplate.tsx | 3 +- .../project/components/PageHeader.tsx | 3 +- .../shared/components/GroupHolder.tsx | 7 +- .../shared/components/HoldersList.tsx | 23 +- .../shared/components/PermissionCell.tsx | 10 +- .../shared/components/PermissionHeader.tsx | 3 +- .../shared/components/UserHolder.tsx | 7 +- .../src/main/js/apps/permissions/utils.ts | 9 +- .../js/apps/portfolio/components/Activity.tsx | 3 +- .../main/js/apps/portfolio/components/App.tsx | 5 +- .../portfolio/components/Subscription.tsx | 3 +- .../components/__tests__/App-test.tsx | 3 +- .../main/js/apps/projectActivity/actions.ts | 5 +- .../components/DefinitionChangeEventInner.tsx | 9 +- .../apps/projectActivity/components/Event.tsx | 3 +- .../projectActivity/components/EventInner.tsx | 3 +- .../projectActivity/components/Events.tsx | 3 +- .../components/GraphHistory.tsx | 3 +- .../components/GraphsTooltips.tsx | 3 +- .../GraphsTooltipsContentEvents.tsx | 3 +- .../components/ProjectActivityApp.tsx | 5 +- .../ProjectActivityAppContainer.tsx | 17 +- .../components/ProjectActivityGraphs.tsx | 3 +- .../ProjectActivityGraphsHeader.tsx | 3 +- .../components/ProjectActivityPageFooter.tsx | 3 +- .../components/ProjectActivityPageHeader.tsx | 3 +- .../components/RichQualityGateEventInner.tsx | 5 +- .../DefinitionChangeEventInner-test.tsx | 3 +- .../components/forms/AddGraphMetric.tsx | 5 +- .../components/forms/ChangeEventForm.tsx | 3 +- .../components/forms/RemoveEventForm.tsx | 3 +- .../src/main/js/apps/projectActivity/utils.ts | 7 +- .../apps/projectBranches/components/App.tsx | 5 +- .../projectBranches/components/BranchRow.tsx | 3 +- .../components/DeleteBranchModal.tsx | 3 +- .../components/LeakPeriodForm.tsx | 3 +- .../components/LongBranchesPattern.tsx | 3 +- .../components/LongBranchesPatternForm.tsx | 3 +- .../components/RenameBranchModal.tsx | 3 +- .../components/SettingForm.tsx | 3 +- .../components/__tests__/App-test.tsx | 23 +- .../components/__tests__/BranchRow-test.tsx | 17 +- .../__tests__/DeleteBranchModal-test.tsx | 9 +- .../__tests__/RenameBranchModal-test.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 +- .../src/main/js/apps/projectLinks/App.tsx | 5 +- .../src/main/js/apps/projectLinks/LinkRow.tsx | 9 +- .../src/main/js/apps/projectLinks/Table.tsx | 3 +- .../src/main/js/apps/projectLinks/utils.ts | 5 +- .../main/js/apps/projectQualityGate/App.tsx | 7 +- .../main/js/apps/projectQualityGate/Form.tsx | 5 +- .../projectQualityGate/__tests__/App-test.tsx | 5 +- .../js/apps/projectQualityProfiles/App.tsx | 3 +- .../apps/projects/components/AllProjects.tsx | 5 +- .../components/DefaultPageSelector.tsx | 3 +- .../projects/components/EmptyInstance.tsx | 5 +- .../projects/components/FavoriteFilter.tsx | 3 +- .../components/NoFavoriteProjects.tsx | 3 +- .../apps/projects/components/PageHeader.tsx | 7 +- .../apps/projects/components/ProjectCard.tsx | 3 +- .../components/ProjectCardLanguages.tsx | 5 +- .../projects/components/ProjectCardLeak.tsx | 3 +- .../components/ProjectCardOverall.tsx | 3 +- .../apps/projects/components/ProjectsList.tsx | 5 +- .../__tests__/DefaultPageSelector-test.tsx | 3 +- .../__tests__/NoFavoriteProjects-test.tsx | 7 +- .../__tests__/ProjectCardLeak-test.tsx | 8 +- .../__tests__/ProjectCardOverall-test.tsx | 8 +- .../apps/projects/filters/LanguagesFilter.tsx | 3 +- .../src/main/js/apps/projects/types.ts | 3 +- .../src/main/js/apps/projects/utils.ts | 5 +- .../visualizations/SimpleBubbleChart.tsx | 2 +- .../visualizations/__tests__/Risk-test.tsx | 6 +- .../__tests__/SimpleBubbleChart-test.tsx | 6 +- .../main/js/apps/projectsManagement/App.tsx | 9 +- .../apps/projectsManagement/AppContainer.tsx | 17 +- .../BulkApplyTemplateModal.tsx | 3 +- .../ChangeVisibilityForm.tsx | 16 +- .../projectsManagement/CreateProjectForm.tsx | 7 +- .../js/apps/projectsManagement/Header.tsx | 5 +- .../js/apps/projectsManagement/Projects.tsx | 3 +- .../js/apps/projectsManagement/Search.tsx | 5 +- .../projectsManagement/__tests__/App-test.tsx | 7 +- .../__tests__/ChangeVisibilityForm-test.tsx | 9 +- .../__tests__/CreateProjectForm-test.tsx | 7 +- .../__tests__/Header-test.tsx | 7 +- .../__tests__/ProjectRow-test.tsx | 3 +- .../__tests__/ProjectRowActions-test.tsx | 6 +- .../__tests__/Projects-test.tsx | 7 +- .../__tests__/Search-test.tsx | 3 +- .../components/AddConditionSelect.tsx | 5 +- .../quality-gates/components/Condition.tsx | 15 +- .../components/ConditionModal.tsx | 21 +- .../components/ConditionOperator.tsx | 3 +- .../quality-gates/components/Conditions.tsx | 17 +- .../components/CopyQualityGateForm.tsx | 3 +- .../components/DeleteQualityGateForm.tsx | 3 +- .../quality-gates/components/DetailsApp.tsx | 17 +- .../components/DetailsContent.tsx | 11 +- .../components/DetailsHeader.tsx | 3 +- .../apps/quality-gates/components/Intro.tsx | 3 +- .../js/apps/quality-gates/components/List.tsx | 3 +- .../apps/quality-gates/components/Period.tsx | 3 +- .../quality-gates/components/Projects.tsx | 3 +- .../components/QualityGatesApp.tsx | 7 +- .../components/RenameQualityGateForm.tsx | 3 +- .../components/ThresholdInput.tsx | 3 +- .../src/main/js/apps/quality-gates/utils.ts | 16 +- .../apps/quality-profiles/components/App.tsx | 3 +- .../details/ProfilePermissions.tsx | 4 +- .../quality-profiles/details/ProfileRules.tsx | 3 +- .../details/__tests__/ProfileRules-test.tsx | 17 +- .../quality-profiles/home/EvolutionRules.tsx | 8 +- .../apps/securityReports/components/App.tsx | 7 +- .../components/VulnerabilityList.tsx | 27 +- .../components/__tests__/App-test.tsx | 3 +- .../__tests__/VulnerabilityList-test.tsx | 3 +- .../components/EmailAlreadyExists.tsx | 3 +- .../js/apps/sessions/components/Login.tsx | 3 +- .../sessions/components/LoginContainer.tsx | 3 +- .../sessions/components/LoginSonarCloud.tsx | 3 +- .../sessions/components/OAuthProviders.tsx | 5 +- .../apps/sessions/components/UpdateLogin.tsx | 3 +- .../js/apps/settings/__tests__/utils-test.ts | 29 +- .../settings/components/AllCategoriesList.tsx | 3 +- .../apps/settings/components/AppContainer.tsx | 3 +- .../components/CategoryDefinitionsList.tsx | 3 +- .../apps/settings/components/Definition.tsx | 5 +- .../settings/components/DefinitionActions.tsx | 3 +- .../settings/components/DefinitionsList.tsx | 5 +- .../js/apps/settings/components/EmailForm.tsx | 3 +- .../apps/settings/components/PageHeader.tsx | 3 +- .../components/SubCategoryDefinitionsList.tsx | 5 +- .../__tests__/DefinitionActions-test.tsx | 5 +- .../apps/settings/components/inputs/Input.tsx | 3 +- .../inputs/InputForSingleSelectList.tsx | 3 +- .../components/inputs/PrimitiveInput.tsx | 19 +- .../inputs/__tests__/Input-test.tsx | 9 +- .../inputs/__tests__/MultiValueInput-test.tsx | 5 +- .../main/js/apps/settings/store/actions.ts | 3 +- .../js/apps/settings/store/definitions.ts | 5 +- .../src/main/js/apps/settings/store/values.ts | 9 +- .../src/main/js/apps/settings/utils.ts | 49 +- .../analyzeProject/AnalyzeTutorial.tsx | 5 +- .../__tests__/AnalyzeTutorial-test.tsx | 3 +- .../tutorials/components/LanguageForm.tsx | 3 +- .../tutorials/components/OrganizationStep.tsx | 2 +- .../components/ProjectAnalysisStep.tsx | 3 +- .../components/commands/AnalysisCommand.tsx | 3 +- .../tutorials/onboarding/OnboardingModal.tsx | 3 +- .../tutorials/onboarding/OnboardingPage.tsx | 3 +- .../projectOnboarding/ProjectOnboarding.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 +- .../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 +- .../main/js/apps/webhooks/components/App.tsx | 7 +- .../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 +- .../components/__tests__/App-test.tsx | 3 +- .../SourceViewer/SourceViewerBase.tsx | 68 +- .../SourceViewer/SourceViewerCode.tsx | 42 +- .../SourceViewer/SourceViewerHeader.tsx | 5 +- .../SourceViewer/components/CoveragePopup.tsx | 7 +- .../components/DuplicationPopup.tsx | 11 +- .../SourceViewer/components/Line.tsx | 19 +- .../SourceViewer/components/LineCode.tsx | 11 +- .../SourceViewer/components/LineCoverage.tsx | 5 +- .../components/LineDuplicationBlock.tsx | 3 +- .../components/LineDuplications.tsx | 5 +- .../components/LineIssuesIndicator.tsx | 5 +- .../components/LineIssuesList.tsx | 7 +- .../SourceViewer/components/LineNumber.tsx | 5 +- .../components/LineOptionsPopup.tsx | 5 +- .../SourceViewer/components/LineSCM.tsx | 7 +- .../components/MeasuresOverlay.tsx | 27 +- .../MeasuresOverlayCoveredFiles.tsx | 5 +- .../components/MeasuresOverlayMeasure.tsx | 3 +- .../components/MeasuresOverlayTestCase.tsx | 3 +- .../components/MeasuresOverlayTestCases.tsx | 7 +- .../SourceViewer/components/SCMPopup.tsx | 3 +- .../components/__tests__/LineCode-test.tsx | 9 +- .../__tests__/LineCoverage-test.tsx | 9 +- .../__tests__/LineIssuesIndicator-test.tsx | 7 +- .../__tests__/LineIssuesList-test.tsx | 7 +- .../__tests__/LineOptionsPopup-test.tsx | 5 +- .../__tests__/MeasuresOverlay-test.tsx | 7 +- .../MeasuresOverlayTestCases-test.tsx | 5 +- .../helpers/getCoverageStatus.tsx | 3 +- .../SourceViewer/helpers/highlight.ts | 3 +- .../SourceViewer/helpers/indexing.ts | 13 +- .../SourceViewer/helpers/issueLocations.tsx | 3 +- .../SourceViewer/helpers/loadIssues.tsx | 11 +- .../charts/LanguageDistribution.tsx | 3 +- .../js/components/common/BranchMeasures.tsx | 9 +- .../js/components/common/BranchStatus.tsx | 3 +- .../components/common/OrganizationAvatar.tsx | 3 +- .../common/PrivacyBadgeContainer.tsx | 21 +- .../components/common/VisibilitySelector.tsx | 15 +- .../common/__tests__/BranchMeasures-test.tsx | 3 +- .../common/__tests__/BranchStatus-test.tsx | 11 +- .../__tests__/PrivacyBadgeContainer-test.tsx | 13 +- .../__tests__/VisibilitySelector-test.tsx | 19 +- .../js/components/controls/HomePageSelect.tsx | 16 +- .../js/components/controls/ValidationForm.tsx | 3 +- .../__tests__/HomePageSelect-test.tsx | 9 +- .../js/components/facet/ListStyleFacet.tsx | 5 +- .../hoc/__tests__/withCurrentUser-test.tsx | 3 +- .../__tests__/withUserOrganizations-test.tsx | 3 +- .../main/js/components/hoc/whenLoggedIn.tsx | 3 +- .../js/components/hoc/withCurrentUser.tsx | 5 +- .../components/hoc/withUserOrganizations.tsx | 10 +- .../icons-components/BranchIcon.tsx | 3 +- .../src/main/js/components/issue/Issue.tsx | 9 +- .../main/js/components/issue/IssueView.tsx | 9 +- .../src/main/js/components/issue/actions.ts | 7 +- .../issue/components/IssueActionsBar.tsx | 13 +- .../issue/components/IssueAssign.tsx | 3 +- .../issue/components/IssueChangelog.tsx | 3 +- .../issue/components/IssueCommentAction.tsx | 3 +- .../issue/components/IssueCommentLine.tsx | 3 +- .../issue/components/IssueSeverity.tsx | 5 +- .../components/issue/components/IssueTags.tsx | 9 +- .../issue/components/IssueTitleBar.tsx | 9 +- .../issue/components/IssueTransition.tsx | 5 +- .../components/issue/components/IssueType.tsx | 5 +- .../issue/components/SimilarIssuesFilter.tsx | 7 +- .../__tests__/IssueCommentLine-test.tsx | 3 +- .../__tests__/IssueTitleBar-test.tsx | 19 +- .../components/__tests__/IssueType-test.tsx | 5 +- .../issue/popups/ChangelogPopup.tsx | 3 +- .../components/issue/popups/CommentPopup.tsx | 3 +- .../issue/popups/SetAssigneePopup.tsx | 7 +- .../issue/popups/SetSeverityPopup.tsx | 3 +- .../components/issue/popups/SetTypePopup.tsx | 7 +- .../issue/popups/SimilarIssuesPopup.tsx | 5 +- .../popups/__tests__/SetTypePopup-test.tsx | 3 +- .../src/main/js/components/measure/utils.ts | 9 +- .../components/preview-graph/PreviewGraph.tsx | 7 +- .../js/components/shared/DrilldownLink.tsx | 9 +- .../main/js/components/shared/TypeHelper.tsx | 3 +- .../js/components/ui/IdentityProviderLink.tsx | 3 +- .../js/components/ui/OrganizationListItem.tsx | 3 +- .../__tests__/OrganizationListItem-test.tsx | 3 +- .../src/main/js/components/ui/buttons.tsx | 5 +- .../src/main/js/components/withAppState.tsx | 5 +- .../workspace/WorkspaceComponentViewer.tsx | 5 +- .../workspace/WorkspaceRuleDetails.tsx | 5 +- .../workspace/WorkspaceRuleViewer.tsx | 3 +- .../main/js/components/workspace/context.ts | 3 +- .../js/helpers/__tests__/branches-test.ts | 19 +- .../helpers/__tests__/organizations-test.ts | 3 +- .../src/main/js/helpers/almIntegrations.ts | 5 +- .../sonar-web/src/main/js/helpers/branches.ts | 56 +- .../src/main/js/helpers/constants.ts | 22 +- .../sonar-web/src/main/js/helpers/issues.ts | 25 +- .../sonar-web/src/main/js/helpers/measures.ts | 15 +- .../src/main/js/helpers/organizations.ts | 17 +- .../sonar-web/src/main/js/helpers/periods.ts | 11 +- server/sonar-web/src/main/js/helpers/urls.ts | 31 +- server/sonar-web/src/main/js/helpers/users.ts | 6 +- .../sonar-web/src/main/js/store/appState.ts | 9 +- .../sonar-web/src/main/js/store/languages.ts | 7 +- server/sonar-web/src/main/js/store/metrics.ts | 5 +- .../src/main/js/store/organizations.ts | 11 +- .../src/main/js/store/rootReducer.ts | 5 +- server/sonar-web/src/main/js/store/users.ts | 13 +- .../src/main/js/store/utils/actions.ts | 3 +- 607 files changed, 2839 insertions(+), 3716 deletions(-) create mode 100644 server/sonar-web/src/main/js/app/types.d.ts delete mode 100644 server/sonar-web/src/main/js/app/types.ts diff --git a/server/sonar-vsts/src/main/js/components/Configuration.tsx b/server/sonar-vsts/src/main/js/components/Configuration.tsx index 63eeb43be10..9094a831697 100644 --- a/server/sonar-vsts/src/main/js/components/Configuration.tsx +++ b/server/sonar-vsts/src/main/js/components/Configuration.tsx @@ -29,7 +29,6 @@ import { parseWidgetSettings } from '../utils'; import { getCurrentUser } from '../../../../../sonar-web/src/main/js/api/users'; -import { CurrentUser } from '../../../../../sonar-web/src/main/js/app/types'; interface Props { contribution: string; @@ -37,7 +36,7 @@ interface Props { } interface State { - currentUser?: CurrentUser; + currentUser?: T.CurrentUser; loading: boolean; projects: Component[]; settings: Settings; diff --git a/server/sonar-vsts/src/main/js/components/LoginForm.tsx b/server/sonar-vsts/src/main/js/components/LoginForm.tsx index 162d7de4767..67ddc239cfe 100644 --- a/server/sonar-vsts/src/main/js/components/LoginForm.tsx +++ b/server/sonar-vsts/src/main/js/components/LoginForm.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import LoginLink from './LoginLink'; import SonarCloudIcon from './SonarCloudIcon'; import * as theme from '../../../../../sonar-web/src/main/js/app/theme'; -import { IdentityProvider } from '../../../../../sonar-web/src/main/js/app/types'; import { getIdentityProviders } from '../../../../../sonar-web/src/main/js/api/users'; import { getTextColor } from '../../../../../sonar-web/src/main/js/helpers/colors'; import { getBaseUrl } from '../../../../../sonar-web/src/main/js/helpers/urls'; @@ -32,7 +31,7 @@ interface Props { } interface State { - identityProviders?: IdentityProvider[]; + identityProviders?: T.IdentityProvider[]; } export default class LoginForm extends React.PureComponent { diff --git a/server/sonar-vsts/src/main/js/components/QGWidget.tsx b/server/sonar-vsts/src/main/js/components/QGWidget.tsx index 330ead0ec99..90d68e2dae1 100644 --- a/server/sonar-vsts/src/main/js/components/QGWidget.tsx +++ b/server/sonar-vsts/src/main/js/components/QGWidget.tsx @@ -25,10 +25,9 @@ import { getPathUrlAsString, getProjectUrl } from '../../../../../sonar-web/src/main/js/helpers/urls'; -import { ComponentMeasure } from '../../../../../sonar-web/src/main/js/app/types'; interface Props { - component: ComponentMeasure; + component: T.ComponentMeasure; } const QG_LEVELS: { [level: string]: string } = { diff --git a/server/sonar-vsts/src/main/js/components/Widget.tsx b/server/sonar-vsts/src/main/js/components/Widget.tsx index 049d8c45f9d..44fd7d2d01d 100644 --- a/server/sonar-vsts/src/main/js/components/Widget.tsx +++ b/server/sonar-vsts/src/main/js/components/Widget.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import QGWidget from './QGWidget'; import LoginForm from './LoginForm'; import { getMeasuresAndMeta } from '../../../../../sonar-web/src/main/js/api/measures'; -import { Metric, ComponentMeasure } from '../../../../../sonar-web/src/main/js/app/types'; import { Settings } from '../utils'; interface Props { @@ -29,9 +28,9 @@ interface Props { } interface State { - component?: ComponentMeasure; + component?: T.ComponentMeasure; loading: boolean; - metrics?: Metric[]; + metrics?: T.Metric[]; unauthorized: boolean; } export default class Widget extends React.PureComponent { diff --git a/server/sonar-vsts/tsconfig.json b/server/sonar-vsts/tsconfig.json index 55d03e5c4eb..bbab74e1bbb 100644 --- a/server/sonar-vsts/tsconfig.json +++ b/server/sonar-vsts/tsconfig.json @@ -18,5 +18,5 @@ }, "sourceMap": true }, - "include": ["./src/main/js/**/*"] + "include": ["./src/main/js/**/*", "../sonar-web/src/main/js/app/types.d.ts"] } diff --git a/server/sonar-web/src/main/js/api/alm-integration.ts b/server/sonar-web/src/main/js/api/alm-integration.ts index 4ede88d3bff..dd5660065ae 100644 --- a/server/sonar-web/src/main/js/api/alm-integration.ts +++ b/server/sonar-web/src/main/js/api/alm-integration.ts @@ -18,20 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getJSON, postJSON, post } from '../helpers/request'; -import { - AlmApplication, - AlmOrganization, - AlmRepository, - AlmUnboundApplication, - OrganizationBase -} from '../app/types'; import throwGlobalError from '../app/utils/throwGlobalError'; export function bindAlmOrganization(data: { installationId: string; organization: string }) { return post('/api/alm_integration/bind_organization', data).catch(throwGlobalError); } -export function getAlmAppInfo(): Promise<{ application: AlmApplication }> { +export function getAlmAppInfo(): Promise<{ application: T.AlmApplication }> { return getJSON('/api/alm_integration/show_app_info').catch(throwGlobalError); } @@ -53,8 +46,8 @@ function fetchAlmOrganization(data: { installationId: string }, remainingTries: } export interface GetAlmOrganizationResponse { - almOrganization: AlmOrganization; - boundOrganization?: OrganizationBase; + almOrganization: T.AlmOrganization; + boundOrganization?: T.OrganizationBase; } export function getAlmOrganization(data: { @@ -71,14 +64,14 @@ export function getAlmOrganization(data: { export function getRepositories(data: { organization: string; -}): Promise<{ repositories: AlmRepository[] }> { +}): Promise<{ repositories: T.AlmRepository[] }> { return getJSON('/api/alm_integration/list_repositories', data).catch(throwGlobalError); } -export function listUnboundApplications(): Promise { +export function listUnboundApplications(): Promise { return getJSON('/api/alm_integration/list_unbound_applications').then( ({ applications }) => - applications.map((app: AlmUnboundApplication) => ({ ...app, name: app.name || app.key })), + applications.map((app: T.AlmUnboundApplication) => ({ ...app, name: app.name || app.key })), throwGlobalError ); } diff --git a/server/sonar-web/src/main/js/api/billing.ts b/server/sonar-web/src/main/js/api/billing.ts index f0a20dca756..c8c2f7012ff 100644 --- a/server/sonar-web/src/main/js/api/billing.ts +++ b/server/sonar-web/src/main/js/api/billing.ts @@ -19,9 +19,8 @@ */ import { getJSON } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; -import { SubscriptionPlan } from '../app/types'; -export function getSubscriptionPlans(): Promise { +export function getSubscriptionPlans(): Promise { return getJSON('/api/billing/show_subscription_plans').then( ({ subscriptionPlans }) => subscriptionPlans, throwGlobalError diff --git a/server/sonar-web/src/main/js/api/branches.ts b/server/sonar-web/src/main/js/api/branches.ts index 9cb5dbaec27..d89c7951acc 100644 --- a/server/sonar-web/src/main/js/api/branches.ts +++ b/server/sonar-web/src/main/js/api/branches.ts @@ -18,14 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getJSON, post } from '../helpers/request'; -import { Branch, PullRequest } from '../app/types'; import throwGlobalError from '../app/utils/throwGlobalError'; -export function getBranches(project: string): Promise { +export function getBranches(project: string): Promise { return getJSON('/api/project_branches/list', { project }).then(r => r.branches, throwGlobalError); } -export function getPullRequests(project: string): Promise { +export function getPullRequests(project: string): Promise { return getJSON('/api/project_pull_requests/list', { project }).then( r => r.pullRequests, throwGlobalError diff --git a/server/sonar-web/src/main/js/api/ce.ts b/server/sonar-web/src/main/js/api/ce.ts index 6b6476a2798..a159628a65f 100644 --- a/server/sonar-web/src/main/js/api/ce.ts +++ b/server/sonar-web/src/main/js/api/ce.ts @@ -19,7 +19,6 @@ */ import { getJSON, post, RequestData } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; -import { Task } from '../app/types'; export function getAnalysisStatus(data: { component: string; @@ -38,7 +37,7 @@ export function getAnalysisStatus(data: { return getJSON('/api/ce/analysis_status', data).catch(throwGlobalError); } -export function getActivity(data: RequestData): Promise<{ tasks: Task[] }> { +export function getActivity(data: RequestData): Promise<{ tasks: T.Task[] }> { return getJSON('/api/ce/activity', data); } @@ -52,7 +51,7 @@ export function getStatus( return getJSON('/api/ce/activity_status', data); } -export function getTask(id: string, additionalFields?: string[]): Promise { +export function getTask(id: string, additionalFields?: string[]): Promise { return getJSON('/api/ce/task', { id, additionalFields }).then(r => r.task); } @@ -66,7 +65,7 @@ export function cancelAllTasks(): Promise { export function getTasksForComponent( componentKey: string -): Promise<{ queue: Task[]; current: Task }> { +): Promise<{ queue: T.Task[]; current: T.Task }> { return getJSON('/api/ce/component', { componentKey }).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/components.ts b/server/sonar-web/src/main/js/api/components.ts index ae01e608b7b..c2706de28ef 100644 --- a/server/sonar-web/src/main/js/api/components.ts +++ b/server/sonar-web/src/main/js/api/components.ts @@ -19,17 +19,6 @@ */ import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, postJSON, post, RequestData } from '../helpers/request'; -import { - SourceLine, - Paging, - Visibility, - BranchParameters, - MyProject, - Metric, - ComponentMeasure, - LightComponent, - SourceViewerFile -} from '../app/types'; export interface BaseSearchProjectsParameters { analyzedBefore?: string; @@ -38,14 +27,14 @@ export interface BaseSearchProjectsParameters { projects?: string; q?: string; qualifiers?: string; - visibility?: Visibility; + visibility?: T.Visibility; } export interface ProjectBase { key: string; name: string; qualifier: string; - visibility: Visibility; + visibility: T.Visibility; } export interface Project extends ProjectBase { @@ -63,7 +52,7 @@ export function getComponents( parameters: SearchProjectsParameters ): Promise<{ components: Project[]; - paging: Paging; + paging: T.Paging; }> { return getJSON('/api/projects/search', parameters); } @@ -104,9 +93,9 @@ export function getComponentTree( metrics: string[] = [], additional: RequestData = {} ): Promise<{ - components: ComponentMeasure[]; - metrics: Metric[]; - paging: Paging; + components: T.ComponentMeasure[]; + metrics: T.Metric[]; + paging: T.Paging; }> { const url = '/api/measures/component_tree'; const data = Object.assign({}, additional, { @@ -134,19 +123,19 @@ export function getComponentLeaves( } export function getComponent( - data: { componentKey: string; metricKeys: string } & BranchParameters + data: { componentKey: string; metricKeys: string } & T.BranchParameters ): Promise { return getJSON('/api/measures/component', data).then(r => r.component, throwGlobalError); } -export interface TreeComponent extends LightComponent { +export interface TreeComponent extends T.LightComponent { id: string; name: string; path?: string; refId?: string; refKey?: string; tags?: string[]; - visibility: Visibility; + visibility: T.Visibility; } export function getTree(data: { @@ -160,12 +149,12 @@ export function getTree(data: { qualifiers?: string; s?: string; strategy?: 'all' | 'leaves' | 'children'; -}): Promise<{ baseComponent: TreeComponent; components: TreeComponent[]; paging: Paging }> { +}): Promise<{ baseComponent: TreeComponent; components: TreeComponent[]; paging: T.Paging }> { return getJSON('/api/components/tree', data).catch(throwGlobalError); } export function doesComponentExists( - data: { component: string } & BranchParameters + data: { component: string } & T.BranchParameters ): Promise { return getJSON('/api/components/show', data).then( ({ component }) => component !== undefined, @@ -173,7 +162,7 @@ export function doesComponentExists( ); } -export function getComponentShow(data: { component: string } & BranchParameters): Promise { +export function getComponentShow(data: { component: string } & T.BranchParameters): Promise { return getJSON('/api/components/show', data).catch(throwGlobalError); } @@ -181,21 +170,21 @@ export function getParents(component: string): Promise { return getComponentShow({ component }).then(r => r.ancestors); } -export function getBreadcrumbs(data: { component: string } & BranchParameters): Promise { +export function getBreadcrumbs(data: { component: string } & T.BranchParameters): Promise { return getComponentShow(data).then(r => { const reversedAncestors = [...r.ancestors].reverse(); return [...reversedAncestors, r.component]; }); } -export function getComponentData(data: { component: string } & BranchParameters): Promise { +export function getComponentData(data: { component: string } & T.BranchParameters): Promise { return getComponentShow(data).then(r => r.component); } export function getMyProjects(data: { p?: number; ps?: number; -}): Promise<{ paging: Paging; projects: MyProject[] }> { +}): Promise<{ paging: T.Paging; projects: T.MyProject[] }> { return getJSON('/api/projects/search_my_projects', data); } @@ -207,7 +196,7 @@ export interface Component { isFavorite?: boolean; analysisDate?: string; tags: string[]; - visibility: Visibility; + visibility: T.Visibility; leakPeriodDate?: string; } @@ -222,7 +211,7 @@ export function searchProjects( components: Component[]; facets: Facet[]; organizations: Array<{ key: string; name: string }>; - paging: Paging; + paging: T.Paging; }> { const url = '/api/components/search_projects'; return getJSON(url, data); @@ -297,23 +286,23 @@ export function getSuggestions( } export function getComponentForSourceViewer( - data: { component: string } & BranchParameters -): Promise { + data: { component: string } & T.BranchParameters +): Promise { return getJSON('/api/components/app', data); } export function getSources( - data: { key: string; from?: number; to?: number } & BranchParameters -): Promise { + data: { key: string; from?: number; to?: number } & T.BranchParameters +): Promise { return getJSON('/api/sources/lines', data).then(r => r.sources); } -export function getDuplications(data: { key: string } & BranchParameters): Promise { +export function getDuplications(data: { key: string } & T.BranchParameters): Promise { return getJSON('/api/duplications/show', data); } export function getTests( - data: { sourceFileKey: string; sourceFileLineNumber: number | string } & BranchParameters + data: { sourceFileKey: string; sourceFileLineNumber: number | string } & T.BranchParameters ): Promise { return getJSON('/api/tests/list', data).then(r => r.tests); } diff --git a/server/sonar-web/src/main/js/api/issues.ts b/server/sonar-web/src/main/js/api/issues.ts index fc49c0f7658..96163c169d9 100644 --- a/server/sonar-web/src/main/js/api/issues.ts +++ b/server/sonar-web/src/main/js/api/issues.ts @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { FacetValue } from '../app/types'; import { getJSON, post, postJSON, RequestData } from '../helpers/request'; import { RawIssue } from '../helpers/issues'; import throwGlobalError from '../app/utils/throwGlobalError'; @@ -75,7 +74,7 @@ export function getFacets( query: RequestData, facets: FacetName[] ): Promise<{ - facets: Array<{ property: string; values: FacetValue[] }>; + facets: Array<{ property: string; values: T.FacetValue[] }>; response: IssuesResponse; }> { const data = { diff --git a/server/sonar-web/src/main/js/api/languages.ts b/server/sonar-web/src/main/js/api/languages.ts index ebf3efdb631..8f0f328fc2d 100644 --- a/server/sonar-web/src/main/js/api/languages.ts +++ b/server/sonar-web/src/main/js/api/languages.ts @@ -18,9 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getJSON } from '../helpers/request'; -import { Language } from '../app/types'; import throwGlobalError from '../app/utils/throwGlobalError'; -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 9a5357a174a..58d537385db 100644 --- a/server/sonar-web/src/main/js/api/measures.ts +++ b/server/sonar-web/src/main/js/api/measures.ts @@ -19,20 +19,10 @@ */ import { getJSON, RequestData, postJSON, post } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; -import { - BranchParameters, - ComponentMeasure, - CustomMeasure, - Measure, - Metric, - Paging, - Period, - PeriodMeasure -} from '../app/types'; export function getMeasures( - data: { componentKey: string; metricKeys: string } & BranchParameters -): Promise { + data: { componentKey: string; metricKeys: string } & T.BranchParameters +): Promise { return getJSON('/api/measures/component', data).then(r => r.component.measures, throwGlobalError); } @@ -40,7 +30,7 @@ export function getMeasuresAndMeta( componentKey: string, metrics: string[], additional: RequestData = {} -): Promise<{ component: ComponentMeasure; metrics?: Metric[]; periods?: Period[] }> { +): Promise<{ component: T.ComponentMeasure; metrics?: T.Metric[]; periods?: T.Period[] }> { const data = { ...additional, componentKey, metricKeys: metrics.join(',') }; return getJSON('/api/measures/component', data); } @@ -48,7 +38,7 @@ export function getMeasuresAndMeta( interface MeasuresForProjects { component: string; metric: string; - periods?: PeriodMeasure[]; + periods?: T.PeriodMeasure[]; value?: string; } @@ -67,7 +57,7 @@ export function getCustomMeasures(data: { p?: number; projectKey: string; ps?: number; -}): Promise<{ customMeasures: CustomMeasure[]; paging: Paging }> { +}): Promise<{ customMeasures: T.CustomMeasure[]; paging: T.Paging }> { return getJSON('/api/custom_measures/search', data).then( r => ({ @@ -83,7 +73,7 @@ export function createCustomMeasure(data: { metricKey: string; projectKey: string; value: string; -}): Promise { +}): Promise { return postJSON('/api/custom_measures/create', data).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/metrics.ts b/server/sonar-web/src/main/js/api/metrics.ts index 25cbbf710bc..96a0ed32230 100644 --- a/server/sonar-web/src/main/js/api/metrics.ts +++ b/server/sonar-web/src/main/js/api/metrics.ts @@ -18,11 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getJSON, post, postJSON } from '../helpers/request'; -import { Metric } from '../app/types'; import throwGlobalError from '../app/utils/throwGlobalError'; export interface MetricsResponse { - metrics: Metric[]; + metrics: T.Metric[]; p: number; ps: number; total: number; @@ -40,13 +39,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) { @@ -71,7 +70,7 @@ export function createMetric(data: { key: string; name: string; type: string; -}): Promise { +}): Promise { return postJSON('/api/metrics/create', data).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/nav.ts b/server/sonar-web/src/main/js/api/nav.ts index e5af1bb7e91..66da48b10ab 100644 --- a/server/sonar-web/src/main/js/api/nav.ts +++ b/server/sonar-web/src/main/js/api/nav.ts @@ -18,15 +18,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getJSON } from '../helpers/request'; -import { AppState, BranchParameters } from '../app/types'; import throwGlobalError from '../app/utils/throwGlobalError'; -export function getGlobalNavigation(): Promise { +export function getGlobalNavigation(): Promise { return getJSON('/api/navigation/global'); } export function getComponentNavigation( - data: { componentKey: string } & BranchParameters + data: { componentKey: string } & T.BranchParameters ): Promise { return getJSON('/api/navigation/component', 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 d1f0db0e09c..025967c5583 100644 --- a/server/sonar-web/src/main/js/api/notifications.ts +++ b/server/sonar-web/src/main/js/api/notifications.ts @@ -17,14 +17,13 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { Notification } from '../app/types'; import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post } from '../helpers/request'; export function getNotifications(): Promise<{ channels: string[]; globalTypes: string[]; - notifications: Notification[]; + notifications: T.Notification[]; perProjectTypes: string[]; }> { return getJSON('/api/notifications/list').catch(throwGlobalError); diff --git a/server/sonar-web/src/main/js/api/organizations.ts b/server/sonar-web/src/main/js/api/organizations.ts index 79397d3b5a2..deae9b7b39b 100644 --- a/server/sonar-web/src/main/js/api/organizations.ts +++ b/server/sonar-web/src/main/js/api/organizations.ts @@ -19,36 +19,29 @@ */ import { getJSON, post, postJSON } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; -import { - Organization, - OrganizationBase, - Paging, - OrganizationMember, - Extension -} from '../app/types'; export function getOrganizations(data: { organizations?: string; member?: boolean; }): Promise<{ - organizations: Organization[]; - paging: Paging; + organizations: T.Organization[]; + paging: T.Paging; }> { return getJSON('/api/organizations/search', data).catch(throwGlobalError); } -export function getOrganization(key: string): Promise { +export function getOrganization(key: string): Promise { return getJSON('/api/organizations/search', { organizations: key }).then( - r => r.organizations.find((o: Organization) => o.key === key), + r => r.organizations.find((o: T.Organization) => o.key === key), throwGlobalError ); } interface GetOrganizationNavigation { - adminPages: Extension[]; + adminPages: T.Extension[]; canUpdateProjectsVisibilityToPrivate: boolean; isDefault: boolean; - pages: Extension[]; + pages: T.Extension[]; } export function getOrganizationNavigation(key: string): Promise { @@ -59,12 +52,12 @@ export function getOrganizationNavigation(key: string): Promise { + data: T.OrganizationBase & { installationId?: string } +): Promise { return postJSON('/api/organizations/create', data).then(r => r.organization, throwGlobalError); } -export function updateOrganization(key: string, changes: OrganizationBase) { +export function updateOrganization(key: string, changes: T.OrganizationBase) { return post('/api/organizations/update', { key, ...changes }).catch(throwGlobalError); } @@ -78,14 +71,14 @@ export function searchMembers(data: { ps?: number; q?: string; selected?: string; -}): Promise<{ paging: Paging; users: OrganizationMember[] }> { +}): Promise<{ paging: T.Paging; users: T.OrganizationMember[] }> { return getJSON('/api/organizations/search_members', data).catch(throwGlobalError); } export function addMember(data: { login: string; organization: string; -}): Promise { +}): Promise { return postJSON('/api/organizations/add_member', data).then(r => r.user, throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/permissions.ts b/server/sonar-web/src/main/js/api/permissions.ts index 235d5c5ef36..1ba67a885a3 100644 --- a/server/sonar-web/src/main/js/api/permissions.ts +++ b/server/sonar-web/src/main/js/api/permissions.ts @@ -18,13 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { BaseSearchProjectsParameters } from './components'; -import { - Paging, - PermissionGroup, - PermissionTemplate, - PermissionUser, - Visibility -} from '../app/types'; import { getJSON, post, postJSON, RequestData } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; @@ -67,7 +60,7 @@ export function revokePermissionFromGroup(data: { } interface GetPermissionTemplatesResponse { - permissionTemplates: PermissionTemplate[]; + permissionTemplates: T.PermissionTemplate[]; defaultTemplates: Array<{ templateId: string; qualifier: string }>; permissions: Array<{ key: string; name: string; description: string }>; } @@ -150,7 +143,7 @@ export function getPermissionsUsersForComponent(data: { organization?: string; p?: number; ps?: number; -}): Promise<{ paging: Paging; users: PermissionUser[] }> { +}): Promise<{ paging: T.Paging; users: T.PermissionUser[] }> { if (!data.ps) { data.ps = PAGE_SIZE; } @@ -164,7 +157,7 @@ export function getPermissionsGroupsForComponent(data: { organization?: string; p?: number; ps?: number; -}): Promise<{ paging: Paging; groups: PermissionGroup[] }> { +}): Promise<{ paging: T.Paging; groups: T.PermissionGroup[] }> { if (!data.ps) { data.ps = PAGE_SIZE; } @@ -177,7 +170,7 @@ export function getGlobalPermissionsUsers(data: { organization?: string; p?: number; ps?: number; -}): Promise<{ paging: Paging; users: PermissionUser[] }> { +}): Promise<{ paging: T.Paging; users: T.PermissionUser[] }> { if (!data.ps) { data.ps = PAGE_SIZE; } @@ -190,7 +183,7 @@ export function getGlobalPermissionsGroups(data: { organization?: string; p?: number; ps?: number; -}): Promise<{ paging: Paging; groups: PermissionGroup[] }> { +}): Promise<{ paging: T.Paging; groups: T.PermissionGroup[] }> { if (!data.ps) { data.ps = PAGE_SIZE; } @@ -237,14 +230,14 @@ export function getPermissionTemplateGroups( export function changeProjectVisibility( project: string, - visibility: Visibility + visibility: T.Visibility ): Promise { return post('/api/projects/update_visibility', { project, visibility }).catch(throwGlobalError); } export function changeProjectDefaultVisibility( organization: string, - projectVisibility: Visibility + projectVisibility: T.Visibility ): Promise { return post('/api/projects/update_default_visibility', { organization, 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 d16733b5ebb..8d9af2debc1 100644 --- a/server/sonar-web/src/main/js/api/projectActivity.ts +++ b/server/sonar-web/src/main/js/api/projectActivity.ts @@ -19,11 +19,10 @@ */ import { getJSON, postJSON, post, RequestData } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; -import { Paging, BranchParameters, Analysis } from '../app/types'; export function getProjectActivity( - data: { project: string; category?: string; p?: number; ps?: number } & BranchParameters -): Promise<{ analyses: Analysis[]; paging: Paging }> { + data: { project: string; category?: string; p?: number; ps?: number } & T.BranchParameters +): Promise<{ analyses: T.Analysis[]; paging: T.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 eec3d0f4a72..2e5e92e6c75 100644 --- a/server/sonar-web/src/main/js/api/projectLinks.ts +++ b/server/sonar-web/src/main/js/api/projectLinks.ts @@ -17,11 +17,10 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { ProjectLink } from '../app/types'; import throwGlobalError from '../app/utils/throwGlobalError'; import { getJSON, post, postJSON } from '../helpers/request'; -export function getProjectLinks(projectKey: string): Promise { +export function getProjectLinks(projectKey: string): Promise { return getJSON('/api/project_links/search', { projectKey }).then(r => r.links, throwGlobalError); } @@ -33,6 +32,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 af49578283e..cd47f7709e3 100644 --- a/server/sonar-web/src/main/js/api/quality-gates.ts +++ b/server/sonar-web/src/main/js/api/quality-gates.ts @@ -19,13 +19,12 @@ */ import { getJSON, post, postJSON } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; -import { Condition, Metric, QualityGate, Omit } from '../app/types'; export function fetchQualityGates(data: { organization?: string; }): Promise<{ actions: { create: boolean }; - qualitygates: QualityGate[]; + qualitygates: T.QualityGate[]; }> { return getJSON('/api/qualitygates/list', data).catch(throwGlobalError); } @@ -33,14 +32,14 @@ export function fetchQualityGates(data: { export function fetchQualityGate(data: { id: number; organization?: string; -}): Promise { +}): Promise { return getJSON('/api/qualitygates/show', data).catch(throwGlobalError); } export function createQualityGate(data: { name: string; organization?: string; -}): Promise { +}): Promise { return postJSON('/api/qualitygates/create', data).catch(throwGlobalError); } @@ -63,7 +62,7 @@ export function copyQualityGate(data: { id: number; name: string; organization?: string; -}): Promise { +}): Promise { return postJSON('/api/qualitygates/copy', data).catch(throwGlobalError); } @@ -78,12 +77,14 @@ export function createCondition( data: { gateId: number; organization?: string; - } & Omit -): Promise { + } & T.Omit +): Promise { return postJSON('/api/qualitygates/create_condition', data); } -export function updateCondition(data: { organization?: string } & Condition): Promise { +export function updateCondition( + data: { organization?: string } & T.Condition +): Promise { return postJSON('/api/qualitygates/update_condition', data); } @@ -94,7 +95,7 @@ export function deleteCondition(data: { id: number; organization?: string }): Pr export function getGateForProject(data: { organization?: string; project: string; -}): Promise { +}): Promise { return getJSON('/api/qualitygates/get_by_project', data).then( ({ qualityGate }) => qualityGate && { @@ -153,7 +154,7 @@ export interface ApplicationProject { } export interface ApplicationQualityGate { - metrics: Metric[]; + metrics: T.Metric[]; projects: ApplicationProject[]; status: string; } 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 d07a6194341..4f1b3bd364e 100644 --- a/server/sonar-web/src/main/js/api/quality-profiles.ts +++ b/server/sonar-web/src/main/js/api/quality-profiles.ts @@ -28,7 +28,6 @@ import { postJSON, RequestData } from '../helpers/request'; -import { Paging } from '../app/types'; import throwGlobalError from '../app/utils/throwGlobalError'; export interface ProfileActions { @@ -193,7 +192,7 @@ export interface SearchUsersResponse { name: string; selected?: boolean; }>; - paging: Paging; + paging: T.Paging; } export function searchUsers(parameters: SearchUsersGroupsParameters): Promise { @@ -202,7 +201,7 @@ export function searchUsers(parameters: SearchUsersGroupsParameters): Promise; - paging: Paging; + paging: T.Paging; } export function searchGroups( diff --git a/server/sonar-web/src/main/js/api/rules.ts b/server/sonar-web/src/main/js/api/rules.ts index ea42bf0a1a7..329af4239a8 100644 --- a/server/sonar-web/src/main/js/api/rules.ts +++ b/server/sonar-web/src/main/js/api/rules.ts @@ -19,7 +19,6 @@ */ import { post, getJSON, postJSON } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; -import { Rule, RuleDetails, RuleActivation } from '../app/types'; export interface GetRulesAppResponse { canWrite?: boolean; @@ -33,11 +32,11 @@ export function getRulesApp(data: { } export interface SearchRulesResponse { - actives?: { [rule: string]: RuleActivation[] }; + actives?: { [rule: string]: T.RuleActivation[] }; facets?: { property: string; values: { count: number; val: string }[] }[]; p: number; ps: number; - rules: Rule[]; + rules: T.Rule[]; total: number; } @@ -57,7 +56,7 @@ export function getRuleDetails(parameters: { actives?: boolean; key: string; organization: string | undefined; -}): Promise<{ actives?: RuleActivation[]; rule: RuleDetails }> { +}): Promise<{ actives?: T.RuleActivation[]; rule: T.RuleDetails }> { return getJSON('/api/rules/show', parameters).catch(throwGlobalError); } @@ -80,7 +79,7 @@ export function createRule(data: { status?: string; template_key: string; type?: string; -}): Promise { +}): Promise { return postJSON('/api/rules/create', data).then( r => r.rule, error => { @@ -112,6 +111,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-reports.ts b/server/sonar-web/src/main/js/api/security-reports.ts index 2747ea7536f..eba073fc227 100644 --- a/server/sonar-web/src/main/js/api/security-reports.ts +++ b/server/sonar-web/src/main/js/api/security-reports.ts @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { SecurityHotspot } from '../app/types'; import { getJSON } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; @@ -26,6 +25,6 @@ export function getSecurityHotspots(data: { standard: 'owaspTop10' | 'sansTop25' | 'cwe'; includeDistribution?: boolean; branch?: string; -}): Promise<{ categories: Array }> { +}): Promise<{ categories: T.SecurityHotspot[] }> { return getJSON('/api/security_reports/show', data).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/api/settings.ts b/server/sonar-web/src/main/js/api/settings.ts index 11b37f1d02f..ae7339db76c 100644 --- a/server/sonar-web/src/main/js/api/settings.ts +++ b/server/sonar-web/src/main/js/api/settings.ts @@ -19,17 +19,10 @@ */ import { omitBy } from 'lodash'; import { getJSON, RequestData, post, postJSON } from '../helpers/request'; -import { - BranchParameters, - SettingCategoryDefinition, - SettingValue, - SettingType, - SettingDefinition -} from '../app/types'; import throwGlobalError from '../app/utils/throwGlobalError'; import { isCategoryDefinition } from '../apps/settings/utils'; -export function getDefinitions(component?: string): Promise { +export function getDefinitions(component?: string): Promise { return getJSON('/api/settings/list_definitions', { component }).then( r => r.definitions, throwGlobalError @@ -37,13 +30,13 @@ export function getDefinitions(component?: string): Promise { + data: { keys: string; component?: string } & T.BranchParameters +): Promise { return getJSON('/api/settings/values', data).then(r => r.settings); } export function setSettingValue( - definition: SettingDefinition, + definition: T.SettingDefinition, value: any, component?: string ): Promise { @@ -52,7 +45,7 @@ export function setSettingValue( if (isCategoryDefinition(definition) && definition.multiValues) { data.values = value; - } else if (definition.type === SettingType.PropertySet) { + } else if (definition.type === 'PROPERTY_SET') { data.fieldValues = value .map((fields: any) => omitBy(fields, value => value == null)) .map(JSON.stringify); @@ -64,13 +57,13 @@ export function setSettingValue( } export function setSimpleSettingValue( - data: { component?: string; value: string; key: string } & BranchParameters + data: { component?: string; value: string; key: string } & T.BranchParameters ): Promise { return post('/api/settings/set', data).catch(throwGlobalError); } export function resetSettingValue( - data: { keys: string; component?: string } & BranchParameters + data: { keys: string; component?: string } & T.BranchParameters ): Promise { return post('/api/settings/reset', data); } diff --git a/server/sonar-web/src/main/js/api/tests.ts b/server/sonar-web/src/main/js/api/tests.ts index 5b649d1d99b..7dbb75c19af 100644 --- a/server/sonar-web/src/main/js/api/tests.ts +++ b/server/sonar-web/src/main/js/api/tests.ts @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import throwGlobalError from '../app/utils/throwGlobalError'; -import { Paging, TestCase, CoveredFile, BranchParameters } from '../app/types'; import { getJSON } from '../helpers/request'; export function getTests( @@ -29,11 +28,11 @@ export function getTests( sourceFileLineNumber?: number; testFileKey: string; testId?: string; - } & BranchParameters -): Promise<{ paging: Paging; tests: TestCase[] }> { + } & T.BranchParameters +): Promise<{ paging: T.Paging; tests: T.TestCase[] }> { return getJSON('/api/tests/list', parameters).catch(throwGlobalError); } -export function getCoveredFiles(data: { testId: string }): Promise { +export function getCoveredFiles(data: { testId: string }): Promise { return getJSON('/api/tests/covered_files', data).then(r => r.files, throwGlobalError); } 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 d397c89345e..6e52132de85 100644 --- a/server/sonar-web/src/main/js/api/time-machine.ts +++ b/server/sonar-web/src/main/js/api/time-machine.ts @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getJSON } from '../helpers/request'; -import { Paging, BranchParameters } from '../app/types'; import throwGlobalError from '../app/utils/throwGlobalError'; interface TimeMachineResponse { @@ -26,7 +25,7 @@ interface TimeMachineResponse { metric: string; history: Array<{ date: string; value?: string }>; }[]; - paging: Paging; + paging: T.Paging; } export function getTimeMachineData( @@ -37,7 +36,7 @@ export function getTimeMachineData( p?: number; ps?: number; to?: string; - } & BranchParameters + } & T.BranchParameters ): Promise { return getJSON('/api/measures/search_history', data).catch(throwGlobalError); } @@ -49,7 +48,7 @@ export function getAllTimeMachineData( from?: string; p?: number; to?: string; - } & BranchParameters, + } & T.BranchParameters, prev?: TimeMachineResponse ): Promise { return getTimeMachineData({ ...data, ps: 1000 }).then(r => { 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 eadd920a5f0..d64fde6cf26 100644 --- a/server/sonar-web/src/main/js/api/user_groups.ts +++ b/server/sonar-web/src/main/js/api/user_groups.ts @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getJSON, post, postJSON } from '../helpers/request'; -import { Paging, Group } from '../app/types'; import throwGlobalError from '../app/utils/throwGlobalError'; export function searchUsersGroups(data: { @@ -27,7 +26,7 @@ export function searchUsersGroups(data: { p?: number; ps?: number; q?: string; -}): Promise<{ groups: Group[]; paging: Paging }> { +}): Promise<{ groups: T.Group[]; paging: T.Paging }> { return getJSON('/api/user_groups/search', data).catch(throwGlobalError); } @@ -45,7 +44,7 @@ export function getUsersInGroup(data: { ps?: number; q?: string; selected?: string; -}): Promise<{ paging: Paging; users: GroupUser[] }> { +}): Promise<{ paging: T.Paging; users: GroupUser[] }> { return getJSON('/api/user_groups/users', data).catch(throwGlobalError); } @@ -71,7 +70,7 @@ export function createGroup(data: { description?: string; organization: string | undefined; name: string; -}): Promise { +}): 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 1954f192c50..75405a9173f 100644 --- a/server/sonar-web/src/main/js/api/users.ts +++ b/server/sonar-web/src/main/js/api/users.ts @@ -19,9 +19,8 @@ */ import { getJSON, post, postJSON, RequestData } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; -import { Paging, HomePage, CurrentUser, IdentityProvider, User } from '../app/types'; -export function getCurrentUser(): Promise { +export function getCurrentUser(): Promise { return getJSON('/api/users/current'); } @@ -46,7 +45,7 @@ export function getUserGroups( organization?: string, query?: string, selected?: string -): Promise<{ paging: Paging; groups: UserGroup[] }> { +): Promise<{ paging: T.Paging; groups: UserGroup[] }> { const data: RequestData = { login }; if (organization) { data.organization = organization; @@ -60,7 +59,7 @@ export function getUserGroups( return getJSON('/api/users/groups', data); } -export function getIdentityProviders(): Promise<{ identityProviders: IdentityProvider[] }> { +export function getIdentityProviders(): Promise<{ identityProviders: T.IdentityProvider[] }> { return getJSON('/api/users/identity_providers').catch(throwGlobalError); } @@ -68,7 +67,7 @@ export function searchUsers(data: { p?: number; ps?: number; q?: string; -}): Promise<{ paging: Paging; users: User[] }> { +}): Promise<{ paging: T.Paging; users: T.User[] }> { data.q = data.q || undefined; return getJSON('/api/users/search', data).catch(throwGlobalError); } @@ -89,14 +88,14 @@ 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); } @@ -104,6 +103,6 @@ export function skipOnboarding(): Promise { return post('/api/users/skip_onboarding_tutorial').catch(throwGlobalError); } -export function setHomePage(homepage: HomePage): Promise { +export function setHomePage(homepage: T.HomePage): Promise { return post('/api/users/set_homepage', homepage).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 a51a01c0948..b3327608c25 100644 --- a/server/sonar-web/src/main/js/api/webhooks.ts +++ b/server/sonar-web/src/main/js/api/webhooks.ts @@ -19,14 +19,13 @@ */ import { getJSON, post, postJSON } from '../helpers/request'; import throwGlobalError from '../app/utils/throwGlobalError'; -import { Webhook, WebhookDelivery, Paging } from '../app/types'; export function createWebhook(data: { name: string; organization: string | undefined; project?: string; url: string; -}): Promise<{ webhook: Webhook }> { +}): Promise<{ webhook: T.Webhook }> { return postJSON('/api/webhooks/create', data).catch(throwGlobalError); } @@ -37,7 +36,7 @@ export function deleteWebhook(data: { webhook: string }): Promise { +}): Promise<{ webhooks: T.Webhook[] }> { return getJSON('/api/webhooks/list', data).catch(throwGlobalError); } @@ -56,14 +55,14 @@ export function searchDeliveries(data: { p?: number; ps?: number; }): Promise<{ - deliveries: WebhookDelivery[]; - paging: Paging; + deliveries: T.WebhookDelivery[]; + paging: T.Paging; }> { return getJSON('/api/webhooks/deliveries', data).catch(throwGlobalError); } export function getDelivery(data: { deliveryId: string; -}): Promise<{ delivery: WebhookDelivery & { payload: string } }> { +}): Promise<{ delivery: T.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 cb2d5b99709..6f65e1d4c26 100644 --- a/server/sonar-web/src/main/js/app/components/AdminContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/AdminContainer.tsx @@ -27,16 +27,15 @@ import { getAppState, Store } from '../../store/rootReducer'; import { getSettingsNavigation } from '../../api/nav'; import { setAdminPages } from '../../store/appState'; import { translate } from '../../helpers/l10n'; -import { Extension, AppState } from '../types'; import { PluginPendingResult, getPendingPlugins } from '../../api/plugins'; import handleRequiredAuthorization from '../utils/handleRequiredAuthorization'; interface StateProps { - appState: Pick; + appState: Pick; } interface DispatchToProps { - setAdminPages: (adminPages: Extension[]) => void; + setAdminPages: (adminPages: T.Extension[]) => void; } interface OwnProps { diff --git a/server/sonar-web/src/main/js/app/components/App.tsx b/server/sonar-web/src/main/js/app/components/App.tsx index df1277c2222..d3f99a4985b 100644 --- a/server/sonar-web/src/main/js/app/components/App.tsx +++ b/server/sonar-web/src/main/js/app/components/App.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import * as PropTypes from 'prop-types'; import { connect } from 'react-redux'; import Helmet from 'react-helmet'; -import { AppState, CurrentUser } from '../types'; import { fetchLanguages } from '../../store/rootActions'; import { fetchMyOrganizations } from '../../apps/account/organizations/actions'; import { getInstance, isSonarCloud } from '../../helpers/system'; @@ -32,8 +31,8 @@ import { isLoggedIn } from '../../helpers/users'; const PageTracker = lazyLoad(() => import('./PageTracker')); interface StateProps { - appState: AppState | undefined; - currentUser: CurrentUser | undefined; + appState: T.AppState | undefined; + currentUser: T.CurrentUser | undefined; enableGravatar: boolean; gravatarServerUrl: string; } 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 faea1ccdef2..1d458306d2b 100644 --- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx @@ -24,7 +24,6 @@ import { differenceBy } from 'lodash'; import { ComponentContext } from './ComponentContext'; import ComponentContainerNotFound from './ComponentContainerNotFound'; import ComponentNav from './nav/component/ComponentNav'; -import { Component, BranchLike, Measure, Task } from '../types'; import handleRequiredAuthorization from '../utils/handleRequiredAuthorization'; import { getBranches, getPullRequests } from '../../api/branches'; import { getTasksForComponent, getAnalysisStatus } from '../../api/ce'; @@ -51,14 +50,14 @@ interface Props { } interface State { - branchLike?: BranchLike; - branchLikes: BranchLike[]; - branchMeasures?: Measure[]; - component?: Component; - currentTask?: Task; + branchLike?: T.BranchLike; + branchLikes: T.BranchLike[]; + branchMeasures?: T.Measure[]; + component?: T.Component; + currentTask?: T.Task; isPending: boolean; loading: boolean; - tasksInProgress?: Task[]; + tasksInProgress?: T.Task[]; warnings: string[]; } @@ -97,7 +96,7 @@ export class ComponentContainer extends React.PureComponent { window.clearTimeout(this.watchStatusTimer); } - addQualifier = (component: Component) => ({ + addQualifier = (component: T.Component) => ({ ...component, qualifier: component.breadcrumbs[component.breadcrumbs.length - 1].qualifier }); @@ -147,11 +146,11 @@ export class ComponentContainer extends React.PureComponent { } fetchBranches = ( - component: Component + component: T.Component ): Promise<{ - branchLike?: BranchLike; - branchLikes: BranchLike[]; - component: Component; + branchLike?: T.BranchLike; + branchLikes: T.BranchLike[]; + component: T.Component; }> => { const application = component.breadcrumbs.find(({ qualifier }) => qualifier === 'APP'); if (application) { @@ -182,14 +181,14 @@ export class ComponentContainer extends React.PureComponent { branchLikes, component }: { - branchLike: BranchLike; - branchLikes: BranchLike[]; - component: Component; + branchLike: T.BranchLike; + branchLikes: T.BranchLike[]; + component: T.Component; }): Promise<{ - branchLike?: BranchLike; - branchLikes: BranchLike[]; - branchMeasures?: Measure[]; - component: Component; + branchLike?: T.BranchLike; + branchLikes: T.BranchLike[]; + branchMeasures?: T.Measure[]; + component: T.Component; }> => { const project = component.breadcrumbs.find(({ qualifier }) => qualifier === 'TRK'); if (project && (isShortLivingBranch(branchLike) || isPullRequest(branchLike))) { @@ -204,7 +203,7 @@ export class ComponentContainer extends React.PureComponent { return Promise.resolve({ branchLike, branchLikes, component }); }; - fetchStatus = (component: Component) => { + fetchStatus = (component: T.Component) => { getTasksForComponent(component.key).then( ({ current, queue }) => { if (this.mounted) { @@ -257,7 +256,7 @@ export class ComponentContainer extends React.PureComponent { ); }; - fetchWarnings = (component: Component, branchLike?: BranchLike) => { + fetchWarnings = (component: T.Component, branchLike?: T.BranchLike) => { if (component.qualifier === 'TRK') { getAnalysisStatus({ component: component.key, @@ -271,14 +270,14 @@ export class ComponentContainer extends React.PureComponent { } }; - getCurrentBranchLike = (branchLikes: BranchLike[]) => { + getCurrentBranchLike = (branchLikes: T.BranchLike[]) => { const { query } = this.props.location; return query.pullRequest ? branchLikes.find(b => isPullRequest(b) && b.key === query.pullRequest) : branchLikes.find(b => isBranch(b) && (query.branch ? b.name === query.branch : b.isMain)); }; - getCurrentTask = (current: Task, branchLike?: BranchLike) => { + getCurrentTask = (current: T.Task, branchLike?: T.BranchLike) => { if (!current) { return undefined; } @@ -288,13 +287,13 @@ export class ComponentContainer extends React.PureComponent { : undefined; }; - getPendingTasks = (pendingTasks: Task[], branchLike?: BranchLike) => { + getPendingTasks = (pendingTasks: T.Task[], branchLike?: T.BranchLike) => { return pendingTasks.filter(task => this.isSameBranch(task, branchLike)); }; isSameBranch = ( - task: Pick, - branchLike?: BranchLike + task: Pick, + branchLike?: T.BranchLike ) => { if (branchLike && !isMainBranch(branchLike)) { if (isPullRequest(branchLike)) { @@ -307,11 +306,11 @@ export class ComponentContainer extends React.PureComponent { return !task.branch && !task.pullRequest; }; - handleComponentChange = (changes: Partial) => { + handleComponentChange = (changes: Partial) => { if (this.mounted) { this.setState(state => { if (state.component) { - const newComponent: Component = { ...state.component, ...changes }; + const newComponent: T.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 b62a351cd3f..a7f5f1ffa20 100644 --- a/server/sonar-web/src/main/js/app/components/ComponentContext.tsx +++ b/server/sonar-web/src/main/js/app/components/ComponentContext.tsx @@ -18,11 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Component, BranchLike } from '../types'; interface ComponentContextType { - branchLike: BranchLike | undefined; - component: Component | undefined; + branchLike: T.BranchLike | undefined; + component: T.Component | undefined; } export const ComponentContext = React.createContext({ diff --git a/server/sonar-web/src/main/js/app/components/GlobalFooter.tsx b/server/sonar-web/src/main/js/app/components/GlobalFooter.tsx index be0881f79df..b426464f053 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalFooter.tsx +++ b/server/sonar-web/src/main/js/app/components/GlobalFooter.tsx @@ -22,7 +22,7 @@ import { Link } from 'react-router'; import GlobalFooterSonarCloud from './GlobalFooterSonarCloud'; import GlobalFooterBranding from './GlobalFooterBranding'; import InstanceMessage from '../../components/common/InstanceMessage'; -import { EDITIONS, EditionKey } from '../../apps/marketplace/utils'; +import { EDITIONS } from '../../apps/marketplace/utils'; import { translate, translateWithParameters } from '../../helpers/l10n'; import { isSonarCloud } from '../../helpers/system'; import { Alert } from '../../components/ui/Alert'; @@ -30,7 +30,7 @@ import { Alert } from '../../components/ui/Alert'; interface Props { hideLoggedInInfo?: boolean; productionDatabase: boolean; - sonarqubeEdition?: EditionKey; + sonarqubeEdition?: T.EditionKey; sonarqubeVersion?: string; } diff --git a/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.tsx b/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.tsx index 158478034d5..c10498eae7a 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/GlobalFooterContainer.tsx @@ -20,11 +20,10 @@ import { connect } from 'react-redux'; import GlobalFooter from './GlobalFooter'; import { getAppState, Store } from '../../store/rootReducer'; -import { EditionKey } from '../../apps/marketplace/utils'; interface StateProps { productionDatabase: boolean; - sonarqubeEdition?: EditionKey; + sonarqubeEdition?: T.EditionKey; sonarqubeVersion?: string; } 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 421c6cceb7c..310d2f27629 100644 --- a/server/sonar-web/src/main/js/app/components/Landing.tsx +++ b/server/sonar-web/src/main/js/app/components/Landing.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import * as PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { Location } from 'history'; -import { CurrentUser } from '../types'; import { getCurrentUser, Store } from '../../store/rootReducer'; import { getHomePageUrl } from '../../helpers/urls'; import { isLoggedIn } from '../../helpers/users'; interface StateProps { - currentUser: CurrentUser | undefined; + currentUser: T.CurrentUser | undefined; } interface OwnProps { 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 e2293316ea9..8ae7a52196c 100644 --- a/server/sonar-web/src/main/js/app/components/ProjectAdminContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/ProjectAdminContainer.tsx @@ -19,13 +19,12 @@ */ import * as React from 'react'; import handleRequiredAuthorization from '../utils/handleRequiredAuthorization'; -import { BranchLike, Component } from '../types'; interface Props { children: JSX.Element; - branchLike?: BranchLike; - branchLikes: BranchLike[]; - component: Component; + branchLike?: T.BranchLike; + branchLikes: T.BranchLike[]; + component: T.Component; isInProgress?: boolean; isPending?: boolean; onBranchesChange: () => void; 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 db691307413..bb92eb2c447 100644 --- a/server/sonar-web/src/main/js/app/components/StartupModal.tsx +++ b/server/sonar-web/src/main/js/app/components/StartupModal.tsx @@ -21,9 +21,7 @@ import * as React from 'react'; import * as PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { withRouter, WithRouterProps } from 'react-router'; -import { CurrentUser, Organization } from '../types'; import { differenceInDays, parseDate, toShortNotSoISOString } from '../../helpers/dates'; -import { EditionKey } from '../../apps/marketplace/utils'; import { getCurrentUser, getAppState, Store } from '../../store/rootReducer'; import { skipOnboarding } from '../../store/users'; import { showLicense } from '../../api/marketplace'; @@ -48,8 +46,8 @@ const TeamOnboardingModal = lazyLoad(() => interface StateProps { canAdmin?: boolean; - currentEdition?: EditionKey; - currentUser: CurrentUser; + currentEdition?: T.EditionKey; + currentUser: T.CurrentUser; } interface DispatchProps { @@ -119,7 +117,7 @@ export class StartupModal extends React.PureComponent { this.props.router.push({ pathname: '/create-organization', state: { paid: true } }); }; - openProjectOnboarding = (organization?: Organization) => { + openProjectOnboarding = (organization?: T.Organization) => { if (isSonarCloud()) { this.setState({ automatic: false, modal: undefined }); const state: { organization?: string; tab?: string } = {}; @@ -140,7 +138,7 @@ export class StartupModal extends React.PureComponent { tryAutoOpenLicense = () => { const { canAdmin, currentEdition, currentUser } = this.props; const hasLicenseManager = hasMessage('license.prompt.title'); - const hasLicensedEdition = currentEdition && currentEdition !== EditionKey.community; + const hasLicensedEdition = currentEdition && currentEdition !== 'community'; if (canAdmin && hasLicensedEdition && isLoggedIn(currentUser) && hasLicenseManager) { const lastPrompt = get(LICENSE_PROMPT, currentUser.login); 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 e37029c0b64..f78e8ea0189 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 @@ -24,16 +24,6 @@ import { getBranches, getPullRequests } from '../../../api/branches'; import { getTasksForComponent } from '../../../api/ce'; import { getComponentData } from '../../../api/components'; import { getComponentNavigation } from '../../../api/nav'; -import { - ShortLivingBranch, - MainBranch, - LongLivingBranch, - PullRequest, - BranchType, - Visibility, - Task, - Component -} from '../../types'; import { STATUSES } from '../../../apps/background-tasks/constants'; import { waitAndUpdate } from '../../../helpers/testUtils'; import { getMeasures } from '../../../api/measures'; @@ -93,12 +83,12 @@ it('changes component', () => { wrapper.instance().mounted = true; wrapper.setState({ branchLikes: [{ isMain: true, name: 'master' }], - component: { qualifier: 'TRK', visibility: Visibility.Public } as Component, + component: { qualifier: 'TRK', visibility: 'public' } as T.Component, loading: false }); - (wrapper.find(Inner).prop('onComponentChange') as Function)({ visibility: Visibility.Private }); - expect(wrapper.state().component).toEqual({ qualifier: 'TRK', visibility: Visibility.Private }); + (wrapper.find(Inner).prop('onComponentChange') as Function)({ visibility: 'private' }); + expect(wrapper.state().component).toEqual({ qualifier: 'TRK', visibility: 'private' }); }); it("loads branches for module's project", async () => { @@ -164,7 +154,7 @@ it('updates the branch measures', async () => { key: 'foo' }); (getBranches as jest.Mock).mockResolvedValueOnce([ - { isMain: false, mergeBranch: 'master', name: 'feature', type: BranchType.SHORT } + { isMain: false, mergeBranch: 'master', name: 'feature', type: 'SHORT' } ]); (getPullRequests as jest.Mock).mockResolvedValueOnce([]); const wrapper = shallow( @@ -229,15 +219,19 @@ it('filters correctly the pending tasks for a main branch', () => { ); const component = wrapper.instance() as ComponentContainer; - const mainBranch: MainBranch = { isMain: true, name: 'master' }; - const shortBranch: ShortLivingBranch = { + const mainBranch: T.MainBranch = { isMain: true, name: 'master' }; + const shortBranch: T.ShortLivingBranch = { isMain: false, mergeBranch: 'master', name: 'feature', - type: BranchType.SHORT + type: 'SHORT' }; - const longBranch: LongLivingBranch = { isMain: false, name: 'branch-7.2', type: BranchType.LONG }; - const pullRequest: PullRequest = { + const longBranch: T.LongLivingBranch = { + isMain: false, + name: 'branch-7.2', + type: 'LONG' + }; + const pullRequest: T.PullRequest = { base: 'feature', branch: 'feature', key: 'pr-89', @@ -264,12 +258,12 @@ it('filters correctly the pending tasks for a main branch', () => { ).toBeFalsy(); expect(component.isSameBranch({ pullRequest: 'pr-89' }, pullRequest)).toBeTruthy(); - const currentTask = { pullRequest: 'pr-89', status: STATUSES.IN_PROGRESS } as Task; + const currentTask = { pullRequest: 'pr-89', status: STATUSES.IN_PROGRESS } as T.Task; const failedTask = { ...currentTask, status: STATUSES.FAILED }; const pendingTasks = [ currentTask, - { branch: 'feature', branchType: 'SHORT' } as Task, - {} as Task + { branch: 'feature', branchType: 'SHORT' } as T.Task, + {} as T.Task ]; expect(component.getCurrentTask(currentTask, undefined)).toBe(undefined); expect(component.getCurrentTask(failedTask, mainBranch)).toBe(failedTask); @@ -281,7 +275,7 @@ it('filters correctly the pending tasks for a main branch', () => { it('reload component after task progress finished', async () => { jest.useFakeTimers(); - const inProgressTask = { id: 'foo', status: STATUSES.IN_PROGRESS } as Task; + const inProgressTask = { id: 'foo', status: STATUSES.IN_PROGRESS } as T.Task; (getTasksForComponent as jest.Mock).mockResolvedValueOnce({ queue: [inProgressTask] }); const wrapper = shallow( 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 4e4691f0d85..5632c136274 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 @@ -27,7 +27,6 @@ import { save, get } from '../../../helpers/storage'; import { hasMessage } from '../../../helpers/l10n'; import { waitAndUpdate, mockRouter } from '../../../helpers/testUtils'; import { differenceInDays, toShortNotSoISOString } from '../../../helpers/dates'; -import { LoggedInUser } from '../../types'; import { EditionKey } from '../../../apps/marketplace/utils'; jest.mock('../../../api/marketplace', () => ({ @@ -49,7 +48,7 @@ jest.mock('../../../helpers/dates', () => ({ toShortNotSoISOString: jest.fn().mockReturnValue('short-not-iso-date') })); -const LOGGED_IN_USER: LoggedInUser = { +const LOGGED_IN_USER: T.LoggedInUser = { groups: [], isLoggedIn: true, login: 'luke', 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 e67237255c3..b3e6c9343ec 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 @@ -25,10 +25,9 @@ import { injectIntl, InjectedIntlProps } from 'react-intl'; import { getExtensionStart } from './utils'; import { translate } from '../../../helpers/l10n'; import getStore from '../../utils/getStore'; -import { CurrentUser } from '../../types'; interface OwnProps { - currentUser: CurrentUser; + currentUser: T.CurrentUser; extension: { key: string; name: string }; onFail: (message: string) => void; options?: {}; 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 e479fbc7537..8db930dd62b 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 @@ -21,11 +21,10 @@ import * as React from 'react'; import { connect } from 'react-redux'; import ExtensionContainer from './ExtensionContainer'; import NotFound from '../NotFound'; -import { Extension } from '../../types'; import { getAppState, Store } from '../../../store/rootReducer'; interface Props { - adminPages: Extension[] | undefined; + adminPages: T.Extension[] | 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 8d7d535333b..b37ac541bea 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 @@ -22,10 +22,9 @@ import { connect } from 'react-redux'; import ExtensionContainer from './ExtensionContainer'; import NotFound from '../NotFound'; import { getAppState, Store } from '../../../store/rootReducer'; -import { Extension } from '../../types'; interface Props { - globalPages: Extension[] | undefined; + globalPages: T.Extension[] | undefined; params: { extensionKey: string; pluginKey: string }; } diff --git a/server/sonar-web/src/main/js/app/components/extensions/OrganizationPageExtension.tsx b/server/sonar-web/src/main/js/app/components/extensions/OrganizationPageExtension.tsx index 56eef2983dc..16ae71708ac 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/OrganizationPageExtension.tsx +++ b/server/sonar-web/src/main/js/app/components/extensions/OrganizationPageExtension.tsx @@ -23,10 +23,9 @@ import ExtensionContainer from './ExtensionContainer'; import NotFound from '../NotFound'; import { getOrganizationByKey, Store } from '../../../store/rootReducer'; import { fetchOrganization } from '../../../apps/organizations/actions'; -import { Organization } from '../../types'; interface StateToProps { - organization?: Organization; + organization?: T.Organization; } interface DispatchProps { 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 d4fb48cc14d..9502e405b63 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 @@ -23,10 +23,9 @@ import { Location } from 'history'; import ExtensionContainer from './ExtensionContainer'; import NotFound from '../NotFound'; import { addGlobalErrorMessage } from '../../../store/globalMessages'; -import { Component } from '../../types'; interface Props { - component: Component; + component: T.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 df6c0f88e90..ada4b4f3e69 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 @@ -20,10 +20,9 @@ import * as React from 'react'; import ExtensionContainer from './ExtensionContainer'; import NotFound from '../NotFound'; -import { Component } from '../../types'; interface Props { - component: Component; + component: T.Component; location: { query: { id: string } }; params: { extensionKey: string; 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 89561422d42..c25f240f1ab 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 @@ -24,17 +24,16 @@ import ComponentNavMenu from './ComponentNavMenu'; import ComponentNavBgTaskNotif from './ComponentNavBgTaskNotif'; import RecentHistory from '../../RecentHistory'; import * as theme from '../../../theme'; -import { BranchLike, Component, Measure, Task } from '../../../types'; import ContextNavBar from '../../../../components/nav/ContextNavBar'; import { STATUSES } from '../../../../apps/background-tasks/constants'; import './ComponentNav.css'; interface Props { - branchLikes: BranchLike[]; - branchMeasures?: Measure[]; - currentBranchLike: BranchLike | undefined; - component: Component; - currentTask?: Task; + branchLikes: T.BranchLike[]; + branchMeasures?: T.Measure[]; + currentBranchLike: T.BranchLike | undefined; + component: T.Component; + currentTask?: T.Task; currentTaskOnSameBranch?: boolean; isInProgress?: boolean; isPending?: boolean; 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 86ca810dcfd..6a0828e4fa1 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 @@ -23,14 +23,13 @@ import { FormattedMessage } from 'react-intl'; import ComponentNavLicenseNotif from './ComponentNavLicenseNotif'; import NavBarNotif from '../../../../components/nav/NavBarNotif'; import PendingIcon from '../../../../components/icons-components/PendingIcon'; -import { Component, Task } from '../../../types'; import { STATUSES } from '../../../../apps/background-tasks/constants'; import { getComponentBackgroundTaskUrl } from '../../../../helpers/urls'; import { hasMessage, translate } from '../../../../helpers/l10n'; interface Props { - component: Component; - currentTask?: Task; + component: T.Component; + currentTask?: T.Task; currentTaskOnSameBranch?: boolean; isInProgress?: boolean; isPending?: boolean; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranch.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranch.tsx index fbdad095b35..8fee54db550 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranch.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranch.tsx @@ -23,7 +23,6 @@ import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; import ComponentNavBranchesMenu from './ComponentNavBranchesMenu'; import DocTooltip from '../../../../components/docs/DocTooltip'; -import { BranchLike, Component } from '../../../types'; import * as theme from '../../../theme'; import BranchIcon from '../../../../components/icons-components/BranchIcon'; import { @@ -41,9 +40,9 @@ import { isSonarCloud } from '../../../../helpers/system'; import { getPortfolioAdminUrl } from '../../../../helpers/urls'; interface Props { - branchLikes: BranchLike[]; - component: Component; - currentBranchLike: BranchLike; + branchLikes: T.BranchLike[]; + component: T.Component; + currentBranchLike: T.BranchLike; location?: any; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenu.tsx index c599dda07d9..5f876d1a6f6 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenu.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenu.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import * as PropTypes from 'prop-types'; import { Link } from 'react-router'; import ComponentNavBranchesMenuItem from './ComponentNavBranchesMenuItem'; -import { BranchLike, Component } from '../../../types'; import { sortBranchesAsTree, isLongLivingBranch, @@ -39,16 +38,16 @@ import HelpTooltip from '../../../../components/controls/HelpTooltip'; import { DropdownOverlay } from '../../../../components/controls/Dropdown'; interface Props { - branchLikes: BranchLike[]; + branchLikes: T.BranchLike[]; canAdmin?: boolean; - component: Component; - currentBranchLike: BranchLike; + component: T.Component; + currentBranchLike: T.BranchLike; onClose: () => void; } interface State { query: string; - selected: BranchLike | undefined; + selected: T.BranchLike | undefined; } export default class ComponentNavBranchesMenu extends React.PureComponent { @@ -136,7 +135,7 @@ export default class ComponentNavBranchesMenu extends React.PureComponent { + handleSelect = (branchLike: T.BranchLike) => { this.setState({ selected: branchLike }); }; @@ -157,10 +156,10 @@ export default class ComponentNavBranchesMenu extends React.PureComponent + getProjectBranchUrl = (branchLike: T.BranchLike) => getBranchLikeUrl(this.props.component.key, branchLike); - isOrphan = (branchLike: BranchLike) => { + isOrphan = (branchLike: T.BranchLike) => { return (isShortLivingBranch(branchLike) || isPullRequest(branchLike)) && branchLike.isOrphan; }; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenuItem.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenuItem.tsx index 204014a567e..d702f959584 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenuItem.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenuItem.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { Link } from 'react-router'; import * as classNames from 'classnames'; import BranchStatus from '../../../../components/common/BranchStatus'; -import { BranchLike, Component } from '../../../types'; import BranchIcon from '../../../../components/icons-components/BranchIcon'; import { isShortLivingBranch, @@ -34,9 +33,9 @@ import { translate } from '../../../../helpers/l10n'; import { getBranchLikeUrl } from '../../../../helpers/urls'; export interface Props { - branchLike: BranchLike; - component: Component; - onSelect: (branchLike: BranchLike) => void; + branchLike: T.BranchLike; + component: T.Component; + onSelect: (branchLike: T.BranchLike) => void; selected: boolean; innerRef?: (node: HTMLLIElement) => void; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx index f3301290cd3..6e847bd13bd 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { Link } from 'react-router'; import ComponentNavBranch from './ComponentNavBranch'; -import { Component, Organization, BranchLike, Breadcrumb } from '../../../types'; import QualifierIcon from '../../../../components/icons-components/QualifierIcon'; import { getOrganizationByKey, @@ -37,14 +36,14 @@ import { getProjectUrl, getBaseUrl } from '../../../../helpers/urls'; import { isSonarCloud } from '../../../../helpers/system'; interface StateProps { - organization?: Organization; + organization?: T.Organization; shouldOrganizationBeDisplayed?: boolean; } interface OwnProps { - branchLikes: BranchLike[]; - component: Component; - currentBranchLike: BranchLike | undefined; + branchLikes: T.BranchLike[]; + component: T.Component; + currentBranchLike: T.BranchLike | undefined; location?: any; } @@ -101,7 +100,7 @@ export function ComponentNavHeader(props: Props) { ); } -function renderBreadcrumbs(breadcrumbs: Breadcrumb[]) { +function renderBreadcrumbs(breadcrumbs: T.Breadcrumb[]) { const lastItem = breadcrumbs[breadcrumbs.length - 1]; return breadcrumbs.map((item, index) => { const isPath = item.qualifier === 'DIR'; 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 1fc44c1cbbb..116cb1489fa 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 @@ -23,10 +23,9 @@ import * as PropTypes from 'prop-types'; import NavBarNotif from '../../../../components/nav/NavBarNotif'; import { translate } from '../../../../helpers/l10n'; import { isValidLicense } from '../../../../api/marketplace'; -import { Task } from '../../../types'; interface Props { - currentTask?: Task; + currentTask?: T.Task; } interface State { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.tsx index 80bebedbd02..1499680b2a8 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMenu.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { Link } from 'react-router'; import * as classNames from 'classnames'; import * as PropTypes from 'prop-types'; -import { BranchLike, Component, Extension } from '../../../types'; import Dropdown from '../../../../components/controls/Dropdown'; import NavBarTabs from '../../../../components/nav/NavBarTabs'; import { @@ -50,8 +49,8 @@ const SETTINGS_URLS = [ ]; interface Props { - branchLike: BranchLike | undefined; - component: Component; + branchLike: T.BranchLike | undefined; + component: T.Component; location?: any; } @@ -443,7 +442,7 @@ export default class ComponentNavMenu extends React.PureComponent { ); } - renderExtension = ({ key, name }: Extension, isAdmin: boolean) => { + renderExtension = ({ key, name }: T.Extension, isAdmin: boolean) => { const pathname = isAdmin ? `/project/admin/extension/${key}` : `/project/extension/${key}`; const query = { id: this.props.component.key, qualifier: this.props.component.qualifier }; return ( diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx index a3093d3e2fb..f7c559de6a3 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx @@ -20,14 +20,6 @@ import * as React from 'react'; import { connect } from 'react-redux'; import ComponentNavWarnings from './ComponentNavWarnings'; -import { - BranchLike, - Component, - CurrentUser, - HomePageType, - HomePage, - Measure -} from '../../../types'; import BranchMeasures from '../../../../components/common/BranchMeasures'; import BranchStatus from '../../../../components/common/BranchStatus'; import DateTimeFormatter from '../../../../components/intl/DateTimeFormatter'; @@ -46,13 +38,13 @@ import { isLoggedIn } from '../../../../helpers/users'; import { getCurrentUser, Store } from '../../../../store/rootReducer'; interface StateProps { - currentUser: CurrentUser; + currentUser: T.CurrentUser; } interface Props extends StateProps { - branchLike?: BranchLike; - branchMeasures?: Measure[]; - component: Component; + branchLike?: T.BranchLike; + branchMeasures?: T.Measure[]; + component: T.Component; warnings: string[]; } @@ -129,17 +121,17 @@ export function ComponentNavMeta({ ); } -function getCurrentPage(component: Component, branchLike: BranchLike | undefined) { - let currentPage: HomePage | undefined; +function getCurrentPage(component: T.Component, branchLike: T.BranchLike | undefined) { + let currentPage: T.HomePage | undefined; if (component.qualifier === 'VW' || component.qualifier === 'SVW') { - currentPage = { type: HomePageType.Portfolio, component: component.key }; + currentPage = { type: 'PORTFOLIO', component: component.key }; } else if (component.qualifier === 'APP') { const branch = isLongLivingBranch(branchLike) ? branchLike.name : undefined; - currentPage = { type: HomePageType.Application, component: component.key, branch }; + currentPage = { type: 'APPLICATION', component: component.key, branch }; } else if (component.qualifier === 'TRK') { // when home page is set to the default branch of a project, its name is returned as `undefined` const branch = isLongLivingBranch(branchLike) ? branchLike.name : undefined; - currentPage = { type: HomePageType.Project, component: component.key, branch }; + currentPage = { type: 'PROJECT', component: component.key, branch }; } return currentPage; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx index 0843db6b9df..2010ef6f8ab 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx @@ -27,7 +27,6 @@ jest.mock('../../../../../helpers/l10n', () => { import * as React from 'react'; import { shallow } from 'enzyme'; import ComponentNavBgTaskNotif from '../ComponentNavBgTaskNotif'; -import { Task } from '../../../../types'; const component = { analysisDate: '2017-01-02T00:00:00.000Z', @@ -46,7 +45,7 @@ it('renders background task error correctly', () => { it('renders background task error correctly for a different branch/PR', () => { expect( getWrapper({ - currentTask: { branch: 'my/branch', status: 'FAILED' } as Task, + currentTask: { branch: 'my/branch', status: 'FAILED' } as T.Task, currentTaskOnSameBranch: false }) ).toMatchSnapshot(); @@ -56,7 +55,7 @@ it('renders background task error correctly for a different branch/PR', () => { pullRequest: '650', pullRequestTitle: 'feature/my_pr', status: 'FAILED' - } as Task, + } as T.Task, currentTaskOnSameBranch: false }) ).toMatchSnapshot(); @@ -89,7 +88,7 @@ function getWrapper(props = {}) { return shallow( ); diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBranch-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBranch-test.tsx index 3fd20dbc41e..17c44b1beb9 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBranch-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBranch-test.tsx @@ -20,28 +20,20 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ComponentNavBranch from '../ComponentNavBranch'; -import { - BranchType, - ShortLivingBranch, - MainBranch, - Component, - LongLivingBranch, - PullRequest -} from '../../../../types'; import { click } from '../../../../../helpers/testUtils'; import { isSonarCloud } from '../../../../../helpers/system'; jest.mock('../../../../../helpers/system', () => ({ isSonarCloud: jest.fn() })); -const mainBranch: MainBranch = { isMain: true, name: 'master' }; -const fooBranch: LongLivingBranch = { isMain: false, name: 'foo', type: BranchType.LONG }; +const mainBranch: T.MainBranch = { isMain: true, name: 'master' }; +const fooBranch: T.LongLivingBranch = { isMain: false, name: 'foo', type: 'LONG' }; beforeEach(() => { (isSonarCloud as jest.Mock).mockImplementation(() => false); }); it('renders main branch', () => { - const component = {} as Component; + const component = {} as T.Component; expect( shallow( { }); it('renders short-living branch', () => { - const branch: ShortLivingBranch = { + const branch: T.ShortLivingBranch = { isMain: false, mergeBranch: 'master', name: 'foo', status: { bugs: 0, codeSmells: 0, qualityGateStatus: 'OK', vulnerabilities: 0 }, - type: BranchType.SHORT + type: 'SHORT' }; - const component = {} as Component; + const component = {} as T.Component; expect( shallow( { }); it('renders pull request', () => { - const pullRequest: PullRequest = { + const pullRequest: T.PullRequest = { base: 'master', branch: 'feature', key: '1234', title: 'Feature PR', url: 'https://example.com/pull/1234' }; - const component = {} as Component; + const component = {} as T.Component; expect( shallow( { }); it('opens menu', () => { - const component = {} as Component; + const component = {} as T.Component; const wrapper = shallow( { }); it('renders single branch popup', () => { - const component = {} as Component; + const component = {} as T.Component; const wrapper = shallow( { }); it('renders no branch support popup', () => { - const component = {} as Component; + const component = {} as T.Component; const wrapper = shallow( { it('renders nothing on SonarCloud without branch support', () => { (isSonarCloud as jest.Mock).mockImplementation(() => true); - const component = {} as Component; + const component = {} as T.Component; const wrapper = shallow( { expect( @@ -90,26 +82,26 @@ it('selects next & previous', () => { expect(wrapper.state().selected).toEqual(shortBranch('foo')); }); -function mainBranch(): MainBranch { +function mainBranch(): T.MainBranch { return { isMain: true, name: 'master' }; } -function shortBranch(name: string, isOrphan?: true): ShortLivingBranch { +function shortBranch(name: string, isOrphan?: true): T.ShortLivingBranch { return { isMain: false, isOrphan, mergeBranch: 'master', name, status: { bugs: 0, codeSmells: 0, qualityGateStatus: 'OK', vulnerabilities: 0 }, - type: BranchType.SHORT + type: 'SHORT' }; } -function longBranch(name: string): LongLivingBranch { - return { isMain: false, name, type: BranchType.LONG }; +function longBranch(name: string): T.LongLivingBranch { + return { isMain: false, name, type: 'LONG' }; } -function pullRequest(title: string): PullRequest { +function pullRequest(title: string): T.PullRequest { return { base: 'master', branch: 'feature', diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBranchesMenuItem-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBranchesMenuItem-test.tsx index 01995e7f92d..7415b1ffa14 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBranchesMenuItem-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBranchesMenuItem-test.tsx @@ -20,19 +20,18 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ComponentNavBranchesMenuItem, { Props } from '../ComponentNavBranchesMenuItem'; -import { BranchType, MainBranch, ShortLivingBranch, Component } from '../../../../types'; -const component = { key: 'component' } as Component; +const component = { key: 'component' } as T.Component; -const shortBranch: ShortLivingBranch = { +const shortBranch: T.ShortLivingBranch = { isMain: false, mergeBranch: 'master', name: 'foo', status: { bugs: 1, codeSmells: 2, qualityGateStatus: 'ERROR', vulnerabilities: 3 }, - type: BranchType.SHORT + type: 'SHORT' }; -const mainBranch: MainBranch = { isMain: true, name: 'master' }; +const mainBranch: T.MainBranch = { isMain: true, name: 'master' }; it('renders main branch', () => { expect(shallowRender({ branchLike: mainBranch })).toMatchSnapshot(); @@ -43,7 +42,7 @@ it('renders short-living branch', () => { }); it('renders short-living orhpan branch', () => { - const orhpan: ShortLivingBranch = { ...shortBranch, isOrphan: true }; + const orhpan: T.ShortLivingBranch = { ...shortBranch, isOrphan: true }; expect(shallowRender({ branchLike: orhpan })).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavHeader-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavHeader-test.tsx index 2d1dd8d5f65..d28d94a1e11 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavHeader-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavHeader-test.tsx @@ -20,26 +20,25 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ComponentNavHeader } from '../ComponentNavHeader'; -import { Visibility } from '../../../../types'; import { isSonarCloud } from '../../../../../helpers/system'; jest.mock('../../../../../helpers/system', () => ({ isSonarCloud: jest.fn().mockReturnValue(false) })); -const component = { +const component: T.Component = { breadcrumbs: [{ key: 'my-project', name: 'My Project', qualifier: 'TRK' }], key: 'my-project', name: 'My Project', organization: 'foo', qualifier: 'TRK', - visibility: Visibility.Public + visibility: 'public' }; -const organization = { +const organization: T.Organization = { key: 'foo', name: 'The Foo Organization', - projectVisibility: Visibility.Public + projectVisibility: 'public' }; it('should not render breadcrumbs with one element', () => { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavLicenseNotif-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavLicenseNotif-test.tsx index c2440b8e197..8528a2701f7 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavLicenseNotif-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavLicenseNotif-test.tsx @@ -22,7 +22,6 @@ import { shallow } from 'enzyme'; import ComponentNavLicenseNotif from '../ComponentNavLicenseNotif'; import { isValidLicense } from '../../../../../api/marketplace'; import { waitAndUpdate } from '../../../../../helpers/testUtils'; -import { Task } from '../../../../types'; jest.mock('../../../../../helpers/l10n', () => { const l10n = require.requireActual('../../../../../helpers/l10n'); @@ -74,7 +73,7 @@ it('renders correctly for LICENSING_LOC error', async () => { function getWrapper(props = {}, context = {}) { return shallow( , { context: { canAdmin: true, ...context } } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx index a7b7bb95953..992673fb9b3 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMenu-test.tsx @@ -20,9 +20,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ComponentNavMenu from '../ComponentNavMenu'; -import { ShortLivingBranch, BranchType, LongLivingBranch, MainBranch } from '../../../../types'; -const mainBranch: MainBranch = { isMain: true, name: 'master' }; +const mainBranch: T.MainBranch = { isMain: true, name: 'master' }; const baseComponent = { breadcrumbs: [], @@ -65,11 +64,11 @@ it('should work with multiple extensions', () => { }); it('should work for short-living branches', () => { - const branch: ShortLivingBranch = { + const branch: T.ShortLivingBranch = { isMain: false, mergeBranch: 'master', name: 'feature', - type: BranchType.SHORT + type: 'SHORT' }; const component = { ...baseComponent, @@ -84,7 +83,7 @@ it('should work for short-living branches', () => { }); it('should work for long-living branches', () => { - const branch: LongLivingBranch = { isMain: false, name: 'release', type: BranchType.LONG }; + const branch: T.LongLivingBranch = { isMain: false, name: 'release', type: 'LONG' }; [true, false].forEach(showSettings => expect( shallow( diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx index fd9e6180817..6e0c12c3928 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ComponentNavMeta } from '../ComponentNavMeta'; -import { BranchType, ShortLivingBranch, LongLivingBranch, PullRequest } from '../../../../types'; const COMPONENT = { analysisDate: '2017-01-02T00:00:00.000Z', @@ -38,12 +37,12 @@ const MEASURES = [ ]; it('renders status of short-living branch', () => { - const branch: ShortLivingBranch = { + const branch: T.ShortLivingBranch = { isMain: false, mergeBranch: 'master', name: 'feature', status: { bugs: 0, codeSmells: 2, qualityGateStatus: 'ERROR', vulnerabilities: 3 }, - type: BranchType.SHORT + type: 'SHORT' }; expect( shallow( @@ -59,11 +58,11 @@ it('renders status of short-living branch', () => { }); it('renders meta for long-living branch', () => { - const branch: LongLivingBranch = { + const branch: T.LongLivingBranch = { isMain: false, name: 'release', status: { qualityGateStatus: 'OK' }, - type: BranchType.LONG + type: 'LONG' }; expect( shallow( @@ -78,7 +77,7 @@ it('renders meta for long-living branch', () => { }); it('renders meta for pull request', () => { - const pullRequest: PullRequest = { + const pullRequest: T.PullRequest = { base: 'master', branch: 'feature', key: '1234', 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 67cda337eae..e5b1ff86885 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 @@ -27,7 +27,6 @@ import GlobalNavUserContainer from './GlobalNavUserContainer'; import Search from '../../search/Search'; import EmbedDocsPopupHelper from '../../embed-docs-modal/EmbedDocsPopupHelper'; import * as theme from '../../../theme'; -import { CurrentUser, AppState } from '../../../types'; import NavBar from '../../../../components/nav/NavBar'; import { lazyLoad } from '../../../../components/lazyLoad'; import { getCurrentUser, getAppState, Store } from '../../../../store/rootReducer'; @@ -39,8 +38,8 @@ import './GlobalNav.css'; const GlobalNavPlus = lazyLoad(() => import('./GlobalNavPlus'), 'GlobalNavPlus'); interface StateProps { - appState: Pick; - currentUser: CurrentUser; + appState: Pick; + currentUser: T.CurrentUser; } interface OwnProps { 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 418dd16875d..39cc87251a2 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 @@ -20,7 +20,6 @@ import * as React from 'react'; import * as classNames from 'classnames'; import { Link } from 'react-router'; -import { CurrentUser, AppState, Extension } from '../../../types'; import { translate } from '../../../../helpers/l10n'; import { getQualityGatesUrl, getBaseUrl } from '../../../../helpers/urls'; import { isMySet } from '../../../../apps/issues/utils'; @@ -30,8 +29,8 @@ import { isSonarCloud } from '../../../../helpers/system'; import { isLoggedIn } from '../../../../helpers/users'; interface Props { - appState: Pick; - currentUser: CurrentUser; + appState: Pick; + currentUser: T.CurrentUser; location: { pathname: string }; } @@ -144,7 +143,7 @@ export default class GlobalNavMenu extends React.PureComponent { ); } - renderGlobalPageLink = ({ key, name }: Extension) => { + renderGlobalPageLink = ({ key, name }: T.Extension) => { return (
  • {name} diff --git a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx index a0267f7197e..8017304aa58 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/GlobalNavPlus.tsx @@ -22,7 +22,6 @@ import { Link, withRouter, WithRouterProps } from 'react-router'; import CreateFormShim from '../../../../apps/portfolio/components/CreateFormShim'; import Dropdown from '../../../../components/controls/Dropdown'; import PlusIcon from '../../../../components/icons-components/PlusIcon'; -import { AppState, LoggedInUser } from '../../../types'; import { getExtensionStart } from '../../extensions/utils'; import { getComponentNavigation } from '../../../../api/nav'; import { translate } from '../../../../helpers/l10n'; @@ -31,8 +30,8 @@ import { getPortfolioAdminUrl, getPortfolioUrl } from '../../../../helpers/urls' import { hasGlobalPermission } from '../../../../helpers/users'; interface Props { - appState: Pick; - currentUser: LoggedInUser; + appState: Pick; + currentUser: T.LoggedInUser; openProjectOnboarding: () => void; } 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 530f17d248f..488a642a771 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 @@ -22,7 +22,6 @@ import { sortBy } from 'lodash'; import * as PropTypes from 'prop-types'; import { Link } from 'react-router'; import * as theme from '../../../theme'; -import { CurrentUser, LoggedInUser, Organization } from '../../../types'; import Avatar from '../../../../components/ui/Avatar'; import OrganizationListItem from '../../../../components/ui/OrganizationListItem'; import { translate } from '../../../../helpers/l10n'; @@ -32,8 +31,8 @@ import { isLoggedIn } from '../../../../helpers/users'; interface Props { appState: { organizationsEnabled?: boolean }; - currentUser: CurrentUser; - organizations: Organization[]; + currentUser: T.CurrentUser; + organizations: T.Organization[]; } export default class GlobalNavUser extends React.PureComponent { @@ -60,7 +59,7 @@ export default class GlobalNavUser extends React.PureComponent { renderAuthenticated() { const { organizations } = this.props; - const currentUser = this.props.currentUser as LoggedInUser; + const currentUser = this.props.currentUser as T.LoggedInUser; const hasOrganizations = this.props.appState.organizationsEnabled && organizations.length > 0; return ( ({ diff --git a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavPlus-test.tsx b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavPlus-test.tsx index 37f845fd4cc..ff36583b9e6 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavPlus-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavPlus-test.tsx @@ -22,7 +22,6 @@ import { shallow, ShallowWrapper } from 'enzyme'; import { GlobalNavPlus } from '../GlobalNavPlus'; import { isSonarCloud } from '../../../../../helpers/system'; import { click, mockRouter } from '../../../../../helpers/testUtils'; -import { LoggedInUser } from '../../../../types'; jest.mock('../../../../../helpers/system', () => ({ isSonarCloud: jest.fn() @@ -79,7 +78,7 @@ function getWrapper(props = {}, globalPermissions?: string[]) { { isLoggedIn: true, permissions: { global: globalPermissions || ['provisioning'] } - } as LoggedInUser + } as T.LoggedInUser } openProjectOnboarding={jest.fn()} router={mockRouter()} diff --git a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavUser-test.tsx b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavUser-test.tsx index 152efb5d69c..49e6ef10666 100644 --- a/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavUser-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNavUser-test.tsx @@ -20,13 +20,12 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import GlobalNavUser from '../GlobalNavUser'; -import { Visibility } from '../../../../types'; const currentUser = { avatar: 'abcd1234', isLoggedIn: true, name: 'foo', email: 'foo@bar.baz' }; -const organizations = [ - { key: 'myorg', name: 'MyOrg', projectVisibility: Visibility.Public }, - { key: 'foo', name: 'Foo', projectVisibility: Visibility.Public }, - { key: 'bar', name: 'bar', projectVisibility: Visibility.Public } +const organizations: T.Organization[] = [ + { key: 'myorg', name: 'MyOrg', projectVisibility: 'public' }, + { key: 'foo', name: 'Foo', projectVisibility: 'public' }, + { key: 'bar', name: 'bar', projectVisibility: 'public' } ]; const appState = { organizationsEnabled: true }; 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 378a5fc5afd..287825da12f 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 @@ -25,13 +25,12 @@ import * as theme from '../../../theme'; import ContextNavBar from '../../../../components/nav/ContextNavBar'; import Dropdown from '../../../../components/controls/Dropdown'; import NavBarTabs from '../../../../components/nav/NavBarTabs'; -import { Extension } from '../../../types'; import { PluginPendingResult } from '../../../../api/plugins'; import DropdownIcon from '../../../../components/icons-components/DropdownIcon'; import { translate } from '../../../../helpers/l10n'; interface Props { - extensions: Extension[]; + extensions: T.Extension[]; fetchPendingPlugins: () => void; location: {}; organizationsEnabled?: boolean; @@ -73,7 +72,7 @@ export default class SettingsNav extends React.PureComponent { return this.isSomethingActive(urls); } - renderExtension = ({ key, name }: Extension) => { + renderExtension = ({ key, name }: T.Extension) => { return (
  • 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 9d91d8b3acd..209b21795f5 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,15 +34,14 @@ import { getSuggestions } from '../../../api/components'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { scrollToElement } from '../../../helpers/scrolling'; import { getProjectUrl } from '../../../helpers/urls'; -import { AppState, CurrentUser } from '../../types'; import './Search.css'; const SearchResults = lazyLoad(() => import('./SearchResults')); const SearchResult = lazyLoad(() => import('./SearchResult')); interface OwnProps { - appState: Pick; - currentUser: CurrentUser; + appState: Pick; + currentUser: T.CurrentUser; } type Props = OwnProps & WithRouterProps; 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 7dd26bd190d..c75fd6719b3 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,10 +25,9 @@ import QualifierIcon from '../../../components/icons-components/QualifierIcon'; import ClockIcon from '../../../components/icons-components/ClockIcon'; import Tooltip from '../../../components/controls/Tooltip'; import { getProjectUrl } from '../../../helpers/urls'; -import { AppState } from '../../types'; interface Props { - appState: Pick; + appState: Pick; component: ComponentResult; innerRef: (componentKey: string, node: HTMLElement | null) => void; onClose: () => void; diff --git a/server/sonar-web/src/main/js/app/types.d.ts b/server/sonar-web/src/main/js/app/types.d.ts new file mode 100644 index 00000000000..d96c74fb7d3 --- /dev/null +++ b/server/sonar-web/src/main/js/app/types.d.ts @@ -0,0 +1,865 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +declare namespace T { + export type Omit = Pick>; + + // Type ordered alphabetically to prevent merge conflicts + + export interface AlmApplication extends IdentityProvider { + installationUrl: string; + } + + export interface AlmOrganization extends OrganizationBase { + key: string; + personal: boolean; + } + + export interface AlmRepository { + label: string; + installationKey: string; + linkedProjectKey?: string; + linkedProjectName?: string; + private?: boolean; + } + + export interface AlmUnboundApplication { + installationId: string; + key: string; + name: string; + } + + export interface Analysis { + date: string; + events: AnalysisEvent[]; + key: string; + } + + export interface AnalysisEvent { + category: string; + description?: string; + key: string; + name: string; + qualityGate?: { + failing: Array<{ branch: string; key: string; name: string }>; + status: string; + stillFailing: boolean; + }; + definitionChange?: { + projects: Array<{ + branch?: string; + changeType: string; + key: string; + name: string; + newBranch?: string; + oldBranch?: string; + }>; + }; + } + + export interface AppState { + adminPages?: Extension[]; + authenticationError?: boolean; + authorizationError?: boolean; + branchesEnabled?: boolean; + canAdmin?: boolean; + defaultOrganization: string; + edition: EditionKey; + globalPages?: Extension[]; + organizationsEnabled?: boolean; + productionDatabase: boolean; + qualifiers: string[]; + settings: { [key: string]: string }; + standalone?: boolean; + version: string; + } + + export interface Branch { + analysisDate?: string; + isMain: boolean; + name: string; + } + + export type BranchLike = Branch | PullRequest; + + export type BranchParameters = { branch?: string } | { pullRequest?: string }; + + export type BranchType = 'LONG' | 'SHORT'; + + export interface Breadcrumb { + key: string; + name: string; + qualifier: string; + } + + export interface Component extends LightComponent { + alm?: { key: string; url: string }; + analysisDate?: string; + breadcrumbs: Breadcrumb[]; + configuration?: ComponentConfiguration; + description?: string; + extensions?: Extension[]; + isFavorite?: boolean; + leakPeriodDate?: string; + name: string; + path?: string; + refKey?: string; + qualityProfiles?: ComponentQualityProfile[]; + qualityGate?: { isDefault?: boolean; key: string; name: string }; + tags?: string[]; + version?: string; + visibility?: Visibility; + } + + interface ComponentConfiguration { + canApplyPermissionTemplate?: boolean; + canUpdateProjectVisibilityToPrivate?: boolean; + extensions?: Extension[]; + showBackgroundTasks?: boolean; + showHistory?: boolean; + showLinks?: boolean; + showManualMeasures?: boolean; + showQualityGates?: boolean; + showQualityProfiles?: boolean; + showPermissions?: boolean; + showSettings?: boolean; + showUpdateKey?: boolean; + } + + export interface ComponentQualityProfile { + deleted?: boolean; + key: string; + language: string; + name: string; + } + + interface ComponentMeasureIntern { + branch?: string; + description?: string; + isFavorite?: boolean; + isRecentlyBrowsed?: boolean; + key: string; + match?: string; + name: string; + organization?: string; + path?: string; + project?: string; + qualifier: string; + refKey?: string; + } + + export interface ComponentMeasure extends ComponentMeasureIntern { + measures?: Measure[]; + } + + export interface ComponentMeasureEnhanced extends ComponentMeasureIntern { + value?: string; + leak?: string; + measures: MeasureEnhanced[]; + } + + export interface Condition { + error: string; + id: number; + metric: string; + op?: string; + period?: number; + warning: string; + } + + export interface CoveredFile { + key: string; + longName: string; + coveredLines: number; + } + + export interface Coupon { + billing?: { + address?: string; + country?: string; + email?: string; + name?: string; + use?: string; + }; + maxNcloc: number; + planActiveUntil: string; + } + + export interface CurrentUser { + isLoggedIn: boolean; + permissions?: { global: string[] }; + showOnboardingTutorial?: boolean; + } + + export interface CustomMeasure { + createdAt?: string; + description?: string; + id: string; + metric: { + key: string; + name: string; + domain?: string; + type: string; + }; + projectKey: string; + pending?: boolean; + user: { + active?: boolean; + email?: string; + login: string; + name: string; + }; + value: string; + updatedAt?: string; + } + + export interface Duplication { + blocks: DuplicationBlock[]; + } + + export interface DuplicationBlock { + _ref: string; + from: number; + size: number; + } + + export interface DuplicatedFile { + key: string; + name: string; + project: string; + projectName: string; + subProject?: string; + subProjectName?: string; + } + + export type EditionKey = 'community' | 'developer' | 'enterprise' | 'datacenter'; + + export interface Extension { + key: string; + name: string; + } + + export interface FacetValue { + count: number; + val: T; + } + + export interface FlowLocation { + component: string; + componentName?: string; + msg?: string; + textRange: TextRange; + } + + export interface Group { + default?: boolean; + description?: string; + id: number; + membersCount: number; + name: string; + } + + export type HomePage = + | { type: 'APPLICATION'; branch: string | undefined; component: string } + | { type: 'ISSUES' } + | { type: 'MY_ISSUES' } + | { type: 'MY_PROJECTS' } + | { type: 'ORGANIZATION'; organization: string } + | { type: 'PORTFOLIO'; component: string } + | { type: 'PORTFOLIOS' } + | { type: 'PROJECT'; branch: string | undefined; component: string } + | { type: 'PROJECTS' }; + + export type HomePageType = + | 'APPLICATION' + | 'ISSUES' + | 'MY_ISSUES' + | 'MY_PROJECTS' + | 'ORGANIZATION' + | 'PORTFOLIO' + | 'PORTFOLIOS' + | 'PROJECT' + | 'PROJECTS'; + + export interface IdentityProvider { + backgroundColor: string; + helpMessage?: string; + iconPath: string; + key: string; + name: string; + } + + export interface SecurityHotspot { + activeRules: number; + category?: string; + cwe?: string; + distribution?: Array; + openSecurityHotspots: number; + toReviewSecurityHotspots: number; + totalRules: number; + vulnerabilities: number; + vulnerabilityRating?: number; + wontFixSecurityHotspots: number; + } + + export interface Issue { + actions: string[]; + assignee?: string; + assigneeActive?: string; + assigneeAvatar?: string; + assigneeLogin?: string; + assigneeName?: string; + author?: string; + branch?: string; + comments?: IssueComment[]; + component: string; + componentLongName: string; + componentQualifier: string; + componentUuid: string; + creationDate: string; + effort?: string; + externalRuleEngine?: string; + fromExternalRule?: boolean; + key: string; + flows: FlowLocation[][]; + fromHotspot: boolean; + line?: number; + message: string; + organization: string; + project: string; + projectName: string; + projectOrganization: string; + projectKey: string; + pullRequest?: string; + resolution?: string; + rule: string; + ruleName: string; + secondaryLocations: FlowLocation[]; + severity: string; + status: string; + subProject?: string; + subProjectName?: string; + subProjectUuid?: string; + tags?: string[]; + textRange?: TextRange; + transitions: string[]; + type: IssueType; + } + + export interface IssueComment { + author?: string; + authorActive?: boolean; + authorAvatar?: string; + authorLogin?: string; + authorName?: string; + createdAt: string; + htmlText: string; + key: string; + markdown: string; + updatable: boolean; + } + + export type IssueType = 'BUG' | 'VULNERABILITY' | 'CODE_SMELL' | 'SECURITY_HOTSPOT'; + + export interface Language { + key: string; + name: string; + } + + export interface Languages { + [key: string]: Language; + } + + export interface LightComponent { + key: string; + organization: string; + qualifier: string; + } + + export interface LinearIssueLocation { + from: number; + index?: number; + line: number; + startLine?: number; + to: number; + } + + export interface LoggedInUser extends CurrentUser { + avatar?: string; + email?: string; + externalIdentity?: string; + externalProvider?: string; + groups: string[]; + homepage?: HomePage; + isLoggedIn: true; + local?: boolean; + login: string; + name: string; + personalOrganization?: string; + scmAccounts: string[]; + } + + export interface LongLivingBranch extends Branch { + isMain: false; + status?: { qualityGateStatus: string }; + type: 'LONG'; + } + + export interface MainBranch extends Branch { + isMain: true; + status?: { qualityGateStatus: string }; + } + + export interface Measure extends MeasureIntern { + metric: string; + } + + export interface MeasureEnhanced extends MeasureIntern { + metric: Metric; + leak?: string; + } + + interface MeasureIntern { + bestValue?: boolean; + periods?: PeriodMeasure[]; + value?: string; + } + + export interface Metric { + bestValue?: string; + custom?: boolean; + decimalScale?: number; + description?: string; + direction?: number; + domain?: string; + hidden?: boolean; + higherValuesAreBetter?: boolean; + id: string; + key: string; + name: string; + qualitative?: boolean; + type: string; + worstValue?: string; + } + + export interface MyProject { + description?: string; + key: string; + lastAnalysisDate?: string; + links: Array<{ + name: string; + type: string; + href: string; + }>; + name: string; + qualityGate?: string; + } + + export interface Notification { + channel: string; + organization?: string; + project?: string; + projectName?: string; + type: string; + } + + export interface OrganizationActions { + admin?: boolean; + delete?: boolean; + provision?: boolean; + executeAnalysis?: boolean; + } + + export interface Organization extends OrganizationBase { + actions?: OrganizationActions; + alm?: { key: string; url: string }; + adminPages?: Extension[]; + canUpdateProjectsVisibilityToPrivate?: boolean; + guarded?: boolean; + isDefault?: boolean; + key: string; + pages?: Extension[]; + projectVisibility?: Visibility; + subscription?: OrganizationSubscription; + } + + export interface OrganizationBase { + avatar?: string; + description?: string; + key?: string; + name: string; + url?: string; + } + + export interface OrganizationMember { + login: string; + name: string; + avatar?: string; + groupCount?: number; + } + + export type OrganizationSubscription = 'FREE' | 'PAID' | 'SONARQUBE'; + + export interface Paging { + pageIndex: number; + pageSize: number; + total: number; + } + + export interface Period { + date: string; + index: number; + mode: PeriodMode; + modeParam?: string; + parameter?: string; + } + + export interface PeriodMeasure { + bestValue?: boolean; + index: number; + value: string; + } + + export type PeriodMode = 'days' | 'date' | 'version' | 'previous_analysis' | 'previous_version'; + + export interface PermissionDefinition { + key: string; + name: string; + description: string; + } + + export type PermissionDefinitions = Array; + + export interface PermissionDefinitionGroup { + category: string; + permissions: PermissionDefinition[]; + } + + export interface PermissionGroup { + description?: string; + id?: string; + name: string; + permissions: string[]; + } + + export interface PermissionUser { + avatar?: string; + email?: string; + login: string; + name: string; + permissions: string[]; + } + + export interface PermissionTemplate { + defaultFor: string[]; + id: string; + name: string; + description?: string; + projectKeyPattern?: string; + createdAt: string; + updatedAt?: string; + permissions: Array<{ + key: string; + usersCount: number; + groupsCount: number; + withProjectCreator?: boolean; + }>; + } + + export interface ProjectLink { + id: string; + name?: string; + type: string; + url: string; + } + + export interface PullRequest { + analysisDate?: string; + base: string; + branch: string; + key: string; + isOrphan?: true; + status?: { + bugs: number; + codeSmells: number; + qualityGateStatus: string; + vulnerabilities: number; + }; + title: string; + url?: string; + } + + export interface QualityGate { + actions?: { + associateProjects?: boolean; + copy?: boolean; + delete?: boolean; + manageConditions?: boolean; + rename?: boolean; + setAsDefault?: boolean; + }; + conditions?: Condition[]; + id: number; + isBuiltIn?: boolean; + isDefault?: boolean; + name: string; + } + + export interface Rule { + isTemplate?: boolean; + key: string; + lang?: string; + langName?: string; + name: string; + params?: RuleParameter[]; + severity: string; + status: string; + sysTags?: string[]; + tags?: string[]; + type: RuleType; + } + + export interface RuleActivation { + createdAt: string; + inherit: RuleInheritance; + params: { key: string; value: string }[]; + qProfile: string; + severity: string; + } + + export interface RuleDetails extends Rule { + createdAt: string; + debtOverloaded?: boolean; + debtRemFnCoeff?: string; + debtRemFnOffset?: string; + debtRemFnType?: string; + defaultDebtRemFnOffset?: string; + defaultDebtRemFnType?: string; + defaultRemFnBaseEffort?: string; + defaultRemFnType?: string; + effortToFixDescription?: string; + htmlDesc?: string; + htmlNote?: string; + internalKey?: string; + isExternal?: boolean; + mdDesc?: string; + mdNote?: string; + remFnBaseEffort?: string; + remFnOverloaded?: boolean; + remFnType?: string; + repo: string; + scope?: RuleScope; + templateKey?: string; + } + + export type RuleInheritance = 'NONE' | 'INHERITED' | 'OVERRIDES'; + + export interface RuleParameter { + // TODO is this extra really returned? + extra?: string; + defaultValue?: string; + htmlDesc?: string; + key: string; + type: string; + } + + export type RuleScope = 'MAIN' | 'TEST' | 'ALL'; + + export type RuleType = 'BUG' | 'VULNERABILITY' | 'CODE_SMELL' | 'SECURITY_HOTSPOT' | 'UNKNOWN'; + + export type Setting = SettingValue & { definition: SettingDefinition }; + + export type SettingType = + | 'STRING' + | 'TEXT' + | 'PASSWORD' + | 'BOOLEAN' + | 'FLOAT' + | 'INTEGER' + | 'LICENSE' + | 'LONG' + | 'SINGLE_SELECT_LIST' + | 'PROPERTY_SET'; + + export interface SettingDefinition { + description?: string; + key: string; + name?: string; + options: string[]; + type?: SettingType; + } + + export interface SettingFieldDefinition extends SettingDefinition { + description: string; + name: string; + } + + export interface SettingCategoryDefinition extends SettingDefinition { + category: string; + defaultValue?: string; + deprecatedKey?: string; + fields: SettingFieldDefinition[]; + multiValues?: boolean; + subCategory: string; + } + + export interface SettingValue { + fieldValues?: Array<{ [key: string]: string }>; + inherited?: boolean; + key: string; + parentFieldValues?: Array<{ [key: string]: string }>; + parentValue?: string; + parentValues?: string[]; + value?: string; + values?: string[]; + } + + export interface ShortLivingBranch extends Branch { + isMain: false; + isOrphan?: true; + mergeBranch: string; + status?: { + bugs: number; + codeSmells: number; + qualityGateStatus: string; + vulnerabilities: number; + }; + type: 'SHORT'; + } + + export interface SourceLine { + code?: string; + conditions?: number; + coverageStatus?: string; + coveredConditions?: number; + duplicated?: boolean; + isNew?: boolean; + line: number; + lineHits?: number; + scmAuthor?: string; + scmDate?: string; + scmRevision?: string; + } + + export interface SourceViewerFile { + canMarkAsFavorite?: boolean; + fav?: boolean; + key: string; + leakPeriodDate?: string; + measures: { + coverage?: string; + duplicationDensity?: string; + issues?: string; + lines?: string; + tests?: string; + }; + path: string; + project: string; + projectName: string; + q: string; + subProject?: string; + subProjectName?: string; + uuid: string; + } + + export interface SubscriptionPlan { + maxNcloc: number; + price: number; + } + + export interface Task { + analysisId?: string; + branch?: string; + branchType?: string; + componentKey?: string; + componentName?: string; + componentQualifier?: string; + errorMessage?: string; + errorStacktrace?: string; + errorType?: string; + executedAt?: string; + executionTimeMs?: number; + hasErrorStacktrace?: boolean; + hasScannerContext?: boolean; + id: string; + logs?: boolean; + organization: string; + pullRequest?: string; + pullRequestTitle?: string; + scannerContext?: string; + startedAt?: string; + status: string; + submittedAt: string; + submitterLogin?: string; + type: string; + warningCount?: number; + warnings?: string[]; + } + + export interface TestCase { + coveredLines: number; + durationInMs: number; + fileId: string; + fileKey: string; + fileName: string; + id: string; + message?: string; + name: string; + stacktrace?: string; + status: string; + } + + export interface TextRange { + startLine: number; + startOffset: number; + endLine: number; + endOffset: number; + } + + export interface User { + active: boolean; + avatar?: string; + email?: string; + externalIdentity?: string; + externalProvider?: string; + groups?: string[]; + local: boolean; + login: string; + name: string; + scmAccounts?: string[]; + tokensCount?: number; + } + + export type Visibility = 'public' | 'private'; + + export interface Webhook { + key: string; + latestDelivery?: WebhookDelivery; + name: string; + url: string; + } + + export interface WebhookDelivery { + at: string; + durationMs: number; + httpStatus?: number; + id: string; + success: boolean; + } +} diff --git a/server/sonar-web/src/main/js/app/types.ts b/server/sonar-web/src/main/js/app/types.ts deleted file mode 100644 index 427cfe2a463..00000000000 --- a/server/sonar-web/src/main/js/app/types.ts +++ /dev/null @@ -1,916 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { EditionKey } from '../apps/marketplace/utils'; - -export type Omit = Pick>; - -// Type ordered alphabetically to prevent merge conflicts - -export interface AlmApplication extends IdentityProvider { - installationUrl: string; -} - -export interface AlmOrganization extends OrganizationBase { - key: string; - personal: boolean; -} - -export interface AlmRepository { - label: string; - installationKey: string; - linkedProjectKey?: string; - linkedProjectName?: string; - private?: boolean; -} - -export interface AlmUnboundApplication { - installationId: string; - key: string; - name: string; -} - -export interface Analysis { - date: string; - events: AnalysisEvent[]; - key: string; -} - -export interface AnalysisEvent { - category: string; - description?: string; - key: string; - name: string; - qualityGate?: { - failing: Array<{ branch: string; key: string; name: string }>; - status: string; - stillFailing: boolean; - }; - definitionChange?: { - projects: Array<{ - branch?: string; - changeType: string; - key: string; - name: string; - newBranch?: string; - oldBranch?: string; - }>; - }; -} - -export interface AppState { - adminPages?: Extension[]; - authenticationError?: boolean; - authorizationError?: boolean; - branchesEnabled?: boolean; - canAdmin?: boolean; - defaultOrganization: string; - edition: EditionKey; - globalPages?: Extension[]; - organizationsEnabled?: boolean; - productionDatabase: boolean; - qualifiers: string[]; - settings: { [key: string]: string }; - standalone?: boolean; - version: string; -} - -export interface Branch { - analysisDate?: string; - isMain: boolean; - name: string; -} - -export type BranchLike = Branch | PullRequest; - -export type BranchParameters = { branch?: string } | { pullRequest?: string }; - -export enum BranchType { - LONG = 'LONG', - SHORT = 'SHORT' -} - -export interface Breadcrumb { - key: string; - name: string; - qualifier: string; -} - -export interface Component extends LightComponent { - alm?: { key: string; url: string }; - analysisDate?: string; - breadcrumbs: Breadcrumb[]; - configuration?: ComponentConfiguration; - description?: string; - extensions?: Extension[]; - isFavorite?: boolean; - leakPeriodDate?: string; - name: string; - path?: string; - refKey?: string; - qualityProfiles?: ComponentQualityProfile[]; - qualityGate?: { isDefault?: boolean; key: string; name: string }; - tags?: string[]; - version?: string; - visibility?: Visibility; -} - -interface ComponentConfiguration { - canApplyPermissionTemplate?: boolean; - canUpdateProjectVisibilityToPrivate?: boolean; - extensions?: Extension[]; - showBackgroundTasks?: boolean; - showHistory?: boolean; - showLinks?: boolean; - showManualMeasures?: boolean; - showQualityGates?: boolean; - showQualityProfiles?: boolean; - showPermissions?: boolean; - showSettings?: boolean; - showUpdateKey?: boolean; -} - -export interface ComponentQualityProfile { - deleted?: boolean; - key: string; - language: string; - name: string; -} - -interface ComponentMeasureIntern { - branch?: string; - description?: string; - isFavorite?: boolean; - isRecentlyBrowsed?: boolean; - key: string; - match?: string; - name: string; - organization?: string; - path?: string; - project?: string; - qualifier: string; - refKey?: string; -} - -export interface ComponentMeasure extends ComponentMeasureIntern { - measures?: Measure[]; -} - -export interface ComponentMeasureEnhanced extends ComponentMeasureIntern { - value?: string; - leak?: string; - measures: MeasureEnhanced[]; -} - -export interface Condition { - error: string; - id: number; - metric: string; - op?: string; - period?: number; - warning: string; -} - -export interface CoveredFile { - key: string; - longName: string; - coveredLines: number; -} - -export interface Coupon { - billing?: { - address?: string; - country?: string; - email?: string; - name?: string; - use?: string; - }; - maxNcloc: number; - planActiveUntil: string; -} - -export interface CurrentUser { - isLoggedIn: boolean; - permissions?: { global: string[] }; - showOnboardingTutorial?: boolean; -} - -export interface CustomMeasure { - createdAt?: string; - description?: string; - id: string; - metric: { - key: string; - name: string; - domain?: string; - type: string; - }; - projectKey: string; - pending?: boolean; - user: { - active?: boolean; - email?: string; - login: string; - name: string; - }; - value: string; - updatedAt?: string; -} - -export interface Duplication { - blocks: DuplicationBlock[]; -} - -export interface DuplicationBlock { - _ref: string; - from: number; - size: number; -} - -export interface DuplicatedFile { - key: string; - name: string; - project: string; - projectName: string; - subProject?: string; - subProjectName?: string; -} - -export interface Extension { - key: string; - name: string; -} - -export interface FacetValue { - count: number; - val: T; -} - -export interface FlowLocation { - component: string; - componentName?: string; - msg?: string; - textRange: TextRange; -} - -export interface Group { - default?: boolean; - description?: string; - id: number; - membersCount: number; - name: string; -} - -export type HomePage = - | { type: HomePageType.Application; branch: string | undefined; component: string } - | { type: HomePageType.Issues } - | { type: HomePageType.MyIssues } - | { type: HomePageType.MyProjects } - | { type: HomePageType.Organization; organization: string } - | { type: HomePageType.Portfolio; component: string } - | { type: HomePageType.Portfolios } - | { type: HomePageType.Project; branch: string | undefined; component: string } - | { type: HomePageType.Projects }; - -export enum HomePageType { - Application = 'APPLICATION', - Issues = 'ISSUES', - MyIssues = 'MY_ISSUES', - MyProjects = 'MY_PROJECTS', - Organization = 'ORGANIZATION', - Portfolio = 'PORTFOLIO', - Portfolios = 'PORTFOLIOS', - Project = 'PROJECT', - Projects = 'PROJECTS' -} - -export interface IdentityProvider { - backgroundColor: string; - helpMessage?: string; - iconPath: string; - key: string; - name: string; -} - -export function hasGlobalPermission(user: CurrentUser, permission: string): boolean { - if (!user.permissions) { - return false; - } - return user.permissions.global.includes(permission); -} - -export function isSameHomePage(a: HomePage, b: HomePage) { - return ( - a.type === b.type && - (a as any).branch === (b as any).branch && - (a as any).component === (b as any).component && - (a as any).organization === (b as any).organization - ); -} - -export interface SecurityHotspot { - activeRules: number; - category?: string; - cwe?: string; - distribution?: Array; - openSecurityHotspots: number; - toReviewSecurityHotspots: number; - totalRules: number; - vulnerabilities: number; - vulnerabilityRating?: number; - wontFixSecurityHotspots: number; -} - -export interface Issue { - actions: string[]; - assignee?: string; - assigneeActive?: string; - assigneeAvatar?: string; - assigneeLogin?: string; - assigneeName?: string; - author?: string; - branch?: string; - comments?: IssueComment[]; - component: string; - componentLongName: string; - componentQualifier: string; - componentUuid: string; - creationDate: string; - effort?: string; - externalRuleEngine?: string; - fromExternalRule?: boolean; - key: string; - flows: FlowLocation[][]; - fromHotspot: boolean; - line?: number; - message: string; - organization: string; - project: string; - projectName: string; - projectOrganization: string; - projectKey: string; - pullRequest?: string; - resolution?: string; - rule: string; - ruleName: string; - secondaryLocations: FlowLocation[]; - severity: string; - status: string; - subProject?: string; - subProjectName?: string; - subProjectUuid?: string; - tags?: string[]; - textRange?: TextRange; - transitions: string[]; - type: IssueType; -} - -export interface IssueComment { - author?: string; - authorActive?: boolean; - authorAvatar?: string; - authorLogin?: string; - authorName?: string; - createdAt: string; - htmlText: string; - key: string; - markdown: string; - updatable: boolean; -} - -export enum IssueType { - Bug = 'BUG', - Vulnerability = 'VULNERABILITY', - CodeSmell = 'CODE_SMELL', - Hotspot = 'SECURITY_HOTSPOT' -} - -export interface Language { - key: string; - name: string; -} - -export interface Languages { - [key: string]: Language; -} - -export interface LightComponent { - key: string; - organization: string; - qualifier: string; -} - -export interface LinearIssueLocation { - from: number; - index?: number; - line: number; - startLine?: number; - to: number; -} - -export interface LoggedInUser extends CurrentUser { - avatar?: string; - email?: string; - externalIdentity?: string; - externalProvider?: string; - groups: string[]; - homepage?: HomePage; - isLoggedIn: true; - local?: boolean; - login: string; - name: string; - personalOrganization?: string; - scmAccounts: string[]; -} - -export interface LongLivingBranch extends Branch { - isMain: false; - status?: { qualityGateStatus: string }; - type: BranchType.LONG; -} - -export interface MainBranch extends Branch { - isMain: true; - status?: { qualityGateStatus: string }; -} - -export interface Measure extends MeasureIntern { - metric: string; -} - -export interface MeasureEnhanced extends MeasureIntern { - metric: Metric; - leak?: string; -} - -interface MeasureIntern { - bestValue?: boolean; - periods?: PeriodMeasure[]; - value?: string; -} - -export interface Metric { - bestValue?: string; - custom?: boolean; - decimalScale?: number; - description?: string; - direction?: number; - domain?: string; - hidden?: boolean; - higherValuesAreBetter?: boolean; - id: string; - key: string; - name: string; - qualitative?: boolean; - type: string; - worstValue?: string; -} - -export interface MyProject { - description?: string; - key: string; - lastAnalysisDate?: string; - links: Array<{ - name: string; - type: string; - href: string; - }>; - name: string; - qualityGate?: string; -} - -export interface Notification { - channel: string; - organization?: string; - project?: string; - projectName?: string; - type: string; -} - -export interface OrganizationActions { - admin?: boolean; - delete?: boolean; - provision?: boolean; - executeAnalysis?: boolean; -} - -export interface Organization extends OrganizationBase { - actions?: OrganizationActions; - alm?: { key: string; url: string }; - adminPages?: Extension[]; - canUpdateProjectsVisibilityToPrivate?: boolean; - guarded?: boolean; - isDefault?: boolean; - key: string; - pages?: Extension[]; - projectVisibility?: Visibility; - subscription?: OrganizationSubscription; -} - -export interface OrganizationBase { - avatar?: string; - description?: string; - key?: string; - name: string; - url?: string; -} - -export interface OrganizationMember { - login: string; - name: string; - avatar?: string; - groupCount?: number; -} - -export enum OrganizationSubscription { - Free = 'FREE', - Paid = 'PAID', - SonarQube = 'SONARQUBE' -} - -export interface Paging { - pageIndex: number; - pageSize: number; - total: number; -} - -export interface Period { - date: string; - index: number; - mode: PeriodMode; - modeParam?: string; - parameter?: string; -} - -export interface PeriodMeasure { - bestValue?: boolean; - index: number; - value: string; -} - -export enum PeriodMode { - Days = 'days', - Date = 'date', - Version = 'version', - PreviousAnalysis = 'previous_analysis', - PreviousVersion = 'previous_version' -} - -export interface PermissionDefinition { - key: string; - name: string; - description: string; -} - -export type PermissionDefinitions = Array; - -export interface PermissionDefinitionGroup { - category: string; - permissions: PermissionDefinition[]; -} - -export interface PermissionGroup { - description?: string; - id?: string; - name: string; - permissions: string[]; -} - -export interface PermissionUser { - avatar?: string; - email?: string; - login: string; - name: string; - permissions: string[]; -} - -export interface PermissionTemplate { - defaultFor: string[]; - id: string; - name: string; - description?: string; - projectKeyPattern?: string; - createdAt: string; - updatedAt?: string; - permissions: Array<{ - key: string; - usersCount: number; - groupsCount: number; - withProjectCreator?: boolean; - }>; -} - -export interface ProjectLink { - id: string; - name?: string; - type: string; - url: string; -} - -export interface PullRequest { - analysisDate?: string; - base: string; - branch: string; - key: string; - isOrphan?: true; - status?: { - bugs: number; - codeSmells: number; - qualityGateStatus: string; - vulnerabilities: number; - }; - title: string; - url?: string; -} - -export interface QualityGate { - actions?: { - associateProjects?: boolean; - copy?: boolean; - delete?: boolean; - manageConditions?: boolean; - rename?: boolean; - setAsDefault?: boolean; - }; - conditions?: Condition[]; - id: number; - isBuiltIn?: boolean; - isDefault?: boolean; - name: string; -} - -export interface Rule { - isTemplate?: boolean; - key: string; - lang?: string; - langName?: string; - name: string; - params?: RuleParameter[]; - severity: string; - status: string; - sysTags?: string[]; - tags?: string[]; - type: RuleType; -} - -export interface RuleActivation { - createdAt: string; - inherit: RuleInheritance; - params: { key: string; value: string }[]; - qProfile: string; - severity: string; -} - -export interface RuleDetails extends Rule { - createdAt: string; - debtOverloaded?: boolean; - debtRemFnCoeff?: string; - debtRemFnOffset?: string; - debtRemFnType?: string; - defaultDebtRemFnOffset?: string; - defaultDebtRemFnType?: string; - defaultRemFnBaseEffort?: string; - defaultRemFnType?: string; - effortToFixDescription?: string; - htmlDesc?: string; - htmlNote?: string; - internalKey?: string; - isExternal?: boolean; - mdDesc?: string; - mdNote?: string; - remFnBaseEffort?: string; - remFnOverloaded?: boolean; - remFnType?: string; - repo: string; - scope?: RuleScope; - templateKey?: string; -} - -export enum RuleInheritance { - NotInherited = 'NONE', - Inherited = 'INHERITED', - Overridden = 'OVERRIDES' -} - -export interface RuleParameter { - // TODO is this extra really returned? - extra?: string; - defaultValue?: string; - htmlDesc?: string; - key: string; - type: string; -} - -export enum RuleScope { - Main = 'MAIN', - Test = 'TEST', - All = 'ALL' -} - -export enum RuleType { - Bug = 'BUG', - Vulnerability = 'VULNERABILITY', - CodeSmell = 'CODE_SMELL', - Hotspot = 'SECURITY_HOTSPOT', - Unknown = 'UNKNOWN' -} - -export type Setting = SettingValue & { definition: SettingDefinition }; - -export enum SettingType { - String = 'STRING', - Text = 'TEXT', - Password = 'PASSWORD', - Boolean = 'BOOLEAN', - Float = 'FLOAT', - Integer = 'INTEGER', - License = 'LICENSE', - Long = 'LONG', - SingleSelectList = 'SINGLE_SELECT_LIST', - PropertySet = 'PROPERTY_SET' -} - -export interface SettingDefinition { - description?: string; - key: string; - name?: string; - options: string[]; - type?: SettingType; -} - -export interface SettingFieldDefinition extends SettingDefinition { - description: string; - name: string; -} - -export interface SettingCategoryDefinition extends SettingDefinition { - category: string; - defaultValue?: string; - deprecatedKey?: string; - fields: SettingFieldDefinition[]; - multiValues?: boolean; - subCategory: string; -} - -export interface SettingValue { - fieldValues?: Array<{ [key: string]: string }>; - inherited?: boolean; - key: string; - parentFieldValues?: Array<{ [key: string]: string }>; - parentValue?: string; - parentValues?: string[]; - value?: string; - values?: string[]; -} - -export interface ShortLivingBranch extends Branch { - isMain: false; - isOrphan?: true; - mergeBranch: string; - status?: { - bugs: number; - codeSmells: number; - qualityGateStatus: string; - vulnerabilities: number; - }; - type: BranchType.SHORT; -} - -export interface SourceLine { - code?: string; - conditions?: number; - coverageStatus?: string; - coveredConditions?: number; - duplicated?: boolean; - isNew?: boolean; - line: number; - lineHits?: number; - scmAuthor?: string; - scmDate?: string; - scmRevision?: string; -} - -export interface SourceViewerFile { - canMarkAsFavorite?: boolean; - fav?: boolean; - key: string; - leakPeriodDate?: string; - measures: { - coverage?: string; - duplicationDensity?: string; - issues?: string; - lines?: string; - tests?: string; - }; - path: string; - project: string; - projectName: string; - q: string; - subProject?: string; - subProjectName?: string; - uuid: string; -} - -export interface SubscriptionPlan { - maxNcloc: number; - price: number; -} - -export interface Task { - analysisId?: string; - branch?: string; - branchType?: string; - componentKey?: string; - componentName?: string; - componentQualifier?: string; - errorMessage?: string; - errorStacktrace?: string; - errorType?: string; - executedAt?: string; - executionTimeMs?: number; - hasErrorStacktrace?: boolean; - hasScannerContext?: boolean; - id: string; - logs?: boolean; - organization: string; - pullRequest?: string; - pullRequestTitle?: string; - scannerContext?: string; - startedAt?: string; - status: string; - submittedAt: string; - submitterLogin?: string; - type: string; - warningCount?: number; - warnings?: string[]; -} - -export interface TestCase { - coveredLines: number; - durationInMs: number; - fileId: string; - fileKey: string; - fileName: string; - id: string; - message?: string; - name: string; - stacktrace?: string; - status: string; -} - -export interface TextRange { - startLine: number; - startOffset: number; - endLine: number; - endOffset: number; -} - -export interface User { - active: boolean; - avatar?: string; - email?: string; - externalIdentity?: string; - externalProvider?: string; - groups?: string[]; - local: boolean; - login: string; - name: string; - scmAccounts?: string[]; - tokensCount?: number; -} - -export enum Visibility { - Public = 'public', - Private = 'private' -} - -export interface Webhook { - key: string; - latestDelivery?: WebhookDelivery; - name: string; - url: string; -} - -export interface WebhookDelivery { - at: string; - durationMs: number; - httpStatus?: number; - id: string; - success: boolean; -} 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 168447466d0..461438b987d 100644 --- a/server/sonar-web/src/main/js/app/utils/getStore.ts +++ b/server/sonar-web/src/main/js/app/utils/getStore.ts @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { Store } from 'redux'; -import { AppState, CurrentUser } from '../types'; import { setAppState } from '../../store/appState'; import rootReducer, { Store as State } from '../../store/rootReducer'; import { receiveCurrentUser } from '../../store/users'; @@ -26,7 +25,7 @@ import configureStore from '../../store/utils/configureStore'; let store: Store; -const createStore = (currentUser?: CurrentUser, appState?: AppState) => { +const createStore = (currentUser?: T.CurrentUser, appState?: T.AppState) => { store = configureStore(rootReducer); if (currentUser) { store.dispatch(receiveCurrentUser(currentUser)); @@ -37,5 +36,5 @@ const createStore = (currentUser?: CurrentUser, appState?: AppState) => { return store; }; -export default (currentUser?: CurrentUser, appState?: AppState) => +export default (currentUser?: T.CurrentUser, appState?: T.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 78bd52c4c53..721abda0ba5 100644 --- a/server/sonar-web/src/main/js/app/utils/startReactApp.tsx +++ b/server/sonar-web/src/main/js/app/utils/startReactApp.tsx @@ -69,7 +69,6 @@ import { maintenanceRoutes, setupRoutes } from '../../apps/maintenance/routes'; import { globalPermissionsRoutes, projectPermissionsRoutes } from '../../apps/permissions/routes'; import { lazyLoad } from '../../components/lazyLoad'; import { isSonarCloud } from '../../helpers/system'; -import { CurrentUser, AppState } from '../types'; function handleUpdate(this: { state: { location: Location } }) { const { action } = this.state.location; @@ -86,8 +85,8 @@ const RouteWithChildRoutes = Route as React.ComponentClass< export default function startReactApp( lang: string, - currentUser?: CurrentUser, - appState?: AppState + currentUser?: T.CurrentUser, + appState?: T.AppState ) { const el = document.getElementById('content'); diff --git a/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx b/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx index 752000d6e13..eb452a2ff8b 100644 --- a/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx +++ b/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx @@ -42,12 +42,11 @@ import { } from '../../../store/rootReducer'; import { translate } from '../../../helpers/l10n'; import { fetchAboutPageSettings } from '../actions'; -import { IssueType, AppState, CurrentUser } from '../../../app/types'; import '../styles.css'; interface Props { - appState: Pick; - currentUser: CurrentUser; + appState: Pick; + currentUser: T.CurrentUser; customText?: string; fetchAboutPageSettings: () => Promise; location: Location; @@ -121,10 +120,9 @@ class AboutApp extends React.PureComponent { let vulnerabilities; let codeSmells; if (!loading && issueTypes) { - bugs = issueTypes[IssueType.Bug] && issueTypes[IssueType.Bug].count; - vulnerabilities = - issueTypes[IssueType.Vulnerability] && issueTypes[IssueType.Vulnerability].count; - codeSmells = issueTypes[IssueType.CodeSmell] && issueTypes[IssueType.CodeSmell].count; + bugs = issueTypes['BUG'] && issueTypes['BUG'].count; + vulnerabilities = issueTypes['VULNERABILITY'] && issueTypes['VULNERABILITY'].count; + codeSmells = issueTypes['CODE_SMELL'] && issueTypes['CODE_SMELL'].count; } return ( diff --git a/server/sonar-web/src/main/js/apps/about/components/AboutStandards.tsx b/server/sonar-web/src/main/js/apps/about/components/AboutStandards.tsx index 07d58182fdb..c0e840db867 100644 --- a/server/sonar-web/src/main/js/apps/about/components/AboutStandards.tsx +++ b/server/sonar-web/src/main/js/apps/about/components/AboutStandards.tsx @@ -23,7 +23,6 @@ import ReadMore from './ReadMore'; import TagsIcon from '../../../components/icons-components/TagsIcon'; import { translate } from '../../../helpers/l10n'; import { getRulesUrl } from '../../../helpers/urls'; -import { AppState } from '../../../app/types'; const link = 'https://redirect.sonarsource.com/doc/rules.html'; @@ -32,7 +31,7 @@ const owaspTags = const sans25Tags = 'sans-top25-porous,sans-top25-risky,sans-top25-insecure'; interface Props { - appState: Pick; + appState: Pick; } export default function AboutStandards({ appState }: Props) { diff --git a/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.tsx b/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.tsx index 5361e0ef438..7010f1ff027 100644 --- a/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.tsx +++ b/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.tsx @@ -25,7 +25,6 @@ import { getIssuesUrl } from '../../../helpers/urls'; import BugIcon from '../../../components/icons-components/BugIcon'; import VulnerabilityIcon from '../../../components/icons-components/VulnerabilityIcon'; import CodeSmellIcon from '../../../components/icons-components/CodeSmellIcon'; -import { IssueType } from '../../../app/types'; interface Props { bugs?: number; @@ -46,11 +45,7 @@ export default function EntryIssueTypes({ bugs, codeSmells, loading, vulnerabili + to={getIssuesUrl({ resolved: 'false', types: 'BUG', s: 'CREATION_DATE' })}> {formatMeasure(bugs, 'SHORT_INT')} @@ -67,7 +62,7 @@ export default function EntryIssueTypes({ bugs, codeSmells, loading, vulnerabili className="about-page-issue-type-link" to={getIssuesUrl({ resolved: 'false', - types: IssueType.Vulnerability, + types: 'VULNERABILITY', s: 'CREATION_DATE' })}> {formatMeasure(vulnerabilities, 'SHORT_INT')} @@ -84,11 +79,7 @@ export default function EntryIssueTypes({ bugs, codeSmells, loading, vulnerabili + to={getIssuesUrl({ resolved: 'false', types: 'CODE_SMELL', s: 'CREATION_DATE' })}> {formatMeasure(codeSmells, 'SHORT_INT')} diff --git a/server/sonar-web/src/main/js/apps/about/sonarcloud/Contact.tsx b/server/sonar-web/src/main/js/apps/about/sonarcloud/Contact.tsx index 9153e103b18..1b9ef436568 100644 --- a/server/sonar-web/src/main/js/apps/about/sonarcloud/Contact.tsx +++ b/server/sonar-web/src/main/js/apps/about/sonarcloud/Contact.tsx @@ -24,7 +24,6 @@ import { Location } from 'history'; import SQPageContainer from './components/SQPageContainer'; import Select from '../../../components/controls/Select'; import { Alert } from '../../../components/ui/Alert'; -import { Organization } from '../../../app/types'; import { isLoggedIn } from '../../../helpers/users'; import './style.css'; @@ -57,7 +56,7 @@ export default class Contact extends React.PureComponent { }; } - getOrganizations = (organizations?: Organization[]) => { + getOrganizations = (organizations?: T.Organization[]) => { return (organizations || []).map(org => ({ label: org.name, value: org.key diff --git a/server/sonar-web/src/main/js/apps/about/sonarcloud/components/SQPageContainer.tsx b/server/sonar-web/src/main/js/apps/about/sonarcloud/components/SQPageContainer.tsx index 97030a220ae..dee101afa87 100644 --- a/server/sonar-web/src/main/js/apps/about/sonarcloud/components/SQPageContainer.tsx +++ b/server/sonar-web/src/main/js/apps/about/sonarcloud/components/SQPageContainer.tsx @@ -22,12 +22,11 @@ import { connect } from 'react-redux'; import { withRouter, WithRouterProps } from 'react-router'; import Footer from './Footer'; import { getCurrentUser, getMyOrganizations, Store } from '../../../../store/rootReducer'; -import { CurrentUser, Organization } from '../../../../app/types'; import GlobalContainer from '../../../../app/components/GlobalContainer'; interface StateProps { - currentUser: CurrentUser; - userOrganizations?: Organization[]; + currentUser: T.CurrentUser; + userOrganizations?: T.Organization[]; } interface OwnProps { 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 02711b9d407..4018f461da5 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 @@ -22,7 +22,6 @@ import { connect } from 'react-redux'; import Helmet from 'react-helmet'; import Nav from './Nav'; import UserCard from './UserCard'; -import { CurrentUser, LoggedInUser } from '../../../app/types'; import { getCurrentUser, areThereCustomOrganizations, Store } from '../../../store/rootReducer'; import { translate } from '../../../helpers/l10n'; import handleRequiredAuthentication from '../../../app/utils/handleRequiredAuthentication'; @@ -30,7 +29,7 @@ import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import '../account.css'; interface Props { - currentUser: CurrentUser; + currentUser: T.CurrentUser; customOrganizations?: boolean; } @@ -55,7 +54,7 @@ class Account extends React.PureComponent {
    - +
    diff --git a/server/sonar-web/src/main/js/apps/account/components/Password.tsx b/server/sonar-web/src/main/js/apps/account/components/Password.tsx index b3cc2f831ae..38a241b0f6a 100644 --- a/server/sonar-web/src/main/js/apps/account/components/Password.tsx +++ b/server/sonar-web/src/main/js/apps/account/components/Password.tsx @@ -21,11 +21,10 @@ import * as React from 'react'; import { changePassword } from '../../../api/users'; import { SubmitButton } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; -import { LoggedInUser } from '../../../app/types'; import { Alert } from '../../../components/ui/Alert'; interface Props { - user: LoggedInUser; + user: T.LoggedInUser; } interface State { 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 bca85261333..1286898bdac 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 @@ -24,10 +24,9 @@ import Password from './Password'; import Tokens from './Tokens'; import { translate } from '../../../helpers/l10n'; import { getCurrentUser, Store } from '../../../store/rootReducer'; -import { LoggedInUser } from '../../../app/types'; interface Props { - user: LoggedInUser; + user: T.LoggedInUser; } function Security({ user }: Props) { @@ -41,7 +40,7 @@ function Security({ user }: Props) { } const mapStateToProps = (state: Store) => ({ - user: getCurrentUser(state) as LoggedInUser + user: getCurrentUser(state) as T.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 6afeeaaf967..550522f5a86 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,10 +19,9 @@ */ import * as React from 'react'; import Avatar from '../../../components/ui/Avatar'; -import { LoggedInUser } from '../../../app/types'; interface Props { - user: LoggedInUser; + user: T.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 0ac75ce0151..5ca04b775f8 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 @@ -19,14 +19,13 @@ */ import * as React from 'react'; import NotificationsList from './NotificationsList'; -import { Notification } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - addNotification: (n: Notification) => void; + addNotification: (n: T.Notification) => void; channels: string[]; - notifications: Notification[]; - removeNotification: (n: Notification) => void; + notifications: T.Notification[]; + removeNotification: (n: T.Notification) => void; types: string[]; } diff --git a/server/sonar-web/src/main/js/apps/account/notifications/Notifications.tsx b/server/sonar-web/src/main/js/apps/account/notifications/Notifications.tsx index 949b0285c7e..a6eadc5ff65 100644 --- a/server/sonar-web/src/main/js/apps/account/notifications/Notifications.tsx +++ b/server/sonar-web/src/main/js/apps/account/notifications/Notifications.tsx @@ -25,7 +25,6 @@ import GlobalNotifications from './GlobalNotifications'; import Projects from './Projects'; import { NotificationProject } from './types'; import * as api from '../../../api/notifications'; -import { Notification } from '../../../app/types'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import { translate } from '../../../helpers/l10n'; import { Alert } from '../../../components/ui/Alert'; @@ -38,7 +37,7 @@ interface State { channels: string[]; globalTypes: string[]; loading: boolean; - notifications: Notification[]; + notifications: T.Notification[]; perProjectTypes: string[]; } @@ -94,13 +93,13 @@ export default class Notifications extends React.PureComponent { ); }; - addNotificationToState = (added: Notification) => { + addNotificationToState = (added: T.Notification) => { this.setState(state => ({ notifications: uniqWith([...state.notifications, added], areNotificationsEqual) })); }; - removeNotificationFromState = (removed: Notification) => { + removeNotificationFromState = (removed: T.Notification) => { this.setState(state => ({ notifications: state.notifications.filter( notification => !areNotificationsEqual(notification, removed) @@ -108,7 +107,7 @@ export default class Notifications extends React.PureComponent { })); }; - addNotification = (added: Notification) => { + addNotification = (added: T.Notification) => { // optimistic update this.addNotificationToState(added); @@ -119,7 +118,7 @@ export default class Notifications extends React.PureComponent { }); }; - removeNotification = (removed: Notification) => { + removeNotification = (removed: T.Notification) => { // optimistic update this.removeNotificationFromState(removed); @@ -175,6 +174,6 @@ export default class Notifications extends React.PureComponent { } } -function areNotificationsEqual(a: Notification, b: Notification) { +function areNotificationsEqual(a: T.Notification, b: T.Notification) { return a.channel === b.channel && a.type === b.type && a.project === b.project; } 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 35915a0f4f1..c091dbde451 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 @@ -18,18 +18,17 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Notification } from '../../../app/types'; import Checkbox from '../../../components/controls/Checkbox'; import { translate, hasMessage } from '../../../helpers/l10n'; interface Props { - onAdd: (n: Notification) => void; - onRemove: (n: Notification) => void; + onAdd: (n: T.Notification) => void; + onRemove: (n: T.Notification) => void; channels: string[]; checkboxId: (type: string, channel: string) => string; project?: boolean; types: string[]; - notifications: Notification[]; + notifications: T.Notification[]; } export default class NotificationsList extends React.PureComponent { 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 f5e29f76ba1..1031b6afc1f 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 @@ -21,17 +21,16 @@ import * as React from 'react'; import { Link } from 'react-router'; import NotificationsList from './NotificationsList'; import { NotificationProject } from './types'; -import { Notification } from '../../../app/types'; import Organization from '../../../components/shared/Organization'; import { translate } from '../../../helpers/l10n'; import { getProjectUrl } from '../../../helpers/urls'; interface Props { - addNotification: (n: Notification) => void; + addNotification: (n: T.Notification) => void; channels: string[]; - notifications: Notification[]; + notifications: T.Notification[]; project: NotificationProject; - removeNotification: (n: Notification) => void; + removeNotification: (n: T.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 87534d86b24..dedd0456093 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,17 +22,16 @@ import { differenceWith } from 'lodash'; import ProjectNotifications from './ProjectNotifications'; import { NotificationProject } from './types'; import { getSuggestions } from '../../../api/components'; -import { Notification } from '../../../app/types'; import { AsyncSelect } from '../../../components/controls/Select'; import Organization from '../../../components/shared/Organization'; import { translate } from '../../../helpers/l10n'; export interface Props { - addNotification: (n: Notification) => void; + addNotification: (n: T.Notification) => void; channels: string[]; - notificationsByProject: { [project: string]: Notification[] }; + notificationsByProject: { [project: string]: T.Notification[] }; projects: NotificationProject[]; - removeNotification: (n: Notification) => void; + removeNotification: (n: T.Notification) => void; types: string[]; } diff --git a/server/sonar-web/src/main/js/apps/account/organizations/OrganizationCard.tsx b/server/sonar-web/src/main/js/apps/account/organizations/OrganizationCard.tsx index 99cc1b00272..4648d2fd377 100644 --- a/server/sonar-web/src/main/js/apps/account/organizations/OrganizationCard.tsx +++ b/server/sonar-web/src/main/js/apps/account/organizations/OrganizationCard.tsx @@ -21,10 +21,9 @@ import * as React from 'react'; import OrganizationAvatar from '../../../components/common/OrganizationAvatar'; import OrganizationLink from '../../../components/ui/OrganizationLink'; import { translate } from '../../../helpers/l10n'; -import { Organization } from '../../../app/types'; interface Props { - organization: Organization; + organization: T.Organization; } export default function OrganizationCard({ organization }: Props) { diff --git a/server/sonar-web/src/main/js/apps/account/organizations/OrganizationsList.tsx b/server/sonar-web/src/main/js/apps/account/organizations/OrganizationsList.tsx index fa9cbfe6052..13681b72508 100644 --- a/server/sonar-web/src/main/js/apps/account/organizations/OrganizationsList.tsx +++ b/server/sonar-web/src/main/js/apps/account/organizations/OrganizationsList.tsx @@ -20,11 +20,10 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import OrganizationCard from './OrganizationCard'; -import { Organization } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - organizations: Organization[]; + organizations: T.Organization[]; } export default function OrganizationsList({ organizations }: Props) { diff --git a/server/sonar-web/src/main/js/apps/account/organizations/UserOrganizations.tsx b/server/sonar-web/src/main/js/apps/account/organizations/UserOrganizations.tsx index 3ec744841b8..22ccbe76fdf 100644 --- a/server/sonar-web/src/main/js/apps/account/organizations/UserOrganizations.tsx +++ b/server/sonar-web/src/main/js/apps/account/organizations/UserOrganizations.tsx @@ -30,12 +30,11 @@ import { getGlobalSettingValue, Store } from '../../../store/rootReducer'; -import { Organization } from '../../../app/types'; interface StateProps { anyoneCanCreate: boolean; canAdmin?: boolean; - organizations: Organization[]; + organizations: T.Organization[]; } interface DispatchProps { 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 f03d64cac11..a156f980763 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 @@ -24,11 +24,10 @@ import UserGroups from './UserGroups'; import UserScmAccounts from './UserScmAccounts'; import { getCurrentUser, areThereCustomOrganizations, Store } from '../../../store/rootReducer'; import { translate } from '../../../helpers/l10n'; -import { LoggedInUser } from '../../../app/types'; interface Props { customOrganizations?: boolean; - user: LoggedInUser; + user: T.LoggedInUser; } function Profile({ customOrganizations, user }: Props) { @@ -69,7 +68,7 @@ function Profile({ customOrganizations, user }: Props) { const mapStateToProps = (state: Store) => ({ customOrganizations: areThereCustomOrganizations(state), - user: getCurrentUser(state) as LoggedInUser + user: getCurrentUser(state) as T.LoggedInUser }); export default connect(mapStateToProps)(Profile); 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 a71dad75ff4..0441ae13aac 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 @@ -21,15 +21,14 @@ import * as React from 'react'; import { getIdentityProviders } from '../../../api/users'; import * as theme from '../../../app/theme'; import { getTextColor } from '../../../helpers/colors'; -import { LoggedInUser, IdentityProvider } from '../../../app/types'; import { getBaseUrl } from '../../../helpers/urls'; interface Props { - user: LoggedInUser; + user: T.LoggedInUser; } interface State { - identityProvider?: IdentityProvider; + identityProvider?: T.IdentityProvider; loading: boolean; } diff --git a/server/sonar-web/src/main/js/apps/account/profile/UserScmAccounts.tsx b/server/sonar-web/src/main/js/apps/account/profile/UserScmAccounts.tsx index 13be6a89f97..39d0240bb7c 100644 --- a/server/sonar-web/src/main/js/apps/account/profile/UserScmAccounts.tsx +++ b/server/sonar-web/src/main/js/apps/account/profile/UserScmAccounts.tsx @@ -19,11 +19,10 @@ */ import * as React from 'react'; import { translate } from '../../../helpers/l10n'; -import { LoggedInUser } from '../../../app/types'; interface Props { scmAccounts: string[]; - user: LoggedInUser; + user: T.LoggedInUser; } export default function UserScmAccounts({ user, scmAccounts }: Props) { 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 f9946715f89..dbbe4e2ce6f 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,10 +26,9 @@ import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; import Level from '../../../components/ui/Level'; import Tooltip from '../../../components/controls/Tooltip'; import { translateWithParameters, translate } from '../../../helpers/l10n'; -import { MyProject } from '../../../app/types'; interface Props { - project: MyProject; + project: T.MyProject; } export default function ProjectCard({ project }: Props) { 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 15a00318c4b..071e23289ce 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 @@ -21,12 +21,11 @@ import * as React from 'react'; import ProjectCard from './ProjectCard'; import ListFooter from '../../../components/controls/ListFooter'; import { translate } from '../../../helpers/l10n'; -import { MyProject } from '../../../app/types'; interface Props { loading: boolean; loadMore: () => void; - projects: MyProject[]; + projects: T.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 a5d62ac64a3..115b2954cae 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 @@ -22,12 +22,11 @@ import Helmet from 'react-helmet'; import Projects from './Projects'; import { getMyProjects } from '../../../api/components'; import { translate } from '../../../helpers/l10n'; -import { MyProject } from '../../../app/types'; interface State { loading: boolean; page: number; - projects?: MyProject[]; + projects?: T.MyProject[]; total?: number; } 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 4542c958b05..4f5bb8c92d4 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 @@ -43,7 +43,6 @@ import { translate } from '../../../helpers/l10n'; import { parseAsDate } from '../../../helpers/query'; import { toShortNotSoISOString } from '../../../helpers/dates'; import '../background-tasks.css'; -import { Task } from '../../../app/types'; interface Props { component?: { id: string }; @@ -54,7 +53,7 @@ interface Props { interface State { loading: boolean; - tasks: Task[]; + tasks: T.Task[]; types?: string[]; query: string; pendingCount: number; @@ -171,7 +170,7 @@ class BackgroundTasksApp extends React.PureComponent { }); }; - handleCancelTask = (task: Task) => { + handleCancelTask = (task: T.Task) => { this.setState({ loading: true }); return cancelTaskAPI(task.id).then(nextTask => { @@ -184,7 +183,7 @@ class BackgroundTasksApp extends React.PureComponent { }, this.stopLoading); }; - handleFilterTask = (task: Task) => { + handleFilterTask = (task: T.Task) => { this.handleFilterUpdate({ query: task.componentKey }); }; diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Footer.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Footer.tsx index 4242bb2b3e3..b36390ae51c 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Footer.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Footer.tsx @@ -19,12 +19,11 @@ */ import * as React from 'react'; import { translateWithParameters } from '../../../helpers/l10n'; -import { Task } from '../../../app/types'; const LIMIT = 1000; interface Props { - tasks: Task[]; + tasks: T.Task[]; } export default function Footer({ tasks }: Props) { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/ScannerContext.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/ScannerContext.tsx index 6fc2bb4e920..77ccdf6edcf 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/ScannerContext.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/ScannerContext.tsx @@ -21,11 +21,10 @@ import * as React from 'react'; import { getTask } from '../../../api/ce'; import { translate } from '../../../helpers/l10n'; import Modal from '../../../components/controls/Modal'; -import { Task } from '../../../app/types'; interface Props { onClose: () => void; - task: Pick; + task: Pick; } interface State { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Stacktrace.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Stacktrace.tsx index 51d2c99875b..f0801d47b41 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Stacktrace.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Stacktrace.tsx @@ -21,11 +21,10 @@ import * as React from 'react'; import { getTask } from '../../../api/ce'; import { translate } from '../../../helpers/l10n'; import Modal from '../../../components/controls/Modal'; -import { Task } from '../../../app/types'; interface Props { onClose: () => void; - task: Pick; + task: Pick; } interface State { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Task.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Task.tsx index 903dad8de13..418496e699d 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Task.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Task.tsx @@ -26,14 +26,13 @@ import TaskDate from './TaskDate'; import TaskId from './TaskId'; import TaskStatus from './TaskStatus'; import TaskSubmitter from './TaskSubmitter'; -import { Task as TaskType } from '../../../app/types'; interface Props { component?: unknown; - onCancelTask: (task: TaskType) => Promise; - onFilterTask: (task: TaskType) => void; - task: TaskType; - previousTask?: TaskType; + onCancelTask: (task: T.Task) => Promise; + onFilterTask: (task: T.Task) => void; + task: T.Task; + previousTask?: T.Task; } export default function Task(props: Props) { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx index fbabb073096..774a810251e 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskActions.tsx @@ -23,7 +23,6 @@ import Stacktrace from './Stacktrace'; import { STATUSES } from '../constants'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import ActionsDropdown, { ActionsDropdownItem } from '../../../components/controls/ActionsDropdown'; -import { Task } from '../../../app/types'; import { lazyLoad } from '../../../components/lazyLoad'; import ConfirmModal from '../../../components/controls/ConfirmModal'; @@ -34,9 +33,9 @@ const AnalysisWarningsModal = lazyLoad( interface Props { component?: unknown; - onCancelTask: (task: Task) => Promise; - onFilterTask: (task: Task) => void; - task: Task; + onCancelTask: (task: T.Task) => Promise; + onFilterTask: (task: T.Task) => void; + task: T.Task; } interface State { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx index 363fb4eae7a..cbc531d4bcf 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx @@ -31,10 +31,9 @@ import { import ShortLivingBranchIcon from '../../../components/icons-components/ShortLivingBranchIcon'; import LongLivingBranchIcon from '../../../components/icons-components/LongLivingBranchIcon'; import PullRequestIcon from '../../../components/icons-components/PullRequestIcon'; -import { Task } from '../../../app/types'; interface Props { - task: Task; + task: T.Task; } export default function TaskComponent({ task }: Props) { @@ -88,7 +87,7 @@ export default function TaskComponent({ task }: Props) { ); } -function getTaskComponentUrl(componentKey: string, task: Task) { +function getTaskComponentUrl(componentKey: string, task: T.Task) { if (task.branch) { if (task.branchType === 'SHORT') { return getShortLivingBranchUrl(componentKey, task.branch); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.tsx index 3f803849b55..1b458aac1c7 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Tasks.tsx @@ -20,15 +20,14 @@ import * as React from 'react'; import * as classNames from 'classnames'; import Task from './Task'; -import { Task as TaskType } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - tasks: TaskType[]; + tasks: T.Task[]; component?: unknown; loading: boolean; - onCancelTask: (task: TaskType) => Promise; - onFilterTask: (task: TaskType) => void; + onCancelTask: (task: T.Task) => Promise; + onFilterTask: (task: T.Task) => void; } export default function Tasks({ tasks, component, loading, onCancelTask, onFilterTask }: Props) { diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskActions-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskActions-test.tsx index 5ce2e4bcf58..6adc36ed287 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskActions-test.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskActions-test.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import TaskActions from '../TaskActions'; import { click } from '../../../../helpers/testUtils'; -import { Task } from '../../../../app/types'; it('renders', () => { expect(shallowRender()).toMatchSnapshot(); @@ -58,7 +57,7 @@ it('shows warnings', () => { expect(wrapper.find('AnalysisWarningsModal').exists()).toBeFalsy(); }); -function shallowRender(fields?: Partial, props?: Partial) { +function shallowRender(fields?: Partial, props?: Partial) { return shallow( (task.id === newTask.id ? newTask : task)); } 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 5eeb0c80896..01bc714f817 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 @@ -18,16 +18,15 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { addComponent, getComponent, addComponentChildren, getComponentChildren } from '../bucket'; -import { ComponentMeasure } from '../../../app/types'; -const component: ComponentMeasure = { key: 'frodo', name: 'frodo', qualifier: 'frodo' }; +const component: T.ComponentMeasure = { key: 'frodo', name: 'frodo', qualifier: 'frodo' }; const componentKey: string = 'foo'; -const childrenA: ComponentMeasure[] = [ +const childrenA: T.ComponentMeasure[] = [ { key: 'foo', name: 'foo', qualifier: 'foo' }, { key: 'bar', name: 'bar', qualifier: 'bar' } ]; -const childrenB: ComponentMeasure[] = [ +const childrenB: T.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 3e1600fbde7..1298507fd0e 100644 --- a/server/sonar-web/src/main/js/apps/code/bucket.ts +++ b/server/sonar-web/src/main/js/apps/code/bucket.ts @@ -17,29 +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. */ -import { ComponentMeasure, Breadcrumb } from '../../app/types'; -let bucket: { [key: string]: ComponentMeasure } = {}; +let bucket: { [key: string]: T.ComponentMeasure } = {}; let childrenBucket: { [key: string]: { - children: ComponentMeasure[]; + children: T.ComponentMeasure[]; page: number; total: number; }; } = {}; -let breadcrumbsBucket: { [key: string]: Breadcrumb[] } = {}; +let breadcrumbsBucket: { [key: string]: T.Breadcrumb[] } = {}; -export function addComponent(component: ComponentMeasure): void { +export function addComponent(component: T.ComponentMeasure): void { bucket[component.key] = component; } -export function getComponent(componentKey: string): ComponentMeasure { +export function getComponent(componentKey: string): T.ComponentMeasure { return bucket[componentKey]; } export function addComponentChildren( componentKey: string, - children: ComponentMeasure[], + children: T.ComponentMeasure[], total: number, page: number ): void { @@ -53,18 +52,18 @@ export function addComponentChildren( export function getComponentChildren( componentKey: string ): { - children: ComponentMeasure[]; + children: T.ComponentMeasure[]; page: number; total: number; } { return childrenBucket[componentKey]; } -export function addComponentBreadcrumbs(componentKey: string, breadcrumbs: Breadcrumb[]): void { +export function addComponentBreadcrumbs(componentKey: string, breadcrumbs: T.Breadcrumb[]): void { breadcrumbsBucket[componentKey] = breadcrumbs; } -export function getComponentBreadcrumbs(componentKey: string): Breadcrumb[] { +export function getComponentBreadcrumbs(componentKey: string): T.Breadcrumb[] { return breadcrumbsBucket[componentKey]; } diff --git a/server/sonar-web/src/main/js/apps/code/components/App.tsx b/server/sonar-web/src/main/js/apps/code/components/App.tsx index e4a25accdc5..9aa8d3a9e97 100644 --- a/server/sonar-web/src/main/js/apps/code/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/App.tsx @@ -26,7 +26,6 @@ import Breadcrumbs from './Breadcrumbs'; import Search from './Search'; import { addComponent, addComponentBreadcrumbs, clearBucket } from '../bucket'; import { retrieveComponentChildren, retrieveComponent, loadMoreChildren } from '../utils'; -import { Breadcrumb, Component, ComponentMeasure, BranchLike, Metric } from '../../../app/types'; import ListFooter from '../../../components/controls/ListFooter'; import SourceViewer from '../../../components/SourceViewer/SourceViewer'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; @@ -37,7 +36,7 @@ import { translate } from '../../../helpers/l10n'; import '../code.css'; interface StateToProps { - metrics: { [metric: string]: Metric }; + metrics: { [metric: string]: T.Metric }; } interface DispatchToProps { @@ -45,21 +44,21 @@ interface DispatchToProps { } interface OwnProps { - branchLike?: BranchLike; - component: Component; + branchLike?: T.BranchLike; + component: T.Component; location: { query: { [x: string]: string } }; } type Props = StateToProps & DispatchToProps & OwnProps; interface State { - baseComponent?: ComponentMeasure; - breadcrumbs: Breadcrumb[]; - components?: ComponentMeasure[]; + baseComponent?: T.ComponentMeasure; + breadcrumbs: T.Breadcrumb[]; + components?: T.ComponentMeasure[]; loading: boolean; page: number; - searchResults?: ComponentMeasure[]; - sourceViewer?: ComponentMeasure; + searchResults?: T.ComponentMeasure[]; + sourceViewer?: T.ComponentMeasure; total: number; } 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 c1fca8d200b..5aadebbdb85 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,11 @@ */ import * as React from 'react'; import ComponentName from './ComponentName'; -import { BranchLike, Breadcrumb, ComponentMeasure } from '../../../app/types'; interface Props { - branchLike?: BranchLike; - breadcrumbs: Breadcrumb[]; - rootComponent: ComponentMeasure; + branchLike?: T.BranchLike; + breadcrumbs: T.Breadcrumb[]; + rootComponent: T.ComponentMeasure; } export default function Breadcrumbs({ branchLike, breadcrumbs, rootComponent }: Props) { 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 81b80ea3591..9352241bd26 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 @@ -23,19 +23,18 @@ import ComponentName from './ComponentName'; import ComponentMeasure from './ComponentMeasure'; import ComponentLink from './ComponentLink'; import ComponentPin from './ComponentPin'; -import { BranchLike, Metric, ComponentMeasure as IComponentMeasure } from '../../../app/types'; const TOP_OFFSET = 200; const BOTTOM_OFFSET = 10; interface Props { - branchLike?: BranchLike; + branchLike?: T.BranchLike; canBrowse?: boolean; - component: IComponentMeasure; + component: T.ComponentMeasure; isLeak: boolean; - metrics: Metric[]; - previous?: IComponentMeasure; - rootComponent: IComponentMeasure; + metrics: T.Metric[]; + previous?: T.ComponentMeasure; + rootComponent: T.ComponentMeasure; selected?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentLink.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentLink.tsx index eb6e931c945..e60a57cc2e9 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentLink.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentLink.tsx @@ -19,14 +19,13 @@ */ import * as React from 'react'; import { Link } from 'react-router'; -import { BranchLike, ComponentMeasure } from '../../../app/types'; import LinkIcon from '../../../components/icons-components/LinkIcon'; import { translate } from '../../../helpers/l10n'; import { getBranchLikeUrl } from '../../../helpers/urls'; interface Props { - branchLike?: BranchLike; - component: ComponentMeasure; + branchLike?: T.BranchLike; + component: T.ComponentMeasure; } export default function ComponentLink({ component, branchLike }: Props) { 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 e33ff7e5d68..fdc492f8e1e 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 @@ -19,13 +19,12 @@ */ import * as React from 'react'; import Measure from '../../../components/measure/Measure'; -import { Metric, ComponentMeasure as IComponentMeasure } from '../../../app/types'; import { isDiffMetric } from '../../../helpers/measures'; import { getLeakValue } from '../../../components/measure/utils'; interface Props { - component: IComponentMeasure; - metric: Metric; + component: T.ComponentMeasure; + metric: T.Metric; } export default function ComponentMeasure({ component, metric }: Props) { diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx index e303cffef93..55a25d0371f 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 @@ -21,13 +21,12 @@ import * as React from 'react'; import { Link } from 'react-router'; import Truncated from './Truncated'; import * as theme from '../../../app/theme'; -import { BranchLike, ComponentMeasure } from '../../../app/types'; import QualifierIcon from '../../../components/icons-components/QualifierIcon'; import { getBranchLikeQuery } from '../../../helpers/branches'; import LongLivingBranchIcon from '../../../components/icons-components/LongLivingBranchIcon'; import { translate } from '../../../helpers/l10n'; -function getTooltip(component: ComponentMeasure) { +function getTooltip(component: T.ComponentMeasure) { const isFile = component.qualifier === 'FIL' || component.qualifier === 'UTS'; if (isFile && component.path) { return component.path + '\n\n' + component.key; @@ -52,11 +51,11 @@ function mostCommitPrefix(strings: string[]) { } interface Props { - branchLike?: BranchLike; + branchLike?: T.BranchLike; canBrowse?: boolean; - component: ComponentMeasure; - previous?: ComponentMeasure; - rootComponent: ComponentMeasure; + component: T.ComponentMeasure; + previous?: T.ComponentMeasure; + rootComponent: T.ComponentMeasure; } export default function ComponentName(props: Props) { 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 24ef4d65621..f486ce21bf3 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 @@ -19,14 +19,13 @@ */ import * as React from 'react'; import * as PropTypes from 'prop-types'; -import { BranchLike, ComponentMeasure } from '../../../app/types'; import PinIcon from '../../../components/icons-components/PinIcon'; import { WorkspaceContext } from '../../../components/workspace/context'; import { translate } from '../../../helpers/l10n'; interface Props { - branchLike?: BranchLike; - component: ComponentMeasure; + branchLike?: T.BranchLike; + component: T.ComponentMeasure; } export default class ComponentPin extends React.PureComponent { 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 2a6bcf6e9f0..c8672d01b7e 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,16 +22,15 @@ import * as classNames from 'classnames'; import Component from './Component'; import ComponentsEmpty from './ComponentsEmpty'; import ComponentsHeader from './ComponentsHeader'; -import { BranchLike, ComponentMeasure, Metric } from '../../../app/types'; import { getCodeMetrics, showLeakMeasure } from '../utils'; interface Props { - baseComponent?: ComponentMeasure; - branchLike?: BranchLike; - components: ComponentMeasure[]; - metrics: { [metric: string]: Metric }; - rootComponent: ComponentMeasure; - selected?: ComponentMeasure; + baseComponent?: T.ComponentMeasure; + branchLike?: T.BranchLike; + components: T.ComponentMeasure[]; + metrics: { [metric: string]: T.Metric }; + rootComponent: T.ComponentMeasure; + selected?: T.ComponentMeasure; } export default function Components(props: Props) { 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 04360721e2d..cf518c06f80 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,13 +20,12 @@ import * as React from 'react'; import * as classNames from 'classnames'; import { translate } from '../../../helpers/l10n'; -import { ComponentMeasure } from '../../../app/types'; interface Props { - baseComponent?: ComponentMeasure; + baseComponent?: T.ComponentMeasure; isLeak: boolean; metrics: string[]; - rootComponent: ComponentMeasure; + rootComponent: T.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 291ff86d533..f8ae8822fd5 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 @@ -22,22 +22,21 @@ import * as PropTypes from 'prop-types'; import * as classNames from 'classnames'; import Components from './Components'; import { getTree } from '../../../api/components'; -import { BranchLike, ComponentMeasure } from '../../../app/types'; import SearchBox from '../../../components/controls/SearchBox'; import { getBranchLikeQuery } from '../../../helpers/branches'; import { translate } from '../../../helpers/l10n'; import { getProjectUrl } from '../../../helpers/urls'; interface Props { - branchLike?: BranchLike; - component: ComponentMeasure; + branchLike?: T.BranchLike; + component: T.ComponentMeasure; location: {}; } interface State { query: string; loading: boolean; - results?: ComponentMeasure[]; + results?: T.ComponentMeasure[]; selectedIndex?: number; } diff --git a/server/sonar-web/src/main/js/apps/code/components/__tests__/Components-test.tsx b/server/sonar-web/src/main/js/apps/code/components/__tests__/Components-test.tsx index f2dee8de3cd..c5388d552a7 100644 --- a/server/sonar-web/src/main/js/apps/code/components/__tests__/Components-test.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/__tests__/Components-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import Components from '../Components'; -import { BranchType } from '../../../../app/types'; const COMPONENT = { key: 'foo', name: 'Foo', qualifier: 'TRK' }; const PORTFOLIO = { key: 'bar', name: 'Bar', qualifier: 'VW' }; @@ -29,7 +28,7 @@ const BRANCH = { isMain: false, name: 'feature', mergeBranch: 'master', - type: BranchType.SHORT + type: 'SHORT' }; it('renders correctly', () => { 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 cb2d2045cf3..73987dc66c0 100644 --- a/server/sonar-web/src/main/js/apps/code/utils.ts +++ b/server/sonar-web/src/main/js/apps/code/utils.ts @@ -27,7 +27,6 @@ import { getComponentBreadcrumbs } from './bucket'; import { getChildren, getComponent, getBreadcrumbs } from '../../api/components'; -import { BranchLike, ComponentMeasure, Breadcrumb } from '../../app/types'; import { getBranchLikeQuery, isShortLivingBranch, isPullRequest } from '../../helpers/branches'; const METRICS = [ @@ -64,8 +63,8 @@ function requestChildren( componentKey: string, metrics: string[], page: number, - branchLike?: BranchLike -): Promise { + branchLike?: T.BranchLike +): Promise { return getChildren(componentKey, metrics, { p: page, ps: PAGE_SIZE, @@ -83,13 +82,13 @@ function requestChildren( function requestAllChildren( componentKey: string, metrics: string[], - branchLike?: BranchLike -): Promise { + branchLike?: T.BranchLike +): Promise { return requestChildren(componentKey, metrics, 1, branchLike); } interface Children { - components: ComponentMeasure[]; + components: T.ComponentMeasure[]; page: number; total: number; } @@ -98,10 +97,10 @@ interface ExpandRootDirFunc { (children: Children): Promise; } -function expandRootDir(metrics: string[], branchLike?: BranchLike): ExpandRootDirFunc { +function expandRootDir(metrics: string[], branchLike?: T.BranchLike): ExpandRootDirFunc { return function({ components, total, ...other }) { const rootDir = components.find( - (component: ComponentMeasure) => component.qualifier === 'DIR' && component.name === '/' + (component: T.ComponentMeasure) => component.qualifier === 'DIR' && component.name === '/' ); if (rootDir) { return requestAllChildren(rootDir.key, metrics, branchLike).then(rootDirComponents => { @@ -123,21 +122,21 @@ function prepareChildren(r: any): Children { }; } -export function showLeakMeasure(branchLike?: BranchLike) { +export function showLeakMeasure(branchLike?: T.BranchLike) { return isShortLivingBranch(branchLike) || isPullRequest(branchLike); } -function skipRootDir(breadcrumbs: ComponentMeasure[]) { +function skipRootDir(breadcrumbs: T.ComponentMeasure[]) { return breadcrumbs.filter(component => { return !(component.qualifier === 'DIR' && component.name === '/'); }); } -function storeChildrenBase(children: ComponentMeasure[]) { +function storeChildrenBase(children: T.ComponentMeasure[]) { children.forEach(addComponent); } -function storeChildrenBreadcrumbs(parentComponentKey: string, children: Breadcrumb[]) { +function storeChildrenBreadcrumbs(parentComponentKey: string, children: T.Breadcrumb[]) { const parentBreadcrumbs = getComponentBreadcrumbs(parentComponentKey); if (parentBreadcrumbs) { children.forEach(child => { @@ -147,7 +146,7 @@ function storeChildrenBreadcrumbs(parentComponentKey: string, children: Breadcru } } -export function getCodeMetrics(qualifier: string, branchLike?: BranchLike) { +export function getCodeMetrics(qualifier: string, branchLike?: T.BranchLike) { if (['VW', 'SVW'].includes(qualifier)) { return PORTFOLIO_METRICS; } @@ -160,7 +159,7 @@ export function getCodeMetrics(qualifier: string, branchLike?: BranchLike) { return METRICS; } -function retrieveComponentBase(componentKey: string, qualifier: string, branchLike?: BranchLike) { +function retrieveComponentBase(componentKey: string, qualifier: string, branchLike?: T.BranchLike) { const existing = getComponentFromBucket(componentKey); if (existing) { return Promise.resolve(existing); @@ -181,8 +180,8 @@ function retrieveComponentBase(componentKey: string, qualifier: string, branchLi export function retrieveComponentChildren( componentKey: string, qualifier: string, - branchLike?: BranchLike -): Promise<{ components: ComponentMeasure[]; page: number; total: number }> { + branchLike?: T.BranchLike +): Promise<{ components: T.ComponentMeasure[]; page: number; total: number }> { const existing = getComponentChildren(componentKey); if (existing) { return Promise.resolve({ @@ -211,8 +210,8 @@ export function retrieveComponentChildren( function retrieveComponentBreadcrumbs( component: string, - branchLike?: BranchLike -): Promise { + branchLike?: T.BranchLike +): Promise { const existing = getComponentBreadcrumbs(component); if (existing) { return Promise.resolve(existing); @@ -229,11 +228,11 @@ function retrieveComponentBreadcrumbs( export function retrieveComponent( componentKey: string, qualifier: string, - branchLike?: BranchLike + branchLike?: T.BranchLike ): Promise<{ - breadcrumbs: Breadcrumb[]; - component: ComponentMeasure; - components: ComponentMeasure[]; + breadcrumbs: T.Breadcrumb[]; + component: T.ComponentMeasure; + components: T.ComponentMeasure[]; page: number; total: number; }> { @@ -256,7 +255,7 @@ export function loadMoreChildren( componentKey: string, page: number, qualifier: string, - branchLike?: BranchLike + branchLike?: T.BranchLike ): Promise { const metrics = getCodeMetrics(qualifier, branchLike); 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 043d71b134a..be5294254e7 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,18 +20,17 @@ import * as React from 'react'; import ActivationFormModal from './ActivationFormModal'; import { Profile as BaseProfile } from '../../../api/quality-profiles'; -import { Rule, RuleDetails, RuleActivation } from '../../../app/types'; import { Button } from '../../../components/ui/buttons'; interface Props { - activation?: RuleActivation; + activation?: T.RuleActivation; buttonText: string; className?: string; modalHeader: string; onDone: (severity: string) => Promise; organization: string | undefined; profiles: BaseProfile[]; - rule: Rule | RuleDetails; + rule: T.Rule | T.RuleDetails; updateMode?: boolean; } 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 d72adba3402..b60724a2a60 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 @@ -22,7 +22,6 @@ import Modal from '../../../components/controls/Modal'; import Select from '../../../components/controls/Select'; import SeverityHelper from '../../../components/shared/SeverityHelper'; import { activateRule, Profile as BaseProfile } from '../../../api/quality-profiles'; -import { Rule, RuleDetails, RuleActivation } from '../../../app/types'; import { SEVERITIES } from '../../../helpers/constants'; import { translate } from '../../../helpers/l10n'; import { sortProfiles } from '../../quality-profiles/utils'; @@ -30,13 +29,13 @@ import { SubmitButton, ResetButtonLink } from '../../../components/ui/buttons'; import { Alert } from '../../../components/ui/Alert'; interface Props { - activation?: RuleActivation; + activation?: T.RuleActivation; modalHeader: string; onClose: () => void; onDone: (severity: string) => Promise; organization: string | undefined; profiles: BaseProfile[]; - rule: Rule | RuleDetails; + rule: T.Rule | T.RuleDetails; updateMode?: boolean; } @@ -150,7 +149,7 @@ export default class ActivationFormModal extends React.PureComponent { detachShortcuts = () => key.deleteScope('coding-rules'); - getOpenRule = (props: Props, rules: Rule[]) => { + getOpenRule = (props: Props, rules: T.Rule[]) => { const open = getOpen(props.location.query); return open && rules.find(rule => rule.key === open); }; @@ -450,7 +442,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: Rule[], selectedIndex: number | undefined) => { + pickRuleAround = (rules: T.Rule[], selectedIndex: number | undefined) => { if (selectedIndex === undefined || rules.length === 0) { return undefined; } @@ -627,7 +619,7 @@ export class App extends React.PureComponent { } } -function parseActives(rawActives: { [rule: string]: RuleActivation[] }) { +function parseActives(rawActives: { [rule: string]: T.RuleActivation[] }) { const actives: Actives = {}; for (const [rule, activations] of Object.entries(rawActives)) { actives[rule] = {}; 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 80a997a3f16..c12c55e53b3 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,10 +24,9 @@ import { Profile } from '../../../api/quality-profiles'; import Dropdown from '../../../components/controls/Dropdown'; import { Button } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; -import { Languages } from '../../../app/types'; interface Props { - languages: Languages; + languages: T.Languages; organization: string | undefined; query: Query; referencedProfiles: { [profile: string]: Profile }; 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 e16077643e7..ee8abcf59b5 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,12 +25,11 @@ import Select from '../../../components/controls/Select'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; import { SubmitButton, ResetButtonLink } from '../../../components/ui/buttons'; -import { Languages } from '../../../app/types'; import { Alert } from '../../../components/ui/Alert'; interface Props { action: string; - languages: Languages; + languages: T.Languages; onClose: () => void; organization: string | undefined; profile?: Profile; 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 6c8e466d200..4927fc99538 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 @@ -19,14 +19,13 @@ */ import * as React from 'react'; import CustomRuleFormModal from './CustomRuleFormModal'; -import { RuleDetails } from '../../../app/types'; interface Props { children: (props: { onClick: () => void }) => React.ReactNode; - customRule?: RuleDetails; - onDone: (newRuleDetails: RuleDetails) => void; + customRule?: T.RuleDetails; + onDone: (newRuleDetails: T.RuleDetails) => void; organization: string | undefined; - templateRule: RuleDetails; + templateRule: T.RuleDetails; } interface State { @@ -55,7 +54,7 @@ export default class CustomRuleButton extends React.PureComponent } }; - handleDone = (newRuleDetails: RuleDetails) => { + handleDone = (newRuleDetails: T.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 43433e1c308..4bfbbd12c42 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 @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { RuleDetails, RuleParameter, RuleType } from '../../../app/types'; import Modal from '../../../components/controls/Modal'; import { translate } from '../../../helpers/l10n'; import MarkdownTips from '../../../components/common/MarkdownTips'; @@ -33,11 +32,11 @@ import { SubmitButton, ResetButtonLink } from '../../../components/ui/buttons'; import { Alert } from '../../../components/ui/Alert'; interface Props { - customRule?: RuleDetails; + customRule?: T.RuleDetails; onClose: () => void; - onDone: (newRuleDetails: RuleDetails) => void; + onDone: (newRuleDetails: T.RuleDetails) => void; organization: string | undefined; - templateRule: RuleDetails; + templateRule: T.RuleDetails; } interface State { @@ -226,7 +225,7 @@ export default class CustomRuleFormModal extends React.PureComponent ); - renderTypeOption = ({ value }: { value: RuleType }) => { + renderTypeOption = ({ value }: { value: T.RuleType }) => { return ; }; @@ -302,7 +301,7 @@ export default class CustomRuleFormModal extends React.PureComponent ); - renderParameterField = (param: RuleParameter) => ( + renderParameterField = (param: T.RuleParameter) => (

    {param.key}

    diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/InheritanceFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/InheritanceFacet.tsx index c4c1102db07..21f968d133b 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/InheritanceFacet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/InheritanceFacet.tsx @@ -19,16 +19,15 @@ */ import * as React from 'react'; import Facet, { BasicProps } from './Facet'; -import { RuleInheritance, Omit } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; -interface Props extends Omit { +interface Props extends T.Omit { disabled: boolean; - value: RuleInheritance | undefined; + value: T.RuleInheritance | undefined; } export default class InheritanceFacet extends React.PureComponent { - renderName = (value: RuleInheritance) => + renderName = (value: T.RuleInheritance) => translate('coding_rules.filters.inheritance', value.toLowerCase()); render() { @@ -39,7 +38,7 @@ export default class InheritanceFacet extends React.PureComponent { {...props} disabled={this.props.disabled} disabledHelper={translate('coding_rules.filters.inheritance.inactive')} - options={Object.values(RuleInheritance)} + options={['NONE', 'INHERITED', 'OVERRIDES']} property="inheritance" renderName={this.renderName} renderTextName={this.renderName} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/PageActions.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/PageActions.tsx index 3341efb884c..ff8078cc940 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/PageActions.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/PageActions.tsx @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Paging } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import PageCounter from '../../../components/common/PageCounter'; @@ -27,7 +26,7 @@ import ReloadButton from '../../../components/controls/ReloadButton'; interface Props { loading: boolean; onReload: () => void; - paging?: Paging; + paging?: T.Paging; selectedIndex?: number; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx index fabcfaf39ee..9cc1230db9d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx @@ -28,7 +28,6 @@ import RuleDetailsProfiles from './RuleDetailsProfiles'; import { Query, Activation } from '../query'; import { Profile } from '../../../api/quality-profiles'; import { getRuleDetails, deleteRule, updateRule } from '../../../api/rules'; -import { RuleActivation, RuleDetails as IRuleDetails } from '../../../app/types'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import ConfirmButton from '../../../components/controls/ConfirmButton'; import DocTooltip from '../../../components/docs/DocTooltip'; @@ -51,9 +50,9 @@ interface Props { } interface State { - actives?: RuleActivation[]; + actives?: T.RuleActivation[]; loading: boolean; - ruleDetails?: IRuleDetails; + ruleDetails?: T.RuleDetails; } export default class RuleDetails extends React.PureComponent { @@ -95,7 +94,7 @@ export default class RuleDetails extends React.PureComponent { } ); - handleRuleChange = (ruleDetails: IRuleDetails) => { + handleRuleChange = (ruleDetails: T.RuleDetails) => { if (this.mounted) { this.setState({ ruleDetails }); } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsCustomRules.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsCustomRules.tsx index 3e5a9bebcac..a7117591fc4 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsCustomRules.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsCustomRules.tsx @@ -22,7 +22,6 @@ import { Link } from 'react-router'; import { sortBy } from 'lodash'; import CustomRuleButton from './CustomRuleButton'; import { searchRules, deleteRule } from '../../../api/rules'; -import { Rule, RuleDetails } from '../../../app/types'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import ConfirmButton from '../../../components/controls/ConfirmButton'; import SeverityHelper from '../../../components/shared/SeverityHelper'; @@ -33,12 +32,12 @@ import { getRuleUrl } from '../../../helpers/urls'; interface Props { canChange?: boolean; organization: string | undefined; - ruleDetails: RuleDetails; + ruleDetails: T.RuleDetails; } interface State { loading: boolean; - rules?: Rule[]; + rules?: T.Rule[]; } export default class RuleDetailsCustomRules extends React.PureComponent { @@ -80,7 +79,7 @@ export default class RuleDetailsCustomRules extends React.PureComponent { + handleRuleCreate = (newRuleDetails: T.RuleDetails) => { if (this.mounted) { this.setState(({ rules = [] }: State) => ({ rules: [...rules, newRuleDetails] @@ -98,7 +97,7 @@ export default class RuleDetailsCustomRules extends React.PureComponent ( + renderRule = (rule: T.Rule) => ( {rule.name} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx index 1b9ae650cb4..349f6976b4f 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx @@ -20,16 +20,15 @@ import * as React from 'react'; import RemoveExtendedDescriptionModal from './RemoveExtendedDescriptionModal'; import { updateRule } from '../../../api/rules'; -import { RuleDetails } from '../../../app/types'; import MarkdownTips from '../../../components/common/MarkdownTips'; import { Button, ResetButtonLink } from '../../../components/ui/buttons'; import { translate, translateWithParameters } from '../../../helpers/l10n'; interface Props { canWrite: boolean | undefined; - onChange: (newRuleDetails: RuleDetails) => void; + onChange: (newRuleDetails: T.RuleDetails) => void; organization: string | undefined; - ruleDetails: RuleDetails; + ruleDetails: T.RuleDetails; } interface State { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx index 9bcca9b529a..8f0d290c3eb 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsIssues.tsx @@ -23,14 +23,13 @@ import { Link } from 'react-router'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import Tooltip from '../../../components/controls/Tooltip'; import { getFacet } from '../../../api/issues'; -import { RuleDetails, RuleType } from '../../../app/types'; import { getIssuesUrl } from '../../../helpers/urls'; import { formatMeasure } from '../../../helpers/measures'; import { translate } from '../../../helpers/l10n'; interface Props { organization: string | undefined; - ruleDetails: Pick; + ruleDetails: Pick; } interface Project { @@ -73,8 +72,8 @@ export default class RuleDetailsIssues extends React.PureComponent resolved: 'false', rules: this.props.ruleDetails.key, types: - this.props.ruleDetails.type === RuleType.Hotspot - ? [RuleType.Vulnerability, RuleType.Hotspot].join() + this.props.ruleDetails.type === 'SECURITY_HOTSPOT' + ? ['VULNERABILITY', 'SECURITY_HOTSPOT'].join() : undefined }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx index 1e7c69c3ea1..fdf418212fe 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsMeta.tsx @@ -22,7 +22,6 @@ import { Link } from 'react-router'; import RuleDetailsTagsPopup from './RuleDetailsTagsPopup'; import SimilarRulesFilter from './SimilarRulesFilter'; import { Query } from '../query'; -import { RuleDetails, RuleScope } from '../../../app/types'; import { getRuleUrl } from '../../../helpers/urls'; import LinkIcon from '../../../components/icons-components/LinkIcon'; import RuleScopeIcon from '../../../components/icons-components/RuleScopeIcon'; @@ -44,7 +43,7 @@ interface Props { onTagsChange: (tags: string[]) => void; organization: string | undefined; referencedRepositories: { [repository: string]: { key: string; language: string; name: string } }; - ruleDetails: RuleDetails; + ruleDetails: T.RuleDetails; } const EXTERNAL_RULE_REPO_PREFIX = 'external_'; @@ -201,7 +200,7 @@ export default class RuleDetailsMeta extends React.PureComponent { }; renderScope = () => { - const scope = this.props.ruleDetails.scope || RuleScope.Main; + const scope = this.props.ruleDetails.scope || 'MAIN'; return (
  • diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsParameters.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsParameters.tsx index a7385653070..6e3efa4ae36 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsParameters.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsParameters.tsx @@ -18,15 +18,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { RuleParameter } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - params: RuleParameter[]; + params: T.RuleParameter[]; } export default class RuleDetailsParameters extends React.PureComponent { - renderParameter = (param: RuleParameter) => ( + renderParameter = (param: T.RuleParameter) => ( {param.key} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx index 3026fac6e3e..f5800a3b282 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsProfiles.tsx @@ -23,7 +23,6 @@ import { Link } from 'react-router'; import ActivationButton from './ActivationButton'; import RuleInheritanceIcon from './RuleInheritanceIcon'; import { Profile, deactivateRule, activateRule } from '../../../api/quality-profiles'; -import { RuleActivation, RuleDetails, RuleInheritance } from '../../../app/types'; import ConfirmButton from '../../../components/controls/ConfirmButton'; import BuiltInQualityProfileBadge from '../../quality-profiles/components/BuiltInQualityProfileBadge'; import InstanceMessage from '../../../components/common/InstanceMessage'; @@ -34,13 +33,13 @@ import { getQualityProfileUrl } from '../../../helpers/urls'; import { translate, translateWithParameters } from '../../../helpers/l10n'; interface Props { - activations: RuleActivation[] | undefined; + activations: T.RuleActivation[] | undefined; canWrite: boolean | undefined; onActivate: () => Promise; onDeactivate: () => Promise; organization: string | undefined; referencedProfiles: { [profile: string]: Profile }; - ruleDetails: RuleDetails; + ruleDetails: T.RuleDetails; } interface State { @@ -90,7 +89,7 @@ export default class RuleDetailsProfiles extends React.PureComponent { + renderInheritedProfile = (activation: T.RuleActivation, profile: Profile) => { if (!profile.parentName) { return null; } @@ -101,8 +100,7 @@ export default class RuleDetailsProfiles extends React.PureComponent - {(activation.inherit === RuleInheritance.Overridden || - activation.inherit === RuleInheritance.Inherited) && ( + {(activation.inherit === 'OVERRIDES' || activation.inherit === 'INHERITED') && ( <> @@ -114,7 +112,7 @@ export default class RuleDetailsProfiles extends React.PureComponent ( + renderSeverity = (activation: T.RuleActivation, parentActivation?: T.RuleActivation) => ( @@ -130,7 +128,10 @@ export default class RuleDetailsProfiles extends React.PureComponent ); - renderParameter = (param: { key: string; value: string }, parentActivation?: RuleActivation) => { + renderParameter = ( + param: { key: string; value: string }, + parentActivation?: T.RuleActivation + ) => { const originalParam = parentActivation && parentActivation.params.find(p => p.key === param.key); const originalValue = originalParam && originalParam.value; @@ -152,16 +153,16 @@ export default class RuleDetailsProfiles extends React.PureComponent ( + renderParameters = (activation: T.RuleActivation, parentActivation?: T.RuleActivation) => ( {activation.params.map(param => this.renderParameter(param, parentActivation))} ); - renderActions = (activation: RuleActivation, profile: Profile) => { + renderActions = (activation: T.RuleActivation, profile: Profile) => { const canEdit = profile.actions && profile.actions.edit && !profile.isBuiltIn; const { ruleDetails } = this.props; - const hasParent = activation.inherit !== RuleInheritance.NotInherited && profile.parentKey; + const hasParent = activation.inherit !== 'NONE' && profile.parentKey; return ( {canEdit && ( @@ -179,7 +180,7 @@ export default class RuleDetailsProfiles extends React.PureComponent )} {hasParent ? ( - activation.inherit === RuleInheritance.Overridden && + activation.inherit === 'OVERRIDES' && profile.parentName && ( { + renderActivation = (activation: T.RuleActivation) => { const { activations = [], ruleDetails } = this.props; const profile = this.props.referencedProfiles[activation.qProfile]; if (!profile) { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleInheritanceIcon.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleInheritanceIcon.tsx index 6ac38d6a51e..cf12ec2adc1 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleInheritanceIcon.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleInheritanceIcon.tsx @@ -19,15 +19,14 @@ */ import * as React from 'react'; import * as theme from '../../../app/theme'; -import { RuleInheritance } from '../../../app/types'; interface Props { className?: string; - inheritance: RuleInheritance.Inherited | RuleInheritance.Overridden; + inheritance: T.RuleInheritance; } export default function RuleInheritanceIcon({ className, inheritance, ...other }: Props) { - const fill = inheritance === RuleInheritance.Overridden ? theme.red : theme.baseFontColor; + const fill = inheritance === 'OVERRIDES' ? theme.red : theme.baseFontColor; return ( ) => void; onOpen: (ruleKey: string) => void; organization: string | undefined; - rule: Rule; + rule: T.Rule; selected: boolean; selectedProfile?: Profile; } @@ -63,7 +62,7 @@ export default class RuleListItem extends React.PureComponent { if (this.props.selectedProfile) { this.props.onActivate(this.props.selectedProfile.key, this.props.rule.key, { severity, - inherit: RuleInheritance.NotInherited + inherit: 'NONE' }); } return Promise.resolve(); @@ -93,7 +92,7 @@ export default class RuleListItem extends React.PureComponent { {selectedProfile && selectedProfile.parentName && ( <> - {activation.inherit === RuleInheritance.Overridden && ( + {activation.inherit === 'OVERRIDES' && ( { /> )} - {activation.inherit === RuleInheritance.Inherited && ( + {activation.inherit === 'INHERITED' && ( ) => void; - rule: Rule; + rule: T.Rule; } export default class SimilarRulesFilter extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/TemplateFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/TemplateFacet.tsx index ed473536094..aa0d4d0675d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/TemplateFacet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/TemplateFacet.tsx @@ -19,11 +19,10 @@ */ import * as React from 'react'; import Facet, { BasicProps } from './Facet'; -import { Omit } from '../../../app/types'; import DocTooltip from '../../../components/docs/DocTooltip'; import { translate } from '../../../helpers/l10n'; -interface Props extends Omit { +interface Props extends T.Omit { onChange: (changes: { template: boolean | undefined }) => void; value: boolean | undefined; } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/TypeFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/TypeFacet.tsx index 0a08bf5587f..ff2accac97f 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/TypeFacet.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/TypeFacet.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import Facet, { BasicProps } from './Facet'; import IssueTypeIcon from '../../../components/ui/IssueTypeIcon'; import { translate } from '../../../helpers/l10n'; -import { RuleType } from '../../../app/types'; export default class TypeFacet extends React.PureComponent { renderName = (type: string) => ( @@ -34,7 +33,7 @@ export default class TypeFacet extends React.PureComponent { renderTextName = (type: string) => translate('issue.type', type); render() { - const options = [RuleType.Bug, RuleType.Vulnerability, RuleType.CodeSmell, RuleType.Hotspot]; + const options = ['BUG', 'VULNERABILITY', 'CODE_SMELL', 'SECURITY_HOTSPOT']; return ( ({ updateRule: jest.fn().mockResolvedValue('updatedrule') })); -const RULE = { +const RULE: T.RuleDetails = { key: 'squid:S1133', repo: 'squid', name: 'Deprecated code should be removed', @@ -38,27 +37,30 @@ const RULE = { status: 'READY', lang: 'java', langName: 'Java', - type: RuleType.CodeSmell + type: 'CODE_SMELL' }; -const EXTERNAL_RULE = { +const EXTERNAL_RULE: T.RuleDetails = { + createdAt: '2013-07-26T09:40:51+0200', key: 'external_xoo:OneExternalIssuePerLine', repo: 'external_xoo', name: 'xoo:OneExternalIssuePerLine', + severity: 'MAJOR', status: 'READY', isExternal: true, - type: RuleType.Unknown + type: 'UNKNOWN' }; -const EXTERNAL_RULE_WITH_DATA = { +const EXTERNAL_RULE_WITH_DATA: T.RuleDetails = { key: 'external_xoo:OneExternalIssueWithDetailsPerLine', repo: 'external_xoo', name: 'One external issue per line', createdAt: '2018-05-31T11:19:51+0200', htmlDesc: '

    Html Description

    ', + severity: 'MAJOR', status: 'READY', isExternal: true, - type: RuleType.Bug + type: 'BUG' }; it('should display correctly', () => { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsIssues-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsIssues-test.tsx index cbd77073ed2..731cddcfeed 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsIssues-test.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsIssues-test.tsx @@ -22,7 +22,6 @@ import { shallow } from 'enzyme'; import RuleDetailsIssues from '../RuleDetailsIssues'; import { waitAndUpdate } from '../../../../helpers/testUtils'; import { getFacet } from '../../../../api/issues'; -import { RuleType } from '../../../../app/types'; jest.mock('../../../../api/issues', () => ({ getFacet: jest.fn().mockResolvedValue({ @@ -39,14 +38,14 @@ beforeEach(() => { }); it('should fetch issues and render', async () => { - await check(RuleType.Bug, undefined); + await check('BUG', undefined); }); it('should handle hotspot rules', async () => { - await check(RuleType.Hotspot, [RuleType.Vulnerability, RuleType.Hotspot]); + await check('SECURITY_HOTSPOT', ['VULNERABILITY', 'SECURITY_HOTSPOT']); }); -async function check(ruleType: RuleType, requestedTypes: RuleType[] | undefined) { +async function check(ruleType: T.RuleType, requestedTypes: T.RuleType[] | undefined) { const wrapper = shallow( ); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx index 137e8b91a1a..d0a62e669c9 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleDetailsMeta-test.tsx @@ -20,10 +20,9 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import RuleDetailsMeta from '../RuleDetailsMeta'; -import { RuleScope, RuleType } from '../../../../app/types'; import RuleDetailsTagsPopup from '../RuleDetailsTagsPopup'; -const RULE = { +const RULE: T.RuleDetails = { key: 'squid:S1133', repo: 'squid', name: 'Deprecated code should be removed', @@ -32,22 +31,23 @@ const RULE = { status: 'READY', lang: 'java', langName: 'Java', - scope: RuleScope.Main, - type: RuleType.CodeSmell + scope: 'MAIN', + type: 'CODE_SMELL' }; -const EXTERNAL_RULE = { +const EXTERNAL_RULE: T.RuleDetails = { key: 'external_xoo:OneExternalIssuePerLine', repo: 'external_xoo', name: 'xoo:OneExternalIssuePerLine', createdAt: '2018-05-31T11:22:13+0200', + severity: 'MAJOR', status: 'READY', - scope: RuleScope.All, + scope: 'ALL', isExternal: true, - type: RuleType.Unknown + type: 'UNKNOWN' }; -const EXTERNAL_RULE_WITH_DATA = { +const EXTERNAL_RULE_WITH_DATA: T.RuleDetails = { key: 'external_xoo:OneExternalIssueWithDetailsPerLine', repo: 'external_xoo', name: 'One external issue per line', @@ -57,9 +57,9 @@ const EXTERNAL_RULE_WITH_DATA = { tags: ['tag'], lang: 'xoo', langName: 'Xoo', - scope: RuleScope.All, + scope: 'ALL', isExternal: true, - type: RuleType.Bug + type: 'BUG' }; it('should display right meta info', () => { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleListItem-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleListItem-test.tsx index 0772c6afe30..8d7ba0a1daf 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleListItem-test.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleListItem-test.tsx @@ -20,10 +20,9 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import RuleListItem from '../RuleListItem'; -import { Rule, RuleType } from '../../../../app/types'; import { mockEvent } from '../../../../helpers/testUtils'; -const rule: Rule = { +const rule: T.Rule = { key: 'foo', lang: 'js', langName: 'JavaScript', @@ -32,7 +31,7 @@ const rule: Rule = { status: 'READY', sysTags: ['a', 'b'], tags: ['x'], - type: RuleType.CodeSmell + type: 'CODE_SMELL' }; it('should render', () => { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/query.ts b/server/sonar-web/src/main/js/apps/coding-rules/query.ts index 6fc8f3c0209..c6d16277e8b 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/query.ts +++ b/server/sonar-web/src/main/js/apps/coding-rules/query.ts @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { RuleInheritance } from '../../app/types'; import { RawQuery, parseAsString, @@ -38,7 +37,7 @@ export interface Query { activationSeverities: string[]; availableSince: Date | undefined; compareToProfile: string | undefined; - inheritance: RuleInheritance | undefined; + inheritance: T.RuleInheritance | undefined; languages: string[]; profile: string | undefined; repositories: string[]; @@ -62,7 +61,7 @@ export type Facets = { [F in FacetKey]?: Facet }; export type OpenFacets = { [F in FacetKey]?: boolean }; export interface Activation { - inherit: string; + inherit: T.RuleInheritance; severity: string; } @@ -141,18 +140,14 @@ export function getOpen(query: RawQuery) { return query.open; } -function parseAsInheritance(value?: string): RuleInheritance | undefined { - if (value === RuleInheritance.Inherited) { - return RuleInheritance.Inherited; - } else if (value === RuleInheritance.NotInherited) { - return RuleInheritance.NotInherited; - } else if (value === RuleInheritance.Overridden) { - return RuleInheritance.Overridden; +function parseAsInheritance(value?: string): T.RuleInheritance | undefined { + if (value === 'INHERITED' || value === 'NONE' || value === 'OVERRIDES') { + return value; } else { return undefined; } } -function serializeInheritance(value: RuleInheritance | undefined): string | undefined { +function serializeInheritance(value: T.RuleInheritance | undefined): string | undefined { return value; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx index 3ecb85b9786..25348fb55db 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx @@ -50,37 +50,33 @@ import { translate } from '../../../helpers/l10n'; import { RawQuery } from '../../../helpers/query'; -import { - BranchLike, - ComponentMeasure, - CurrentUser, - MeasureEnhanced, - Metric, - Period -} from '../../../app/types'; import '../../../components/search-navigator.css'; import '../style.css'; interface Props { - branchLike?: BranchLike; - component: ComponentMeasure; - currentUser: CurrentUser; + branchLike?: T.BranchLike; + component: T.ComponentMeasure; + currentUser: T.CurrentUser; location: { pathname: string; query: RawQuery }; fetchMeasures: ( component: string, metricsKey: string[], - branchLike?: BranchLike - ) => Promise<{ component: ComponentMeasure; measures: MeasureEnhanced[]; leakPeriod?: Period }>; + branchLike?: T.BranchLike + ) => Promise<{ + component: T.ComponentMeasure; + measures: T.MeasureEnhanced[]; + leakPeriod?: T.Period; + }>; fetchMetrics: () => void; - metrics: { [metric: string]: Metric }; + metrics: { [metric: string]: T.Metric }; metricsKey: string[]; router: InjectedRouter; } interface State { loading: boolean; - measures: MeasureEnhanced[]; - leakPeriod?: Period; + measures: T.MeasureEnhanced[]; + leakPeriod?: T.Period; } export default class App extends React.PureComponent { @@ -162,7 +158,7 @@ export default class App extends React.PureComponent { ); }; - getHelmetTitle = (query: Query, displayOverview: boolean, metric?: Metric) => { + getHelmetTitle = (query: Query, displayOverview: boolean, metric?: T.Metric) => { if (displayOverview && query.metric) { return isProjectOverview(query.metric) ? translate('component_measures.overview.project_overview.facet') @@ -205,7 +201,7 @@ export default class App extends React.PureComponent { }); }; - renderContent = (displayOverview: boolean, query: Query, metric?: Metric) => { + renderContent = (displayOverview: boolean, query: Query, metric?: T.Metric) => { const { branchLike, component, fetchMeasures, metrics } = this.props; const { leakPeriod } = this.state; if (displayOverview) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/AppContainer.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/AppContainer.tsx index 5f332e09455..ae7a599a5aa 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/AppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/AppContainer.tsx @@ -28,19 +28,10 @@ import { getMeasuresAndMeta } from '../../../api/measures'; import { getLeakPeriod } from '../../../helpers/periods'; import { enhanceMeasure } from '../../../components/measure/utils'; import { getBranchLikeQuery } from '../../../helpers/branches'; -import { - BranchLike, - ComponentMeasure, - CurrentUser, - Measure, - MeasureEnhanced, - Metric, - Period -} from '../../../app/types'; interface StateToProps { - currentUser: CurrentUser; - metrics: { [metric: string]: Metric }; + currentUser: T.CurrentUser; + metrics: { [metric: string]: T.Metric }; metricsKey: string[]; } @@ -48,14 +39,18 @@ interface DispatchToProps { fetchMeasures: ( component: string, metricsKey: string[], - branchLike?: BranchLike - ) => Promise<{ component: ComponentMeasure; measures: MeasureEnhanced[]; leakPeriod?: Period }>; + branchLike?: T.BranchLike + ) => Promise<{ + component: T.ComponentMeasure; + measures: T.MeasureEnhanced[]; + leakPeriod?: T.Period; + }>; fetchMetrics: () => void; } interface OwnProps { - branchLike?: BranchLike; - component: ComponentMeasure; + branchLike?: T.BranchLike; + component: T.ComponentMeasure; } const mapStateToProps = (state: any): StateToProps => ({ @@ -64,7 +59,7 @@ const mapStateToProps = (state: any): StateToProps => ({ metricsKey: getMetricsKey(state) }); -function banQualityGate({ measures = [], qualifier }: ComponentMeasure): Measure[] { +function banQualityGate({ measures = [], qualifier }: T.ComponentMeasure): T.Measure[] { const bannedMetrics: string[] = []; if (!['VW', 'SVW'].includes(qualifier)) { bannedMetrics.push('alert_status'); @@ -75,7 +70,7 @@ function banQualityGate({ measures = [], qualifier }: ComponentMeasure): Measure return measures.filter(measure => !bannedMetrics.includes(measure.metric)); } -const fetchMeasures = (component: string, metricsKey: string[], branchLike?: BranchLike) => ( +const fetchMeasures = (component: string, metricsKey: string[], branchLike?: T.BranchLike) => ( _dispatch: Dispatch, getState: () => any ) => { @@ -92,7 +87,7 @@ const fetchMeasures = (component: string, metricsKey: string[], branchLike?: Bra ); const newBugs = measures.find(measure => measure.metric.key === 'new_bugs'); - const applicationPeriods = newBugs ? [{ index: 1 } as Period] : []; + const applicationPeriods = newBugs ? [{ index: 1 } as T.Period] : []; const leakPeriod = getLeakPeriod(component.qualifier === 'APP' ? applicationPeriods : periods); return { component, measures, leakPeriod }; }, throwGlobalError); diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumb.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumb.tsx index 326401a8377..17e53750aaa 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumb.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumb.tsx @@ -20,11 +20,10 @@ import * as React from 'react'; import Tooltip from '../../../components/controls/Tooltip'; import { collapsePath, limitComponentName } from '../../../helpers/path'; -import { ComponentMeasure } from '../../../app/types'; interface Props { canBrowse: boolean; - component: ComponentMeasure; + component: T.ComponentMeasure; isLast: boolean; handleSelect: (component: string) => void; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx index f90d46e7550..926f96c80b8 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/Breadcrumbs.tsx @@ -22,19 +22,18 @@ import * as key from 'keymaster'; import Breadcrumb from './Breadcrumb'; import { getBreadcrumbs } from '../../../api/components'; import { getBranchLikeQuery } from '../../../helpers/branches'; -import { BranchLike, ComponentMeasure } from '../../../app/types'; interface Props { backToFirst: boolean; - branchLike?: BranchLike; + branchLike?: T.BranchLike; className?: string; - component: ComponentMeasure; + component: T.ComponentMeasure; handleSelect: (component: string) => void; - rootComponent: ComponentMeasure; + rootComponent: T.ComponentMeasure; } interface State { - breadcrumbs: ComponentMeasure[]; + breadcrumbs: T.ComponentMeasure[]; } export default class Breadcrumbs extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.tsx index 57362e1933f..9f145e734af 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/LeakPeriodLegend.tsx @@ -27,12 +27,11 @@ import Tooltip from '../../../components/controls/Tooltip'; import { getPeriodLabel, getPeriodDate } from '../../../helpers/periods'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { differenceInDays } from '../../../helpers/dates'; -import { ComponentMeasure, Period, PeriodMode } from '../../../app/types'; interface Props { className?: string; - component: ComponentMeasure; - period: Period; + component: T.ComponentMeasure; + period: T.Period; } export default class LeakPeriodLegend extends React.PureComponent { @@ -62,7 +61,7 @@ export default class LeakPeriodLegend extends React.PureComponent { ); - if (period.mode === PeriodMode.Days) { + if (period.mode === 'days') { return label; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx index 7d795c8d1f8..c9ddae92ee3 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx @@ -36,33 +36,23 @@ import { getProjectUrl } from '../../../helpers/urls'; import { isDiffMetric } from '../../../helpers/measures'; import { isSameBranchLike, getBranchLikeQuery } from '../../../helpers/branches'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; -import { - BranchLike, - ComponentMeasure, - ComponentMeasureEnhanced, - CurrentUser, - Metric, - Paging, - MeasureEnhanced, - Period -} from '../../../app/types'; import { RequestData } from '../../../helpers/request'; import { isLoggedIn } from '../../../helpers/users'; interface Props { - branchLike?: BranchLike; + branchLike?: T.BranchLike; className?: string; - component: ComponentMeasure; - currentUser: CurrentUser; + component: T.ComponentMeasure; + currentUser: T.CurrentUser; loading: boolean; loadingMore: boolean; - leakPeriod?: Period; - measure?: MeasureEnhanced; - metric: Metric; - metrics: { [metric: string]: Metric }; - rootComponent: ComponentMeasure; + leakPeriod?: T.Period; + measure?: T.MeasureEnhanced; + metric: T.Metric; + metrics: { [metric: string]: T.Metric }; + rootComponent: T.ComponentMeasure; router: InjectedRouter; - secondaryMeasure?: MeasureEnhanced; + secondaryMeasure?: T.MeasureEnhanced; updateLoading: (param: { [key: string]: boolean }) => void; updateSelected: (component: string) => void; updateView: (view: string) => void; @@ -70,9 +60,9 @@ interface Props { } interface State { - components: ComponentMeasureEnhanced[]; - metric?: Metric; - paging?: Paging; + components: T.ComponentMeasureEnhanced[]; + metric?: T.Metric; + paging?: T.Paging; selected?: string; view?: string; } @@ -109,7 +99,7 @@ export default class MeasureContent extends React.PureComponent { return index !== -1 ? index : undefined; }; - getComponentRequestParams = (view: string, metric: Metric, options: Object = {}) => { + getComponentRequestParams = (view: string, metric: T.Metric, options: Object = {}) => { const strategy = view === 'list' ? 'leaves' : 'children'; const metricKeys = [metric.key]; const opts: RequestData = { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContentContainer.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContentContainer.tsx index c8a1301038d..0a756d3b8ad 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContentContainer.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContentContainer.tsx @@ -21,28 +21,20 @@ import * as React from 'react'; import { InjectedRouter } from 'react-router'; import MeasureContent from './MeasureContent'; import { Query } from '../utils'; -import { - ComponentMeasure, - Metric, - BranchLike, - CurrentUser, - MeasureEnhanced, - Period -} from '../../../app/types'; interface Props { - branchLike?: BranchLike; + branchLike?: T.BranchLike; className?: string; - currentUser: CurrentUser; - rootComponent: ComponentMeasure; + currentUser: T.CurrentUser; + rootComponent: T.ComponentMeasure; fetchMeasures: ( component: string, metricsKey: string[], - branchLike?: BranchLike - ) => Promise<{ component: ComponentMeasure; measures: MeasureEnhanced[] }>; - leakPeriod?: Period; - metric: Metric; - metrics: { [metric: string]: Metric }; + branchLike?: T.BranchLike + ) => Promise<{ component: T.ComponentMeasure; measures: T.MeasureEnhanced[] }>; + leakPeriod?: T.Period; + metric: T.Metric; + metrics: { [metric: string]: T.Metric }; router: InjectedRouter; selected?: string; updateQuery: (query: Partial) => void; @@ -56,10 +48,10 @@ interface LoadingState { } interface State { - component?: ComponentMeasure; + component?: T.ComponentMeasure; loading: LoadingState; - measure?: MeasureEnhanced; - secondaryMeasure?: MeasureEnhanced; + measure?: T.MeasureEnhanced; + secondaryMeasure?: T.MeasureEnhanced; } export default class MeasureContentContainer extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureFavoriteContainer.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureFavoriteContainer.tsx index d062ad6af50..43e4148b94d 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureFavoriteContainer.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureFavoriteContainer.tsx @@ -21,12 +21,11 @@ import * as React from 'react'; import Favorite from '../../../components/controls/Favorite'; import { getComponentForSourceViewer } from '../../../api/components'; import { isMainBranch } from '../../../helpers/branches'; -import { BranchLike, SourceViewerFile } from '../../../app/types'; -type FavComponent = Pick; +type FavComponent = Pick; interface Props { - branchLike?: BranchLike; + branchLike?: T.BranchLike; className?: string; component: string; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx index d85dcc4a067..59e894f6aae 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx @@ -28,16 +28,15 @@ import Tooltip from '../../../components/controls/Tooltip'; import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; import { getMeasureHistoryUrl } from '../../../helpers/urls'; import { isDiffMetric } from '../../../helpers/measures'; -import { BranchLike, ComponentMeasure, MeasureEnhanced, Metric, Period } from '../../../app/types'; import { hasFullMeasures } from '../utils'; interface Props { - branchLike?: BranchLike; - component: ComponentMeasure; - leakPeriod?: Period; - measure?: MeasureEnhanced; - metric: Metric; - secondaryMeasure?: MeasureEnhanced; + branchLike?: T.BranchLike; + component: T.ComponentMeasure; + leakPeriod?: T.Period; + measure?: T.MeasureEnhanced; + metric: T.Metric; + secondaryMeasure?: T.MeasureEnhanced; } export default function MeasureHeader(props: Props) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx index 18c34ea5d4a..7c049607c45 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverview.tsx @@ -28,33 +28,24 @@ import { getComponentLeaves } from '../../../api/components'; import { enhanceComponent, getBubbleMetrics, isFileType } from '../utils'; import { getBranchLikeQuery } from '../../../helpers/branches'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; -import { - BranchLike, - ComponentMeasure, - ComponentMeasureEnhanced, - CurrentUser, - Metric, - Paging, - Period -} from '../../../app/types'; interface Props { - branchLike?: BranchLike; + branchLike?: T.BranchLike; className?: string; - component: ComponentMeasure; - currentUser: CurrentUser; + component: T.ComponentMeasure; + currentUser: T.CurrentUser; domain: string; - leakPeriod?: Period; + leakPeriod?: T.Period; loading: boolean; - metrics: { [metric: string]: Metric }; - rootComponent: ComponentMeasure; + metrics: { [metric: string]: T.Metric }; + rootComponent: T.ComponentMeasure; updateLoading: (param: { [key: string]: boolean }) => void; updateSelected: (component: string) => void; } interface State { - components: ComponentMeasureEnhanced[]; - paging?: Paging; + components: T.ComponentMeasureEnhanced[]; + paging?: T.Paging; } const BUBBLES_LIMIT = 500; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx index 642cde71e20..db3a5229e37 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureOverviewContainer.tsx @@ -24,16 +24,15 @@ import { getComponentShow } from '../../../api/components'; import { getProjectUrl } from '../../../helpers/urls'; import { isViewType, Query } from '../utils'; import { getBranchLikeQuery } from '../../../helpers/branches'; -import { BranchLike, ComponentMeasure, CurrentUser, Metric, Period } from '../../../app/types'; interface Props { - branchLike?: BranchLike; + branchLike?: T.BranchLike; className?: string; - currentUser: CurrentUser; + currentUser: T.CurrentUser; domain: string; - leakPeriod?: Period; - metrics: { [metric: string]: Metric }; - rootComponent: ComponentMeasure; + leakPeriod?: T.Period; + metrics: { [metric: string]: T.Metric }; + rootComponent: T.ComponentMeasure; router: InjectedRouter; selected?: string; updateQuery: (query: Partial) => void; @@ -45,7 +44,7 @@ interface LoadingState { } interface State { - component?: ComponentMeasure; + component?: T.ComponentMeasure; loading: LoadingState; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.tsx index 69347353959..cd84ac1c88d 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureViewSelect.tsx @@ -24,11 +24,10 @@ import TreemapIcon from '../../../components/icons-components/TreemapIcon'; import Select from '../../../components/controls/Select'; import { hasList, hasTree, hasTreemap } from '../utils'; import { translate } from '../../../helpers/l10n'; -import { Metric } from '../../../app/types'; interface Props { className?: string; - metric: Metric; + metric: T.Metric; handleViewChange: (view: string) => void; view: string; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/PageActions.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/PageActions.tsx index 75078edb21a..8417f05b294 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/PageActions.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/PageActions.tsx @@ -20,12 +20,11 @@ import * as React from 'react'; import FilesCounter from './FilesCounter'; import { translate } from '../../../helpers/l10n'; -import { Paging } from '../../../app/types'; interface Props { current?: number; isFile?: boolean; - paging?: Paging; + paging?: T.Paging; totalLoadedComponents?: number; view?: string; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/LeakPeriodLegend-test.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/LeakPeriodLegend-test.tsx index be616b62017..3aa1046f6dc 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/LeakPeriodLegend-test.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/LeakPeriodLegend-test.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import LeakPeriodLegend from '../LeakPeriodLegend'; import { differenceInDays } from '../../../../helpers/dates'; -import { ComponentMeasure, Period, PeriodMode } from '../../../../app/types'; jest.mock('../../../../helpers/dates', () => { const dates = require.requireActual('../../../../helpers/dates'); @@ -41,17 +40,17 @@ const APP = { qualifier: 'APP' }; -const PERIOD = { +const PERIOD: T.Period = { date: '2017-05-16T13:50:02+0200', index: 1, - mode: PeriodMode.PreviousVersion, + mode: 'previous_version', parameter: '6,4' }; -const PERIOD_DAYS = { +const PERIOD_DAYS: T.Period = { date: '2017-05-16T13:50:02+0200', index: 1, - mode: PeriodMode.Days, + mode: 'days', parameter: '18' }; @@ -69,7 +68,7 @@ it('should render a more precise date', () => { expect(getWrapper(PROJECT, PERIOD)).toMatchSnapshot(); }); -function getWrapper(component: ComponentMeasure, period: Period) { +function getWrapper(component: T.ComponentMeasure, period: T.Period) { return shallow(, { context: { intl: { formatDate: (date: string) => 'formatted.' + date } diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx index 2df222654bd..9b43b1ce72b 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureHeader-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import MeasureHeader from '../MeasureHeader'; -import { PeriodMode } from '../../../../app/types'; const METRIC = { id: '1', @@ -64,9 +63,9 @@ const PROPS = { leakPeriod: { date: '2017-05-16T13:50:02+0200', index: 1, - mode: PeriodMode.PreviousVersion, + mode: 'previous_version', parameter: '6,4' - }, + } as T.Period, measure: MEASURE, metric: METRIC }; diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureViewSelect-test.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureViewSelect-test.tsx index a54ea14a3a1..c1d6e7cfda8 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureViewSelect-test.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/MeasureViewSelect-test.tsx @@ -20,14 +20,13 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import MeasureViewSelect from '../MeasureViewSelect'; -import { Metric } from '../../../../app/types'; it('should display correctly with treemap option', () => { expect( shallow( {}} - metric={{ type: 'PERCENT' } as Metric} + metric={{ type: 'PERCENT' } as T.Metric} view="tree" /> ) diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChart.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChart.tsx index 0c07b5a249f..c52981c4872 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChart.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChart.tsx @@ -31,20 +31,19 @@ import { } from '../../../helpers/l10n'; import { getBubbleMetrics, getBubbleYDomain, isProjectOverview } from '../utils'; import { RATING_COLORS } from '../../../helpers/constants'; -import { ComponentMeasure, ComponentMeasureEnhanced, Metric } from '../../../app/types'; const HEIGHT = 500; interface Props { - component: ComponentMeasure; - components: ComponentMeasureEnhanced[]; + component: T.ComponentMeasure; + components: T.ComponentMeasureEnhanced[]; domain: string; - metrics: { [metric: string]: Metric }; + metrics: { [metric: string]: T.Metric }; updateSelected: (component: string) => void; } export default class BubbleChart extends React.PureComponent { - getMeasureVal = (component: ComponentMeasureEnhanced, metric: Metric) => { + getMeasureVal = (component: T.ComponentMeasureEnhanced, metric: T.Metric) => { const measure = component.measures.find(measure => measure.metric.key === metric.key); if (!measure) { return undefined; @@ -55,7 +54,7 @@ export default class BubbleChart extends React.PureComponent { getTooltip( componentName: string, values: { x: number; y: number; size: number; colors?: Array }, - metrics: { x: Metric; y: Metric; size: Metric; colors?: Array } + metrics: { x: T.Metric; y: T.Metric; size: T.Metric; colors?: T.Metric[] } ) { const inner = [ componentName, @@ -85,7 +84,7 @@ export default class BubbleChart extends React.PureComponent { ); } - handleBubbleClick = (component: ComponentMeasureEnhanced) => + handleBubbleClick = (component: T.ComponentMeasureEnhanced) => this.props.updateSelected(component.refKey || component.key); getDescription(domain: string) { @@ -97,7 +96,7 @@ export default class BubbleChart extends React.PureComponent { return translatedDescription; } - renderBubbleChart(metrics: { x: Metric; y: Metric; size: Metric; colors?: Metric[] }) { + renderBubbleChart(metrics: { x: T.Metric; y: T.Metric; size: T.Metric; colors?: T.Metric[] }) { const items = this.props.components .map(component => { const x = this.getMeasureVal(component, metrics.x); @@ -120,13 +119,13 @@ export default class BubbleChart extends React.PureComponent { tooltip: this.getTooltip(component.name, { x, y, size, colors }, metrics) }; }) - .filter(Boolean) as BubbleItem[]; + .filter(Boolean) as BubbleItem[]; const formatXTick = (tick: string | number | undefined) => formatMeasure(tick, metrics.x.type); const formatYTick = (tick: string | number | undefined) => formatMeasure(tick, metrics.y.type); return ( - + formatXTick={formatXTick} formatYTick={formatYTick} height={HEIGHT} @@ -138,7 +137,7 @@ export default class BubbleChart extends React.PureComponent { ); } - renderChartHeader(domain: string, sizeMetric: Metric, colorsMetric?: Metric[]) { + renderChartHeader(domain: string, sizeMetric: T.Metric, colorsMetric?: T.Metric[]) { const title = isProjectOverview(domain) ? translate('component_measures.overview', domain, 'title') : translateWithParameters( diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/CodeView.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/CodeView.tsx index a07eb4710c2..9dd42f1299f 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/CodeView.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/CodeView.tsx @@ -20,20 +20,13 @@ import * as React from 'react'; import * as key from 'keymaster'; import SourceViewer from '../../../components/SourceViewer/SourceViewer'; -import { - BranchLike, - ComponentMeasure, - ComponentMeasureEnhanced, - Metric, - Period -} from '../../../app/types'; interface Props { - branchLike?: BranchLike; - component: ComponentMeasure; - components: Array; - leakPeriod?: Period; - metric: Metric; + branchLike?: T.BranchLike; + component: T.ComponentMeasure; + components: T.ComponentMeasureEnhanced[]; + leakPeriod?: T.Period; + metric: T.Metric; selectedIdx?: number; updateSelected: (component: string) => void; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx index 4ddcd665e7b..071f6f2c7b6 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentCell.tsx @@ -30,14 +30,13 @@ import { getProjectUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; -import { BranchLike, ComponentMeasure, ComponentMeasureEnhanced, Metric } from '../../../app/types'; interface Props { - branchLike?: BranchLike; - component: ComponentMeasureEnhanced; + branchLike?: T.BranchLike; + component: T.ComponentMeasureEnhanced; onClick: (component: string) => void; - metric: Metric; - rootComponent: ComponentMeasure; + metric: T.Metric; + rootComponent: T.ComponentMeasure; } export default class ComponentCell extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx index 957fdc7b3e5..01cf98e452d 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsList.tsx @@ -22,15 +22,14 @@ import ComponentsListRow from './ComponentsListRow'; import EmptyResult from './EmptyResult'; import { complementary } from '../config/complementary'; import { getLocalizedMetricName } from '../../../helpers/l10n'; -import { ComponentMeasure, ComponentMeasureEnhanced, Metric, BranchLike } from '../../../app/types'; interface Props { - branchLike?: BranchLike; - components: ComponentMeasureEnhanced[]; + branchLike?: T.BranchLike; + components: T.ComponentMeasureEnhanced[]; onClick: (component: string) => void; - metric: Metric; - metrics: { [metric: string]: Metric }; - rootComponent: ComponentMeasure; + metric: T.Metric; + metrics: { [metric: string]: T.Metric }; + rootComponent: T.ComponentMeasure; selectedComponent?: string; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx index 6ae4c80b619..e19138b2bdf 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/ComponentsListRow.tsx @@ -21,16 +21,15 @@ import * as React from 'react'; import * as classNames from 'classnames'; import ComponentCell from './ComponentCell'; import MeasureCell from './MeasureCell'; -import { ComponentMeasure, Metric, ComponentMeasureEnhanced, BranchLike } from '../../../app/types'; interface Props { - branchLike?: BranchLike; - component: ComponentMeasureEnhanced; + branchLike?: T.BranchLike; + component: T.ComponentMeasureEnhanced; isSelected: boolean; onClick: (component: string) => void; - otherMetrics: Metric[]; - metric: Metric; - rootComponent: ComponentMeasure; + otherMetrics: T.Metric[]; + metric: T.Metric; + rootComponent: T.ComponentMeasure; } export default function ComponentsListRow(props: Props) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx index 0413514857e..8d106bc29fd 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx @@ -23,29 +23,22 @@ import { throttle } from 'lodash'; import ComponentsList from './ComponentsList'; import ListFooter from '../../../components/controls/ListFooter'; import { Button } from '../../../components/ui/buttons'; -import { - ComponentMeasure, - ComponentMeasureEnhanced, - Metric, - Paging, - BranchLike -} from '../../../app/types'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { isPeriodBestValue, isDiffMetric, formatMeasure } from '../../../helpers/measures'; import { scrollToElement } from '../../../helpers/scrolling'; import { Alert } from '../../../components/ui/Alert'; interface Props { - branchLike?: BranchLike; - components: ComponentMeasureEnhanced[]; + branchLike?: T.BranchLike; + components: T.ComponentMeasureEnhanced[]; fetchMore: () => void; handleSelect: (component: string) => void; handleOpen: (component: string) => void; loadingMore: boolean; - metric: Metric; - metrics: { [metric: string]: Metric }; - paging?: Paging; - rootComponent: ComponentMeasure; + metric: T.Metric; + metrics: { [metric: string]: T.Metric }; + paging?: T.Paging; + rootComponent: T.ComponentMeasure; selectedKey?: string; selectedIdx?: number; } @@ -103,7 +96,7 @@ export default class ListView extends React.PureComponent { ['up', 'down', 'right'].forEach(action => key.unbind(action, 'measures-files')); } - getVisibleComponents = (components: ComponentMeasureEnhanced[], showBestMeasures: boolean) => { + getVisibleComponents = (components: T.ComponentMeasureEnhanced[], showBestMeasures: boolean) => { if (showBestMeasures) { return components; } @@ -118,7 +111,7 @@ export default class ListView extends React.PureComponent { this.setState({ showBestMeasures: true }); }; - hasBestValue = (component: ComponentMeasureEnhanced) => { + hasBestValue = (component: T.ComponentMeasureEnhanced) => { const { metric } = this.props; const focusedMeasure = component.measures.find(measure => measure.metric.key === metric.key); if (focusedMeasure && isDiffMetric(metric.key)) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/MeasureCell.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/MeasureCell.tsx index 951bb590f62..fb1f210e2b2 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/MeasureCell.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/MeasureCell.tsx @@ -20,12 +20,11 @@ import * as React from 'react'; import Measure from '../../../components/measure/Measure'; import { isDiffMetric } from '../../../helpers/measures'; -import { Metric, MeasureEnhanced, ComponentMeasureEnhanced } from '../../../app/types'; interface Props { - component: ComponentMeasureEnhanced; - measure?: MeasureEnhanced; - metric: Metric; + component: T.ComponentMeasureEnhanced; + measure?: T.MeasureEnhanced; + metric: T.Metric; } export default function MeasureCell({ component, measure, metric }: Props) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx index 61a35f44ace..2f07bb3545a 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx @@ -30,13 +30,12 @@ import TreeMap, { TreeMapItem } from '../../../components/charts/TreeMap'; import { translate, translateWithParameters, getLocalizedMetricName } from '../../../helpers/l10n'; import { formatMeasure, isDiffMetric } from '../../../helpers/measures'; import { getBranchLikeUrl } from '../../../helpers/urls'; -import { BranchLike, ComponentMeasureEnhanced, Metric } from '../../../app/types'; interface Props { - branchLike?: BranchLike; - components: ComponentMeasureEnhanced[]; + branchLike?: T.BranchLike; + components: T.ComponentMeasureEnhanced[]; handleSelect: (component: string) => void; - metric: Metric; + metric: T.Metric; } interface State { @@ -105,7 +104,7 @@ export default class TreeMapView extends React.PureComponent { .domain(['ERROR', 'WARN', 'OK', 'NONE']) .range(LEVEL_COLORS); - getPercentColorScale = (metric: Metric) => { + getPercentColorScale = (metric: T.Metric) => { const color = scaleLinear().domain([0, 25, 50, 75, 100]); color.range(metric.direction === 1 ? [...COLORS].reverse() : COLORS); return color; @@ -116,7 +115,7 @@ export default class TreeMapView extends React.PureComponent { .domain([1, 2, 3, 4, 5]) .range(COLORS); - getColorScale = (metric: Metric) => { + getColorScale = (metric: T.Metric) => { if (metric.type === 'LEVEL') { return this.getLevelColorScale(); } @@ -133,10 +132,10 @@ export default class TreeMapView extends React.PureComponent { sizeMetric, sizeValue }: { - colorMetric: Metric; + colorMetric: T.Metric; colorValue?: string; componentName: string; - sizeMetric: Metric; + sizeMetric: T.Metric; sizeValue: number; }) => { const formatted = diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.tsx b/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.tsx index 1a52f8c80c5..675e94cfaf5 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainFacet.tsx @@ -37,10 +37,9 @@ import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; -import { MeasureEnhanced } from '../../../app/types'; interface Props { - domain: { name: string; measures: MeasureEnhanced[] }; + domain: { name: string; measures: T.MeasureEnhanced[] }; hasOverview: boolean; onChange: (metric: string) => void; onToggle: (property: string) => void; @@ -63,7 +62,11 @@ export default class DomainFacet extends React.PureComponent { this.props.onToggle(this.props.domain.name); }; - hasFacetSelected = (domain: { name: string }, measures: MeasureEnhanced[], selected: string) => { + hasFacetSelected = ( + domain: { name: string }, + measures: T.MeasureEnhanced[], + selected: string + ) => { const measureSelected = measures.find(measure => measure.metric.key === selected); const overviewSelected = domain.name === selected && this.hasOverview(domain.name); return measureSelected || overviewSelected; @@ -73,7 +76,7 @@ export default class DomainFacet extends React.PureComponent { return this.props.hasOverview && hasBubbleChart(domain); }; - renderItemFacetStat = (item: MeasureEnhanced) => { + renderItemFacetStat = (item: T.MeasureEnhanced) => { return hasFacetStat(item.metric.key) ? : null; }; diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.tsx b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.tsx index 473b287cbd7..a9ac8816935 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/FacetMeasureValue.tsx @@ -20,10 +20,9 @@ import * as React from 'react'; import Measure from '../../../components/measure/Measure'; import { isDiffMetric } from '../../../helpers/measures'; -import { MeasureEnhanced } from '../../../app/types'; interface Props { - measure: MeasureEnhanced; + measure: T.MeasureEnhanced; } export default function FacetMeasureValue({ measure }: Props) { diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx index 09683497982..6aed80029c9 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx @@ -21,11 +21,10 @@ import * as React from 'react'; import ProjectOverviewFacet from './ProjectOverviewFacet'; import DomainFacet from './DomainFacet'; import { getDefaultView, groupByDomains, KNOWN_DOMAINS, PROJECT_OVERVEW, Query } from '../utils'; -import { MeasureEnhanced } from '../../../app/types'; interface Props { hasOverview: boolean; - measures: MeasureEnhanced[]; + measures: T.MeasureEnhanced[]; selectedMetric: string; updateQuery: (query: Partial) => void; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/utils.ts b/server/sonar-web/src/main/js/apps/component-measures/utils.ts index 05f0713f257..9ea4c49bc28 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/utils.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/utils.ts @@ -21,13 +21,6 @@ import { groupBy, memoize, sortBy, toPairs } from 'lodash'; import { domains } from './config/domains'; import { bubbles } from './config/bubbles'; import { getLocalizedMetricName } from '../../helpers/l10n'; -import { - ComponentMeasure, - ComponentMeasureEnhanced, - Metric, - MeasureEnhanced, - BranchLike -} from '../../app/types'; import { enhanceMeasure } from '../../components/measure/utils'; import { cleanQuery, parseAsString, RawQuery, serializeString } from '../../helpers/query'; import { isLongLivingBranch, isMainBranch } from '../../helpers/branches'; @@ -59,30 +52,30 @@ const BANNED_MEASURES = [ 'new_info_violations' ]; -export function filterMeasures(measures: MeasureEnhanced[]): MeasureEnhanced[] { +export function filterMeasures(measures: T.MeasureEnhanced[]): T.MeasureEnhanced[] { return measures.filter(measure => !BANNED_MEASURES.includes(measure.metric.key)); } export function sortMeasures( domainName: string, - measures: Array -): Array { + measures: Array +): Array { const config = domains[domainName] || {}; const configOrder = config.order || []; return sortBy(measures, [ - (item: MeasureEnhanced | string) => { + (item: T.MeasureEnhanced | string) => { if (typeof item === 'string') { return configOrder.indexOf(item); } const idx = configOrder.indexOf(item.metric.key); return idx >= 0 ? idx : configOrder.length; }, - (item: MeasureEnhanced | string) => + (item: T.MeasureEnhanced | string) => typeof item === 'string' ? item : getLocalizedMetricName(item.metric) ]); } -export function addMeasureCategories(domainName: string, measures: MeasureEnhanced[]) { +export function addMeasureCategories(domainName: string, measures: T.MeasureEnhanced[]) { const categories = domains[domainName] && domains[domainName].categories; if (categories && categories.length > 0) { return [...categories, ...measures]; @@ -91,10 +84,10 @@ export function addMeasureCategories(domainName: string, measures: MeasureEnhanc } export function enhanceComponent( - component: ComponentMeasure, - metric: Metric | undefined, - metrics: { [key: string]: Metric } -): ComponentMeasureEnhanced { + component: T.ComponentMeasure, + metric: T.Metric | undefined, + metrics: { [key: string]: T.Metric } +): T.ComponentMeasureEnhanced { if (!component.measures) { return { ...component, measures: [] }; } @@ -106,22 +99,22 @@ export function enhanceComponent( return { ...component, value, leak, measures: enhancedMeasures }; } -export function isFileType(component: ComponentMeasure): boolean { +export function isFileType(component: T.ComponentMeasure): boolean { return ['FIL', 'UTS'].includes(component.qualifier); } -export function isViewType(component: ComponentMeasure): boolean { +export function isViewType(component: T.ComponentMeasure): boolean { return ['VW', 'SVW', 'APP'].includes(component.qualifier); } -export const groupByDomains = memoize((measures: MeasureEnhanced[]) => { +export const groupByDomains = memoize((measures: T.MeasureEnhanced[]) => { const domains = toPairs(groupBy(measures, measure => measure.metric.domain)).map(r => ({ name: r[0], measures: r[1] })); return sortBy(domains, [ - (domain: { name: string; measures: MeasureEnhanced[] }) => { + (domain: { name: string; measures: T.MeasureEnhanced[] }) => { const idx = KNOWN_DOMAINS.indexOf(domain.name); return idx >= 0 ? idx : KNOWN_DOMAINS.length; }, @@ -156,11 +149,14 @@ export function hasFacetStat(metric: string): boolean { return metric !== 'alert_status'; } -export function hasFullMeasures(branch?: BranchLike) { +export function hasFullMeasures(branch?: T.BranchLike) { return !branch || isLongLivingBranch(branch) || isMainBranch(branch); } -export function getMeasuresPageMetricKeys(metrics: { [key: string]: Metric }, branch?: BranchLike) { +export function getMeasuresPageMetricKeys( + metrics: { [key: string]: T.Metric }, + branch?: T.BranchLike +) { if (!hasFullMeasures(branch)) { return [ 'coverage', @@ -182,7 +178,7 @@ export function getMeasuresPageMetricKeys(metrics: { [key: string]: Metric }, br return getDisplayMetrics(Object.values(metrics)).map(metric => metric.key); } -export function getBubbleMetrics(domain: string, metrics: { [key: string]: Metric }) { +export function getBubbleMetrics(domain: string, metrics: { [key: string]: T.Metric }) { const conf = bubbles[domain]; return { x: metrics[conf.x], diff --git a/server/sonar-web/src/main/js/apps/create/components/OrganizationSelect.tsx b/server/sonar-web/src/main/js/apps/create/components/OrganizationSelect.tsx index 321548ec75d..84751b58556 100644 --- a/server/sonar-web/src/main/js/apps/create/components/OrganizationSelect.tsx +++ b/server/sonar-web/src/main/js/apps/create/components/OrganizationSelect.tsx @@ -20,16 +20,15 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import Select from '../../../components/controls/Select'; -import { Organization } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; import { sanitizeAlmId } from '../../../helpers/almIntegrations'; import { getBaseUrl } from '../../../helpers/urls'; interface Props { hideIcons?: boolean; - onChange: (organization: Organization) => void; + onChange: (organization: T.Organization) => void; organization: string; - organizations: Organization[]; + organizations: T.Organization[]; } export default function OrganizationSelect({ @@ -59,7 +58,7 @@ export default function OrganizationSelect({ } export function getOptionRenderer(hideIcons?: boolean) { - return function optionRenderer(organization: Organization) { + return function optionRenderer(organization: T.Organization) { const icon = organization.alm ? `sonarcloud/${sanitizeAlmId(organization.alm.key)}` : 'sonarcloud-square-logo'; diff --git a/server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationBind.tsx b/server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationBind.tsx index f8275990c8d..0436f276ce7 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationBind.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationBind.tsx @@ -20,13 +20,12 @@ import * as React from 'react'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import OrganizationSelect from '../components/OrganizationSelect'; -import { Organization } from '../../../app/types'; import { SubmitButton } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; interface Props { onBindOrganization: (organization: string) => Promise; - unboundOrganizations: Organization[]; + unboundOrganizations: T.Organization[]; } interface State { @@ -57,7 +56,7 @@ export default class AutoOrganizationBind extends React.PureComponent { + handleChange = ({ key }: T.Organization) => { this.setState({ organization: key }); }; diff --git a/server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationCreate.tsx b/server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationCreate.tsx index 178e1e12d41..06fa37b4e9d 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationCreate.tsx @@ -26,13 +26,6 @@ import OrganizationDetailsForm from './OrganizationDetailsForm'; import { Query } from './utils'; import RadioToggle from '../../../components/controls/RadioToggle'; import { DeleteButton } from '../../../components/ui/buttons'; -import { - AlmApplication, - AlmOrganization, - AlmUnboundApplication, - Organization, - OrganizationBase -} from '../../../app/types'; import { bindAlmOrganization } from '../../../api/alm-integration'; import { sanitizeAlmId } from '../../../helpers/almIntegrations'; import { translate } from '../../../helpers/l10n'; @@ -44,17 +37,17 @@ export enum Filters { } interface Props { - almApplication: AlmApplication; + almApplication: T.AlmApplication; almInstallId?: string; - almOrganization?: AlmOrganization; - almUnboundApplications: AlmUnboundApplication[]; - boundOrganization?: OrganizationBase; + almOrganization?: T.AlmOrganization; + almUnboundApplications: T.AlmUnboundApplication[]; + boundOrganization?: T.OrganizationBase; className?: string; createOrganization: ( - organization: OrganizationBase & { installationId?: string } - ) => Promise; + organization: T.OrganizationBase & { installationId?: string } + ) => Promise; onOrgCreated: (organization: string, justCreated?: boolean) => void; - unboundOrganizations: Organization[]; + unboundOrganizations: T.Organization[]; updateUrlQuery: (query: Partial) => void; } @@ -84,7 +77,7 @@ export default class AutoOrganizationCreate extends React.PureComponent) => { + handleCreateOrganization = (organization: Required) => { return this.props .createOrganization({ avatar: organization.avatar, @@ -101,7 +94,7 @@ export default class AutoOrganizationCreate extends React.PureComponent { + renderContent = (almOrganization: T.AlmOrganization) => { const { almApplication, unboundOrganizations } = this.props; const { filter } = this.state; diff --git a/server/sonar-web/src/main/js/apps/create/organization/AutoPersonalOrganizationBind.tsx b/server/sonar-web/src/main/js/apps/create/organization/AutoPersonalOrganizationBind.tsx index 5191bbee8be..875e0b8555b 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/AutoPersonalOrganizationBind.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/AutoPersonalOrganizationBind.tsx @@ -22,26 +22,20 @@ import { FormattedMessage } from 'react-intl'; import OrganizationDetailsForm from './OrganizationDetailsForm'; import { Query } from './utils'; import { DeleteButton } from '../../../components/ui/buttons'; -import { - AlmApplication, - AlmOrganization, - OrganizationBase, - Organization -} from '../../../app/types'; import { getBaseUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; import { sanitizeAlmId } from '../../../helpers/almIntegrations'; import OrganizationAvatar from '../../../components/common/OrganizationAvatar'; interface Props { - almApplication: AlmApplication; + almApplication: T.AlmApplication; almInstallId?: string; - almOrganization: AlmOrganization; - importPersonalOrg: Organization; + almOrganization: T.AlmOrganization; + importPersonalOrg: T.Organization; onOrgCreated: (organization: string) => void; updateOrganization: ( - organization: OrganizationBase & { installationId?: string } - ) => Promise; + organization: T.OrganizationBase & { installationId?: string } + ) => Promise; updateUrlQuery: (query: Partial) => void; } @@ -50,7 +44,7 @@ export default class AutoPersonalOrganizationBind extends React.PureComponent) => { + handleCreateOrganization = (organization: Required) => { return this.props .updateOrganization({ avatar: organization.avatar, diff --git a/server/sonar-web/src/main/js/apps/create/organization/BillingFormShim.tsx b/server/sonar-web/src/main/js/apps/create/organization/BillingFormShim.tsx index df4a59ebce6..ce44586f84a 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/BillingFormShim.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/BillingFormShim.tsx @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { CurrentUser, SubscriptionPlan } from '../../../app/types'; interface ChildrenProps { onSubmit: React.FormEventHandler; @@ -29,11 +28,11 @@ interface ChildrenProps { interface Props { children: (props: ChildrenProps) => React.ReactElement; initialCountry?: string; - currentUser: CurrentUser; + currentUser: T.CurrentUser; onCommit: () => void; onFailToUpgrade?: () => void; organizationKey: string | (() => Promise); - subscriptionPlans: SubscriptionPlan[]; + subscriptionPlans: T.SubscriptionPlan[]; } export default class BillingFormShim extends React.Component { diff --git a/server/sonar-web/src/main/js/apps/create/organization/CreateOrganization.tsx b/server/sonar-web/src/main/js/apps/create/organization/CreateOrganization.tsx index 8c4b57192ea..1de0e054c9b 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/CreateOrganization.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/CreateOrganization.tsx @@ -50,15 +50,6 @@ import { listUnboundApplications } from '../../../api/alm-integration'; import { getSubscriptionPlans } from '../../../api/billing'; -import { - AlmApplication, - AlmOrganization, - AlmUnboundApplication, - LoggedInUser, - Organization, - OrganizationBase, - SubscriptionPlan -} from '../../../app/types'; import { hasAdvancedALMIntegration, isPersonal } from '../../../helpers/almIntegrations'; import { translate } from '../../../helpers/l10n'; import { get, remove } from '../../../helpers/storage'; @@ -72,26 +63,26 @@ import '../../tutorials/styles.css'; // TODO remove me interface Props { createOrganization: ( - organization: OrganizationBase & { installationId?: string } - ) => Promise; - currentUser: LoggedInUser; + organization: T.OrganizationBase & { installationId?: string } + ) => Promise; + currentUser: T.LoggedInUser; deleteOrganization: (key: string) => Promise; updateOrganization: ( - organization: OrganizationBase & { installationId?: string } - ) => Promise; - userOrganizations: Organization[]; + organization: T.OrganizationBase & { installationId?: string } + ) => Promise; + userOrganizations: T.Organization[]; skipOnboarding: () => void; } interface State { - almApplication?: AlmApplication; - almOrganization?: AlmOrganization; + almApplication?: T.AlmApplication; + almOrganization?: T.AlmOrganization; almOrgLoading: boolean; - almUnboundApplications: AlmUnboundApplication[]; - boundOrganization?: OrganizationBase; + almUnboundApplications: T.AlmUnboundApplication[]; + boundOrganization?: T.OrganizationBase; loading: boolean; - organization?: Organization; - subscriptionPlans?: SubscriptionPlan[]; + organization?: T.Organization; + subscriptionPlans?: T.SubscriptionPlan[]; } type StateWithAutoImport = State & Required>; @@ -168,7 +159,7 @@ export class CreateOrganization extends React.PureComponent { + setValidOrgKey = (almOrganization: T.AlmOrganization) => { const key = slugify(almOrganization.key); const keys = [key, ...times(9, i => `${key}-${i + 1}`)]; return api @@ -273,7 +264,7 @@ export class CreateOrganization extends React.PureComponent { + renderContent = (almInstallId?: string, importPersonalOrg?: T.Organization) => { const { currentUser, location } = this.props; const { state } = this; const { almOrganization } = state; @@ -396,9 +387,9 @@ export class CreateOrganization extends React.PureComponent { - return api.createOrganization(organization).then((organization: Organization) => { + return api.createOrganization(organization).then((organization: T.Organization) => { dispatch(actions.createOrganization(organization)); return organization; }); @@ -406,7 +397,7 @@ function createOrganization(organization: OrganizationBase & { installationId?: } function updateOrganization( - organization: OrganizationBase & { key: string; installationId?: string } + organization: T.OrganizationBase & { key: string; installationId?: string } ) { return (dispatch: Dispatch) => { const { key, installationId, ...changes } = organization; diff --git a/server/sonar-web/src/main/js/apps/create/organization/ManualOrganizationCreate.tsx b/server/sonar-web/src/main/js/apps/create/organization/ManualOrganizationCreate.tsx index 4f67564ddbf..ea69f4ad3a5 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/ManualOrganizationCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/ManualOrganizationCreate.tsx @@ -22,16 +22,15 @@ import OrganizationDetailsForm from './OrganizationDetailsForm'; import OrganizationDetailsStep from './OrganizationDetailsStep'; import PlanStep from './PlanStep'; import { formatPrice } from './utils'; -import { OrganizationBase, Organization, SubscriptionPlan } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - createOrganization: (organization: OrganizationBase) => Promise; + createOrganization: (organization: T.OrganizationBase) => Promise; className?: string; deleteOrganization: (key: string) => Promise; onOrgCreated: (organization: string) => void; onlyPaid?: boolean; - subscriptionPlans?: SubscriptionPlan[]; + subscriptionPlans?: T.SubscriptionPlan[]; } enum Step { @@ -40,7 +39,7 @@ enum Step { } interface State { - organization?: Organization; + organization?: T.Organization; step: Step; } @@ -60,7 +59,7 @@ export default class ManualOrganizationCreate extends React.PureComponent) => { + handleOrganizationDetailsFinish = (organization: Required) => { this.setState({ organization, step: Step.Plan }); return Promise.resolve(); }; diff --git a/server/sonar-web/src/main/js/apps/create/organization/OrganizationDetailsForm.tsx b/server/sonar-web/src/main/js/apps/create/organization/OrganizationDetailsForm.tsx index de7330f912f..a3dbc4e49a9 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/OrganizationDetailsForm.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/OrganizationDetailsForm.tsx @@ -25,16 +25,15 @@ import OrganizationDescriptionInput from '../components/OrganizationDescriptionI import OrganizationKeyInput from '../components/OrganizationKeyInput'; import OrganizationNameInput from '../components/OrganizationNameInput'; import OrganizationUrlInput from '../components/OrganizationUrlInput'; -import { OrganizationBase } from '../../../app/types'; import { ResetButtonLink, SubmitButton } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; -type RequiredOrganization = Required; +type RequiredOrganization = Required; interface Props { keyReadOnly?: boolean; onContinue: (organization: RequiredOrganization) => Promise; - organization?: OrganizationBase & { key: string }; + organization?: T.OrganizationBase & { key: string }; submitText: string; } diff --git a/server/sonar-web/src/main/js/apps/create/organization/OrganizationDetailsStep.tsx b/server/sonar-web/src/main/js/apps/create/organization/OrganizationDetailsStep.tsx index b10abe71323..978b7faa200 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/OrganizationDetailsStep.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/OrganizationDetailsStep.tsx @@ -21,14 +21,13 @@ import * as React from 'react'; import Step from '../../tutorials/components/Step'; import { translate } from '../../../helpers/l10n'; import AlertSuccessIcon from '../../../components/icons-components/AlertSuccessIcon'; -import { OrganizationBase } from '../../../app/types'; interface Props { children: React.ReactNode; finished: boolean; onOpen: () => void; open: boolean; - organization?: OrganizationBase & { key: string }; + organization?: T.OrganizationBase & { key: string }; } export default class OrganizationDetailsStep extends React.PureComponent { renderForm = () => { diff --git a/server/sonar-web/src/main/js/apps/create/organization/PlanStep.tsx b/server/sonar-web/src/main/js/apps/create/organization/PlanStep.tsx index 8a5517068c8..ffb191a0e68 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/PlanStep.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/PlanStep.tsx @@ -24,7 +24,6 @@ import Step from '../../tutorials/components/Step'; import { withCurrentUser } from '../../../components/hoc/withCurrentUser'; import { translate } from '../../../helpers/l10n'; import { getExtensionStart } from '../../../app/components/extensions/utils'; -import { SubscriptionPlan } from '../../../app/types'; import { SubmitButton } from '../../../components/ui/buttons'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; @@ -38,7 +37,7 @@ interface Props { onlyPaid?: boolean; open: boolean; startingPrice: string; - subscriptionPlans: SubscriptionPlan[]; + subscriptionPlans: T.SubscriptionPlan[]; } interface State { diff --git a/server/sonar-web/src/main/js/apps/create/organization/RemoteOrganizationChoose.tsx b/server/sonar-web/src/main/js/apps/create/organization/RemoteOrganizationChoose.tsx index 8ac73dfba21..199fa8899e9 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/RemoteOrganizationChoose.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/RemoteOrganizationChoose.tsx @@ -27,23 +27,17 @@ import OrganizationAvatar from '../../../components/common/OrganizationAvatar'; import Select from '../../../components/controls/Select'; import { Alert } from '../../../components/ui/Alert'; import { SubmitButton } from '../../../components/ui/buttons'; -import { - AlmApplication, - AlmOrganization, - AlmUnboundApplication, - OrganizationBase -} from '../../../app/types'; import { sanitizeAlmId } from '../../../helpers/almIntegrations'; import { translate } from '../../../helpers/l10n'; import { save } from '../../../helpers/storage'; import { getBaseUrl } from '../../../helpers/urls'; interface Props { - almApplication: AlmApplication; + almApplication: T.AlmApplication; almInstallId?: string; - almOrganization?: AlmOrganization; - almUnboundApplications: AlmUnboundApplication[]; - boundOrganization?: OrganizationBase; + almOrganization?: T.AlmOrganization; + almUnboundApplications: T.AlmUnboundApplication[]; + boundOrganization?: T.OrganizationBase; } interface State { @@ -72,11 +66,11 @@ export class RemoteOrganizationChoose extends React.PureComponent { + handleInstallationChange = ({ installationId }: T.AlmUnboundApplication) => { this.setState({ unboundInstallationId: installationId }); }; - renderOption = (organization: AlmUnboundApplication) => { + renderOption = (organization: T.AlmUnboundApplication) => { const { almApplication } = this.props; return ( diff --git a/server/sonar-web/src/main/js/apps/create/organization/__tests__/CreateOrganization-test.tsx b/server/sonar-web/src/main/js/apps/create/organization/__tests__/CreateOrganization-test.tsx index ece50179d3f..f4471222b68 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/__tests__/CreateOrganization-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/__tests__/CreateOrganization-test.tsx @@ -23,7 +23,6 @@ import { Location } from 'history'; import { shallow } from 'enzyme'; import { CreateOrganization } from '../CreateOrganization'; import { mockRouter, waitAndUpdate } from '../../../../helpers/testUtils'; -import { LoggedInUser } from '../../../../app/types'; import { getAlmAppInfo, getAlmOrganization, @@ -71,7 +70,7 @@ jest.mock('../../../../helpers/storage', () => ({ remove: jest.fn() })); -const user: LoggedInUser = { +const user: T.LoggedInUser = { groups: [], isLoggedIn: true, login: 'luke', diff --git a/server/sonar-web/src/main/js/apps/create/project/AlmRepositoryItem.tsx b/server/sonar-web/src/main/js/apps/create/project/AlmRepositoryItem.tsx index cf360366a10..aa700e4ce57 100644 --- a/server/sonar-web/src/main/js/apps/create/project/AlmRepositoryItem.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/AlmRepositoryItem.tsx @@ -24,15 +24,14 @@ import * as theme from '../../../app/theme'; import Checkbox from '../../../components/controls/Checkbox'; import CheckIcon from '../../../components/icons-components/CheckIcon'; import Tooltip from '../../../components/controls/Tooltip'; -import { AlmRepository, IdentityProvider } from '../../../app/types'; import { getBaseUrl, getProjectUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; interface Props { - identityProvider: IdentityProvider; - repository: AlmRepository; + identityProvider: T.IdentityProvider; + repository: T.AlmRepository; selected: boolean; - toggleRepository: (repository: AlmRepository) => void; + toggleRepository: (repository: T.AlmRepository) => void; } export default class AlmRepositoryItem extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/create/project/AutoProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/AutoProjectCreate.tsx index 1440a56ab88..70f4f76cacd 100644 --- a/server/sonar-web/src/main/js/apps/create/project/AutoProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/AutoProjectCreate.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import RemoteRepositories from './RemoteRepositories'; import OrganizationInput from './OrganizationInput'; import IdentityProviderLink from '../../../components/ui/IdentityProviderLink'; -import { AlmApplication, Organization } from '../../../app/types'; import { ORGANIZATION_IMPORT_BINDING_IN_PROGRESS_TIMESTAMP, ORGANIZATION_IMPORT_REDIRECT_TO_PROJECT_TIMESTAMP @@ -30,8 +29,8 @@ import { translate } from '../../../helpers/l10n'; import { save } from '../../../helpers/storage'; interface Props { - almApplication: AlmApplication; - boundOrganizations: Organization[]; + almApplication: T.AlmApplication; + boundOrganizations: T.Organization[]; onProjectCreate: (projectKeys: string[], organization: string) => void; organization?: string; } @@ -61,7 +60,7 @@ export default class AutoProjectCreate extends React.PureComponent save(ORGANIZATION_IMPORT_REDIRECT_TO_PROJECT_TIMESTAMP, Date.now().toString(10)); }; - handleOrganizationSelect = ({ key }: Organization) => { + handleOrganizationSelect = ({ key }: T.Organization) => { this.setState({ selectedOrganization: key }); }; diff --git a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx index d6e6cdab45e..882bf5b36a9 100644 --- a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx @@ -28,7 +28,6 @@ import Tabs from '../../../components/controls/Tabs'; import { whenLoggedIn } from '../../../components/hoc/whenLoggedIn'; import { withUserOrganizations } from '../../../components/hoc/withUserOrganizations'; import { skipOnboarding } from '../../../store/users'; -import { LoggedInUser, AlmApplication, Organization } from '../../../app/types'; import { getAlmAppInfo } from '../../../api/alm-integration'; import { hasAdvancedALMIntegration } from '../../../helpers/almIntegrations'; import { translate } from '../../../helpers/l10n'; @@ -36,13 +35,13 @@ import { getProjectUrl, getOrganizationUrl } from '../../../helpers/urls'; import '../../../app/styles/sonarcloud.css'; interface Props { - currentUser: LoggedInUser; + currentUser: T.LoggedInUser; skipOnboarding: () => void; - userOrganizations: Organization[]; + userOrganizations: T.Organization[]; } interface State { - almApplication?: AlmApplication; + almApplication?: T.AlmApplication; loading: boolean; } diff --git a/server/sonar-web/src/main/js/apps/create/project/ManualProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/ManualProjectCreate.tsx index 2fc7cb8d183..a9551883464 100644 --- a/server/sonar-web/src/main/js/apps/create/project/ManualProjectCreate.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/ManualProjectCreate.tsx @@ -22,16 +22,15 @@ import OrganizationInput from './OrganizationInput'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import { SubmitButton } from '../../../components/ui/buttons'; import { createProject } from '../../../api/components'; -import { LoggedInUser, Organization } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; import ProjectKeyInput from '../components/ProjectKeyInput'; import ProjectNameInput from '../components/ProjectNameInput'; interface Props { - currentUser: LoggedInUser; + currentUser: T.LoggedInUser; onProjectCreate: (projectKeys: string[]) => void; organization?: string; - userOrganizations: Organization[]; + userOrganizations: T.Organization[]; } interface State { @@ -96,7 +95,7 @@ export default class ManualProjectCreate extends React.PureComponent { + handleOrganizationSelect = ({ key }: T.Organization) => { this.setState({ selectedOrganization: key }); }; diff --git a/server/sonar-web/src/main/js/apps/create/project/OrganizationInput.tsx b/server/sonar-web/src/main/js/apps/create/project/OrganizationInput.tsx index 6a52175bfcb..a4d3b7e3f96 100644 --- a/server/sonar-web/src/main/js/apps/create/project/OrganizationInput.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/OrganizationInput.tsx @@ -21,15 +21,14 @@ import * as React from 'react'; import { WithRouterProps, withRouter } from 'react-router'; import OrganizationSelect from '../components/OrganizationSelect'; import { ORGANIZATION_IMPORT_REDIRECT_TO_PROJECT_TIMESTAMP } from '../organization/utils'; -import { Organization } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; import { save } from '../../../helpers/storage'; interface Props { autoImport?: boolean; - onChange: (organization: Organization) => void; + onChange: (organization: T.Organization) => void; organization: string; - organizations: Organization[]; + organizations: T.Organization[]; } export class OrganizationInput extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/create/project/RemoteRepositories.tsx b/server/sonar-web/src/main/js/apps/create/project/RemoteRepositories.tsx index dd5c5bd2d84..c2a895ecc60 100644 --- a/server/sonar-web/src/main/js/apps/create/project/RemoteRepositories.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/RemoteRepositories.tsx @@ -21,21 +21,20 @@ import * as React from 'react'; import AlmRepositoryItem from './AlmRepositoryItem'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import { getRepositories, provisionProject } from '../../../api/alm-integration'; -import { AlmApplication, AlmRepository } from '../../../app/types'; import { SubmitButton } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; interface Props { - almApplication: AlmApplication; + almApplication: T.AlmApplication; onProjectCreate: (projectKeys: string[], organization: string) => void; organization: string; } -type SelectedRepositories = { [key: string]: AlmRepository | undefined }; +type SelectedRepositories = { [key: string]: T.AlmRepository | undefined }; interface State { loading: boolean; - repositories: AlmRepository[]; + repositories: T.AlmRepository[]; selectedRepositories: SelectedRepositories; submitting: boolean; } @@ -123,7 +122,7 @@ export default class RemoteRepositories extends React.PureComponent { + toggleRepository = (repository: T.AlmRepository) => { this.setState(({ selectedRepositories }) => ({ selectedRepositories: { ...selectedRepositories, diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectPage-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectPage-test.tsx index 95f3a5eabcb..707e1871d7d 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectPage-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/CreateProjectPage-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { CreateProjectPage } from '../CreateProjectPage'; -import { LoggedInUser } from '../../../../app/types'; import { waitAndUpdate, mockRouter } from '../../../../helpers/testUtils'; import { getAlmAppInfo } from '../../../../api/alm-integration'; @@ -36,7 +35,7 @@ jest.mock('../../../../api/alm-integration', () => ({ }) })); -const user: LoggedInUser = { +const user: T.LoggedInUser = { externalProvider: 'github', groups: [], isLoggedIn: true, diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/App.tsx b/server/sonar-web/src/main/js/apps/custom-measures/components/App.tsx index 620b3f6a528..8d23734dc0a 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/App.tsx @@ -27,7 +27,6 @@ import { updateCustomMeasure, deleteCustomMeasure } from '../../../api/measures'; -import { Paging, CustomMeasure } from '../../../app/types'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import ListFooter from '../../../components/controls/ListFooter'; import { translate } from '../../../helpers/l10n'; @@ -38,8 +37,8 @@ interface Props { interface State { loading: boolean; - measures?: CustomMeasure[]; - paging?: Paging; + measures?: T.CustomMeasure[]; + paging?: T.Paging; } const PAGE_SIZE = 50; diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/DeleteForm.tsx b/server/sonar-web/src/main/js/apps/custom-measures/components/DeleteForm.tsx index f8da5faad95..e23131b5dd8 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/components/DeleteForm.tsx +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/DeleteForm.tsx @@ -18,14 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { CustomMeasure } from '../../../app/types'; import SimpleModal from '../../../components/controls/SimpleModal'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import { SubmitButton, ResetButtonLink } from '../../../components/ui/buttons'; import { translate, translateWithParameters } from '../../../helpers/l10n'; interface Props { - measure: CustomMeasure; + measure: T.CustomMeasure; onClose: () => void; onSubmit: () => Promise; } diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/Form.tsx b/server/sonar-web/src/main/js/apps/custom-measures/components/Form.tsx index 40c2a87f64e..2ab28d4ec84 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/components/Form.tsx +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/Form.tsx @@ -19,7 +19,6 @@ */ import * as React from 'react'; import { getAllMetrics } from '../../../api/metrics'; -import { CustomMeasure, Metric } from '../../../app/types'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import Select from '../../../components/controls/Select'; import SimpleModal from '../../../components/controls/SimpleModal'; @@ -30,7 +29,7 @@ import { Alert } from '../../../components/ui/Alert'; interface Props { confirmButtonText: string; header: string; - measure?: CustomMeasure; + measure?: T.CustomMeasure; onClose: () => void; onSubmit: (data: { description: string; metricKey: string; value: string }) => Promise; skipMetrics?: string[]; @@ -40,7 +39,7 @@ interface State { description: string; loading: boolean; metricKey?: string; - metrics?: Metric[]; + metrics?: T.Metric[]; value: string; } diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/Item.tsx b/server/sonar-web/src/main/js/apps/custom-measures/components/Item.tsx index 335d89faacd..a34438f6679 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/components/Item.tsx +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/Item.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import DeleteForm from './DeleteForm'; import Form from './Form'; import MeasureDate from './MeasureDate'; -import { CustomMeasure } from '../../../app/types'; import ActionsDropdown, { ActionsDropdownDivider, ActionsDropdownItem @@ -31,7 +30,7 @@ import { translate } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; interface Props { - measure: CustomMeasure; + measure: T.CustomMeasure; onDelete: (measureId: string) => Promise; onEdit: (data: { description: string; id: string; value: string }) => Promise; } diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/List.tsx b/server/sonar-web/src/main/js/apps/custom-measures/components/List.tsx index f26474192d1..4d691d38a4b 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/components/List.tsx +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/List.tsx @@ -20,11 +20,10 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import Item from './Item'; -import { CustomMeasure } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - measures: CustomMeasure[]; + measures: T.CustomMeasure[]; onDelete: (measureId: string) => Promise; onEdit: (data: { description: string; id: string; value: string }) => Promise; } diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/MeasureDate.tsx b/server/sonar-web/src/main/js/apps/custom-measures/components/MeasureDate.tsx index cde3f66e28d..8fd76ecebb0 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/components/MeasureDate.tsx +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/MeasureDate.tsx @@ -18,12 +18,11 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { CustomMeasure } from '../../../app/types'; import DateFormatter from '../../../components/intl/DateFormatter'; import { translate } from '../../../helpers/l10n'; interface Props { - measure: CustomMeasure; + measure: T.CustomMeasure; } export default function MeasureDate({ measure }: Props) { diff --git a/server/sonar-web/src/main/js/apps/custom-metrics/components/App.tsx b/server/sonar-web/src/main/js/apps/custom-metrics/components/App.tsx index a8f87cf9941..e55a24a065c 100644 --- a/server/sonar-web/src/main/js/apps/custom-metrics/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/custom-metrics/components/App.tsx @@ -32,7 +32,6 @@ import { createMetric, MetricsResponse } from '../../../api/metrics'; -import { Metric, Paging } from '../../../app/types'; import ListFooter from '../../../components/controls/ListFooter'; import { translate } from '../../../helpers/l10n'; @@ -41,8 +40,8 @@ interface Props {} interface State { domains?: string[]; loading: boolean; - metrics?: Metric[]; - paging?: Paging; + metrics?: T.Metric[]; + paging?: T.Paging; types?: string[]; } @@ -104,7 +103,7 @@ export default class App extends React.PureComponent { } }; - getPaging = (response: MetricsResponse): Paging => ({ + getPaging = (response: MetricsResponse): T.Paging => ({ pageIndex: response.p, pageSize: response.ps, total: response.total diff --git a/server/sonar-web/src/main/js/apps/custom-metrics/components/DeleteForm.tsx b/server/sonar-web/src/main/js/apps/custom-metrics/components/DeleteForm.tsx index c799bcb1a56..8ab5fdd1990 100644 --- a/server/sonar-web/src/main/js/apps/custom-metrics/components/DeleteForm.tsx +++ b/server/sonar-web/src/main/js/apps/custom-metrics/components/DeleteForm.tsx @@ -18,14 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Metric } from '../../../app/types'; import SimpleModal from '../../../components/controls/SimpleModal'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import { SubmitButton, ResetButtonLink } from '../../../components/ui/buttons'; import { translate, translateWithParameters } from '../../../helpers/l10n'; interface Props { - metric: Metric; + metric: T.Metric; onClose: () => void; onSubmit: () => Promise; } diff --git a/server/sonar-web/src/main/js/apps/custom-metrics/components/Form.tsx b/server/sonar-web/src/main/js/apps/custom-metrics/components/Form.tsx index c6d4e5ee4c3..ca804ea571f 100644 --- a/server/sonar-web/src/main/js/apps/custom-metrics/components/Form.tsx +++ b/server/sonar-web/src/main/js/apps/custom-metrics/components/Form.tsx @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Metric } from '../../../app/types'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import SimpleModal from '../../../components/controls/SimpleModal'; import { translate } from '../../../helpers/l10n'; @@ -36,7 +35,7 @@ export interface MetricProps { interface Props { confirmButtonText: string; domains: string[]; - metric?: Metric; + metric?: T.Metric; header: string; onClose: () => void; onSubmit: (data: MetricProps) => Promise; diff --git a/server/sonar-web/src/main/js/apps/custom-metrics/components/Item.tsx b/server/sonar-web/src/main/js/apps/custom-metrics/components/Item.tsx index 7f31c648bf3..6fc4002a09f 100644 --- a/server/sonar-web/src/main/js/apps/custom-metrics/components/Item.tsx +++ b/server/sonar-web/src/main/js/apps/custom-metrics/components/Item.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import DeleteForm from './DeleteForm'; import Form, { MetricProps } from './Form'; -import { Metric } from '../../../app/types'; import ActionsDropdown, { ActionsDropdownDivider, ActionsDropdownItem @@ -29,7 +28,7 @@ import { translate } from '../../../helpers/l10n'; interface Props { domains?: string[]; - metric: Metric; + metric: T.Metric; onDelete: (metricKey: string) => Promise; onEdit: (data: { id: string } & MetricProps) => Promise; types?: string[]; diff --git a/server/sonar-web/src/main/js/apps/custom-metrics/components/List.tsx b/server/sonar-web/src/main/js/apps/custom-metrics/components/List.tsx index ddbf383ec2d..4a21e16fd63 100644 --- a/server/sonar-web/src/main/js/apps/custom-metrics/components/List.tsx +++ b/server/sonar-web/src/main/js/apps/custom-metrics/components/List.tsx @@ -21,12 +21,11 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import { MetricProps } from './Form'; import Item from './Item'; -import { Metric } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { domains?: string[]; - metrics: Metric[]; + metrics: T.Metric[]; onDelete: (metricKey: string) => Promise; onEdit: (data: { id: string } & MetricProps) => Promise; types?: string[]; diff --git a/server/sonar-web/src/main/js/apps/groups/components/App.tsx b/server/sonar-web/src/main/js/apps/groups/components/App.tsx index 3742549abdb..78af399e5a5 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/App.tsx @@ -24,7 +24,6 @@ import List from './List'; import forSingleOrganization from '../../organizations/forSingleOrganization'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import { searchUsersGroups, deleteGroup, updateGroup, createGroup } from '../../../api/user_groups'; -import { Group, Paging } from '../../../app/types'; import ListFooter from '../../../components/controls/ListFooter'; import SearchBox from '../../../components/controls/SearchBox'; import { translate } from '../../../helpers/l10n'; @@ -34,9 +33,9 @@ interface Props { } interface State { - groups?: Group[]; + groups?: T.Group[]; loading: boolean; - paging?: Paging; + paging?: T.Paging; query: string; } diff --git a/server/sonar-web/src/main/js/apps/groups/components/DeleteForm.tsx b/server/sonar-web/src/main/js/apps/groups/components/DeleteForm.tsx index a1a3a495677..27510f29e35 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/DeleteForm.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/DeleteForm.tsx @@ -18,14 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Group } from '../../../app/types'; import SimpleModal from '../../../components/controls/SimpleModal'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import { SubmitButton, ResetButtonLink } from '../../../components/ui/buttons'; import { translate, translateWithParameters } from '../../../helpers/l10n'; interface Props { - group: Group; + group: T.Group; onClose: () => void; onSubmit: () => Promise; } diff --git a/server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx b/server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx index b149628988d..f9ba6d44efc 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/EditMembers.tsx @@ -19,12 +19,11 @@ */ import * as React from 'react'; import EditMembersModal from './EditMembersModal'; -import { Group } from '../../../app/types'; import BulletListIcon from '../../../components/icons-components/BulletListIcon'; import { ButtonIcon } from '../../../components/ui/buttons'; interface Props { - group: Group; + group: T.Group; onEdit: () => void; organization: string | undefined; } diff --git a/server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx b/server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx index 097ff47354b..0118f637394 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx @@ -29,11 +29,10 @@ import { addUserToGroup, getUsersInGroup } from '../../../api/user_groups'; -import { Group } from '../../../app/types'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; interface Props { - group: Group; + group: T.Group; onClose: () => void; organization: string | undefined; } diff --git a/server/sonar-web/src/main/js/apps/groups/components/Form.tsx b/server/sonar-web/src/main/js/apps/groups/components/Form.tsx index 8d1e4fc8434..b17b6d86d98 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/Form.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/Form.tsx @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Group } from '../../../app/types'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import SimpleModal from '../../../components/controls/SimpleModal'; import { ResetButtonLink, SubmitButton } from '../../../components/ui/buttons'; @@ -26,7 +25,7 @@ import { translate } from '../../../helpers/l10n'; interface Props { confirmButtonText: string; - group?: Group; + group?: T.Group; header: string; onClose: () => void; onSubmit: (data: { description: string; name: string }) => Promise; diff --git a/server/sonar-web/src/main/js/apps/groups/components/List.tsx b/server/sonar-web/src/main/js/apps/groups/components/List.tsx index 1971e243c15..ba46b2a2844 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/List.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/List.tsx @@ -20,11 +20,10 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import ListItem from './ListItem'; -import { Group } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - groups: Group[]; + groups: T.Group[]; onDelete: (name: string) => Promise; onEdit: (data: { description?: string; id: number; name?: string }) => Promise; onEditMembers: () => void; diff --git a/server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx b/server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx index a1f2f8ba611..c6275faa960 100644 --- a/server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx +++ b/server/sonar-web/src/main/js/apps/groups/components/ListItem.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import DeleteForm from './DeleteForm'; import EditMembers from './EditMembers'; import Form from './Form'; -import { Group } from '../../../app/types'; import ActionsDropdown, { ActionsDropdownItem, ActionsDropdownDivider @@ -30,7 +29,7 @@ import { translate } from '../../../helpers/l10n'; import { omitNil } from '../../../helpers/request'; interface Props { - group: Group; + group: T.Group; onDelete: (name: string) => Promise; onEdit: (data: { description?: string; id: number; name?: string }) => Promise; onEditMembers: () => void; diff --git a/server/sonar-web/src/main/js/apps/issues/IssuesPageSelector.tsx b/server/sonar-web/src/main/js/apps/issues/IssuesPageSelector.tsx index 2025d4bb7f1..b8e7c7dbd5b 100644 --- a/server/sonar-web/src/main/js/apps/issues/IssuesPageSelector.tsx +++ b/server/sonar-web/src/main/js/apps/issues/IssuesPageSelector.tsx @@ -20,14 +20,13 @@ import * as React from 'react'; import { connect } from 'react-redux'; import AppContainer from './components/AppContainer'; -import { CurrentUser } from '../../app/types'; import { RawQuery } from '../../helpers/query'; import { getCurrentUser, Store } from '../../store/rootReducer'; import { isSonarCloud } from '../../helpers/system'; import { isLoggedIn } from '../../helpers/users'; interface StateProps { - currentUser: CurrentUser; + currentUser: T.CurrentUser; } interface Props extends StateProps { diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.tsx b/server/sonar-web/src/main/js/apps/issues/components/App.tsx index cfb4f7bee79..4faebc2f57f 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/App.tsx @@ -53,14 +53,6 @@ import { STANDARDS, ReferencedRule } from '../utils'; -import { - Component, - CurrentUser, - Issue, - Paging, - BranchLike, - Organization -} from '../../../app/types'; import handleRequiredAuthentication from '../../../app/utils/handleRequiredAuthentication'; import Dropdown from '../../../components/controls/Dropdown'; import ListFooter from '../../../components/controls/ListFooter'; @@ -89,24 +81,24 @@ interface FetchIssuesPromise { components: ReferencedComponent[]; effortTotal: number; facets: RawFacet[]; - issues: Issue[]; + issues: T.Issue[]; languages: ReferencedLanguage[]; - paging: Paging; + paging: T.Paging; rules: ReferencedRule[]; users: ReferencedUser[]; } interface Props { - branchLike?: BranchLike; - component?: Component; - currentUser: CurrentUser; + branchLike?: T.BranchLike; + component?: T.Component; + currentUser: T.CurrentUser; fetchIssues: (query: RawQuery, requestOrganizations?: boolean) => Promise; hideAuthorFacet?: boolean; location: { pathname: string; query: RawQuery }; myIssues?: boolean; onBranchesChange: () => void; organization?: { key: string }; - userOrganizations: Organization[]; + userOrganizations: T.Organization[]; } export interface State { @@ -114,7 +106,7 @@ export interface State { checked: string[]; effortTotal?: number; facets: { [facet: string]: Facet }; - issues: Issue[]; + issues: T.Issue[]; lastChecked?: string; loading: boolean; loadingFacets: { [key: string]: boolean }; @@ -122,9 +114,9 @@ export interface State { locationsNavigator: boolean; myIssues: boolean; openFacets: { [facet: string]: boolean }; - openIssue?: Issue; + openIssue?: T.Issue; openPopup?: { issue: string; name: string }; - paging?: Paging; + paging?: T.Paging; query: Query; referencedComponentsById: { [id: string]: ReferencedComponent }; referencedComponentsByKey: { [key: string]: ReferencedComponent }; @@ -321,7 +313,7 @@ export default class App extends React.PureComponent { return index !== -1 ? index : undefined; } - getOpenIssue = (props: Props, issues: Issue[]) => { + getOpenIssue = (props: Props, issues: T.Issue[]) => { const open = getOpen(props.location.query); return open ? issues.find(issue => issue.key === open) : undefined; }; @@ -508,8 +500,8 @@ export default class App extends React.PureComponent { fetchIssuesUntil = ( p: number, - done: (issues: Issue[], paging: Paging) => boolean - ): Promise<{ issues: Issue[]; paging: Paging }> => { + done: (issues: T.Issue[], paging: T.Paging) => boolean + ): Promise<{ issues: T.Issue[]; paging: T.Paging }> => { return this.fetchIssuesPage(p).then(response => { const { issues, paging } = response; @@ -559,9 +551,9 @@ export default class App extends React.PureComponent { return Promise.reject(undefined); } - const isSameComponent = (issue: Issue) => issue.component === openIssue.component; + const isSameComponent = (issue: T.Issue) => issue.component === openIssue.component; - const done = (issues: Issue[], paging: Paging) => { + const done = (issues: T.Issue[], paging: T.Paging) => { if (paging.total <= paging.pageIndex * paging.pageSize) { return true; } @@ -636,7 +628,7 @@ export default class App extends React.PureComponent { getCheckedIssues = () => { const issues = this.state.checked .map(checked => this.state.issues.find(issue => issue.key === checked)) - .filter((issue): issue is Issue => issue !== undefined); + .filter((issue): issue is T.Issue => issue !== undefined); const paging = { pageIndex: 1, pageSize: issues.length, total: issues.length }; return Promise.resolve({ issues, paging }); }; @@ -769,7 +761,7 @@ export default class App extends React.PureComponent { } }; - handleIssueChange = (issue: Issue) => { + handleIssueChange = (issue: T.Issue) => { this.setState(state => ({ issues: state.issues.map(candidate => (candidate.key === issue.key ? issue : candidate)) })); @@ -850,7 +842,7 @@ export default class App extends React.PureComponent { this.setState(actions.selectPreviousFlow); }; - renderBulkChange(openIssue: Issue | undefined) { + renderBulkChange(openIssue: T.Issue | undefined) { const { component, currentUser } = this.props; const { bulkChange, checked, paging, issues } = this.state; @@ -999,7 +991,7 @@ export default class App extends React.PureComponent { ); } - renderSide(openIssue: Issue | undefined) { + renderSide(openIssue: T.Issue | undefined) { return ( {({ top }) => ( diff --git a/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx b/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx index 00e0522766c..bd92e5ee7ad 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx @@ -22,7 +22,6 @@ import { Dispatch } from 'redux'; import { uniq } from 'lodash'; import { searchIssues } from '../../../api/issues'; import { getOrganizations } from '../../../api/organizations'; -import { CurrentUser, Organization } from '../../../app/types'; import throwGlobalError from '../../../app/utils/throwGlobalError'; import { getCurrentUser, @@ -36,8 +35,8 @@ import { RawQuery } from '../../../helpers/query'; import { receiveOrganizations } from '../../../store/organizations'; interface StateProps { - currentUser: CurrentUser; - userOrganizations: Organization[]; + currentUser: T.CurrentUser; + userOrganizations: T.Organization[]; } const mapStateToProps = (state: Store): StateProps => ({ diff --git a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx index 0438b4d4c13..49f0642ddb1 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { pickBy, sortBy } from 'lodash'; import { searchAssignees } from '../utils'; import { searchIssueTags, bulkChangeIssues } from '../../../api/issues'; -import { Component, CurrentUser, Issue, Paging, IssueType } from '../../../app/types'; import throwGlobalError from '../../../app/utils/throwGlobalError'; import MarkdownTips from '../../../components/common/MarkdownTips'; import SearchSelect from '../../../components/controls/SearchSelect'; @@ -50,9 +49,9 @@ interface TagOption { } interface Props { - component: Component | undefined; - currentUser: CurrentUser; - fetchIssues: (x: {}) => Promise<{ issues: Issue[]; paging: Paging }>; + component: T.Component | undefined; + currentUser: T.CurrentUser; + fetchIssues: (x: {}) => Promise<{ issues: T.Issue[]; paging: T.Paging }>; onClose: () => void; onDone: () => void; organization: { key: string } | undefined; @@ -72,10 +71,10 @@ interface FormFields { interface State extends FormFields { initialTags: Array<{ label: string; value: string }>; - issues: Issue[]; + issues: T.Issue[]; // used for initial loading of issues loading: boolean; - paging?: Paging; + paging?: T.Paging; // used when submitting a form submitting: boolean; } @@ -232,7 +231,7 @@ export default class BulkChangeModal extends React.PureComponent { ); }; - getAvailableTransitions(issues: Issue[]) { + getAvailableTransitions(issues: T.Issue[]) { const transitions: { [x: string]: number } = {}; issues.forEach(issue => { if (issue.transitions) { @@ -334,7 +333,7 @@ export default class BulkChangeModal extends React.PureComponent { return null; } - const types = [IssueType.Bug, IssueType.Vulnerability, IssueType.CodeSmell]; + const types: T.IssueType[] = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; const options = types.map(type => ({ label: translate('issue.type', type), value: type })); const optionRenderer = (option: { label: string; value: string }) => ( @@ -542,7 +541,7 @@ export default class BulkChangeModal extends React.PureComponent { } function hasAction(action: string) { - return (issue: Issue) => issue.actions && issue.actions.includes(action); + return (issue: T.Issue) => issue.actions && issue.actions.includes(action); } function promptCreateTag(label: string) { diff --git a/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx b/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx index 3e3adfad26d..cc1560bb9a3 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx @@ -20,16 +20,15 @@ import * as React from 'react'; import { Link } from 'react-router'; import { getSelectedLocation } from '../utils'; -import { BranchLike, Component, Issue } from '../../../app/types'; import Organization from '../../../components/shared/Organization'; import { collapsePath, limitComponentName } from '../../../helpers/path'; import { getBranchLikeUrl, getCodeUrl } from '../../../helpers/urls'; interface Props { - branchLike?: BranchLike; - component?: Component; + branchLike?: T.BranchLike; + component?: T.Component; issue: Pick< - Issue, + T.Issue, | 'component' | 'componentLongName' | 'flows' diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx index e748494a653..3cfcad6534a 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx @@ -20,21 +20,20 @@ import * as React from 'react'; import ListItem from './ListItem'; import { Query } from '../utils'; -import { BranchLike, Component, Issue } from '../../../app/types'; interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; checked: string[]; - component: Component | undefined; - issues: Issue[]; + component: T.Component | undefined; + issues: T.Issue[]; onFilterChange: (changes: Partial) => void; - onIssueChange: (issue: Issue) => void; + onIssueChange: (issue: T.Issue) => void; onIssueCheck: ((issueKey: string, event: { shiftKey?: boolean }) => void) | undefined; onIssueClick: (issueKey: string) => void; onPopupToggle: (issue: string, popupName: string, open?: boolean) => void; openPopup: { issue: string; name: string } | undefined; organization: { key: string } | undefined; - selectedIssue: Issue | undefined; + selectedIssue: T.Issue | undefined; } export default class IssuesList extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx index 6266c18322c..2ac7e78287d 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.tsx @@ -19,18 +19,17 @@ */ import * as React from 'react'; import { getLocations, getSelectedLocation } from '../utils'; -import { BranchLike, Issue } from '../../../app/types'; import SourceViewer from '../../../components/SourceViewer/SourceViewer'; import { scrollToElement } from '../../../helpers/scrolling'; interface Props { - branchLike: BranchLike | undefined; - loadIssues: (component: string, from: number, to: number) => Promise; + branchLike: T.BranchLike | undefined; + loadIssues: (component: string, from: number, to: number) => Promise; locationsNavigator: boolean; - onIssueChange: (issue: Issue) => void; + onIssueChange: (issue: T.Issue) => void; onIssueSelect: (issueKey: string) => void; onLocationSelect: (index: number) => void; - openIssue: Issue; + openIssue: T.Issue; selectedFlowIndex: number | undefined; selectedLocationIndex: number | undefined; } diff --git a/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx b/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx index 65cf89e269f..e8db92cc557 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx @@ -20,22 +20,21 @@ import * as React from 'react'; import ComponentBreadcrumbs from './ComponentBreadcrumbs'; import { Query } from '../utils'; -import { BranchLike, Issue as IssueType, Component } from '../../../app/types'; import Issue from '../../../components/issue/Issue'; interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; checked: boolean; - component: Component | undefined; - issue: IssueType; - onChange: (issue: IssueType) => void; + component: T.Component | undefined; + issue: T.Issue; + onChange: (issue: T.Issue) => void; onCheck: ((issueKey: string, event: { shiftKey?: boolean }) => void) | undefined; onClick: (issueKey: string) => void; onFilterChange: (changes: Partial) => void; onPopupToggle: (issue: string, popupName: string, open?: boolean) => void; openPopup: string | undefined; organization: { key: string } | undefined; - previousIssue: IssueType | undefined; + previousIssue: T.Issue | undefined; selected: boolean; } @@ -46,7 +45,7 @@ interface State { export default class ListItem extends React.PureComponent { state: State = { similarIssues: false }; - handleFilter = (property: string, issue: IssueType) => { + handleFilter = (property: string, issue: T.Issue) => { const { onFilterChange } = this.props; const issuesReset = { issues: [] }; diff --git a/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx b/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx index 31eb0f06472..b890f9868c9 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import IssuesCounter from './IssuesCounter'; import TotalEffort from './TotalEffort'; -import { HomePageType, Paging } from '../../../app/types'; import HomePageSelect from '../../../components/controls/HomePageSelect'; import ReloadButton from '../../../components/controls/ReloadButton'; import { translate } from '../../../helpers/l10n'; @@ -30,7 +29,7 @@ interface Props { canSetHome: boolean; effortTotal: number | undefined; onReload: () => void; - paging: Paging | undefined; + paging: T.Paging | undefined; selectedIndex: number | undefined; } @@ -71,9 +70,7 @@ export default class PageActions extends React.PureComponent { {this.props.canSetHome && ( )} diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx index 4255ab774d9..7a14512a402 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx @@ -20,14 +20,13 @@ import * as React from 'react'; import App from '../App'; import { shallowWithIntl, waitAndUpdate } from '../../../../helpers/testUtils'; -import { Issue } from '../../../../app/types'; const replace = jest.fn(); const issues = [ - { key: 'foo' } as Issue, - { key: 'bar' } as Issue, - { key: 'third' } as Issue, - { key: 'fourth' } as Issue + { key: 'foo' } as T.Issue, + { key: 'bar' } as T.Issue, + { key: 'third' } as T.Issue, + { key: 'fourth' } as T.Issue ]; const facets = [{ property: 'severities', values: [{ val: 'MINOR', count: 4 }] }]; const paging = { pageIndex: 1, pageSize: 100, total: 4 }; diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx index e6fa64c3464..f9105feba82 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import BulkChangeModal from '../BulkChangeModal'; import { waitAndUpdate } from '../../../../helpers/testUtils'; -import { Issue, IssueType } from '../../../../app/types'; jest.mock('../../../../api/issues', () => ({ searchIssueTags: () => Promise.resolve([undefined, []]) @@ -57,14 +56,14 @@ it('should display form when issues are present', async () => { severity: 'foo', status: 'foo', transitions: [], - type: IssueType.Bug + type: 'BUG' } ]); await waitAndUpdate(wrapper); expect(wrapper).toMatchSnapshot(); }); -const getWrapper = (issues: Issue[]) => { +const getWrapper = (issues: T.Issue[]) => { return shallow( { it('renders with branch', () => { const issue = { ...baseIssue, subProject: 'sub-proj', subProjectName: 'sub-proj-name' }; - const shortBranch: ShortLivingBranch = { + const shortBranch: T.ShortLivingBranch = { isMain: false, mergeBranch: '', name: 'feature', - type: BranchType.SHORT + type: 'SHORT' }; expect( shallow( diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssue.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssue.tsx index 2109ebb181d..79a1ef82afc 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssue.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssue.tsx @@ -20,14 +20,13 @@ import * as React from 'react'; import ConciseIssueBox from './ConciseIssueBox'; import ConciseIssueComponent from './ConciseIssueComponent'; -import { Issue } from '../../../app/types'; interface Props { - issue: Issue; + issue: T.Issue; onFlowSelect: (index: number) => void; onLocationSelect: (index: number) => void; onSelect: (issueKey: string) => void; - previousIssue: Issue | undefined; + previousIssue: T.Issue | undefined; scroll: (element: Element) => void; selected: boolean; selectedFlowIndex: number | undefined; diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx index c8201f79b0e..57aa1b89620 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx @@ -21,12 +21,11 @@ import * as React from 'react'; import * as classNames from 'classnames'; import ConciseIssueLocations from './ConciseIssueLocations'; import ConciseIssueLocationsNavigator from './ConciseIssueLocationsNavigator'; -import { Issue } from '../../../app/types'; import SeverityHelper from '../../../components/shared/SeverityHelper'; import TypeHelper from '../../../components/shared/TypeHelper'; interface Props { - issue: Issue; + issue: T.Issue; onClick: (issueKey: string) => void; onFlowSelect: (index: number) => void; onLocationSelect: (index: number) => void; diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocations.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocations.tsx index 3a2cdb9885f..72ec5133ec4 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocations.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocations.tsx @@ -19,10 +19,9 @@ */ import * as React from 'react'; import ConciseIssueLocationBadge from './ConciseIssueLocationBadge'; -import { Issue } from '../../../app/types'; interface Props { - issue: Pick; + issue: Pick; onFlowSelect: (index: number) => void; selectedFlowIndex: number | undefined; } diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocationsNavigator.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocationsNavigator.tsx index 60946f692f5..313d13070da 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocationsNavigator.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueLocationsNavigator.tsx @@ -22,10 +22,9 @@ import { uniq } from 'lodash'; import ConciseIssueLocationsNavigatorLocation from './ConciseIssueLocationsNavigatorLocation'; import CrossFileLocationsNavigator from './CrossFileLocationsNavigator'; import { getLocations } from '../utils'; -import { Issue } from '../../../app/types'; interface Props { - issue: Pick; + issue: Pick; onLocationSelect: (index: number) => void; scroll: (element: Element) => void; selectedFlowIndex: number | undefined; diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesList.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesList.tsx index 4b5045d09ae..546dfe9ea2c 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesList.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesList.tsx @@ -19,11 +19,10 @@ */ import * as React from 'react'; import ConciseIssue from './ConciseIssue'; -import { Issue } from '../../../app/types'; import { scrollToElement } from '../../../helpers/scrolling'; interface Props { - issues: Issue[]; + issues: T.Issue[]; onFlowSelect: (index: number) => void; onIssueSelect: (issueKey: string) => void; onLocationSelect: (index: number) => void; diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesListHeader.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesListHeader.tsx index ffffdeb0a55..0c79994ab33 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesListHeader.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesListHeader.tsx @@ -21,14 +21,13 @@ import * as React from 'react'; import BackButton from '../../../components/controls/BackButton'; import ReloadButton from '../../../components/controls/ReloadButton'; import IssuesCounter from '../components/IssuesCounter'; -import { Paging } from '../../../app/types'; interface Props { displayBackButton?: boolean; loading: boolean; onBackClick: () => void; onReload: () => void; - paging: Paging | undefined; + paging: T.Paging | undefined; selectedIndex: number | undefined; } diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/CrossFileLocationsNavigator.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/CrossFileLocationsNavigator.tsx index 295ffe694fa..b6990775caa 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/CrossFileLocationsNavigator.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/CrossFileLocationsNavigator.tsx @@ -19,13 +19,12 @@ */ import * as React from 'react'; import ConciseIssueLocationsNavigatorLocation from './ConciseIssueLocationsNavigatorLocation'; -import { Issue, FlowLocation } from '../../../app/types'; import { translateWithParameters } from '../../../helpers/l10n'; import { collapsePath } from '../../../helpers/path'; interface Props { - issue: Pick; - locations: FlowLocation[]; + issue: Pick; + locations: T.FlowLocation[]; onLocationSelect: (index: number) => void; scroll: (element: Element) => void; selectedLocationIndex: number | undefined; @@ -39,7 +38,7 @@ interface LocationGroup { component: string | undefined; componentName: string | undefined; firstLocationIndex: number; - locations: FlowLocation[]; + locations: T.FlowLocation[]; } export default class CrossFileLocationsNavigator extends React.PureComponent { @@ -68,10 +67,10 @@ export default class CrossFileLocationsNavigator extends React.PureComponent { + groupByFile = (locations: T.FlowLocation[]) => { const groups: LocationGroup[] = []; - let currentLocations: FlowLocation[] = []; + let currentLocations: T.FlowLocation[] = []; let currentComponent: string | undefined; let currentComponentName: string | undefined; let currentFirstLocationIndex = 0; diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx index 094dc233472..ce4db1c68bc 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx @@ -20,9 +20,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ConciseIssue from '../ConciseIssue'; -import { Issue, IssueType } from '../../../../app/types'; -const issue: Issue = { +const issue: T.Issue = { actions: [], component: '', componentLongName: 'src/file.js', @@ -44,7 +43,7 @@ const issue: Issue = { severity: '', status: '', transitions: [], - type: IssueType.Bug + type: 'BUG' }; it('should render', () => { diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssueLocationsNavigator-test.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssueLocationsNavigator-test.tsx index 9ae00c5b9c4..16c29302df3 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssueLocationsNavigator-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssueLocationsNavigator-test.tsx @@ -20,23 +20,22 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ConciseIssueLocationsNavigator from '../ConciseIssueLocationsNavigator'; -import { FlowLocation } from '../../../../app/types'; -const location1: FlowLocation = { +const location1: T.FlowLocation = { component: 'foo', componentName: 'src/foo.js', msg: 'Do not use foo', textRange: { startLine: 7, endLine: 7, startOffset: 5, endOffset: 8 } }; -const location2: FlowLocation = { +const location2: T.FlowLocation = { component: 'foo', componentName: 'src/foo.js', msg: 'Do not use foo', textRange: { startLine: 8, endLine: 8, startOffset: 0, endOffset: 5 } }; -const location3: FlowLocation = { +const location3: T.FlowLocation = { component: 'bar', componentName: 'src/bar.js', msg: 'Do not use bar', diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssuesList-test.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssuesList-test.tsx index 07c082a2439..1115a917bfb 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssuesList-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssuesList-test.tsx @@ -20,10 +20,9 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ConciseIssuesList from '../ConciseIssuesList'; -import { Issue } from '../../../../app/types'; it('should render', () => { - const issues = [{ key: 'foo' }, { key: 'bar' }] as Issue[]; + const issues = [{ key: 'foo' }, { key: 'bar' }] as T.Issue[]; expect( shallow( ) => Promise; onChange: (changes: Partial) => void; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.tsx index 5e049e522ae..240d69eaf98 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/CreationDateFacet.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { max } from 'lodash'; import { intlShape } from 'react-intl'; import { Query } from '../utils'; -import { Component } from '../../../app/types'; import FacetBox from '../../../components/facet/FacetBox'; import FacetHeader from '../../../components/facet/FacetHeader'; import FacetItem from '../../../components/facet/FacetItem'; @@ -36,7 +35,7 @@ import { formatMeasure } from '../../../helpers/measures'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; interface Props { - component: Component | undefined; + component: T.Component | undefined; createdAfter: Date | undefined; createdAt: string; createdBefore: Date | undefined; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx index a88080345c5..b321275922d 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx @@ -22,14 +22,13 @@ import { omit } from 'lodash'; import ListStyleFacet from '../../../components/facet/ListStyleFacet'; import { Query, ReferencedComponent, Facet } from '../utils'; import { searchProjects, getTree } from '../../../api/components'; -import { Component, Paging } from '../../../app/types'; import Organization from '../../../components/shared/Organization'; import QualifierIcon from '../../../components/icons-components/QualifierIcon'; import { translate } from '../../../helpers/l10n'; import { highlightTerm } from '../../../helpers/search'; interface Props { - component: Component | undefined; + component: T.Component | undefined; loadSearchResultCount: (property: string, changes: Partial) => Promise; fetching: boolean; onChange: (changes: Partial) => void; @@ -52,7 +51,7 @@ export default class ProjectFacet extends React.PureComponent { handleSearch = ( query: string, page = 1 - ): Promise<{ results: SearchedProject[]; paging: Paging }> => { + ): Promise<{ results: SearchedProject[]; paging: T.Paging }> => { const { component, organization } = this.props; if (component && ['VW', 'SVW', 'APP'].includes(component.qualifier)) { return getTree({ diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx index 645fe829f73..ff67f02db4e 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx @@ -22,7 +22,6 @@ import { omit } from 'lodash'; import ListStyleFacet from '../../../components/facet/ListStyleFacet'; import { Query, ReferencedRule, Facet } from '../utils'; import { searchRules } from '../../../api/rules'; -import { Rule } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { @@ -57,7 +56,7 @@ export default class RuleFacet extends React.PureComponent { })); }; - loadSearchResultCount = (rules: Rule[]) => { + loadSearchResultCount = (rules: T.Rule[]) => { return this.props.loadSearchResultCount('rules', { rules: rules.map(rule => rule.key) }); }; @@ -72,13 +71,13 @@ export default class RuleFacet extends React.PureComponent { return langName ? `(${langName}) ${name}` : name; }; - renderSearchResult = (rule: Rule) => { + renderSearchResult = (rule: T.Rule) => { return this.formatRuleName(rule.name, rule.langName); }; render() { return ( - + facetHeader={translate('issues.facet.rules')} fetching={this.props.fetching} getFacetItemText={this.getRuleName} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx index 1e37378bab5..a69c660691d 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx @@ -42,10 +42,9 @@ import { ReferencedRule, STANDARDS } from '../utils'; -import { Component } from '../../../app/types'; export interface Props { - component: Component | undefined; + component: T.Component | undefined; facets: { [facet: string]: Facet }; hideAuthorFacet?: boolean; loadSearchResultCount: (property: string, changes: Partial) => Promise; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx index 8b73c81e71b..1799db279a5 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx @@ -22,14 +22,13 @@ import { omit } from 'lodash'; import { Query, Facet } from '../utils'; import { searchIssueTags } from '../../../api/issues'; import * as theme from '../../../app/theme'; -import { Component } from '../../../app/types'; import TagsIcon from '../../../components/icons-components/TagsIcon'; import { translate } from '../../../helpers/l10n'; import ListStyleFacet from '../../../components/facet/ListStyleFacet'; import { highlightTerm } from '../../../helpers/search'; interface Props { - component: Component | undefined; + component: T.Component | undefined; fetching: boolean; loadSearchResultCount: (property: string, changes: Partial) => Promise; onChange: (changes: Partial) => void; diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx index e246dc28202..7656884a799 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/TypeFacet.tsx @@ -28,7 +28,7 @@ import IssueTypeIcon from '../../../components/ui/IssueTypeIcon'; import { translate } from '../../../helpers/l10n'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import MultipleSelectionHint from '../../../components/facet/MultipleSelectionHint'; -import { IssueType } from '../../../app/types'; +import { ISSUE_TYPES } from '../../../helpers/constants'; interface Props { fetching: boolean; @@ -39,8 +39,6 @@ interface Props { types: string[]; } -const TYPES = [IssueType.Bug, IssueType.Vulnerability, IssueType.CodeSmell, IssueType.Hotspot]; - export default class TypeFacet extends React.PureComponent { property = 'types'; @@ -81,8 +79,7 @@ export default class TypeFacet extends React.PureComponent { // type is selected explicitly types.includes(type) || // bugs, vulnerabilities and code smells are selected implicitly by default - (types.length === 0 && - [IssueType.Bug, IssueType.Vulnerability, IssueType.CodeSmell].includes(type as IssueType)) + (types.length === 0 && ['BUG', 'VULNERABILITY', 'CODE_SMELL'].includes(type)) ); } @@ -126,7 +123,7 @@ export default class TypeFacet extends React.PureComponent { {this.props.open && ( <> - {TYPES.map(this.renderItem)} + {ISSUE_TYPES.map(this.renderItem)} )} diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts index ee1412f78f8..7d20dc76483 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/utils.ts @@ -19,7 +19,6 @@ */ import { searchMembers } from '../../api/organizations'; import { searchUsers } from '../../api/users'; -import { Issue, Paging } from '../../app/types'; import { formatMeasure } from '../../helpers/measures'; import { get, save } from '../../helpers/storage'; import { @@ -215,7 +214,7 @@ export const searchAssignees = ( query: string, organization: string | undefined, page = 1 -): Promise<{ paging: Paging; results: SearchedAssignee[] }> => { +): Promise<{ paging: T.Paging; results: SearchedAssignee[] }> => { return organization ? searchMembers({ organization, p: page, ps: 50, q: query }).then(({ paging, users }) => ({ paging, @@ -235,7 +234,7 @@ export const saveMyIssues = (myIssues: boolean) => save(ISSUES_DEFAULT, myIssues ? LOCALSTORAGE_MY : LOCALSTORAGE_ALL); export function getLocations( - { flows, secondaryLocations }: Pick, + { flows, secondaryLocations }: Pick, selectedFlowIndex: number | undefined ) { if (selectedFlowIndex !== undefined) { @@ -246,7 +245,7 @@ export function getLocations( } export function getSelectedLocation( - issue: Pick, + issue: Pick, selectedFlowIndex: number | undefined, selectedLocationIndex: number | undefined ) { @@ -263,7 +262,7 @@ export function getSelectedLocation( } export function allLocationsEmpty( - issue: Pick, + issue: Pick, selectedFlowIndex: number | undefined ) { return getLocations(issue, selectedFlowIndex).every(location => !location.msg); diff --git a/server/sonar-web/src/main/js/apps/marketplace/App.tsx b/server/sonar-web/src/main/js/apps/marketplace/App.tsx index 2233c8542e1..ca09d9a5ddf 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/App.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/App.tsx @@ -26,7 +26,7 @@ import EditionBoxes from './EditionBoxes'; import Footer from './Footer'; import PluginsList from './PluginsList'; import Search from './Search'; -import { filterPlugins, parseQuery, Query, serializeQuery, EditionKey } from './utils'; +import { filterPlugins, parseQuery, Query, serializeQuery } from './utils'; import Suggestions from '../../app/components/embed-docs-modal/Suggestions'; import { getAvailablePlugins, @@ -41,7 +41,7 @@ import { translate } from '../../helpers/l10n'; import './style.css'; export interface Props { - currentEdition?: EditionKey; + currentEdition?: T.EditionKey; fetchPendingPlugins: () => void; location: { pathname: string; query: RawQuery }; pendingPlugins: PluginPendingResult; diff --git a/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx b/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx index 463d28dacbe..1c400266d68 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/AppContainer.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { connect } from 'react-redux'; import App from './App'; -import { EditionKey } from './utils'; import { getAppState, getGlobalSettingValue, Store } from '../../store/rootReducer'; import { RawQuery } from '../../helpers/query'; import MarketplaceContext from '../../app/components/MarketplaceContext'; @@ -30,7 +29,7 @@ interface OwnProps { } interface StateToProps { - currentEdition?: EditionKey; + currentEdition?: T.EditionKey; standaloneMode?: boolean; updateCenterActive: boolean; } diff --git a/server/sonar-web/src/main/js/apps/marketplace/EditionBoxes.tsx b/server/sonar-web/src/main/js/apps/marketplace/EditionBoxes.tsx index 6f1064db849..b42bc304622 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/EditionBoxes.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/EditionBoxes.tsx @@ -20,11 +20,11 @@ import * as React from 'react'; import EditionBox from './components/EditionBox'; -import { EDITIONS, EditionKey } from './utils'; +import { EDITIONS } from './utils'; import { getMarketplaceNavigation } from '../../api/nav'; export interface Props { - currentEdition?: EditionKey; + currentEdition?: T.EditionKey; } interface State { diff --git a/server/sonar-web/src/main/js/apps/marketplace/Header.tsx b/server/sonar-web/src/main/js/apps/marketplace/Header.tsx index cfff7fe32ad..44f5941aa5e 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/Header.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/Header.tsx @@ -18,11 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { EditionKey } from './utils'; import { translate } from '../../helpers/l10n'; interface Props { - currentEdition?: EditionKey; + currentEdition?: T.EditionKey; } export default function Header({ currentEdition }: Props) { @@ -35,7 +34,7 @@ export default function Header({ currentEdition }: Props) { )}

    - {currentEdition === EditionKey.datacenter + {currentEdition === 'datacenter' ? translate('marketplace.page.description_best_edition') : translate('marketplace.page.description')}

    diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx index 1d59ca8d8e6..56304f8337b 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx @@ -21,14 +21,14 @@ import * as React from 'react'; import tooltipDCE from 'Docs/tooltips/editions/datacenter.md'; import tooltipDE from 'Docs/tooltips/editions/developer.md'; import tooltipEE from 'Docs/tooltips/editions/enterprise.md'; -import { Edition, getEditionUrl, EditionKey } from '../utils'; +import { Edition, getEditionUrl } from '../utils'; import { translate } from '../../../helpers/l10n'; import { lazyLoad } from '../../../components/lazyLoad'; const DocMarkdownBlock = lazyLoad(() => import('../../../components/docs/DocMarkdownBlock')); interface Props { - currentEdition?: EditionKey; + currentEdition?: T.EditionKey; edition: Edition; ncloc?: number; serverId?: string; diff --git a/server/sonar-web/src/main/js/apps/marketplace/utils.ts b/server/sonar-web/src/main/js/apps/marketplace/utils.ts index ef9097d577d..2db6169b2ac 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/utils.ts +++ b/server/sonar-web/src/main/js/apps/marketplace/utils.ts @@ -73,7 +73,7 @@ export const EDITIONS: Edition[] = [ export function getEditionUrl( edition: Edition, - data: { serverId?: string; ncloc?: number; sourceEdition?: string } + data: { serverId?: string; ncloc?: number; sourceEdition?: T.EditionKey } ) { let url = edition.homeUrl; const query = stringify(omitNil(data)); diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/AddMemberForm.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/AddMemberForm.tsx index 2617234955e..f5d802f3e63 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/AddMemberForm.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/AddMemberForm.tsx @@ -23,17 +23,16 @@ import { searchMembers } from '../../api/organizations'; import Modal from '../../components/controls/Modal'; import { translate } from '../../helpers/l10n'; import { SubmitButton, ResetButtonLink, Button } from '../../components/ui/buttons'; -import { Organization, OrganizationMember } from '../../app/types'; interface Props { - addMember: (member: OrganizationMember) => void; - organization: Organization; + addMember: (member: T.OrganizationMember) => void; + organization: T.Organization; memberLogins: string[]; } interface State { open: boolean; - selectedMember?: OrganizationMember; + selectedMember?: T.OrganizationMember; } export default class AddMemberForm extends React.PureComponent { @@ -65,7 +64,7 @@ export default class AddMemberForm extends React.PureComponent { } }; - selectedMemberChange = (member: OrganizationMember) => { + selectedMemberChange = (member: T.OrganizationMember) => { this.setState({ selectedMember: member }); }; diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/ManageMemberGroupsForm.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/ManageMemberGroupsForm.tsx index 6d92e7fce8b..132bab70289 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/ManageMemberGroupsForm.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/ManageMemberGroupsForm.tsx @@ -24,14 +24,13 @@ import Modal from '../../components/controls/Modal'; import { translate, translateWithParameters } from '../../helpers/l10n'; import OrganizationGroupCheckbox from '../organizations/components/OrganizationGroupCheckbox'; import { SubmitButton, ResetButtonLink } from '../../components/ui/buttons'; -import { Organization, OrganizationMember, Group } from '../../app/types'; interface Props { onClose: () => void; - member: OrganizationMember; - organization: Organization; - organizationGroups: Group[]; - updateMemberGroups: (member: OrganizationMember, add: string[], remove: string[]) => void; + member: T.OrganizationMember; + organization: T.Organization; + organizationGroups: T.Group[]; + updateMemberGroups: (member: T.OrganizationMember, add: string[], remove: string[]) => void; } interface State { diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/MembersList.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/MembersList.tsx index 676478bbbff..ae87c282014 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/MembersList.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/MembersList.tsx @@ -20,16 +20,15 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import MembersListItem from './MembersListItem'; -import { Group, Organization, OrganizationMember } from '../../app/types'; import { translate } from '../../helpers/l10n'; interface Props { - members: OrganizationMember[]; - organizationGroups: Group[]; - organization: Organization; - removeMember: (member: OrganizationMember) => void; + members: T.OrganizationMember[]; + organizationGroups: T.Group[]; + organization: T.Organization; + removeMember: (member: T.OrganizationMember) => void; updateMemberGroups: ( - member: OrganizationMember, + member: T.OrganizationMember, add: Array, remove: Array ) => void; diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/MembersListItem.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/MembersListItem.tsx index 4b586b366d9..75c43550d7c 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/MembersListItem.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/MembersListItem.tsx @@ -27,14 +27,13 @@ import ActionsDropdown, { ActionsDropdownDivider, ActionsDropdownItem } from '../../components/controls/ActionsDropdown'; -import { Group, Organization, OrganizationMember } from '../../app/types'; interface Props { - member: OrganizationMember; - organization: Organization; - organizationGroups: Group[]; - removeMember: (member: OrganizationMember) => void; - updateMemberGroups: (member: OrganizationMember, add: string[], remove: string[]) => void; + member: T.OrganizationMember; + organization: T.Organization; + organizationGroups: T.Group[]; + removeMember: (member: T.OrganizationMember) => void; + updateMemberGroups: (member: T.OrganizationMember, add: string[], remove: string[]) => void; } interface State { diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembers.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembers.tsx index 1769a76333a..ab567cda6b7 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembers.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembers.tsx @@ -27,19 +27,18 @@ import Suggestions from '../../app/components/embed-docs-modal/Suggestions'; import ListFooter from '../../components/controls/ListFooter'; import DocTooltip from '../../components/docs/DocTooltip'; import { translate } from '../../helpers/l10n'; -import { Group, Organization, OrganizationMember, Paging } from '../../app/types'; import { searchMembers, addMember, removeMember } from '../../api/organizations'; import { searchUsersGroups, addUserToGroup, removeUserFromGroup } from '../../api/user_groups'; interface Props { - organization: Organization; + organization: T.Organization; } interface State { - groups: Group[]; + groups: T.Group[]; loading: boolean; - members?: OrganizationMember[]; - paging?: Paging; + members?: T.OrganizationMember[]; + paging?: T.Paging; query: string; } @@ -123,7 +122,7 @@ export default class OrganizationMembers extends React.PureComponent { + handleAddMember = ({ login }: T.OrganizationMember) => { // TODO optimistic update addMember({ login, organization: this.props.organization.key }).then( member => { @@ -138,7 +137,7 @@ export default class OrganizationMembers extends React.PureComponent { + handleRemoveMember = ({ login }: T.OrganizationMember) => { // TODO optimistic update removeMember({ login, organization: this.props.organization.key }).then( () => { @@ -153,13 +152,16 @@ export default class OrganizationMembers extends React.PureComponent OrganizationMember) => { + updateGroup = ( + login: string, + updater: (member: T.OrganizationMember) => T.OrganizationMember + ) => { this.setState(({ members }) => ({ members: members && members.map(member => (member.login === login ? updater(member) : member)) })); }; - updateMemberGroups = ({ login }: OrganizationMember, add: string[], remove: string[]) => { + updateMemberGroups = ({ login }: T.OrganizationMember, add: string[], remove: string[]) => { // TODO optimistic update const promises = [ ...add.map(name => diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembersContainer.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembersContainer.tsx index c2b0821b83e..86db8266dc3 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembersContainer.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/OrganizationMembersContainer.tsx @@ -19,7 +19,6 @@ */ import { connect } from 'react-redux'; import OrganizationMembers from './OrganizationMembers'; -import { Organization } from '../../app/types'; import { getOrganizationByKey, Store } from '../../store/rootReducer'; interface OwnProps { @@ -27,7 +26,7 @@ interface OwnProps { } interface StateProps { - organization: Organization; + organization: T.Organization; } const mapStateToProps = (state: Store, ownProps: OwnProps): StateProps => { diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/RemoveMemberForm.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/RemoveMemberForm.tsx index 636ae892a31..ec6494d4fbc 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/RemoveMemberForm.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/RemoveMemberForm.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import Modal from '../../components/controls/Modal'; import { translate, translateWithParameters } from '../../helpers/l10n'; import { SubmitButton, ResetButtonLink } from '../../components/ui/buttons'; -import { Organization, OrganizationMember } from '../../app/types'; interface Props { onClose: () => void; - member: OrganizationMember; - organization: Organization; - removeMember: (member: OrganizationMember) => void; + member: T.OrganizationMember; + organization: T.Organization; + removeMember: (member: T.OrganizationMember) => void; } export default class RemoveMemberForm extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/OrganizationMembers-test.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/OrganizationMembers-test.tsx index 429e6d34767..b99236cd1a0 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/OrganizationMembers-test.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/OrganizationMembers-test.tsx @@ -23,7 +23,6 @@ import OrganizationMembers from '../OrganizationMembers'; import { waitAndUpdate } from '../../../helpers/testUtils'; import { searchMembers, addMember, removeMember } from '../../../api/organizations'; import { searchUsersGroups, addUserToGroup, removeUserFromGroup } from '../../../api/user_groups'; -import { OrganizationMember } from '../../../app/types'; jest.mock('../../../api/organizations', () => ({ addMember: jest.fn().mockResolvedValue({ login: 'bar', name: 'Bar', groupCount: 1 }), @@ -103,7 +102,7 @@ it('should add new member', async () => { expect( wrapper .find('MembersList') - .prop('members') + .prop('members') .find(m => m.login === 'bar') ).toBeDefined(); expect(wrapper.find('ListFooter').prop('total')).toEqual(4); @@ -120,7 +119,7 @@ it('should remove member', async () => { expect( wrapper .find('MembersList') - .prop('members') + .prop('members') .find(m => m.login === 'john') ).toBeUndefined(); expect(wrapper.find('ListFooter').prop('total')).toEqual(2); @@ -140,7 +139,7 @@ it('should update groups', async () => { await waitAndUpdate(wrapper); const john = wrapper .find('MembersList') - .prop('members') + .prop('members') .find(m => m.login === 'john'); expect(john && john.groupCount).toBe(2); expect(addUserToGroup).toHaveBeenCalledTimes(2); diff --git a/server/sonar-web/src/main/js/apps/organizations/actions.ts b/server/sonar-web/src/main/js/apps/organizations/actions.ts index e843cda6344..6d72a0b9318 100644 --- a/server/sonar-web/src/main/js/apps/organizations/actions.ts +++ b/server/sonar-web/src/main/js/apps/organizations/actions.ts @@ -22,7 +22,6 @@ import * as api from '../../api/organizations'; import * as actions from '../../store/organizations'; import { addGlobalSuccessMessage } from '../../store/globalMessages'; import { translate, translateWithParameters } from '../../helpers/l10n'; -import { Organization, OrganizationBase } from '../../app/types'; export const fetchOrganization = (key: string) => (dispatch: Dispatch) => { return Promise.all([api.getOrganization(key), api.getOrganizationNavigation(key)]).then( @@ -35,8 +34,10 @@ export const fetchOrganization = (key: string) => (dispatch: Dispatch) => { ); }; -export const createOrganization = (organization: OrganizationBase) => (dispatch: Dispatch) => { - return api.createOrganization(organization).then((organization: Organization) => { +export const createOrganization = (organization: T.OrganizationBase) => ( + dispatch: Dispatch +) => { + return api.createOrganization(organization).then((organization: T.Organization) => { dispatch(actions.createOrganization(organization)); dispatch( addGlobalSuccessMessage(translateWithParameters('organization.created', organization.name)) @@ -45,7 +46,7 @@ export const createOrganization = (organization: OrganizationBase) => (dispatch: }); }; -export const updateOrganization = (key: string, changes: OrganizationBase) => ( +export const updateOrganization = (key: string, changes: T.OrganizationBase) => ( dispatch: Dispatch ) => { return api.updateOrganization(key, changes).then(() => { diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationAccessContainer.tsx b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationAccessContainer.tsx index 72263ccf372..5c579857e13 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationAccessContainer.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationAccessContainer.tsx @@ -22,12 +22,11 @@ import { connect } from 'react-redux'; import { RouterState } from 'react-router'; import { getCurrentUser, getOrganizationByKey, Store } from '../../../store/rootReducer'; import handleRequiredAuthorization from '../../../app/utils/handleRequiredAuthorization'; -import { Organization, CurrentUser } from '../../../app/types'; import { isLoggedIn } from '../../../helpers/users'; interface StateToProps { - currentUser: CurrentUser; - organization?: Organization; + currentUser: T.CurrentUser; + organization?: T.Organization; } interface OwnProps extends RouterState { diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationContainer.tsx b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationContainer.tsx index baadb3fd4cd..0b12f8035e8 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationContainer.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationContainer.tsx @@ -21,11 +21,10 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { RouterState } from 'react-router'; import { getCurrentUser, getOrganizationByKey, Store } from '../../../store/rootReducer'; -import { Organization, CurrentUser } from '../../../app/types'; interface StateToProps { - organization?: Organization; - currentUser: CurrentUser; + organization?: T.Organization; + currentUser: T.CurrentUser; } interface OwnProps extends RouterState { diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.tsx b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.tsx index 7e506f92d8c..613f2e8a631 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationDelete.tsx @@ -25,7 +25,6 @@ import ConfirmButton from '../../../components/controls/ConfirmButton'; import InstanceMessage from '../../../components/common/InstanceMessage'; import { translate } from '../../../helpers/l10n'; import { deleteOrganization } from '../actions'; -import { Organization } from '../../../app/types'; import { Button } from '../../../components/ui/buttons'; import { getOrganizationBilling } from '../../../api/organizations'; import { isSonarCloud } from '../../../helpers/system'; @@ -36,7 +35,7 @@ interface DispatchToProps { } interface OwnProps { - organization: Pick; + organization: Pick; } type Props = OwnProps & DispatchToProps; diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationEdit.tsx b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationEdit.tsx index 46d57d52361..8b3cb46ca54 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationEdit.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationEdit.tsx @@ -24,15 +24,14 @@ import { debounce } from 'lodash'; import OrganizationAvatar from '../../../components/common/OrganizationAvatar'; import { SubmitButton } from '../../../components/ui/buttons'; import { updateOrganization } from '../actions'; -import { Organization, OrganizationBase } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface DispatchProps { - updateOrganization: (organization: string, changes: OrganizationBase) => Promise; + updateOrganization: (organization: string, changes: T.OrganizationBase) => Promise; } interface OwnProps { - organization: Organization; + organization: T.Organization; } type Props = OwnProps & DispatchProps; diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationGroupCheckbox.tsx b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationGroupCheckbox.tsx index a1209ecbb9c..8a04bbe77fa 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationGroupCheckbox.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationGroupCheckbox.tsx @@ -20,10 +20,9 @@ import * as React from 'react'; import * as classNames from 'classnames'; import Checkbox from '../../../components/controls/Checkbox'; -import { Group } from '../../../app/types'; interface Props { - group: Group; + group: T.Group; checked: boolean; onCheck: (name: string, checked: boolean) => void; } diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationJustCreated.tsx b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationJustCreated.tsx index 71a96eb4e8d..23751fc6dc4 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationJustCreated.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationJustCreated.tsx @@ -19,7 +19,6 @@ */ import * as React from 'react'; import { withRouter, WithRouterProps } from 'react-router'; -import { Organization } from '../../../app/types'; import { Button } from '../../../components/ui/buttons'; import OnboardingProjectIcon from '../../../components/icons-components/OnboardingProjectIcon'; import OnboardingAddMembersIcon from '../../../components/icons-components/OnboardingAddMembersIcon'; @@ -28,7 +27,7 @@ import '../../tutorials/styles.css'; import './OrganizationJustCreated.css'; interface Props { - organization: Organization; + organization: T.Organization; } export class OrganizationJustCreated extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.tsx b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.tsx index b78929a9040..f0d281877eb 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationPage.tsx @@ -26,7 +26,6 @@ import OrganizationNavigation from '../navigation/OrganizationNavigation'; import { fetchOrganization } from '../actions'; import NotFound from '../../../app/components/NotFound'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; -import { Organization, CurrentUser } from '../../../app/types'; import { getOrganizationByKey, getCurrentUser, @@ -41,9 +40,9 @@ interface OwnProps { } interface StateProps { - currentUser: CurrentUser; - organization?: Organization; - userOrganizations: Organization[]; + currentUser: T.CurrentUser; + organization?: T.Organization; + userOrganizations: T.Organization[]; } interface DispatchToProps { @@ -86,7 +85,7 @@ export class OrganizationPage extends React.PureComponent { this.props.fetchOrganization(organizationKey).then(this.stopLoading, this.stopLoading); }; - renderChildren(organization: Organization) { + renderChildren(organization: T.Organization) { const { location } = this.props; const justCreated = Boolean(location.state && location.state.justCreated); return justCreated ? ( diff --git a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjects.tsx b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjects.tsx index ce54a3eea92..ebce36467e1 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjects.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/components/OrganizationProjects.tsx @@ -20,11 +20,10 @@ import * as React from 'react'; import AllProjectsContainer from '../../projects/components/AllProjectsContainer'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; -import { Organization } from '../../../app/types'; interface Props { location: { pathname: string; query: { [x: string]: string } }; - organization: Organization; + organization: T.Organization; } export default function OrganizationProjects(props: Props) { diff --git a/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationAccessContainer-test.tsx b/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationAccessContainer-test.tsx index 961b7f6bc4b..33794e419ee 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationAccessContainer-test.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationAccessContainer-test.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { Location } from 'history'; import { hasAdminAccess, OrganizationAccess } from '../OrganizationAccessContainer'; -import { Visibility } from '../../../../app/types'; jest.mock('../../../../app/utils/handleRequiredAuthorization', () => ({ default: jest.fn() })); @@ -38,14 +37,14 @@ const loggedInUser = { showOnboardingTutorial: false }; -const organization = { +const organization: T.Organization = { actions: { admin: false }, key: 'foo', name: 'Foo', - projectVisibility: Visibility.Public + projectVisibility: 'public' }; -const adminOrganization = { ...organization, actions: { admin: true } }; +const adminOrganization: T.Organization = { ...organization, actions: { admin: true } }; describe('component', () => { it('should render children', () => { diff --git a/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationJustCreated-test.tsx b/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationJustCreated-test.tsx index ef6c0c10ea6..08ee42d00db 100644 --- a/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationJustCreated-test.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/components/__tests__/OrganizationJustCreated-test.tsx @@ -20,10 +20,9 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { OrganizationJustCreated } from '../OrganizationJustCreated'; -import { Organization } from '../../../../app/types'; import { click } from '../../../../helpers/testUtils'; -const organization: Organization = { key: 'foo', name: 'Foo' }; +const organization: T.Organization = { key: 'foo', name: 'Foo' }; it('should render', () => { // @ts-ignore diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.tsx index d74444d133b..64f216b78e3 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.tsx @@ -23,13 +23,12 @@ import OrganizationNavigationMeta from './OrganizationNavigationMeta'; import OrganizationNavigationMenuContainer from './OrganizationNavigationMenuContainer'; import * as theme from '../../../app/theme'; import ContextNavBar from '../../../components/nav/ContextNavBar'; -import { Organization, CurrentUser } from '../../../app/types'; interface Props { - currentUser: CurrentUser; + currentUser: T.CurrentUser; location: { pathname: string }; - organization: Organization; - userOrganizations: Organization[]; + organization: T.Organization; + userOrganizations: T.Organization[]; } export default function OrganizationNavigation({ diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationAdministration.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationAdministration.tsx index e890a54eb11..b4baf580895 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationAdministration.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationAdministration.tsx @@ -20,14 +20,13 @@ import * as React from 'react'; import { Link } from 'react-router'; import * as classNames from 'classnames'; -import { Organization } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; import Dropdown from '../../../components/controls/Dropdown'; import DropdownIcon from '../../../components/icons-components/DropdownIcon'; interface Props { location: { pathname: string }; - organization: Organization; + organization: T.Organization; } const ADMIN_PATHS = [ diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationExtensions.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationExtensions.tsx index 67eac961218..4d81a048639 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationExtensions.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationExtensions.tsx @@ -20,14 +20,13 @@ import * as React from 'react'; import { Link } from 'react-router'; import * as classNames from 'classnames'; -import { Organization } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; import Dropdown from '../../../components/controls/Dropdown'; import DropdownIcon from '../../../components/icons-components/DropdownIcon'; interface Props { location: { pathname: string }; - organization: Organization; + organization: T.Organization; } export default function OrganizationNavigationExtensions({ location, organization }: Props) { diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeader.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeader.tsx index 4d7bb7f71e1..435bd6e2df3 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeader.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeader.tsx @@ -19,7 +19,6 @@ */ import * as React from 'react'; import { sortBy } from 'lodash'; -import { Organization } from '../../../app/types'; import OrganizationAvatar from '../../../components/common/OrganizationAvatar'; import Dropdown from '../../../components/controls/Dropdown'; import DropdownIcon from '../../../components/icons-components/DropdownIcon'; @@ -28,8 +27,8 @@ import { sanitizeAlmId } from '../../../helpers/almIntegrations'; import { getBaseUrl } from '../../../helpers/urls'; interface Props { - organization: Organization; - organizations: Organization[]; + organization: T.Organization; + organizations: T.Organization[]; } export default function OrganizationNavigationHeader({ organization, organizations }: Props) { diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeaderContainer.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeaderContainer.tsx index fb6b23e087b..9a3538713a8 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeaderContainer.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeaderContainer.tsx @@ -19,11 +19,10 @@ */ import { connect } from 'react-redux'; import OrganizationNavigationHeader from './OrganizationNavigationHeader'; -import { Organization } from '../../../app/types'; import { getMyOrganizations, Store } from '../../../store/rootReducer'; interface StateProps { - organizations: Organization[]; + organizations: T.Organization[]; } const mapStateToProps = (state: Store): StateProps => ({ diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMenuContainer.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMenuContainer.tsx index ba5160c5baa..6814a2127a1 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMenuContainer.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMenuContainer.tsx @@ -22,7 +22,6 @@ import { connect } from 'react-redux'; import { Link } from 'react-router'; import OrganizationNavigationExtensions from './OrganizationNavigationExtensions'; import OrganizationNavigationAdministration from './OrganizationNavigationAdministration'; -import { Organization, CurrentUser } from '../../../app/types'; import NavBarTabs from '../../../components/nav/NavBarTabs'; import { translate } from '../../../helpers/l10n'; import { getQualityGatesUrl } from '../../../helpers/urls'; @@ -30,13 +29,13 @@ import { hasPrivateAccess, isCurrentUserMemberOf } from '../../../helpers/organi import { getCurrentUser, getMyOrganizations, Store } from '../../../store/rootReducer'; interface StateToProps { - currentUser: CurrentUser; - userOrganizations: Organization[]; + currentUser: T.CurrentUser; + userOrganizations: T.Organization[]; } interface OwnProps { location: { pathname: string }; - organization: Organization; + organization: T.Organization; } type Props = OwnProps & StateToProps; diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMeta.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMeta.tsx index ed6bfdd185e..8ec2a861f30 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMeta.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMeta.tsx @@ -23,12 +23,11 @@ import DocTooltip from '../../../components/docs/DocTooltip'; import { translate } from '../../../helpers/l10n'; import { isSonarCloud } from '../../../helpers/system'; import { hasPrivateAccess, isPaidOrganization } from '../../../helpers/organizations'; -import { CurrentUser, HomePageType, Organization } from '../../../app/types'; interface Props { - currentUser: CurrentUser; - organization: Organization; - userOrganizations: Organization[]; + currentUser: T.CurrentUser; + organization: T.Organization; + userOrganizations: T.Organization[]; } export default function OrganizationNavigationMeta({ @@ -62,9 +61,7 @@ export default function OrganizationNavigationMeta({ {onSonarCloud && (
    - +
    )} diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.tsx index ecfdd94f780..bdc8387e4ad 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import OrganizationNavigation from '../OrganizationNavigation'; -import { Visibility } from '../../../../app/types'; it('render', () => { expect( @@ -31,7 +30,7 @@ it('render', () => { organization={{ key: 'foo', name: 'Foo', - projectVisibility: Visibility.Public + projectVisibility: 'public' }} userOrganizations={[]} /> diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationAdministration-test.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationAdministration-test.tsx index eb8baeef190..4672359959e 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationAdministration-test.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationAdministration-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import OrganizationNavigationAdministration from '../OrganizationNavigationAdministration'; -import { Visibility } from '../../../../app/types'; it('renders', () => { const wrapper = shallow( @@ -29,7 +28,7 @@ it('renders', () => { organization={{ key: 'foo', name: 'Foo', - projectVisibility: Visibility.Public + projectVisibility: 'public' }} /> ); diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationHeader-test.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationHeader-test.tsx index 6b08b874b9e..11f682b73d0 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationHeader-test.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationHeader-test.tsx @@ -20,13 +20,12 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import OrganizationNavigationHeader from '../OrganizationNavigationHeader'; -import { Visibility } from '../../../../app/types'; it('renders', () => { expect( shallow( ) @@ -41,7 +40,7 @@ it('renders with alm integration', () => { alm: { key: 'github', url: 'https://github.com/foo' }, key: 'foo', name: 'Foo', - projectVisibility: Visibility.Public + projectVisibility: 'public' }} organizations={[]} /> @@ -50,16 +49,16 @@ it('renders with alm integration', () => { }); it('renders dropdown', () => { - const organizations = [ - { actions: { admin: true }, key: 'org1', name: 'org1', projectVisibility: Visibility.Public }, - { actions: { admin: false }, key: 'org2', name: 'org2', projectVisibility: Visibility.Public } + const organizations: T.Organization[] = [ + { actions: { admin: true }, key: 'org1', name: 'org1', projectVisibility: 'public' }, + { actions: { admin: false }, key: 'org2', name: 'org2', projectVisibility: 'public' } ]; const wrapper = shallow( diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMenuContainer-test.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMenuContainer-test.tsx index e2c37db5866..3c326c97a3f 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMenuContainer-test.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMenuContainer-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { OrganizationNavigationMenu } from '../OrganizationNavigationMenuContainer'; -import { Visibility } from '../../../../app/types'; import { isCurrentUserMemberOf, hasPrivateAccess } from '../../../../helpers/organizations'; jest.mock('../../../../helpers/organizations', () => ({ @@ -28,10 +27,10 @@ jest.mock('../../../../helpers/organizations', () => ({ hasPrivateAccess: jest.fn().mockReturnValue(true) })); -const organization = { +const organization: T.Organization = { key: 'foo', name: 'Foo', - projectVisibility: Visibility.Public + projectVisibility: 'public' }; const loggedInUser = { diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMeta-test.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMeta-test.tsx index 5009da6beb4..c402be1352c 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMeta-test.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMeta-test.tsx @@ -20,11 +20,10 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import OrganizationNavigationMeta from '../OrganizationNavigationMeta'; -import { OrganizationSubscription } from '../../../../app/types'; jest.mock('../../../../helpers/system', () => ({ isSonarCloud: () => true })); -const organization = { key: 'foo', name: 'Foo', subscription: OrganizationSubscription.Free }; +const organization: T.Organization = { key: 'foo', name: 'Foo', subscription: 'FREE' }; it('renders', () => { expect( @@ -43,7 +42,7 @@ it('renders with private badge', () => { shallow( ) diff --git a/server/sonar-web/src/main/js/apps/overview/badges/BadgeParams.tsx b/server/sonar-web/src/main/js/apps/overview/badges/BadgeParams.tsx index 6c5a6613d61..ddb7de1f365 100644 --- a/server/sonar-web/src/main/js/apps/overview/badges/BadgeParams.tsx +++ b/server/sonar-web/src/main/js/apps/overview/badges/BadgeParams.tsx @@ -22,11 +22,10 @@ import { BadgeColors, BadgeType, BadgeOptions } from './utils'; import Select from '../../../components/controls/Select'; import { fetchWebApi } from '../../../api/web-api'; import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; -import { Metric } from '../../../app/types'; interface Props { className?: string; - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; options: BadgeOptions; type: BadgeType; updateOptions: (options: Partial) => void; diff --git a/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx b/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx index 9898a4f2b01..1962e6f73f0 100644 --- a/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx +++ b/server/sonar-web/src/main/js/apps/overview/badges/BadgesModal.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import BadgeButton from './BadgeButton'; import BadgeParams from './BadgeParams'; import { BadgeType, BadgeOptions, getBadgeUrl } from './utils'; -import { Metric, BranchLike } from '../../../app/types'; import CodeSnippet from '../../../components/common/CodeSnippet'; import Modal from '../../../components/controls/Modal'; import { getBranchLikeQuery } from '../../../helpers/branches'; @@ -31,8 +30,8 @@ import { isSonarCloud } from '../../../helpers/system'; import './styles.css'; interface Props { - branchLike?: BranchLike; - metrics: { [key: string]: Metric }; + branchLike?: T.BranchLike; + metrics: { [key: string]: T.Metric }; project: string; qualifier: string; } diff --git a/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgeParams-test.tsx b/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgeParams-test.tsx index 5e8936739b3..7656a4ac629 100644 --- a/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgeParams-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgeParams-test.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import BadgeParams from '../BadgeParams'; import { BadgeType } from '../utils'; -import { Metric } from '../../../../app/types'; jest.mock('../../../../api/web-api', () => ({ fetchWebApi: () => @@ -39,8 +38,8 @@ jest.mock('../../../../api/web-api', () => ({ })); const METRICS = { - alert_status: { key: 'alert_status', name: 'Quality Gate' } as Metric, - coverage: { key: 'coverage', name: 'Coverage' } as Metric + alert_status: { key: 'alert_status', name: 'Quality Gate' } as T.Metric, + coverage: { key: 'coverage', name: 'Coverage' } as T.Metric }; it('should display marketing badge params', () => { diff --git a/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgesModal-test.tsx b/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgesModal-test.tsx index 23555a9a631..eedcb7913f0 100644 --- a/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgesModal-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/badges/__tests__/BadgesModal-test.tsx @@ -21,17 +21,16 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import BadgesModal from '../BadgesModal'; import { click } from '../../../../helpers/testUtils'; -import { ShortLivingBranch, BranchType } from '../../../../app/types'; import { isSonarCloud } from '../../../../helpers/system'; jest.mock('../../../../helpers/urls', () => ({ getHostUrl: () => 'host' })); jest.mock('../../../../helpers/system', () => ({ isSonarCloud: jest.fn() })); -const shortBranch: ShortLivingBranch = { +const shortBranch: T.ShortLivingBranch = { isMain: false, mergeBranch: '', name: 'branch-6.6', - type: BranchType.SHORT + type: 'SHORT' }; it('should display the modal after click on sonar cloud', () => { diff --git a/server/sonar-web/src/main/js/apps/overview/components/App.tsx b/server/sonar-web/src/main/js/apps/overview/components/App.tsx index 68c8238c23c..74ec5533243 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/App.tsx @@ -24,7 +24,6 @@ import EmptyOverview from './EmptyOverview'; import OverviewApp from './OverviewApp'; import SonarCloudEmptyOverview from './SonarCloudEmptyOverview'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; -import { Component, BranchLike } from '../../../app/types'; import { isShortLivingBranch } from '../../../helpers/branches'; import { getShortLivingBranchUrl, @@ -36,12 +35,12 @@ import { import { isSonarCloud } from '../../../helpers/system'; interface Props { - branchLike?: BranchLike; - branchLikes: BranchLike[]; - component: Component; + branchLike?: T.BranchLike; + branchLikes: T.BranchLike[]; + component: T.Component; isInProgress?: boolean; isPending?: boolean; - onComponentChange: (changes: Partial) => void; + onComponentChange: (changes: Partial) => void; } export default class App extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx index 9fb9e9a51e2..2e9f7123d60 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx @@ -25,11 +25,10 @@ import DateTooltipFormatter from '../../../components/intl/DateTooltipFormatter' import { getApplicationLeak } from '../../../api/application'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import DateFromNow from '../../../components/intl/DateFromNow'; -import { LightComponent, LongLivingBranch } from '../../../app/types'; interface Props { - branch?: LongLivingBranch; - component: LightComponent; + branch?: T.LongLivingBranch; + component: T.LightComponent; } interface State { diff --git a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx index a5db1cb7e6a..c862b97b0e4 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import { Link } from 'react-router'; import { FormattedMessage } from 'react-intl'; import { translate } from '../../../helpers/l10n'; -import { BranchLike } from '../../../app/types'; import { isBranch, isLongLivingBranch } from '../../../helpers/branches'; import { Alert } from '../../../components/ui/Alert'; interface Props { - branchLike?: BranchLike; - branchLikes: BranchLike[]; + branchLike?: T.BranchLike; + branchLikes: T.BranchLike[]; component: string; showWarning?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx index 7e1c17777dd..fd3615653aa 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/LeakPeriodLegend.tsx @@ -26,10 +26,9 @@ import Tooltip from '../../../components/controls/Tooltip'; import { getPeriodDate, getPeriodLabel } from '../../../helpers/periods'; import { translateWithParameters } from '../../../helpers/l10n'; import { differenceInDays } from '../../../helpers/dates'; -import { Period, PeriodMode } from '../../../app/types'; interface Props { - period: Period; + period: T.Period; } export default class LeakPeriodLegend extends React.PureComponent { @@ -48,7 +47,7 @@ export default class LeakPeriodLegend extends React.PureComponent { return null; } - if (period.mode === PeriodMode.Days) { + if (period.mode === 'days') { return (
    {translateWithParameters('overview.new_code_period_x', leakPeriodLabel)} @@ -64,7 +63,7 @@ export default class LeakPeriodLegend extends React.PureComponent { const formattedDateFunction = (formattedLeakPeriodDate: string) => ( {translateWithParameters( - period.mode === PeriodMode.PreviousAnalysis + period.mode === 'previous_analysis' ? 'overview.previous_analysis_on_x' : 'overview.started_on_x', formattedLeakPeriodDate @@ -90,7 +89,7 @@ export default class LeakPeriodLegend extends React.PureComponent { {fromNow => ( {translateWithParameters( - period.mode === PeriodMode.PreviousAnalysis + period.mode === 'previous_analysis' ? 'overview.previous_analysis_x' : 'overview.started_x', fromNow diff --git a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx index aa82ff5837f..611b3f5087f 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.tsx @@ -48,18 +48,17 @@ import { } from '../../../helpers/branches'; import { fetchMetrics } from '../../../store/rootActions'; import { getMetrics, Store } from '../../../store/rootReducer'; -import { BranchLike, Component, Metric, MeasureEnhanced, Period } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; import '../styles.css'; interface OwnProps { - branchLike?: BranchLike; - component: Component; + branchLike?: T.BranchLike; + component: T.Component; onComponentChange: (changes: {}) => void; } interface StateToProps { - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; } interface DispatchToProps { @@ -74,8 +73,8 @@ interface State { }; historyStartDate?: Date; loading: boolean; - measures: MeasureEnhanced[]; - periods?: Period[]; + measures: T.MeasureEnhanced[]; + periods?: T.Period[]; } export class OverviewApp extends React.PureComponent { @@ -162,7 +161,7 @@ export class OverviewApp extends React.PureComponent { getApplicationLeakPeriod = () => this.state.measures.find(measure => measure.metric.key === 'new_bugs') - ? ({ index: 1 } as Period) + ? ({ index: 1 } as T.Period) : undefined; isEmpty = () => diff --git a/server/sonar-web/src/main/js/apps/overview/components/SonarCloudEmptyOverview.tsx b/server/sonar-web/src/main/js/apps/overview/components/SonarCloudEmptyOverview.tsx index 46ebf59c072..d1be8f47023 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/SonarCloudEmptyOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/SonarCloudEmptyOverview.tsx @@ -22,7 +22,6 @@ import { connect } from 'react-redux'; import { FormattedMessage } from 'react-intl'; import AnalyzeTutorial from '../../tutorials/analyzeProject/AnalyzeTutorial'; import MetaContainer from '../meta/MetaContainer'; -import { BranchLike, Component, CurrentUser } from '../../../app/types'; import { isLongLivingBranch, isBranch, isMainBranch } from '../../../helpers/branches'; import { translate } from '../../../helpers/l10n'; import { isLoggedIn } from '../../../helpers/users'; @@ -31,15 +30,15 @@ import '../../../app/styles/sonarcloud.css'; import { Alert } from '../../../components/ui/Alert'; interface OwnProps { - branchLike?: BranchLike; - branchLikes: BranchLike[]; - component: Component; + branchLike?: T.BranchLike; + branchLikes: T.BranchLike[]; + component: T.Component; hasAnalyses?: boolean; onComponentChange: (changes: {}) => void; } interface StateProps { - currentUser: CurrentUser; + currentUser: T.CurrentUser; } type Props = OwnProps & StateProps; @@ -99,7 +98,7 @@ export function WarningMessage({ branchLike, message }: { - branchLike?: BranchLike; + branchLike?: T.BranchLike; message: string; }) { if (!isBranch(branchLike)) { diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx index 73eb99d9350..afac1a5750e 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { mount, shallow } from 'enzyme'; import App from '../App'; -import { BranchType, LongLivingBranch } from '../../../../app/types'; import { isSonarCloud } from '../../../../helpers/system'; jest.mock('../../../../helpers/system', () => ({ isSonarCloud: jest.fn() })); @@ -66,7 +65,7 @@ it('should render SonarCloudEmptyOverview', () => { }); it('redirects on Code page for files', () => { - const branch: LongLivingBranch = { isMain: false, name: 'b', type: BranchType.LONG }; + const branch: T.LongLivingBranch = { isMain: false, name: 'b', type: 'LONG' }; const newComponent = { ...component, breadcrumbs: [ diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx index 6fd204472ab..593c512198b 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.tsx @@ -20,9 +20,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import EmptyOverview from '../EmptyOverview'; -import { BranchType } from '../../../../app/types'; -const branch = { isMain: true, name: 'b', type: BranchType.LONG }; +const branch = { isMain: true, name: 'b', type: 'LONG' }; it('renders', () => { expect( diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx index 77a2ddc8cca..f4a39fd5f13 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/LeakPeriodLegend-test.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import LeakPeriodLegend from '../LeakPeriodLegend'; import { differenceInDays } from '../../../../helpers/dates'; -import { Period, PeriodMode } from '../../../../app/types'; jest.mock('../../../../helpers/dates', () => { const dates = require.requireActual('../../../../helpers/dates'); @@ -34,7 +33,7 @@ it('10 days', () => { getWrapper({ date: '2013-09-22T00:00:00+0200', index: 0, - mode: PeriodMode.Days, + mode: 'days', parameter: '10' }) ).toMatchSnapshot(); @@ -45,7 +44,7 @@ it('date', () => { getWrapper({ date: '2013-09-22T00:00:00+0200', index: 0, - mode: PeriodMode.Date, + mode: 'date', parameter: '2013-01-01' }) ).toMatchSnapshot(); @@ -56,7 +55,7 @@ it('version', () => { getWrapper({ date: '2013-09-22T00:00:00+0200', index: 0, - mode: PeriodMode.Version, + mode: 'version', parameter: '0.1' }).find('.overview-legend') ).toMatchSnapshot(); @@ -67,7 +66,7 @@ it('previous_version', () => { getWrapper({ date: '2013-09-22T00:00:00+0200', index: 0, - mode: PeriodMode.PreviousVersion + mode: 'previous_version' }).find('.overview-legend') ).toMatchSnapshot(); }); @@ -77,7 +76,7 @@ it('previous_analysis', () => { getWrapper({ date: '2013-09-22T00:00:00+0200', index: 0, - mode: PeriodMode.PreviousAnalysis + mode: 'previous_analysis' }).find('.overview-legend') ).toMatchSnapshot(); }); @@ -88,12 +87,12 @@ it('should render a more precise date', () => { getWrapper({ date: '2018-08-17T00:00:00+0200', index: 0, - mode: PeriodMode.PreviousVersion + mode: 'previous_version' }) ).toMatchSnapshot(); }); -function getWrapper(period: Period) { +function getWrapper(period: T.Period) { return shallow(, { context: { intl: { formatDate: (date: string) => 'formatted.' + date } diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/SonarCloudEmptyOverview-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/SonarCloudEmptyOverview-test.tsx index 278fca079d1..f971b2dbe9f 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/SonarCloudEmptyOverview-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/SonarCloudEmptyOverview-test.tsx @@ -20,9 +20,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { SonarCloudEmptyOverview, WarningMessage } from '../SonarCloudEmptyOverview'; -import { BranchType } from '../../../../app/types'; -const branch = { isMain: true, name: 'b', type: BranchType.LONG }; +const branch = { isMain: true, name: 'b', type: 'LONG' }; const component = { key: 'foo', diff --git a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx index 1de1bc02ba4..849706cdc88 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx +++ b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.tsx @@ -23,22 +23,21 @@ import Analysis from './Analysis'; import { getProjectActivity } from '../../../api/projectActivity'; import PreviewGraph from '../../../components/preview-graph/PreviewGraph'; import { translate } from '../../../helpers/l10n'; -import { Metric, Component, BranchLike, Analysis as AnalysisType } from '../../../app/types'; import { getBranchLikeQuery, isSameBranchLike } from '../../../helpers/branches'; import { getActivityUrl } from '../../../helpers/urls'; interface Props { - branchLike?: BranchLike; - component: Component; + branchLike?: T.BranchLike; + component: T.Component; history?: { [metric: string]: Array<{ date: Date; value?: string }>; }; - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; qualifier: string; } interface State { - analyses: AnalysisType[]; + analyses: T.Analysis[]; loading: boolean; } @@ -99,7 +98,7 @@ export default class AnalysesList extends React.PureComponent { ); }; - renderList(analyses: AnalysisType[]) { + renderList(analyses: T.Analysis[]) { if (!analyses.length) { return

    {translate('no_results')}

    ; } diff --git a/server/sonar-web/src/main/js/apps/overview/events/Analysis.tsx b/server/sonar-web/src/main/js/apps/overview/events/Analysis.tsx index aa00c270b34..615bccad2de 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/Analysis.tsx +++ b/server/sonar-web/src/main/js/apps/overview/events/Analysis.tsx @@ -21,11 +21,10 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import Event from './Event'; import DateTooltipFormatter from '../../../components/intl/DateTooltipFormatter'; -import { Analysis as AnalysisType } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - analysis: AnalysisType; + analysis: T.Analysis; qualifier: string; } diff --git a/server/sonar-web/src/main/js/apps/overview/events/Event.tsx b/server/sonar-web/src/main/js/apps/overview/events/Event.tsx index b7fc148533a..262ff7c78a9 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/Event.tsx +++ b/server/sonar-web/src/main/js/apps/overview/events/Event.tsx @@ -19,14 +19,13 @@ */ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; -import { AnalysisEvent } from '../../../app/types'; import { isRichQualityGateEvent } from '../../projectActivity/components/RichQualityGateEventInner'; import Level from '../../../components/ui/Level'; import { translate } from '../../../helpers/l10n'; import { isDefinitionChangeEvent } from '../../projectActivity/components/DefinitionChangeEventInner'; interface Props { - event: AnalysisEvent; + event: T.AnalysisEvent; } export default function Event({ event }: Props) { diff --git a/server/sonar-web/src/main/js/apps/overview/main/BugsAndVulnerabilities.tsx b/server/sonar-web/src/main/js/apps/overview/main/BugsAndVulnerabilities.tsx index 146158a5b61..3c7de94b878 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/BugsAndVulnerabilities.tsx +++ b/server/sonar-web/src/main/js/apps/overview/main/BugsAndVulnerabilities.tsx @@ -29,7 +29,6 @@ import { getMetricName } from '../utils'; import { getComponentDrilldownUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; import { isLongLivingBranch } from '../../../helpers/branches'; -import { IssueType } from '../../../app/types'; export class BugsAndVulnerabilities extends React.PureComponent { renderHeader() { @@ -82,9 +81,7 @@ export class BugsAndVulnerabilities extends React.PureComponent {
    - - {this.props.renderIssues('new_bugs', IssueType.Bug)} - + {this.props.renderIssues('new_bugs', 'BUG')} {this.props.renderRating('new_reliability_rating')}
    @@ -95,7 +92,7 @@ export class BugsAndVulnerabilities extends React.PureComponent {
    - {this.props.renderIssues('new_vulnerabilities', IssueType.Vulnerability)} + {this.props.renderIssues('new_vulnerabilities', 'VULNERABILITY')} {this.props.renderRating('new_security_rating')}
    @@ -115,7 +112,7 @@ export class BugsAndVulnerabilities extends React.PureComponent {
    - {this.props.renderIssues('bugs', IssueType.Bug)} + {this.props.renderIssues('bugs', 'BUG')} {this.props.renderRating('reliability_rating')}
    @@ -126,7 +123,7 @@ export class BugsAndVulnerabilities extends React.PureComponent {
    - {this.props.renderIssues('vulnerabilities', IssueType.Vulnerability)} + {this.props.renderIssues('vulnerabilities', 'VULNERABILITY')} {this.props.renderRating('security_rating')}
    diff --git a/server/sonar-web/src/main/js/apps/overview/main/CodeSmells.tsx b/server/sonar-web/src/main/js/apps/overview/main/CodeSmells.tsx index c49704368f0..f5adea6c517 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/CodeSmells.tsx +++ b/server/sonar-web/src/main/js/apps/overview/main/CodeSmells.tsx @@ -25,7 +25,6 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; import CodeSmellIcon from '../../../components/icons-components/CodeSmellIcon'; import DrilldownLink from '../../../components/shared/DrilldownLink'; -import { IssueType } from '../../../app/types'; export class CodeSmells extends React.PureComponent { renderHeader() { @@ -85,7 +84,7 @@ export class CodeSmells extends React.PureComponent {
    - {this.props.renderIssues('new_code_smells', IssueType.CodeSmell)} + {this.props.renderIssues('new_code_smells', 'CODE_SMELL')}
    @@ -115,7 +114,7 @@ export class CodeSmells extends React.PureComponent {
    - {this.props.renderIssues('code_smells', IssueType.CodeSmell)} + {this.props.renderIssues('code_smells', 'CODE_SMELL')}
    diff --git a/server/sonar-web/src/main/js/apps/overview/main/enhance.tsx b/server/sonar-web/src/main/js/apps/overview/main/enhance.tsx index d583ae979d8..3bad649a3ea 100644 --- a/server/sonar-web/src/main/js/apps/overview/main/enhance.tsx +++ b/server/sonar-web/src/main/js/apps/overview/main/enhance.tsx @@ -39,14 +39,13 @@ import { getComponentIssuesUrl, getMeasureHistoryUrl } from '../../../helpers/urls'; -import { Component, BranchLike, MeasureEnhanced, Period } from '../../../app/types'; import { getBranchLikeQuery } from '../../../helpers/branches'; export interface EnhanceProps { - branchLike?: BranchLike; - component: Component; - measures: MeasureEnhanced[]; - leakPeriod?: Period; + branchLike?: T.BranchLike; + component: T.Component; + measures: T.MeasureEnhanced[]; + leakPeriod?: T.Period; history?: { [metric: string]: Array<{ date: Date; value?: string }>; }; @@ -54,11 +53,11 @@ export interface EnhanceProps { } export interface ComposedProps extends EnhanceProps { - getValue: (measure: MeasureEnhanced) => string | undefined; + getValue: (measure: T.MeasureEnhanced) => string | undefined; renderHeader: (domain: string, label: string) => React.ReactNode; renderMeasure: (metricKey: string) => React.ReactNode; renderRating: (metricKey: string) => React.ReactNode; - renderIssues: (metric: string, type: string) => React.ReactNode; + renderIssues: (metric: string, type: T.IssueType) => React.ReactNode; renderHistoryLink: (metricKey: string) => React.ReactNode; renderTimeline: (metricKey: string, range: string, children?: React.ReactNode) => React.ReactNode; } @@ -67,7 +66,7 @@ export default function enhance(ComposedComponent: React.ComponentType { static displayName = `enhance(${ComposedComponent.displayName})}`; - getValue = (measure: MeasureEnhanced) => { + getValue = (measure: T.MeasureEnhanced) => { const { leakPeriod } = this.props; if (!measure) { return '0'; diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx index 80fe882f3d9..f4a9b938b37 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaContainer.tsx @@ -29,15 +29,6 @@ import MetaSize from './MetaSize'; import MetaTags from './MetaTags'; import BadgesModal from '../badges/BadgesModal'; import AnalysesList from '../events/AnalysesList'; -import { - Visibility, - Component, - Metric, - BranchLike, - CurrentUser, - Organization, - MeasureEnhanced -} from '../../../app/types'; import { translate } from '../../../helpers/l10n'; import { hasPrivateAccess } from '../../../helpers/organizations'; import { @@ -49,19 +40,19 @@ import { import PrivacyBadgeContainer from '../../../components/common/PrivacyBadgeContainer'; interface StateToProps { - currentUser: CurrentUser; - organization?: Organization; - userOrganizations: Organization[]; + currentUser: T.CurrentUser; + organization?: T.Organization; + userOrganizations: T.Organization[]; } interface OwnProps { - branchLike?: BranchLike; - component: Component; + branchLike?: T.BranchLike; + component: T.Component; history?: { [metric: string]: Array<{ date: Date; value?: string }>; }; - measures?: MeasureEnhanced[]; - metrics?: { [key: string]: Metric }; + measures?: T.MeasureEnhanced[]; + metrics?: { [key: string]: T.Metric }; onComponentChange: (changes: {}) => void; } @@ -113,7 +104,7 @@ export class Meta extends React.PureComponent { const isProject = qualifier === 'TRK'; const isApp = qualifier === 'APP'; - const isPrivate = visibility === Visibility.Private; + const isPrivate = visibility === 'private'; return (
    diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx index 85eeaf8ca81..a1e1e6bad13 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx @@ -19,11 +19,10 @@ */ import * as React from 'react'; import { getLinkName } from '../../projectLinks/utils'; -import { ProjectLink } from '../../../app/types'; import ProjectLinkIcon from '../../../components/icons-components/ProjectLinkIcon'; interface Props { - link: ProjectLink; + link: T.ProjectLink; } export default function MetaLink({ link }: Props) { diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaLinks.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaLinks.tsx index 78d87b6f88b..0a8251dfb27 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaLinks.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaLinks.tsx @@ -21,15 +21,14 @@ import * as React from 'react'; import MetaLink from './MetaLink'; import { orderLinks } from '../../projectLinks/utils'; import { getProjectLinks } from '../../../api/projectLinks'; -import { LightComponent, ProjectLink } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - component: LightComponent; + component: T.LightComponent; } interface State { - links?: ProjectLink[]; + links?: T.ProjectLink[]; } export default class MetaLinks extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx index 06452143c33..406ffcee656 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx @@ -26,16 +26,15 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getQualityProfileUrl } from '../../../helpers/urls'; import { searchRules } from '../../../api/rules'; import { getLanguages, Store } from '../../../store/rootReducer'; -import { ComponentQualityProfile, Languages } from '../../../app/types'; interface StateProps { - languages: Languages; + languages: T.Languages; } interface OwnProps { headerClassName?: string; organization?: string; - profiles: ComponentQualityProfile[]; + profiles: T.ComponentQualityProfile[]; } interface State { @@ -90,7 +89,7 @@ class MetaQualityProfiles extends React.PureComponent { - renderLoC = (ncloc?: MeasureEnhanced) => ( + renderLoC = (ncloc?: T.MeasureEnhanced) => (
    void; } diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx index 91cba327f51..7cf6741b1b9 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGate.tsx @@ -23,17 +23,16 @@ import ApplicationQualityGateProject from './ApplicationQualityGateProject'; import Level from '../../../components/ui/Level'; import { getApplicationQualityGate, ApplicationProject } from '../../../api/quality-gates'; import { translate } from '../../../helpers/l10n'; -import { LightComponent, Metric, LongLivingBranch } from '../../../app/types'; import DocTooltip from '../../../components/docs/DocTooltip'; interface Props { - branch?: LongLivingBranch; - component: LightComponent; + branch?: T.LongLivingBranch; + component: T.LightComponent; } type State = { loading: boolean; - metrics?: { [key: string]: Metric }; + metrics?: { [key: string]: T.Metric }; projects?: ApplicationProject[]; status?: string; }; diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGateProject.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGateProject.tsx index 620a839fed0..fe5df8f34e6 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGateProject.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/ApplicationQualityGateProject.tsx @@ -24,11 +24,10 @@ import { getLocalizedMetricName, translate } from '../../../helpers/l10n'; import { formatMeasure, isDiffMetric } from '../../../helpers/measures'; import { getProjectUrl } from '../../../helpers/urls'; import './ApplicationQualityGateProject.css'; -import { Metric } from '../../../app/types'; import { ApplicationProject, ConditionAnalysis } from '../../../api/quality-gates'; interface Props { - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; project: ApplicationProject; } diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx index b49ea0000a2..47370714c3e 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGate.tsx @@ -24,13 +24,12 @@ import { translate } from '../../../helpers/l10n'; import Level from '../../../components/ui/Level'; import HelpTooltip from '../../../components/controls/HelpTooltip'; import DocTooltip from '../../../components/docs/DocTooltip'; -import { Component, BranchLike, MeasureEnhanced } from '../../../app/types'; import { Alert } from '../../../components/ui/Alert'; interface Props { - branchLike?: BranchLike; - component: Pick; - measures: MeasureEnhanced[]; + branchLike?: T.BranchLike; + component: Pick; + measures: T.MeasureEnhanced[]; } export default function QualityGate({ branchLike, component, measures }: Props) { @@ -89,6 +88,6 @@ function parseQualityGateDetails(rawDetails: string) { return JSON.parse(rawDetails); } -function isProject(component: Pick) { +function isProject(component: Pick) { return component.qualifier === 'TRK'; } diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx index af96ccf0a1d..627bf89d57d 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateCondition.tsx @@ -28,11 +28,10 @@ import { getPeriodValue, isDiffMetric, formatMeasure } from '../../../helpers/me import { translate } from '../../../helpers/l10n'; import { getComponentIssuesUrl } from '../../../helpers/urls'; import { getBranchLikeQuery } from '../../../helpers/branches'; -import { IssueType, BranchLike, Component } from '../../../app/types'; interface Props { - branchLike?: BranchLike; - component: Pick; + branchLike?: T.BranchLike; + component: Pick; condition: QualityGateStatusConditionEnhanced; } @@ -60,7 +59,7 @@ export default class QualityGateCondition extends React.PureComponent { }; getUrlForCodeSmells(sinceLeakPeriod: boolean) { - return this.getIssuesUrl(sinceLeakPeriod, { types: IssueType.CodeSmell }); + return this.getIssuesUrl(sinceLeakPeriod, { types: 'CODE_SMELL' }); } getUrlForBugsOrVulnerabilities(type: string, sinceLeakPeriod: boolean) { @@ -81,7 +80,7 @@ export default class QualityGateCondition extends React.PureComponent { } getUrlForType(type: string, sinceLeakPeriod: boolean) { - return type === IssueType.CodeSmell + return type === 'CODE_SMELL' ? this.getUrlForCodeSmells(sinceLeakPeriod) : this.getUrlForBugsOrVulnerabilities(type, sinceLeakPeriod); } @@ -98,12 +97,12 @@ export default class QualityGateCondition extends React.PureComponent { const metricKey = condition.measure.metric.key; const RATING_METRICS_MAPPING: { [metric: string]: [string, boolean] } = { - reliability_rating: [IssueType.Bug, false], - new_reliability_rating: [IssueType.Bug, true], - security_rating: [IssueType.Vulnerability, false], - new_security_rating: [IssueType.Vulnerability, true], - sqale_rating: [IssueType.CodeSmell, false], - new_maintainability_rating: [IssueType.CodeSmell, true] + reliability_rating: ['BUG', false], + new_reliability_rating: ['BUG', true], + security_rating: ['VULNERABILITY', false], + new_security_rating: ['VULNERABILITY', true], + sqale_rating: ['CODE_SMELL', false], + new_maintainability_rating: ['CODE_SMELL', true] }; return RATING_METRICS_MAPPING[metricKey] ? ( diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx index 32762196d54..5f4118e85bd 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/QualityGateConditions.tsx @@ -24,13 +24,12 @@ import { QualityGateStatusCondition, QualityGateStatusConditionEnhanced } from ' import { getMeasuresAndMeta } from '../../../api/measures'; import { enhanceMeasuresWithMetrics } from '../../../helpers/measures'; import { isSameBranchLike, getBranchLikeQuery } from '../../../helpers/branches'; -import { BranchLike, Component, MeasureEnhanced } from '../../../app/types'; const LEVEL_ORDER = ['ERROR', 'WARN']; interface Props { - branchLike?: BranchLike; - component: Pick; + branchLike?: T.BranchLike; + component: Pick; conditions: QualityGateStatusCondition[]; } @@ -126,7 +125,7 @@ export default class QualityGateConditions extends React.PureComponent { const measure = measures.find(measure => measure.metric.key === condition.metric)!; diff --git a/server/sonar-web/src/main/js/apps/overview/utils.ts b/server/sonar-web/src/main/js/apps/overview/utils.ts index cb0923876ef..7e1b8f2eb74 100644 --- a/server/sonar-web/src/main/js/apps/overview/utils.ts +++ b/server/sonar-web/src/main/js/apps/overview/utils.ts @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { MeasureEnhanced } from '../../app/types'; import { translate } from '../../helpers/l10n'; export interface QualityGateStatusCondition { @@ -32,7 +31,7 @@ export interface QualityGateStatusCondition { // long name to not mix with Condition from /app/types.ts export interface QualityGateStatusConditionEnhanced extends QualityGateStatusCondition { - measure: MeasureEnhanced; + measure: T.MeasureEnhanced; } export const METRICS = [ diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.tsx index 771e50e4292..ce073542841 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/ActionsCell.tsx @@ -27,7 +27,6 @@ import { deletePermissionTemplate, updatePermissionTemplate } from '../../../api/permissions'; -import { PermissionTemplate } from '../../../app/types'; import ActionsDropdown, { ActionsDropdownItem } from '../../../components/controls/ActionsDropdown'; import QualifierIcon from '../../../components/icons-components/QualifierIcon'; import { translate } from '../../../helpers/l10n'; @@ -35,7 +34,7 @@ import { translate } from '../../../helpers/l10n'; export interface Props { fromDetails?: boolean; organization?: { isDefault?: boolean; key: string }; - permissionTemplate: PermissionTemplate; + permissionTemplate: T.PermissionTemplate; refresh: () => void; topQualifiers: string[]; } diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/DeleteForm.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/DeleteForm.tsx index b89b76e1c31..85dd456fa94 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/DeleteForm.tsx +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/DeleteForm.tsx @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { PermissionTemplate } from '../../../app/types'; import SimpleModal from '../../../components/controls/SimpleModal'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import { SubmitButton, ResetButtonLink } from '../../../components/ui/buttons'; @@ -27,7 +26,7 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; interface Props { onClose: () => void; onSubmit: () => Promise; - permissionTemplate: PermissionTemplate; + permissionTemplate: T.PermissionTemplate; } export default function DeleteForm({ onClose, onSubmit, permissionTemplate: t }: Props) { diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx b/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx index 0282227203b..4315b32a2b0 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/global/components/AllHoldersList.tsx @@ -22,13 +22,6 @@ import { connect } from 'react-redux'; import SearchForm from '../../shared/components/SearchForm'; import HoldersList from '../../shared/components/HoldersList'; import ListFooter from '../../../../components/controls/ListFooter'; -import { - AppState, - Organization, - Paging, - PermissionGroup, - PermissionUser -} from '../../../../app/types'; import { PERMISSIONS_ORDER_GLOBAL, convertToPermissionDefinitions, @@ -37,32 +30,32 @@ import { import { Store, getAppState } from '../../../../store/rootReducer'; interface StateProps { - appState: Pick; + appState: Pick; } interface OwnProps { filter: string; grantPermissionToGroup: (groupName: string, permission: string) => Promise; grantPermissionToUser: (login: string, permission: string) => Promise; - groups: PermissionGroup[]; - groupsPaging?: Paging; + groups: T.PermissionGroup[]; + groupsPaging?: T.Paging; loadHolders: () => void; loading?: boolean; onLoadMore: () => void; onFilter: (filter: string) => void; onSearch: (query: string) => void; - organization?: Organization; + organization?: T.Organization; query: string; revokePermissionFromGroup: (groupName: string, permission: string) => Promise; revokePermissionFromUser: (login: string, permission: string) => Promise; - users: PermissionUser[]; - usersPaging?: Paging; + users: T.PermissionUser[]; + usersPaging?: T.Paging; } type Props = StateProps & OwnProps; export class AllHoldersList extends React.PureComponent { - handleToggleUser = (user: PermissionUser, permission: string) => { + handleToggleUser = (user: T.PermissionUser, permission: string) => { const hasPermission = user.permissions.includes(permission); if (hasPermission) { return this.props.revokePermissionFromUser(user.login, permission); @@ -71,7 +64,7 @@ export class AllHoldersList extends React.PureComponent { } }; - handleToggleGroup = (group: PermissionGroup, permission: string) => { + handleToggleGroup = (group: T.PermissionGroup, permission: string) => { const hasPermission = group.permissions.includes(permission); if (hasPermission) { diff --git a/server/sonar-web/src/main/js/apps/permissions/global/components/App.tsx b/server/sonar-web/src/main/js/apps/permissions/global/components/App.tsx index f34942f8cc2..fe32df6b04e 100644 --- a/server/sonar-web/src/main/js/apps/permissions/global/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/global/components/App.tsx @@ -25,22 +25,21 @@ import AllHoldersList from './AllHoldersList'; import * as api from '../../../../api/permissions'; import Suggestions from '../../../../app/components/embed-docs-modal/Suggestions'; import { translate } from '../../../../helpers/l10n'; -import { Organization, Paging, PermissionGroup, PermissionUser } from '../../../../app/types'; import forSingleOrganization from '../../../organizations/forSingleOrganization'; import '../../styles.css'; interface Props { - organization?: Organization; + organization?: T.Organization; } interface State { filter: 'all' | 'groups' | 'users'; - groups: PermissionGroup[]; - groupsPaging?: Paging; + groups: T.PermissionGroup[]; + groupsPaging?: T.Paging; loading: boolean; query: string; - users: PermissionUser[]; - usersPaging?: Paging; + users: T.PermissionUser[]; + usersPaging?: T.Paging; } export class App extends React.PureComponent { @@ -70,7 +69,7 @@ export class App extends React.PureComponent { const { organization } = this.props; const { filter, query } = this.state; - const getUsers: Promise<{ paging?: Paging; users: PermissionUser[] }> = + const getUsers: Promise<{ paging?: T.Paging; users: T.PermissionUser[] }> = filter !== 'groups' ? api.getGlobalPermissionsUsers({ q: query || undefined, @@ -79,7 +78,7 @@ export class App extends React.PureComponent { }) : Promise.resolve({ paging: undefined, users: [] }); - const getGroups: Promise<{ paging?: Paging; groups: PermissionGroup[] }> = + const getGroups: Promise<{ paging?: T.Paging; groups: T.PermissionGroup[] }> = filter !== 'users' ? api.getGlobalPermissionsGroups({ q: query || undefined, @@ -133,7 +132,7 @@ export class App extends React.PureComponent { this.setState({ query }, this.loadHolders); }; - addPermissionToGroup = (groups: PermissionGroup[], group: string, permission: string) => { + addPermissionToGroup = (groups: T.PermissionGroup[], group: string, permission: string) => { return groups.map( candidate => candidate.name === group @@ -142,7 +141,7 @@ export class App extends React.PureComponent { ); }; - addPermissionToUser = (users: PermissionUser[], user: string, permission: string) => { + addPermissionToUser = (users: T.PermissionUser[], user: string, permission: string) => { return users.map( candidate => candidate.login === user @@ -151,7 +150,7 @@ export class App extends React.PureComponent { ); }; - removePermissionFromGroup = (groups: PermissionGroup[], group: string, permission: string) => { + removePermissionFromGroup = (groups: T.PermissionGroup[], group: string, permission: string) => { return groups.map( candidate => candidate.name === group @@ -160,7 +159,7 @@ export class App extends React.PureComponent { ); }; - removePermissionFromUser = (users: PermissionUser[], user: string, permission: string) => { + removePermissionFromUser = (users: T.PermissionUser[], user: string, permission: string) => { return users.map( candidate => candidate.login === user diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.tsx b/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.tsx index 27cd441636e..52db4021166 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/AllHoldersList.tsx @@ -23,21 +23,14 @@ import SearchForm from '../../shared/components/SearchForm'; import HoldersList from '../../shared/components/HoldersList'; import ListFooter from '../../../../components/controls/ListFooter'; import { PERMISSIONS_ORDER_BY_QUALIFIER, convertToPermissionDefinitions } from '../../utils'; -import { - Component, - Paging, - PermissionGroup, - PermissionUser, - Visibility -} from '../../../../app/types'; interface Props { - component: Component; + component: T.Component; filter: string; grantPermissionToGroup: (group: string, permission: string) => Promise; grantPermissionToUser: (user: string, permission: string) => Promise; - groups: PermissionGroup[]; - groupsPaging?: Paging; + groups: T.PermissionGroup[]; + groupsPaging?: T.Paging; onLoadMore: () => void; onFilterChange: (filter: string) => void; onPermissionSelect: (permissions?: string) => void; @@ -46,13 +39,13 @@ interface Props { revokePermissionFromGroup: (group: string, permission: string) => Promise; revokePermissionFromUser: (user: string, permission: string) => Promise; selectedPermission?: string; - users: PermissionUser[]; - usersPaging?: Paging; - visibility?: Visibility; + users: T.PermissionUser[]; + usersPaging?: T.Paging; + visibility?: T.Visibility; } export default class AllHoldersList extends React.PureComponent { - handleToggleUser = (user: PermissionUser, permission: string) => { + handleToggleUser = (user: T.PermissionUser, permission: string) => { const hasPermission = user.permissions.includes(permission); if (hasPermission) { @@ -62,7 +55,7 @@ export default class AllHoldersList extends React.PureComponent { } }; - handleToggleGroup = (group: PermissionGroup, permission: string) => { + handleToggleGroup = (group: T.PermissionGroup, permission: string) => { const hasPermission = group.permissions.includes(permission); if (hasPermission) { @@ -79,7 +72,7 @@ export default class AllHoldersList extends React.PureComponent { render() { const { filter, groups, groupsPaging, users, usersPaging } = this.props; let order = PERMISSIONS_ORDER_BY_QUALIFIER[this.props.component.qualifier]; - if (this.props.visibility === Visibility.Public) { + if (this.props.visibility === 'public') { order = without(order, 'user', 'codeviewer'); } const permissions = convertToPermissionDefinitions(order, 'projects_role'); diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/App.tsx b/server/sonar-web/src/main/js/apps/permissions/project/components/App.tsx index 9e9f7678116..0f82247d151 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/App.tsx @@ -27,30 +27,23 @@ import UpgradeOrganizationBox from '../../../../components/common/UpgradeOrganiz import VisibilitySelector from '../../../../components/common/VisibilitySelector'; import * as api from '../../../../api/permissions'; import { translate } from '../../../../helpers/l10n'; -import { - Component, - Paging, - PermissionGroup, - PermissionUser, - Visibility -} from '../../../../app/types'; import '../../styles.css'; interface Props { - component: Component; - onComponentChange: (changes: Partial) => void; + component: T.Component; + onComponentChange: (changes: Partial) => void; } interface State { disclaimer: boolean; filter: string; - groups: PermissionGroup[]; - groupsPaging?: Paging; + groups: T.PermissionGroup[]; + groupsPaging?: T.Paging; loading: boolean; query: string; selectedPermission?: string; - users: PermissionUser[]; - usersPaging?: Paging; + users: T.PermissionUser[]; + usersPaging?: T.Paging; } export default class App extends React.PureComponent { @@ -87,7 +80,7 @@ export default class App extends React.PureComponent { const { component } = this.props; const { filter, query, selectedPermission } = this.state; - const getUsers: Promise<{ paging?: Paging; users: PermissionUser[] }> = + const getUsers: Promise<{ paging?: T.Paging; users: T.PermissionUser[] }> = filter !== 'groups' ? api.getPermissionsUsersForComponent({ projectKey: component.key, @@ -98,7 +91,7 @@ export default class App extends React.PureComponent { }) : Promise.resolve({ paging: undefined, users: [] }); - const getGroups: Promise<{ paging?: Paging; groups: PermissionGroup[] }> = + const getGroups: Promise<{ paging?: T.Paging; groups: T.PermissionGroup[] }> = filter !== 'users' ? api.getPermissionsGroupsForComponent({ projectKey: component.key, @@ -307,7 +300,7 @@ export default class App extends React.PureComponent { }; handleVisibilityChange = (visibility: string) => { - if (visibility === Visibility.Public) { + if (visibility === 'public') { this.openDisclaimer(); } else { this.turnProjectToPrivate(); @@ -315,28 +308,28 @@ export default class App extends React.PureComponent { }; turnProjectToPublic = () => { - this.props.onComponentChange({ visibility: Visibility.Public }); - api.changeProjectVisibility(this.props.component.key, Visibility.Public).then( + this.props.onComponentChange({ visibility: 'public' }); + api.changeProjectVisibility(this.props.component.key, 'public').then( () => { this.loadHolders(); }, () => { this.props.onComponentChange({ - visibility: Visibility.Private + visibility: 'private' }); } ); }; turnProjectToPrivate = () => { - this.props.onComponentChange({ visibility: Visibility.Private }); - api.changeProjectVisibility(this.props.component.key, Visibility.Private).then( + this.props.onComponentChange({ visibility: 'private' }); + api.changeProjectVisibility(this.props.component.key, 'private').then( () => { this.loadHolders(); }, () => { this.props.onComponentChange({ - visibility: Visibility.Public + visibility: 'public' }); } ); diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/ApplyTemplate.tsx b/server/sonar-web/src/main/js/apps/permissions/project/components/ApplyTemplate.tsx index 37cbecb1251..c90c4509123 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/ApplyTemplate.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/ApplyTemplate.tsx @@ -19,7 +19,6 @@ */ import * as React from 'react'; import { getPermissionTemplates, applyTemplateToProject } from '../../../../api/permissions'; -import { PermissionTemplate } from '../../../../app/types'; import DeferredSpinner from '../../../../components/common/DeferredSpinner'; import SimpleModal from '../../../../components/controls/SimpleModal'; import Select from '../../../../components/controls/Select'; @@ -38,7 +37,7 @@ interface State { done: boolean; loading: boolean; permissionTemplate?: string; - permissionTemplates?: PermissionTemplate[]; + permissionTemplates?: T.PermissionTemplate[]; } export default class ApplyTemplate extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx index e7c6947c1a9..53fa13680f6 100644 --- a/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/project/components/PageHeader.tsx @@ -19,12 +19,11 @@ */ import * as React from 'react'; import ApplyTemplate from './ApplyTemplate'; -import { Component } from '../../../../app/types'; import { Button } from '../../../../components/ui/buttons'; import { translate } from '../../../../helpers/l10n'; interface Props { - component: Component; + component: T.Component; loadHolders: () => void; loading: boolean; } diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/GroupHolder.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/GroupHolder.tsx index 54b3c93a865..540d238bbbc 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/GroupHolder.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/GroupHolder.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import { without } from 'lodash'; import PermissionCell from './PermissionCell'; import GroupIcon from '../../../../components/icons-components/GroupIcon'; -import { PermissionDefinitions, PermissionGroup } from '../../../../app/types'; import { isPermissionDefinitionGroup } from '../../utils'; interface Props { - group: PermissionGroup; - onToggle: (group: PermissionGroup, permission: string) => Promise; - permissions: PermissionDefinitions; + group: T.PermissionGroup; + onToggle: (group: T.PermissionGroup, permission: string) => Promise; + permissions: T.PermissionDefinitions; selectedPermission?: string; } diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.tsx index c90341d2510..fe9b4c898e3 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/HoldersList.tsx @@ -23,21 +23,20 @@ import UserHolder from './UserHolder'; import GroupHolder from './GroupHolder'; import PermissionHeader from './PermissionHeader'; import { translate } from '../../../../helpers/l10n'; -import { PermissionGroup, PermissionUser, PermissionDefinitions } from '../../../../app/types'; import { isPermissionDefinitionGroup } from '../../utils'; interface Props { filter?: string; - groups: PermissionGroup[]; + groups: T.PermissionGroup[]; loading?: boolean; onSelectPermission?: (permission: string) => void; - onToggleGroup: (group: PermissionGroup, permission: string) => Promise; - onToggleUser: (user: PermissionUser, permission: string) => Promise; - permissions: PermissionDefinitions; + onToggleGroup: (group: T.PermissionGroup, permission: string) => Promise; + onToggleUser: (user: T.PermissionUser, permission: string) => Promise; + permissions: T.PermissionDefinitions; query?: string; selectedPermission?: string; showPublicProjectsWarning?: boolean; - users: PermissionUser[]; + users: T.PermissionUser[]; } interface State { @@ -51,11 +50,11 @@ export default class HoldersList extends React.PureComponent { } } - isPermissionUser(item: PermissionGroup | PermissionUser): item is PermissionUser { - return (item as PermissionUser).login !== undefined; + isPermissionUser(item: T.PermissionGroup | T.PermissionUser): item is T.PermissionUser { + return (item as T.PermissionUser).login !== undefined; } - handleGroupToggle = (group: PermissionGroup, permission: string) => { + handleGroupToggle = (group: T.PermissionGroup, permission: string) => { const key = group.id || group.name; if (this.state.initialPermissionsCount[key] === undefined) { this.setState(state => ({ @@ -68,7 +67,7 @@ export default class HoldersList extends React.PureComponent { return this.props.onToggleGroup(group, permission); }; - handleUserToggle = (user: PermissionUser, permission: string) => { + handleUserToggle = (user: T.PermissionUser, permission: string) => { if (this.state.initialPermissionsCount[user.login] === undefined) { this.setState(state => ({ initialPermissionsCount: { @@ -80,7 +79,7 @@ export default class HoldersList extends React.PureComponent { return this.props.onToggleUser(user, permission); }; - getItemInitialPermissionsCount = (item: PermissionGroup | PermissionUser) => { + getItemInitialPermissionsCount = (item: T.PermissionGroup | T.PermissionUser) => { const key = this.isPermissionUser(item) ? item.login : item.id || item.name; return this.state.initialPermissionsCount[key] !== undefined ? this.state.initialPermissionsCount[key] @@ -96,7 +95,7 @@ export default class HoldersList extends React.PureComponent { ); } - renderItem(item: PermissionUser | PermissionGroup, permissions: PermissionDefinitions) { + renderItem(item: T.PermissionUser | T.PermissionGroup, permissions: T.PermissionDefinitions) { return this.isPermissionUser(item) ? ( void; - permission: PermissionDefinition | PermissionDefinitionGroup; - permissionItem: PermissionGroup | PermissionUser; + permission: T.PermissionDefinition | T.PermissionDefinitionGroup; + permissionItem: T.PermissionGroup | T.PermissionUser; selectedPermission?: string; } diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx index 69e2a082b75..b5d9d890005 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/PermissionHeader.tsx @@ -22,14 +22,13 @@ import * as classNames from 'classnames'; import HelpTooltip from '../../../../components/controls/HelpTooltip'; import InstanceMessage from '../../../../components/common/InstanceMessage'; import { translate, translateWithParameters } from '../../../../helpers/l10n'; -import { PermissionDefinition, PermissionDefinitionGroup } from '../../../../app/types'; import { isPermissionDefinitionGroup } from '../../utils'; import Tooltip from '../../../../components/controls/Tooltip'; import { Alert } from '../../../../components/ui/Alert'; interface Props { onSelectPermission?: (permission: string) => void; - permission: PermissionDefinition | PermissionDefinitionGroup; + permission: T.PermissionDefinition | T.PermissionDefinitionGroup; selectedPermission?: string; showPublicProjectsWarning?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/UserHolder.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/UserHolder.tsx index 728fe12cd98..0a7ed8dde02 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/UserHolder.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/UserHolder.tsx @@ -22,14 +22,13 @@ import { without } from 'lodash'; import PermissionCell from './PermissionCell'; import Avatar from '../../../../components/ui/Avatar'; import { translate } from '../../../../helpers/l10n'; -import { PermissionDefinitions, PermissionUser } from '../../../../app/types'; import { isPermissionDefinitionGroup } from '../../utils'; interface Props { - onToggle: (user: PermissionUser, permission: string) => Promise; - permissions: PermissionDefinitions; + onToggle: (user: T.PermissionUser, permission: string) => Promise; + permissions: T.PermissionDefinitions; selectedPermission?: string; - user: PermissionUser; + user: T.PermissionUser; } interface State { diff --git a/server/sonar-web/src/main/js/apps/permissions/utils.ts b/server/sonar-web/src/main/js/apps/permissions/utils.ts index 98de45fa190..f0b78108820 100644 --- a/server/sonar-web/src/main/js/apps/permissions/utils.ts +++ b/server/sonar-web/src/main/js/apps/permissions/utils.ts @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { translate } from '../../helpers/l10n'; -import { PermissionDefinition, PermissionDefinitionGroup } from '../../app/types'; export const PERMISSIONS_ORDER_FOR_PROJECT_TEMPLATE = [ 'user', @@ -66,7 +65,7 @@ function convertToPermissionDefinition(permission: string, l10nPrefix: string) { export function convertToPermissionDefinitions( permissions: Array, l10nPrefix: string -): Array { +): Array { return permissions.map(permission => { if (typeof permission === 'object') { return { @@ -81,7 +80,7 @@ export function convertToPermissionDefinitions( } export function isPermissionDefinitionGroup( - permission?: PermissionDefinition | PermissionDefinitionGroup -): permission is PermissionDefinitionGroup { - return Boolean(permission && (permission as PermissionDefinitionGroup).category); + permission?: T.PermissionDefinition | T.PermissionDefinitionGroup +): permission is T.PermissionDefinitionGroup { + return Boolean(permission && (permission as T.PermissionDefinitionGroup).category); } diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/Activity.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/Activity.tsx index 5907d243265..7e73a05b4b2 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/Activity.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/Activity.tsx @@ -26,14 +26,13 @@ import { } from '../../projectActivity/utils'; import PreviewGraph from '../../../components/preview-graph/PreviewGraph'; import { getAllTimeMachineData } from '../../../api/time-machine'; -import { Metric } from '../../../app/types'; import { parseDate } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; import { get } from '../../../helpers/storage'; interface Props { component: string; - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; } interface State { diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx index b5bef871e77..dd6bc722b41 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/App.tsx @@ -34,16 +34,15 @@ import { getChildren } from '../../../api/components'; import { translate } from '../../../helpers/l10n'; import { fetchMetrics } from '../../../store/rootActions'; import { getMetrics, Store } from '../../../store/rootReducer'; -import { Metric, Component } from '../../../app/types'; import '../styles.css'; import PrivacyBadgeContainer from '../../../components/common/PrivacyBadgeContainer'; interface OwnProps { - component: Component; + component: T.Component; } interface StateToProps { - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; } interface DispatchToProps { diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/Subscription.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/Subscription.tsx index 4d55cc25215..8fe4700c153 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/Subscription.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/Subscription.tsx @@ -22,12 +22,11 @@ import AlertSuccessIcon from '../../../components/icons-components/AlertSuccessI import { ReportStatus, subscribe, unsubscribe } from '../../../api/report'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { Button } from '../../../components/ui/buttons'; -import { CurrentUser } from '../../../app/types'; import { isLoggedIn } from '../../../helpers/users'; interface Props { component: string; - currentUser: CurrentUser; + currentUser: T.CurrentUser; status: ReportStatus; } diff --git a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx index 58ec3447ae8..1a66a953799 100644 --- a/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/portfolio/components/__tests__/App-test.tsx @@ -44,12 +44,11 @@ jest.mock('../Report', () => ({ import * as React from 'react'; import { shallow, mount } from 'enzyme'; import { App } from '../App'; -import { Component } from '../../../../app/types'; const getMeasures = require('../../../../api/measures').getMeasures as jest.Mock; const getChildren = require('../../../../api/components').getChildren as jest.Mock; -const component = { key: 'foo', name: 'Foo', qualifier: 'TRK' } as Component; +const component = { key: 'foo', name: 'Foo', qualifier: 'TRK' } as T.Component; it('renders', () => { const wrapper = shallow(); diff --git a/server/sonar-web/src/main/js/apps/projectActivity/actions.ts b/server/sonar-web/src/main/js/apps/projectActivity/actions.ts index 0843edf9bb8..926f7095513 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/actions.ts +++ b/server/sonar-web/src/main/js/apps/projectActivity/actions.ts @@ -18,9 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { State } from './components/ProjectActivityAppContainer'; -import { AnalysisEvent } from '../../app/types'; -export function addCustomEvent(analysis: string, event: AnalysisEvent) { +export function addCustomEvent(analysis: string, event: T.AnalysisEvent) { return (state: State) => ({ analyses: state.analyses.map(item => { if (item.key !== analysis) { @@ -42,7 +41,7 @@ export function deleteEvent(analysis: string, event: string) { }); } -export function changeEvent(analysis: string, event: AnalysisEvent) { +export function changeEvent(analysis: string, event: T.AnalysisEvent) { return (state: State) => ({ analyses: state.analyses.map(item => { if (item.key !== analysis) { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx index df2328de21f..b5ec2e12520 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/DefinitionChangeEventInner.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { Link } from 'react-router'; import { FormattedMessage } from 'react-intl'; import * as classNames from 'classnames'; -import { AnalysisEvent, BranchLike } from '../../../app/types'; import DropdownIcon from '../../../components/icons-components/DropdownIcon'; import ProjectEventIcon from '../../../components/icons-components/ProjectEventIcon'; import { ResetButtonLink } from '../../../components/ui/buttons'; @@ -31,15 +30,15 @@ import LongLivingBranchIcon from '../../../components/icons-components/LongLivin import { isMainBranch } from '../../../helpers/branches'; import { limitComponentName } from '../../../helpers/path'; -export type DefinitionChangeEvent = AnalysisEvent & - Required>; +export type DefinitionChangeEvent = T.AnalysisEvent & + Required>; -export function isDefinitionChangeEvent(event: AnalysisEvent): event is DefinitionChangeEvent { +export function isDefinitionChangeEvent(event: T.AnalysisEvent): event is DefinitionChangeEvent { return event.category === 'DEFINITION_CHANGE' && event.definitionChange !== undefined; } interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; event: DefinitionChangeEvent; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/Event.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/Event.tsx index b2923e8d25e..7f9e0519749 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/Event.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/Event.tsx @@ -24,14 +24,13 @@ import RemoveEventForm from './forms/RemoveEventForm'; import Tooltip from '../../../components/controls/Tooltip'; import { DeleteButton, EditButton } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; -import { AnalysisEvent } from '../../../app/types'; interface Props { analysis: string; canAdmin?: boolean; changeEvent: (event: string, name: string) => Promise; deleteEvent: (analysis: string, event: string) => Promise; - event: AnalysisEvent; + event: T.AnalysisEvent; isFirst?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.tsx index 69369b52d4a..c32ef56e442 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/EventInner.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import * as classNames from 'classnames'; import { isRichQualityGateEvent, RichQualityGateEventInner } from './RichQualityGateEventInner'; import { isDefinitionChangeEvent, DefinitionChangeEventInner } from './DefinitionChangeEventInner'; -import { AnalysisEvent } from '../../../app/types'; import { ComponentContext } from '../../../app/components/ComponentContext'; import ProjectEventIcon from '../../../components/icons-components/ProjectEventIcon'; import { translate } from '../../../helpers/l10n'; interface Props { - event: AnalysisEvent; + event: T.AnalysisEvent; } export default function EventInner({ event }: Props) { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/Events.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/Events.tsx index b891e1f686d..e5dd48f5f83 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/Events.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/Events.tsx @@ -20,14 +20,13 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import Event from './Event'; -import { AnalysisEvent } from '../../../app/types'; interface Props { analysis: string; canAdmin?: boolean; changeEvent: (event: string, name: string) => Promise; deleteEvent: (analysis: string, event: string) => Promise; - events: AnalysisEvent[]; + events: T.AnalysisEvent[]; isFirst?: boolean; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphHistory.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphHistory.tsx index 7576d41f7df..f188656f3c2 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphHistory.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphHistory.tsx @@ -25,10 +25,9 @@ import GraphsLegendStatic from './GraphsLegendStatic'; import AdvancedTimeline from '../../../components/charts/AdvancedTimeline'; import { formatMeasure, getShortType } from '../../../helpers/measures'; import { MeasureHistory, Serie } from '../utils'; -import { AnalysisEvent } from '../../../app/types'; interface Props { - events: AnalysisEvent[]; + events: T.AnalysisEvent[]; graph: string; graphEndDate?: Date; graphStartDate?: Date; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.tsx index 027a0ce1636..b8542ee8be4 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.tsx @@ -26,10 +26,9 @@ import GraphsTooltipsContentIssues from './GraphsTooltipsContentIssues'; import { DEFAULT_GRAPH, MeasureHistory, Serie } from '../utils'; import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; import { Popup, PopupPlacement } from '../../../components/ui/popups'; -import { AnalysisEvent } from '../../../app/types'; interface Props { - events: AnalysisEvent[]; + events: T.AnalysisEvent[]; formatValue: (tick: number | string) => string; graph: string; graphWidth: number; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentEvents.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentEvents.tsx index c9c67110b71..239b09c5f51 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentEvents.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltipsContentEvents.tsx @@ -20,11 +20,10 @@ import * as React from 'react'; import ProjectEventIcon from '../../../components/icons-components/ProjectEventIcon'; import { translate } from '../../../helpers/l10n'; -import { AnalysisEvent } from '../../../app/types'; interface Props { addSeparator: boolean; - events: AnalysisEvent[]; + events: T.AnalysisEvent[]; } export default function GraphsTooltipsContentEvents({ addSeparator, events }: Props) { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx index e3c0725684d..8f64b78ec38 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx @@ -26,7 +26,6 @@ import { MeasureHistory, Query, ParsedAnalysis } from '../utils'; import { parseDate } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; -import { Metric, Component } from '../../../app/types'; import './projectActivity.css'; interface Props { @@ -39,8 +38,8 @@ interface Props { deleteEvent: (analysis: string, event: string) => Promise; graphLoading: boolean; initializing: boolean; - project: Pick; - metrics: Metric[]; + project: Pick; + metrics: T.Metric[]; measuresHistory: MeasureHistory[]; query: Query; updateQuery: (changes: Partial) => void; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx index 2b003b1ec9c..2ddfd9672fe 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.tsx @@ -42,12 +42,11 @@ import { Query, ParsedAnalysis } from '../utils'; -import { Metric, Paging, BranchLike, Component } from '../../../app/types'; import { RawQuery } from '../../../helpers/query'; interface Props { - branchLike?: BranchLike; - component: Component; + branchLike?: T.BranchLike; + component: T.Component; location: Location; router: Pick; } @@ -57,9 +56,9 @@ export interface State { analysesLoading: boolean; graphLoading: boolean; initialized: boolean; - metrics: Metric[]; + metrics: T.Metric[]; measuresHistory: MeasureHistory[]; - paging?: Paging; + paging?: T.Paging; query: Query; } @@ -188,8 +187,8 @@ export default class ProjectActivityAppContainer extends React.PureComponent => { + prevResult?: { analyses: ParsedAnalysis[]; paging: T.Paging } + ): Promise<{ analyses: ParsedAnalysis[]; paging: T.Paging }> => { if ( prevResult && prevResult.paging.pageIndex * prevResult.paging.pageSize >= prevResult.paging.total @@ -208,7 +207,7 @@ export default class ProjectActivityAppContainer extends React.PureComponent { + getTopLevelComponent = (component: T.Component) => { let current = component.breadcrumbs.length - 1; while ( current > 0 && @@ -219,7 +218,7 @@ export default class ProjectActivityAppContainer extends React.PureComponent) => void; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphsHeader.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphsHeader.tsx index 8f7e5bd70df..ad1955d4368 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphsHeader.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphsHeader.tsx @@ -22,13 +22,12 @@ import AddGraphMetric from './forms/AddGraphMetric'; import { isCustomGraph, GRAPH_TYPES } from '../utils'; import Select from '../../../components/controls/Select'; import { translate } from '../../../helpers/l10n'; -import { Metric } from '../../../app/types'; interface Props { addCustomMetric: (metric: string) => void; removeCustomMetric: (metric: string) => void; graph: string; - metrics: Metric[]; + metrics: T.Metric[]; metricsTypeFilter?: string[]; selectedMetrics: string[]; updateGraph: (graphType: string) => void; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.tsx index e32165f83d3..9c58fc2ab00 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFooter.tsx @@ -19,12 +19,11 @@ */ import * as React from 'react'; import ListFooter from '../../../components/controls/ListFooter'; -import { Paging } from '../../../app/types'; interface Props { analyses: unknown[]; fetchMoreActivity: () => void; - paging?: Paging; + paging?: T.Paging; } export default function ProjectActivityPageFooter({ analyses, fetchMoreActivity, paging }: Props) { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx index 8136cfcc71a..d5427b1e91d 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx @@ -25,12 +25,11 @@ import ProjectActivityDateInput from './ProjectActivityDateInput'; import { EVENT_TYPES, APPLICATION_EVENT_TYPES, Query } from '../utils'; import Select from '../../../components/controls/Select'; import { translate } from '../../../helpers/l10n'; -import { Component } from '../../../app/types'; interface Props { category?: string; from?: Date; - project: Pick; + project: Pick; to?: Date; updateQuery: (changes: Partial) => void; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/RichQualityGateEventInner.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/RichQualityGateEventInner.tsx index 65ea0562655..598fd155bf5 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/RichQualityGateEventInner.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/RichQualityGateEventInner.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; import * as classNames from 'classnames'; -import { AnalysisEvent } from '../../../app/types'; import DropdownIcon from '../../../components/icons-components/DropdownIcon'; import Level from '../../../components/ui/Level'; import ProjectEventIcon from '../../../components/icons-components/ProjectEventIcon'; @@ -29,9 +28,9 @@ import { ResetButtonLink } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; import { getProjectUrl } from '../../../helpers/urls'; -export type RichQualityGateEvent = AnalysisEvent & Required>; +export type RichQualityGateEvent = T.AnalysisEvent & Required>; -export function isRichQualityGateEvent(event: AnalysisEvent): event is RichQualityGateEvent { +export function isRichQualityGateEvent(event: T.AnalysisEvent): event is RichQualityGateEvent { return event.category === 'QUALITY_GATE' && event.qualityGate !== undefined; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx index adff6e7da08..5dc67e3ef41 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/DefinitionChangeEventInner-test.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { DefinitionChangeEventInner, DefinitionChangeEvent } from '../DefinitionChangeEventInner'; import { click } from '../../../../helpers/testUtils'; -import { LongLivingBranch, BranchType } from '../../../../app/types'; it('should render', () => { const event: DefinitionChangeEvent = { @@ -44,7 +43,7 @@ it('should render', () => { }); it('should render for a branch', () => { - const branch: LongLivingBranch = { name: 'feature-x', isMain: false, type: BranchType.LONG }; + const branch: T.LongLivingBranch = { name: 'feature-x', isMain: false, type: 'LONG' }; const event: DefinitionChangeEvent = { category: 'DEFINITION_CHANGE', key: 'foo1234', diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddGraphMetric.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddGraphMetric.tsx index 01b587c81db..5d4d36ed8cb 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddGraphMetric.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/AddGraphMetric.tsx @@ -25,12 +25,11 @@ import Dropdown from '../../../../components/controls/Dropdown'; import { Button } from '../../../../components/ui/buttons'; import { isDiffMetric } from '../../../../helpers/measures'; import { getLocalizedMetricName, translate } from '../../../../helpers/l10n'; -import { Metric } from '../../../../app/types'; interface Props { addMetric: (metric: string) => void; className?: string; - metrics: Metric[]; + metrics: T.Metric[]; metricsTypeFilter?: string[]; removeMetric: (metric: string) => void; selectedMetrics: string[]; @@ -82,7 +81,7 @@ export default class AddGraphMetric extends React.PureComponent { .map(metric => metric.key); }; - getSelectedMetricsElements = (metrics: Metric[], selectedMetrics?: string[]) => { + getSelectedMetricsElements = (metrics: T.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/apps/projectActivity/components/forms/ChangeEventForm.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.tsx index 6e2d95c85bb..b7cf9827a53 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/ChangeEventForm.tsx @@ -20,12 +20,11 @@ import * as React from 'react'; import { translate } from '../../../../helpers/l10n'; import ConfirmModal from '../../../../components/controls/ConfirmModal'; -import { AnalysisEvent } from '../../../../app/types'; interface Props { changeEvent: (event: string, name: string) => Promise; header: string; - event: AnalysisEvent; + event: T.AnalysisEvent; onClose: () => void; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.tsx index abecbb8a41d..dee2732c12e 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/forms/RemoveEventForm.tsx @@ -20,12 +20,11 @@ import * as React from 'react'; import { translate } from '../../../../helpers/l10n'; import ConfirmModal from '../../../../components/controls/ConfirmModal'; -import { AnalysisEvent } from '../../../../app/types'; interface Props { analysis: string; deleteEvent: (analysis: string, event: string) => Promise; - event: AnalysisEvent; + event: T.AnalysisEvent; header: string; removeEventQuestion: string; onClose: () => void; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/utils.ts b/server/sonar-web/src/main/js/apps/projectActivity/utils.ts index ce069f69369..a596a9ac6b4 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/utils.ts +++ b/server/sonar-web/src/main/js/apps/projectActivity/utils.ts @@ -30,9 +30,8 @@ import { } from '../../helpers/query'; import { parseDate, startOfDay } from '../../helpers/dates'; import { getLocalizedMetricName, translate } from '../../helpers/l10n'; -import { Metric, Analysis, Omit } from '../../app/types'; -export type ParsedAnalysis = Omit & { date: Date }; +export type ParsedAnalysis = T.Omit & { date: Date }; export interface Query { category: string; @@ -142,7 +141,7 @@ export function generateCoveredLinesMetric( }; } -function findMetric(key: string, metrics: Metric[] | { [key: string]: Metric }) { +function findMetric(key: string, metrics: T.Metric[] | { [key: string]: T.Metric }) { if (Array.isArray(metrics)) { return metrics.find(metric => metric.key === key); } @@ -152,7 +151,7 @@ function findMetric(key: string, metrics: Metric[] | { [key: string]: Metric }) export function generateSeries( measuresHistory: MeasureHistory[], graph: string, - metrics: Metric[] | { [key: string]: Metric }, + metrics: T.Metric[] | { [key: string]: T.Metric }, displayedMetrics: string[] ): Serie[] { if (displayedMetrics.length <= 0 || typeof measuresHistory === 'undefined') { diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx index f73a5e17ecd..dab6b18c8c8 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/App.tsx @@ -22,7 +22,6 @@ import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; import BranchRow from './BranchRow'; import LongBranchesPattern from './LongBranchesPattern'; -import { BranchLike } from '../../../app/types'; import { sortBranchesAsTree, getBranchLikeKey, @@ -35,7 +34,7 @@ import { formatMeasure } from '../../../helpers/measures'; import HelpTooltip from '../../../components/controls/HelpTooltip'; interface Props { - branchLikes: BranchLike[]; + branchLikes: T.BranchLike[]; canAdmin?: boolean; component: { key: string }; onBranchesChange: () => void; @@ -78,7 +77,7 @@ export default class App extends React.PureComponent { ); } - isOrphan = (branchLike: BranchLike) => { + isOrphan = (branchLike: T.BranchLike) => { return (isShortLivingBranch(branchLike) || isPullRequest(branchLike)) && branchLike.isOrphan; }; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx index fbcbb4d1751..26b5bb56027 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/BranchRow.tsx @@ -22,7 +22,6 @@ import * as classNames from 'classnames'; import DeleteBranchModal from './DeleteBranchModal'; import LeakPeriodForm from './LeakPeriodForm'; import RenameBranchModal from './RenameBranchModal'; -import { BranchLike } from '../../../app/types'; import BranchStatus from '../../../components/common/BranchStatus'; import BranchIcon from '../../../components/icons-components/BranchIcon'; import { @@ -40,7 +39,7 @@ import ActionsDropdown, { } from '../../../components/controls/ActionsDropdown'; interface Props { - branchLike: BranchLike; + branchLike: T.BranchLike; component: string; isOrphan?: boolean; onChange: () => void; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx index c98bb190f65..637b54a2774 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx @@ -19,14 +19,13 @@ */ import * as React from 'react'; import { deleteBranch, deletePullRequest } from '../../../api/branches'; -import { BranchLike } from '../../../app/types'; import Modal from '../../../components/controls/Modal'; import { SubmitButton, ResetButtonLink } from '../../../components/ui/buttons'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { isPullRequest, getBranchLikeDisplayName } from '../../../helpers/branches'; interface Props { - branchLike: BranchLike; + branchLike: T.BranchLike; component: string; onClose: () => void; onDelete: () => void; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/LeakPeriodForm.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/LeakPeriodForm.tsx index ebfc5e35072..3104fb7af2e 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/LeakPeriodForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/LeakPeriodForm.tsx @@ -22,7 +22,6 @@ import SettingForm from './SettingForm'; import { translate } from '../../../helpers/l10n'; import { getValues } from '../../../api/settings'; import Modal from '../../../components/controls/Modal'; -import { SettingValue } from '../../../app/types'; interface Props { branch: string; @@ -32,7 +31,7 @@ interface Props { interface State { loading: boolean; - setting?: SettingValue; + setting?: T.SettingValue; submitting: boolean; value?: string; } diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx index e0b17e46f8e..a884cb48195 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPattern.tsx @@ -22,7 +22,6 @@ import LongBranchesPatternForm from './LongBranchesPatternForm'; import { getValues } from '../../../api/settings'; import { EditButton } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; -import { SettingValue } from '../../../app/types'; interface Props { project: string; @@ -30,7 +29,7 @@ interface Props { interface State { formOpen: boolean; - setting?: SettingValue; + setting?: T.SettingValue; } export const LONG_BRANCH_PATTERN = 'sonar.branch.longLivedBranches.regex'; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPatternForm.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPatternForm.tsx index d323cf22a81..d966c92ad76 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPatternForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/LongBranchesPatternForm.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import SettingForm from './SettingForm'; import { translate } from '../../../helpers/l10n'; import Modal from '../../../components/controls/Modal'; -import { SettingValue } from '../../../app/types'; interface Props { onChange: () => void; onClose: () => void; project: string; - setting: SettingValue; + setting: T.SettingValue; } export default function LongBranchesPatternForm(props: Props) { diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx index 2e8ee656d44..ab41ea24d43 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx @@ -19,13 +19,12 @@ */ import * as React from 'react'; import { renameBranch } from '../../../api/branches'; -import { MainBranch } from '../../../app/types'; import Modal from '../../../components/controls/Modal'; import { SubmitButton, ResetButtonLink } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; interface Props { - branch: MainBranch; + branch: T.MainBranch; component: string; onClose: () => void; onRename: () => void; diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/SettingForm.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/SettingForm.tsx index 08f1bb0e802..f400962c823 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/SettingForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/SettingForm.tsx @@ -21,14 +21,13 @@ import * as React from 'react'; import { setSimpleSettingValue, resetSettingValue } from '../../../api/settings'; import { Button, SubmitButton, ResetButtonLink } from '../../../components/ui/buttons'; import { translate, translateWithParameters } from '../../../helpers/l10n'; -import { SettingValue } from '../../../app/types'; interface Props { branch?: string; onClose: () => void; onChange: () => void; project: string; - setting: SettingValue; + setting: T.SettingValue; } interface State { diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx index 36faa6a97e2..638bd45b1dc 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/App-test.tsx @@ -25,13 +25,6 @@ jest.mock('../../../../api/settings', () => ({ import * as React from 'react'; import { mount, shallow } from 'enzyme'; import App from '../App'; -import { - BranchType, - LongLivingBranch, - ShortLivingBranch, - MainBranch, - PullRequest -} from '../../../../app/types'; const getValues = require('../../../../api/settings').getValues as jest.Mock; @@ -41,22 +34,22 @@ beforeEach(() => { it('renders sorted list of branches', () => { const branchLikes: [ - MainBranch, - LongLivingBranch, - ShortLivingBranch, - PullRequest, - ShortLivingBranch + T.MainBranch, + T.LongLivingBranch, + T.ShortLivingBranch, + T.PullRequest, + T.ShortLivingBranch ] = [ { isMain: true, name: 'master' }, - { isMain: false, name: 'branch-1.0', type: BranchType.LONG }, - { isMain: false, mergeBranch: 'master', name: 'feature', type: BranchType.SHORT }, + { isMain: false, name: 'branch-1.0', type: 'LONG' }, + { isMain: false, mergeBranch: 'master', name: 'feature', type: 'SHORT' }, { base: 'master', branch: 'feature', key: '1234', title: 'Feature PR' }, { isMain: false, mergeBranch: 'foobar', isOrphan: true, name: 'feature', - type: BranchType.SHORT + type: 'SHORT' } ]; const wrapper = shallow( diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchRow-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchRow-test.tsx index eac799c7f6f..cb33663fbca 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchRow-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/BranchRow-test.tsx @@ -20,26 +20,19 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import BranchRow from '../BranchRow'; -import { - MainBranch, - ShortLivingBranch, - BranchType, - PullRequest, - BranchLike -} from '../../../../app/types'; import { click } from '../../../../helpers/testUtils'; -const mainBranch: MainBranch = { isMain: true, name: 'master' }; +const mainBranch: T.MainBranch = { isMain: true, name: 'master' }; -const shortBranch: ShortLivingBranch = { +const shortBranch: T.ShortLivingBranch = { analysisDate: '2017-09-27T00:05:19+0000', isMain: false, name: 'feature', mergeBranch: 'foo', - type: BranchType.SHORT + type: 'SHORT' }; -const pullRequest: PullRequest = { +const pullRequest: T.PullRequest = { base: 'master', branch: 'feature', key: '1234', @@ -85,7 +78,7 @@ it('deletes pull request', () => { expect(onChange).toBeCalled(); }); -function shallowRender(branchLike: BranchLike, onChange: () => void = jest.fn()) { +function shallowRender(branchLike: T.BranchLike, onChange: () => void = jest.fn()) { const wrapper = shallow( ); diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx index 721df857ac0..e8a4150d6db 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/DeleteBranchModal-test.tsx @@ -26,15 +26,14 @@ jest.mock('../../../../api/branches', () => ({ import * as React from 'react'; import { shallow, ShallowWrapper } from 'enzyme'; import DeleteBranchModal from '../DeleteBranchModal'; -import { ShortLivingBranch, BranchType, BranchLike, PullRequest } from '../../../../app/types'; import { submit, doAsync, click, waitAndUpdate } from '../../../../helpers/testUtils'; import { deleteBranch, deletePullRequest } from '../../../../api/branches'; -const branch: ShortLivingBranch = { +const branch: T.ShortLivingBranch = { isMain: false, name: 'feature', mergeBranch: 'master', - type: BranchType.SHORT + type: 'SHORT' }; beforeEach(() => { @@ -64,7 +63,7 @@ it('deletes branch', async () => { it('deletes pull request', async () => { (deletePullRequest as jest.Mock).mockImplementationOnce(() => Promise.resolve()); - const pullRequest: PullRequest = { + const pullRequest: T.PullRequest = { base: 'master', branch: 'feature', key: '1234', @@ -106,7 +105,7 @@ it('stops loading on WS error', async () => { }); function shallowRender( - branchLike: BranchLike, + branchLike: T.BranchLike, onDelete: () => void = jest.fn(), onClose: () => void = jest.fn() ) { diff --git a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx index 7e69538b1e7..de40ac89403 100644 --- a/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBranches/components/__tests__/RenameBranchModal-test.tsx @@ -23,7 +23,6 @@ jest.mock('../../../../api/branches', () => ({ renameBranch: jest.fn() })); import * as React from 'react'; import { shallow, ShallowWrapper } from 'enzyme'; import RenameBranchModal from '../RenameBranchModal'; -import { MainBranch } from '../../../../app/types'; import { submit, doAsync, click, change, waitAndUpdate } from '../../../../helpers/testUtils'; import { renameBranch } from '../../../../api/branches'; @@ -77,7 +76,7 @@ it('stops loading on WS error', async () => { }); function shallowRender(onRename: () => void = jest.fn(), onClose: () => void = jest.fn()) { - const branch: MainBranch = { isMain: true, name: 'master' }; + const branch: T.MainBranch = { isMain: true, name: 'master' }; const wrapper = shallow( ); diff --git a/server/sonar-web/src/main/js/apps/projectDeletion/App.tsx b/server/sonar-web/src/main/js/apps/projectDeletion/App.tsx index 87413a22988..ff35ca6fb2d 100644 --- a/server/sonar-web/src/main/js/apps/projectDeletion/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectDeletion/App.tsx @@ -21,11 +21,10 @@ import * as React from 'react'; import Helmet from 'react-helmet'; import Header from './Header'; import Form from './Form'; -import { Component } from '../../app/types'; import { translate } from '../../helpers/l10n'; interface Props { - component: Pick; + component: Pick; } export default function App(props: Props) { diff --git a/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx b/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx index 1114935a92f..0b546452f37 100644 --- a/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx +++ b/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx @@ -22,11 +22,10 @@ import { withRouter, WithRouterProps } from 'react-router'; import { deleteProject, deletePortfolio } from '../../api/components'; import { Button } from '../../components/ui/buttons'; import { translate, translateWithParameters } from '../../helpers/l10n'; -import { Component } from '../../app/types'; import ConfirmButton from '../../components/controls/ConfirmButton'; interface Props { - component: Pick; + component: Pick; } export default withRouter( diff --git a/server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx b/server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx index 4cd39cec859..0cfc5903b43 100644 --- a/server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx +++ b/server/sonar-web/src/main/js/apps/projectDeletion/Header.tsx @@ -19,10 +19,9 @@ */ import * as React from 'react'; import { translate } from '../../helpers/l10n'; -import { Component } from '../../app/types'; interface Props { - component: Pick; + component: Pick; } export default function Header(props: Props) { diff --git a/server/sonar-web/src/main/js/apps/projectLinks/App.tsx b/server/sonar-web/src/main/js/apps/projectLinks/App.tsx index 5e9d9a2b94e..0d246149716 100644 --- a/server/sonar-web/src/main/js/apps/projectLinks/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectLinks/App.tsx @@ -22,16 +22,15 @@ import Helmet from 'react-helmet'; import Header from './Header'; import Table from './Table'; import { getProjectLinks, createLink, deleteLink } from '../../api/projectLinks'; -import { ProjectLink, Component } from '../../app/types'; import { translate } from '../../helpers/l10n'; import DeferredSpinner from '../../components/common/DeferredSpinner'; interface Props { - component: Pick; + component: Pick; } interface State { - links?: ProjectLink[]; + links?: T.ProjectLink[]; loading: boolean; } diff --git a/server/sonar-web/src/main/js/apps/projectLinks/LinkRow.tsx b/server/sonar-web/src/main/js/apps/projectLinks/LinkRow.tsx index 7d2630cba14..9ca2a8f6906 100644 --- a/server/sonar-web/src/main/js/apps/projectLinks/LinkRow.tsx +++ b/server/sonar-web/src/main/js/apps/projectLinks/LinkRow.tsx @@ -19,19 +19,18 @@ */ import * as React from 'react'; import { isProvided, getLinkName } from './utils'; -import { ProjectLink } from '../../app/types'; import ConfirmButton from '../../components/controls/ConfirmButton'; import ProjectLinkIcon from '../../components/icons-components/ProjectLinkIcon'; import { Button } from '../../components/ui/buttons'; import { translate, translateWithParameters } from '../../helpers/l10n'; interface Props { - link: ProjectLink; + link: T.ProjectLink; onDelete: (linkId: string) => Promise; } export default class LinkRow extends React.PureComponent { - renderNameForProvided = (link: ProjectLink) => { + renderNameForProvided = (link: T.ProjectLink) => { return (
    @@ -44,7 +43,7 @@ export default class LinkRow extends React.PureComponent { ); }; - renderName = (link: ProjectLink) => { + renderName = (link: T.ProjectLink) => { return (
    @@ -59,7 +58,7 @@ export default class LinkRow extends React.PureComponent { ); }; - renderDeleteButton = (link: ProjectLink) => { + renderDeleteButton = (link: T.ProjectLink) => { if (isProvided(link)) { return null; } diff --git a/server/sonar-web/src/main/js/apps/projectLinks/Table.tsx b/server/sonar-web/src/main/js/apps/projectLinks/Table.tsx index 41a21af6d92..dc789bdb14d 100644 --- a/server/sonar-web/src/main/js/apps/projectLinks/Table.tsx +++ b/server/sonar-web/src/main/js/apps/projectLinks/Table.tsx @@ -20,11 +20,10 @@ import * as React from 'react'; import LinkRow from './LinkRow'; import { orderLinks } from './utils'; -import { ProjectLink } from '../../app/types'; import { translate } from '../../helpers/l10n'; interface Props { - links: ProjectLink[]; + links: T.ProjectLink[]; onDelete: (linkId: string) => Promise; } diff --git a/server/sonar-web/src/main/js/apps/projectLinks/utils.ts b/server/sonar-web/src/main/js/apps/projectLinks/utils.ts index 2bb1bd70c25..c5a39442084 100644 --- a/server/sonar-web/src/main/js/apps/projectLinks/utils.ts +++ b/server/sonar-web/src/main/js/apps/projectLinks/utils.ts @@ -18,13 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { partition, sortBy } from 'lodash'; -import { ProjectLink } from '../../app/types'; import { translate } from '../../helpers/l10n'; const PROVIDED_TYPES = ['homepage', 'ci', 'issue', 'scm', 'scm_dev']; -type NameAndType = Pick; +type NameAndType = Pick; -export function isProvided(link: Pick) { +export function isProvided(link: Pick) { return PROVIDED_TYPES.includes(link.type); } diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/App.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/App.tsx index 2ecc5f07a4f..d41fa24b94a 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityGate/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityGate/App.tsx @@ -30,17 +30,16 @@ import { import Suggestions from '../../app/components/embed-docs-modal/Suggestions'; import addGlobalSuccessMessage from '../../app/utils/addGlobalSuccessMessage'; import handleRequiredAuthorization from '../../app/utils/handleRequiredAuthorization'; -import { Component, QualityGate } from '../../app/types'; import { translate } from '../../helpers/l10n'; interface Props { - component: Component; + component: T.Component; onComponentChange: (changes: {}) => void; } interface State { - allGates?: QualityGate[]; - gate?: QualityGate; + allGates?: T.QualityGate[]; + gate?: T.QualityGate; loading: boolean; } diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/Form.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/Form.tsx index 1ac3be588b2..d85420c8697 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityGate/Form.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityGate/Form.tsx @@ -20,11 +20,10 @@ import * as React from 'react'; import Select from '../../components/controls/Select'; import { translate } from '../../helpers/l10n'; -import { QualityGate } from '../../app/types'; interface Props { - allGates: QualityGate[]; - gate?: QualityGate; + allGates: T.QualityGate[]; + gate?: T.QualityGate; onChange: (oldGate?: number, newGate?: number) => Promise; } diff --git a/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/App-test.tsx index 158e002447c..10b43cd82ed 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityGate/__tests__/App-test.tsx @@ -36,7 +36,6 @@ jest.mock('../../../app/utils/handleRequiredAuthorization', () => ({ import * as React from 'react'; import { shallow } from 'enzyme'; import App from '../App'; -import { Component } from '../../../app/types'; const associateGateWithProject = require('../../../api/quality-gates') .associateGateWithProject as jest.Mock; @@ -63,7 +62,7 @@ const component = { organization: 'org', qualifier: 'TRK', version: '0.0.1' -} as Component; +} as T.Component; beforeEach(() => { associateGateWithProject.mockClear(); @@ -75,7 +74,7 @@ it('checks permissions', () => { handleRequiredAuthorization.mockClear(); shallow( ); diff --git a/server/sonar-web/src/main/js/apps/projectQualityProfiles/App.tsx b/server/sonar-web/src/main/js/apps/projectQualityProfiles/App.tsx index 9cd66cea2cf..6f93a366e3e 100644 --- a/server/sonar-web/src/main/js/apps/projectQualityProfiles/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectQualityProfiles/App.tsx @@ -27,14 +27,13 @@ import { searchQualityProfiles, Profile } from '../../api/quality-profiles'; -import { Component } from '../../app/types'; import Suggestions from '../../app/components/embed-docs-modal/Suggestions'; import addGlobalSuccessMessage from '../../app/utils/addGlobalSuccessMessage'; import handleRequiredAuthorization from '../../app/utils/handleRequiredAuthorization'; import { translate, translateWithParameters } from '../../helpers/l10n'; interface Props { - component: Component; + component: T.Component; } interface State { diff --git a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx index 0e1c185aaac..9094431da5d 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx @@ -26,7 +26,6 @@ import ProjectsList from './ProjectsList'; import PageSidebar from './PageSidebar'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import Visualizations from '../visualizations/Visualizations'; -import { CurrentUser, Organization } from '../../../app/types'; import handleRequiredAuthentication from '../../../app/utils/handleRequiredAuthentication'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import ListFooter from '../../../components/controls/ListFooter'; @@ -43,10 +42,10 @@ import '../../../components/search-navigator.css'; import '../styles.css'; export interface Props { - currentUser: CurrentUser; + currentUser: T.CurrentUser; isFavorite: boolean; location: { pathname: string; query: RawQuery }; - organization: Organization | undefined; + organization: T.Organization | undefined; organizationsEnabled?: boolean; storageOptionsSuffix?: string; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx b/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx index c2d8c70efdd..dd86e540523 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/DefaultPageSelector.tsx @@ -23,12 +23,11 @@ import AllProjectsContainer from './AllProjectsContainer'; import { PROJECTS_DEFAULT_FILTER, PROJECTS_FAVORITE, PROJECTS_ALL } from '../utils'; import { get } from '../../../helpers/storage'; import { searchProjects } from '../../../api/components'; -import { CurrentUser } from '../../../app/types'; import { isSonarCloud } from '../../../helpers/system'; import { isLoggedIn } from '../../../helpers/users'; interface Props { - currentUser: CurrentUser; + currentUser: T.CurrentUser; location: { pathname: string; query: { [x: string]: string } }; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx b/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx index a4e91c44302..790e0970db3 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/EmptyInstance.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import * as PropTypes from 'prop-types'; import { translate } from '../../../helpers/l10n'; import { Button } from '../../../components/ui/buttons'; -import { Organization, CurrentUser } from '../../../app/types'; import { isSonarCloud } from '../../../helpers/system'; import { hasGlobalPermission, isLoggedIn } from '../../../helpers/users'; interface Props { - organization?: Organization; - currentUser: CurrentUser; + organization?: T.Organization; + currentUser: T.CurrentUser; } export default class EmptyInstance extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx b/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx index ebec0b9f090..958d8b69721 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/FavoriteFilter.tsx @@ -20,14 +20,13 @@ import * as React from 'react'; import { IndexLink, Link } from 'react-router'; import { translate } from '../../../helpers/l10n'; -import { CurrentUser } from '../../../app/types'; import { save } from '../../../helpers/storage'; import { RawQuery } from '../../../helpers/query'; import { PROJECTS_DEFAULT_FILTER, PROJECTS_FAVORITE, PROJECTS_ALL } from '../utils'; import { isLoggedIn } from '../../../helpers/users'; interface Props { - currentUser: CurrentUser; + currentUser: T.CurrentUser; organization?: { key: string }; query?: RawQuery; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/NoFavoriteProjects.tsx b/server/sonar-web/src/main/js/apps/projects/components/NoFavoriteProjects.tsx index 469007d6b14..c28dc6312b7 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/NoFavoriteProjects.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/NoFavoriteProjects.tsx @@ -28,11 +28,10 @@ import OrganizationListItem from '../../../components/ui/OrganizationListItem'; import { Button } from '../../../components/ui/buttons'; import { getMyOrganizations, Store } from '../../../store/rootReducer'; import { isSonarCloud } from '../../../helpers/system'; -import { Organization } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface StateProps { - organizations: Organization[]; + organizations: T.Organization[]; } export class NoFavoriteProjects extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx index 54cae091589..088be7ee8c8 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/PageHeader.tsx @@ -23,7 +23,6 @@ import PerspectiveSelect from './PerspectiveSelect'; import ProjectsSortingSelect from './ProjectsSortingSelect'; import SearchFilterContainer from '../filters/SearchFilterContainer'; import Tooltip from '../../../components/controls/Tooltip'; -import { CurrentUser, HomePageType } from '../../../app/types'; import HomePageSelect from '../../../components/controls/HomePageSelect'; import { translate } from '../../../helpers/l10n'; import { RawQuery } from '../../../helpers/query'; @@ -32,7 +31,7 @@ import { isSonarCloud } from '../../../helpers/system'; import { isLoggedIn } from '../../../helpers/users'; interface Props { - currentUser: CurrentUser; + currentUser: T.CurrentUser; isFavorite: boolean; loading: boolean; onPerspectiveChange: (x: { view: string; visualization?: string }) => void; @@ -104,9 +103,7 @@ export default function PageHeader(props: Props) { {showHomePageSelect && ( )} diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCard.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCard.tsx index e562aac058e..b1bd9138c4b 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCard.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCard.tsx @@ -21,11 +21,10 @@ import * as React from 'react'; import ProjectCardLeak from './ProjectCardLeak'; import ProjectCardOverall from './ProjectCardOverall'; import { Project } from '../types'; -import { Organization } from '../../../app/types'; interface Props { height: number; - organization: Organization | undefined; + organization: T.Organization | undefined; project: Project; type?: string; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.tsx index 790fd8ec979..2c703a27114 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.tsx @@ -21,12 +21,11 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import Tooltip from '../../../components/controls/Tooltip'; import { translate } from '../../../helpers/l10n'; -import { Languages } from '../../../app/types'; interface Props { className?: string; distribution?: string; - languages: Languages; + languages: T.Languages; } export default function ProjectCardLanguages({ className, distribution, languages }: Props) { @@ -65,7 +64,7 @@ export default function ProjectCardLanguages({ className, distribution, language ); } -function getLanguageName(languages: Languages, key: string): string { +function getLanguageName(languages: T.Languages, key: string): string { if (key === '') { return translate('unknown'); } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeak.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeak.tsx index fe1452872f4..bda94e978e3 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeak.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeak.tsx @@ -30,12 +30,11 @@ import PrivacyBadgeContainer from '../../../components/common/PrivacyBadgeContai import { translate, translateWithParameters } from '../../../helpers/l10n'; import { Project } from '../types'; import { formatDuration } from '../utils'; -import { Organization } from '../../../app/types'; import { getProjectUrl } from '../../../helpers/urls'; interface Props { height: number; - organization: Organization | undefined; + organization: T.Organization | undefined; project: Project; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.tsx index 264ef83813c..882c297ff8f 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.tsx @@ -28,12 +28,11 @@ import TagsList from '../../../components/tags/TagsList'; import PrivacyBadgeContainer from '../../../components/common/PrivacyBadgeContainer'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { Project } from '../types'; -import { Organization } from '../../../app/types'; import { getProjectUrl } from '../../../helpers/urls'; interface Props { height: number; - organization: Organization | undefined; + organization: T.Organization | undefined; project: Project; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectsList.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectsList.tsx index 3cb5f2fc575..8bb2f535070 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectsList.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectsList.tsx @@ -28,14 +28,13 @@ import EmptyFavoriteSearch from './EmptyFavoriteSearch'; import EmptySearch from '../../../components/common/EmptySearch'; import { Project } from '../types'; import { Query } from '../query'; -import { Organization, CurrentUser } from '../../../app/types'; interface Props { cardType?: string; - currentUser: CurrentUser; + currentUser: T.CurrentUser; isFavorite: boolean; isFiltered: boolean; - organization: Organization | undefined; + organization: T.Organization | undefined; projects: Project[]; query: Query; } diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx index f5beee0d39c..e3d269914db 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/DefaultPageSelector-test.tsx @@ -36,7 +36,6 @@ jest.mock('../../../../api/components', () => ({ import * as React from 'react'; import { mount } from 'enzyme'; import DefaultPageSelector from '../DefaultPageSelector'; -import { CurrentUser } from '../../../../app/types'; import { doAsync } from '../../../../helpers/testUtils'; const get = require('../../../../helpers/storage').get as jest.Mock; @@ -83,7 +82,7 @@ it('fetches favorites', () => { }); function mountRender( - currentUser: CurrentUser = { isLoggedIn: true }, + currentUser: T.CurrentUser = { isLoggedIn: true }, query: any = {}, replace: any = jest.fn() ) { diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/NoFavoriteProjects-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/NoFavoriteProjects-test.tsx index 01b07755388..0e0f2af3a93 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/NoFavoriteProjects-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/NoFavoriteProjects-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { NoFavoriteProjects } from '../NoFavoriteProjects'; -import { Visibility } from '../../../../app/types'; import { isSonarCloud } from '../../../../helpers/system'; jest.mock('../../../../helpers/system', () => ({ isSonarCloud: jest.fn() })); @@ -32,9 +31,9 @@ it('renders', () => { it('renders for SonarCloud', () => { (isSonarCloud as jest.Mock).mockImplementation(() => true); - const organizations = [ - { actions: { admin: true }, key: 'org1', name: 'org1', projectVisibility: Visibility.Public }, - { actions: { admin: false }, key: 'org2', name: 'org2', projectVisibility: Visibility.Public } + const organizations: T.Organization[] = [ + { actions: { admin: true }, key: 'org1', name: 'org1', projectVisibility: 'public' }, + { actions: { admin: false }, key: 'org2', name: 'org2', projectVisibility: 'public' } ]; expect(shallow()).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardLeak-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardLeak-test.tsx index 2eb69814db0..9376052bf6c 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardLeak-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardLeak-test.tsx @@ -20,7 +20,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ProjectCardLeak from '../ProjectCardLeak'; -import { Visibility } from '../../../../app/types'; +import { Project } from '../../types'; jest.mock( 'date-fns/difference_in_milliseconds', @@ -34,7 +34,7 @@ const MEASURES = { new_bugs: '12' }; -const PROJECT = { +const PROJECT: Project = { analysisDate: '2017-01-01', leakPeriodDate: '2016-12-01', key: 'foo', @@ -42,7 +42,7 @@ const PROJECT = { name: 'Foo', organization: { key: 'org', name: 'org' }, tags: [], - visibility: Visibility.Public + visibility: 'public' }; it('should display analysis date and leak start date', () => { @@ -68,7 +68,7 @@ it('should display tags', () => { }); it('should display private badge', () => { - const project = { ...PROJECT, visibility: Visibility.Private }; + const project: Project = { ...PROJECT, visibility: 'private' }; expect( shallow() .find('Connect(PrivacyBadge)') diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverall-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverall-test.tsx index f0c2736bde7..fe1685807d3 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverall-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverall-test.tsx @@ -20,7 +20,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ProjectCardOverall from '../ProjectCardOverall'; -import { Visibility } from '../../../../app/types'; +import { Project } from '../../types'; const MEASURES = { alert_status: 'OK', @@ -29,14 +29,14 @@ const MEASURES = { new_bugs: '12' }; -const PROJECT = { +const PROJECT: Project = { analysisDate: '2017-01-01', key: 'foo', measures: MEASURES, name: 'Foo', organization: { key: 'org', name: 'org' }, tags: [], - visibility: Visibility.Public + visibility: 'public' }; it('should display analysis date (and not leak period) when defined', () => { @@ -77,7 +77,7 @@ it('should display tags', () => { }); it('should display private badge', () => { - const project = { ...PROJECT, visibility: Visibility.Private }; + const project: Project = { ...PROJECT, visibility: 'private' }; expect( shallow() .find('Connect(PrivacyBadge)') diff --git a/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx b/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx index 7d875b5ae85..23a92e1cf35 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx @@ -27,11 +27,10 @@ import { getLanguageByKey } from '../../../store/languages'; import { translate } from '../../../helpers/l10n'; import { Facet } from '../types'; import { RawQuery } from '../../../helpers/query'; -import { Languages } from '../../../app/types'; interface Props { facet?: Facet; - languages: Languages; + languages: T.Languages; maxFacetValue?: number; onQueryChange: (change: RawQuery) => void; organization?: { key: string }; diff --git a/server/sonar-web/src/main/js/apps/projects/types.ts b/server/sonar-web/src/main/js/apps/projects/types.ts index e997ca3eae6..b77a627aedf 100644 --- a/server/sonar-web/src/main/js/apps/projects/types.ts +++ b/server/sonar-web/src/main/js/apps/projects/types.ts @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { Visibility } from '../../app/types'; export interface Project { analysisDate?: string; @@ -28,7 +27,7 @@ export interface Project { name: string; organization?: { key: string; name: string }; tags: string[]; - visibility: Visibility; + visibility: T.Visibility; } export interface Facet { diff --git a/server/sonar-web/src/main/js/apps/projects/utils.ts b/server/sonar-web/src/main/js/apps/projects/utils.ts index abc41aeb328..b1be8b79d6d 100644 --- a/server/sonar-web/src/main/js/apps/projects/utils.ts +++ b/server/sonar-web/src/main/js/apps/projects/utils.ts @@ -25,7 +25,6 @@ import { getOrganizations } from '../../api/organizations'; import { searchProjects, Facet } from '../../api/components'; import { getMeasuresForProjects } from '../../api/measures'; import { isDiffMetric, getPeriodValue } from '../../helpers/measures'; -import { Organization } from '../../app/types'; interface SortingOption { class?: string; @@ -164,7 +163,7 @@ export function parseSorting(sort: string): { sortValue: string; sortDesc: boole export function fetchProjects( query: Query, isFavorite: boolean, - organization: Organization | undefined, + organization: T.Organization | undefined, pageIndex = 1 ) { const ps = query.view === 'visualizations' ? PAGE_SIZE_VISUALIZATIONS : PAGE_SIZE; @@ -259,7 +258,7 @@ export function fetchProjectMeasures(projects: Array<{ key: string }>, query: Qu export function fetchProjectOrganizations( projects: Array<{ organization: string }>, - organization: Organization | undefined + organization: T.Organization | undefined ) { if (organization) { return Promise.resolve([organization]); diff --git a/server/sonar-web/src/main/js/apps/projects/visualizations/SimpleBubbleChart.tsx b/server/sonar-web/src/main/js/apps/projects/visualizations/SimpleBubbleChart.tsx index be1e6ee0f8c..c0c68a4c13d 100644 --- a/server/sonar-web/src/main/js/apps/projects/visualizations/SimpleBubbleChart.tsx +++ b/server/sonar-web/src/main/js/apps/projects/visualizations/SimpleBubbleChart.tsx @@ -27,7 +27,7 @@ import { getProjectUrl } from '../../../helpers/urls'; import { Project } from '../types'; import HelpTooltip from '../../../components/controls/HelpTooltip'; -export interface Metric { +interface Metric { key: string; type: string; } diff --git a/server/sonar-web/src/main/js/apps/projects/visualizations/__tests__/Risk-test.tsx b/server/sonar-web/src/main/js/apps/projects/visualizations/__tests__/Risk-test.tsx index 23d9bb2830c..35081887946 100644 --- a/server/sonar-web/src/main/js/apps/projects/visualizations/__tests__/Risk-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/visualizations/__tests__/Risk-test.tsx @@ -20,15 +20,15 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import Risk from '../Risk'; -import { Visibility } from '../../../../app/types'; +import { Project } from '../../types'; it('renders', () => { - const project1 = { + const project1: Project = { key: 'foo', measures: { complexity: '17.2', coverage: '53.5', ncloc: '1734' }, name: 'Foo', tags: [], - visibility: Visibility.Public + visibility: 'public' }; expect( shallow() diff --git a/server/sonar-web/src/main/js/apps/projects/visualizations/__tests__/SimpleBubbleChart-test.tsx b/server/sonar-web/src/main/js/apps/projects/visualizations/__tests__/SimpleBubbleChart-test.tsx index e5b3f083975..0adf159c4a5 100644 --- a/server/sonar-web/src/main/js/apps/projects/visualizations/__tests__/SimpleBubbleChart-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/visualizations/__tests__/SimpleBubbleChart-test.tsx @@ -20,15 +20,15 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import SimpleBubbleChart from '../SimpleBubbleChart'; -import { Visibility } from '../../../../app/types'; +import { Project } from '../../types'; it('renders', () => { - const project1 = { + const project1: Project = { key: 'foo', measures: { complexity: '17.2', coverage: '53.5', ncloc: '1734', security_rating: '2' }, name: 'Foo', tags: [], - visibility: Visibility.Public + visibility: 'public' }; expect( shallow( diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/App.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/App.tsx index 4df65fc78df..293e9f98836 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/App.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/App.tsx @@ -27,15 +27,14 @@ import CreateProjectForm from './CreateProjectForm'; import ListFooter from '../../components/controls/ListFooter'; import Suggestions from '../../app/components/embed-docs-modal/Suggestions'; import { getComponents, Project } from '../../api/components'; -import { Organization, Visibility } from '../../app/types'; import { toNotSoISOString } from '../../helpers/dates'; import { translate } from '../../helpers/l10n'; export interface Props { currentUser: { login: string }; hasProvisionPermission?: boolean; - onVisibilityChange: (visibility: Visibility) => void; - organization: Organization; + onVisibilityChange: (visibility: T.Visibility) => void; + organization: T.Organization; topLevelQualifiers: string[]; } @@ -50,7 +49,7 @@ interface State { ready: boolean; selection: string[]; total: number; - visibility?: Visibility; + visibility?: T.Visibility; } const PAGE_SIZE = 50; @@ -138,7 +137,7 @@ export default class App extends React.PureComponent { ); }; - onVisibilityChanged = (newVisibility: Visibility | 'all') => { + onVisibilityChanged = (newVisibility: T.Visibility | 'all') => { this.setState( { ready: false, diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/AppContainer.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/AppContainer.tsx index a932cbe7b5b..99437f0da4f 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/AppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/AppContainer.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { connect } from 'react-redux'; import App from './App'; import forSingleOrganization from '../organizations/forSingleOrganization'; -import { Organization, LoggedInUser, Visibility } from '../../app/types'; import { getAppState, getOrganizationByKey, getCurrentUser, Store } from '../../store/rootReducer'; import { receiveOrganizations } from '../../store/organizations'; import { changeProjectDefaultVisibility } from '../../api/permissions'; @@ -29,18 +28,18 @@ import { fetchOrganization } from '../organizations/actions'; interface StateProps { appState: { defaultOrganization: string; qualifiers: string[] }; - currentUser: LoggedInUser; - organization?: Organization; + currentUser: T.LoggedInUser; + organization?: T.Organization; } interface DispatchProps { fetchOrganization: (organization: string) => void; - onVisibilityChange: (organization: Organization, visibility: Visibility) => void; + onVisibilityChange: (organization: T.Organization, visibility: T.Visibility) => void; } interface OwnProps { onRequestFail: (error: any) => void; - organization: Organization; + organization: T.Organization; } class AppContainer extends React.PureComponent { @@ -52,7 +51,7 @@ class AppContainer extends React.PureComponent { + handleVisibilityChange = (visibility: T.Visibility) => { if (this.props.organization) { this.props.onVisibilityChange(this.props.organization, visibility); } @@ -82,12 +81,12 @@ class AppContainer extends React.PureComponent ({ appState: getAppState(state), - currentUser: getCurrentUser(state) as LoggedInUser, + currentUser: getCurrentUser(state) as T.LoggedInUser, organization: ownProps.organization || getOrganizationByKey(state, getAppState(state).defaultOrganization) }); -const onVisibilityChange = (organization: Organization, visibility: Visibility) => ( +const onVisibilityChange = (organization: T.Organization, visibility: T.Visibility) => ( dispatch: Function ) => { const currentVisibility = organization.projectVisibility; @@ -99,7 +98,7 @@ const onVisibilityChange = (organization: Organization, visibility: Visibility) const mapDispatchToProps = (dispatch: Function) => ({ fetchOrganization: (key: string) => dispatch(fetchOrganization(key)), - onVisibilityChange: (organization: Organization, visibility: Visibility) => + onVisibilityChange: (organization: T.Organization, visibility: T.Visibility) => dispatch(onVisibilityChange(organization, visibility)) }); diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx index 0e8fe28995c..77f52ddec6e 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/BulkApplyTemplateModal.tsx @@ -19,7 +19,6 @@ */ import * as React from 'react'; import { getPermissionTemplates, bulkApplyTemplate } from '../../api/permissions'; -import { PermissionTemplate } from '../../app/types'; import { translate, translateWithParameters } from '../../helpers/l10n'; import Modal from '../../components/controls/Modal'; import Select from '../../components/controls/Select'; @@ -42,7 +41,7 @@ interface State { done: boolean; loading: boolean; permissionTemplate?: string; - permissionTemplates?: PermissionTemplate[]; + permissionTemplates?: T.PermissionTemplate[]; submitting: boolean; } diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/ChangeVisibilityForm.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/ChangeVisibilityForm.tsx index 55ce40be1b9..04e41ea9b39 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/ChangeVisibilityForm.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/ChangeVisibilityForm.tsx @@ -21,25 +21,24 @@ import * as React from 'react'; import * as classNames from 'classnames'; import UpgradeOrganizationBox from '../../components/common/UpgradeOrganizationBox'; import Modal from '../../components/controls/Modal'; -import { Organization, Visibility } from '../../app/types'; import { Button, ResetButtonLink } from '../../components/ui/buttons'; import { translate } from '../../helpers/l10n'; import { Alert } from '../../components/ui/Alert'; export interface Props { onClose: () => void; - onConfirm: (visiblity: Visibility) => void; - organization: Organization; + onConfirm: (visiblity: T.Visibility) => void; + organization: T.Organization; } interface State { - visibility: Visibility; + visibility: T.Visibility; } export default class ChangeVisibilityForm extends React.PureComponent { constructor(props: Props) { super(props); - this.state = { visibility: props.organization.projectVisibility as Visibility }; + this.state = { visibility: props.organization.projectVisibility as T.Visibility }; } handleConfirmClick = () => { @@ -50,7 +49,7 @@ export default class ChangeVisibilityForm extends React.PureComponent) => { event.preventDefault(); event.currentTarget.blur(); - const visibility = event.currentTarget.dataset.visibility as Visibility; + const visibility = event.currentTarget.dataset.visibility as T.Visibility; this.setState({ visibility }); }; @@ -63,11 +62,10 @@ export default class ChangeVisibilityForm extends React.PureComponent
    - {[Visibility.Public, Visibility.Private].map(visibility => ( + {['public', 'private'].map(visibility => (

    - {visibility === Visibility.Private && - !organization.canUpdateProjectsVisibilityToPrivate ? ( + {visibility === 'private' && !organization.canUpdateProjectsVisibilityToPrivate ? ( void; onProjectCreated: () => void; - organization: Organization; + organization: T.Organization; } interface State { @@ -41,7 +40,7 @@ interface State { key: string; loading: boolean; name: string; - visibility?: Visibility; + visibility?: T.Visibility; // add index declaration to be able to do `this.setState({ [name]: value });` [x: string]: any; } @@ -82,7 +81,7 @@ export default class CreateProjectForm extends React.PureComponent this.setState({ [name]: value }); }; - handleVisibilityChange = (visibility: Visibility) => { + handleVisibilityChange = (visibility: T.Visibility) => { this.setState({ visibility }); }; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx index 4d75c04cc18..70d207a00c4 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Header.tsx @@ -19,7 +19,6 @@ */ import * as React from 'react'; import ChangeVisibilityForm from './ChangeVisibilityForm'; -import { Organization, Visibility } from '../../app/types'; import { EditButton, Button } from '../../components/ui/buttons'; import { translate } from '../../helpers/l10n'; import { isSonarCloud } from '../../helpers/system'; @@ -27,8 +26,8 @@ import { isSonarCloud } from '../../helpers/system'; export interface Props { hasProvisionPermission?: boolean; onProjectCreate: () => void; - onVisibilityChange: (visibility: Visibility) => void; - organization: Organization; + onVisibilityChange: (visibility: T.Visibility) => void; + organization: T.Organization; } interface State { diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Projects.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Projects.tsx index 09add750d94..5ad0ae99ba2 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Projects.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Projects.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import * as classNames from 'classnames'; import ProjectRow from './ProjectRow'; -import { Organization } from '../../app/types'; import { translate } from '../../helpers/l10n'; import { Project } from '../../api/components'; @@ -28,7 +27,7 @@ interface Props { currentUser: { login: string }; onProjectDeselected: (project: string) => void; onProjectSelected: (project: string) => void; - organization: Organization; + organization: T.Organization; projects: Project[]; ready?: boolean; selection: string[]; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx index f336153d976..eeb7e985832 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx @@ -29,7 +29,6 @@ import Select from '../../components/controls/Select'; import SearchBox from '../../components/controls/SearchBox'; import { Button } from '../../components/ui/buttons'; import { Project } from '../../api/components'; -import { Organization, Visibility } from '../../app/types'; import { translate } from '../../helpers/l10n'; export interface Props { @@ -42,7 +41,7 @@ export interface Props { onQualifierChanged: (qualifier: string) => void; onVisibilityChanged: (qualifier: string) => void; onSearch: (query: string) => void; - organization: Organization; + organization: T.Organization; projects: Project[]; provisioned: boolean; qualifiers: string; @@ -51,7 +50,7 @@ export interface Props { selection: any[]; topLevelQualifiers: string[]; total: number; - visibility?: Visibility; + visibility?: T.Visibility; } interface State { diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/App-test.tsx index 3299c3e33b4..f27f9b4eaf3 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/App-test.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import App, { Props } from '../App'; -import { Visibility } from '../../../app/types'; jest.mock('lodash', () => { const lodash = require.requireActual('lodash'); @@ -33,7 +32,7 @@ jest.mock('../../../api/components', () => ({ getComponents: jest.fn() })); const getComponents = require('../../../api/components').getComponents as jest.Mock; -const organization = { key: 'org', name: 'org', projectVisibility: Visibility.Public }; +const organization: T.Organization = { key: 'org', name: 'org', projectVisibility: 'public' }; const defaultSearchParameters = { organization: 'org', @@ -129,8 +128,8 @@ it('creates project', () => { it('changes default project visibility', () => { const onVisibilityChange = jest.fn(); const wrapper = shallowRender({ onVisibilityChange }); - wrapper.find('Header').prop('onVisibilityChange')(Visibility.Private); - expect(onVisibilityChange).toBeCalledWith(Visibility.Private); + wrapper.find('Header').prop('onVisibilityChange')('private'); + expect(onVisibilityChange).toBeCalledWith('private'); }); function shallowRender(props?: { [P in keyof Props]?: Props[P] }) { diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/ChangeVisibilityForm-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/ChangeVisibilityForm-test.tsx index 18fdae14861..d6f02e43602 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/ChangeVisibilityForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/ChangeVisibilityForm-test.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ChangeVisibilityForm from '../ChangeVisibilityForm'; import { click } from '../../../helpers/testUtils'; -import { Visibility } from '../../../app/types'; -const organization = { +const organization: T.Organization = { canUpdateProjectsVisibilityToPrivate: true, key: 'org', name: 'org', - projectVisibility: Visibility.Public + projectVisibility: 'public' }; it('renders disabled', () => { @@ -53,13 +52,13 @@ it('changes visibility', () => { click(wrapper.find('a[data-visibility="private"]'), { currentTarget: { blur() {}, - dataset: { visibility: Visibility.Private } + dataset: { visibility: 'private' } } }); expect(wrapper).toMatchSnapshot(); click(wrapper.find('.js-confirm')); - expect(onConfirm).toBeCalledWith(Visibility.Private); + expect(onConfirm).toBeCalledWith('private'); }); function shallowRender(props: Partial = {}) { diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/CreateProjectForm-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/CreateProjectForm-test.tsx index bc9e0ff3a6d..4fb4271cbff 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/CreateProjectForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/CreateProjectForm-test.tsx @@ -28,11 +28,10 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import CreateProjectForm from '../CreateProjectForm'; import { change, submit, waitAndUpdate } from '../../../helpers/testUtils'; -import { Visibility } from '../../../app/types'; const createProject = require('../../../api/components').createProject as jest.Mock; -const organization = { key: 'org', name: 'org', projectVisibility: Visibility.Public }; +const organization: T.Organization = { key: 'org', name: 'org', projectVisibility: 'public' }; it('creates project', async () => { const wrapper = shallow( @@ -51,7 +50,7 @@ it('creates project', async () => { change(wrapper.find('input[name="key"]'), 'key', { currentTarget: { name: 'key', value: 'key' } }); - wrapper.find('VisibilitySelector').prop('onChange')(Visibility.Private); + wrapper.find('VisibilitySelector').prop('onChange')('private'); wrapper.update(); expect(wrapper).toMatchSnapshot(); @@ -60,7 +59,7 @@ it('creates project', async () => { name: 'name', organization: 'org', project: 'key', - visibility: Visibility.Private + visibility: 'private' }); expect(wrapper).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Header-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Header-test.tsx index 310e6246165..6eddf971a9f 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Header-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Header-test.tsx @@ -20,10 +20,9 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import Header, { Props } from '../Header'; -import { Visibility } from '../../../app/types'; import { click } from '../../../helpers/testUtils'; -const organization = { key: 'org', name: 'org', projectVisibility: Visibility.Public }; +const organization: T.Organization = { key: 'org', name: 'org', projectVisibility: 'public' }; it('renders', () => { expect(shallowRender()).toMatchSnapshot(); @@ -44,8 +43,8 @@ it('changes default visibility', () => { const modalWrapper = wrapper.find('ChangeVisibilityForm'); expect(modalWrapper).toMatchSnapshot(); - modalWrapper.prop('onConfirm')(Visibility.Private); - expect(onVisibilityChange).toBeCalledWith(Visibility.Private); + modalWrapper.prop('onConfirm')('private'); + expect(onVisibilityChange).toBeCalledWith('private'); modalWrapper.prop('onClose')(); wrapper.update(); diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/ProjectRow-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/ProjectRow-test.tsx index 140fae55d91..6cb6b4835b0 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/ProjectRow-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/ProjectRow-test.tsx @@ -20,13 +20,12 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ProjectRow from '../ProjectRow'; -import { Visibility } from '../../../app/types'; const project = { key: 'project', name: 'Project', qualifier: 'TRK', - visibility: Visibility.Private + visibility: 'private' }; it('renders', () => { diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/ProjectRowActions-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/ProjectRowActions-test.tsx index df159be98da..4b2046321c0 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/ProjectRowActions-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/ProjectRowActions-test.tsx @@ -20,8 +20,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ProjectRowActions, { Props } from '../ProjectRowActions'; -import { Visibility } from '../../../app/types'; import { click, waitAndUpdate } from '../../../helpers/testUtils'; +import { Project } from '../../../api/components'; jest.mock('../../../api/components', () => ({ getComponentShow: jest.fn(() => Promise.reject(undefined)) @@ -31,13 +31,13 @@ jest.mock('../../../api/nav', () => ({ getComponentNavigation: jest.fn(() => Promise.resolve()) })); -const project = { +const project: Project = { id: '', key: 'project', name: 'Project', organization: 'org', qualifier: 'TRK', - visibility: Visibility.Private + visibility: 'private' }; it('restores access', async () => { diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Projects-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Projects-test.tsx index 63a914ea80a..d1669a1f25f 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Projects-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Projects-test.tsx @@ -20,12 +20,11 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import Projects from '../Projects'; -import { Visibility } from '../../../app/types'; -const organization = { key: 'org', name: 'org', projectVisibility: Visibility.Public }; +const organization = { key: 'org', name: 'org', projectVisibility: 'public' }; const projects = [ - { key: 'a', name: 'A', qualifier: 'TRK', visibility: Visibility.Public }, - { key: 'b', name: 'B', qualifier: 'TRK', visibility: Visibility.Public } + { key: 'a', name: 'A', qualifier: 'TRK', visibility: 'public' }, + { key: 'b', name: 'B', qualifier: 'TRK', visibility: 'public' } ]; const selection = ['a']; diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Search-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Search-test.tsx index f8081a89174..018dc396858 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Search-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Search-test.tsx @@ -21,9 +21,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import Search, { Props } from '../Search'; import { click } from '../../../helpers/testUtils'; -import { Visibility } from '../../../app/types'; -const organization = { key: 'org', name: 'org', projectVisibility: Visibility.Public }; +const organization: T.Organization = { key: 'org', name: 'org', projectVisibility: 'public' }; it('renders', () => { expect(shallowRender()).toMatchSnapshot(); diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/AddConditionSelect.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/AddConditionSelect.tsx index 9b9f416c3d3..22226b306ed 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/AddConditionSelect.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/AddConditionSelect.tsx @@ -21,11 +21,10 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import Select from '../../../components/controls/Select'; import { translate, getLocalizedMetricName, getLocalizedMetricDomain } from '../../../helpers/l10n'; -import { Metric } from '../../../app/types'; interface Props { - metrics: Metric[]; - onAddCondition: (metric: Metric) => void; + metrics: T.Metric[]; + onAddCondition: (metric: T.Metric) => void; } interface State { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx index 284a0e876d5..af9f13c9a51 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Condition.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import ConditionOperator from './ConditionOperator'; import Period from './Period'; import ConditionModal from './ConditionModal'; -import { Condition as ICondition, Metric, QualityGate } from '../../../app/types'; import ActionsDropdown, { ActionsDropdownItem } from '../../../components/controls/ActionsDropdown'; import { translate, getLocalizedMetricName, translateWithParameters } from '../../../helpers/l10n'; import { formatMeasure } from '../../../helpers/measures'; @@ -29,13 +28,13 @@ import ConfirmModal from '../../../components/controls/ConfirmModal'; import { deleteCondition } from '../../../api/quality-gates'; interface Props { - condition: ICondition; + condition: T.Condition; canEdit: boolean; - metric: Metric; + metric: T.Metric; organization?: string; - onRemoveCondition: (Condition: ICondition) => void; - onSaveCondition: (newCondition: ICondition, oldCondition: ICondition) => void; - qualityGate: QualityGate; + onRemoveCondition: (Condition: T.Condition) => void; + onSaveCondition: (newCondition: T.Condition, oldCondition: T.Condition) => void; + qualityGate: T.QualityGate; } interface State { @@ -60,7 +59,7 @@ export default class Condition extends React.PureComponent { }; } - handleUpdateCondition = (newCondition: ICondition) => { + handleUpdateCondition = (newCondition: T.Condition) => { this.props.onSaveCondition(newCondition, this.props.condition); }; @@ -80,7 +79,7 @@ export default class Condition extends React.PureComponent { this.setState({ deleteFormOpen: false }); }; - removeCondition = (condition: ICondition) => { + removeCondition = (condition: T.Condition) => { deleteCondition({ id: condition.id, organization: this.props.organization }).then( () => this.props.onRemoveCondition(condition), () => {} diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx index 5c11c927d00..86a1706430e 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionModal.tsx @@ -23,7 +23,6 @@ import ConditionOperator from './ConditionOperator'; import ThresholdInput from './ThresholdInput'; import Period from './Period'; import { translate, getLocalizedMetricName } from '../../../helpers/l10n'; -import { Metric, QualityGate, Condition, Omit } from '../../../app/types'; import { createCondition, updateCondition } from '../../../api/quality-gates'; import { isDiffMetric } from '../../../helpers/measures'; import { parseError } from '../../../helpers/request'; @@ -31,20 +30,20 @@ import ConfirmModal from '../../../components/controls/ConfirmModal'; import { Alert } from '../../../components/ui/Alert'; interface Props { - condition?: Condition; - metric?: Metric; - metrics?: Metric[]; + condition?: T.Condition; + metric?: T.Metric; + metrics?: T.Metric[]; header: string; - onAddCondition: (condition: Condition) => void; + onAddCondition: (condition: T.Condition) => void; onClose: () => void; organization?: string; - qualityGate: QualityGate; + qualityGate: T.QualityGate; } interface State { error: string; errorMessage?: string; - metric?: Metric; + metric?: T.Metric; op?: string; period: boolean; warning: string; @@ -72,8 +71,8 @@ export default class ConditionModal extends React.PureComponent { this.mounted = false; } - getUpdatedCondition = (metric: Metric) => { - const data: Omit = { + getUpdatedCondition = (metric: T.Metric) => { + const data: T.Omit = { metric: metric.key, op: metric.type === 'RATING' ? 'GT' : this.state.op, warning: this.state.warning, @@ -95,7 +94,7 @@ export default class ConditionModal extends React.PureComponent { if (this.state.metric) { const { condition, qualityGate, organization } = this.props; const newCondition = this.getUpdatedCondition(this.state.metric); - let submitPromise: Promise; + let submitPromise: Promise; if (condition) { submitPromise = updateCondition({ organization, id: condition.id, ...newCondition }); } else { @@ -113,7 +112,7 @@ export default class ConditionModal extends React.PureComponent { return Promise.reject('No metric selected'); }; - handleChooseType = (metric: Metric) => { + handleChooseType = (metric: T.Metric) => { this.setState({ metric }); }; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionOperator.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionOperator.tsx index 526813bde06..125b5110d9f 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionOperator.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/ConditionOperator.tsx @@ -19,13 +19,12 @@ */ import * as React from 'react'; import Select from '../../../components/controls/Select'; -import { Metric } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { op?: string; canEdit: boolean; - metric: Metric; + metric: T.Metric; onOperatorChange?: (op: string) => void; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx index fd422093e2f..6fa018479e0 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Conditions.tsx @@ -23,24 +23,23 @@ import Condition from './Condition'; import ConditionModal from './ConditionModal'; import DocTooltip from '../../../components/docs/DocTooltip'; import { translate, getLocalizedMetricName } from '../../../helpers/l10n'; -import { Condition as ICondition, Metric, QualityGate } from '../../../app/types'; import ModalButton from '../../../components/controls/ModalButton'; import { Button } from '../../../components/ui/buttons'; import { Alert } from '../../../components/ui/Alert'; interface Props { canEdit: boolean; - conditions: ICondition[]; - metrics: { [key: string]: Metric }; - onAddCondition: (condition: ICondition) => void; - onSaveCondition: (newCondition: ICondition, oldCondition: ICondition) => void; - onRemoveCondition: (Condition: ICondition) => void; + conditions: T.Condition[]; + metrics: { [key: string]: T.Metric }; + onAddCondition: (condition: T.Condition) => void; + onSaveCondition: (newCondition: T.Condition, oldCondition: T.Condition) => void; + onRemoveCondition: (Condition: T.Condition) => void; organization?: string; - qualityGate: QualityGate; + qualityGate: T.QualityGate; } export default class Conditions extends React.PureComponent { - getConditionKey = (condition: ICondition, index: number) => { + getConditionKey = (condition: T.Condition, index: number) => { return condition.id ? condition.id : `new-${index}`; }; @@ -54,7 +53,7 @@ export default class Conditions extends React.PureComponent { condition => metrics[condition.metric] && metrics[condition.metric].name ); - const duplicates: ICondition[] = []; + const duplicates: T.Condition[] = []; const savedConditions = existingConditions.filter(condition => condition.id != null); savedConditions.forEach(condition => { const sameCount = savedConditions.filter( diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx index 0d95becd65d..b7e2c9831d2 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx @@ -23,13 +23,12 @@ import { copyQualityGate } from '../../../api/quality-gates'; import ConfirmModal from '../../../components/controls/ConfirmModal'; import { translate } from '../../../helpers/l10n'; import { getQualityGateUrl } from '../../../helpers/urls'; -import { QualityGate } from '../../../app/types'; interface Props { onClose: () => void; onCopy: () => Promise; organization?: string; - qualityGate: QualityGate; + qualityGate: T.QualityGate; } interface State { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DeleteQualityGateForm.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/DeleteQualityGateForm.tsx index 818b2d6d052..f523a4f12f1 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DeleteQualityGateForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DeleteQualityGateForm.tsx @@ -24,12 +24,11 @@ import ConfirmButton from '../../../components/controls/ConfirmButton'; import { Button } from '../../../components/ui/buttons'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getQualityGatesUrl } from '../../../helpers/urls'; -import { QualityGate } from '../../../app/types'; interface Props { onDelete: () => Promise; organization?: string; - qualityGate: QualityGate; + qualityGate: T.QualityGate; } export default class DeleteQualityGateForm extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsApp.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsApp.tsx index d09415b9c64..95bb2bcfb76 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsApp.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsApp.tsx @@ -26,19 +26,18 @@ import DetailsContent from './DetailsContent'; import { getMetrics, Store } from '../../../store/rootReducer'; import { fetchMetrics } from '../../../store/rootActions'; import { fetchQualityGate } from '../../../api/quality-gates'; -import { Metric, QualityGate, Condition } from '../../../app/types'; import { checkIfDefault, addCondition, replaceCondition, deleteCondition } from '../utils'; interface OwnProps { - onSetDefault: (qualityGate: QualityGate) => void; + onSetDefault: (qualityGate: T.QualityGate) => void; organization?: string; params: { id: number }; - qualityGates: QualityGate[]; + qualityGates: T.QualityGate[]; refreshQualityGates: () => Promise; } interface StateToProps { - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; } interface DispatchToProps { @@ -49,7 +48,7 @@ type Props = StateToProps & DispatchToProps & OwnProps; interface State { loading: boolean; - qualityGate?: QualityGate; + qualityGate?: T.QualityGate; } export class DetailsApp extends React.PureComponent { @@ -93,7 +92,7 @@ export class DetailsApp extends React.PureComponent { ); }; - handleAddCondition = (condition: Condition) => { + handleAddCondition = (condition: T.Condition) => { this.setState(({ qualityGate }) => { if (!qualityGate) { return null; @@ -102,7 +101,7 @@ export class DetailsApp extends React.PureComponent { }); }; - handleSaveCondition = (newCondition: Condition, oldCondition: Condition) => { + handleSaveCondition = (newCondition: T.Condition, oldCondition: T.Condition) => { this.setState(({ qualityGate }) => { if (!qualityGate) { return null; @@ -111,7 +110,7 @@ export class DetailsApp extends React.PureComponent { }); }; - handleRemoveCondition = (condition: Condition) => { + handleRemoveCondition = (condition: T.Condition) => { this.setState(({ qualityGate }) => { if (!qualityGate) { return null; @@ -126,7 +125,7 @@ export class DetailsApp extends React.PureComponent { return null; } this.props.onSetDefault(qualityGate); - const newQualityGate: QualityGate = { + const newQualityGate: T.QualityGate = { ...qualityGate, actions: { ...qualityGate.actions, delete: false, setAsDefault: false } }; diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.tsx index ea00c28f0ae..5d2b70f78e3 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsContent.tsx @@ -22,16 +22,15 @@ import Conditions from './Conditions'; import Projects from './Projects'; import DocTooltip from '../../../components/docs/DocTooltip'; import { translate } from '../../../helpers/l10n'; -import { Condition as ICondition, Metric, QualityGate } from '../../../app/types'; interface Props { isDefault?: boolean; - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; organization?: string; - onAddCondition: (condition: ICondition) => void; - onRemoveCondition: (Condition: ICondition) => void; - onSaveCondition: (newCondition: ICondition, oldCondition: ICondition) => void; - qualityGate: QualityGate; + onAddCondition: (condition: T.Condition) => void; + onRemoveCondition: (Condition: T.Condition) => void; + onSaveCondition: (newCondition: T.Condition, oldCondition: T.Condition) => void; + qualityGate: T.QualityGate; } export default class DetailsContent extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.tsx index 6f7343e0485..642619fe84a 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/DetailsHeader.tsx @@ -26,12 +26,11 @@ import ModalButton from '../../../components/controls/ModalButton'; import { setQualityGateAsDefault } from '../../../api/quality-gates'; import { Button } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; -import { QualityGate } from '../../../app/types'; interface Props { onSetDefault: () => void; organization?: string; - qualityGate: QualityGate; + qualityGate: T.QualityGate; refreshItem: () => Promise; refreshList: () => Promise; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Intro.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Intro.tsx index bbf59a9610d..fa5ec72b485 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Intro.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Intro.tsx @@ -20,12 +20,11 @@ import * as React from 'react'; import { InjectedRouter } from 'react-router'; import { translate } from '../../../helpers/l10n'; -import { QualityGate } from '../../../app/types'; import { getQualityGateUrl } from '../../../helpers/urls'; interface Props { organization?: string; - qualityGates: QualityGate[]; + qualityGates: T.QualityGate[]; router: InjectedRouter; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/List.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/List.tsx index 5586c52f22f..2adbb1518b0 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/List.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/List.tsx @@ -22,11 +22,10 @@ import { Link } from 'react-router'; import BuiltInQualityGateBadge from './BuiltInQualityGateBadge'; import { translate } from '../../../helpers/l10n'; import { getQualityGateUrl } from '../../../helpers/urls'; -import { QualityGate } from '../../../app/types'; interface Props { organization?: string; - qualityGates: QualityGate[]; + qualityGates: T.QualityGate[]; } export default function List({ organization, qualityGates }: Props) { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Period.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Period.tsx index fbb996c24da..1668dce7822 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Period.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Period.tsx @@ -19,13 +19,12 @@ */ import * as React from 'react'; import Checkbox from '../../../components/controls/Checkbox'; -import { Metric } from '../../../app/types'; import { isDiffMetric } from '../../../helpers/measures'; import { translate } from '../../../helpers/l10n'; interface Props { canEdit: boolean; - metric: Metric; + metric: T.Metric; onPeriodChange?: (checked: boolean) => void; period: boolean; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx index 8153ec3e3ca..77eafc27e7e 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/Projects.tsx @@ -26,12 +26,11 @@ import { associateGateWithProject, dissociateGateWithProject } from '../../../api/quality-gates'; -import { QualityGate } from '../../../app/types'; interface Props { canEdit?: boolean; organization?: string; - qualityGate: QualityGate; + qualityGate: T.QualityGate; } interface State { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.tsx index 07104d8db0e..56e3986f26c 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/QualityGatesApp.tsx @@ -27,7 +27,6 @@ import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import { fetchQualityGates } from '../../../api/quality-gates'; import { translate } from '../../../helpers/l10n'; import { getQualityGateUrl } from '../../../helpers/urls'; -import { Organization, QualityGate } from '../../../app/types'; import '../../../components/search-navigator.css'; import '../styles.css'; @@ -36,13 +35,13 @@ interface Props { organization?: string; refreshQualityGates: () => Promise; }>; - organization: Pick; + organization: Pick; } interface State { canCreate: boolean; loading: boolean; - qualityGates: QualityGate[]; + qualityGates: T.QualityGate[]; } export default class QualityGatesApp extends React.PureComponent { @@ -102,7 +101,7 @@ export default class QualityGatesApp extends React.PureComponent { ); }; - handleSetDefault = (qualityGate: QualityGate) => { + handleSetDefault = (qualityGate: T.QualityGate) => { this.setState(({ qualityGates }) => { return { qualityGates: qualityGates.map(candidate => { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/RenameQualityGateForm.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/RenameQualityGateForm.tsx index 852ed3fb40f..5c5f7292b78 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/RenameQualityGateForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/RenameQualityGateForm.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import ConfirmModal from '../../../components/controls/ConfirmModal'; import { renameQualityGate } from '../../../api/quality-gates'; import { translate } from '../../../helpers/l10n'; -import { QualityGate } from '../../../app/types'; interface Props { onClose: () => void; onRename: () => Promise; organization?: string; - qualityGate: QualityGate; + qualityGate: T.QualityGate; } interface State { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/ThresholdInput.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/ThresholdInput.tsx index f5c328f348a..ef7f7417793 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/ThresholdInput.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/ThresholdInput.tsx @@ -19,12 +19,11 @@ */ import * as React from 'react'; import Select from '../../../components/controls/Select'; -import { Metric } from '../../../app/types'; interface Props { name: string; value: string; - metric: Metric; + metric: T.Metric; onChange: (value: string) => void; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/utils.ts b/server/sonar-web/src/main/js/apps/quality-gates/utils.ts index 6279a475f12..b617fab89e2 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/utils.ts +++ b/server/sonar-web/src/main/js/apps/quality-gates/utils.ts @@ -18,30 +18,28 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { QualityGate, Condition } from '../../app/types'; - -export function checkIfDefault(qualityGate: QualityGate, list: QualityGate[]): boolean { +export function checkIfDefault(qualityGate: T.QualityGate, list: T.QualityGate[]): boolean { const finding = list.find(candidate => candidate.id === qualityGate.id); return (finding && finding.isDefault) || false; } -export function addCondition(qualityGate: QualityGate, condition: Condition): QualityGate { +export function addCondition(qualityGate: T.QualityGate, condition: T.Condition): T.QualityGate { const oldConditions = qualityGate.conditions || []; const conditions = [...oldConditions, condition]; return { ...qualityGate, conditions }; } -export function deleteCondition(qualityGate: QualityGate, condition: Condition): QualityGate { +export function deleteCondition(qualityGate: T.QualityGate, condition: T.Condition): T.QualityGate { const conditions = qualityGate.conditions && qualityGate.conditions.filter(candidate => candidate !== condition); return { ...qualityGate, conditions }; } export function replaceCondition( - qualityGate: QualityGate, - newCondition: Condition, - oldCondition: Condition -): QualityGate { + qualityGate: T.QualityGate, + newCondition: T.Condition, + oldCondition: T.Condition +): T.QualityGate { const conditions = qualityGate.conditions && qualityGate.conditions.map(candidate => { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx index dc123ff9963..28c7cd7d123 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx @@ -24,12 +24,11 @@ import { sortProfiles } from '../utils'; import { Exporter, Profile } from '../types'; import OrganizationHelmet from '../../../components/common/OrganizationHelmet'; import { translate } from '../../../helpers/l10n'; -import { Languages } from '../../../app/types'; import '../styles.css'; interface Props { children: React.ReactElement; - languages: Languages; + languages: T.Languages; organization: { name: string; key: string } | undefined; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx index ad88c22f0a1..b19ce402ff9 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissions.tsx @@ -128,7 +128,7 @@ export default class ProfilePermissions extends React.PureComponent { + handleGroupAdd = (addedGroup: T.Group) => { if (this.mounted) { this.setState((state: State) => ({ addUserForm: false, @@ -137,7 +137,7 @@ export default class ProfilePermissions extends React.PureComponent { + handleGroupDelete = (removedGroup: T.Group) => { if (this.mounted) { this.setState((state: State) => ({ groups: state.groups && state.groups.filter(group => group !== removedGroup) diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx index 038499c0fb2..ec7f000e6dd 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx @@ -29,11 +29,10 @@ import { getQualityProfile } from '../../../api/quality-profiles'; import { getRulesUrl } from '../../../helpers/urls'; import { translate } from '../../../helpers/l10n'; import { Profile } from '../types'; -import { RuleType } from '../../../app/types'; import { Button } from '../../../components/ui/buttons'; import DocTooltip from '../../../components/docs/DocTooltip'; -const TYPES = [RuleType.Bug, RuleType.Vulnerability, RuleType.CodeSmell, RuleType.Hotspot]; +const TYPES = ['BUG', 'VULNERABILITY', 'CODE_SMELL', 'SECURITY_HOTSPOT']; interface Props { organization: string | null; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRules-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRules-test.tsx index ef964aa5b01..3d7c0ff4bf1 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRules-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileRules-test.tsx @@ -23,7 +23,6 @@ import ProfileRules from '../ProfileRules'; import * as apiRules from '../../../../api/rules'; import * as apiQP from '../../../../api/quality-profiles'; import { waitAndUpdate } from '../../../../helpers/testUtils'; -import { RuleType } from '../../../../app/types'; const PROFILE = { activeRuleCount: 68, @@ -49,10 +48,10 @@ const apiResponseAll = { { property: 'types', values: [ - { val: RuleType.CodeSmell, count: 168 }, - { val: RuleType.Bug, count: 68 }, - { val: RuleType.Vulnerability, count: 7 }, - { val: RuleType.Hotspot, count: 10 } + { val: 'CODE_SMELL', count: 168 }, + { val: 'BUG', count: 68 }, + { val: 'VULNERABILITY', count: 7 }, + { val: 'SECURITY_HOTSPOT', count: 10 } ] } ] @@ -64,10 +63,10 @@ const apiResponseActive = { { property: 'types', values: [ - { val: RuleType.Bug, count: 68 }, - { val: RuleType.CodeSmell, count: 0 }, - { val: RuleType.Vulnerability, count: 0 }, - { val: RuleType.Hotspot, count: 0 } + { val: 'BUG', count: 68 }, + { val: 'CODE_SMELL', count: 0 }, + { val: 'VULNERABILITY', count: 0 }, + { val: 'SECURITY_HOTSPOT', count: 0 } ] } ] diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx index f0e4363e8dc..c3bf8c77f7a 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionRules.tsx @@ -25,11 +25,13 @@ import { translateWithParameters, translate } from '../../../helpers/l10n'; import { getRulesUrl } from '../../../helpers/urls'; import { toShortNotSoISOString } from '../../../helpers/dates'; import { formatMeasure } from '../../../helpers/measures'; -import { Rule, RuleActivation } from '../../../app/types'; const RULES_LIMIT = 10; -function parseRules(rules: Rule[], actives?: { [rule: string]: RuleActivation[] }): ExtendedRule[] { +function parseRules( + rules: T.Rule[], + actives?: { [rule: string]: T.RuleActivation[] } +): ExtendedRule[] { return rules.map(rule => { const activations = actives && actives[rule.key]; return { ...rule, activations: activations ? activations.length : 0 }; @@ -40,7 +42,7 @@ interface Props { organization: string | null; } -interface ExtendedRule extends Rule { +interface ExtendedRule extends T.Rule { activations: number; } diff --git a/server/sonar-web/src/main/js/apps/securityReports/components/App.tsx b/server/sonar-web/src/main/js/apps/securityReports/components/App.tsx index ed50bf28c72..8ab102b5744 100755 --- a/server/sonar-web/src/main/js/apps/securityReports/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/securityReports/components/App.tsx @@ -24,7 +24,6 @@ import { Link } from 'react-router'; import VulnerabilityList from './VulnerabilityList'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import { translate } from '../../../helpers/l10n'; -import { Component, BranchLike, SecurityHotspot } from '../../../app/types'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import Checkbox from '../../../components/controls/Checkbox'; import { RawQuery } from '../../../helpers/query'; @@ -37,15 +36,15 @@ import { Alert } from '../../../components/ui/Alert'; import '../style.css'; interface Props { - branchLike?: BranchLike; - component: Component; + branchLike?: T.BranchLike; + component: T.Component; location: { pathname: string; query: RawQuery }; params: { type: string }; } interface State { loading: boolean; - findings: Array; + findings: T.SecurityHotspot[]; hasVulnerabilities: boolean; type: StandardType; showCWE: boolean; diff --git a/server/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx b/server/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx index 28cbd625f14..8629b9d2639 100755 --- a/server/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx +++ b/server/sonar-web/src/main/js/apps/securityReports/components/VulnerabilityList.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import * as classNames from 'classnames'; import { Link } from 'react-router'; import { translate } from '../../../helpers/l10n'; -import { SecurityHotspot, Component, BranchLike, IssueType } from '../../../app/types'; import Rating from '../../../components/ui/Rating'; import { getComponentIssuesUrl, getRulesUrl } from '../../../helpers/urls'; import { getBranchLikeQuery } from '../../../helpers/branches'; @@ -43,9 +42,9 @@ import { isSonarCloud } from '../../../helpers/system'; import * as theme from '../../../app/theme'; interface Props { - branchLike?: BranchLike; - component: Component; - findings: SecurityHotspot[]; + branchLike?: T.BranchLike; + component: T.Component; + findings: T.SecurityHotspot[]; showCWE: boolean; type: StandardType; } @@ -86,7 +85,7 @@ export default class VulnerabilityList extends React.PureComponent ); }; - getName(finding: SecurityHotspot, type: StandardType) { + getName(finding: T.SecurityHotspot, type: StandardType) { const category = finding.category || finding.cwe || 'unknown'; const renderers = { owaspTop10: renderOwaspTop10Category, @@ -138,7 +137,7 @@ export default class VulnerabilityList extends React.PureComponent {translate('security_reports.activate_rules.link')} @@ -190,14 +189,14 @@ export default class VulnerabilityList extends React.PureComponent }; renderFinding( - finding: SecurityHotspot, + finding: T.SecurityHotspot, isCWE?: boolean, - parent?: SecurityHotspot + parent?: T.SecurityHotspot ): React.ReactFragment { const { branchLike, component, type } = this.props; const params: { [name: string]: string | undefined } = { ...getBranchLikeQuery(branchLike), - types: IssueType.Hotspot + types: 'SECURITY_HOTSPOT' }; if (isCWE && parent) { params['cwe'] = finding.cwe; @@ -224,7 +223,7 @@ export default class VulnerabilityList extends React.PureComponent finding.activeRules, { ...params, - types: IssueType.Vulnerability, + types: 'VULNERABILITY', resolved: 'false' }, finding.vulnerabilities, @@ -233,7 +232,7 @@ export default class VulnerabilityList extends React.PureComponent className="link-no-underline spacer-left" to={getComponentIssuesUrl(component.key, { ...params, - types: IssueType.Vulnerability, + types: 'VULNERABILITY', resolved: 'false' })}> @@ -247,7 +246,7 @@ export default class VulnerabilityList extends React.PureComponent finding.activeRules, { ...params, - types: IssueType.Hotspot, + types: 'SECURITY_HOTSPOT', resolved: 'false', statuses: 'OPEN,REOPENED' }, @@ -259,7 +258,7 @@ export default class VulnerabilityList extends React.PureComponent finding.activeRules, { ...params, - types: IssueType.Hotspot, + types: 'SECURITY_HOTSPOT', resolutions: 'FIXED', statuses: 'RESOLVED' }, @@ -271,7 +270,7 @@ export default class VulnerabilityList extends React.PureComponent finding.activeRules, { ...params, - types: IssueType.Hotspot, + types: 'SECURITY_HOTSPOT', resolutions: 'WONTFIX', statuses: 'RESOLVED' }, diff --git a/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx index 61c8f980517..b934385a71b 100644 --- a/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/App-test.tsx @@ -78,14 +78,13 @@ jest.mock('../../../../api/security-reports', () => ({ import * as React from 'react'; import { shallow } from 'enzyme'; -import { Component } from '../../../../app/types'; import App from '../App'; import { waitAndUpdate } from '../../../../helpers/testUtils'; const getSecurityHotspots = require('../../../../api/security-reports') .getSecurityHotspots as jest.Mock; -const component = { key: 'foo', name: 'Foo', qualifier: 'TRK' } as Component; +const component = { key: 'foo', name: 'Foo', qualifier: 'TRK' } as T.Component; const context = { router: { push: jest.fn() } }; const location = { pathname: 'foo', query: {} }; const locationWithCWE = { pathname: 'foo', query: { showCWE: 'true' } }; diff --git a/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/VulnerabilityList-test.tsx b/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/VulnerabilityList-test.tsx index 06f6ed58ae1..c9a8902b61a 100644 --- a/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/VulnerabilityList-test.tsx +++ b/server/sonar-web/src/main/js/apps/securityReports/components/__tests__/VulnerabilityList-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import VulnerabilityList from '../VulnerabilityList'; -import { Component } from '../../../../app/types'; jest.mock('../../../../helpers/standards.json', () => ({ default: { @@ -30,7 +29,7 @@ jest.mock('../../../../helpers/standards.json', () => ({ } })); -const component = { key: 'foo', name: 'Foo', qualifier: 'TRK' } as Component; +const component = { key: 'foo', name: 'Foo', qualifier: 'TRK' } as T.Component; const findings = [ { activeRules: 1, diff --git a/server/sonar-web/src/main/js/apps/sessions/components/EmailAlreadyExists.tsx b/server/sonar-web/src/main/js/apps/sessions/components/EmailAlreadyExists.tsx index e8bc0c13bae..411b0254014 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/EmailAlreadyExists.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/EmailAlreadyExists.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { getIdentityProviders } from '../../../api/users'; import * as theme from '../../../app/theme'; -import { IdentityProvider } from '../../../app/types'; import { getTextColor } from '../../../helpers/colors'; import { translate } from '../../../helpers/l10n'; import { getBaseUrl } from '../../../helpers/urls'; @@ -40,7 +39,7 @@ interface Props { } interface State { - identityProviders: IdentityProvider[]; + identityProviders: T.IdentityProvider[]; loading: boolean; } diff --git a/server/sonar-web/src/main/js/apps/sessions/components/Login.tsx b/server/sonar-web/src/main/js/apps/sessions/components/Login.tsx index 7af866cade5..2e7708d5f56 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/Login.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/Login.tsx @@ -20,12 +20,11 @@ import * as React from 'react'; import LoginForm from './LoginForm'; import OAuthProviders from './OAuthProviders'; -import { IdentityProvider } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; import './Login.css'; interface Props { - identityProviders: IdentityProvider[]; + identityProviders: T.IdentityProvider[]; onSubmit: (login: string, password: string) => Promise; returnTo: string; } diff --git a/server/sonar-web/src/main/js/apps/sessions/components/LoginContainer.tsx b/server/sonar-web/src/main/js/apps/sessions/components/LoginContainer.tsx index e676c44a2e9..68341e09285 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/LoginContainer.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/LoginContainer.tsx @@ -23,7 +23,6 @@ import Login from './Login'; import LoginSonarCloud from './LoginSonarCloud'; import { doLogin } from '../../../store/rootActions'; import { getIdentityProviders } from '../../../api/users'; -import { IdentityProvider } from '../../../app/types'; import { getReturnUrl } from '../../../helpers/urls'; import { isSonarCloud } from '../../../helpers/system'; @@ -42,7 +41,7 @@ interface DispatchToProps { type Props = OwnProps & DispatchToProps; interface State { - identityProviders?: IdentityProvider[]; + identityProviders?: T.IdentityProvider[]; } class LoginContainer extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/sessions/components/LoginSonarCloud.tsx b/server/sonar-web/src/main/js/apps/sessions/components/LoginSonarCloud.tsx index 8aa620c9ace..ce758229acc 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/LoginSonarCloud.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/LoginSonarCloud.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import * as classNames from 'classnames'; import LoginForm from './LoginForm'; import OAuthProviders from './OAuthProviders'; -import { IdentityProvider } from '../../../app/types'; import { getBaseUrl } from '../../../helpers/urls'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import './LoginSonarCloud.css'; interface Props { - identityProviders: IdentityProvider[]; + identityProviders: T.IdentityProvider[]; onSubmit: (login: string, password: string) => Promise; returnTo: string; showForm?: boolean; diff --git a/server/sonar-web/src/main/js/apps/sessions/components/OAuthProviders.tsx b/server/sonar-web/src/main/js/apps/sessions/components/OAuthProviders.tsx index 80ad700666e..cf52cab84cb 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/OAuthProviders.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/OAuthProviders.tsx @@ -23,13 +23,12 @@ import HelpTooltip from '../../../components/controls/HelpTooltip'; import IdentityProviderLink from '../../../components/ui/IdentityProviderLink'; import { translateWithParameters } from '../../../helpers/l10n'; import { getBaseUrl } from '../../../helpers/urls'; -import { IdentityProvider } from '../../../app/types'; import './OAuthProviders.css'; interface Props { className?: string; formatLabel?: (name: string) => React.ReactNode; - identityProviders: IdentityProvider[]; + identityProviders: T.IdentityProvider[]; returnTo: string; } @@ -53,7 +52,7 @@ export default function OAuthProviders(props: Props) { interface ItemProps { format: (name: string) => React.ReactNode; - identityProvider: IdentityProvider; + identityProvider: T.IdentityProvider; returnTo: string; } diff --git a/server/sonar-web/src/main/js/apps/sessions/components/UpdateLogin.tsx b/server/sonar-web/src/main/js/apps/sessions/components/UpdateLogin.tsx index 6aac2f2e318..ea03b8deb7a 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/UpdateLogin.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/UpdateLogin.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { getIdentityProviders } from '../../../api/users'; import * as theme from '../../../app/theme'; -import { IdentityProvider } from '../../../app/types'; import { getTextColor } from '../../../helpers/colors'; import { translate } from '../../../helpers/l10n'; import { getBaseUrl } from '../../../helpers/urls'; @@ -40,7 +39,7 @@ interface Props { } interface State { - identityProviders: IdentityProvider[]; + identityProviders: T.IdentityProvider[]; loading: boolean; } diff --git a/server/sonar-web/src/main/js/apps/settings/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/settings/__tests__/utils-test.ts index 53605d927a4..7bb1eb132cb 100644 --- a/server/sonar-web/src/main/js/apps/settings/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/settings/__tests__/utils-test.ts @@ -18,14 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getEmptyValue, getDefaultValue } from '../utils'; -import { SettingFieldDefinition, SettingCategoryDefinition, SettingType } from '../../../app/types'; const fields = [ - { key: 'foo', type: SettingType.String } as SettingFieldDefinition, - { key: 'bar', type: SettingType.SingleSelectList } as SettingFieldDefinition + { key: 'foo', type: 'STRING' } as T.SettingFieldDefinition, + { key: 'bar', type: 'SINGLE_SELECT_LIST' } as T.SettingFieldDefinition ]; -const settingDefinition: SettingCategoryDefinition = { +const settingDefinition: T.SettingCategoryDefinition = { category: 'test', fields: [], key: 'test', @@ -35,25 +34,37 @@ const settingDefinition: SettingCategoryDefinition = { describe('#getEmptyValue()', () => { it('should work for property sets', () => { - const setting = { ...settingDefinition, type: SettingType.PropertySet, fields }; + const setting: T.SettingCategoryDefinition = { + ...settingDefinition, + type: 'PROPERTY_SET', + fields + }; expect(getEmptyValue(setting)).toEqual([{ foo: '', bar: null }]); }); it('should work for multi values string', () => { - const setting = { ...settingDefinition, type: SettingType.String, multiValues: true }; + const setting: T.SettingCategoryDefinition = { + ...settingDefinition, + type: 'STRING', + multiValues: true + }; expect(getEmptyValue(setting)).toEqual(['']); }); it('should work for multi values boolean', () => { - const setting = { ...settingDefinition, type: SettingType.Boolean, multiValues: true }; + const setting: T.SettingCategoryDefinition = { + ...settingDefinition, + type: 'BOOLEAN', + multiValues: true + }; expect(getEmptyValue(setting)).toEqual([null]); }); }); describe('#getDefaultValue()', () => { const check = (parentValue?: string, expected?: string) => { - const setting = { - definition: { key: 'test', options: [], type: SettingType.Boolean }, + const setting: T.Setting = { + definition: { key: 'test', options: [], type: 'BOOLEAN' }, parentValue, key: 'test' }; diff --git a/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.tsx b/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.tsx index f01a2ed2b25..8118c2f0362 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/AllCategoriesList.tsx @@ -23,7 +23,6 @@ import { connect } from 'react-redux'; import { sortBy } from 'lodash'; import { IndexLink } from 'react-router'; import { getCategoryName } from '../utils'; -import { Component } from '../../../app/types'; import { getSettingsAppAllCategories, Store } from '../../../store/rootReducer'; interface Category { @@ -33,7 +32,7 @@ interface Category { interface Props { categories: string[]; - component?: Component; + component?: T.Component; defaultCategory: string; selectedCategory: string; } diff --git a/server/sonar-web/src/main/js/apps/settings/components/AppContainer.tsx b/server/sonar-web/src/main/js/apps/settings/components/AppContainer.tsx index 7a65fab906e..3950c150e0b 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/AppContainer.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/AppContainer.tsx @@ -29,12 +29,11 @@ import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import { fetchSettings } from '../store/actions'; import { getSettingsAppDefaultCategory, Store } from '../../../store/rootReducer'; import { translate } from '../../../helpers/l10n'; -import { Component } from '../../../app/types'; import '../styles.css'; import '../side-tabs.css'; interface Props { - component?: Component; + component?: T.Component; defaultCategory: string; fetchSettings(component?: string): Promise; } diff --git a/server/sonar-web/src/main/js/apps/settings/components/CategoryDefinitionsList.tsx b/server/sonar-web/src/main/js/apps/settings/components/CategoryDefinitionsList.tsx index 87f503f9ee8..f1ee1b717af 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/CategoryDefinitionsList.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/CategoryDefinitionsList.tsx @@ -21,11 +21,10 @@ import { connect } from 'react-redux'; import SubCategoryDefinitionsList from './SubCategoryDefinitionsList'; import { fetchValues } from '../store/actions'; import { getSettingsAppSettingsForCategory, Store } from '../../../store/rootReducer'; -import { Component } from '../../../app/types'; interface Props { category: string; - component?: Component; + component?: T.Component; } const mapStateToProps = (state: Store, ownProps: Props) => ({ diff --git a/server/sonar-web/src/main/js/apps/settings/components/Definition.tsx b/server/sonar-web/src/main/js/apps/settings/components/Definition.tsx index d9b9b34d837..10b87c4abb1 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/Definition.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/Definition.tsx @@ -39,19 +39,18 @@ import { isSettingsAppLoading, Store } from '../../../store/rootReducer'; -import { Component, Setting } from '../../../app/types'; interface Props { cancelChange: (key: string) => void; changedValue: any; changeValue: (key: string, value: any) => void; checkValue: (key: string) => boolean; - component?: Component; + component?: T.Component; loading: boolean; passValidation: (key: string) => void; resetValue: (key: string, component?: string) => Promise; saveValue: (key: string, component?: string) => Promise; - setting: Setting; + setting: T.Setting; validationMessage?: string; } diff --git a/server/sonar-web/src/main/js/apps/settings/components/DefinitionActions.tsx b/server/sonar-web/src/main/js/apps/settings/components/DefinitionActions.tsx index b7fab85c9ad..bc263cdeb7b 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/DefinitionActions.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/DefinitionActions.tsx @@ -22,7 +22,6 @@ import Modal from '../../../components/controls/Modal'; import { Button, ResetButtonLink, SubmitButton } from '../../../components/ui/buttons'; import { isEmptyValue, getDefaultValue, getSettingValue } from '../utils'; import { translate } from '../../../helpers/l10n'; -import { Setting } from '../../../app/types'; type Props = { changedValue: string; @@ -32,7 +31,7 @@ type Props = { onCancel: () => void; onReset: () => void; onSave: () => void; - setting: Setting; + setting: T.Setting; }; type State = { reseting: boolean }; diff --git a/server/sonar-web/src/main/js/apps/settings/components/DefinitionsList.tsx b/server/sonar-web/src/main/js/apps/settings/components/DefinitionsList.tsx index 2f597afc239..b5fd89edd9d 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/DefinitionsList.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/DefinitionsList.tsx @@ -19,11 +19,10 @@ */ import * as React from 'react'; import Definition from './Definition'; -import { Component, Setting } from '../../../app/types'; interface Props { - component?: Component; - settings: Setting[]; + component?: T.Component; + settings: T.Setting[]; } export default function DefinitionsList({ component, settings }: Props) { diff --git a/server/sonar-web/src/main/js/apps/settings/components/EmailForm.tsx b/server/sonar-web/src/main/js/apps/settings/components/EmailForm.tsx index f1516115bba..77e202c7cf6 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/EmailForm.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/EmailForm.tsx @@ -23,11 +23,10 @@ import { sendTestEmail } from '../../../api/settings'; import { parseError } from '../../../helpers/request'; import { SubmitButton } from '../../../components/ui/buttons'; import { Alert } from '../../../components/ui/Alert'; -import { LoggedInUser } from '../../../app/types'; import { withCurrentUser } from '../../../components/hoc/withCurrentUser'; interface Props { - currentUser: LoggedInUser; + currentUser: T.LoggedInUser; } interface State { diff --git a/server/sonar-web/src/main/js/apps/settings/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/settings/components/PageHeader.tsx index 18b2f644585..3aecf2f05f8 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/PageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/PageHeader.tsx @@ -20,10 +20,9 @@ import * as React from 'react'; import InstanceMessage from '../../../components/common/InstanceMessage'; import { translate } from '../../../helpers/l10n'; -import { Component } from '../../../app/types'; interface Props { - component?: Component; + component?: T.Component; } export default function PageHeader({ component }: Props) { diff --git a/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.tsx b/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.tsx index 34fa14caaa0..108997c3882 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/SubCategoryDefinitionsList.tsx @@ -22,13 +22,12 @@ import { groupBy, isEqual, sortBy } from 'lodash'; import DefinitionsList from './DefinitionsList'; import EmailForm from './EmailForm'; import { getSubCategoryName, getSubCategoryDescription } from '../utils'; -import { Component, SettingCategoryDefinition, Setting } from '../../../app/types'; interface Props { category: string; - component?: Component; + component?: T.Component; fetchValues: Function; - settings: Array; + settings: Array; } export default class SubCategoryDefinitionsList extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/DefinitionActions-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/__tests__/DefinitionActions-test.tsx index 432be0e9f3b..2bbe437983d 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/DefinitionActions-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/DefinitionActions-test.tsx @@ -21,9 +21,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import DefinitionActions from '../DefinitionActions'; -import { SettingType } from '../../../../app/types'; -const definition = { +const definition: T.SettingCategoryDefinition = { category: 'baz', description: 'lorem', fields: [], @@ -31,7 +30,7 @@ const definition = { name: 'foobar', options: [], subCategory: 'bar', - type: SettingType.String + type: 'STRING' }; const settings = { diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/Input.tsx b/server/sonar-web/src/main/js/apps/settings/components/inputs/Input.tsx index cbe09c0278d..1859d777515 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/Input.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/Input.tsx @@ -22,7 +22,6 @@ import PropertySetInput from './PropertySetInput'; import MultiValueInput from './MultiValueInput'; import PrimitiveInput from './PrimitiveInput'; import { DefaultInputProps, isCategoryDefinition } from '../../utils'; -import { SettingType } from '../../../../app/types'; export default function Input(props: DefaultInputProps) { const { definition } = props.setting; @@ -31,7 +30,7 @@ export default function Input(props: DefaultInputProps) { return ; } - if (definition.type === SettingType.PropertySet) { + if (definition.type === 'PROPERTY_SET') { return ; } diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/InputForSingleSelectList.tsx b/server/sonar-web/src/main/js/apps/settings/components/inputs/InputForSingleSelectList.tsx index 71466a83d18..f57fa5e98de 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/InputForSingleSelectList.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/InputForSingleSelectList.tsx @@ -20,9 +20,8 @@ import * as React from 'react'; import Select from '../../../../components/controls/Select'; import { DefaultSpecializedInputProps } from '../../utils'; -import { SettingCategoryDefinition } from '../../../../app/types'; -type Props = DefaultSpecializedInputProps & Pick; +type Props = DefaultSpecializedInputProps & Pick; export default class InputForSingleSelectList extends React.PureComponent { handleInputChange = ({ value }: { value: string }) => { diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/PrimitiveInput.tsx b/server/sonar-web/src/main/js/apps/settings/components/inputs/PrimitiveInput.tsx index 7f611e1e1a0..274cb51551b 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/PrimitiveInput.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/PrimitiveInput.tsx @@ -30,20 +30,19 @@ import { DefaultInputProps, DefaultSpecializedInputProps } from '../../utils'; -import { SettingType } from '../../../../app/types'; const typeMapping: { - [type in SettingType]?: + [type in T.SettingType]?: | React.ComponentClass | React.StatelessComponent } = { - [SettingType.String]: InputForString, - [SettingType.Text]: InputForText, - [SettingType.Password]: InputForPassword, - [SettingType.Boolean]: InputForBoolean, - [SettingType.Integer]: InputForNumber, - [SettingType.Long]: InputForNumber, - [SettingType.Float]: InputForNumber + STRING: InputForString, + TEXT: InputForText, + PASSWORD: InputForPassword, + BOOLEAN: InputForBoolean, + INTEGER: InputForNumber, + LONG: InputForNumber, + FLOAT: InputForNumber }; interface Props extends DefaultInputProps { @@ -57,7 +56,7 @@ export default class PrimitiveInput extends React.PureComponent { const name = this.props.name || getUniqueName(definition); - if (definition.type === SettingType.SingleSelectList) { + if (definition.type === 'SINGLE_SELECT_LIST') { return ( { @@ -58,9 +57,9 @@ it('should render MultiValueInput', () => { }); it('should render PropertySetInput', () => { - const setting = { + const setting: T.Setting = { ...settingValue, - definition: { ...settingDefinition, type: SettingType.PropertySet, fields: [] } + definition: { ...settingDefinition, type: 'PROPERTY_SET', fields: [] } }; const onChange = jest.fn(); diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/MultiValueInput-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/MultiValueInput-test.tsx index 2fab1a35ed0..6e4b2ed8b65 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/MultiValueInput-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/MultiValueInput-test.tsx @@ -23,20 +23,19 @@ import MultiValueInput from '../MultiValueInput'; import PrimitiveInput from '../PrimitiveInput'; import { click } from '../../../../../helpers/testUtils'; import { DefaultInputProps } from '../../../utils'; -import { SettingType } from '../../../../../app/types'; const settingValue = { key: 'example' }; -const settingDefinition = { +const settingDefinition: T.SettingCategoryDefinition = { category: 'general', fields: [], key: 'example', multiValues: true, options: [], subCategory: 'Branches', - type: SettingType.String + type: 'STRING' }; const assertValues = (inputs: ShallowWrapper, values: string[]) => { diff --git a/server/sonar-web/src/main/js/apps/settings/store/actions.ts b/server/sonar-web/src/main/js/apps/settings/store/actions.ts index d3b3526c06f..4636a8b5e26 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/actions.ts +++ b/server/sonar-web/src/main/js/apps/settings/store/actions.ts @@ -42,13 +42,12 @@ import { getSettingsAppChangedValue, Store } from '../../../store/rootReducer'; -import { SettingType } from '../../../app/types'; export function fetchSettings(component?: string) { return (dispatch: Dispatch) => { return getDefinitions(component).then(definitions => { const filtered = definitions - .filter(definition => definition.type !== SettingType.License) + .filter(definition => definition.type !== 'LICENSE') // do not display this setting on project level .filter( definition => !component || definition.key !== 'sonar.branch.longLivedBranches.regex' diff --git a/server/sonar-web/src/main/js/apps/settings/store/definitions.ts b/server/sonar-web/src/main/js/apps/settings/store/definitions.ts index fef242043bf..9871af85a50 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/definitions.ts +++ b/server/sonar-web/src/main/js/apps/settings/store/definitions.ts @@ -19,7 +19,6 @@ */ import { keyBy, sortBy, uniqBy } from 'lodash'; import { ActionType } from '../../../store/utils/actions'; -import { SettingCategoryDefinition } from '../../../app/types'; import { DEFAULT_CATEGORY, getCategoryName } from '../utils'; const enum Actions { @@ -29,10 +28,10 @@ const enum Actions { type Action = ActionType; export interface State { - [key: string]: SettingCategoryDefinition; + [key: string]: T.SettingCategoryDefinition; } -export function receiveDefinitions(definitions: SettingCategoryDefinition[]) { +export function receiveDefinitions(definitions: T.SettingCategoryDefinition[]) { return { type: Actions.ReceiveDefinitions, definitions }; } diff --git a/server/sonar-web/src/main/js/apps/settings/store/values.ts b/server/sonar-web/src/main/js/apps/settings/store/values.ts index e00727a86a5..023148c7a5b 100644 --- a/server/sonar-web/src/main/js/apps/settings/store/values.ts +++ b/server/sonar-web/src/main/js/apps/settings/store/values.ts @@ -21,7 +21,6 @@ import { combineReducers } from 'redux'; import { keyBy } from 'lodash'; import { ActionType } from '../../../store/utils/actions'; import { Action as AppStateAction, Actions as AppStateActions } from '../../../store/appState'; -import { SettingValue } from '../../../app/types'; enum Actions { receiveValues = 'RECEIVE_VALUES' @@ -30,7 +29,7 @@ enum Actions { type Action = ActionType; interface SettingsState { - [key: string]: SettingValue; + [key: string]: T.SettingValue; } export interface State { @@ -77,7 +76,11 @@ function global(state: State['components'] = {}, action: Action | AppStateAction export default combineReducers({ components, global }); -export function getValue(state: State, key: string, component?: string): SettingValue | undefined { +export function getValue( + state: State, + key: string, + component?: string +): T.SettingValue | undefined { if (component) { return state.components[component] && state.components[component][key]; } diff --git a/server/sonar-web/src/main/js/apps/settings/utils.ts b/server/sonar-web/src/main/js/apps/settings/utils.ts index 40abef3e3c8..baacdb76839 100644 --- a/server/sonar-web/src/main/js/apps/settings/utils.ts +++ b/server/sonar-web/src/main/js/apps/settings/utils.ts @@ -18,17 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { translate, hasMessage } from '../../helpers/l10n'; -import { - Omit, - Setting, - SettingCategoryDefinition, - SettingType, - SettingDefinition -} from '../../app/types'; export const DEFAULT_CATEGORY = 'general'; -export type DefaultSpecializedInputProps = Omit & { +export type DefaultSpecializedInputProps = T.Omit & { isDefault: boolean; name: string; }; @@ -38,16 +31,16 @@ export interface DefaultInputProps { onCancel?: () => void; onChange: (value: any) => void; onSave?: () => void; - setting: Setting; + setting: T.Setting; value: any; } -export function getPropertyName(definition: SettingDefinition) { +export function getPropertyName(definition: T.SettingDefinition) { const key = `property.${definition.key}.name`; return hasMessage(key) ? translate(key) : definition.name; } -export function getPropertyDescription(definition: SettingDefinition) { +export function getPropertyDescription(definition: T.SettingDefinition) { const key = `property.${definition.key}.description`; return hasMessage(key) ? translate(key) : definition.description; } @@ -67,66 +60,68 @@ export function getSubCategoryDescription(category: string, subCategory: string) return hasMessage(key) ? translate(key) : null; } -export function getUniqueName(definition: SettingDefinition, index?: string) { +export function getUniqueName(definition: T.SettingDefinition, index?: string) { const indexSuffix = index ? `[${index}]` : ''; return `settings[${definition.key}]${indexSuffix}`; } -export function getSettingValue({ definition, fieldValues, value, values }: Setting) { +export function getSettingValue({ definition, fieldValues, value, values }: T.Setting) { if (isCategoryDefinition(definition) && definition.multiValues) { return values; - } else if (definition.type === SettingType.PropertySet) { + } else if (definition.type === 'PROPERTY_SET') { return fieldValues; } else { return value; } } -export function isEmptyValue(definition: SettingDefinition, value: any) { +export function isEmptyValue(definition: T.SettingDefinition, value: any) { if (value == null) { return true; - } else if (definition.type === SettingType.Boolean) { + } else if (definition.type === 'BOOLEAN') { return false; } else { return value.length === 0; } } -export function isCategoryDefinition(item: SettingDefinition): item is SettingCategoryDefinition { +export function isCategoryDefinition( + item: T.SettingDefinition +): item is T.SettingCategoryDefinition { return Boolean((item as any).fields); } -export function getEmptyValue(item: SettingDefinition | SettingCategoryDefinition): any { +export function getEmptyValue(item: T.SettingDefinition | T.SettingCategoryDefinition): any { if (isCategoryDefinition(item)) { if (item.multiValues) { return [getEmptyValue({ ...item, multiValues: false })]; } - if (item.type === SettingType.PropertySet) { + if (item.type === 'PROPERTY_SET') { const value: { [key: string]: string } = {}; item.fields.forEach(field => (value[field.key] = getEmptyValue(field))); return [value]; } } - if (item.type === SettingType.Boolean || item.type === SettingType.SingleSelectList) { + if (item.type === 'BOOLEAN' || item.type === 'SINGLE_SELECT_LIST') { return null; } return ''; } -export function isDefaultOrInherited(setting: Setting) { +export function isDefaultOrInherited(setting: T.Setting) { return Boolean(setting.inherited); } -export function getDefaultValue(setting: Setting) { +export function getDefaultValue(setting: T.Setting) { const { definition, parentFieldValues, parentValue, parentValues } = setting; - if (definition.type === SettingType.Password) { + if (definition.type === 'PASSWORD') { return translate('settings.default.password'); } - if (definition.type === SettingType.Boolean && parentValue) { + if (definition.type === 'BOOLEAN' && parentValue) { const isTrue = parentValue === 'true'; return isTrue ? translate('settings.boolean.true') : translate('settings.boolean.false'); } @@ -140,11 +135,7 @@ export function getDefaultValue(setting: Setting) { return parentValues.join(', '); } - if ( - definition.type === SettingType.PropertySet && - parentFieldValues && - parentFieldValues.length > 0 - ) { + if (definition.type === 'PROPERTY_SET' && parentFieldValues && parentFieldValues.length > 0) { return translate('settings.default.complex_value'); } diff --git a/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/AnalyzeTutorial.tsx b/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/AnalyzeTutorial.tsx index 031af9848cd..6d2ce3130ef 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/AnalyzeTutorial.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/AnalyzeTutorial.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import AnalyzeTutorialSuggestion from './AnalyzeTutorialSuggestion'; import ProjectAnalysisStep from '../components/ProjectAnalysisStep'; import TokenStep from '../components/TokenStep'; -import { Component, LoggedInUser } from '../../../app/types'; import { isVSTS } from '../../../helpers/almIntegrations'; import { translate } from '../../../helpers/l10n'; import '../styles.css'; @@ -32,8 +31,8 @@ enum Steps { } interface Props { - component: Component; - currentUser: LoggedInUser; + component: T.Component; + currentUser: T.LoggedInUser; } interface State { diff --git a/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/__tests__/AnalyzeTutorial-test.tsx b/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/__tests__/AnalyzeTutorial-test.tsx index 17617b4b9db..3b8f8ca1433 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/__tests__/AnalyzeTutorial-test.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/__tests__/AnalyzeTutorial-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import AnalyzeTutorial from '../AnalyzeTutorial'; -import { LoggedInUser } from '../../../../app/types'; Date.now = jest.fn().mockReturnValue(1540457859031); @@ -34,7 +33,7 @@ const component = { version: '0.0.1' }; -const loggedInUser: LoggedInUser = { +const loggedInUser: T.LoggedInUser = { groups: [], isLoggedIn: true, login: 'luke', diff --git a/server/sonar-web/src/main/js/apps/tutorials/components/LanguageForm.tsx b/server/sonar-web/src/main/js/apps/tutorials/components/LanguageForm.tsx index 8762501b301..26e273e936a 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/components/LanguageForm.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/components/LanguageForm.tsx @@ -23,11 +23,10 @@ import NewProjectForm from './NewProjectForm'; import RadioToggle from '../../../components/controls/RadioToggle'; import { translate } from '../../../helpers/l10n'; import { isSonarCloud } from '../../../helpers/system'; -import { Component } from '../../../app/types'; import { isLanguageConfigured, LanguageConfig } from '../utils'; interface Props { - component?: Component; + component?: T.Component; config?: LanguageConfig; onDone: (config: LanguageConfig) => void; onReset: () => void; diff --git a/server/sonar-web/src/main/js/apps/tutorials/components/OrganizationStep.tsx b/server/sonar-web/src/main/js/apps/tutorials/components/OrganizationStep.tsx index 57c9ffb63d0..203b46cbeed 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/components/OrganizationStep.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/components/OrganizationStep.tsx @@ -32,7 +32,7 @@ import { Button } from '../../../components/ui/buttons'; type Selection = 'personal' | 'existing' | 'new'; interface Props { - currentUser: { login: string; isLoggedIn: boolean }; + currentUser: T.CurrentUser; finished: boolean; onOpen: () => void; onContinue: (organization: string) => void; diff --git a/server/sonar-web/src/main/js/apps/tutorials/components/ProjectAnalysisStep.tsx b/server/sonar-web/src/main/js/apps/tutorials/components/ProjectAnalysisStep.tsx index 3a924f2415e..e4887471654 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/components/ProjectAnalysisStep.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/components/ProjectAnalysisStep.tsx @@ -22,11 +22,10 @@ import Step from './Step'; import LanguageForm from './LanguageForm'; import AnalysisCommand from './commands/AnalysisCommand'; import { translate } from '../../../helpers/l10n'; -import { Component } from '../../../app/types'; import { LanguageConfig } from '../utils'; interface Props { - component?: Component; + component?: T.Component; displayRowLayout?: boolean; onFinish?: (projectKey?: string) => void; onReset?: () => void; diff --git a/server/sonar-web/src/main/js/apps/tutorials/components/commands/AnalysisCommand.tsx b/server/sonar-web/src/main/js/apps/tutorials/components/commands/AnalysisCommand.tsx index 9f40deec8cd..829463faae3 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/components/commands/AnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/components/commands/AnalysisCommand.tsx @@ -25,11 +25,10 @@ import Msvc from './Msvc'; import ClangGCC from './ClangGCC'; import Other from './Other'; import { getHostUrl } from '../../../../helpers/urls'; -import { Component } from '../../../../app/types'; import { LanguageConfig } from '../../utils'; interface Props { - component?: Component; + component?: T.Component; organization?: string; languageConfig: LanguageConfig; small?: boolean; diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/OnboardingModal.tsx b/server/sonar-web/src/main/js/apps/tutorials/onboarding/OnboardingModal.tsx index d7a8aa94acd..719ba4d4ba1 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/OnboardingModal.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/OnboardingModal.tsx @@ -26,7 +26,6 @@ import OnboardingProjectIcon from '../../../components/icons-components/Onboardi import OnboardingTeamIcon from '../../../components/icons-components/OnboardingTeamIcon'; import { Button, ResetButtonLink } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; -import { CurrentUser } from '../../../app/types'; import { getCurrentUser, Store } from '../../../store/rootReducer'; import { isLoggedIn } from '../../../helpers/users'; import '../styles.css'; @@ -39,7 +38,7 @@ interface OwnProps { } interface StateProps { - currentUser: CurrentUser; + currentUser: T.CurrentUser; } type Props = OwnProps & StateProps; diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/OnboardingPage.tsx b/server/sonar-web/src/main/js/apps/tutorials/onboarding/OnboardingPage.tsx index ae23029734e..7aa040268ff 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/OnboardingPage.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/OnboardingPage.tsx @@ -24,7 +24,6 @@ import { InjectedRouter } from 'react-router'; import OnboardingModal from './OnboardingModal'; import { skipOnboarding } from '../../../store/users'; import TeamOnboardingModal from '../teamOnboarding/TeamOnboardingModal'; -import { Organization } from '../../../app/types'; interface DispatchProps { skipOnboarding: () => void; @@ -55,7 +54,7 @@ export class OnboardingPage extends React.PureComponent) => { + closeOrganizationOnboarding = ({ key }: Pick) => { this.closeOnboarding(); this.props.router.push(`/organizations/${key}`); }; diff --git a/server/sonar-web/src/main/js/apps/tutorials/projectOnboarding/ProjectOnboarding.tsx b/server/sonar-web/src/main/js/apps/tutorials/projectOnboarding/ProjectOnboarding.tsx index 164f58ed467..e21b74aa1bb 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/projectOnboarding/ProjectOnboarding.tsx +++ b/server/sonar-web/src/main/js/apps/tutorials/projectOnboarding/ProjectOnboarding.tsx @@ -27,7 +27,6 @@ import OrganizationStep from '../components/OrganizationStep'; import TokenStep from '../components/TokenStep'; import handleRequiredAuthentication from '../../../app/utils/handleRequiredAuthentication'; import { getCurrentUser, areThereCustomOrganizations, Store } from '../../../store/rootReducer'; -import { CurrentUser } from '../../../app/types'; import { ResetButtonLink } from '../../../components/ui/buttons'; import { getProjectUrl } from '../../../helpers/urls'; import { translate, translateWithParameters } from '../../../helpers/l10n'; @@ -41,7 +40,7 @@ interface OwnProps { } interface StateProps { - currentUser: CurrentUser; + currentUser: T.CurrentUser; organizationsEnabled?: boolean; } @@ -199,7 +198,7 @@ export class ProjectOnboarding extends React.PureComponent { const mapStateToProps = (state: Store): StateProps => { return { - currentUser: getCurrentUser(state), + currentUser: getCurrentUser(state) as T.LoggedInUser, organizationsEnabled: areThereCustomOrganizations(state) }; }; 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 9c898e36ad6..e833d41cd55 100644 --- a/server/sonar-web/src/main/js/apps/users/UsersApp.tsx +++ b/server/sonar-web/src/main/js/apps/users/UsersApp.tsx @@ -28,7 +28,6 @@ import { parseQuery, Query, serializeQuery } from './utils'; import ListFooter from '../../components/controls/ListFooter'; import Suggestions from '../../app/components/embed-docs-modal/Suggestions'; import { getIdentityProviders, searchUsers } from '../../api/users'; -import { Paging, IdentityProvider, User } from '../../app/types'; import { translate } from '../../helpers/l10n'; interface Props { @@ -38,10 +37,10 @@ interface Props { } interface State { - identityProviders: IdentityProvider[]; + identityProviders: T.IdentityProvider[]; loading: boolean; - paging?: Paging; - users: User[]; + paging?: T.Paging; + users: T.User[]; } export default 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 cb91c04a60a..19eb40284b9 100644 --- a/server/sonar-web/src/main/js/apps/users/UsersList.tsx +++ b/server/sonar-web/src/main/js/apps/users/UsersList.tsx @@ -19,16 +19,15 @@ */ import * as React from 'react'; import UserListItem from './components/UserListItem'; -import { IdentityProvider, User } from '../../app/types'; import { translate } from '../../helpers/l10n'; interface Props { currentUser: { isLoggedIn: boolean; login?: string }; - identityProviders: IdentityProvider[]; + identityProviders: T.IdentityProvider[]; onUpdateUsers: () => void; organizationsEnabled?: boolean; updateTokensCount: (login: string, tokensCount: number) => void; - users: User[]; + users: T.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 062a463d444..8bb6d61728d 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 @@ -19,7 +19,6 @@ */ import * as React from 'react'; import { deactivateUser } from '../../../api/users'; -import { User } from '../../../app/types'; import Modal from '../../../components/controls/Modal'; import { SubmitButton, ResetButtonLink } from '../../../components/ui/buttons'; import { translate, translateWithParameters } from '../../../helpers/l10n'; @@ -27,7 +26,7 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; export interface Props { onClose: () => void; onUpdateUsers: () => void; - user: User; + user: T.User; } 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 c09f4297e9c..144ce96cf54 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 @@ -19,7 +19,6 @@ */ import * as React from 'react'; import { find, without } from 'lodash'; -import { User } from '../../../app/types'; import Modal from '../../../components/controls/Modal'; import SelectList, { Filter } from '../../../components/SelectList/SelectList'; import { translate } from '../../../helpers/l10n'; @@ -29,7 +28,7 @@ import { addUserToGroup, removeUserFromGroup } from '../../../api/user_groups'; interface Props { onClose: () => void; onUpdateUsers: () => void; - user: User; + user: T.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 5ee73668115..a937d9610fd 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 @@ -19,7 +19,6 @@ */ import * as React from 'react'; import { changePassword } from '../../../api/users'; -import { User } from '../../../app/types'; import addGlobalSuccessMessage from '../../../app/utils/addGlobalSuccessMessage'; import throwGlobalError from '../../../app/utils/throwGlobalError'; import Modal from '../../../components/controls/Modal'; @@ -30,7 +29,7 @@ import { Alert } from '../../../components/ui/Alert'; interface Props { isCurrentUser: boolean; - user: User; + user: T.User; onClose: () => void; } 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 6a96b785357..99a3eb5c1c9 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 @@ -19,12 +19,11 @@ */ import * as React from 'react'; import TokensForm from './TokensForm'; -import { User } from '../../../app/types'; import Modal from '../../../components/controls/Modal'; import { translate } from '../../../helpers/l10n'; interface Props { - user: User; + user: T.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 5c132436de1..84d6f05326e 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 @@ -21,7 +21,6 @@ import * as React from 'react'; import DeactivateForm from './DeactivateForm'; import PasswordForm from './PasswordForm'; import UserForm from './UserForm'; -import { User } from '../../../app/types'; import ActionsDropdown, { ActionsDropdownItem, ActionsDropdownDivider @@ -31,7 +30,7 @@ import { translate } from '../../../helpers/l10n'; interface Props { isCurrentUser: boolean; onUpdateUsers: () => void; - user: User; + user: T.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 381d58ff3df..05c2384a004 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 @@ -21,7 +21,6 @@ import * as React from 'react'; import { uniq } from 'lodash'; import UserScmAccountInput from './UserScmAccountInput'; import { createUser, updateUser } from '../../../api/users'; -import { User } from '../../../app/types'; import throwGlobalError from '../../../app/utils/throwGlobalError'; import Modal from '../../../components/controls/Modal'; import { Button, ResetButtonLink, SubmitButton } from '../../../components/ui/buttons'; @@ -30,7 +29,7 @@ import { parseError } from '../../../helpers/request'; import { Alert } from '../../../components/ui/Alert'; export interface Props { - user?: User; + user?: T.User; onClose: () => void; onUpdateUsers: () => void; } 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 53ab715e8da..2fc3ae5bc67 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 @@ -20,14 +20,13 @@ import * as React from 'react'; import GroupsForm from './GroupsForm'; import BulletListIcon from '../../../components/icons-components/BulletListIcon'; -import { User } from '../../../app/types'; import { ButtonIcon } from '../../../components/ui/buttons'; import { translate, translateWithParameters } from '../../../helpers/l10n'; interface Props { groups: string[]; onUpdateUsers: () => void; - user: User; + user: T.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 10d34f4a158..8e0c82dd167 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,19 +23,18 @@ import UserActions from './UserActions'; import UserGroups from './UserGroups'; import UserListItemIdentity from './UserListItemIdentity'; import UserScmAccounts from './UserScmAccounts'; -import { IdentityProvider, User } from '../../../app/types'; import BulletListIcon from '../../../components/icons-components/BulletListIcon'; import Avatar from '../../../components/ui/Avatar'; import { ButtonIcon } from '../../../components/ui/buttons'; import { translate } from '../../../helpers/l10n'; interface Props { - identityProvider?: IdentityProvider; + identityProvider?: T.IdentityProvider; isCurrentUser: boolean; onUpdateUsers: () => void; organizationsEnabled?: boolean; updateTokensCount: (login: string, tokensCount: number) => void; - user: User; + user: T.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 1d3ff144df0..4751d64b0ba 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 @@ -19,13 +19,12 @@ */ import * as React from 'react'; import * as theme from '../../../app/theme'; -import { IdentityProvider, User } from '../../../app/types'; import { getTextColor } from '../../../helpers/colors'; import { getBaseUrl } from '../../../helpers/urls'; interface Props { - identityProvider?: IdentityProvider; - user: User; + identityProvider?: T.IdentityProvider; + user: T.User; } export default function UserListItemIdentity({ identityProvider, user }: Props) { 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 e29280e7d14..37c21e0a5b6 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 @@ -24,17 +24,16 @@ import PageHeader from './PageHeader'; import WebhooksList from './WebhooksList'; import { createWebhook, deleteWebhook, searchWebhooks, updateWebhook } from '../../../api/webhooks'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; -import { LightComponent, Organization, Webhook } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - component?: LightComponent; - organization: Organization | undefined; + component?: T.LightComponent; + organization: T.Organization | undefined; } interface State { loading: boolean; - webhooks: Webhook[]; + webhooks: T.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 462df320caa..297d0a504e6 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 @@ -22,13 +22,12 @@ import { FormikProps } from 'formik'; import { isWebUri } from 'valid-url'; import ValidationModal from '../../../components/controls/ValidationModal'; import InputValidationField from '../../../components/controls/InputValidationField'; -import { Webhook } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { onClose: () => void; onDone: (data: { name: string; url: string }) => Promise; - webhook?: Webhook; + webhook?: T.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 4e177160af0..b8b63d4131b 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 @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Webhook } from '../../../app/types'; import SimpleModal from '../../../components/controls/SimpleModal'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import { SubmitButton, ResetButtonLink } from '../../../components/ui/buttons'; @@ -27,7 +26,7 @@ import { translate, translateWithParameters } from '../../../helpers/l10n'; interface Props { onClose: () => void; onSubmit: () => Promise; - webhook: Webhook; + webhook: T.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 c1622381057..d4ccf4b5427 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 @@ -23,19 +23,18 @@ import { Button } from '../../../components/ui/buttons'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import ListFooter from '../../../components/controls/ListFooter'; import Modal from '../../../components/controls/Modal'; -import { Webhook, WebhookDelivery, Paging } from '../../../app/types'; import { translateWithParameters, translate } from '../../../helpers/l10n'; import { searchDeliveries } from '../../../api/webhooks'; interface Props { onClose: () => void; - webhook: Webhook; + webhook: T.Webhook; } interface State { - deliveries: WebhookDelivery[]; + deliveries: T.WebhookDelivery[]; loading: boolean; - paging?: Paging; + paging?: T.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 c5994e7a1c1..45de010ffc3 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 @@ -24,10 +24,9 @@ import AlertSuccessIcon from '../../../components/icons-components/AlertSuccessI import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; import BoxedGroupAccordion from '../../../components/controls/BoxedGroupAccordion'; import { getDelivery } from '../../../api/webhooks'; -import { WebhookDelivery } from '../../../app/types'; interface Props { - delivery: WebhookDelivery; + delivery: T.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 06f661468dd..4809cea9fee 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,11 +22,10 @@ import CodeSnippet from '../../../components/common/CodeSnippet'; import DeferredSpinner from '../../../components/common/DeferredSpinner'; import { formatMeasure } from '../../../helpers/measures'; import { translateWithParameters, translate } from '../../../helpers/l10n'; -import { WebhookDelivery } from '../../../app/types'; interface Props { className?: string; - delivery: WebhookDelivery; + delivery: T.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 154dcd8e188..0cae97b03f5 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 @@ -21,14 +21,13 @@ import * as React from 'react'; import DeliveryItem from './DeliveryItem'; import { Button } from '../../../components/ui/buttons'; import Modal from '../../../components/controls/Modal'; -import { Webhook, WebhookDelivery } from '../../../app/types'; import { translateWithParameters, translate } from '../../../helpers/l10n'; import { getDelivery } from '../../../api/webhooks'; interface Props { - delivery: WebhookDelivery; + delivery: T.WebhookDelivery; onClose: () => void; - webhook: Webhook; + webhook: T.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 cfbeff267e3..8e318dc5b75 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 @@ -26,12 +26,11 @@ import ActionsDropdown, { ActionsDropdownDivider } from '../../../components/controls/ActionsDropdown'; import { translate } from '../../../helpers/l10n'; -import { Webhook } from '../../../app/types'; interface Props { onDelete: (webhook: string) => Promise; onUpdate: (data: { webhook: string; name: string; url: string }) => Promise; - webhook: Webhook; + webhook: T.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 3bd7e4aa4b2..d1632165b52 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 @@ -20,12 +20,11 @@ import * as React from 'react'; import WebhookItemLatestDelivery from './WebhookItemLatestDelivery'; import WebhookActions from './WebhookActions'; -import { Webhook } from '../../../app/types'; interface Props { onDelete: (webhook: string) => Promise; onUpdate: (data: { webhook: string; name: string; url: string }) => Promise; - webhook: Webhook; + webhook: T.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 417790dddeb..0e5525f8851 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,11 +24,10 @@ import AlertErrorIcon from '../../../components/icons-components/AlertErrorIcon' import AlertSuccessIcon from '../../../components/icons-components/AlertSuccessIcon'; import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; import { ButtonIcon } from '../../../components/ui/buttons'; -import { Webhook } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { - webhook: Webhook; + webhook: T.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 92e8f191c29..98003f79c25 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,13 +20,12 @@ import * as React from 'react'; import { sortBy } from 'lodash'; import WebhookItem from './WebhookItem'; -import { Webhook } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; interface Props { onDelete: (webhook: string) => Promise; onUpdate: (data: { webhook: string; name: string; url: string }) => Promise; - webhooks: Webhook[]; + webhooks: T.Webhook[]; } export default class WebhooksList extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/__tests__/App-test.tsx index 756f3830852..5a66a194451 100644 --- a/server/sonar-web/src/main/js/apps/webhooks/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/webhooks/components/__tests__/App-test.tsx @@ -26,7 +26,6 @@ import { searchWebhooks, updateWebhook } from '../../../../api/webhooks'; -import { Visibility } from '../../../../app/types'; jest.mock('../../../../api/webhooks', () => ({ createWebhook: jest.fn(() => @@ -44,7 +43,7 @@ jest.mock('../../../../api/webhooks', () => ({ updateWebhook: jest.fn(() => Promise.resolve()) })); -const organization = { key: 'foo', name: 'Foo', projectVisibility: Visibility.Private }; +const organization: T.Organization = { key: 'foo', name: 'Foo', projectVisibility: 'private' }; const component = { key: 'bar', organization: 'foo', qualifier: 'TRK' }; beforeEach(() => { 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 23dc626afc0..34ce61ab17e 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx @@ -37,16 +37,6 @@ import { getDuplications, getSources } from '../../api/components'; -import { - BranchLike, - DuplicatedFile, - Duplication, - FlowLocation, - Issue, - LinearIssueLocation, - SourceLine, - SourceViewerFile -} from '../../app/types'; import { isSameBranchLike, getBranchLikeQuery } from '../../helpers/branches'; import { translate } from '../../helpers/l10n'; import { Alert } from '../ui/Alert'; @@ -56,7 +46,7 @@ import './styles.css'; export interface Props { aroundLine?: number; - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; component: string; displayAllIssues?: boolean; displayIssueLocationsCount?: boolean; @@ -65,27 +55,27 @@ export interface Props { highlightedLine?: number; // `undefined` elements mean they are located in a different file, // but kept to maintaint the location indexes - highlightedLocations?: (FlowLocation | undefined)[]; + highlightedLocations?: (T.FlowLocation | undefined)[]; highlightedLocationMessage?: { index: number; text: string | undefined }; loadComponent: ( component: string, - branchLike: BranchLike | undefined - ) => Promise; + branchLike: T.BranchLike | undefined + ) => Promise; loadIssues: ( component: string, from: number, to: number, - branchLike: BranchLike | undefined - ) => Promise; + branchLike: T.BranchLike | undefined + ) => Promise; loadSources: ( component: string, from: number, to: number, - branchLike: BranchLike | undefined - ) => Promise; - onLoaded?: (component: SourceViewerFile, sources: SourceLine[], issues: Issue[]) => void; + branchLike: T.BranchLike | undefined + ) => Promise; + onLoaded?: (component: T.SourceViewerFile, sources: T.SourceLine[], issues: T.Issue[]) => void; onLocationSelect?: (index: number) => void; - onIssueChange?: (issue: Issue) => void; + onIssueChange?: (issue: T.Issue) => void; onIssueSelect?: (issueKey: string) => void; onIssueUnselect?: () => void; scroll?: (element: HTMLElement) => void; @@ -93,17 +83,17 @@ export interface Props { } interface State { - component?: SourceViewerFile; + component?: T.SourceViewerFile; displayDuplications: boolean; - duplicatedFiles?: { [ref: string]: DuplicatedFile }; - duplications?: Duplication[]; + duplicatedFiles?: { [ref: string]: T.DuplicatedFile }; + duplications?: T.Duplication[]; duplicationsByLine: { [line: number]: number[] }; hasSourcesAfter: boolean; highlightedSymbols: string[]; - issueLocationsByLine: { [line: number]: LinearIssueLocation[] }; + issueLocationsByLine: { [line: number]: T.LinearIssueLocation[] }; issuePopup?: { issue: string; name: string }; - issues?: Issue[]; - issuesByLine: { [line: number]: Issue[] }; + issues?: T.Issue[]; + issuesByLine: { [line: number]: T.Issue[] }; linePopup?: { index?: number; line: number; name: string }; loading: boolean; loadingSourcesAfter: boolean; @@ -113,7 +103,7 @@ interface State { openIssuesByLine: { [line: number]: boolean }; selectedIssue?: string; sourceRemoved: boolean; - sources?: SourceLine[]; + sources?: T.SourceLine[]; symbolsByLine: { [line: number]: string[] }; } @@ -206,7 +196,7 @@ export default class SourceViewerBase extends React.PureComponent this.mounted = false; } - computeCoverageStatus(lines: SourceLine[]) { + computeCoverageStatus(lines: T.SourceLine[]) { return lines.map(line => ({ ...line, coverageStatus: getCoverageStatus(line) })); } @@ -225,7 +215,7 @@ export default class SourceViewerBase extends React.PureComponent this.setState({ loading: true }); const to = (this.props.aroundLine || 0) + LINES; - const loadIssues = (component: SourceViewerFile, sources: SourceLine[]) => { + const loadIssues = (component: T.SourceViewerFile, sources: T.SourceLine[]) => { this.props.loadIssues(this.props.component, 1, to, this.props.branchLike).then( issues => { if (this.mounted) { @@ -278,7 +268,7 @@ export default class SourceViewerBase extends React.PureComponent } }; - const onFailLoadSources = (response: Response, component: SourceViewerFile) => { + const onFailLoadSources = (response: Response, component: T.SourceViewerFile) => { // TODO handle other statuses if (this.mounted) { if (response.status === 403) { @@ -289,7 +279,7 @@ export default class SourceViewerBase extends React.PureComponent } }; - const onResolve = (component: SourceViewerFile) => { + const onResolve = (component: T.SourceViewerFile) => { const sourcesRequest = component.q === 'FIL' || component.q === 'UTS' ? this.loadSources() : Promise.resolve([]); sourcesRequest.then( @@ -356,7 +346,7 @@ export default class SourceViewerBase extends React.PureComponent ); } - loadSources = (): Promise => { + loadSources = (): Promise => { return new Promise((resolve, reject) => { const onFailLoadSources = ({ response }: { response: Response }) => { // TODO handle other statuses @@ -479,7 +469,7 @@ export default class SourceViewerBase extends React.PureComponent ); }; - loadDuplications = (line: SourceLine) => { + loadDuplications = (line: T.SourceLine) => { getDuplications({ key: this.props.component, ...getBranchLikeQuery(this.props.branchLike) @@ -571,19 +561,19 @@ export default class SourceViewerBase extends React.PureComponent } }; - handleOpenIssues = (line: SourceLine) => { + handleOpenIssues = (line: T.SourceLine) => { this.setState(state => ({ openIssuesByLine: { ...state.openIssuesByLine, [line.line]: true } })); }; - handleCloseIssues = (line: SourceLine) => { + handleCloseIssues = (line: T.SourceLine) => { this.setState(state => ({ openIssuesByLine: { ...state.openIssuesByLine, [line.line]: false } })); }; - handleIssueChange = (issue: Issue) => { + handleIssueChange = (issue: T.Issue) => { this.setState(({ issues = [] }) => { const newIssues = issues.map(candidate => (candidate.key === issue.key ? issue : candidate)); return { issues: newIssues, issuesByLine: issuesByLine(newIssues) }; @@ -628,7 +618,7 @@ export default class SourceViewerBase extends React.PureComponent ); }; - renderCode(sources: SourceLine[]) { + renderCode(sources: T.SourceLine[]) { const hasSourcesBefore = sources.length > 0 && sources[0].line > 1; return ( } } -function defaultLoadComponent(component: string, branchLike: BranchLike | undefined) { +function defaultLoadComponent(component: string, branchLike: T.BranchLike | undefined) { return Promise.all([ getComponentForSourceViewer({ component, ...getBranchLikeQuery(branchLike) }), getComponentData({ component, ...getBranchLikeQuery(branchLike) }) @@ -739,7 +729,7 @@ function defaultLoadSources( key: string, from: number | undefined, to: number | undefined, - branchLike: BranchLike | undefined + branchLike: T.BranchLike | undefined ) { return getSources({ key, from, to, ...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 c1a034d4dc5..6f8c04ecb54 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx @@ -21,14 +21,6 @@ import * as React from 'react'; import { intersection } from 'lodash'; import Line from './components/Line'; import { getLinearLocations } from './helpers/issueLocations'; -import { - BranchLike, - Duplication, - FlowLocation, - Issue, - LinearIssueLocation, - SourceLine -} from '../../app/types'; import { translate } from '../../helpers/l10n'; import { Button } from '../ui/buttons'; @@ -42,13 +34,13 @@ const ZERO_LINE = { }; interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; componentKey: string; displayAllIssues?: boolean; displayIssueLocationsCount?: boolean; displayIssueLocationsLink?: boolean; displayLocationMarkers?: boolean; - duplications: Duplication[] | undefined; + duplications: T.Duplication[] | undefined; duplicationsByLine: { [line: number]: number[] }; hasSourcesAfter: boolean; hasSourcesBefore: boolean; @@ -56,23 +48,23 @@ 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: (FlowLocation | undefined)[] | undefined; + highlightedLocations: (T.FlowLocation | undefined)[] | undefined; highlightedSymbols: string[]; - issueLocationsByLine: { [line: number]: LinearIssueLocation[] }; + issueLocationsByLine: { [line: number]: T.LinearIssueLocation[] }; issuePopup: { issue: string; name: string } | undefined; - issues: Issue[] | undefined; - issuesByLine: { [line: number]: Issue[] }; + issues: T.Issue[] | undefined; + issuesByLine: { [line: number]: T.Issue[] }; linePopup: { index?: number; line: number; name: string } | undefined; - loadDuplications: (line: SourceLine) => void; + loadDuplications: (line: T.SourceLine) => void; loadingSourcesAfter: boolean; loadingSourcesBefore: boolean; loadSourcesAfter: () => void; loadSourcesBefore: () => void; - onIssueChange: (issue: Issue) => void; + onIssueChange: (issue: T.Issue) => void; onIssuePopupToggle: (issue: string, popupName: string, open?: boolean) => void; - onIssuesClose: (line: SourceLine) => void; + onIssuesClose: (line: T.SourceLine) => void; onIssueSelect: (issueKey: string) => void; - onIssuesOpen: (line: SourceLine) => void; + onIssuesOpen: (line: T.SourceLine) => void; onIssueUnselect: () => void; onLinePopupToggle: (x: { index?: number; line: number; name: string; open?: boolean }) => void; onLocationSelect: ((index: number) => void) | undefined; @@ -81,30 +73,30 @@ interface Props { renderDuplicationPopup: (index: number, line: number) => JSX.Element; scroll?: (element: HTMLElement) => void; selectedIssue: string | undefined; - sources: SourceLine[]; + sources: T.SourceLine[]; symbolsByLine: { [line: number]: string[] }; } export default class SourceViewerCode extends React.PureComponent { - getDuplicationsForLine = (line: SourceLine): number[] => { + getDuplicationsForLine = (line: T.SourceLine): number[] => { return this.props.duplicationsByLine[line.line] || EMPTY_ARRAY; }; - getIssuesForLine = (line: SourceLine): Issue[] => { + getIssuesForLine = (line: T.SourceLine): T.Issue[] => { return this.props.issuesByLine[line.line] || EMPTY_ARRAY; }; - getIssueLocationsForLine = (line: SourceLine): LinearIssueLocation[] => { + getIssueLocationsForLine = (line: T.SourceLine): T.LinearIssueLocation[] => { return this.props.issueLocationsByLine[line.line] || EMPTY_ARRAY; }; - getSecondaryIssueLocationsForLine = (line: SourceLine): LinearIssueLocation[] => { + getSecondaryIssueLocationsForLine = (line: T.SourceLine): T.LinearIssueLocation[] => { const { highlightedLocations } = this.props; if (!highlightedLocations) { return EMPTY_ARRAY; } return highlightedLocations.reduce((locations, location, index) => { - const linearLocations: LinearIssueLocation[] = location + const linearLocations: T.LinearIssueLocation[] = location ? getLinearLocations(location.textRange) .filter(l => l.line === line.line) .map(l => ({ ...l, startLine: location.textRange.startLine, index })) @@ -120,7 +112,7 @@ export default class SourceViewerCode extends React.PureComponent { displayDuplications, displayIssues }: { - line: SourceLine; + line: T.SourceLine; index: number; displayCoverage: boolean; displayDuplications: boolean; 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 36595d01856..5bf963a9fb1 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx @@ -22,7 +22,6 @@ import * as React from 'react'; import { Link } from 'react-router'; import * as PropTypes from 'prop-types'; import MeasuresOverlay from './components/MeasuresOverlay'; -import { SourceViewerFile, BranchLike } from '../../app/types'; import QualifierIcon from '../icons-components/QualifierIcon'; import Dropdown from '../controls/Dropdown'; import Favorite from '../controls/Favorite'; @@ -43,8 +42,8 @@ import { formatMeasure } from '../../helpers/measures'; import { omitNil } from '../../helpers/request'; interface Props { - branchLike: BranchLike | undefined; - sourceViewerFile: SourceViewerFile; + branchLike: T.BranchLike | undefined; + sourceViewerFile: T.SourceViewerFile; } interface State { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/CoveragePopup.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/CoveragePopup.tsx index cff05965304..f98d78c9376 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/CoveragePopup.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/CoveragePopup.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { groupBy } from 'lodash'; import * as PropTypes from 'prop-types'; import { getTests } from '../../../api/components'; -import { BranchLike, SourceLine, TestCase } from '../../../app/types'; import { DropdownOverlay } from '../../controls/Dropdown'; import TestStatusIcon from '../../icons-components/TestStatusIcon'; import { PopupPlacement } from '../../ui/popups'; @@ -36,15 +35,15 @@ import { translate } from '../../../helpers/l10n'; import { collapsePath } from '../../../helpers/path'; interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; componentKey: string; - line: SourceLine; + line: T.SourceLine; onClose: () => void; } interface State { loading: boolean; - testCases: TestCase[]; + testCases: T.TestCase[]; } export default class CoveragePopup extends React.PureComponent { 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 c3c9bff0e83..1f348fde012 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 @@ -21,7 +21,6 @@ import * as React from 'react'; import { Link } from 'react-router'; import * as PropTypes from 'prop-types'; import { groupBy, sortBy } from 'lodash'; -import { BranchLike, DuplicatedFile, DuplicationBlock, SourceViewerFile } from '../../../app/types'; import { DropdownOverlay } from '../../controls/Dropdown'; import QualifierIcon from '../../icons-components/QualifierIcon'; import { PopupPlacement } from '../../ui/popups'; @@ -33,13 +32,13 @@ import { getProjectUrl } from '../../../helpers/urls'; import { Alert } from '../../ui/Alert'; interface Props { - blocks: DuplicationBlock[]; - branchLike: BranchLike | undefined; - duplicatedFiles?: { [ref: string]: DuplicatedFile }; + blocks: T.DuplicationBlock[]; + branchLike: T.BranchLike | undefined; + duplicatedFiles?: { [ref: string]: T.DuplicatedFile }; inRemovedComponent: boolean; onClose: () => void; popupPosition?: any; - sourceViewerFile: SourceViewerFile; + sourceViewerFile: T.SourceViewerFile; } export default class DuplicationPopup extends React.PureComponent { @@ -75,7 +74,7 @@ export default class DuplicationPopup extends React.PureComponent { this.props.onClose(); }; - renderDuplication(file: DuplicatedFile, children: React.ReactNode, line?: number) { + renderDuplication(file: T.DuplicatedFile, children: React.ReactNode, line?: number) { return this.shouldLink() ? ( void; + loadDuplications: (line: T.SourceLine) => void; onLinePopupToggle: (x: { index?: number; line: number; name: string; open?: boolean }) => void; - onIssueChange: (issue: Issue) => void; + onIssueChange: (issue: T.Issue) => void; onIssuePopupToggle: (issueKey: string, popupName: string, open?: boolean) => void; - onIssuesClose: (line: SourceLine) => void; + onIssuesClose: (line: T.SourceLine) => void; onIssueSelect: (issueKey: string) => void; - onIssuesOpen: (line: SourceLine) => void; + onIssuesOpen: (line: T.SourceLine) => void; onIssueUnselect: () => void; onLocationSelect: ((x: number) => void) | undefined; onSymbolClick: (symbols: string[]) => void; openIssues: boolean; - previousLine: SourceLine | undefined; + previousLine: T.SourceLine | undefined; renderDuplicationPopup: (index: number, line: number) => JSX.Element; scroll?: (element: HTMLElement) => void; secondaryIssueLocations: Array<{ 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 b3ac1a77358..6ec33831474 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,7 +20,6 @@ import * as React from 'react'; import * as classNames from 'classnames'; import LineIssuesList from './LineIssuesList'; -import { BranchLike, Issue, LinearIssueLocation, SourceLine } from '../../../app/types'; import LocationIndex from '../../common/LocationIndex'; import LocationMessage from '../../common/LocationMessage'; import { @@ -31,17 +30,17 @@ import { } from '../helpers/highlight'; interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; displayIssueLocationsCount?: boolean; displayIssueLocationsLink?: boolean; displayLocationMarkers?: boolean; highlightedLocationMessage: { index: number; text: string | undefined } | undefined; highlightedSymbols: string[] | undefined; - issueLocations: LinearIssueLocation[]; + issueLocations: T.LinearIssueLocation[]; issuePopup: { issue: string; name: string } | undefined; - issues: Issue[]; - line: SourceLine; - onIssueChange: (issue: Issue) => void; + issues: T.Issue[]; + line: T.SourceLine; + onIssueChange: (issue: T.Issue) => void; onIssuePopupToggle: (issue: string, popupName: string, open?: boolean) => void; onIssueSelect: (issueKey: string) => void; onLocationSelect: ((index: number) => void) | undefined; 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 2be765bb904..4eb30dca4e7 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 @@ -19,15 +19,14 @@ */ import * as React from 'react'; import CoveragePopup from './CoveragePopup'; -import { BranchLike, SourceLine } from '../../../app/types'; import Tooltip from '../../controls/Tooltip'; import Toggler from '../../controls/Toggler'; import { translate } from '../../../helpers/l10n'; interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; componentKey: string; - line: SourceLine; + line: T.SourceLine; onPopupToggle: (x: { index?: number; line: number; name: string; open?: boolean }) => void; popupOpen: boolean; } 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 0b9ae37f2fc..aaeebd3ff43 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 @@ -19,7 +19,6 @@ */ import * as React from 'react'; import * as classNames from 'classnames'; -import { SourceLine } from '../../../app/types'; import Tooltip from '../../controls/Tooltip'; import Toggler from '../../controls/Toggler'; import { translate } from '../../../helpers/l10n'; @@ -27,7 +26,7 @@ import { translate } from '../../../helpers/l10n'; interface Props { duplicated: boolean; index: number; - line: SourceLine; + line: T.SourceLine; onPopupToggle: (x: { index?: number; line: number; name: string; open?: boolean }) => void; popupOpen: boolean; renderDuplicationPopup: (index: number, line: number) => JSX.Element; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplications.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplications.tsx index c51c49dcdca..a70dc04c969 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplications.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineDuplications.tsx @@ -19,13 +19,12 @@ */ import * as React from 'react'; import * as classNames from 'classnames'; -import { SourceLine } from '../../../app/types'; import Tooltip from '../../controls/Tooltip'; import { translate } from '../../../helpers/l10n'; interface Props { - line: SourceLine; - onClick: (line: SourceLine) => void; + line: T.SourceLine; + onClick: (line: T.SourceLine) => void; } export default class LineDuplications extends React.PureComponent { 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 e8d9b4162de..42bbfcd5cff 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 @@ -21,11 +21,10 @@ import * as React from 'react'; import * as classNames from 'classnames'; import SeverityIcon from '../../icons-components/SeverityIcon'; import { sortBySeverity } from '../../../helpers/issues'; -import { Issue, SourceLine } from '../../../app/types'; interface Props { - issues: Issue[]; - line: SourceLine; + issues: T.Issue[]; + line: T.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 6e8cfca7732..c036c1b431c 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 @@ -18,16 +18,15 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { BranchLike, Issue as IssueType } from '../../../app/types'; import Issue from '../../issue/Issue'; interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; displayIssueLocationsCount?: boolean; displayIssueLocationsLink?: boolean; issuePopup: { issue: string; name: string } | undefined; - issues: IssueType[]; - onIssueChange: (issue: IssueType) => void; + issues: T.Issue[]; + onIssueChange: (issue: T.Issue) => 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 15af9ac258d..34ef00be9d3 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 @@ -19,13 +19,12 @@ */ import * as React from 'react'; import LineOptionsPopup from './LineOptionsPopup'; -import { BranchLike, SourceLine } from '../../../app/types'; import Toggler from '../../controls/Toggler'; interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; componentKey: string; - line: SourceLine; + line: T.SourceLine; onPopupToggle: (x: { index?: number; line: number; name: string; open?: boolean }) => void; popupOpen: boolean; } 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 34a136d8391..ec9d9be9884 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 @@ -19,16 +19,15 @@ */ import * as React from 'react'; import { Link } from 'react-router'; -import { BranchLike, SourceLine } from '../../../app/types'; import { DropdownOverlay } from '../../controls/Dropdown'; import { PopupPlacement } from '../../ui/popups'; import { translate } from '../../../helpers/l10n'; import { getBranchLikeQuery } from '../../../helpers/branches'; interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; componentKey: string; - line: SourceLine; + line: T.SourceLine; } export default function LineOptionsPopup({ branchLike, componentKey, line }: Props) { 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 394c321b12d..43babe90379 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 @@ -19,14 +19,13 @@ */ import * as React from 'react'; import SCMPopup from './SCMPopup'; -import { SourceLine } from '../../../app/types'; import Toggler from '../../controls/Toggler'; interface Props { - line: SourceLine; + line: T.SourceLine; onPopupToggle: (x: { index?: number; line: number; name: string; open?: boolean }) => void; popupOpen: boolean; - previousLine: SourceLine | undefined; + previousLine: T.SourceLine | undefined; } export default class LineSCM extends React.PureComponent { @@ -74,7 +73,7 @@ export default class LineSCM extends React.PureComponent { } } -function isSCMChanged(s: SourceLine, p: SourceLine | undefined) { +function isSCMChanged(s: T.SourceLine, p: T.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 a21e366ae91..14fd268ddf3 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 @@ -26,13 +26,6 @@ import { Button } from '../../ui/buttons'; import { getFacets } from '../../../api/issues'; import { getMeasures } from '../../../api/measures'; import { getAllMetrics } from '../../../api/metrics'; -import { - FacetValue, - SourceViewerFile, - BranchLike, - MeasureEnhanced, - IssueType -} from '../../../app/types'; import Modal from '../../controls/Modal'; import Measure from '../../measure/Measure'; import QualifierIcon from '../../icons-components/QualifierIcon'; @@ -52,22 +45,22 @@ import { getBranchLikeQuery } from '../../../helpers/branches'; import TagsIcon from '../../icons-components/TagsIcon'; interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; onClose: () => void; - sourceViewerFile: SourceViewerFile; + sourceViewerFile: T.SourceViewerFile; } interface Measures { - [metricKey: string]: MeasureEnhanced; + [metricKey: string]: T.MeasureEnhanced; } interface State { loading: boolean; measures: Measures; - severitiesFacet?: FacetValue[]; + severitiesFacet?: T.FacetValue[]; showAllMeasures: boolean; - tagsFacet?: FacetValue[]; - typesFacet?: FacetValue[]; + tagsFacet?: T.FacetValue[]; + typesFacet?: T.FacetValue[]; } export default class MeasuresOverlay extends React.PureComponent { @@ -131,7 +124,7 @@ export default class MeasuresOverlay extends React.PureComponent { return { severitiesFacet: severitiesFacet && severitiesFacet.values, tagsFacet: tagsFacet && tagsFacet.values, - typesFacet: typesFacet && (typesFacet.values as FacetValue[]) + typesFacet: typesFacet && (typesFacet.values as T.FacetValue[]) }; }); }; @@ -142,7 +135,7 @@ export default class MeasuresOverlay extends React.PureComponent { this.setState({ showAllMeasures: true }); }; - renderMeasure = (measure: MeasureEnhanced | undefined) => { + renderMeasure = (measure: T.MeasureEnhanced | undefined) => { return measure ? : null; }; @@ -173,7 +166,7 @@ export default class MeasuresOverlay extends React.PureComponent { ); }; - renderBigMeasure = (measure: MeasureEnhanced | undefined) => { + renderBigMeasure = (measure: T.MeasureEnhanced | undefined) => { return measure ? (

    @@ -357,7 +350,7 @@ export default class MeasuresOverlay extends React.PureComponent { ); }; - renderDomain = (domain: string, measures: MeasureEnhanced[]) => { + renderDomain = (domain: string, measures: T.MeasureEnhanced[]) => { return (
    diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayCoveredFiles.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayCoveredFiles.tsx index 1e46274b9e9..530acbcdab3 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayCoveredFiles.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayCoveredFiles.tsx @@ -20,17 +20,16 @@ import * as React from 'react'; import { Link } from 'react-router'; import { getCoveredFiles } from '../../../api/tests'; -import { TestCase, CoveredFile } from '../../../app/types'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { getProjectUrl } from '../../../helpers/urls'; import DeferredSpinner from '../../common/DeferredSpinner'; interface Props { - testCase: TestCase; + testCase: T.TestCase; } interface State { - coveredFiles?: CoveredFile[]; + coveredFiles?: T.CoveredFile[]; loading: boolean; } 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 7a41a9ef001..11fb3a5ac57 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 @@ -18,13 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Metric } from '../../../app/types'; import Measure from '../../measure/Measure'; import IssueTypeIcon from '../../ui/IssueTypeIcon'; import { getLocalizedMetricName } from '../../../helpers/l10n'; export interface MeasureWithMetric { - metric: Metric; + metric: T.Metric; value?: string; } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayTestCase.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayTestCase.tsx index 6f2981c17c8..2f149fd4471 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayTestCase.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayTestCase.tsx @@ -18,12 +18,11 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { TestCase } from '../../../app/types'; import TestStatusIcon from '../../icons-components/TestStatusIcon'; interface Props { onClick: (testId: string) => void; - testCase: TestCase; + testCase: T.TestCase; } export default class MeasuresOverlayTestCase extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayTestCases.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayTestCases.tsx index 8b2f880be51..244bd4b6a26 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayTestCases.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/MeasuresOverlayTestCases.tsx @@ -23,12 +23,11 @@ import { orderBy } from 'lodash'; import MeasuresOverlayCoveredFiles from './MeasuresOverlayCoveredFiles'; import MeasuresOverlayTestCase from './MeasuresOverlayTestCase'; import { getTests } from '../../../api/tests'; -import { TestCase, BranchLike } from '../../../app/types'; import { translate } from '../../../helpers/l10n'; import { getBranchLikeQuery } from '../../../helpers/branches'; interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; componentKey: string; } @@ -37,7 +36,7 @@ interface State { selectedTestId?: string; sort?: string; sortAsc?: boolean; - testCases?: TestCase[]; + testCases?: T.TestCase[]; } export default class MeasuresOverlayTestCases extends React.PureComponent { @@ -174,7 +173,7 @@ export default class MeasuresOverlayTestCases extends React.PureComponent { @@ -53,11 +52,11 @@ it('render code', () => { code: 'class Foo {' }; const issueLocations = [{ from: 0, to: 5, line: 3 }]; - const branch: ShortLivingBranch = { + const branch: T.ShortLivingBranch = { isMain: false, mergeBranch: 'master', name: 'feature', - type: BranchType.SHORT + type: 'SHORT' }; const wrapper = shallow( { - const line: SourceLine = { line: 3, coverageStatus: 'covered' }; + const line: T.SourceLine = { line: 3, coverageStatus: 'covered' }; const wrapper = shallow( { }); it('render uncovered line', () => { - const line: SourceLine = { line: 3, coverageStatus: 'uncovered' }; + const line: T.SourceLine = { line: 3, coverageStatus: 'uncovered' }; const wrapper = shallow( { }); it('render line with unknown coverage', () => { - const line: SourceLine = { line: 3 }; + const line: T.SourceLine = { line: 3 }; const wrapper = shallow( { }); it('should open coverage popup', () => { - const line: SourceLine = { line: 3, coverageStatus: 'covered' }; + const line: T.SourceLine = { line: 3, coverageStatus: 'covered' }; const onPopupToggle = jest.fn(); const wrapper = shallow( { @@ -68,7 +67,7 @@ it('render highest severity', () => { it('no issues', () => { const line = { line: 3 }; - const issues: Issue[] = []; + const issues: T.Issue[] = []; const onClick = jest.fn(); const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); 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 5c40c7d813f..af54ee90c3e 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 @@ -20,9 +20,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import LineIssuesList from '../LineIssuesList'; -import { Issue, IssueType } from '../../../../app/types'; -const issueBase: Issue = { +const issueBase: T.Issue = { actions: [], component: '', componentLongName: '', @@ -44,11 +43,11 @@ const issueBase: Issue = { severity: '', status: '', transitions: [], - type: IssueType.Bug + type: 'BUG' }; it('render issues list', () => { - const issues: Issue[] = [{ ...issueBase, key: 'foo' }, { ...issueBase, key: 'bar' }]; + const issues: T.Issue[] = [{ ...issueBase, key: 'foo' }, { ...issueBase, key: 'bar' }]; const onIssueClick = jest.fn(); const wrapper = shallow( { const line = { line: 3 }; - const branch: ShortLivingBranch = { + const branch: T.ShortLivingBranch = { isMain: false, mergeBranch: 'master', name: 'feature', - type: BranchType.SHORT + type: 'SHORT' }; const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); 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 3c4a20dd0e2..2b29658928b 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 @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import MeasuresOverlay from '../MeasuresOverlay'; -import { SourceViewerFile, ShortLivingBranch, BranchType } from '../../../../app/types'; import { waitAndUpdate, click } from '../../../../helpers/testUtils'; jest.mock('../../../../api/issues', () => ({ @@ -136,7 +135,7 @@ jest.mock('../../../../api/metrics', () => ({ ]) })); -const sourceViewerFile: SourceViewerFile = { +const sourceViewerFile: T.SourceViewerFile = { key: 'component-key', measures: {}, path: 'src/file.js', @@ -148,11 +147,11 @@ const sourceViewerFile: SourceViewerFile = { uuid: 'abcd123' }; -const branchLike: ShortLivingBranch = { +const branchLike: T.ShortLivingBranch = { isMain: false, mergeBranch: 'master', name: 'feature', - type: BranchType.SHORT + type: 'SHORT' }; it('should render source file', async () => { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlayTestCases-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlayTestCases-test.tsx index 1eacb341dc0..47b3d3e8612 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlayTestCases-test.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/MeasuresOverlayTestCases-test.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import MeasuresOverlayTestCases from '../MeasuresOverlayTestCases'; import { waitAndUpdate, click } from '../../../../helpers/testUtils'; -import { ShortLivingBranch, BranchType } from '../../../../app/types'; jest.mock('../../../../api/tests', () => ({ getTests: () => @@ -61,11 +60,11 @@ jest.mock('../../../../api/tests', () => ({ }) })); -const branchLike: ShortLivingBranch = { +const branchLike: T.ShortLivingBranch = { isMain: false, mergeBranch: 'master', name: 'feature', - type: BranchType.SHORT + type: 'SHORT' }; it('should render', async () => { diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/getCoverageStatus.tsx b/server/sonar-web/src/main/js/components/SourceViewer/helpers/getCoverageStatus.tsx index 88fd50b2f1d..cbcf01bb11f 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/getCoverageStatus.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/getCoverageStatus.tsx @@ -17,9 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { SourceLine } from '../../../app/types'; -export default function getCoverageStatus(s: SourceLine): string | undefined { +export default function getCoverageStatus(s: T.SourceLine): string | undefined { let status: string | 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 2f105f74884..45a6b7649bb 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,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { uniq } from 'lodash'; -import { LinearIssueLocation } from '../../../app/types'; export interface Token { className: string; @@ -85,7 +84,7 @@ function part(str: string, from: number, to: number, acc: number): string { */ export function highlightIssueLocations( tokens: Token[], - issueLocations: LinearIssueLocation[], + issueLocations: T.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 bf103f0cf34..5046bbead7f 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 @@ -20,10 +20,9 @@ import { flatten } from 'lodash'; import { splitByTokens } from './highlight'; import { getLinearLocations } from './issueLocations'; -import { Duplication, Issue, LinearIssueLocation, SourceLine } from '../../../app/types'; -export function issuesByLine(issues: Issue[]) { - const index: { [line: number]: Issue[] } = {}; +export function issuesByLine(issues: T.Issue[]) { + const index: { [line: number]: T.Issue[] } = {}; issues.forEach(issue => { const line = issue.textRange ? issue.textRange.endLine : 0; if (!(line in index)) { @@ -34,8 +33,8 @@ export function issuesByLine(issues: Issue[]) { return index; } -export function locationsByLine(issues: Issue[]) { - const index: { [line: number]: LinearIssueLocation[] } = {}; +export function locationsByLine(issues: T.Issue[]) { + const index: { [line: number]: T.LinearIssueLocation[] } = {}; issues.forEach(issue => { getLinearLocations(issue.textRange).forEach(location => { if (!(location.line in index)) { @@ -47,7 +46,7 @@ export function locationsByLine(issues: Issue[]) { return index; } -export function duplicationsByLine(duplications: Duplication[] | undefined) { +export function duplicationsByLine(duplications: T.Duplication[] | undefined) { if (duplications == null) { return {}; } @@ -71,7 +70,7 @@ export function duplicationsByLine(duplications: Duplication[] | undefined) { return duplicationsByLine; } -export function symbolsByLine(sources: SourceLine[]) { +export function symbolsByLine(sources: T.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.tsx b/server/sonar-web/src/main/js/components/SourceViewer/helpers/issueLocations.tsx index 5c0f7ee9616..09ba8f805f3 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/issueLocations.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/issueLocations.tsx @@ -17,9 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { LinearIssueLocation, TextRange } from '../../../app/types'; -export function getLinearLocations(textRange: TextRange | undefined): LinearIssueLocation[] { +export function getLinearLocations(textRange: T.TextRange | undefined): T.LinearIssueLocation[] { if (!textRange) { return []; } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.tsx b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.tsx index e23ce75a528..fd9a03de6f2 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.tsx @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { searchIssues } from '../../../api/issues'; -import { BranchLike, Issue } from '../../../app/types'; import { getBranchLikeQuery } from '../../../helpers/branches'; import { parseIssueFromResponse } from '../../../helpers/issues'; import { RawQuery } from '../../../helpers/query'; @@ -26,7 +25,7 @@ import { RawQuery } from '../../../helpers/query'; // maximum possible value const PAGE_SIZE = 500; -function buildQuery(component: string, branchLike: BranchLike | undefined) { +function buildQuery(component: string, branchLike: T.BranchLike | undefined) { return { additionalFields: '_all', resolved: 'false', @@ -36,7 +35,7 @@ function buildQuery(component: string, branchLike: BranchLike | undefined) { }; } -export function loadPage(query: RawQuery, page: number, pageSize = PAGE_SIZE): Promise { +export function loadPage(query: RawQuery, page: number, pageSize = PAGE_SIZE): Promise { return searchIssues({ ...query, p: page, @@ -51,7 +50,7 @@ export function loadPageAndNext( toLine: number, page: number, pageSize = PAGE_SIZE -): Promise { +): Promise { return loadPage(query, page).then(issues => { if (issues.length === 0) { return []; @@ -76,8 +75,8 @@ export default function loadIssues( component: string, _fromLine: number, toLine: number, - branchLike: BranchLike | undefined -): Promise { + branchLike: T.BranchLike | undefined +): 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/charts/LanguageDistribution.tsx b/server/sonar-web/src/main/js/components/charts/LanguageDistribution.tsx index 1ff1acac6c6..148d04a29df 100644 --- a/server/sonar-web/src/main/js/components/charts/LanguageDistribution.tsx +++ b/server/sonar-web/src/main/js/components/charts/LanguageDistribution.tsx @@ -22,12 +22,11 @@ import { sortBy } from 'lodash'; import Histogram from './Histogram'; import { formatMeasure } from '../../helpers/measures'; import { translate } from '../../helpers/l10n'; -import { Languages } from '../../app/types'; interface Props { alignTicks?: boolean; distribution: string; - languages: Languages; + languages: T.Languages; width: number; } diff --git a/server/sonar-web/src/main/js/components/common/BranchMeasures.tsx b/server/sonar-web/src/main/js/components/common/BranchMeasures.tsx index 680ef8e51cf..055b55f6e68 100644 --- a/server/sonar-web/src/main/js/components/common/BranchMeasures.tsx +++ b/server/sonar-web/src/main/js/components/common/BranchMeasures.tsx @@ -21,7 +21,6 @@ import * as React from 'react'; import * as classNames from 'classnames'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router'; -import { Measure, BranchLike } from '../../app/types'; import { getLeakValue } from '../measure/utils'; import CoverageRating from '../ui/CoverageRating'; import { formatMeasure } from '../../helpers/measures'; @@ -31,9 +30,9 @@ import DuplicationsRating from '../ui/DuplicationsRating'; import { getComponentDrilldownUrl } from '../../helpers/urls'; interface Props { - branchLike: BranchLike; + branchLike: T.BranchLike; componentKey: string; - measures: Measure[]; + measures: T.Measure[]; } export default function BranchMeasures({ branchLike, componentKey, measures }: Props) { @@ -59,10 +58,10 @@ export default function BranchMeasures({ branchLike, componentKey, measures }: P } interface MeasureProps { - branchLike: BranchLike; + branchLike: T.BranchLike; className?: string; componentKey: string; - measure: Measure | undefined; + measure: T.Measure | undefined; } export function BranchCoverage({ branchLike, className, componentKey, measure }: MeasureProps) { diff --git a/server/sonar-web/src/main/js/components/common/BranchStatus.tsx b/server/sonar-web/src/main/js/components/common/BranchStatus.tsx index 8fc097af87f..e1ede2a2a97 100644 --- a/server/sonar-web/src/main/js/components/common/BranchStatus.tsx +++ b/server/sonar-web/src/main/js/components/common/BranchStatus.tsx @@ -26,7 +26,6 @@ import CodeSmellIcon from '../icons-components/CodeSmellIcon'; import HelpTooltip from '../controls/HelpTooltip'; import Tooltip from '../controls/Tooltip'; import VulnerabilityIcon from '../icons-components/VulnerabilityIcon'; -import { BranchLike } from '../../app/types'; import { getBranchQualityGateColor, isShortLivingBranch, @@ -39,7 +38,7 @@ import { formatMeasure } from '../../helpers/measures'; import './BranchStatus.css'; interface Props { - branchLike: BranchLike; + branchLike: T.BranchLike; concise?: boolean; helpTooltipClassName?: string; } diff --git a/server/sonar-web/src/main/js/components/common/OrganizationAvatar.tsx b/server/sonar-web/src/main/js/components/common/OrganizationAvatar.tsx index bda1c6774a0..c7e95c82de4 100644 --- a/server/sonar-web/src/main/js/components/common/OrganizationAvatar.tsx +++ b/server/sonar-web/src/main/js/components/common/OrganizationAvatar.tsx @@ -20,12 +20,11 @@ import * as React from 'react'; import * as classNames from 'classnames'; import GenericAvatar from '../ui/GenericAvatar'; -import { OrganizationBase } from '../../app/types'; import './OrganizationAvatar.css'; interface Props { className?: string; - organization: Pick; + organization: Pick; small?: boolean; } 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 dde6fb821a4..6bc7f28526f 100644 --- a/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx +++ b/server/sonar-web/src/main/js/components/common/PrivacyBadgeContainer.tsx @@ -23,7 +23,6 @@ import { connect } from 'react-redux'; import * as theme from '../../app/theme'; import Tooltip from '../controls/Tooltip'; import { translate } from '../../helpers/l10n'; -import { Visibility, Organization, CurrentUser } from '../../app/types'; import { isSonarCloud } from '../../helpers/system'; import { isCurrentUserMemberOf, isPaidOrganization } from '../../helpers/organizations'; import { @@ -36,21 +35,21 @@ import VisibleIcon from '../icons-components/VisibleIcon'; import DocTooltip from '../docs/DocTooltip'; interface StateToProps { - currentUser: CurrentUser; - organization?: Organization; - userOrganizations: Organization[]; + currentUser: T.CurrentUser; + organization?: T.Organization; + userOrganizations: T.Organization[]; } interface OwnProps { className?: string; - organization: Organization | string | undefined; + organization: T.Organization | string | undefined; qualifier: string; tooltipProps?: { projectKey: string }; - visibility: Visibility; + visibility: T.Visibility; } interface Props extends OwnProps, StateToProps { - organization: Organization | undefined; + organization: T.Organization | undefined; } export function PrivacyBadge({ @@ -64,14 +63,14 @@ export function PrivacyBadge({ }: Props) { const onSonarCloud = isSonarCloud(); if ( - visibility !== Visibility.Private && + visibility !== 'private' && (!onSonarCloud || !isCurrentUserMemberOf(currentUser, organization, userOrganizations)) ) { return null; } let icon = null; - if (isPaidOrganization(organization) && visibility === Visibility.Public) { + if (isPaidOrganization(organization) && visibility === 'public') { icon = ; } @@ -117,10 +116,10 @@ const mapStateToProps = (state: Store, { organization }: OwnProps) => { export default connect(mapStateToProps)(PrivacyBadge); -function getDoc(visibility: Visibility, icon: JSX.Element | null, organization: Organization) { +function getDoc(visibility: T.Visibility, icon: JSX.Element | null, organization: T.Organization) { let doc; const { actions = {} } = organization; - if (visibility === Visibility.Private) { + if (visibility === 'private') { doc = import(/* webpackMode: "eager" */ 'Docs/tooltips/project/visibility-private.md'); } else if (icon) { if (actions.admin) { 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 7d6633d1189..3a5c2025479 100644 --- a/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx +++ b/server/sonar-web/src/main/js/components/common/VisibilitySelector.tsx @@ -20,26 +20,25 @@ import * as React from 'react'; import * as classNames from 'classnames'; import { translate } from '../../helpers/l10n'; -import { Visibility } from '../../app/types'; interface Props { canTurnToPrivate?: boolean; className?: string; - onChange: (visibility: Visibility) => void; - visibility?: Visibility; + onChange: (visibility: T.Visibility) => void; + visibility?: T.Visibility; } export default class VisibilitySelector extends React.PureComponent { handlePublicClick = (event: React.SyntheticEvent) => { event.preventDefault(); event.currentTarget.blur(); - this.props.onChange(Visibility.Public); + this.props.onChange('public'); }; handlePrivateClick = (event: React.SyntheticEvent) => { event.preventDefault(); event.currentTarget.blur(); - this.props.onChange(Visibility.Private); + this.props.onChange('private'); }; render() { @@ -52,7 +51,7 @@ export default class VisibilitySelector extends React.PureComponent { onClick={this.handlePublicClick}> {translate('visibility.public')} @@ -66,7 +65,7 @@ export default class VisibilitySelector extends React.PureComponent { onClick={this.handlePrivateClick}> {translate('visibility.private')} @@ -75,7 +74,7 @@ export default class VisibilitySelector extends React.PureComponent { {translate('visibility.private')} diff --git a/server/sonar-web/src/main/js/components/common/__tests__/BranchMeasures-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/BranchMeasures-test.tsx index c53ec9c6bd3..708db974c7d 100644 --- a/server/sonar-web/src/main/js/components/common/__tests__/BranchMeasures-test.tsx +++ b/server/sonar-web/src/main/js/components/common/__tests__/BranchMeasures-test.tsx @@ -20,14 +20,13 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import BranchMeasures, { BranchCoverage, BranchDuplications } from '../BranchMeasures'; -import { PullRequest } from '../../../app/types'; const MEASURES = [ { metric: 'new_coverage', value: '0', periods: [{ index: 1, value: '95.9943' }] }, { metric: 'new_duplicated_lines_density', periods: [{ index: 1, value: '3.5' }] } ]; -const pr: PullRequest = { base: 'master', branch: 'feature-x', key: '5', title: '' }; +const pr: T.PullRequest = { base: 'master', branch: 'feature-x', key: '5', title: '' }; describe('BranchMeasures', () => { it('should render coverage and duplications', () => { diff --git a/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx index 5be99d59f49..6e35af6c5e7 100644 --- a/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx +++ b/server/sonar-web/src/main/js/components/common/__tests__/BranchStatus-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import BranchStatus from '../BranchStatus'; -import { BranchType, LongLivingBranch, ShortLivingBranch, MainBranch } from '../../../app/types'; it('renders status of short-living branches', () => { checkShort('OK', 0, 0, 0); @@ -34,32 +33,32 @@ it('renders status of short-living branches', () => { codeSmells: number, vulnerabilities: number ) { - const shortBranch: ShortLivingBranch = { + const shortBranch: T.ShortLivingBranch = { isMain: false, mergeBranch: 'master', name: 'foo', status: { bugs, codeSmells, qualityGateStatus, vulnerabilities }, - type: BranchType.SHORT + type: 'SHORT' }; expect(shallow()).toMatchSnapshot(); } }); it('renders status of long-living branches', () => { - const branch: LongLivingBranch = { isMain: false, name: 'foo', type: BranchType.LONG }; + const branch: T.LongLivingBranch = { isMain: false, name: 'foo', type: 'LONG' }; expect(getWrapper(branch).type()).toBeNull(); expect(getWrapper(branch, 'OK')).toMatchSnapshot(); expect(getWrapper(branch, 'ERROR')).toMatchSnapshot(); }); it('renders status of main branch', () => { - const branch: MainBranch = { isMain: true, name: 'foo' }; + const branch: T.MainBranch = { isMain: true, name: 'foo' }; expect(getWrapper(branch).type()).toBeNull(); expect(getWrapper(branch, 'OK')).toMatchSnapshot(); expect(getWrapper(branch, 'ERROR')).toMatchSnapshot(); }); -function getWrapper(branch: MainBranch | LongLivingBranch, qualityGateStatus?: string) { +function getWrapper(branch: T.MainBranch | T.LongLivingBranch, qualityGateStatus?: string) { if (qualityGateStatus) { branch.status = { qualityGateStatus }; } diff --git a/server/sonar-web/src/main/js/components/common/__tests__/PrivacyBadgeContainer-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/PrivacyBadgeContainer-test.tsx index d087ccea800..28e77898aec 100644 --- a/server/sonar-web/src/main/js/components/common/__tests__/PrivacyBadgeContainer-test.tsx +++ b/server/sonar-web/src/main/js/components/common/__tests__/PrivacyBadgeContainer-test.tsx @@ -20,12 +20,11 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { PrivacyBadge } from '../PrivacyBadgeContainer'; -import { Visibility, OrganizationSubscription } from '../../../app/types'; import { isSonarCloud } from '../../../helpers/system'; jest.mock('../../../helpers/system', () => ({ isSonarCloud: jest.fn().mockReturnValue(false) })); -const organization = { key: 'foo', name: 'Foo' }; +const organization: T.Organization = { key: 'foo', name: 'Foo' }; const loggedInUser = { isLoggedIn: true, login: 'luke', name: 'Skywalker' }; it('renders', () => { @@ -33,12 +32,12 @@ it('renders', () => { }); it('do not render', () => { - expect(getWrapper({ visibility: Visibility.Public })).toMatchSnapshot(); + expect(getWrapper({ visibility: 'public' })).toMatchSnapshot(); }); it('renders public', () => { (isSonarCloud as jest.Mock).mockReturnValueOnce(true); - expect(getWrapper({ visibility: Visibility.Public })).toMatchSnapshot(); + expect(getWrapper({ visibility: 'public' })).toMatchSnapshot(); }); it('renders public with icon', () => { @@ -48,9 +47,9 @@ it('renders public with icon', () => { organization: { ...organization, actions: { admin: true }, - subscription: OrganizationSubscription.Paid + subscription: 'PAID' }, - visibility: Visibility.Public + visibility: 'public' }) ).toMatchSnapshot(); }); @@ -62,7 +61,7 @@ function getWrapper(props = {}) { organization={organization} qualifier="TRK" userOrganizations={[organization]} - visibility={Visibility.Private} + visibility={'private'} {...props} /> ); diff --git a/server/sonar-web/src/main/js/components/common/__tests__/VisibilitySelector-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/VisibilitySelector-test.tsx index 73c2b7771e6..655563b8932 100644 --- a/server/sonar-web/src/main/js/components/common/__tests__/VisibilitySelector-test.tsx +++ b/server/sonar-web/src/main/js/components/common/__tests__/VisibilitySelector-test.tsx @@ -21,37 +21,28 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import VisibilitySelector from '../VisibilitySelector'; import { click } from '../../../helpers/testUtils'; -import { Visibility } from '../../../app/types'; it('changes visibility', () => { const onChange = jest.fn(); const wrapper = shallow( - + ); expect(wrapper).toMatchSnapshot(); click(wrapper.find('#visibility-private')); - expect(onChange).toBeCalledWith(Visibility.Private); + expect(onChange).toBeCalledWith('private'); - wrapper.setProps({ visibility: Visibility.Private }); + wrapper.setProps({ visibility: 'private' }); expect(wrapper).toMatchSnapshot(); click(wrapper.find('#visibility-public')); - expect(onChange).toBeCalledWith(Visibility.Public); + expect(onChange).toBeCalledWith('public'); }); it('renders disabled', () => { expect( shallow( - + ) ).toMatchSnapshot(); }); 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 fef52ae8902..084637d8f73 100644 --- a/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx +++ b/server/sonar-web/src/main/js/components/controls/HomePageSelect.tsx @@ -22,23 +22,22 @@ import * as classNames from 'classnames'; import { connect } from 'react-redux'; import Tooltip from './Tooltip'; import HomeIcon from '../icons-components/HomeIcon'; -import { CurrentUser, HomePage, isSameHomePage } from '../../app/types'; import { translate } from '../../helpers/l10n'; import { getCurrentUser, Store } from '../../store/rootReducer'; import { setHomePage } from '../../store/users'; import { isLoggedIn } from '../../helpers/users'; interface StateProps { - currentUser: CurrentUser; + currentUser: T.CurrentUser; } interface DispatchProps { - setHomePage: (homepage: HomePage) => void; + setHomePage: (homepage: T.HomePage) => void; } interface Props extends StateProps, DispatchProps { className?: string; - currentPage: HomePage; + currentPage: T.HomePage; } class HomePageSelect extends React.PureComponent { @@ -92,3 +91,12 @@ export default connect( mapStateToProps, mapDispatchToProps )(HomePageSelect); + +function isSameHomePage(a: T.HomePage, b: T.HomePage) { + return ( + a.type === b.type && + (a as any).branch === (b as any).branch && + (a as any).component === (b as any).component && + (a as any).organization === (b as any).organization + ); +} 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 b4e061b3924..47b04cbf0c4 100644 --- a/server/sonar-web/src/main/js/components/controls/ValidationForm.tsx +++ b/server/sonar-web/src/main/js/components/controls/ValidationForm.tsx @@ -19,9 +19,8 @@ */ import * as React from 'react'; import { FormikActions, FormikProps, Formik } from 'formik'; -import { Omit } from '../../app/types'; -export type ChildrenProps = Omit, 'handleSubmit'>; +export type ChildrenProps = T.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 89803a78e97..686e0d663fb 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 @@ -21,7 +21,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import HomePageSelect from '../HomePageSelect'; import { setHomePage } from '../../../api/users'; -import { HomePageType, HomePage, LoggedInUser, CurrentUser } from '../../../app/types'; import { click } from '../../../helpers/testUtils'; import rootReducer, { getCurrentUser, Store } from '../../../store/rootReducer'; import configureStore from '../../../store/utils/configureStore'; @@ -30,7 +29,7 @@ jest.mock('../../../api/users', () => ({ setHomePage: jest.fn(() => Promise.resolve()) })); -const homepage: HomePage = { type: HomePageType.Projects }; +const homepage: T.HomePage = { type: 'PROJECTS' }; it('should render unchecked', () => { const store = configureStore(rootReducer, { @@ -41,7 +40,7 @@ it('should render unchecked', () => { it('should render checked', () => { const store = configureStore(rootReducer, { - users: { currentUser: { isLoggedIn: true, homepage } as CurrentUser } + users: { currentUser: { isLoggedIn: true, homepage } as T.CurrentUser } } as Store); expect(getWrapper(homepage, store)).toMatchSnapshot(); }); @@ -53,7 +52,7 @@ it('should set new home page', async () => { const wrapper = getWrapper(homepage, store); click(wrapper.find('a')); await new Promise(setImmediate); - const currentUser = getCurrentUser(store.getState() as Store) as LoggedInUser; + const currentUser = getCurrentUser(store.getState() as Store) as T.LoggedInUser; expect(currentUser.homepage).toEqual(homepage); expect(setHomePage).toBeCalledWith(homepage); }); @@ -65,7 +64,7 @@ it('should not render for anonymous', () => { expect(getWrapper(homepage, store).type()).toBeNull(); }); -function getWrapper(currentPage: HomePage, store: any) { +function getWrapper(currentPage: T.HomePage, store: any) { return shallow(, { context: { store } }).dive(); diff --git a/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx b/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx index 473a4cc19b4..d6f2556fee6 100644 --- a/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx +++ b/server/sonar-web/src/main/js/components/facet/ListStyleFacet.tsx @@ -27,7 +27,6 @@ import ListStyleFacetFooter from './ListStyleFacetFooter'; import MultipleSelectionHint from './MultipleSelectionHint'; import { translate } from '../../helpers/l10n'; import DeferredSpinner from '../common/DeferredSpinner'; -import { Paging } from '../../app/types'; import SearchBox from '../controls/SearchBox'; import ListFooter from '../controls/ListFooter'; import { formatMeasure } from '../../helpers/measures'; @@ -37,7 +36,7 @@ import { Alert } from '../ui/Alert'; interface SearchResponse { maxResults?: boolean; results: S[]; - paging?: Paging; + paging?: T.Paging; } export interface Props { @@ -72,7 +71,7 @@ interface State { query: string; searching: boolean; searchMaxResults?: boolean; - searchPaging?: Paging; + searchPaging?: T.Paging; searchResults?: S[]; searchResultsCounts: { [key: string]: number }; showFullList: boolean; diff --git a/server/sonar-web/src/main/js/components/hoc/__tests__/withCurrentUser-test.tsx b/server/sonar-web/src/main/js/components/hoc/__tests__/withCurrentUser-test.tsx index 84c292a37f9..d04cfceebfd 100644 --- a/server/sonar-web/src/main/js/components/hoc/__tests__/withCurrentUser-test.tsx +++ b/server/sonar-web/src/main/js/components/hoc/__tests__/withCurrentUser-test.tsx @@ -20,10 +20,9 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { createStore } from 'redux'; -import { CurrentUser } from '../../../app/types'; import { withCurrentUser } from '../withCurrentUser'; -class X extends React.Component<{ currentUser: CurrentUser }> { +class X extends React.Component<{ currentUser: T.CurrentUser }> { render() { return
    ; } diff --git a/server/sonar-web/src/main/js/components/hoc/__tests__/withUserOrganizations-test.tsx b/server/sonar-web/src/main/js/components/hoc/__tests__/withUserOrganizations-test.tsx index dee2f7fec03..637d54e55ea 100644 --- a/server/sonar-web/src/main/js/components/hoc/__tests__/withUserOrganizations-test.tsx +++ b/server/sonar-web/src/main/js/components/hoc/__tests__/withUserOrganizations-test.tsx @@ -20,12 +20,11 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { createStore } from 'redux'; -import { Organization } from '../../../app/types'; import { withUserOrganizations } from '../withUserOrganizations'; jest.mock('../../../api/organizations', () => ({ getOrganizations: jest.fn() })); -class X extends React.Component<{ userOrganizations: Organization[] }> { +class X extends React.Component<{ userOrganizations: T.Organization[] }> { render() { return
    ; } diff --git a/server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx b/server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx index 2ce4c8894c0..30e32f600e0 100644 --- a/server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx +++ b/server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx @@ -19,14 +19,13 @@ */ import * as React from 'react'; import { withCurrentUser } from './withCurrentUser'; -import { CurrentUser } from '../../app/types'; import { isLoggedIn } from '../../helpers/users'; import handleRequiredAuthentication from '../../app/utils/handleRequiredAuthentication'; export function whenLoggedIn

    (WrappedComponent: React.ComponentClass

    ) { const wrappedDisplayName = WrappedComponent.displayName || WrappedComponent.name || 'Component'; - class Wrapper extends React.Component

    { + class Wrapper extends React.Component

    { static displayName = `whenLoggedIn(${wrappedDisplayName})`; componentDidMount() { diff --git a/server/sonar-web/src/main/js/components/hoc/withCurrentUser.tsx b/server/sonar-web/src/main/js/components/hoc/withCurrentUser.tsx index b1933e1e23a..26a903ad595 100644 --- a/server/sonar-web/src/main/js/components/hoc/withCurrentUser.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withCurrentUser.tsx @@ -19,15 +19,14 @@ */ import * as React from 'react'; import { connect } from 'react-redux'; -import { CurrentUser } from '../../app/types'; import { Store, getCurrentUser } from '../../store/rootReducer'; export function withCurrentUser

    ( - WrappedComponent: React.ComponentClass

    + WrappedComponent: React.ComponentClass

    ) { const wrappedDisplayName = WrappedComponent.displayName || WrappedComponent.name || 'Component'; - class Wrapper extends React.Component

    { + class Wrapper extends React.Component

    { static displayName = `withCurrentUser(${wrappedDisplayName})`; render() { diff --git a/server/sonar-web/src/main/js/components/hoc/withUserOrganizations.tsx b/server/sonar-web/src/main/js/components/hoc/withUserOrganizations.tsx index bedc033bc09..485c9b6ac96 100644 --- a/server/sonar-web/src/main/js/components/hoc/withUserOrganizations.tsx +++ b/server/sonar-web/src/main/js/components/hoc/withUserOrganizations.tsx @@ -21,17 +21,19 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { Store, getMyOrganizations } from '../../store/rootReducer'; import { fetchMyOrganizations } from '../../apps/account/organizations/actions'; -import { Organization } from '../../app/types'; export function withUserOrganizations

    ( WrappedComponent: React.ComponentClass< P & { - personalOrganization?: Organization; - userOrganizations: Organization[]; + personalOrganization?: T.Organization; + userOrganizations: T.Organization[]; } > ) { - type Props = P & { fetchMyOrganizations: () => Promise; userOrganizations: Organization[] }; + type Props = P & { + fetchMyOrganizations: () => Promise; + userOrganizations: T.Organization[]; + }; const wrappedDisplayName = WrappedComponent.displayName || WrappedComponent.name || 'Component'; class Wrapper extends React.Component { diff --git a/server/sonar-web/src/main/js/components/icons-components/BranchIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/BranchIcon.tsx index f4dae266050..e9e89e9ecd6 100644 --- a/server/sonar-web/src/main/js/components/icons-components/BranchIcon.tsx +++ b/server/sonar-web/src/main/js/components/icons-components/BranchIcon.tsx @@ -22,11 +22,10 @@ import ShortLivingBranchIcon from './ShortLivingBranchIcon'; import LongLivingBranchIcon from './LongLivingBranchIcon'; import PullRequestIcon from './PullRequestIcon'; import { IconProps } from './Icon'; -import { BranchLike } from '../../app/types'; import { isShortLivingBranch, isPullRequest } from '../../helpers/branches'; interface Props extends IconProps { - branchLike: BranchLike; + branchLike: T.BranchLike; } export default function BranchIcon({ branchLike, ...props }: Props) { diff --git a/server/sonar-web/src/main/js/components/issue/Issue.tsx b/server/sonar-web/src/main/js/components/issue/Issue.tsx index e08b886fff2..663105633eb 100644 --- a/server/sonar-web/src/main/js/components/issue/Issue.tsx +++ b/server/sonar-web/src/main/js/components/issue/Issue.tsx @@ -22,19 +22,18 @@ import * as key from 'keymaster'; import IssueView from './IssueView'; import { updateIssue } from './actions'; import { setIssueAssignee } from '../../api/issues'; -import { BranchLike, Issue as IssueType } from '../../app/types'; import './Issue.css'; interface Props { - branchLike?: BranchLike; + branchLike?: T.BranchLike; checked?: boolean; displayLocationsCount?: boolean; displayLocationsLink?: boolean; - issue: IssueType; - onChange: (issue: IssueType) => void; + issue: T.Issue; + onChange: (issue: T.Issue) => void; onCheck?: (issue: string, event: { shiftKey?: boolean }) => void; onClick: (issueKey: string) => void; - onFilter?: (property: string, issue: IssueType) => void; + onFilter?: (property: string, issue: T.Issue) => void; onPopupToggle: (issue: string, popupName: string, open?: boolean) => void; openPopup?: string; selected: boolean; diff --git a/server/sonar-web/src/main/js/components/issue/IssueView.tsx b/server/sonar-web/src/main/js/components/issue/IssueView.tsx index 932d51a9176..486b2ac4b66 100644 --- a/server/sonar-web/src/main/js/components/issue/IssueView.tsx +++ b/server/sonar-web/src/main/js/components/issue/IssueView.tsx @@ -24,20 +24,19 @@ import IssueActionsBar from './components/IssueActionsBar'; import IssueCommentLine from './components/IssueCommentLine'; import { updateIssue } from './actions'; import { deleteIssueComment, editIssueComment } from '../../api/issues'; -import { Issue, BranchLike } from '../../app/types'; interface Props { - branchLike?: BranchLike; + branchLike?: T.BranchLike; checked?: boolean; currentPopup?: string; displayLocationsCount?: boolean; displayLocationsLink?: boolean; - issue: Issue; + issue: T.Issue; onAssign: (login: string) => void; - onChange: (issue: Issue) => void; + onChange: (issue: T.Issue) => void; onCheck?: (issue: string, event: { shiftKey?: boolean }) => void; onClick: (issueKey: string) => void; - onFilter?: (property: string, issue: Issue) => void; + onFilter?: (property: string, issue: T.Issue) => void; selected: boolean; togglePopup: (popup: string, show: boolean | void) => void; } diff --git a/server/sonar-web/src/main/js/components/issue/actions.ts b/server/sonar-web/src/main/js/components/issue/actions.ts index 763c3b2baca..f00f6599d77 100644 --- a/server/sonar-web/src/main/js/components/issue/actions.ts +++ b/server/sonar-web/src/main/js/components/issue/actions.ts @@ -18,14 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { parseIssueFromResponse } from '../../helpers/issues'; -import { Issue } from '../../app/types'; import { IssueResponse } from '../../api/issues'; export const updateIssue = ( - onChange: (issue: Issue) => void, + onChange: (issue: T.Issue) => void, resultPromise: Promise, - oldIssue?: Issue, - newIssue?: Issue + oldIssue?: T.Issue, + newIssue?: T.Issue ) => { const optimisticUpdate = oldIssue !== undefined && newIssue !== undefined; if (optimisticUpdate) { diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx index ae74f0131f9..a800041b208 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueActionsBar.tsx @@ -25,16 +25,15 @@ import IssueTags from './IssueTags'; import IssueTransition from './IssueTransition'; import IssueType from './IssueType'; import { updateIssue } from '../actions'; -import { IssueType as IssueTypes, Issue } from '../../../app/types'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { RawQuery } from '../../../helpers/query'; import { IssueResponse } from '../../../api/issues'; interface Props { - issue: Issue; + issue: T.Issue; currentPopup?: string; onAssign: (login: string) => void; - onChange: (issue: Issue) => void; + onChange: (issue: T.Issue) => void; togglePopup: (popup: string, show?: boolean) => void; } @@ -48,7 +47,7 @@ export default class IssueActionsBar extends React.PureComponent { }; setIssueProperty = ( - property: keyof Issue, + property: keyof T.Issue, popup: string, apiCall: (query: RawQuery) => Promise, value: string @@ -71,11 +70,11 @@ export default class IssueActionsBar extends React.PureComponent { this.props.togglePopup('comment', open); }; - handleTransition = (issue: Issue) => { + handleTransition = (issue: T.Issue) => { this.props.onChange(issue); if ( issue.resolution === 'FALSE-POSITIVE' || - (issue.resolution === 'WONTFIX' && issue.type !== IssueTypes.Hotspot) + (issue.resolution === 'WONTFIX' && issue.type !== 'SECURITY_HOTSPOT') ) { this.toggleComment(true, translate('issue.comment.tell_why')); } @@ -89,7 +88,7 @@ export default class IssueActionsBar extends React.PureComponent { const canSetType = issue.actions.includes('set_type'); const canSetTags = issue.actions.includes('set_tags'); const hasTransitions = issue.transitions && issue.transitions.length > 0; - const isSecurityHotspot = issue.type === IssueTypes.Hotspot; + const isSecurityHotspot = issue.type === 'SECURITY_HOTSPOT'; return (

    diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueAssign.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueAssign.tsx index 34072ed3d2c..b65e3c2e53d 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueAssign.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueAssign.tsx @@ -24,11 +24,10 @@ import Toggler from '../../controls/Toggler'; import DropdownIcon from '../../icons-components/DropdownIcon'; import { Button } from '../../ui/buttons'; import { translate } from '../../../helpers/l10n'; -import { Issue } from '../../../app/types'; interface Props { isOpen: boolean; - issue: Pick; + issue: Pick; canAssign: boolean; onAssign: (login: string) => void; togglePopup: (popup: string, show?: boolean) => void; diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.tsx index 19e8b1a3ca5..70d4c8ee1dc 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueChangelog.tsx @@ -25,11 +25,10 @@ import DateTimeFormatter from '../../intl/DateTimeFormatter'; import Toggler from '../../controls/Toggler'; import Tooltip from '../../controls/Tooltip'; import { Button } from '../../ui/buttons'; -import { Issue } from '../../../app/types'; interface Props { isOpen: boolean; - issue: Pick; + issue: Pick; creationDate: string; togglePopup: (popup: string, show?: boolean) => void; } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.tsx index 950c88e89ae..39ab83ff97a 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueCommentAction.tsx @@ -24,13 +24,12 @@ import { Button } from '../../ui/buttons'; import CommentPopup from '../popups/CommentPopup'; import { addIssueComment } from '../../../api/issues'; import { translate } from '../../../helpers/l10n'; -import { Issue } from '../../../app/types'; interface Props { commentPlaceholder: string; currentPopup?: string; issueKey: string; - onChange: (issue: Issue) => void; + onChange: (issue: T.Issue) => void; toggleComment: (open?: boolean, placeholder?: string) => void; } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.tsx index ce516d1775a..9e3c10690b0 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueCommentLine.tsx @@ -24,10 +24,9 @@ import { EditButton, DeleteButton } from '../../ui/buttons'; import CommentDeletePopup from '../popups/CommentDeletePopup'; import CommentPopup from '../popups/CommentPopup'; import DateFromNow from '../../intl/DateFromNow'; -import { IssueComment } from '../../../app/types'; interface Props { - comment: IssueComment; + comment: T.IssueComment; onDelete: (comment: string) => void; onEdit: (comment: string, text: string) => void; } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.tsx index 3913c36af51..8823284000e 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueSeverity.tsx @@ -24,15 +24,14 @@ import Toggler from '../../controls/Toggler'; import DropdownIcon from '../../icons-components/DropdownIcon'; import SeverityHelper from '../../shared/SeverityHelper'; import { Button } from '../../ui/buttons'; -import { Issue } from '../../../app/types'; import { RawQuery } from '../../../helpers/query'; interface Props { canSetSeverity: boolean; isOpen: boolean; - issue: Pick; + issue: Pick; setIssueProperty: ( - property: keyof Issue, + property: keyof T.Issue, popup: string, apiCall: (query: RawQuery) => Promise, value: string diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTags.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueTags.tsx index c0b8cb68f40..d0ae952a225 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTags.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTags.tsx @@ -25,13 +25,12 @@ import Toggler from '../../controls/Toggler'; import TagsList from '../../tags/TagsList'; import { Button } from '../../ui/buttons'; import { translate } from '../../../helpers/l10n'; -import { Issue } from '../../../app/types'; interface Props { canSetTags: boolean; isOpen: boolean; - issue: Pick; - onChange: (issue: Issue) => void; + issue: Pick; + onChange: (issue: T.Issue) => void; togglePopup: (popup: string, show?: boolean) => void; } @@ -46,8 +45,8 @@ export default class IssueTags extends React.PureComponent { updateIssue( this.props.onChange, setIssueTags({ issue: issue.key, tags: tags.join(',') }), - issue as Issue, - newIssue as Issue + issue as T.Issue, + newIssue as T.Issue ); }; diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx index 11a869003e9..25739813227 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx @@ -29,15 +29,14 @@ import { getBranchLikeQuery } from '../../../helpers/branches'; import { getComponentIssuesUrl } from '../../../helpers/urls'; import { formatMeasure } from '../../../helpers/measures'; import { translate, translateWithParameters } from '../../../helpers/l10n'; -import { IssueType, BranchLike, Issue } from '../../../app/types'; interface Props { - branchLike?: BranchLike; + branchLike?: T.BranchLike; currentPopup?: string; displayLocationsCount?: boolean; displayLocationsLink?: boolean; - issue: Issue; - onFilter?: (property: string, issue: Issue) => void; + issue: T.Issue; + onFilter?: (property: string, issue: T.Issue) => void; togglePopup: (popup: string, show?: boolean) => void; } @@ -71,7 +70,7 @@ export default function IssueTitleBar(props: Props) {
    ; - onChange: (issue: Issue) => void; + issue: Pick; + onChange: (issue: T.Issue) => void; togglePopup: (popup: string, show?: boolean) => void; } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueType.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueType.tsx index 6d38647517a..b99f152e9a4 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueType.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueType.tsx @@ -25,15 +25,14 @@ import DropdownIcon from '../../icons-components/DropdownIcon'; import { Button } from '../../ui/buttons'; import IssueTypeIcon from '../../ui/IssueTypeIcon'; import { translate } from '../../../helpers/l10n'; -import { Issue } from '../../../app/types'; import { RawQuery } from '../../../helpers/query'; interface Props { canSetType: boolean; isOpen: boolean; - issue: Pick; + issue: Pick; setIssueProperty: ( - property: keyof Issue, + property: keyof T.Issue, popup: string, apiCall: (query: RawQuery) => Promise, value: string diff --git a/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.tsx b/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.tsx index 2af9d3a8ff3..60fb22dfe6c 100644 --- a/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/SimilarIssuesFilter.tsx @@ -24,17 +24,16 @@ import DropdownIcon from '../../icons-components/DropdownIcon'; import FilterIcon from '../../icons-components/FilterIcon'; import { Button } from '../../ui/buttons'; import { translate } from '../../../helpers/l10n'; -import { Issue } from '../../../app/types'; interface Props { isOpen: boolean; - issue: Issue; + issue: T.Issue; togglePopup: (popup: string, show?: boolean) => void; - onFilter?: (property: string, issue: Issue) => void; + onFilter?: (property: string, issue: T.Issue) => void; } export default class SimilarIssuesFilter extends React.PureComponent { - handleFilter = (property: string, issue: Issue) => { + handleFilter = (property: string, issue: T.Issue) => { this.togglePopup(false); if (this.props.onFilter) { this.props.onFilter(property, issue); diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.tsx b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.tsx index ce358423f35..0ce8f9f43d7 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueCommentLine-test.tsx @@ -21,9 +21,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import IssueCommentLine from '../IssueCommentLine'; import { click } from '../../../../helpers/testUtils'; -import { IssueComment } from '../../../../app/types'; -const comment: IssueComment = { +const comment: T.IssueComment = { authorAvatar: 'gravatarhash', authorName: 'John Doe', createdAt: '2017-03-01T09:36:01+0100', diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.tsx b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.tsx index 43b0c9a8f21..6dcfe67f543 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.tsx @@ -20,15 +20,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import IssueTitleBar from '../IssueTitleBar'; -import { - ShortLivingBranch, - Issue, - BranchType, - IssueType, - FlowLocation -} from '../../../../app/types'; -const issue: Issue = { +const issue: T.Issue = { actions: [], component: 'main.js', componentLongName: 'main.js', @@ -52,16 +45,16 @@ const issue: Issue = { status: 'OPEN', textRange: { startLine: 25, endLine: 26, startOffset: 0, endOffset: 15 }, transitions: [], - type: IssueType.Bug + type: 'BUG' }; -const issueWithLocations: Issue = { +const issueWithLocations: T.Issue = { ...issue, flows: [[loc(), loc(), loc()], [loc(), loc()]], secondaryLocations: [loc(), loc()] }; -function loc(): FlowLocation { +function loc(): T.FlowLocation { return { component: 'main.js', textRange: { startLine: 1, startOffset: 1, endLine: 2, endOffset: 2 } @@ -69,11 +62,11 @@ function loc(): FlowLocation { } it('should render the titlebar correctly', () => { - const branch: ShortLivingBranch = { + const branch: T.ShortLivingBranch = { isMain: false, mergeBranch: 'master', name: 'feature-1.0', - type: BranchType.SHORT + type: 'SHORT' }; const element = shallow( diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueType-test.tsx b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueType-test.tsx index a7d62b447c1..e078ebb237e 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueType-test.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueType-test.tsx @@ -21,10 +21,9 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import IssueType from '../IssueType'; import { click } from '../../../../helpers/testUtils'; -import { IssueType as Type } from '../../../../app/types'; -const issue = { - type: Type.Bug +const issue: Pick = { + type: 'BUG' }; it('should render without the action when the correct rights are missing', () => { diff --git a/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.tsx index 394fa2567d1..d8ee5dcd763 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/ChangelogPopup.tsx @@ -24,7 +24,6 @@ import Avatar from '../../ui/Avatar'; import DateTimeFormatter from '../../intl/DateTimeFormatter'; import IssueChangelogDiff, { ChangelogDiff } from '../components/IssueChangelogDiff'; import { DropdownOverlay } from '../../controls/Dropdown'; -import { Issue } from '../../../app/types'; interface Changelog { avatar?: string; @@ -35,7 +34,7 @@ interface Changelog { } interface Props { - issue: Pick; + issue: Pick; } interface State { diff --git a/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx index fe399cd8d4c..68d3933ee06 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/CommentPopup.tsx @@ -22,10 +22,9 @@ import MarkdownTips from '../../common/MarkdownTips'; import { Button, ResetButtonLink } from '../../ui/buttons'; import { translate } from '../../../helpers/l10n'; import { DropdownOverlay } from '../../controls/Dropdown'; -import { IssueComment } from '../../../app/types'; interface Props { - comment?: Pick; + comment?: Pick; onComment: (text: string) => void; toggleComment: (visible: boolean) => void; placeholder: string; diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx index 6d4e9744ebd..872760f182a 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SetAssigneePopup.tsx @@ -29,7 +29,6 @@ import { searchUsers } from '../../../api/users'; import { translate } from '../../../helpers/l10n'; import { getCurrentUser, Store } from '../../../store/rootReducer'; import { DropdownOverlay } from '../../controls/Dropdown'; -import { Issue, CurrentUser, OrganizationMember } from '../../../app/types'; import { isSonarCloud } from '../../../helpers/system'; import { isLoggedIn } from '../../../helpers/users'; @@ -41,8 +40,8 @@ interface User { } interface Props { - currentUser: CurrentUser; - issue: Pick; + currentUser: T.CurrentUser; + issue: Pick; onSelect: (login: string) => void; } @@ -84,7 +83,7 @@ class SetAssigneePopup extends React.PureComponent { searchUsers({ q: query, ps: LIST_SIZE }).then(this.handleSearchResult, () => {}); }; - handleSearchResult = (response: { users: OrganizationMember[] }) => { + handleSearchResult = (response: { users: T.OrganizationMember[] }) => { this.setState({ users: response.users, currentUser: response.users.length > 0 ? response.users[0].login : '' diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.tsx index dbefb623d92..49e4534f987 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.tsx @@ -23,10 +23,9 @@ import SelectList from '../../common/SelectList'; import SelectListItem from '../../common/SelectListItem'; import SeverityIcon from '../../icons-components/SeverityIcon'; import { DropdownOverlay } from '../../controls/Dropdown'; -import { Issue } from '../../../app/types'; type Props = { - issue: Pick; + issue: Pick; onSelect: (severity: string) => void; }; diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.tsx index 9deb10ced76..35db527ed9d 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.tsx @@ -23,14 +23,13 @@ import IssueTypeIcon from '../../ui/IssueTypeIcon'; import SelectList from '../../common/SelectList'; import SelectListItem from '../../common/SelectListItem'; import { DropdownOverlay } from '../../controls/Dropdown'; -import { Issue, IssueType } from '../../../app/types'; interface Props { - issue: Pick; - onSelect: (type: IssueType) => void; + issue: Pick; + onSelect: (type: T.IssueType) => void; } -const TYPES = [IssueType.Bug, IssueType.Vulnerability, IssueType.CodeSmell]; +const TYPES = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; export default function SetTypePopup({ issue, onSelect }: Props) { return ( diff --git a/server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.tsx index 85f8a606ab1..c75c01b1b65 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.tsx @@ -29,11 +29,10 @@ import IssueTypeIcon from '../../ui/IssueTypeIcon'; import Avatar from '../../ui/Avatar'; import { translate } from '../../../helpers/l10n'; import { fileFromPath, limitComponentName } from '../../../helpers/path'; -import { Issue } from '../../../app/types'; interface Props { - issue: Issue; - onFilter: (property: string, issue: Issue) => void; + issue: T.Issue; + onFilter: (property: string, issue: T.Issue) => void; } export default class SimilarIssuesPopup extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/components/issue/popups/__tests__/SetTypePopup-test.tsx b/server/sonar-web/src/main/js/components/issue/popups/__tests__/SetTypePopup-test.tsx index 20d17bb4fbf..3de436bf1c3 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/__tests__/SetTypePopup-test.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/__tests__/SetTypePopup-test.tsx @@ -20,9 +20,8 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import SetTypePopup from '../SetTypePopup'; -import { IssueType } from '../../../../app/types'; it('should render tags popup correctly', () => { - const element = shallow(); + const element = shallow(); expect(element).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/measure/utils.ts b/server/sonar-web/src/main/js/components/measure/utils.ts index e5851a5f956..7442298c091 100644 --- a/server/sonar-web/src/main/js/components/measure/utils.ts +++ b/server/sonar-web/src/main/js/components/measure/utils.ts @@ -18,15 +18,14 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getRatingTooltip as nextGetRatingTooltip, isDiffMetric } from '../../helpers/measures'; -import { Metric, Measure, MeasureEnhanced } from '../../app/types'; import { getLeakPeriod } from '../../helpers/periods'; const KNOWN_RATINGS = ['sqale_rating', 'reliability_rating', 'security_rating']; export function enhanceMeasure( - measure: Measure, - metrics: { [key: string]: Metric } -): MeasureEnhanced { + measure: T.Measure, + metrics: { [key: string]: T.Metric } +): T.MeasureEnhanced { return { ...measure, metric: metrics[measure.metric], @@ -34,7 +33,7 @@ export function enhanceMeasure( }; } -export function getLeakValue(measure: Measure | undefined): string | undefined { +export function getLeakValue(measure: T.Measure | undefined): string | undefined { if (!measure || !measure.periods) { return undefined; } diff --git a/server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx b/server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx index 10941bae6b7..177af3e2515 100644 --- a/server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx +++ b/server/sonar-web/src/main/js/components/preview-graph/PreviewGraph.tsx @@ -37,16 +37,15 @@ import { import { get } from '../../helpers/storage'; import { formatMeasure, getShortType } from '../../helpers/measures'; import { getBranchLikeQuery } from '../../helpers/branches'; -import { BranchLike, Metric } from '../../app/types'; interface History { [x: string]: Array<{ date: Date; value?: string }>; } interface Props { - branchLike?: BranchLike; + branchLike?: T.BranchLike; history?: History; - metrics: { [key: string]: Metric }; + metrics: { [key: string]: T.Metric }; project: string; renderWhenEmpty?: () => React.ReactNode; } @@ -120,7 +119,7 @@ export default class PreviewGraph extends React.PureComponent { history: History | undefined, graph: string, customMetrics: string[], - metrics: { [x: string]: Metric } + metrics: { [x: string]: T.Metric } ) => { const myHistory = history; if (!myHistory) { diff --git a/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx b/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx index b711cdb4783..714830dafe1 100644 --- a/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx +++ b/server/sonar-web/src/main/js/components/shared/DrilldownLink.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { Link } from 'react-router'; import { getComponentDrilldownUrl, getComponentIssuesUrl } from '../../helpers/urls'; -import { BranchLike, IssueType } from '../../app/types'; import { getBranchLikeQuery } from '../../helpers/branches'; const ISSUE_MEASURES = [ @@ -49,7 +48,7 @@ const ISSUE_MEASURES = [ ]; interface Props { - branchLike?: BranchLike; + branchLike?: T.BranchLike; children?: React.ReactNode; className?: string; component: string; @@ -104,15 +103,15 @@ export default class DrilldownLink extends React.PureComponent { break; case 'code_smells': case 'new_code_smells': - Object.assign(params, { resolved: 'false', types: IssueType.CodeSmell }); + Object.assign(params, { resolved: 'false', types: 'CODE_SMELL' }); break; case 'bugs': case 'new_bugs': - Object.assign(params, { resolved: 'false', types: IssueType.Bug }); + Object.assign(params, { resolved: 'false', types: 'BUG' }); break; case 'vulnerabilities': case 'new_vulnerabilities': - Object.assign(params, { resolved: 'false', types: IssueType.Vulnerability }); + Object.assign(params, { resolved: 'false', types: 'VULNERABILITY' }); break; default: Object.assign(params, { resolved: 'false' }); diff --git a/server/sonar-web/src/main/js/components/shared/TypeHelper.tsx b/server/sonar-web/src/main/js/components/shared/TypeHelper.tsx index f397063230e..110f0517460 100644 --- a/server/sonar-web/src/main/js/components/shared/TypeHelper.tsx +++ b/server/sonar-web/src/main/js/components/shared/TypeHelper.tsx @@ -20,11 +20,10 @@ import * as React from 'react'; import IssueTypeIcon from '../ui/IssueTypeIcon'; import { translate } from '../../helpers/l10n'; -import { RuleType, IssueType } from '../../app/types'; interface Props { className?: string; - type: IssueType | RuleType; + type: T.IssueType | T.RuleType; } export default function TypeHelper(props: Props) { diff --git a/server/sonar-web/src/main/js/components/ui/IdentityProviderLink.tsx b/server/sonar-web/src/main/js/components/ui/IdentityProviderLink.tsx index 75354424c63..7d945daa970 100644 --- a/server/sonar-web/src/main/js/components/ui/IdentityProviderLink.tsx +++ b/server/sonar-web/src/main/js/components/ui/IdentityProviderLink.tsx @@ -21,13 +21,12 @@ import * as React from 'react'; import * as classNames from 'classnames'; import { isDarkColor } from '../../helpers/colors'; import { getBaseUrl } from '../../helpers/urls'; -import { IdentityProvider } from '../../app/types'; import './IdentityProviderLink.css'; interface Props { children: React.ReactNode; className?: string; - identityProvider: IdentityProvider; + identityProvider: T.IdentityProvider; onClick?: () => void; small?: boolean; url: string | undefined; diff --git a/server/sonar-web/src/main/js/components/ui/OrganizationListItem.tsx b/server/sonar-web/src/main/js/components/ui/OrganizationListItem.tsx index 11ab3e1a6c4..46b1d9087f3 100644 --- a/server/sonar-web/src/main/js/components/ui/OrganizationListItem.tsx +++ b/server/sonar-web/src/main/js/components/ui/OrganizationListItem.tsx @@ -19,12 +19,11 @@ */ import * as React from 'react'; import OrganizationLink from './OrganizationLink'; -import { Organization } from '../../app/types'; import OrganizationAvatar from '../common/OrganizationAvatar'; import { translate } from '../../helpers/l10n'; interface Props { - organization: Organization; + organization: T.Organization; } export default function OrganizationListItem({ organization }: Props) { diff --git a/server/sonar-web/src/main/js/components/ui/__tests__/OrganizationListItem-test.tsx b/server/sonar-web/src/main/js/components/ui/__tests__/OrganizationListItem-test.tsx index ed060178aa8..0c82a1789ad 100644 --- a/server/sonar-web/src/main/js/components/ui/__tests__/OrganizationListItem-test.tsx +++ b/server/sonar-web/src/main/js/components/ui/__tests__/OrganizationListItem-test.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import OrganizationListItem from '../OrganizationListItem'; -import { Visibility } from '../../../app/types'; it('renders', () => { expect( @@ -30,7 +29,7 @@ it('renders', () => { actions: { admin: true }, key: 'org', name: 'org', - projectVisibility: Visibility.Public + projectVisibility: 'public' }} /> ) diff --git a/server/sonar-web/src/main/js/components/ui/buttons.tsx b/server/sonar-web/src/main/js/components/ui/buttons.tsx index 1e9d8bb866f..371fa16dfa9 100644 --- a/server/sonar-web/src/main/js/components/ui/buttons.tsx +++ b/server/sonar-web/src/main/js/components/ui/buttons.tsx @@ -20,7 +20,6 @@ import * as React from 'react'; import * as classNames from 'classnames'; import * as theme from '../../app/theme'; -import { Omit } from '../../app/types'; import ClearIcon from '../icons-components/ClearIcon'; import EditIcon from '../icons-components/EditIcon'; import Tooltip from '../controls/Tooltip'; @@ -77,12 +76,12 @@ export class Button extends React.PureComponent { } } -export function SubmitButton(props: Omit) { +export function SubmitButton(props: T.Omit) { // do not prevent default to actually submit a form return