You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exposeLibraries.ts 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2022 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import { FormattedMessage } from 'react-intl';
  21. import NotFound from '../../../app/components/NotFound';
  22. import DonutChart from '../../../components/charts/DonutChart';
  23. import ActionsDropdown, { ActionsDropdownItem } from '../../../components/controls/ActionsDropdown';
  24. import BoxedTabs from '../../../components/controls/BoxedTabs';
  25. import {
  26. Button,
  27. EditButton,
  28. ResetButtonLink,
  29. SubmitButton
  30. } from '../../../components/controls/buttons';
  31. import Checkbox from '../../../components/controls/Checkbox';
  32. import ClickEventBoundary from '../../../components/controls/ClickEventBoundary';
  33. import ConfirmButton from '../../../components/controls/ConfirmButton';
  34. import Dropdown from '../../../components/controls/Dropdown';
  35. import Favorite from '../../../components/controls/Favorite';
  36. import HelpTooltip from '../../../components/controls/HelpTooltip';
  37. import HomePageSelect from '../../../components/controls/HomePageSelect';
  38. import ListFooter from '../../../components/controls/ListFooter';
  39. import Modal from '../../../components/controls/Modal';
  40. import Radio from '../../../components/controls/Radio';
  41. import RadioToggle from '../../../components/controls/RadioToggle';
  42. import ReloadButton from '../../../components/controls/ReloadButton';
  43. import SearchBox from '../../../components/controls/SearchBox';
  44. import SearchSelect from '../../../components/controls/SearchSelect';
  45. import SelectLegacy from '../../../components/controls/SelectLegacy';
  46. import SelectList, { SelectListFilter } from '../../../components/controls/SelectList';
  47. import SimpleModal from '../../../components/controls/SimpleModal';
  48. import Tooltip from '../../../components/controls/Tooltip';
  49. import AlertErrorIcon from '../../../components/icons/AlertErrorIcon';
  50. import AlertSuccessIcon from '../../../components/icons/AlertSuccessIcon';
  51. import AlertWarnIcon from '../../../components/icons/AlertWarnIcon';
  52. import BranchIcon from '../../../components/icons/BranchIcon';
  53. import BranchLikeIcon from '../../../components/icons/BranchLikeIcon';
  54. import BulletListIcon from '../../../components/icons/BulletListIcon';
  55. import CheckIcon from '../../../components/icons/CheckIcon';
  56. import ClearIcon from '../../../components/icons/ClearIcon';
  57. import DetachIcon from '../../../components/icons/DetachIcon';
  58. import DropdownIcon from '../../../components/icons/DropdownIcon';
  59. import HelpIcon from '../../../components/icons/HelpIcon';
  60. import HistoryIcon from '../../../components/icons/HistoryIcon';
  61. import LockIcon from '../../../components/icons/LockIcon';
  62. import MeasuresIcon from '../../../components/icons/MeasuresIcon';
  63. import PlusCircleIcon from '../../../components/icons/PlusCircleIcon';
  64. import PullRequestIcon from '../../../components/icons/PullRequestIcon';
  65. import QualifierIcon from '../../../components/icons/QualifierIcon';
  66. import SecurityHotspotIcon from '../../../components/icons/SecurityHotspotIcon';
  67. import VulnerabilityIcon from '../../../components/icons/VulnerabilityIcon';
  68. import WarningIcon from '../../../components/icons/WarningIcon';
  69. import DateFormatter from '../../../components/intl/DateFormatter';
  70. import DateFromNow from '../../../components/intl/DateFromNow';
  71. import DateTimeFormatter from '../../../components/intl/DateTimeFormatter';
  72. import Measure from '../../../components/measure/Measure';
  73. import RatingTooltipContent from '../../../components/measure/RatingTooltipContent';
  74. import { Alert } from '../../../components/ui/Alert';
  75. import CoverageRating from '../../../components/ui/CoverageRating';
  76. import DeferredSpinner from '../../../components/ui/DeferredSpinner';
  77. import DuplicationsRating from '../../../components/ui/DuplicationsRating';
  78. import Level from '../../../components/ui/Level';
  79. import MandatoryFieldMarker from '../../../components/ui/MandatoryFieldMarker';
  80. import MandatoryFieldsExplanation from '../../../components/ui/MandatoryFieldsExplanation';
  81. import Rating from '../../../components/ui/Rating';
  82. import {
  83. getBranchLikeQuery,
  84. isBranch,
  85. isMainBranch,
  86. isPullRequest,
  87. sortBranches
  88. } from '../../../helpers/branch-like';
  89. import handleRequiredAuthentication from '../../../helpers/handleRequiredAuthentication';
  90. import { translate, translateWithParameters } from '../../../helpers/l10n';
  91. import * as measures from '../../../helpers/measures';
  92. import {
  93. get,
  94. getJSON,
  95. getText,
  96. omitNil,
  97. parseError,
  98. post,
  99. postJSON,
  100. postJSONBody,
  101. request
  102. } from '../../../helpers/request';
  103. import { sanitizeStringRestricted } from '../../../helpers/sanitize';
  104. import {
  105. getStandards,
  106. renderCWECategory,
  107. renderOwaspTop10Category,
  108. renderSansTop25Category,
  109. renderSonarSourceSecurityCategory
  110. } from '../../../helpers/security-standard';
  111. import {
  112. getCodeUrl,
  113. getComponentDrilldownUrl,
  114. getComponentIssuesUrl,
  115. getComponentSecurityHotspotsUrl,
  116. getMeasureHistoryUrl,
  117. getRulesUrl
  118. } from '../../../helpers/urls';
  119. import addGlobalSuccessMessage from '../../utils/addGlobalSuccessMessage';
  120. import throwGlobalError from '../../utils/throwGlobalError';
  121. import A11ySkipTarget from '../a11y/A11ySkipTarget';
  122. import Suggestions from '../embed-docs-modal/Suggestions';
  123. const exposeLibraries = () => {
  124. const global = window as any;
  125. global.SonarRequest = {
  126. request,
  127. get,
  128. getJSON,
  129. getText,
  130. omitNil,
  131. parseError,
  132. post,
  133. postJSON,
  134. postJSONBody,
  135. throwGlobalError,
  136. addGlobalSuccessMessage
  137. };
  138. global.t = translate;
  139. global.tp = translateWithParameters;
  140. /**
  141. * @deprecated since SonarQube 8.7
  142. */
  143. Object.defineProperty(global, 'SonarHelpers', {
  144. get: () => {
  145. // eslint-disable-next-line no-console
  146. console.warn('SonarHelpers usages are deprecated since SonarQube 8.7');
  147. return {
  148. getBranchLikeQuery,
  149. handleRequiredAuthentication,
  150. isBranch,
  151. isMainBranch,
  152. isPullRequest,
  153. sortBranches,
  154. getStandards,
  155. renderCWECategory,
  156. renderOwaspTop10Category,
  157. renderSansTop25Category,
  158. renderSonarSourceSecurityCategory,
  159. getCodeUrl,
  160. getComponentDrilldownUrl,
  161. getComponentIssuesUrl,
  162. getComponentSecurityHotspotsUrl,
  163. getMeasureHistoryUrl,
  164. getRulesUrl,
  165. sanitizeStringRestricted
  166. };
  167. }
  168. });
  169. /**
  170. * @deprecated since SonarQube 8.7
  171. */
  172. Object.defineProperty(global, 'SonarMeasures', {
  173. get: () => {
  174. // eslint-disable-next-line no-console
  175. console.warn('SonarMeasures usages are deprecated since SonarQube 8.7');
  176. return { ...measures };
  177. }
  178. });
  179. /**
  180. * @deprecated since SonarQube 8.7
  181. */
  182. Object.defineProperty(global, 'SonarComponents', {
  183. get: () => {
  184. // eslint-disable-next-line no-console
  185. console.warn('SonarComponents usages are deprecated since SonarQube 8.7');
  186. return {
  187. A11ySkipTarget,
  188. ActionsDropdown,
  189. ActionsDropdownItem,
  190. Alert,
  191. AlertErrorIcon,
  192. AlertSuccessIcon,
  193. AlertWarnIcon,
  194. BranchIcon: BranchLikeIcon,
  195. BoxedTabs,
  196. BulletListIcon,
  197. Button,
  198. Checkbox,
  199. CheckIcon,
  200. ClearIcon,
  201. ClickEventBoundary,
  202. ConfirmButton,
  203. CoverageRating,
  204. DateFormatter,
  205. DateFromNow,
  206. DateTimeFormatter,
  207. DeferredSpinner,
  208. DetachIcon,
  209. DonutChart,
  210. Dropdown,
  211. DropdownIcon,
  212. DuplicationsRating,
  213. EditButton,
  214. Favorite,
  215. FormattedMessage,
  216. HelpIcon,
  217. HelpTooltip,
  218. HistoryIcon,
  219. HomePageSelect,
  220. Level,
  221. ListFooter,
  222. LockIcon,
  223. LongLivingBranchIcon: BranchIcon,
  224. MandatoryFieldMarker,
  225. MandatoryFieldsExplanation,
  226. Measure,
  227. MeasuresIcon,
  228. Modal,
  229. NotFound,
  230. PlusCircleIcon,
  231. PullRequestIcon,
  232. QualifierIcon,
  233. Radio,
  234. RadioToggle,
  235. Rating,
  236. RatingTooltipContent,
  237. ReloadButton,
  238. ResetButtonLink,
  239. SearchBox,
  240. SearchSelect,
  241. SecurityHotspotIcon,
  242. SelectLegacy,
  243. SelectList,
  244. SelectListFilter,
  245. SimpleModal,
  246. SubmitButton,
  247. Suggestions,
  248. Tooltip,
  249. VulnerabilityIcon,
  250. WarningIcon
  251. };
  252. }
  253. });
  254. };
  255. export default exposeLibraries;