Browse Source

feat(saved-search) Hide project saved-searches when org feature is on (#12508)

Hide saved searches in the project settings pages and display a 404 on
direct access when the org-saved-searches feature is enabled.

I've moved project saved searches to a code split as it will be removed
in the near future and we can byte-shave the main bundle now.

Fixes SEN-362
Mark Story 6 years ago
parent
commit
fe146efc29

+ 1 - 0
src/sentry/api/endpoints/project_details.py

@@ -88,6 +88,7 @@ class ProjectAdminSerializer(ProjectMemberSerializer):
     securityToken = serializers.RegexField(r'^[-a-zA-Z0-9+/=\s]+$', max_length=255)
     securityTokenHeader = serializers.RegexField(r'^[a-zA-Z0-9_\-]+$', max_length=20)
     verifySSL = serializers.BooleanField(required=False)
+
     defaultEnvironment = serializers.CharField(required=False, allow_none=True)
     dataScrubber = serializers.BooleanField(required=False)
     dataScrubberDefaults = serializers.BooleanField(required=False)

+ 2 - 1
src/sentry/runner/commands/devservices.py

@@ -143,7 +143,8 @@ def up(project, exclude):
         listening = ''
         if options['ports']:
             listening = ' (listening: %s)' % ', '.join(map(text_type, options['ports'].values()))
-        click.secho("> Creating '%s' container%s" % (options['name'], listening), err=True, fg='yellow')
+        click.secho("> Creating '%s' container%s" %
+                    (options['name'], listening), err=True, fg='yellow')
         client.containers.run(**options)
 
 

+ 1 - 0
src/sentry/static/sentry/app/components/search/sources/routeSource.jsx

@@ -77,6 +77,7 @@ class RouteSource extends React.Component {
         mapFunc(accountSettingsNavigation),
         mapFunc(projectSettingsNavigation, {
           project: project || {},
+          organization: organization || {},
           access: new Set((organization && organization.access) || []),
           features: new Set((project && project.features) || []),
         }),

+ 3 - 2
src/sentry/static/sentry/app/routes.jsx

@@ -43,7 +43,6 @@ import ProjectInstallOverview from 'app/views/projectInstall/overview';
 import ProjectInstallPlatform from 'app/views/projectInstall/platform';
 import ProjectPluginDetails from 'app/views/projectPluginDetails';
 import ProjectPlugins from 'app/views/projectPlugins';
-import ProjectSavedSearches from 'app/views/projectSavedSearches';
 import ProjectSettings from 'app/views/projectSettings';
 import ProjectTags from 'app/views/projectTags';
 import RouteNotFound from 'app/views/routeNotFound';
@@ -287,7 +286,9 @@ function routes() {
       <Route
         path="saved-searches/"
         name="Saved Searches"
-        component={errorHandler(ProjectSavedSearches)}
+        componentPromise={() =>
+          import(/* webpackChunkName: "ProjectSavedSearches" */ './views/projectSavedSearches')}
+        component={errorHandler(LazyLoad)}
       />
       <Route
         path="debug-symbols/"

+ 15 - 1
src/sentry/static/sentry/app/views/projectSavedSearches.jsx

@@ -10,6 +10,7 @@ import Button from 'app/components/button';
 import Confirm from 'app/components/confirm';
 import EmptyStateWarning from 'app/components/emptyStateWarning';
 import IndicatorStore from 'app/stores/indicatorStore';
+import NotFound from 'app/components/errors/notFound';
 import SentryTypes from 'app/sentryTypes';
 import SettingsPageHeader from 'app/views/settings/components/settingsPageHeader';
 
@@ -101,6 +102,7 @@ class ProjectSavedSearches extends AsyncView {
   getTitle() {
     return t('Saved Searches');
   }
+
   static contextTypes = {
     organization: SentryTypes.Organization,
   };
@@ -238,5 +240,17 @@ class ProjectSavedSearches extends AsyncView {
   }
 }
 
-export default ProjectSavedSearches;
+const ProjectSavedSearchContainer = function(props, context) {
+  const hasSavedSearch = context.organization.features.includes('org-saved-searches');
+  if (hasSavedSearch) {
+    return <NotFound />;
+  }
+  return <ProjectSavedSearches {...props} />;
+};
+
+ProjectSavedSearchContainer.contextTypes = {
+  organization: SentryTypes.Organization,
+};
+
+export default ProjectSavedSearchContainer;
 export {SavedSearchRow};

+ 6 - 3
src/sentry/static/sentry/app/views/projectSettings/index.jsx

@@ -93,6 +93,7 @@ const ProjectSettings = createReactClass({
     const rootInstallPath = `${pathPrefix}/install/`;
     const path = this.props.location.pathname;
     const processingIssues = this.state.project.processingIssues;
+    const organization = this.context.organization;
 
     return (
       <div className="row">
@@ -126,9 +127,11 @@ const ProjectSettings = createReactClass({
             <ListLink to={`${pathPrefix}/data-forwarding/`}>
               {t('Data Forwarding')}
             </ListLink>
-            <ListLink to={`${pathPrefix}/saved-searches/`}>
-              {t('Saved Searches')}
-            </ListLink>
+            {organization.features.includes('org-saved-searches') === false && (
+              <ListLink to={`${pathPrefix}/saved-searches/`}>
+                {t('Saved Searches')}
+              </ListLink>
+            )}
             <ListLink to={`${pathPrefix}/debug-symbols/`}>
               {t('Debug Information Files')}
             </ListLink>

+ 6 - 1
src/sentry/static/sentry/app/views/settings/project/navigationConfiguration.jsx

@@ -4,7 +4,6 @@ const pathPrefix = '/settings/:orgId/projects/:projectId';
 
 export default function getConfiguration({project}) {
   const plugins = ((project && project.plugins) || []).filter(plugin => plugin.enabled);
-
   return [
     {
       name: t('Project'),
@@ -48,6 +47,12 @@ export default function getConfiguration({project}) {
           path: `${pathPrefix}/saved-searches/`,
           title: t('Saved Searches'),
           description: t('Manage saved searches for a project and your account'),
+          show: ({organization}) => {
+            if (!organization || !organization.features) {
+              return true;
+            }
+            return !organization.features.includes('org-saved-searches');
+          },
         },
         {
           path: `${pathPrefix}/debug-symbols/`,

+ 1 - 1
src/sentry/static/sentry/app/views/settings/project/projectSettingsNavigation.jsx

@@ -32,7 +32,7 @@ const ProjectSettingsNavigation = createReactClass({
 
     return (
       <SettingsNavigation
-        navigationObjects={getConfiguration({project})}
+        navigationObjects={getConfiguration({project, organization: org})}
         access={access}
         features={features}
         organization={org}

+ 1 - 0
src/sentry/testutils/cases.py

@@ -763,6 +763,7 @@ class PluginTestCase(TestCase):
 class CliTestCase(TestCase):
     runner = fixture(CliRunner)
     command = None
+
     default_args = []
 
     def invoke(self, *args):

File diff suppressed because it is too large
+ 543 - 559
tests/js/spec/views/__snapshots__/projectSavedSearches.spec.jsx.snap


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