From 7983068e4d2a45531ba0942688e659adf9ee61a2 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 18 Aug 2017 18:53:44 +0200 Subject: [PATCH] translate all routes files to ts (#2378) --- server/sonar-web/package.json | 21 ++- .../js/apps/about/{routes.js => routes.ts} | 4 +- .../js/apps/account/projects/ProjectCard.js | 94 -------------- .../js/apps/account/projects/ProjectCard.tsx | 94 ++++++++++++++ .../main/js/apps/account/projects/Projects.js | 67 ---------- .../js/apps/account/projects/Projects.tsx | 65 ++++++++++ ...ectsContainer.js => ProjectsContainer.tsx} | 34 ++--- .../js/apps/account/projects/propTypes.js | 34 ----- .../main/js/apps/account/projects/types.ts | 32 +++++ .../js/apps/account/{routes.js => routes.ts} | 16 ++- .../background-tasks/{routes.js => routes.ts} | 4 +- .../js/apps/code/{routes.js => routes.ts} | 4 +- .../coding-rules/{routes.js => routes.ts} | 4 +- .../{routes.js => routes.ts} | 8 +- .../component/components/{App.js => App.tsx} | 21 ++- .../apps/component/{routes.js => routes.ts} | 4 +- .../custom-measures/{routes.js => routes.ts} | 4 +- .../js/apps/groups/{routes.js => routes.ts} | 4 +- .../js/apps/issues/{routes.js => routes.ts} | 3 +- ...ntainer.js => MaintenanceAppContainer.tsx} | 2 +- ...pAppContainer.js => SetupAppContainer.tsx} | 2 +- .../maintenance/{routes.js => routes.tsx} | 2 +- ...ppContainer.js => MetricsAppContainer.tsx} | 2 +- .../js/apps/metrics/{routes.js => routes.ts} | 4 +- .../ApplicationQualityGate-test.js.snap | 2 - .../js/apps/overview/{routes.js => routes.ts} | 4 +- .../{routes.js => routes.ts} | 4 +- .../apps/permissions/{routes.js => routes.ts} | 6 +- .../projectActivity/{routes.js => routes.ts} | 4 +- .../projects-admin/{routes.js => routes.ts} | 4 +- .../projects/components/{App.js => App.tsx} | 3 +- .../js/apps/projects/{routes.js => routes.ts} | 9 +- .../quality-gates/{routes.js => routes.ts} | 8 +- ...{utils-test.js.snap => utils-test.ts.snap} | 12 ++ .../{utils-test.js => utils-test.ts} | 7 +- .../quality-profiles/changelog/Changelog.js | 122 ------------------ .../quality-profiles/changelog/Changelog.tsx | 109 ++++++++++++++++ ...logContainer.js => ChangelogContainer.tsx} | 112 ++++++++-------- .../{ChangelogEmpty.js => ChangelogEmpty.tsx} | 17 +-- ...ChangelogSearch.js => ChangelogSearch.tsx} | 29 ++--- .../{ChangesList.js => ChangesList.tsx} | 41 +++--- ...ParameterChange.js => ParameterChange.tsx} | 43 +++--- .../{SeverityChange.js => SeverityChange.tsx} | 28 ++-- .../{Changelog-test.js => Changelog-test.tsx} | 20 +-- ...earch-test.js => ChangelogSearch-test.tsx} | 2 +- ...angesList-test.js => ChangesList-test.tsx} | 2 +- ...hange-test.js => ParameterChange-test.tsx} | 4 +- ...Change-test.js => SeverityChange-test.tsx} | 2 +- ...onContainer.js => ComparisonContainer.tsx} | 70 +++++----- ...ComparisonEmpty.js => ComparisonEmpty.tsx} | 17 +-- .../{ComparisonForm.js => ComparisonForm.tsx} | 27 ++-- ...arisonResults.js => ComparisonResults.tsx} | 40 +++--- ...onForm-test.js => ComparisonForm-test.tsx} | 5 +- ...lts-test.js => ComparisonResults-test.tsx} | 4 +- .../components/{App.js => App.tsx} | 42 +++--- .../{AppContainer.js => AppContainer.tsx} | 8 +- .../{BuiltInBadge.js => BuiltInBadge.tsx} | 25 ++-- ...CopyProfileForm.js => CopyProfileForm.tsx} | 50 ++++--- ...teProfileForm.js => DeleteProfileForm.tsx} | 41 +++--- .../{ProfileActions.js => ProfileActions.tsx} | 64 +++++---- ...ofileContainer.js => ProfileContainer.tsx} | 35 +++-- .../{ProfileDate.js => ProfileDate.tsx} | 37 ++---- .../{ProfileLink.js => ProfileLink.tsx} | 41 +++--- ...ProfileNotFound.js => ProfileNotFound.tsx} | 39 +++--- ...meProfileForm.js => RenameProfileForm.tsx} | 48 +++---- ...iner-test.js => ProfileContainer-test.tsx} | 25 ++-- ...angeParentForm.js => ChangeParentForm.tsx} | 61 ++++----- ...ProjectsForm.js => ChangeProjectsForm.tsx} | 38 +++--- .../{ProfileDetails.js => ProfileDetails.tsx} | 55 ++++---- ...ofileExporters.js => ProfileExporters.tsx} | 27 ++-- .../{ProfileHeader.js => ProfileHeader.tsx} | 25 ++-- ...eInheritance.js => ProfileInheritance.tsx} | 100 +++++++------- .../details/ProfileInheritanceBox.js | 93 ------------- .../details/ProfileInheritanceBox.tsx | 82 ++++++++++++ ...ProfileProjects.js => ProfileProjects.tsx} | 53 ++++---- .../{ProfileRules.js => ProfileRules.tsx} | 62 ++++----- ...g.js => ProfileRulesDeprecatedWarning.tsx} | 13 +- ...RowOfType.js => ProfileRulesRowOfType.tsx} | 25 ++-- ...esRowTotal.js => ProfileRulesRowTotal.tsx} | 23 ++-- ....js => ProfileRulesSonarWayComparison.tsx} | 21 ++- ...ileRules-test.js => ProfileRules-test.tsx} | 29 ++--- ...=> ProfileRulesDeprecatedWarning-test.tsx} | 3 +- ...test.js => ProfileRulesRowOfType-test.tsx} | 3 +- ...-test.js => ProfileRulesRowTotal-test.tsx} | 3 +- ...> ProfileRulesSonarWayComparison-test.tsx} | 3 +- ...est.js.snap => ProfileRules-test.tsx.snap} | 0 ...ofileRulesDeprecatedWarning-test.tsx.snap} | 0 ...ap => ProfileRulesRowOfType-test.tsx.snap} | 0 ...nap => ProfileRulesRowTotal-test.tsx.snap} | 0 ...fileRulesSonarWayComparison-test.tsx.snap} | 0 ...teProfileForm.js => CreateProfileForm.tsx} | 82 ++++++------ .../home/{Evolution.js => Evolution.tsx} | 37 ++---- .../home/EvolutionDeprecated.js | 96 -------------- .../home/EvolutionDeprecated.tsx | 86 ++++++++++++ .../{EvolutionRules.js => EvolutionRules.tsx} | 44 ++++--- .../home/EvolutionStagnant.js | 80 ------------ .../home/EvolutionStagnant.tsx | 73 +++++++++++ .../{HomeContainer.js => HomeContainer.tsx} | 53 ++++---- .../home/{PageHeader.js => PageHeader.tsx} | 45 +++---- .../{ProfilesList.js => ProfilesList.tsx} | 54 ++++---- ...esListHeader.js => ProfilesListHeader.tsx} | 19 +-- ...ProfilesListRow.js => ProfilesListRow.tsx} | 38 +++--- ...eProfileForm.js => RestoreProfileForm.tsx} | 54 ++++---- .../js/apps/quality-profiles/propTypes.js | 76 ----------- .../quality-profiles/{routes.js => routes.ts} | 14 +- .../main/js/apps/quality-profiles/types.ts | 53 ++++++++ .../quality-profiles/{utils.js => utils.ts} | 50 +++---- .../apps/sessions/components/Unauthorized.js | 49 ------- .../apps/sessions/components/Unauthorized.tsx | 50 +++++++ .../js/apps/sessions/{routes.js => routes.ts} | 8 +- .../js/apps/settings/{routes.js => routes.ts} | 10 +- .../src/main/js/apps/system/routes.js | 28 ---- .../src/main/js/apps/system/routes.ts | 30 +++++ .../update-center/{routes.js => routes.ts} | 12 +- .../js/apps/users/{routes.js => routes.ts} | 4 +- .../js/apps/web-api/{routes.js => routes.ts} | 10 +- .../main/js/components/SelectList/index.js | 7 +- .../controls/{DateInput.js => DateInput.tsx} | 42 +++--- .../main/js/components/controls/ListFooter.js | 70 ---------- .../js/components/controls/ListFooter.tsx | 61 +++++++++ .../controls/{Tooltip.js => Tooltip.tsx} | 28 ++-- .../{BugIcon.js => BugIcon.tsx} | 12 +- .../{CodeSmellIcon.js => CodeSmellIcon.tsx} | 12 +- ...erabilityIcon.js => VulnerabilityIcon.tsx} | 12 +- .../js/components/shared/QualifierIcon.js | 45 ------- .../js/components/shared/QualifierIcon.tsx | 36 ++++++ .../{IssueTypeIcon.js => IssueTypeIcon.tsx} | 69 +++++----- .../src/main/js/components/ui/Level.js | 51 -------- .../src/main/js/components/ui/Level.tsx | 43 ++++++ .../src/main/js/typings/rc-tooltip.d.ts | 54 ++++++++ server/sonar-web/tsconfig.json | 2 +- server/sonar-web/yarn.lock | 26 ++++ 132 files changed, 2014 insertions(+), 2171 deletions(-) rename server/sonar-web/src/main/js/apps/about/{routes.js => routes.ts} (86%) delete mode 100644 server/sonar-web/src/main/js/apps/account/projects/ProjectCard.js create mode 100644 server/sonar-web/src/main/js/apps/account/projects/ProjectCard.tsx delete mode 100644 server/sonar-web/src/main/js/apps/account/projects/Projects.js create mode 100644 server/sonar-web/src/main/js/apps/account/projects/Projects.tsx rename server/sonar-web/src/main/js/apps/account/projects/{ProjectsContainer.js => ProjectsContainer.tsx} (81%) delete mode 100644 server/sonar-web/src/main/js/apps/account/projects/propTypes.js create mode 100644 server/sonar-web/src/main/js/apps/account/projects/types.ts rename server/sonar-web/src/main/js/apps/account/{routes.js => routes.ts} (71%) rename server/sonar-web/src/main/js/apps/background-tasks/{routes.js => routes.ts} (86%) rename server/sonar-web/src/main/js/apps/code/{routes.js => routes.ts} (86%) rename server/sonar-web/src/main/js/apps/coding-rules/{routes.js => routes.ts} (86%) rename server/sonar-web/src/main/js/apps/component-measures/{routes.js => routes.ts} (85%) rename server/sonar-web/src/main/js/apps/component/components/{App.js => App.tsx} (89%) rename server/sonar-web/src/main/js/apps/component/{routes.js => routes.ts} (86%) rename server/sonar-web/src/main/js/apps/custom-measures/{routes.js => routes.ts} (87%) rename server/sonar-web/src/main/js/apps/groups/{routes.js => routes.ts} (89%) rename server/sonar-web/src/main/js/apps/issues/{routes.js => routes.ts} (87%) rename server/sonar-web/src/main/js/apps/maintenance/components/{MaintenanceAppContainer.js => MaintenanceAppContainer.tsx} (97%) rename server/sonar-web/src/main/js/apps/maintenance/components/{SetupAppContainer.js => SetupAppContainer.tsx} (97%) rename server/sonar-web/src/main/js/apps/maintenance/{routes.js => routes.tsx} (97%) rename server/sonar-web/src/main/js/apps/metrics/components/{MetricsAppContainer.js => MetricsAppContainer.tsx} (97%) rename server/sonar-web/src/main/js/apps/metrics/{routes.js => routes.ts} (87%) rename server/sonar-web/src/main/js/apps/overview/{routes.js => routes.ts} (86%) rename server/sonar-web/src/main/js/apps/permission-templates/{routes.js => routes.ts} (88%) rename server/sonar-web/src/main/js/apps/permissions/{routes.js => routes.ts} (85%) rename server/sonar-web/src/main/js/apps/projectActivity/{routes.js => routes.ts} (87%) rename server/sonar-web/src/main/js/apps/projects-admin/{routes.js => routes.ts} (88%) rename server/sonar-web/src/main/js/apps/projects/components/{App.js => App.tsx} (97%) rename server/sonar-web/src/main/js/apps/projects/{routes.js => routes.ts} (76%) rename server/sonar-web/src/main/js/apps/quality-gates/{routes.js => routes.ts} (78%) rename server/sonar-web/src/main/js/apps/quality-profiles/__tests__/__snapshots__/{utils-test.js.snap => utils-test.ts.snap} (92%) rename server/sonar-web/src/main/js/apps/quality-profiles/__tests__/{utils-test.js => utils-test.ts} (92%) delete mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.js create mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx rename server/sonar-web/src/main/js/apps/quality-profiles/changelog/{ChangelogContainer.js => ChangelogContainer.tsx} (73%) rename server/sonar-web/src/main/js/apps/quality-profiles/changelog/{ChangelogEmpty.js => ChangelogEmpty.tsx} (79%) rename server/sonar-web/src/main/js/apps/quality-profiles/changelog/{ChangelogSearch.js => ChangelogSearch.tsx} (84%) rename server/sonar-web/src/main/js/apps/quality-profiles/changelog/{ChangesList.js => ChangesList.tsx} (63%) rename server/sonar-web/src/main/js/apps/quality-profiles/changelog/{ParameterChange.js => ParameterChange.tsx} (63%) rename server/sonar-web/src/main/js/apps/quality-profiles/changelog/{SeverityChange.js => SeverityChange.tsx} (73%) rename server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/{Changelog-test.js => Changelog-test.tsx} (74%) rename server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/{ChangelogSearch-test.js => ChangelogSearch-test.tsx} (98%) rename server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/{ChangesList-test.js => ChangesList-test.tsx} (98%) rename server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/{ParameterChange-test.js => ParameterChange-test.tsx} (91%) rename server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/{SeverityChange-test.js => SeverityChange-test.tsx} (97%) rename server/sonar-web/src/main/js/apps/quality-profiles/compare/{ComparisonContainer.js => ComparisonContainer.tsx} (74%) rename server/sonar-web/src/main/js/apps/quality-profiles/compare/{ComparisonEmpty.js => ComparisonEmpty.tsx} (78%) rename server/sonar-web/src/main/js/apps/quality-profiles/compare/{ComparisonForm.js => ComparisonForm.tsx} (80%) rename server/sonar-web/src/main/js/apps/quality-profiles/compare/{ComparisonResults.js => ComparisonResults.tsx} (87%) rename server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/{ComparisonForm-test.js => ComparisonForm-test.tsx} (95%) rename server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/{ComparisonResults-test.js => ComparisonResults-test.tsx} (97%) rename server/sonar-web/src/main/js/apps/quality-profiles/components/{App.js => App.tsx} (83%) rename server/sonar-web/src/main/js/apps/quality-profiles/components/{AppContainer.js => AppContainer.tsx} (84%) rename server/sonar-web/src/main/js/apps/quality-profiles/components/{BuiltInBadge.js => BuiltInBadge.tsx} (79%) rename server/sonar-web/src/main/js/apps/quality-profiles/components/{CopyProfileForm.js => CopyProfileForm.tsx} (82%) rename server/sonar-web/src/main/js/apps/quality-profiles/components/{DeleteProfileForm.js => DeleteProfileForm.tsx} (86%) rename server/sonar-web/src/main/js/apps/quality-profiles/components/{ProfileActions.js => ProfileActions.tsx} (84%) rename server/sonar-web/src/main/js/apps/quality-profiles/components/{ProfileContainer.js => ProfileContainer.tsx} (86%) rename server/sonar-web/src/main/js/apps/quality-profiles/components/{ProfileDate.js => ProfileDate.tsx} (68%) rename server/sonar-web/src/main/js/apps/quality-profiles/components/{ProfileLink.js => ProfileLink.tsx} (63%) rename server/sonar-web/src/main/js/apps/quality-profiles/components/{ProfileNotFound.js => ProfileNotFound.tsx} (63%) rename server/sonar-web/src/main/js/apps/quality-profiles/components/{RenameProfileForm.js => RenameProfileForm.tsx} (83%) rename server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/{ProfileContainer-test.js => ProfileContainer-test.tsx} (82%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/{ChangeParentForm.js => ChangeParentForm.tsx} (80%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/{ChangeProjectsForm.js => ChangeProjectsForm.tsx} (78%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/{ProfileDetails.js => ProfileDetails.tsx} (56%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/{ProfileExporters.js => ProfileExporters.tsx} (84%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/{ProfileHeader.js => ProfileHeader.tsx} (92%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/{ProfileInheritance.js => ProfileInheritance.tsx} (75%) delete mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.js create mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx rename server/sonar-web/src/main/js/apps/quality-profiles/details/{ProfileProjects.js => ProfileProjects.tsx} (86%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/{ProfileRules.js => ProfileRules.tsx} (85%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/{ProfileRulesDeprecatedWarning.js => ProfileRulesDeprecatedWarning.tsx} (88%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/{ProfileRulesRowOfType.js => ProfileRulesRowOfType.tsx} (85%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/{ProfileRulesRowTotal.js => ProfileRulesRowTotal.tsx} (85%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/{ProfileRulesSonarWayComparison.js => ProfileRulesSonarWayComparison.tsx} (87%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/{ProfileRules-test.js => ProfileRules-test.tsx} (89%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/{ProfileRulesDeprecatedWarning-test.js => ProfileRulesDeprecatedWarning-test.tsx} (96%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/{ProfileRulesRowOfType-test.js => ProfileRulesRowOfType-test.tsx} (98%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/{ProfileRulesRowTotal-test.js => ProfileRulesRowTotal-test.tsx} (97%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/{ProfileRulesSonarWayComparison-test.js => ProfileRulesSonarWayComparison-test.tsx} (97%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/{ProfileRules-test.js.snap => ProfileRules-test.tsx.snap} (100%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/{ProfileRulesDeprecatedWarning-test.js.snap => ProfileRulesDeprecatedWarning-test.tsx.snap} (100%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/{ProfileRulesRowOfType-test.js.snap => ProfileRulesRowOfType-test.tsx.snap} (100%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/{ProfileRulesRowTotal-test.js.snap => ProfileRulesRowTotal-test.tsx.snap} (100%) rename server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/__snapshots__/{ProfileRulesSonarWayComparison-test.js.snap => ProfileRulesSonarWayComparison-test.tsx.snap} (100%) rename server/sonar-web/src/main/js/apps/quality-profiles/home/{CreateProfileForm.js => CreateProfileForm.tsx} (79%) rename server/sonar-web/src/main/js/apps/quality-profiles/home/{Evolution.js => Evolution.tsx} (62%) delete mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.js create mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionDeprecated.tsx rename server/sonar-web/src/main/js/apps/quality-profiles/home/{EvolutionRules.js => EvolutionRules.tsx} (83%) delete mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.js create mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/home/EvolutionStagnant.tsx rename server/sonar-web/src/main/js/apps/quality-profiles/home/{HomeContainer.js => HomeContainer.tsx} (56%) rename server/sonar-web/src/main/js/apps/quality-profiles/home/{PageHeader.js => PageHeader.tsx} (83%) rename server/sonar-web/src/main/js/apps/quality-profiles/home/{ProfilesList.js => ProfilesList.tsx} (75%) rename server/sonar-web/src/main/js/apps/quality-profiles/home/{ProfilesListHeader.js => ProfilesListHeader.tsx} (93%) rename server/sonar-web/src/main/js/apps/quality-profiles/home/{ProfilesListRow.js => ProfilesListRow.tsx} (88%) rename server/sonar-web/src/main/js/apps/quality-profiles/home/{RestoreProfileForm.js => RestoreProfileForm.tsx} (84%) delete mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/propTypes.js rename server/sonar-web/src/main/js/apps/quality-profiles/{routes.js => routes.ts} (75%) create mode 100644 server/sonar-web/src/main/js/apps/quality-profiles/types.ts rename server/sonar-web/src/main/js/apps/quality-profiles/{utils.js => utils.ts} (71%) delete mode 100644 server/sonar-web/src/main/js/apps/sessions/components/Unauthorized.js create mode 100644 server/sonar-web/src/main/js/apps/sessions/components/Unauthorized.tsx rename server/sonar-web/src/main/js/apps/sessions/{routes.js => routes.ts} (78%) rename server/sonar-web/src/main/js/apps/settings/{routes.js => routes.ts} (75%) delete mode 100644 server/sonar-web/src/main/js/apps/system/routes.js create mode 100644 server/sonar-web/src/main/js/apps/system/routes.ts rename server/sonar-web/src/main/js/apps/update-center/{routes.js => routes.ts} (74%) rename server/sonar-web/src/main/js/apps/users/{routes.js => routes.ts} (86%) rename server/sonar-web/src/main/js/apps/web-api/{routes.js => routes.ts} (76%) rename server/sonar-web/src/main/js/components/controls/{DateInput.js => DateInput.tsx} (75%) delete mode 100644 server/sonar-web/src/main/js/components/controls/ListFooter.js create mode 100644 server/sonar-web/src/main/js/components/controls/ListFooter.tsx rename server/sonar-web/src/main/js/components/controls/{Tooltip.js => Tooltip.tsx} (71%) rename server/sonar-web/src/main/js/components/icons-components/{BugIcon.js => BugIcon.tsx} (89%) rename server/sonar-web/src/main/js/components/icons-components/{CodeSmellIcon.js => CodeSmellIcon.tsx} (90%) rename server/sonar-web/src/main/js/components/icons-components/{VulnerabilityIcon.js => VulnerabilityIcon.tsx} (92%) delete mode 100644 server/sonar-web/src/main/js/components/shared/QualifierIcon.js create mode 100644 server/sonar-web/src/main/js/components/shared/QualifierIcon.tsx rename server/sonar-web/src/main/js/components/ui/{IssueTypeIcon.js => IssueTypeIcon.tsx} (55%) delete mode 100644 server/sonar-web/src/main/js/components/ui/Level.js create mode 100644 server/sonar-web/src/main/js/components/ui/Level.tsx create mode 100644 server/sonar-web/src/main/js/typings/rc-tooltip.d.ts diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index ae03fe49562..e9019ccbe63 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -44,13 +44,18 @@ "devDependencies": { "@types/classnames": "2.2.0", "@types/enzyme": "2.8.6", + "@types/escape-html": "0.0.19", "@types/jest": "20.0.7", + "@types/jquery": "3.2.11", "@types/lodash": "4.14.73", "@types/prop-types": "15.5.1", "@types/react": "16.0.2", "@types/react-dom": "15.5.2", + "@types/react-helmet": "5.0.3", + "@types/react-modal": "2.2.0", "@types/react-redux": "5.0.3", "@types/react-router": "3.0.5", + "@types/react-select": "1.0.51", "autoprefixer": "7.1.1", "awesome-typescript-loader": "3.2.3", "babel-core": "^6.22.1", @@ -122,8 +127,16 @@ ], "jest": { "coverageDirectory": "/target/coverage", - "coveragePathIgnorePatterns": ["/node_modules", "/tests"], - "moduleFileExtensions": ["ts", "tsx", "js", "json"], + "coveragePathIgnorePatterns": [ + "/node_modules", + "/tests" + ], + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "json" + ], "moduleNameMapper": { "^.+\\.(hbs|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/config/jest/FileStub.js", "^.+\\.css$": "/config/jest/CSSStub.js" @@ -132,7 +145,9 @@ "/config/polyfills.js", "/config/jest/SetupTestEnvironment.js" ], - "snapshotSerializers": ["enzyme-to-json/serializer"], + "snapshotSerializers": [ + "enzyme-to-json/serializer" + ], "testPathIgnorePatterns": [ "/node_modules", "/src/main/webapp", diff --git a/server/sonar-web/src/main/js/apps/about/routes.js b/server/sonar-web/src/main/js/apps/about/routes.ts similarity index 86% rename from server/sonar-web/src/main/js/apps/about/routes.js rename to server/sonar-web/src/main/js/apps/about/routes.ts index 0748dad497d..6da3a2d64ba 100644 --- a/server/sonar-web/src/main/js/apps/about/routes.js +++ b/server/sonar-web/src/main/js/apps/about/routes.ts @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps } from 'react-router'; + const routes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { import('./components/AboutApp').then(i => callback(null, { component: i.default })); } } diff --git a/server/sonar-web/src/main/js/apps/account/projects/ProjectCard.js b/server/sonar-web/src/main/js/apps/account/projects/ProjectCard.js deleted file mode 100644 index 13826f80dc8..00000000000 --- a/server/sonar-web/src/main/js/apps/account/projects/ProjectCard.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 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 React from 'react'; -import moment from 'moment'; -import { sortBy } from 'lodash'; -import { Link } from 'react-router'; -import Level from '../../../components/ui/Level'; -import { projectType } from './propTypes'; -import { translateWithParameters, translate } from '../../../helpers/l10n'; - -export default class ProjectCard extends React.PureComponent { - static propTypes = { - project: projectType.isRequired - }; - - render() { - const { project } = this.props; - const isAnalyzed = project.lastAnalysisDate != null; - const analysisMoment = isAnalyzed && moment(project.lastAnalysisDate); - const links = sortBy(project.links, 'type'); - - return ( -
- - -

- - {project.name} - -

- - {links.length > 0 && -
-
    - {links.map(link => -
  • - - - -
  • - )} -
-
} - -
- {project.key} -
- - {!!project.description && -
- {project.description} -
} -
- ); - } -} 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 new file mode 100644 index 00000000000..93a3a787715 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/account/projects/ProjectCard.tsx @@ -0,0 +1,94 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import * as moment from 'moment'; +import { sortBy } from 'lodash'; +import { Link } from 'react-router'; +import { IProject } from './types'; +import Level from '../../../components/ui/Level'; +import { translateWithParameters, translate } from '../../../helpers/l10n'; + +interface Props { + project: IProject; +} + +export default function ProjectCard(props: Props) { + const { project } = props; + const isAnalyzed = project.lastAnalysisDate != null; + const analysisMoment = isAnalyzed && moment(project.lastAnalysisDate); + const links = sortBy(project.links, 'type'); + + return ( +
+ + +

+ + {project.name} + +

+ + {links.length > 0 && +
+
    + {links.map(link => +
  • + + + +
  • + )} +
+
} + +
+ {project.key} +
+ + {!!project.description && +
+ {project.description} +
} +
+ ); +} diff --git a/server/sonar-web/src/main/js/apps/account/projects/Projects.js b/server/sonar-web/src/main/js/apps/account/projects/Projects.js deleted file mode 100644 index 89c151f73d5..00000000000 --- a/server/sonar-web/src/main/js/apps/account/projects/Projects.js +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 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 React from 'react'; -import PropTypes from 'prop-types'; -import ProjectCard from './ProjectCard'; -import ListFooter from '../../../components/controls/ListFooter'; -import { projectsListType } from './propTypes'; -import { translate } from '../../../helpers/l10n'; - -export default class Projects extends React.PureComponent { - static propTypes = { - projects: projectsListType.isRequired, - total: PropTypes.number.isRequired, - loading: PropTypes.bool.isRequired, - loadMore: PropTypes.func.isRequired - }; - - render() { - const { projects } = this.props; - - return ( -
- {projects.length === 0 - ?
- {translate('my_account.projects.no_results')} -
- :

- {translate('my_account.projects.description')} -

} - - {projects.length > 0 && -
    - {projects.map(project => -
  • - -
  • - )} -
} - - {projects.length > 0 && - } -
- ); - } -} 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 new file mode 100644 index 00000000000..e3681c3465d --- /dev/null +++ b/server/sonar-web/src/main/js/apps/account/projects/Projects.tsx @@ -0,0 +1,65 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import ProjectCard from './ProjectCard'; +import { IProject } from './types'; +import ListFooter from '../../../components/controls/ListFooter'; +import { translate } from '../../../helpers/l10n'; + +interface Props { + loading: boolean; + loadMore: () => void; + projects: IProject[]; + search: (query: string) => void; + total?: number; +} + +export default function Projects(props: Props) { + const { projects } = props; + + return ( +
+ {projects.length === 0 + ?
+ {translate('my_account.projects.no_results')} +
+ :

+ {translate('my_account.projects.description')} +

} + + {projects.length > 0 && +
    + {projects.map(project => +
  • + +
  • + )} +
} + + {projects.length > 0 && + } +
+ ); +} diff --git a/server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.js b/server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.tsx similarity index 81% rename from server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.js rename to server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.tsx index 69aea617c93..b822768884d 100644 --- a/server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.js +++ b/server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.tsx @@ -17,24 +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 React from 'react'; +import * as React from 'react'; import Helmet from 'react-helmet'; import Projects from './Projects'; import { getMyProjects } from '../../../api/components'; import { translate } from '../../../helpers/l10n'; -export default class ProjectsContainer extends React.PureComponent { - state = { +interface State { + loading: boolean; + page: number; + projects?: any[]; + query: string; + total?: number; +} + +export default class ProjectsContainer extends React.PureComponent<{}, State> { + mounted: boolean; + state: State = { loading: true, page: 1, query: '' }; - componentWillMount() { - this.loadMore = this.loadMore.bind(this); - this.search = this.search.bind(this); - } - componentDidMount() { this.mounted = true; this.loadProjects(); @@ -46,15 +50,15 @@ export default class ProjectsContainer extends React.PureComponent { loadProjects(page = this.state.page, query = this.state.query) { this.setState({ loading: true }); - const data = { ps: 100 }; + const data: { [p: string]: any } = { ps: 100 }; if (page > 1) { data.p = page; } if (query) { data.q = query; } - return getMyProjects(data).then(r => { - const projects = page > 1 ? [...this.state.projects, ...r.projects] : r.projects; + return getMyProjects(data).then((r: any) => { + const projects = page > 1 ? [...(this.state.projects || []), ...r.projects] : r.projects; this.setState({ projects, query, @@ -65,13 +69,9 @@ export default class ProjectsContainer extends React.PureComponent { }); } - loadMore() { - return this.loadProjects(this.state.page + 1); - } + loadMore = () => this.loadProjects(this.state.page + 1); - search(query) { - return this.loadProjects(1, query); - } + search = (query: string) => this.loadProjects(1, query); render() { const helmet = ; diff --git a/server/sonar-web/src/main/js/apps/account/projects/propTypes.js b/server/sonar-web/src/main/js/apps/account/projects/propTypes.js deleted file mode 100644 index cae87b48906..00000000000 --- a/server/sonar-web/src/main/js/apps/account/projects/propTypes.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 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 PropTypes from 'prop-types'; - -const { shape, string, array, arrayOf } = PropTypes; - -export const projectType = shape({ - id: string.isRequired, - key: string.isRequired, - name: string.isRequired, - lastAnalysisDate: string, - description: string, - links: array.isRequired, - qualityGate: string -}); - -export const projectsListType = arrayOf(projectType); diff --git a/server/sonar-web/src/main/js/apps/account/projects/types.ts b/server/sonar-web/src/main/js/apps/account/projects/types.ts new file mode 100644 index 00000000000..76feb045c64 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/account/projects/types.ts @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +export interface IProject { + id: string; + key: string; + name: string; + lastAnalysisDate: string; + description: string; + links: Array<{ + href: string; + name: string; + type: string; + }>; + qualityGate: string; +} diff --git a/server/sonar-web/src/main/js/apps/account/routes.js b/server/sonar-web/src/main/js/apps/account/routes.ts similarity index 71% rename from server/sonar-web/src/main/js/apps/account/routes.js rename to server/sonar-web/src/main/js/apps/account/routes.ts index 2b92bf00f6b..90e66149504 100644 --- a/server/sonar-web/src/main/js/apps/account/routes.js +++ b/server/sonar-web/src/main/js/apps/account/routes.ts @@ -17,44 +17,46 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps, RouteComponent } from 'react-router'; + const routes = [ { - getComponent(_, callback) { + getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) { import('./components/Account').then(i => callback(null, i.default)); }, childRoutes: [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { import('./profile/Profile').then(i => callback(null, { component: i.default })); } }, { path: 'security', - getComponent(_, callback) { + getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) { import('./components/Security').then(i => callback(null, i.default)); } }, { path: 'projects', - getComponent(_, callback) { + getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) { import('./projects/ProjectsContainer').then(i => callback(null, i.default)); } }, { path: 'notifications', - getComponent(_, callback) { + getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) { import('./notifications/Notifications').then(i => callback(null, i.default)); } }, { path: 'organizations', - getComponent(_, callback) { + getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) { import('./organizations/UserOrganizations').then(i => callback(null, i.default)); }, childRoutes: [ { path: 'create', - getComponent(_, callback) { + getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) { import('./organizations/CreateOrganizationForm').then(i => callback(null, i.default)); } } diff --git a/server/sonar-web/src/main/js/apps/background-tasks/routes.js b/server/sonar-web/src/main/js/apps/background-tasks/routes.ts similarity index 86% rename from server/sonar-web/src/main/js/apps/background-tasks/routes.js rename to server/sonar-web/src/main/js/apps/background-tasks/routes.ts index 3f46e626d9e..88e0a5e53bc 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/routes.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/routes.ts @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps } from 'react-router'; + const routes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { import('./components/BackgroundTasksApp').then(i => callback(null, { component: i.default })); } } diff --git a/server/sonar-web/src/main/js/apps/code/routes.js b/server/sonar-web/src/main/js/apps/code/routes.ts similarity index 86% rename from server/sonar-web/src/main/js/apps/code/routes.js rename to server/sonar-web/src/main/js/apps/code/routes.ts index 4de41657b76..fcffeff191c 100644 --- a/server/sonar-web/src/main/js/apps/code/routes.js +++ b/server/sonar-web/src/main/js/apps/code/routes.ts @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps } from 'react-router'; + const routes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { import('./components/App').then(i => callback(null, { component: i.default })); } } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/routes.js b/server/sonar-web/src/main/js/apps/coding-rules/routes.ts similarity index 86% rename from server/sonar-web/src/main/js/apps/coding-rules/routes.js rename to server/sonar-web/src/main/js/apps/coding-rules/routes.ts index af91a4eab6d..798ee29934a 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/routes.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/routes.ts @@ -17,10 +17,12 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, RouteComponent } from 'react-router'; + const routes = [ { indexRoute: { - getComponent(_, callback) { + getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) { import('./components/CodingRulesAppContainer').then(i => callback(null, i.default)); } } diff --git a/server/sonar-web/src/main/js/apps/component-measures/routes.js b/server/sonar-web/src/main/js/apps/component-measures/routes.ts similarity index 85% rename from server/sonar-web/src/main/js/apps/component-measures/routes.js rename to server/sonar-web/src/main/js/apps/component-measures/routes.ts index c0abc9f57d8..9f3813c87e2 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/routes.js +++ b/server/sonar-web/src/main/js/apps/component-measures/routes.ts @@ -17,15 +17,17 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps, RedirectFunction } from 'react-router'; + const routes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { import('./components/AppContainer').then(i => callback(null, { component: i.default })); } }, { path: 'domain/:domainName', - onEnter(nextState, replace) { + onEnter(nextState: RouterState, replace: RedirectFunction) { replace({ pathname: '/component_measures', query: { @@ -37,7 +39,7 @@ const routes = [ }, { path: 'metric/:metricKey(/:view)', - onEnter(nextState, replace) { + onEnter(nextState: RouterState, replace: RedirectFunction) { if (nextState.params.view === 'history') { replace({ pathname: '/project/activity', diff --git a/server/sonar-web/src/main/js/apps/component/components/App.js b/server/sonar-web/src/main/js/apps/component/components/App.tsx similarity index 89% rename from server/sonar-web/src/main/js/apps/component/components/App.js rename to server/sonar-web/src/main/js/apps/component/components/App.tsx index e8c1c9f2128..a1fb59f825c 100644 --- a/server/sonar-web/src/main/js/apps/component/components/App.js +++ b/server/sonar-web/src/main/js/apps/component/components/App.tsx @@ -17,20 +17,19 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import SourceViewer from '../../../components/SourceViewer/SourceViewer'; -export default class App extends React.PureComponent { - /*:: props: { - location: { - query: { - id: string, - line?: string - } - } +interface Props { + location: { + query: { + id: string; + line?: string; + }; }; -*/ +} + +export default class App extends React.PureComponent { scrollToLine = () => { const { line } = this.props.location.query; if (line) { diff --git a/server/sonar-web/src/main/js/apps/component/routes.js b/server/sonar-web/src/main/js/apps/component/routes.ts similarity index 86% rename from server/sonar-web/src/main/js/apps/component/routes.js rename to server/sonar-web/src/main/js/apps/component/routes.ts index 9943b1d8380..c5105eeca4e 100644 --- a/server/sonar-web/src/main/js/apps/component/routes.js +++ b/server/sonar-web/src/main/js/apps/component/routes.ts @@ -17,10 +17,12 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, RouteComponent } from 'react-router'; + const routes = [ { indexRoute: { - getComponent(_, callback) { + getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) { import('./components/App').then(i => callback(null, i.default)); } } diff --git a/server/sonar-web/src/main/js/apps/custom-measures/routes.js b/server/sonar-web/src/main/js/apps/custom-measures/routes.ts similarity index 87% rename from server/sonar-web/src/main/js/apps/custom-measures/routes.js rename to server/sonar-web/src/main/js/apps/custom-measures/routes.ts index e3aee2038cd..ad092ba1d48 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/routes.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/routes.ts @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps } from 'react-router'; + const routes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { import('./components/CustomMeasuresAppContainer').then(i => callback(null, { component: i.default }) ); diff --git a/server/sonar-web/src/main/js/apps/groups/routes.js b/server/sonar-web/src/main/js/apps/groups/routes.ts similarity index 89% rename from server/sonar-web/src/main/js/apps/groups/routes.js rename to server/sonar-web/src/main/js/apps/groups/routes.ts index 8829f80c94b..80ee5984d39 100644 --- a/server/sonar-web/src/main/js/apps/groups/routes.js +++ b/server/sonar-web/src/main/js/apps/groups/routes.ts @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps } from 'react-router'; + const routes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { Promise.all([ import('./components/GroupsAppContainer').then(i => i.default), import('../organizations/forSingleOrganization').then(i => i.default) diff --git a/server/sonar-web/src/main/js/apps/issues/routes.js b/server/sonar-web/src/main/js/apps/issues/routes.ts similarity index 87% rename from server/sonar-web/src/main/js/apps/issues/routes.js rename to server/sonar-web/src/main/js/apps/issues/routes.ts index ffcdcb7a090..e915d90da0a 100644 --- a/server/sonar-web/src/main/js/apps/issues/routes.js +++ b/server/sonar-web/src/main/js/apps/issues/routes.ts @@ -17,11 +17,12 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps } from 'react-router'; import { onEnter } from './redirects'; const routes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { import('./components/AppContainer').then(i => callback(null, { component: i.default, onEnter }) ); diff --git a/server/sonar-web/src/main/js/apps/maintenance/components/MaintenanceAppContainer.js b/server/sonar-web/src/main/js/apps/maintenance/components/MaintenanceAppContainer.tsx similarity index 97% rename from server/sonar-web/src/main/js/apps/maintenance/components/MaintenanceAppContainer.js rename to server/sonar-web/src/main/js/apps/maintenance/components/MaintenanceAppContainer.tsx index bf151b827ac..923d805efd7 100644 --- a/server/sonar-web/src/main/js/apps/maintenance/components/MaintenanceAppContainer.js +++ b/server/sonar-web/src/main/js/apps/maintenance/components/MaintenanceAppContainer.tsx @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import React from 'react'; +import * as React from 'react'; import init from '../init'; export default class MaintenanceAppContainer extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/maintenance/components/SetupAppContainer.js b/server/sonar-web/src/main/js/apps/maintenance/components/SetupAppContainer.tsx similarity index 97% rename from server/sonar-web/src/main/js/apps/maintenance/components/SetupAppContainer.js rename to server/sonar-web/src/main/js/apps/maintenance/components/SetupAppContainer.tsx index c28492700ce..398ebb69fd6 100644 --- a/server/sonar-web/src/main/js/apps/maintenance/components/SetupAppContainer.js +++ b/server/sonar-web/src/main/js/apps/maintenance/components/SetupAppContainer.tsx @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import React from 'react'; +import * as React from 'react'; import init from '../init'; export default class SetupAppContainer extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/maintenance/routes.js b/server/sonar-web/src/main/js/apps/maintenance/routes.tsx similarity index 97% rename from server/sonar-web/src/main/js/apps/maintenance/routes.js rename to server/sonar-web/src/main/js/apps/maintenance/routes.tsx index e6b19e9a5a3..df6cd941cd5 100644 --- a/server/sonar-web/src/main/js/apps/maintenance/routes.js +++ b/server/sonar-web/src/main/js/apps/maintenance/routes.tsx @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import React from 'react'; +import * as React from 'react'; import { IndexRoute } from 'react-router'; import MaintenanceAppContainer from './components/MaintenanceAppContainer'; import SetupAppContainer from './components/SetupAppContainer'; diff --git a/server/sonar-web/src/main/js/apps/metrics/components/MetricsAppContainer.js b/server/sonar-web/src/main/js/apps/metrics/components/MetricsAppContainer.tsx similarity index 97% rename from server/sonar-web/src/main/js/apps/metrics/components/MetricsAppContainer.js rename to server/sonar-web/src/main/js/apps/metrics/components/MetricsAppContainer.tsx index f5f031e9839..0bf49c749d5 100644 --- a/server/sonar-web/src/main/js/apps/metrics/components/MetricsAppContainer.js +++ b/server/sonar-web/src/main/js/apps/metrics/components/MetricsAppContainer.tsx @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import React from 'react'; +import * as React from 'react'; import Helmet from 'react-helmet'; import init from '../init'; import { translate } from '../../../helpers/l10n'; diff --git a/server/sonar-web/src/main/js/apps/metrics/routes.js b/server/sonar-web/src/main/js/apps/metrics/routes.ts similarity index 87% rename from server/sonar-web/src/main/js/apps/metrics/routes.js rename to server/sonar-web/src/main/js/apps/metrics/routes.ts index 637dba72da9..c52951ea17b 100644 --- a/server/sonar-web/src/main/js/apps/metrics/routes.js +++ b/server/sonar-web/src/main/js/apps/metrics/routes.ts @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps } from 'react-router'; + const routes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { import('./components/MetricsAppContainer').then(i => callback(null, { component: i.default }) ); diff --git a/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/ApplicationQualityGate-test.js.snap b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/ApplicationQualityGate-test.js.snap index 247c1251986..326b9ecefb1 100644 --- a/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/ApplicationQualityGate-test.js.snap +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/__snapshots__/ApplicationQualityGate-test.js.snap @@ -27,8 +27,6 @@ exports[`renders 2`] = ` overview.quality_gate
any) { import('./components/AppContainer').then(i => callback(null, { component: i.default })); } } diff --git a/server/sonar-web/src/main/js/apps/permission-templates/routes.js b/server/sonar-web/src/main/js/apps/permission-templates/routes.ts similarity index 88% rename from server/sonar-web/src/main/js/apps/permission-templates/routes.js rename to server/sonar-web/src/main/js/apps/permission-templates/routes.ts index ce1b2679e4a..f00dc431c31 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/routes.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/routes.ts @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps } from 'react-router'; + const routes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { Promise.all([ import('./components/AppContainer').then(i => i.default), import('../organizations/forSingleOrganization').then(i => i.default) diff --git a/server/sonar-web/src/main/js/apps/permissions/routes.js b/server/sonar-web/src/main/js/apps/permissions/routes.ts similarity index 85% rename from server/sonar-web/src/main/js/apps/permissions/routes.js rename to server/sonar-web/src/main/js/apps/permissions/routes.ts index 631a26985b1..85a62be0dd2 100644 --- a/server/sonar-web/src/main/js/apps/permissions/routes.js +++ b/server/sonar-web/src/main/js/apps/permissions/routes.ts @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps } from 'react-router'; + export const globalPermissionsRoutes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { Promise.all([ import('./global/components/App').then(i => i.default), import('../organizations/forSingleOrganization').then(i => i.default) @@ -32,7 +34,7 @@ export const globalPermissionsRoutes = [ export const projectPermissionsRoutes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { import('./project/components/AppContainer').then(i => callback(null, { component: i.default }) ); diff --git a/server/sonar-web/src/main/js/apps/projectActivity/routes.js b/server/sonar-web/src/main/js/apps/projectActivity/routes.ts similarity index 87% rename from server/sonar-web/src/main/js/apps/projectActivity/routes.js rename to server/sonar-web/src/main/js/apps/projectActivity/routes.ts index 11233a7368b..47d7bda3dae 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/routes.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/routes.ts @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps } from 'react-router'; + const routes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { import('./components/ProjectActivityAppContainer').then(i => callback(null, { component: i.default }) ); diff --git a/server/sonar-web/src/main/js/apps/projects-admin/routes.js b/server/sonar-web/src/main/js/apps/projects-admin/routes.ts similarity index 88% rename from server/sonar-web/src/main/js/apps/projects-admin/routes.js rename to server/sonar-web/src/main/js/apps/projects-admin/routes.ts index d17958371b6..447c6ae73dd 100644 --- a/server/sonar-web/src/main/js/apps/projects-admin/routes.js +++ b/server/sonar-web/src/main/js/apps/projects-admin/routes.ts @@ -17,9 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps } from 'react-router'; + const routes = [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { Promise.all([ import('./AppContainer').then(i => i.default), import('../organizations/forSingleOrganization').then(i => i.default) diff --git a/server/sonar-web/src/main/js/apps/projects/components/App.js b/server/sonar-web/src/main/js/apps/projects/components/App.tsx similarity index 97% rename from server/sonar-web/src/main/js/apps/projects/components/App.js rename to server/sonar-web/src/main/js/apps/projects/components/App.tsx index 83b097ed170..471331fb0b9 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/App.js +++ b/server/sonar-web/src/main/js/apps/projects/components/App.tsx @@ -17,8 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -//@flow -import React from 'react'; +import * as React from 'react'; export default class App extends React.PureComponent { componentDidMount() { diff --git a/server/sonar-web/src/main/js/apps/projects/routes.js b/server/sonar-web/src/main/js/apps/projects/routes.ts similarity index 76% rename from server/sonar-web/src/main/js/apps/projects/routes.js rename to server/sonar-web/src/main/js/apps/projects/routes.ts index 1c3c76cc3d4..c6f3df309f5 100644 --- a/server/sonar-web/src/main/js/apps/projects/routes.js +++ b/server/sonar-web/src/main/js/apps/projects/routes.ts @@ -17,16 +17,17 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps, RouteComponent, RedirectFunction } from 'react-router'; import { saveAll } from '../../helpers/storage'; const routes = [ { - getComponent(_, callback) { + getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) { import('./components/App').then(i => callback(null, i.default)); }, childRoutes: [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { import('./components/DefaultPageSelector').then(i => callback(null, { component: i.default }) ); @@ -34,14 +35,14 @@ const routes = [ }, { path: 'all', - onEnter(_, replace) { + onEnter(_: RouterState, replace: RedirectFunction) { saveAll(); replace('/projects'); } }, { path: 'favorite', - getComponent(_, callback) { + getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) { import('./components/FavoriteProjectsContainer').then(i => callback(null, i.default)); } } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/routes.js b/server/sonar-web/src/main/js/apps/quality-gates/routes.ts similarity index 78% rename from server/sonar-web/src/main/js/apps/quality-gates/routes.js rename to server/sonar-web/src/main/js/apps/quality-gates/routes.ts index 8664f1f39bb..f1d203bc354 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/routes.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/routes.ts @@ -17,20 +17,22 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { RouterState, IndexRouteProps, RouteComponent } from 'react-router'; + const routes = [ { - getComponent(_, callback) { + getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) { import('./containers/QualityGatesAppContainer').then(i => callback(null, i.default)); }, childRoutes: [ { - getIndexRoute(_, callback) { + getIndexRoute(_: RouterState, callback: (err: any, route: IndexRouteProps) => any) { import('./components/Intro').then(i => callback(null, { component: i.default })); } }, { path: 'show/:id', - getComponent(_, callback) { + getComponent(_: RouterState, callback: (err: any, component: RouteComponent) => any) { import('./containers/DetailsContainer').then(i => callback(null, i.default)); } } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/__tests__/__snapshots__/utils-test.js.snap b/server/sonar-web/src/main/js/apps/quality-profiles/__tests__/__snapshots__/utils-test.ts.snap similarity index 92% rename from server/sonar-web/src/main/js/apps/quality-profiles/__tests__/__snapshots__/utils-test.js.snap rename to server/sonar-web/src/main/js/apps/quality-profiles/__tests__/__snapshots__/utils-test.ts.snap index 63a0a9ee7e0..a833c80f2e3 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/__tests__/__snapshots__/utils-test.js.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/__tests__/__snapshots__/utils-test.ts.snap @@ -105,6 +105,18 @@ Array [ `; exports[`#sortProfiles sorts partial set of inherited profiles 1`] = ` +Array [ + Object { + "childrenCount": 0, + "depth": 1, + "key": "foo", + "name": "foo", + "parentKey": "bar", + }, +] +`; + +exports[`#sortProfiles sorts partial set of inherited profiles 2`] = ` Array [ Object { "childrenCount": 0, diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/__tests__/utils-test.js b/server/sonar-web/src/main/js/apps/quality-profiles/__tests__/utils-test.ts similarity index 92% rename from server/sonar-web/src/main/js/apps/quality-profiles/__tests__/utils-test.js rename to server/sonar-web/src/main/js/apps/quality-profiles/__tests__/utils-test.ts index 57157f7de3a..433702eab06 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/__tests__/utils-test.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/__tests__/utils-test.ts @@ -18,9 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { sortProfiles } from '../utils'; +import { IProfile } from '../types'; -function createProfile(key, parentKey) { - return { name: key, key, parentKey }; +function createProfile(key: string, parentKey?: string) { + return { name: key, key, parentKey } as IProfile; } describe('#sortProfiles', () => { @@ -54,7 +55,7 @@ describe('#sortProfiles', () => { it('sorts partial set of inherited profiles', () => { const foo = createProfile('foo', 'bar'); - expect(sortProfiles([foo]), ['foo']); + expect(sortProfiles([foo])).toMatchSnapshot(); const profile1 = createProfile('profile1', 'x'); const profile2 = createProfile('profile2'); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.js deleted file mode 100644 index 7eeb76ee8f8..00000000000 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.js +++ /dev/null @@ -1,122 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 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. - */ -// @flow -import React from 'react'; -import { Link } from 'react-router'; -import moment from 'moment'; -import ChangesList from './ChangesList'; -import { translate } from '../../../helpers/l10n'; -import { getRulesUrl } from '../../../helpers/urls'; - -/*:: -type Props = { - events: Array<{ - action: string, - authorName: string, - date: string, - params?: {}, - ruleKey: string, - ruleName: string - }>, - organization: ?string -}; -*/ - -export default class Changelog extends React.PureComponent { - /*:: props: Props; */ - - render() { - let isEvenRow = false; - - const rows = this.props.events.map((event, index) => { - const prev = index > 0 ? this.props.events[index - 1] : null; - const isSameDate = prev != null && moment(prev.date).diff(event.date, 'seconds') < 10; - const isBulkChange = - prev != null && - isSameDate && - prev.authorName === event.authorName && - prev.action === event.action; - - if (!isBulkChange) { - isEvenRow = !isEvenRow; - } - - const className = 'js-profile-changelog-event ' + (isEvenRow ? 'even' : 'odd'); - - return ( - - - {!isBulkChange && moment(event.date).format('LLL')} - - - - {!isBulkChange && - (event.authorName - ? - {event.authorName} - - : System)} - - - - {!isBulkChange && translate('quality_profiles.changelog', event.action)} - - - - - {event.ruleName} - - - - - - - - ); - }); - - return ( - - - - - - - - - - - - {rows} - -
- {translate('date')} - - {translate('user')} - - {translate('action')} - - {translate('rule')} - - {translate('parameters')} -
- ); - } -} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx new file mode 100644 index 00000000000..6c152925cca --- /dev/null +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx @@ -0,0 +1,109 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { Link } from 'react-router'; +import * as moment from 'moment'; +import ChangesList from './ChangesList'; +import { translate } from '../../../helpers/l10n'; +import { getRulesUrl } from '../../../helpers/urls'; +import { IProfileChangelogEvent } from '../types'; + +interface Props { + events: IProfileChangelogEvent[]; + organization: string | null; +} + +export default function Changelog(props: Props) { + let isEvenRow = false; + + const rows = props.events.map((event, index) => { + const prev = index > 0 ? props.events[index - 1] : null; + const isSameDate = prev != null && moment(prev.date).diff(event.date, 'seconds') < 10; + const isBulkChange = + prev != null && + isSameDate && + prev.authorName === event.authorName && + prev.action === event.action; + + if (!isBulkChange) { + isEvenRow = !isEvenRow; + } + + const className = 'js-profile-changelog-event ' + (isEvenRow ? 'even' : 'odd'); + + return ( + + + {!isBulkChange && moment(event.date).format('LLL')} + + + + {!isBulkChange && + (event.authorName + ? + {event.authorName} + + : System)} + + + + {!isBulkChange && translate('quality_profiles.changelog', event.action)} + + + + + {event.ruleName} + + + + + {event.params && } + + + ); + }); + + return ( + + + + + + + + + + + + {rows} + +
+ {translate('date')} + + {translate('user')} + + {translate('action')} + + {translate('rule')} + + {translate('parameters')} +
+ ); +} diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.tsx similarity index 73% rename from server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.js rename to server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.tsx index 6bca8f58b0f..aa54dd0c89c 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogContainer.tsx @@ -17,48 +17,42 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; -import PropTypes from 'prop-types'; +import * as React from 'react'; +import * as PropTypes from 'prop-types'; import Changelog from './Changelog'; import ChangelogSearch from './ChangelogSearch'; import ChangelogEmpty from './ChangelogEmpty'; import { getProfileChangelog } from '../../../api/quality-profiles'; import { translate } from '../../../helpers/l10n'; import { getProfileChangelogPath } from '../utils'; -/*:: import type { Profile } from '../propTypes'; */ +import { IProfile, IProfileChangelogEvent } from '../types'; -/*:: -type Props = { +interface Props { location: { query: { - since?: string, - to?: string - } - }, - organization: ?string, - profile: Profile -}; -*/ - -/*:: -type State = { - events?: Array<*>, - loading: boolean, - page?: number, - total?: number -}; -*/ - -export default class ChangelogContainer extends React.PureComponent { - /*:: mounted: boolean; */ - /*:: props: Props; */ + since?: string; + to?: string; + }; + }; + organization: string | null; + profile: IProfile; +} + +interface State { + events?: IProfileChangelogEvent[]; + loading: boolean; + page?: number; + total?: number; +} + +export default class ChangelogContainer extends React.PureComponent { + mounted: boolean; static contextTypes = { router: PropTypes.object }; - state /*: State */ = { + state: State = { loading: true }; @@ -67,7 +61,7 @@ export default class ChangelogContainer extends React.PureComponent { this.loadChangelog(); } - componentDidUpdate(prevProps /*: Props */) { + componentDidUpdate(prevProps: Props) { if (prevProps.location !== this.props.location) { this.loadChangelog(); } @@ -80,7 +74,7 @@ export default class ChangelogContainer extends React.PureComponent { loadChangelog() { this.setState({ loading: true }); const { query } = this.props.location; - const data /*: Object */ = { profileKey: this.props.profile.key }; + const data: any = { profileKey: this.props.profile.key }; if (query.since) { data.since = query.since; } @@ -88,7 +82,7 @@ export default class ChangelogContainer extends React.PureComponent { data.to = query.to; } - getProfileChangelog(data).then(r => { + getProfileChangelog(data).then((r: any) => { if (this.mounted) { this.setState({ events: r.events, @@ -100,36 +94,38 @@ export default class ChangelogContainer extends React.PureComponent { }); } - loadMore(e /*: SyntheticInputEvent */) { - e.preventDefault(); - e.target.blur(); + loadMore(event: React.SyntheticEvent) { + event.preventDefault(); + event.currentTarget.blur(); + + if (this.state.page != null) { + this.setState({ loading: true }); + const { query } = this.props.location; + const data: any = { + profileKey: this.props.profile.key, + p: this.state.page + 1 + }; + if (query.since) { + data.since = query.since; + } + if (query.to) { + data.to = query.to; + } - this.setState({ loading: true }); - const { query } = this.props.location; - const data /*: Object */ = { - profileKey: this.props.profile.key, - p: this.state.page + 1 - }; - if (query.since) { - data.since = query.since; - } - if (query.to) { - data.to = query.to; + getProfileChangelog(data).then((r: any) => { + if (this.mounted && this.state.events) { + this.setState({ + events: [...this.state.events, ...r.events], + total: r.total, + page: r.p, + loading: false + }); + } + }); } - - getProfileChangelog(data).then(r => { - if (this.mounted && this.state.events) { - this.setState({ - events: [...this.state.events, ...r.events], - total: r.total, - page: r.p, - loading: false - }); - } - }); } - handleFromDateChange = (fromDate /*: string | void */) => { + handleFromDateChange = (fromDate?: string) => { const path = getProfileChangelogPath( this.props.profile.name, this.props.profile.language, @@ -142,7 +138,7 @@ export default class ChangelogContainer extends React.PureComponent { this.context.router.push(path); }; - handleToDateChange = (toDate /*: string | void */) => { + handleToDateChange = (toDate?: string) => { const path = getProfileChangelogPath( this.props.profile.name, this.props.profile.language, diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogEmpty.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogEmpty.tsx similarity index 79% rename from server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogEmpty.js rename to server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogEmpty.tsx index 96db0d8c8eb..b8a9fbaa35e 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogEmpty.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogEmpty.tsx @@ -17,16 +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. */ -// @flow -import React from 'react'; +import * as React from 'react'; import { translate } from '../../../helpers/l10n'; -export default class ChangelogEmpty extends React.PureComponent { - render() { - return ( -
- {translate('no_results')} -
- ); - } +export default function ChangelogEmpty() { + return ( +
+ {translate('no_results')} +
+ ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogSearch.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogSearch.tsx similarity index 84% rename from server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogSearch.js rename to server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogSearch.tsx index c0abdb0155a..e59479fccf3 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogSearch.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangelogSearch.tsx @@ -17,27 +17,22 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import DateInput from '../../../components/controls/DateInput'; import { translate } from '../../../helpers/l10n'; -/*:: -type Props = { - fromDate?: string, - toDate?: string, - onFromDateChange: () => void, - onReset: () => void, - onToDateChange: () => void -}; -*/ - -export default class ChangelogSearch extends React.PureComponent { - /*:: props: Props; */ +interface Props { + fromDate?: string; + toDate?: string; + onFromDateChange: () => void; + onReset: () => void; + onToDateChange: () => void; +} - handleResetClick(e /*: SyntheticInputEvent */) { - e.preventDefault(); - e.target.blur(); +export default class ChangelogSearch extends React.PureComponent { + handleResetClick(event: React.SyntheticEvent) { + event.preventDefault(); + event.currentTarget.blur(); this.props.onReset(); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.tsx similarity index 63% rename from server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.js rename to server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.tsx index c910ebb54ab..c800e44e918 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ChangesList.tsx @@ -17,33 +17,24 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import SeverityChange from './SeverityChange'; import ParameterChange from './ParameterChange'; -/*:: -type Props = { - changes: { [string]: ?string } -}; -*/ - -export default class ChangesList extends React.PureComponent { - /*:: props: Props; */ - - render() { - const { changes } = this.props; +interface Props { + changes: { [change: string]: string | null }; +} - return ( -
    - {Object.keys(changes).map(key => -
  • - {key === 'severity' - ? - : } -
  • - )} -
- ); - } +export default function ChangesList({ changes }: Props) { + return ( +
    + {Object.keys(changes).map(key => +
  • + {key === 'severity' + ? + : } +
  • + )} +
+ ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.tsx similarity index 63% rename from server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.js rename to server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.tsx index 9ee9d2bd80f..d62d11d7c25 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/ParameterChange.tsx @@ -17,38 +17,29 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import { translateWithParameters } from '../../../helpers/l10n'; -/*:: -type Props = { - name: string, - value: ?string -}; -*/ - -export default class ParameterChange extends React.PureComponent { - /*:: props: Props; */ - - render() { - const { name, value } = this.props; - - if (value == null) { - return ( -
- {translateWithParameters( - 'quality_profiles.changelog.parameter_reset_to_default_value', - name - )} -
- ); - } +interface Props { + name: string; + value: string | null; +} +export default function ParameterChange({ name, value }: Props) { + if (value == null) { return (
- {translateWithParameters('quality_profiles.parameter_set_to', name, value)} + {translateWithParameters( + 'quality_profiles.changelog.parameter_reset_to_default_value', + name + )}
); } + + return ( +
+ {translateWithParameters('quality_profiles.parameter_set_to', name, value)} +
+ ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/SeverityChange.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/SeverityChange.tsx similarity index 73% rename from server/sonar-web/src/main/js/apps/quality-profiles/changelog/SeverityChange.js rename to server/sonar-web/src/main/js/apps/quality-profiles/changelog/SeverityChange.tsx index 546c46610c2..3c744e731a9 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/SeverityChange.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/SeverityChange.tsx @@ -17,26 +17,18 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import SeverityHelper from '../../../components/shared/SeverityHelper'; import { translate } from '../../../helpers/l10n'; -/*:: -type Props = { - severity: ?string -}; -*/ - -export default class SeverityChange extends React.PureComponent { - /*:: props: Props; */ +interface Props { + severity: string | null; +} - render() { - return ( -
- {translate('quality_profiles.severity_set_to')}{' '} - -
- ); - } +export default function SeverityChange({ severity }: Props) { + return ( +
+ {translate('quality_profiles.severity_set_to')} +
+ ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx similarity index 74% rename from server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.js rename to server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx index 32774553ba1..ed8fb6b6106 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/Changelog-test.tsx @@ -18,11 +18,12 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import React from 'react'; +import * as React from 'react'; import Changelog from '../Changelog'; import ChangesList from '../ChangesList'; +import { IProfileChangelogEvent } from '../../types'; -function createEvent(overrides) { +function createEvent(overrides?: { [p: string]: any }): IProfileChangelogEvent { return { date: '2016-01-01', authorName: 'John', @@ -30,50 +31,51 @@ function createEvent(overrides) { ruleKey: 'squid1234', ruleName: 'Do not do this', params: {}, + organization: null, ...overrides }; } it('should render events', () => { const events = [createEvent(), createEvent()]; - const changelog = shallow(); + const changelog = shallow(); expect(changelog.find('tbody').find('tr').length).toBe(2); }); it('should render event date', () => { const events = [createEvent()]; - const changelog = shallow(); + const changelog = shallow(); expect(changelog.text()).toContain('2016'); }); it('should render author', () => { const events = [createEvent()]; - const changelog = shallow(); + const changelog = shallow(); expect(changelog.text()).toContain('John'); }); it('should render system author', () => { const events = [createEvent({ authorName: undefined })]; - const changelog = shallow(); + const changelog = shallow(); expect(changelog.text()).toContain('System'); }); it('should render action', () => { const events = [createEvent()]; - const changelog = shallow(); + const changelog = shallow(); expect(changelog.text()).toContain('ACTIVATED'); }); it('should render rule', () => { const events = [createEvent()]; - const changelog = shallow(); + const changelog = shallow(); expect(changelog.find('Link').prop('to')).toContain('rule_key=squid1234'); }); it('should render ChangesList', () => { const params = { severity: 'BLOCKER' }; const events = [createEvent({ params })]; - const changelog = shallow(); + const changelog = shallow(); const changesList = changelog.find(ChangesList); expect(changesList.length).toBe(1); expect(changesList.prop('changes')).toBe(params); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogSearch-test.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogSearch-test.tsx similarity index 98% rename from server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogSearch-test.js rename to server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogSearch-test.tsx index be461db98d4..78dd87a4b9f 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogSearch-test.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangelogSearch-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import React from 'react'; +import * as React from 'react'; import ChangelogSearch from '../ChangelogSearch'; import DateInput from '../../../../components/controls/DateInput'; import { click } from '../../../../helpers/testUtils'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangesList-test.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangesList-test.tsx similarity index 98% rename from server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangesList-test.js rename to server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangesList-test.tsx index 7ccb56ee199..82ddc9af0a0 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangesList-test.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ChangesList-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import React from 'react'; +import * as React from 'react'; import ChangesList from '../ChangesList'; import SeverityChange from '../SeverityChange'; import ParameterChange from '../ParameterChange'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ParameterChange-test.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ParameterChange-test.tsx similarity index 91% rename from server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ParameterChange-test.js rename to server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ParameterChange-test.tsx index 25032b3e07a..de80150b085 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ParameterChange-test.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/ParameterChange-test.tsx @@ -18,11 +18,11 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import React from 'react'; +import * as React from 'react'; import ParameterChange from '../ParameterChange'; it('should render different messages', () => { - const first = shallow(); + const first = shallow(); const second = shallow(); expect(first.text()).not.toBe(second.text()); }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/SeverityChange-test.js b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/SeverityChange-test.tsx similarity index 97% rename from server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/SeverityChange-test.js rename to server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/SeverityChange-test.tsx index 8597dd0ab8c..bc5f6553420 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/SeverityChange-test.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/__tests__/SeverityChange-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import React from 'react'; +import * as React from 'react'; import SeverityChange from '../SeverityChange'; import SeverityHelper from '../../../../components/shared/SeverityHelper'; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.js b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.tsx similarity index 74% rename from server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.js rename to server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.tsx index 718d80dcc3d..003fd55a6d3 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonContainer.tsx @@ -17,45 +17,45 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; -import PropTypes from 'prop-types'; +import * as React from 'react'; +import * as PropTypes from 'prop-types'; import ComparisonForm from './ComparisonForm'; import ComparisonResults from './ComparisonResults'; import { compareProfiles } from '../../../api/quality-profiles'; import { getProfileComparePath } from '../utils'; -/*:: import type { Profile } from '../propTypes'; */ - -/*:: -type Props = { - location: { query: { withKey?: string } }, - organization: ?string, - profile: Profile, - profiles: Array -}; -*/ - -/*:: -type State = { - loading: boolean, - left?: { name: string }, - right?: { name: string }, - inLeft?: Array<*>, - inRight?: Array<*>, - modified?: Array<*> -}; -*/ - -export default class ComparisonContainer extends React.PureComponent { - /*:: mounted: boolean; */ - /*:: props: Props; */ - /*:: state: State; */ +import { IProfile } from '../types'; + +interface Props { + location: { query: { withKey?: string } }; + organization: string | null; + profile: IProfile; + profiles: IProfile[]; +} + +type Params = { [p: string]: string }; + +interface State { + loading: boolean; + left?: { name: string }; + right?: { name: string }; + inLeft?: Array<{ key: string; name: string; severity: string }>; + inRight?: Array<{ key: string; name: string; severity: string }>; + modified?: Array<{ + key: string; + name: string; + left: { params: Params; severity: string }; + right: { params: Params; severity: string }; + }>; +} + +export default class ComparisonContainer extends React.PureComponent { + mounted: boolean; static contextTypes = { router: PropTypes.object }; - constructor(props /*: Props */) { + constructor(props: Props) { super(props); this.state = { loading: false }; } @@ -65,7 +65,7 @@ export default class ComparisonContainer extends React.PureComponent { this.loadResults(); } - componentDidUpdate(prevProps /*: Props */) { + componentDidUpdate(prevProps: Props) { if (prevProps.profile !== this.props.profile || prevProps.location !== this.props.location) { this.loadResults(); } @@ -83,7 +83,7 @@ export default class ComparisonContainer extends React.PureComponent { } this.setState({ loading: true }); - compareProfiles(this.props.profile.key, withKey).then(r => { + compareProfiles(this.props.profile.key, withKey).then((r: any) => { if (this.mounted) { this.setState({ left: r.left, @@ -97,7 +97,7 @@ export default class ComparisonContainer extends React.PureComponent { }); } - handleCompare = (withKey /*: string */) => { + handleCompare = (withKey: string) => { const path = getProfileComparePath( this.props.profile.name, this.props.profile.language, @@ -126,6 +126,10 @@ export default class ComparisonContainer extends React.PureComponent { {left != null && + inLeft != null && + right != null && + inRight != null && + modified != null && - {translate('quality_profile.empty_comparison')} -
- ); - } +export default function ComparisonEmpty() { + return ( +
+ {translate('quality_profile.empty_comparison')} +
+ ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonForm.tsx similarity index 80% rename from server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonForm.js rename to server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonForm.tsx index c0a0086f006..11c4fb25639 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonForm.tsx @@ -17,25 +17,20 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; -import Select from 'react-select'; +import * as React from 'react'; +import * as Select from 'react-select'; import { translate } from '../../../helpers/l10n'; -/*:: import type { Profile } from '../propTypes'; */ +import { IProfile } from '../types'; -/*:: -type Props = { - profile: Profile, - profiles: Array, - onCompare: string => void, - withKey: string -}; -*/ - -export default class ComparisonForm extends React.PureComponent { - /*:: props: Props; */ +interface Props { + profile: IProfile; + profiles: IProfile[]; + onCompare: (rule: string) => void; + withKey?: string; +} - handleChange(option /*: { value: string } */) { +export default class ComparisonForm extends React.PureComponent { + handleChange(option: { value: string }) { this.props.onCompare(option.value); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.js b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx similarity index 87% rename from server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.js rename to server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx index b13c88ecace..f29c2ec1c2b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx @@ -17,33 +17,31 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import { Link } from 'react-router'; import ComparisonEmpty from './ComparisonEmpty'; import SeverityIcon from '../../../components/shared/SeverityIcon'; import { translateWithParameters } from '../../../helpers/l10n'; import { getRulesUrl } from '../../../helpers/urls'; -/*:: -type Params = { [string]: string }; -*/ +type Params = { [p: string]: string }; -/*:: -type Props = { - left: { name: string }, - right: { name: string }, - inLeft: Array<*>, - inRight: Array<*>, - modified: Array<*>, - organization: ?string -}; -*/ - -export default class ComparisonResults extends React.PureComponent { - /*:: props: Props; */ +interface Props { + left: { name: string }; + right: { name: string }; + inLeft: Array<{ key: string; name: string; severity: string }>; + inRight: Array<{ key: string; name: string; severity: string }>; + modified: Array<{ + key: string; + name: string; + left: { params: Params; severity: string }; + right: { params: Params; severity: string }; + }>; + organization: string | null; +} - renderRule(rule /*: { key: string, name: string } */, severity /*: string */) { +export default class ComparisonResults extends React.PureComponent { + renderRule(rule: { key: string; name: string }, severity: string) { return (
{' '} @@ -52,7 +50,7 @@ export default class ComparisonResults extends React.PureComponent { ); } - renderParameters(params /*: Params */) { + renderParameters(params: Params) { if (!params) { return null; } @@ -135,7 +133,7 @@ export default class ComparisonResults extends React.PureComponent { } const header = ( - +
{translateWithParameters( 'quality_profiles.x_rules_have_different_configuration', diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/ComparisonForm-test.js b/server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/ComparisonForm-test.tsx similarity index 95% rename from server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/ComparisonForm-test.js rename to server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/ComparisonForm-test.tsx index b972451e628..55edbd993fe 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/ComparisonForm-test.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/ComparisonForm-test.tsx @@ -18,8 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import React from 'react'; -import Select from 'react-select'; +import * as React from 'react'; import ComparisonForm from '../ComparisonForm'; import { createFakeProfile } from '../../utils'; @@ -38,7 +37,7 @@ it('should render Select with right options', () => { profiles={profiles} onCompare={() => true} /> - ).find(Select); + ).find('Select'); expect(output.length).toBe(1); expect(output.prop('value')).toBe('another'); expect(output.prop('options')).toEqual([{ value: 'another', label: 'another name' }]); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/ComparisonResults-test.js b/server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/ComparisonResults-test.tsx similarity index 97% rename from server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/ComparisonResults-test.js rename to server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/ComparisonResults-test.tsx index d346aa2f480..c3200b06612 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/ComparisonResults-test.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/__tests__/ComparisonResults-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import React from 'react'; +import * as React from 'react'; import { Link } from 'react-router'; import ComparisonResults from '../ComparisonResults'; import ComparisonEmpty from '../ComparisonEmpty'; @@ -32,6 +32,7 @@ it('should render ComparisonEmpty', () => { inLeft={[]} inRight={[]} modified={[]} + organization={null} /> ); expect(output.is(ComparisonEmpty)).toBe(true); @@ -65,6 +66,7 @@ it('should compare', () => { inLeft={inLeft} inRight={inRight} modified={modified} + organization={null} /> ); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/App.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx similarity index 83% rename from server/sonar-web/src/main/js/apps/quality-profiles/components/App.js rename to server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx index b0f80ee623b..44013b73e70 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/App.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx @@ -17,37 +17,31 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import { searchQualityProfiles, getExporters } from '../../../api/quality-profiles'; import { sortProfiles } from '../utils'; import { translate } from '../../../helpers/l10n'; import OrganizationHelmet from '../../../components/common/OrganizationHelmet'; -/*:: import type { Exporter } from '../propTypes'; */ import '../styles.css'; +import { IExporter, IProfile } from '../types'; -/*:: -type Props = { - children: React.Element<*>, - currentUser: { permissions: { global: Array } }, - languages: Array<*>, - onRequestFail: Object => void, - organization: { name: string, canAdmin?: boolean, key: string } | null -}; -*/ +interface Props { + children: React.ReactElement; + currentUser: { permissions: { global: Array } }; + languages: Array<{}>; + onRequestFail: (reasong: any) => void; + organization: { name: string; canAdmin?: boolean; key: string } | null; +} -/*:: -type State = { - loading: boolean, - exporters?: Array, - profiles?: Array<*> -}; -*/ +interface State { + loading: boolean; + exporters?: IExporter[]; + profiles?: IProfile[]; +} -export default class App extends React.PureComponent { - /*:: mounted: boolean; */ - /*:: props: Props; */ - state /*: State */ = { loading: true }; +export default class App extends React.PureComponent { + mounted: boolean; + state: State = { loading: true }; componentWillMount() { const html = document.querySelector('html'); @@ -90,7 +84,7 @@ export default class App extends React.PureComponent { } updateProfiles = () => { - return this.fetchProfiles().then(profiles => { + return this.fetchProfiles().then((profiles: any) => { if (this.mounted) { this.setState({ profiles: sortProfiles(profiles) }); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.tsx similarity index 84% rename from server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.js rename to server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.tsx index a9809ffe0dc..9eb3af6d784 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/AppContainer.tsx @@ -22,7 +22,7 @@ import App from './App'; import { getLanguages, getCurrentUser, getOrganizationByKey } from '../../../store/rootReducer'; import { onFail } from '../../../store/rootActions'; -const mapStateToProps = (state, ownProps) => ({ +const mapStateToProps = (state: any, ownProps: any) => ({ currentUser: getCurrentUser(state), languages: getLanguages(state), organization: ownProps.params.organizationKey @@ -30,8 +30,8 @@ const mapStateToProps = (state, ownProps) => ({ : null }); -const mapDispatchToProps = dispatch => ({ - onRequestFail: error => onFail(dispatch)(error) +const mapDispatchToProps = (dispatch: any) => ({ + onRequestFail: (error: any) => onFail(dispatch)(error) }); -export default connect(mapStateToProps, mapDispatchToProps)(App); +export default connect(mapStateToProps, mapDispatchToProps)(App as any); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.tsx similarity index 79% rename from server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.js rename to server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.tsx index fa2e1635620..7a70614d3e5 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/BuiltInBadge.tsx @@ -17,22 +17,19 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; -import classNames from 'classnames'; +import * as React from 'react'; +import * as classNames from 'classnames'; import Tooltip from '../../../components/controls/Tooltip'; import { translate } from '../../../helpers/l10n'; -/*:: -type Props = {| - className?: string, - tooltip?: boolean -|}; -*/ +interface Props { + className?: string; + tooltip?: boolean; +} -export default function BuiltInBadge(props /*: Props */) { +export default function BuiltInBadge({ className, tooltip = true }: Props) { const badge = ( -
+
{translate('quality_profiles.built_in')}
); @@ -44,13 +41,9 @@ export default function BuiltInBadge(props /*: Props */) { ); - return props.tooltip + return tooltip ? {badge} : badge; } - -BuiltInBadge.defaultProps = { - tooltip: true -}; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/CopyProfileForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/CopyProfileForm.tsx similarity index 82% rename from server/sonar-web/src/main/js/apps/quality-profiles/components/CopyProfileForm.js rename to server/sonar-web/src/main/js/apps/quality-profiles/components/CopyProfileForm.tsx index 4ad268e4982..4d24898081d 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/CopyProfileForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/CopyProfileForm.tsx @@ -17,33 +17,27 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import Modal from 'react-modal'; -/*:: import type { Profile } from '../propTypes'; */ import { copyProfile } from '../../../api/quality-profiles'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { IProfile } from '../types'; -/*:: -type Props = { - onClose: () => void, - onCopy: string => void, - onRequestFail: Object => void, - profile: Profile -}; -*/ +interface Props { + onClose: () => void; + onCopy: (name: string) => void; + onRequestFail: (reasong: any) => void; + profile: IProfile; +} -/*:: -type State = { - loading: boolean, - name: ?string -}; -*/ +interface State { + loading: boolean; + name: string | null; +} -export default class CopyProfileForm extends React.PureComponent { - /*:: mounted: boolean; */ - /*:: props: Props; */ - state /*: State */ = { loading: false, name: null }; +export default class CopyProfileForm extends React.PureComponent { + mounted: boolean; + state: State = { loading: false, name: null }; componentDidMount() { this.mounted = true; @@ -53,16 +47,16 @@ export default class CopyProfileForm extends React.PureComponent { this.mounted = false; } - handleCancelClick = (event /*: Event */) => { + handleCancelClick = (event: React.SyntheticEvent) => { event.preventDefault(); this.props.onClose(); }; - handleNameChange = (event /*: { currentTarget: HTMLInputElement } */) => { + handleNameChange = (event: React.SyntheticEvent) => { this.setState({ name: event.currentTarget.value }); }; - handleFormSubmit = (event /*: Event */) => { + handleFormSubmit = (event: React.SyntheticEvent) => { event.preventDefault(); const { name } = this.state; @@ -70,8 +64,8 @@ export default class CopyProfileForm extends React.PureComponent { if (name != null) { this.setState({ loading: true }); copyProfile(this.props.profile.key, name).then( - profile => this.props.onCopy(profile.name), - error => { + (profile: any) => this.props.onCopy(profile.name), + (error: any) => { if (this.mounted) { this.setState({ loading: false }); } @@ -113,11 +107,11 @@ export default class CopyProfileForm extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/DeleteProfileForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/DeleteProfileForm.tsx similarity index 86% rename from server/sonar-web/src/main/js/apps/quality-profiles/components/DeleteProfileForm.js rename to server/sonar-web/src/main/js/apps/quality-profiles/components/DeleteProfileForm.tsx index 975ca0a32db..5a7b22719db 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/DeleteProfileForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/DeleteProfileForm.tsx @@ -17,32 +17,27 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import Modal from 'react-modal'; -/*:: import type { Profile } from '../propTypes'; */ import { deleteProfile } from '../../../api/quality-profiles'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { IProfile } from '../types'; -/*:: -type Props = { - onClose: () => void, - onDelete: () => void, - onRequestFail: Object => void, - profile: Profile -}; -*/ +interface Props { + onClose: () => void; + onDelete: () => void; + onRequestFail: (reason: any) => void; + profile: IProfile; +} -/*:: -type State = { - loading: boolean -}; -*/ +interface State { + loading: boolean; + name: string | null; +} -export default class DeleteProfileForm extends React.PureComponent { - /*:: mounted: boolean; */ - /*:: props: Props; */ - state /*: State */ = { loading: false, name: null }; +export default class DeleteProfileForm extends React.PureComponent { + mounted: boolean; + state: State = { loading: false, name: null }; componentDidMount() { this.mounted = true; @@ -52,15 +47,15 @@ export default class DeleteProfileForm extends React.PureComponent { this.mounted = false; } - handleCancelClick = (event /*: Event */) => { + handleCancelClick = (event: React.SyntheticEvent) => { event.preventDefault(); this.props.onClose(); }; - handleFormSubmit = (event /*: Event */) => { + handleFormSubmit = (event: React.SyntheticEvent) => { event.preventDefault(); this.setState({ loading: true }); - deleteProfile(this.props.profile.key).then(this.props.onDelete, error => { + deleteProfile(this.props.profile.key).then(this.props.onDelete, (error: any) => { if (this.mounted) { this.setState({ loading: false }); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx similarity index 84% rename from server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.js rename to server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx index 8a2b2f805f0..6d1ad5c0120 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.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. */ -// @flow -import React from 'react'; -import PropTypes from 'prop-types'; +import * as React from 'react'; +import * as PropTypes from 'prop-types'; import { Link } from 'react-router'; import RenameProfileForm from './RenameProfileForm'; import CopyProfileForm from './CopyProfileForm'; @@ -28,31 +27,24 @@ import { translate } from '../../../helpers/l10n'; import { getRulesUrl } from '../../../helpers/urls'; import { setDefaultProfile } from '../../../api/quality-profiles'; import { getProfilePath, getProfileComparePath, getProfilesPath } from '../utils'; -/*:: import type { Profile } from '../propTypes'; */ - -/*:: -type Props = { - canAdmin: boolean, - fromList: boolean, - onRequestFail: Object => void, - organization: ?string, - profile: Profile, - updateProfiles: () => Promise<*> -}; -*/ - -/*:: -type State = { - copyFormOpen: boolean, - deleteFormOpen: boolean, - renameFormOpen: boolean -}; -*/ - -export default class ProfileActions extends React.PureComponent { - /*:: props: Props; */ - /*:: state: State; */ +import { IProfile } from '../types'; + +interface Props { + canAdmin: boolean; + fromList?: boolean; + onRequestFail: (reasong: any) => void; + organization: string | null; + profile: IProfile; + updateProfiles: () => Promise; +} + +interface State { + copyFormOpen: boolean; + deleteFormOpen: boolean; + renameFormOpen: boolean; +} +export default class ProfileActions extends React.PureComponent { static defaultProps = { fromList: false }; @@ -61,7 +53,7 @@ export default class ProfileActions extends React.PureComponent { router: PropTypes.object }; - constructor(props /*: Props */) { + constructor(props: Props) { super(props); this.state = { copyFormOpen: false, @@ -70,12 +62,12 @@ export default class ProfileActions extends React.PureComponent { }; } - handleRenameClick = (event /*: Event */) => { + handleRenameClick = (event: React.SyntheticEvent) => { event.preventDefault(); this.setState({ renameFormOpen: true }); }; - handleProfileRename = (name /*: string */) => { + handleProfileRename = (name: string) => { this.closeRenameForm(); this.props.updateProfiles().then(() => { if (!this.props.fromList) { @@ -90,12 +82,12 @@ export default class ProfileActions extends React.PureComponent { this.setState({ renameFormOpen: false }); }; - handleCopyClick = (event /*: Event */) => { + handleCopyClick = (event: React.SyntheticEvent) => { event.preventDefault(); this.setState({ copyFormOpen: true }); }; - handleProfileCopy = (name /*: string */) => { + handleProfileCopy = (name: string) => { this.props.updateProfiles().then(() => { this.context.router.push( getProfilePath(name, this.props.profile.language, this.props.organization) @@ -107,12 +99,12 @@ export default class ProfileActions extends React.PureComponent { this.setState({ copyFormOpen: false }); }; - handleSetDefaultClick = (e /*: SyntheticInputEvent */) => { + handleSetDefaultClick = (e: React.SyntheticEvent) => { e.preventDefault(); setDefaultProfile(this.props.profile.key).then(this.props.updateProfiles); }; - handleDeleteClick = (event /*: Event */) => { + handleDeleteClick = (event: React.SyntheticEvent) => { event.preventDefault(); this.setState({ deleteFormOpen: true }); }; @@ -131,7 +123,9 @@ export default class ProfileActions extends React.PureComponent { // FIXME use org, name and lang const backupUrl = - window.baseUrl + '/api/qualityprofiles/backup?profileKey=' + encodeURIComponent(profile.key); + (window as any).baseUrl + + '/api/qualityprofiles/backup?profileKey=' + + encodeURIComponent(profile.key); const activateMoreUrl = getRulesUrl( { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx similarity index 86% rename from server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.js rename to server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx index f44f53c9e35..ee6d302acdd 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileContainer.tsx @@ -17,32 +17,27 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import Helmet from 'react-helmet'; import ProfileNotFound from './ProfileNotFound'; import ProfileHeader from '../details/ProfileHeader'; -/*:: import type { Profile } from '../propTypes'; */ +import { IProfile } from '../types'; -/*:: -type Props = { - canAdmin: boolean, - children: React.Element<*>, +interface Props { + canAdmin: boolean; + children: React.ReactElement; location: { - pathname: string, - query: { key?: string, language: string, name: string } - }, - onRequestFail: Object => void, - organization: ?string, - profiles: Array, - router: { replace: ({}) => void }, - updateProfiles: () => Promise<*> -}; -*/ - -export default class ProfileContainer extends React.PureComponent { - /*:: props: Props; */ + pathname: string; + query: { key?: string; language: string; name: string }; + }; + onRequestFail: (reasong: any) => void; + organization: string | null; + profiles: IProfile[]; + router: { replace: ({}) => void }; + updateProfiles: () => Promise; +} +export default class ProfileContainer extends React.PureComponent { componentDidMount() { const { location, profiles, router } = this.props; if (location.query.key) { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileDate.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileDate.tsx similarity index 68% rename from server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileDate.js rename to server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileDate.tsx index ae878a4ba6b..947b15e419c 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileDate.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileDate.tsx @@ -17,35 +17,20 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; -import moment from 'moment'; +import * as React from 'react'; +import * as moment from 'moment'; import { translate } from '../../../helpers/l10n'; -/*:: -type Props = { - date?: string -}; -*/ - -export default class ProfileDate extends React.PureComponent { - /*:: props: Props; */ - - render() { - const { date } = this.props; - - if (!date) { - return ( - - {translate('never')} - - ); - } +interface Props { + date?: string; +} - return ( - +export default function ProfileDate({ date }: Props) { + return date + ? {moment(date).fromNow()} - ); - } + : + {translate('never')} + ; } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileLink.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileLink.tsx similarity index 63% rename from server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileLink.js rename to server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileLink.tsx index 2ff0534c108..8b69532ad74 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileLink.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileLink.tsx @@ -17,32 +17,25 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import { Link } from 'react-router'; import { getProfilePath } from '../utils'; -/*:: -type Props = { - children?: React.Element<*>, - language: string, - name: string, - organization: ?string -}; -*/ - -export default class ProfileLink extends React.PureComponent { - /*:: props: Props; */ +interface Props { + className?: string; + children?: React.ReactElement | string; + language: string; + name: string; + organization: string | null; +} - render() { - const { name, language, organization, children, ...other } = this.props; - return ( - - {children} - - ); - } +export default function ProfileLink({ name, language, organization, children, ...other }: Props) { + return ( + + {children} + + ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileNotFound.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileNotFound.tsx similarity index 63% rename from server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileNotFound.js rename to server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileNotFound.tsx index 7dce1cc0ce1..a6fd496502c 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileNotFound.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileNotFound.tsx @@ -17,34 +17,27 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import { IndexLink } from 'react-router'; import { translate } from '../../../helpers/l10n'; import { getProfilesPath } from '../utils'; -/*:: -type Props = { - organization: ?string -}; -*/ - -export default class ProfileNotFound extends React.PureComponent { - /*:: props: Props; */ +interface Props { + organization: string | null; +} - render() { - return ( -
-
- - {translate('quality_profiles.page')} - -
+export default function ProfileNotFound(props: Props) { + return ( +
+
+ + {translate('quality_profiles.page')} + +
-
- {translate('quality_profiles.not_found')} -
+
+ {translate('quality_profiles.not_found')}
- ); - } +
+ ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/RenameProfileForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/RenameProfileForm.tsx similarity index 83% rename from server/sonar-web/src/main/js/apps/quality-profiles/components/RenameProfileForm.js rename to server/sonar-web/src/main/js/apps/quality-profiles/components/RenameProfileForm.tsx index 37d63394d21..1d1491975ec 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/RenameProfileForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/RenameProfileForm.tsx @@ -17,33 +17,27 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import Modal from 'react-modal'; -/*:: import type { Profile } from '../propTypes'; */ import { renameProfile } from '../../../api/quality-profiles'; import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { IProfile } from '../types'; -/*:: -type Props = { - onClose: () => void, - onRename: string => void, - onRequestFail: Object => void, - profile: Profile -}; -*/ +interface Props { + onClose: () => void; + onRename: (name: string) => void; + onRequestFail: (reason: any) => void; + profile: IProfile; +} -/*:: -type State = { - loading: boolean, - name: ?string -}; -*/ +interface State { + loading: boolean; + name: string | null; +} -export default class RenameProfileForm extends React.PureComponent { - /*:: mounted: boolean; */ - /*:: props: Props; */ - state /*: State */ = { loading: false, name: null }; +export default class RenameProfileForm extends React.PureComponent { + mounted: boolean; + state: State = { loading: false, name: null }; componentDidMount() { this.mounted = true; @@ -53,16 +47,16 @@ export default class RenameProfileForm extends React.PureComponent { this.mounted = false; } - handleCancelClick = (event /*: Event */) => { + handleCancelClick = (event: React.SyntheticEvent) => { event.preventDefault(); this.props.onClose(); }; - handleNameChange = (event /*: { currentTarget: HTMLInputElement } */) => { + handleNameChange = (event: React.SyntheticEvent) => { this.setState({ name: event.currentTarget.value }); }; - handleFormSubmit = (event /*: Event */) => { + handleFormSubmit = (event: React.SyntheticEvent) => { event.preventDefault(); const { name } = this.state; @@ -71,7 +65,7 @@ export default class RenameProfileForm extends React.PureComponent { this.setState({ loading: true }); renameProfile(this.props.profile.key, name).then( () => this.props.onRename(name), - error => { + (error: any) => { if (this.mounted) { this.setState({ loading: false }); } @@ -113,11 +107,11 @@ export default class RenameProfileForm extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileContainer-test.js b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileContainer-test.tsx similarity index 82% rename from server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileContainer-test.js rename to server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileContainer-test.tsx index 08aa98c6b32..1c0efc638ab 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileContainer-test.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileContainer-test.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { shallow } from 'enzyme'; -import React from 'react'; +import * as React from 'react'; import Helmet from 'react-helmet'; import ProfileContainer from '../ProfileContainer'; import ProfileNotFound from '../ProfileNotFound'; @@ -31,9 +31,12 @@ it('should render ProfileHeader', () => { const updateProfiles = jest.fn(); const output = shallow(
@@ -52,10 +55,13 @@ it('should render ProfileNotFound', () => { ]; const output = shallow( true}> + location={{ pathname: '', query: { language: 'js', name: 'random' } }} + onRequestFail={jest.fn()} + organization={null} + profiles={profiles} + router={{} as any} + updateProfiles={jest.fn()}>
); @@ -67,9 +73,12 @@ it('should render Helmet', () => { const updateProfiles = jest.fn(); const output = shallow(
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeParentForm.js b/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeParentForm.tsx similarity index 80% rename from server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeParentForm.js rename to server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeParentForm.tsx index f7d019e63d8..fd8292c7d97 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeParentForm.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ChangeParentForm.tsx @@ -17,36 +17,30 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import Modal from 'react-modal'; -import Select from 'react-select'; +import * as Select from 'react-select'; import { sortBy } from 'lodash'; import { changeProfileParent } from '../../../api/quality-profiles'; import { translate } from '../../../helpers/l10n'; -/*:: import type { Profile } from '../propTypes'; */ +import { IProfile } from '../types'; -/*:: -type Props = { - onChange: () => void, - onClose: () => void, - onRequestFail: Object => void, - profile: Profile, - profiles: Array -}; -*/ +interface Props { + onChange: () => void; + onClose: () => void; + onRequestFail: (reasong: any) => void; + profile: IProfile; + profiles: IProfile[]; +} -/*:: -type State = { - loading: boolean, - selected: ?string -}; -*/ +interface State { + loading: boolean; + selected: string | null; +} -export default class ChangeParentForm extends React.PureComponent { - /*:: mounted: boolean; */ - /*:: props: Props; */ - state /*: State */ = { +export default class ChangeParentForm extends React.PureComponent { + mounted: boolean; + state: State = { loading: false, selected: null }; @@ -59,28 +53,30 @@ export default class ChangeParentForm extends React.PureComponent { this.mounted = false; } - handleCancelClick = (event /*: Event */) => { + handleCancelClick = (event: React.SyntheticEvent) => { event.preventDefault(); this.props.onClose(); }; - handleSelectChange = (option /*: { value: string } */) => { + handleSelectChange = (option: { value: string }) => { this.setState({ selected: option.value }); }; - handleFormSubmit = (event /*: Event */) => { + handleFormSubmit = (event: React.SyntheticEvent) => { event.preventDefault(); const parent = this.state.selected; if (parent != null) { this.setState({ loading: true }); - changeProfileParent(this.props.profile.key, parent).then(this.props.onChange).catch(error => { - if (this.mounted) { - this.setState({ loading: false }); - } - this.props.onRequestFail(error); - }); + changeProfileParent(this.props.profile.key, parent) + .then(this.props.onChange) + .catch((error: any) => { + if (this.mounted) { + this.setState({ loading: false }); + } + this.props.onRequestFail(error); + }); } }; @@ -122,7 +118,6 @@ export default class ChangeParentForm extends React.PureComponent { @@ -157,7 +150,6 @@ export default class CreateProfileForm extends React.PureComponent { (this.input = node as HTMLInputElement)} type="text" defaultValue={this.props.value} readOnly={true} diff --git a/server/sonar-web/src/main/js/components/controls/ListFooter.js b/server/sonar-web/src/main/js/components/controls/ListFooter.js deleted file mode 100644 index 24711f088db..00000000000 --- a/server/sonar-web/src/main/js/components/controls/ListFooter.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 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 classNames from 'classnames'; -import React from 'react'; -import PropTypes from 'prop-types'; -import { translate, translateWithParameters } from '../../helpers/l10n'; -import { formatMeasure } from '../../helpers/measures'; - -export default class ListFooter extends React.PureComponent { - static propTypes = { - count: PropTypes.number.isRequired, - total: PropTypes.number.isRequired, - loadMore: PropTypes.func, - ready: PropTypes.bool - }; - - static defaultProps = { - ready: true - }; - - canLoadMore() { - return typeof this.props.loadMore === 'function'; - } - - handleLoadMore = event => { - event.preventDefault(); - event.target.blur(); - this.props.loadMore(); - }; - - render() { - const hasMore = this.props.total > this.props.count; - const loadMoreLink = ( - - {translate('show_more')} - - ); - const className = classNames('spacer-top note text-center', { - 'new-loading': !this.props.ready - }); - - return ( -
- {translateWithParameters( - 'x_of_y_shown', - formatMeasure(this.props.count, 'INT'), - formatMeasure(this.props.total, 'INT') - )} - {this.canLoadMore() && hasMore ? loadMoreLink : null} -
- ); - } -} diff --git a/server/sonar-web/src/main/js/components/controls/ListFooter.tsx b/server/sonar-web/src/main/js/components/controls/ListFooter.tsx new file mode 100644 index 00000000000..7d5df6797d5 --- /dev/null +++ b/server/sonar-web/src/main/js/components/controls/ListFooter.tsx @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import * as classNames from 'classnames'; +import { translate, translateWithParameters } from '../../helpers/l10n'; +import { formatMeasure } from '../../helpers/measures'; + +interface Props { + count: number; + loadMore?: () => void; + ready?: boolean; + total: number; +} + +export default function ListFooter({ ready = true, ...props }: Props) { + const handleLoadMore = (event: React.SyntheticEvent) => { + event.preventDefault(); + event.currentTarget.blur(); + if (props.loadMore) { + props.loadMore(); + } + }; + + const hasMore = props.total > props.count; + const loadMoreLink = ( + + {translate('show_more')} + + ); + const className = classNames('spacer-top note text-center', { + 'new-loading': !ready + }); + + return ( +
+ {translateWithParameters( + 'x_of_y_shown', + formatMeasure(props.count, 'INT', null), + formatMeasure(props.total, 'INT', null) + )} + {props.loadMore != null && hasMore ? loadMoreLink : null} +
+ ); +} diff --git a/server/sonar-web/src/main/js/components/controls/Tooltip.js b/server/sonar-web/src/main/js/components/controls/Tooltip.tsx similarity index 71% rename from server/sonar-web/src/main/js/components/controls/Tooltip.js rename to server/sonar-web/src/main/js/components/controls/Tooltip.tsx index 68197750050..f33a4f1677c 100644 --- a/server/sonar-web/src/main/js/components/controls/Tooltip.js +++ b/server/sonar-web/src/main/js/components/controls/Tooltip.tsx @@ -17,23 +17,19 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import TooltipCore from 'rc-tooltip'; -export default class Tooltip extends React.PureComponent { - /*:: props: { - placement?: string - }; -*/ - - static defaultProps = { - placement: 'bottom' - }; +interface Props { + overlay: React.ReactNode; + placement?: string; + [attr: string]: any; +} - render() { - return ( - - ); - } +export default function Tooltip(props: Props) { + return ; } + +(Tooltip as React.StatelessComponent).defaultProps = { + placement: 'bottom' +}; diff --git a/server/sonar-web/src/main/js/components/icons-components/BugIcon.js b/server/sonar-web/src/main/js/components/icons-components/BugIcon.tsx similarity index 89% rename from server/sonar-web/src/main/js/components/icons-components/BugIcon.js rename to server/sonar-web/src/main/js/components/icons-components/BugIcon.tsx index 48726f839d0..eb5f504ecb8 100644 --- a/server/sonar-web/src/main/js/components/icons-components/BugIcon.js +++ b/server/sonar-web/src/main/js/components/icons-components/BugIcon.tsx @@ -17,14 +17,14 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; -/*:: -type Props = { className?: string, size?: number }; -*/ +interface Props { + className?: string; + size?: number; +} -export default function BugIcon({ className, size = 16 } /*: Props */) { +export default function BugIcon({ className, size = 16 }: Props) { /* eslint-disable max-len */ return ( ; - } -} diff --git a/server/sonar-web/src/main/js/components/shared/QualifierIcon.tsx b/server/sonar-web/src/main/js/components/shared/QualifierIcon.tsx new file mode 100644 index 00000000000..802d90c10d2 --- /dev/null +++ b/server/sonar-web/src/main/js/components/shared/QualifierIcon.tsx @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import * as classNames from 'classnames'; + +interface Props { + className?: string; + qualifier: string | null; +} + +export default function QualifierIcon(props: Props) { + if (!props.qualifier) { + return null; + } + + const className = classNames('icon-qualifier-' + props.qualifier.toLowerCase(), props.className); + + return ; +} diff --git a/server/sonar-web/src/main/js/components/ui/IssueTypeIcon.js b/server/sonar-web/src/main/js/components/ui/IssueTypeIcon.tsx similarity index 55% rename from server/sonar-web/src/main/js/components/ui/IssueTypeIcon.js rename to server/sonar-web/src/main/js/components/ui/IssueTypeIcon.tsx index 83feca0536e..63aae3cc815 100644 --- a/server/sonar-web/src/main/js/components/ui/IssueTypeIcon.js +++ b/server/sonar-web/src/main/js/components/ui/IssueTypeIcon.tsx @@ -17,49 +17,44 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// @flow -import React from 'react'; +import * as React from 'react'; import BugIcon from '../icons-components/BugIcon'; import VulnerabilityIcon from '../icons-components/VulnerabilityIcon'; import CodeSmellIcon from '../icons-components/CodeSmellIcon'; -export default class IssueTypeIcon extends React.PureComponent { - /*:: props: { - className?: string, - query: string - }; -*/ - - renderIcon() { - switch (this.props.query.toLowerCase()) { - case 'bug': - case 'bugs': - case 'new_bugs': - return ; - case 'vulnerability': - case 'vulnerabilities': - case 'new_vulnerabilities': - return ; - case 'code_smell': - case 'code_smells': - case 'new_code_smells': - return ; - default: - return null; - } - } +interface Props { + className?: string; + query: string; +} - render() { - const icon = this.renderIcon(); +export default function IssueTypeIcon(props: Props) { + let icon; - if (!icon) { - return null; - } + switch (props.query.toLowerCase()) { + case 'bug': + case 'bugs': + case 'new_bugs': + icon = ; + break; + case 'vulnerability': + case 'vulnerabilities': + case 'new_vulnerabilities': + icon = ; + break; + case 'code_smell': + case 'code_smells': + case 'new_code_smells': + icon = ; + break; + } - return this.props.className - ? - {icon} - - : icon; + if (!icon) { + return null; } + + return props.className + ? + {icon} + + : icon; } diff --git a/server/sonar-web/src/main/js/components/ui/Level.js b/server/sonar-web/src/main/js/components/ui/Level.js deleted file mode 100644 index 2ba079f1995..00000000000 --- a/server/sonar-web/src/main/js/components/ui/Level.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 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 React from 'react'; -import PropTypes from 'prop-types'; -import classNames from 'classnames'; -import { formatMeasure } from '../../helpers/measures'; -import './Level.css'; - -export default class Level extends React.PureComponent { - static propTypes = { - className: PropTypes.string, - level: PropTypes.oneOf(['ERROR', 'WARN', 'OK', 'NONE']).isRequired, - small: PropTypes.bool, - muted: PropTypes.bool - }; - - static defaultProps = { - small: false, - muted: false - }; - - render() { - const formatted = formatMeasure(this.props.level, 'LEVEL'); - const className = classNames(this.props.className, 'level', 'level-' + this.props.level, { - 'level-small': this.props.small, - 'level-muted': this.props.muted - }); - return ( - - {formatted} - - ); - } -} diff --git a/server/sonar-web/src/main/js/components/ui/Level.tsx b/server/sonar-web/src/main/js/components/ui/Level.tsx new file mode 100644 index 00000000000..b5495695578 --- /dev/null +++ b/server/sonar-web/src/main/js/components/ui/Level.tsx @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import * as classNames from 'classnames'; +import { formatMeasure } from '../../helpers/measures'; +import './Level.css'; + +interface Props { + className?: string; + level: string; + small?: boolean; + muted?: boolean; +} + +export default function Level(props: Props) { + const formatted = formatMeasure(props.level, 'LEVEL', null); + const className = classNames(props.className, 'level', 'level-' + props.level, { + 'level-small': props.small, + 'level-muted': props.muted + }); + return ( + + {formatted} + + ); +} diff --git a/server/sonar-web/src/main/js/typings/rc-tooltip.d.ts b/server/sonar-web/src/main/js/typings/rc-tooltip.d.ts new file mode 100644 index 00000000000..b10195eca40 --- /dev/null +++ b/server/sonar-web/src/main/js/typings/rc-tooltip.d.ts @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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 module 'rc-tooltip' { + export type Trigger = 'hover' | 'click' | 'focus'; + export type Placement = + | 'left' + | 'right' + | 'top' + | 'bottom' + | 'topLeft' + | 'topRight' + | 'bottomLeft' + | 'bottomRight'; + + export interface Props extends React.Props { + overlayClassName?: string; + trigger?: Trigger[]; + mouseEnterDelay?: number; + mouseLeaveDelay?: number; + overlayStyle?: React.CSSProperties; + prefixCls?: string; + transitionName?: string; + onVisibleChange?: () => void; + visible?: boolean; + defaultVisible?: boolean; + placement?: Placement | Object; + align?: Object; + onPopupAlign?: (popupDomNode: Element, align: Object) => void; + overlay: React.ReactNode; + arrowContent?: React.ReactNode; + getTooltipContainer?: () => Element; + destroyTooltipOnHide?: boolean; + } + + // the next line is crucial, it is absent in the original typings + export default class Tooltip extends React.Component {} +} diff --git a/server/sonar-web/tsconfig.json b/server/sonar-web/tsconfig.json index 6f5b468c4b0..427192d12e7 100644 --- a/server/sonar-web/tsconfig.json +++ b/server/sonar-web/tsconfig.json @@ -9,7 +9,7 @@ "target": "es5", "jsx": "react", "lib": ["es2017", "dom"], - "module": "es2015", + "module": "esnext", "moduleResolution": "node", "typeRoots": ["./src/main/js/typings", "./node_modules/@types"] }, diff --git a/server/sonar-web/yarn.lock b/server/sonar-web/yarn.lock index 75d358da6cb..b3a14ca74f1 100644 --- a/server/sonar-web/yarn.lock +++ b/server/sonar-web/yarn.lock @@ -24,6 +24,10 @@ "@types/cheerio" "*" "@types/react" "*" +"@types/escape-html@0.0.19": + version "0.0.19" + resolved "https://registry.yarnpkg.com/@types/escape-html/-/escape-html-0.0.19.tgz#595ff7bd7ee510af54517819de24abdcea6f3507" + "@types/history@^3": version "3.2.1" resolved "https://registry.yarnpkg.com/@types/history/-/history-3.2.1.tgz#0039ab0e0be2a0cc22bac171d27a44588103d123" @@ -32,6 +36,10 @@ version "20.0.7" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-20.0.7.tgz#39cd215db8bda03928dceb933a1e63eb2cbd210e" +"@types/jquery@3.2.11": + version "3.2.11" + resolved "https://registry.yarnpkg.com/@types/jquery/-/jquery-3.2.11.tgz#9119f91bb103b16ae8c4375b019a9b341b409f50" + "@types/lodash@4.14.73": version "4.14.73" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.73.tgz#9837e47db8643ba5bcef2c7921f37d90f9c24213" @@ -51,6 +59,18 @@ "@types/node" "*" "@types/react" "*" +"@types/react-helmet@5.0.3": + version "5.0.3" + resolved "https://registry.yarnpkg.com/@types/react-helmet/-/react-helmet-5.0.3.tgz#614e706cb73120936c7c067404809f8c2f1a840c" + dependencies: + "@types/react" "*" + +"@types/react-modal@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@types/react-modal/-/react-modal-2.2.0.tgz#e92bb8454e53030581f263e3fb7e7d27e3eb85b8" + dependencies: + "@types/react" "*" + "@types/react-redux@5.0.3": version "5.0.3" resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-5.0.3.tgz#cd68de0c49c516b940fdc6f688535596b5d6eca4" @@ -65,6 +85,12 @@ "@types/history" "^3" "@types/react" "*" +"@types/react-select@1.0.51": + version "1.0.51" + resolved "https://registry.yarnpkg.com/@types/react-select/-/react-select-1.0.51.tgz#47e7787b068c34395251e95a0981cff8034eddcc" + dependencies: + "@types/react" "*" + "@types/react@*", "@types/react@16.0.2": version "16.0.2" resolved "https://registry.yarnpkg.com/@types/react/-/react-16.0.2.tgz#0b31a73cdde6272b719e5b05a7df6d1e2654a804" -- 2.39.5