Browse Source

cleanup(settings): remove unused ApiNewToken file (#15085)

Stephen Cefali 5 years ago
parent
commit
b9e27ad022

+ 0 - 66
src/sentry/static/sentry/app/views/apiNewToken.jsx

@@ -1,66 +0,0 @@
-import React from 'react';
-import {browserHistory} from 'react-router';
-
-import AsyncView from 'app/views/asyncView';
-import {API_SCOPES, DEFAULT_API_SCOPES} from 'app/constants';
-import NarrowLayout from 'app/components/narrowLayout';
-import {ApiForm, MultipleCheckboxField} from 'app/components/forms';
-import {t, tct} from 'app/locale';
-
-const SORTED_DEFAULT_API_SCOPES = DEFAULT_API_SCOPES.sort();
-const API_CHOICES = API_SCOPES.map(s => [s, s]);
-
-export default class ApiNewToken extends AsyncView {
-  getEndpoints() {
-    return [];
-  }
-
-  getTitle() {
-    return 'Create API Token';
-  }
-
-  onCancel() {
-    browserHistory.push('/api/');
-  }
-
-  onSubmitSuccess() {
-    browserHistory.push('/api/');
-  }
-
-  renderBody() {
-    return (
-      <NarrowLayout>
-        <h3>{t('Create New Token')}</h3>
-        <hr />
-        <p>
-          {t(
-            "Authentication tokens allow you to perform actions against the Sentry API on behalf of your account. They're the easiest way to get started using the API."
-          )}
-        </p>
-        <p>
-          {tct(
-            'For more information on how to use the web API, see our [link:documentation].',
-            {
-              link: <a href="https://docs.sentry.io/hosted/api/" />,
-            }
-          )}
-        </p>
-        <ApiForm
-          apiMethod="POST"
-          apiEndpoint="/api-tokens/"
-          className="form-stacked api-new-token"
-          initialData={{scopes: SORTED_DEFAULT_API_SCOPES}}
-          onSubmitSuccess={this.onSubmitSuccess}
-          onCancel={this.onCancel}
-        >
-          <MultipleCheckboxField
-            name="scopes"
-            choices={API_CHOICES}
-            label={t('Scopes')}
-            required
-          />
-        </ApiForm>
-      </NarrowLayout>
-    );
-  }
-}

+ 112 - 102
tests/js/spec/views/__snapshots__/apiNewToken.spec.jsx.snap

@@ -4,15 +4,15 @@ exports[`ApiNewToken render() renders 1`] = `
 <SideEffect(DocumentTitle)
   title="Create API Token - Sentry"
 >
-  <NarrowLayout>
-    <h3>
-      Create New Token
-    </h3>
-    <hr />
-    <p>
+  <div>
+    <StyledSettingsPageHeading
+      noTitleStyles={false}
+      title="Create New Token"
+    />
+    <TextBlock>
       Authentication tokens allow you to perform actions against the Sentry API on behalf of your account. They're the easiest way to get started using the API.
-    </p>
-    <p>
+    </TextBlock>
+    <TextBlock>
       <span
         key="5"
       >
@@ -37,105 +37,115 @@ exports[`ApiNewToken render() renders 1`] = `
           .
         </span>
       </span>
-    </p>
-    <ApiForm
-      apiEndpoint="/api-tokens/"
-      apiMethod="POST"
-      cancelLabel="Cancel"
-      className="form-stacked api-new-token"
-      errorMessage="Unable to save your changes. Please ensure all fields are valid and try again."
-      footerClass="form-actions align-right"
-      hideErrors={false}
-      initialData={
-        Object {
-          "scopes": Array [
-            "event:admin",
-            "event:read",
-            "member:read",
-            "org:read",
-            "project:read",
-            "project:releases",
-            "team:read",
-          ],
+    </TextBlock>
+    <Panel>
+      <PanelHeader>
+        Create New Token
+      </PanelHeader>
+      <ApiForm
+        apiEndpoint="/api-tokens/"
+        apiMethod="POST"
+        footerStyle={
+          Object {
+            "marginTop": 0,
+            "paddingRight": 20,
+          }
         }
-      }
-      onCancel={[Function]}
-      onSubmitSuccess={[Function]}
-      requireChanges={false}
-      resetOnError={false}
-      submitDisabled={false}
-      submitErrorMessage="There was an error saving your changes."
-      submitLabel="Save Changes"
-      submitLoadingMessage="Saving changes.."
-    >
-      <MultipleCheckboxField
-        choices={
-          Array [
-            Array [
-              "project:read",
+        initialData={
+          Object {
+            "scopes": Array [
+              "event:admin",
+              "event:read",
+              "member:read",
+              "org:read",
               "project:read",
-            ],
-            Array [
-              "project:write",
-              "project:write",
-            ],
-            Array [
-              "project:admin",
-              "project:admin",
-            ],
-            Array [
               "project:releases",
-              "project:releases",
-            ],
-            Array [
               "team:read",
-              "team:read",
-            ],
-            Array [
-              "team:write",
-              "team:write",
-            ],
-            Array [
-              "team:admin",
-              "team:admin",
-            ],
-            Array [
-              "event:read",
-              "event:read",
             ],
-            Array [
-              "event:admin",
-              "event:admin",
-            ],
-            Array [
-              "org:read",
-              "org:read",
-            ],
-            Array [
-              "org:write",
-              "org:write",
-            ],
-            Array [
-              "org:admin",
-              "org:admin",
-            ],
-            Array [
-              "member:read",
-              "member:read",
-            ],
-            Array [
-              "member:admin",
-              "member:admin",
-            ],
-          ]
+          }
         }
-        disabled={false}
-        hideErrorMessage={false}
-        label="Scopes"
-        name="scopes"
-        required={true}
-      />
-    </ApiForm>
-  </NarrowLayout>
+        onCancel={[Function]}
+        onSubmitSuccess={[Function]}
+        submitLabel="Create Token"
+      >
+        <PanelBody
+          direction="column"
+          disablePadding={true}
+          flex={false}
+        >
+          <FormField
+            choices={
+              Array [
+                Array [
+                  "project:read",
+                  "project:read",
+                ],
+                Array [
+                  "project:write",
+                  "project:write",
+                ],
+                Array [
+                  "project:admin",
+                  "project:admin",
+                ],
+                Array [
+                  "project:releases",
+                  "project:releases",
+                ],
+                Array [
+                  "team:read",
+                  "team:read",
+                ],
+                Array [
+                  "team:write",
+                  "team:write",
+                ],
+                Array [
+                  "team:admin",
+                  "team:admin",
+                ],
+                Array [
+                  "event:read",
+                  "event:read",
+                ],
+                Array [
+                  "event:admin",
+                  "event:admin",
+                ],
+                Array [
+                  "org:read",
+                  "org:read",
+                ],
+                Array [
+                  "org:write",
+                  "org:write",
+                ],
+                Array [
+                  "org:admin",
+                  "org:admin",
+                ],
+                Array [
+                  "member:read",
+                  "member:read",
+                ],
+                Array [
+                  "member:admin",
+                  "member:admin",
+                ],
+              ]
+            }
+            flexibleControlStateSize={false}
+            hideErrorMessage={false}
+            inline={false}
+            label="Scopes"
+            name="scopes"
+            required={true}
+          >
+            <Component />
+          </FormField>
+        </PanelBody>
+      </ApiForm>
+    </Panel>
+  </div>
 </SideEffect(DocumentTitle)>
 `;

+ 1 - 1
tests/js/spec/views/apiNewToken.spec.jsx

@@ -1,7 +1,7 @@
 import React from 'react';
 import {shallow} from 'sentry-test/enzyme';
 
-import ApiNewToken from 'app/views/apiNewToken';
+import ApiNewToken from 'app/views/settings/account/apiNewToken';
 
 describe('ApiNewToken', function() {
   describe('render()', function() {