Browse Source

feat(plugins) Hide plugins that also have integrations (#11031)

By hiding legacy plugins in the UI we make it a bit harder for customers
to enable plugins we don't want them to use. This should help guide them
towards the organization integrations which we plan on supporting more.

Fixes APP-890
Mark Story 6 years ago
parent
commit
604228cc6b

+ 2 - 0
src/sentry/api/serializers/models/plugin.py

@@ -62,6 +62,8 @@ class PluginSerializer(Serializer):
                 'url': six.text_type(obj.author_url)
             }
 
+        d['isHidden'] = d.get('enabled', False) is False and obj.is_hidden()
+
         if obj.description:
             d['description'] = six.text_type(obj.description)
 

+ 8 - 0
src/sentry/plugins/__init__.py

@@ -7,6 +7,14 @@ sentry.plugins
 """
 from __future__ import absolute_import
 
+HIDDEN_PLUGINS = (
+    'bitbucket',
+    'gitlab',
+    'github',
+    'slack',
+    'vsts'
+)
+
 from sentry.plugins.base import *  # NOQA
 from sentry.plugins.bases import *  # NOQA
 from sentry.plugins.interfaces import *  # NOQA

+ 9 - 0
src/sentry/plugins/base/v1.py

@@ -17,6 +17,7 @@ from django.http import HttpResponseRedirect
 from threading import local
 
 from sentry.auth import access
+from sentry.plugins import HIDDEN_PLUGINS
 from sentry.plugins.config import PluginConfigMixin
 from sentry.plugins.status import PluginStatusMixin
 from sentry.plugins.base.response import Response
@@ -488,6 +489,14 @@ class IPlugin(local, PluggableViewMixin, PluginConfigMixin, PluginStatusMixin):
         """
         return hasattr(self, 'test_configuration')
 
+    def is_hidden(self):
+        """
+        Should this plugin be hidden in the UI
+
+        We use this to hide plugins as they are replaced with integrations.
+        """
+        return self.slug in HIDDEN_PLUGINS
+
     def configure(self, request, project=None):
         """Configures the plugin."""
         return default_plugin_config(self, project, request)

+ 9 - 0
src/sentry/plugins/base/v2.py

@@ -15,6 +15,7 @@ import six
 from django.http import HttpResponseRedirect
 from threading import local
 
+from sentry.plugins import HIDDEN_PLUGINS
 from sentry.plugins.config import PluginConfigMixin
 from sentry.plugins.status import PluginStatusMixin
 from sentry.plugins.base.response import Response
@@ -108,6 +109,14 @@ class IPlugin2(local, PluginConfigMixin, PluginStatusMixin):
 
         return True
 
+    def is_hidden(self):
+        """
+        Should this plugin be hidden in the UI
+
+        We use this to hide plugins as they are replaced with integrations.
+        """
+        return self.slug in HIDDEN_PLUGINS
+
     def reset_options(self, project=None, user=None):
         from sentry.plugins.helpers import reset_options
         return reset_options(self.get_conf_key(), project, user)

+ 1 - 1
src/sentry/static/sentry/app/components/pluginList.jsx

@@ -72,7 +72,7 @@ export default class PluginList extends React.Component {
         })}
 
         <InactivePlugins
-          plugins={pluginList.filter(p => !p.enabled)}
+          plugins={pluginList.filter(p => !p.enabled && !p.isHidden)}
           onEnablePlugin={this.handleEnablePlugin}
         />
       </div>

+ 1 - 1
src/sentry/static/sentry/app/views/projectPlugins/projectPlugins.jsx

@@ -64,7 +64,7 @@ class ProjectPlugins extends Component {
             </Access>
           </PanelAlert>
 
-          {plugins.map(plugin => (
+          {plugins.filter(p => !p.isHidden).map(plugin => (
             <PanelItem key={plugin.id}>
               <ProjectPluginRow
                 params={params}

+ 1 - 0
tests/js/fixtures/plugin.js

@@ -2,6 +2,7 @@ export function Plugin(params = {}) {
   return {
     author: {url: 'https://github.com/getsentry/sentry', name: 'Sentry Team'},
     enabled: false,
+    isHidden: false,
     id: 'amazon-sqs',
     name: 'Amazon SQS',
     slug: 'amazon-sqs',

+ 7 - 0
tests/js/fixtures/plugins.js

@@ -11,6 +11,13 @@ export function Plugins(params = []) {
       canDisable: false,
       hasConfiguration: false,
     }),
+    Plugin({
+      enabled: false,
+      isHidden: true,
+      name: 'Hidden Plugin',
+      slug: 'hidden-plugin',
+      id: 'hidden-plugin',
+    }),
     ...params,
   ];
 }

+ 27 - 0
tests/js/spec/components/__snapshots__/inactivePlugins.spec.jsx.snap

@@ -71,6 +71,33 @@ exports[`InactivePlugins renders plugins list 1`] = `
           </Flex>
         </IntegrationButton>
       </Box>
+      <Box
+        key="hidden-plugin"
+        m={1}
+      >
+        <IntegrationButton
+          className="ref-plugin-enable-hidden-plugin"
+          onClick={[Function]}
+        >
+          <Flex
+            align="center"
+            justify="center"
+          >
+            <Flex
+              align="center"
+              mr={1}
+            >
+              <PluginIcon
+                pluginId="hidden-plugin"
+                size={20}
+              />
+            </Flex>
+            <TextOverflow>
+              Hidden Plugin
+            </TextOverflow>
+          </Flex>
+        </IntegrationButton>
+      </Box>
     </Flex>
   </PanelBody>
 </Panel>

+ 2 - 0
tests/js/spec/views/__snapshots__/projectPluginDetails.spec.jsx.snap

@@ -319,6 +319,7 @@ exports[`ProjectPluginDetails renders 1`] = `
                     "enabled": false,
                     "hasConfiguration": true,
                     "id": "amazon-sqs",
+                    "isHidden": false,
                     "name": "Amazon SQS",
                     "slug": "amazon-sqs",
                     "version": "8.23.0.dev0",
@@ -521,6 +522,7 @@ exports[`ProjectPluginDetails renders 1`] = `
                                     "enabled": false,
                                     "hasConfiguration": true,
                                     "id": "amazon-sqs",
+                                    "isHidden": false,
                                     "name": "Amazon SQS",
                                     "slug": "amazon-sqs",
                                     "version": "8.23.0.dev0",

Some files were not shown because too many files changed in this diff