pluginIcon.tsx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import styled from '@emotion/styled';
  2. import amixr from 'sentry-logos/logo-amixr.svg';
  3. import asana from 'sentry-logos/logo-asana.svg';
  4. import asayer from 'sentry-logos/logo-asayer.svg';
  5. import aws from 'sentry-logos/logo-aws.svg';
  6. import vsts from 'sentry-logos/logo-azure.svg';
  7. import bitbucket from 'sentry-logos/logo-bitbucket.svg';
  8. import bitbucketserver from 'sentry-logos/logo-bitbucket-server.svg';
  9. import calixa from 'sentry-logos/logo-calixa.svg';
  10. import campfire from 'sentry-logos/logo-campfire.svg';
  11. import clickup from 'sentry-logos/logo-clickup.svg';
  12. import clubhouse from 'sentry-logos/logo-clubhouse.svg';
  13. import datadog from 'sentry-logos/logo-datadog.svg';
  14. import placeholder from 'sentry-logos/logo-default.svg';
  15. import flowdock from 'sentry-logos/logo-flowdock.svg';
  16. import fullstory from 'sentry-logos/logo-fullstory.svg';
  17. import github from 'sentry-logos/logo-github.svg';
  18. import githubActions from 'sentry-logos/logo-github-actions.svg';
  19. import githubEnterprise from 'sentry-logos/logo-github-enterprise.svg';
  20. import gitlab from 'sentry-logos/logo-gitlab.svg';
  21. import grafana from 'sentry-logos/logo-grafana.svg';
  22. import heroku from 'sentry-logos/logo-heroku.svg';
  23. import insightfinder from 'sentry-logos/logo-insight-finder.svg';
  24. import jira from 'sentry-logos/logo-jira.svg';
  25. import jiraserver from 'sentry-logos/logo-jira-server.svg';
  26. import komodor from 'sentry-logos/logo-komodor.svg';
  27. import lighthouse from 'sentry-logos/logo-lighthouse.svg';
  28. import linear from 'sentry-logos/logo-linear.svg';
  29. import msteams from 'sentry-logos/logo-msteams.svg';
  30. import netlify from 'sentry-logos/logo-netlify.svg';
  31. import octohook from 'sentry-logos/logo-octohook.svg';
  32. import opsgenie from 'sentry-logos/logo-opsgenie.svg';
  33. import pagerduty from 'sentry-logos/logo-pagerduty.svg';
  34. import phabricator from 'sentry-logos/logo-phabricator.svg';
  35. import pivotal from 'sentry-logos/logo-pivotaltracker.svg';
  36. import pushover from 'sentry-logos/logo-pushover.svg';
  37. import quill from 'sentry-logos/logo-quill.svg';
  38. import redmine from 'sentry-logos/logo-redmine.svg';
  39. import rocketchat from 'sentry-logos/logo-rocketchat.svg';
  40. import rookout from 'sentry-logos/logo-rookout.svg';
  41. import segment from 'sentry-logos/logo-segment.svg';
  42. import sentry from 'sentry-logos/logo-sentry.svg';
  43. import slack from 'sentry-logos/logo-slack.svg';
  44. import spikesh from 'sentry-logos/logo-spikesh.svg';
  45. import split from 'sentry-logos/logo-split.svg';
  46. import taiga from 'sentry-logos/logo-taiga.svg';
  47. import taskcall from 'sentry-logos/logo-taskcall.svg';
  48. import teamwork from 'sentry-logos/logo-teamwork.svg';
  49. import trello from 'sentry-logos/logo-trello.svg';
  50. import twilio from 'sentry-logos/logo-twilio.svg';
  51. import vercel from 'sentry-logos/logo-vercel.svg';
  52. import victorops from 'sentry-logos/logo-victorops.svg';
  53. import visualstudio from 'sentry-logos/logo-visualstudio.svg';
  54. import youtrack from 'sentry-logos/logo-youtrack.svg';
  55. import zulip from 'sentry-logos/logo-zulip.svg';
  56. import Feature from 'sentry/components/acl/feature';
  57. import Avatar from 'sentry/components/avatar';
  58. import {SentryApp} from 'sentry/types';
  59. // Map of plugin id -> logo filename
  60. export const DEFAULT_ICON = placeholder;
  61. export const ICON_PATHS = {
  62. _default: DEFAULT_ICON,
  63. sentry,
  64. browsers: sentry,
  65. device: sentry,
  66. interface_types: sentry,
  67. os: sentry,
  68. urls: sentry,
  69. webhooks: sentry,
  70. 'amazon-sqs': aws,
  71. aws_lambda: aws,
  72. amixr,
  73. asana,
  74. asayer,
  75. bitbucket,
  76. bitbucket_pipelines: bitbucket,
  77. bitbucket_server: bitbucketserver,
  78. calixa,
  79. campfire,
  80. clickup,
  81. clubhouse,
  82. datadog,
  83. flowdock,
  84. fullstory,
  85. github,
  86. github_actions: githubActions,
  87. github_enterprise: githubEnterprise,
  88. gitlab,
  89. grafana,
  90. heroku,
  91. insight_finder: insightfinder,
  92. jira,
  93. jira_server: jiraserver,
  94. komodor,
  95. lighthouse,
  96. linear,
  97. msteams,
  98. netlify,
  99. octohook,
  100. opsgenie,
  101. pagerduty,
  102. phabricator,
  103. pivotal,
  104. pushover,
  105. quill,
  106. redmine,
  107. rocketchat,
  108. rookout,
  109. segment,
  110. shortcut: clubhouse,
  111. slack,
  112. spikesh,
  113. split,
  114. taiga,
  115. taskcall,
  116. teamwork,
  117. trello,
  118. twilio,
  119. visualstudio,
  120. vsts,
  121. youtrack,
  122. vercel,
  123. victorops,
  124. zulip,
  125. };
  126. type Props = {
  127. pluginId?: string;
  128. size?: number;
  129. isColor?: boolean;
  130. sentryApp?: SentryApp;
  131. className?: string;
  132. };
  133. // The following component uses hardcoded frontend resources
  134. const FallbackPluginIcon = styled('div')<Props>`
  135. position: relative;
  136. height: ${p => p.size}px;
  137. width: ${p => p.size}px;
  138. border-radius: 2px;
  139. border: 0;
  140. display: inline-block;
  141. background-size: contain;
  142. background-position: center center;
  143. background-repeat: no-repeat;
  144. background-image: url(${({pluginId}) =>
  145. (pluginId !== undefined && ICON_PATHS[pluginId]) || DEFAULT_ICON});
  146. `;
  147. const PluginIcon = ({pluginId, size, sentryApp, isColor, className}: Props) => (
  148. <Feature features={['organizations:sentry-app-logo-upload']}>
  149. {({hasFeature}) => {
  150. if (hasFeature && sentryApp) {
  151. return (
  152. <Avatar
  153. size={size}
  154. sentryApp={sentryApp}
  155. isColor={isColor}
  156. className={className}
  157. />
  158. );
  159. }
  160. return <FallbackPluginIcon pluginId={pluginId} size={size} className={className} />;
  161. }}
  162. </Feature>
  163. );
  164. PluginIcon.defaultProps = {
  165. pluginId: '_default',
  166. size: 20,
  167. isColor: true,
  168. };
  169. export default PluginIcon;