Просмотр исходного кода

api: show all project keys by default

David Cramer 7 лет назад
Родитель
Сommit
23c359ef11
3 измененных файлов с 44 добавлено и 18 удалено
  1. 6 0
      CHANGES
  2. 20 4
      src/sentry/api/endpoints/project_keys.py
  3. 18 14
      src/sentry/static/sentry/app/views/projectKeys.jsx

+ 6 - 0
CHANGES

@@ -18,6 +18,12 @@ Schema Changes
 - Removed DSymSymbol
 - Removed DSymSymbol
 - Removed GlobalDSymFile
 - Removed GlobalDSymFile
 
 
+API Changes
+~~~~~~~~~~~
+
+- Project keys endpoint will include all available keys by default. Use
+  ``status=active`` to retain the old behavior.
+
 Version 8.17
 Version 8.17
 ------------
 ------------
 
 

+ 20 - 4
src/sentry/api/endpoints/project_keys.py

@@ -53,12 +53,28 @@ class ProjectKeysEndpoint(ProjectEndpoint):
         :pparam string project_slug: the slug of the project the client keys
         :pparam string project_slug: the slug of the project the client keys
                                      belong to.
                                      belong to.
         """
         """
-        keys = list(ProjectKey.objects.filter(
+        queryset = ProjectKey.objects.filter(
             project=project,
             project=project,
-            status=ProjectKeyStatus.ACTIVE,
             roles=ProjectKey.roles.store,
             roles=ProjectKey.roles.store,
-        ))
-        return Response(serialize(keys, request.user))
+        )
+        status = request.GET.get('status')
+        if status == 'active':
+            queryset = queryset.filter(
+                status=ProjectKeyStatus.ACTIVE,
+            )
+        elif status == 'inactive':
+            queryset = queryset.filter(
+                status=ProjectKeyStatus.INACTIVE,
+            )
+        elif status:
+            queryset = queryset.none()
+
+        return self.paginate(
+            request=request,
+            queryset=queryset,
+            order_by='-id',
+            on_results=lambda x: serialize(x, request.user),
+        )
 
 
     @attach_scenarios([create_key_scenario])
     @attach_scenarios([create_key_scenario])
     def post(self, request, project):
     def post(self, request, project):

+ 18 - 14
src/sentry/static/sentry/app/views/projectKeys.jsx

@@ -10,6 +10,7 @@ import LoadingError from '../components/loadingError';
 import LoadingIndicator from '../components/loadingIndicator';
 import LoadingIndicator from '../components/loadingIndicator';
 import {t, tct} from '../locale';
 import {t, tct} from '../locale';
 import OrganizationState from '../mixins/organizationState';
 import OrganizationState from '../mixins/organizationState';
+import Pagination from '../components/pagination';
 
 
 const KeyRow = React.createClass({
 const KeyRow = React.createClass({
   propTypes: {
   propTypes: {
@@ -288,20 +289,23 @@ export default React.createClass({
     let {orgId, projectId} = this.props.params;
     let {orgId, projectId} = this.props.params;
     let access = this.getAccess();
     let access = this.getAccess();
     return (
     return (
-      <div className="client-key-list">
-        {this.state.keyList.map(key => {
-          return (
-            <KeyRow
-              access={access}
-              key={key.id}
-              orgId={orgId}
-              projectId={projectId}
-              data={key}
-              onToggle={this.handleToggleKey.bind(this, key)}
-              onRemove={this.handleRemoveKey.bind(this, key)}
-            />
-          );
-        })}
+      <div>
+        <div className="client-key-list">
+          {this.state.keyList.map(key => {
+            return (
+              <KeyRow
+                access={access}
+                key={key.id}
+                orgId={orgId}
+                projectId={projectId}
+                data={key}
+                onToggle={this.handleToggleKey.bind(this, key)}
+                onRemove={this.handleRemoveKey.bind(this, key)}
+              />
+            );
+          })}
+        </div>
+        <Pagination pageLinks={this.state.pageLinks} />
       </div>
       </div>
     );
     );
   },
   },