inactivePlugins.tsx 1.9 KB

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