inactivePlugins.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import styled from '@emotion/styled';
  2. import {Panel, PanelBody, PanelHeader} from 'sentry/components/panels';
  3. import TextOverflow from 'sentry/components/textOverflow';
  4. import {t} from 'sentry/locale';
  5. import PluginIcon from 'sentry/plugins/components/pluginIcon';
  6. import space from 'sentry/styles/space';
  7. import {Plugin} from 'sentry/types';
  8. type Props = {
  9. onEnablePlugin: (plugin: Plugin) => void;
  10. plugins: Plugin[];
  11. };
  12. const InactivePlugins = ({plugins, onEnablePlugin}: Props) => {
  13. if (plugins.length === 0) {
  14. return null;
  15. }
  16. return (
  17. <Panel>
  18. <PanelHeader>{t('Inactive Integrations')}</PanelHeader>
  19. <PanelBody>
  20. <Plugins>
  21. {plugins.map(plugin => (
  22. <IntegrationButton
  23. key={plugin.id}
  24. onClick={() => onEnablePlugin(plugin)}
  25. className={`ref-plugin-enable-${plugin.id}`}
  26. >
  27. <Label>
  28. <StyledPluginIcon pluginId={plugin.id} />
  29. <TextOverflow>{plugin.shortName || plugin.name}</TextOverflow>
  30. </Label>
  31. </IntegrationButton>
  32. ))}
  33. </Plugins>
  34. </PanelBody>
  35. </Panel>
  36. );
  37. };
  38. const Plugins = styled('div')`
  39. display: flex;
  40. padding: ${space(1)};
  41. flex: 1;
  42. flex-wrap: wrap;
  43. `;
  44. const IntegrationButton = styled('button')`
  45. margin: ${space(1)};
  46. width: 175px;
  47. text-align: center;
  48. font-size: ${p => p.theme.fontSizeSmall};
  49. color: #889ab0;
  50. letter-spacing: 0.1px;
  51. font-weight: 600;
  52. text-transform: uppercase;
  53. border: 1px solid #eee;
  54. background: inherit;
  55. border-radius: ${p => p.theme.borderRadius};
  56. padding: 10px;
  57. &:hover {
  58. border-color: #ccc;
  59. }
  60. `;
  61. const Label = styled('div')`
  62. display: flex;
  63. align-items: center;
  64. justify-content: center;
  65. `;
  66. const StyledPluginIcon = styled(PluginIcon)`
  67. margin-right: ${space(1)};
  68. `;
  69. export default InactivePlugins;