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

ref(stubs): convert stubs to tsx (#52442)

Jonas 1 год назад
Родитель
Сommit
76552de310

+ 0 - 9
fixtures/js-stubs/accountAppearance.js

@@ -1,9 +0,0 @@
-export function AccountAppearance(params = {}) {
-  return {
-    stacktrace_order: '2',
-    timezone: 'US/Pacific',
-    language: 'en',
-    clock_24_hours: true,
-    ...params,
-  };
-}

+ 3 - 1
fixtures/js-stubs/accountEmails.js → fixtures/js-stubs/accountEmails.tsx

@@ -1,4 +1,6 @@
-export function AccountEmails(params = []) {
+import type {UserEmail} from 'sentry/types';
+
+export function AccountEmails(params: UserEmail[] = []): UserEmail[] {
   return [
     {
       email: 'primary@example.com',

+ 46 - 19
fixtures/js-stubs/activityFeed.js → fixtures/js-stubs/activityFeed.tsx

@@ -1,9 +1,16 @@
-export function ActivityFeed(params = {}) {
+import {
+  type Activity,
+  EventOrGroupType,
+  GroupActivityType,
+  IssueCategory,
+  IssueType,
+} from 'sentry/types';
+
+export function ActivityFeed(params: Partial<Activity> = {}): Activity {
   return {
     data: {text: 'Very interesting comment'},
     dateCreated: '2019-04-29T21:43:32.280Z',
-    project: {
-      status: 'active',
+    project: TestStubs.Project({
       features: [
         'releases',
         'sample-events',
@@ -13,21 +20,18 @@ export function ActivityFeed(params = {}) {
         'similarity-view',
         'data-forwarding',
       ],
-      color: '#bf873f',
       isInternal: true,
-      isPublic: false,
       dateCreated: '2019-03-09T06:52:19.832Z',
       id: '1',
       slug: 'internal',
       name: 'Internal',
       hasAccess: true,
       isBookmarked: false,
-      platform: null,
+      platform: undefined,
       firstEvent: '2019-03-09T06:56:15Z',
-      avatar: {avatarUuid: null, avatarType: 'letter_avatar'},
       isMember: true,
-    },
-    user: {
+    }),
+    user: TestStubs.User({
       username: 'billy@sentry.io',
       lastLogin: '2019-04-23T00:10:19.787Z',
       isSuperuser: true,
@@ -52,8 +56,8 @@ export function ActivityFeed(params = {}) {
       avatar: {avatarUuid: null, avatarType: 'letter_avatar'},
       hasPasswordAuth: true,
       email: 'billy@sentry.io',
-    },
-    type: 'note',
+    }),
+    type: GroupActivityType.NOTE,
     issue: {
       platform: 'javascript',
       lastSeen: '2019-04-26T16:34:12.288Z',
@@ -62,25 +66,48 @@ export function ActivityFeed(params = {}) {
       culprit: '/organizations/:orgId/issues/:groupId/feedback/',
       title: 'Error: user efedback',
       id: '524',
-      assignedTo: null,
-      logger: null,
-      type: 'error',
+      assignedTo: {
+        id: '1',
+        name: 'actor',
+        type: 'user',
+      },
+      issueCategory: IssueCategory.ERROR,
+      issueType: IssueType.ERROR,
+      participants: [],
+      latestEvent: TestStubs.Event(),
+      isUnhandled: true,
+      pluginActions: [],
+      pluginContexts: [],
+      seenBy: [],
+      filtered: null,
+      pluginIssues: [],
+      // there is a nasty type issue here where "reprocessing" cannot be assigned to
+      // resolution status | "reprocessing" and "reprocessing" cannot be assigned to resolution
+      // status (fails even if I as const it).
+      // @ts-expect-error
+      status: 'reprocessing',
+      activity: [],
+      logger: 'critical',
+      type: EventOrGroupType.ERROR,
       annotations: [],
-      metadata: {type: 'Error', value: 'user efedback', filename: '<anonymous>'},
-      status: 'unresolved',
+      metadata: {type: 'Error', value: 'user feedback', filename: '<anonymous>'},
       subscriptionDetails: {reason: 'commented'},
       isPublic: false,
       hasSeen: true,
       shortId: 'INTERNAL-DW',
-      shareId: null,
+      shareId: '99',
       firstSeen: '2019-04-26T16:34:12.288Z',
       count: '1',
       permalink: 'http://localhost:8000/organizations/sentry/issues/524/?project=1',
       level: 'error',
       isSubscribed: true,
       isBookmarked: false,
-      project: {platform: null, slug: 'internal', id: '1', name: 'Internal'},
-      statusDetails: {},
+      project: TestStubs.Project({
+        platform: undefined,
+        slug: 'internal',
+        id: '1',
+        name: 'Internal',
+      }),
     },
     id: '48',
     ...params,

+ 6 - 1
fixtures/js-stubs/apiApplication.js → fixtures/js-stubs/apiApplication.tsx

@@ -1,4 +1,8 @@
-export function ApiApplication(params = {}) {
+import type {ApiApplication as ApiApplicationType} from 'sentry/types';
+
+export function ApiApplication(
+  params: Partial<ApiApplicationType> = {}
+): ApiApplicationType {
   return {
     allowedOrigins: [],
     clientID: 'aowekr12903i9i423094i23904j',
@@ -8,6 +12,7 @@ export function ApiApplication(params = {}) {
     name: 'Adjusted Shrimp',
     privacyUrl: null,
     redirectUris: [],
+    termsUrl: null,
     ...params,
   };
 }

+ 0 - 11
fixtures/js-stubs/apiKey.js

@@ -1,11 +0,0 @@
-export function ApiKey(params = {}) {
-  return {
-    allowed_origins: '',
-    id: 1,
-    key: 'aa624bcc12024702a202cd90be5feda0',
-    label: 'Default',
-    scope_list: ['project:read', 'event:read', 'team:read', 'member:read'],
-    status: 0,
-    ...params,
-  };
-}

+ 0 - 8
fixtures/js-stubs/apiToken.js

@@ -1,8 +0,0 @@
-export function ApiToken(params = {}) {
-  return {
-    token: 'apitoken123',
-    dateCreated: new Date('Thu Jan 11 2018 18:01:41 GMT-0800 (PST)'),
-    scopes: ['scope1', 'scope2'],
-    ...params,
-  };
-}

+ 17 - 0
fixtures/js-stubs/apiToken.tsx

@@ -0,0 +1,17 @@
+import type {InternalAppApiToken as InternalAppApiTokenType} from 'sentry/types';
+
+export function ApiToken(
+  params: Partial<InternalAppApiTokenType> = {}
+): InternalAppApiTokenType {
+  return {
+    id: '1',
+    token: 'apitoken123',
+    dateCreated: new Date('Thu Jan 11 2018 18:01:41 GMT-0800 (PST)').toISOString(),
+    scopes: ['project:read', 'project:write'],
+    application: null,
+    refreshToken: 'refresh_token',
+    expiresAt: new Date('Thu Jan 11 2018 18:01:41 GMT-0800 (PST)').toISOString(),
+    state: 'active',
+    ...params,
+  };
+}

+ 0 - 76
fixtures/js-stubs/asana.js

@@ -1,76 +0,0 @@
-export function AsanaPlugin() {
-  return {
-    status: 'unknown',
-    description: 'Integrate Asana issues by linking a repository to a project.',
-    isTestable: false,
-    hasConfiguration: true,
-    shortName: 'Asana',
-    slug: 'asana',
-    name: 'Asana',
-    assets: [],
-    title: 'Asana',
-    contexts: [],
-    doc: '',
-    resourceLinks: [
-      {url: 'https://github.com/getsentry/sentry/issues', title: 'Bug Tracker'},
-      {url: 'https://github.com/getsentry/sentry', title: 'Source'},
-    ],
-    allowed_actions: ['create', 'link', 'unlink'],
-    enabled: true,
-    id: 'asana',
-    version: '9.1.0.dev0',
-    canDisable: true,
-    author: {url: 'https://github.com/getsentry/sentry', name: 'Sentry Team'},
-    type: 'issue-tracking',
-    metadata: {},
-  };
-}
-
-export function AsanaCreate() {
-  return [
-    {
-      name: 'workspace',
-      default: 608780875677549,
-      choices: [[608780875677549, 'sentry.io']],
-      readonly: true,
-      label: 'Asana Workspace',
-      type: 'select',
-    },
-    {
-      default: 'Error: Loading chunk 3 failed.',
-      type: 'text',
-      name: 'title',
-      label: 'Name',
-    },
-    {
-      default:
-        'http://localhost:8000/default/internal/issues/3750/\n\n```\nError: Loading chunk 3 failed.\n  at HTMLScriptElement.onScriptComplete (/_static/1529684704/sentry/dist/vendor.js:762:24)\n```',
-      required: false,
-      type: 'textarea',
-      name: 'description',
-      label: 'Notes',
-    },
-    {
-      name: 'project',
-      placeholder: 'Start typing to search for a project',
-      required: false,
-      has_autocomplete: true,
-      label: 'Project',
-      type: 'select',
-    },
-    {
-      name: 'assignee',
-      placeholder: 'Start typing to search for a user',
-      required: false,
-      has_autocomplete: true,
-      label: 'Assignee',
-      type: 'select',
-    },
-  ];
-}
-
-const DEFAULT_AUTOCOMPLETE = {text: '(#724210387969378) billy', id: 724210387969378};
-
-export function AsanaAutocomplete(type = 'project', values = [DEFAULT_AUTOCOMPLETE]) {
-  return {[type]: values};
-}

+ 3 - 1
fixtures/js-stubs/auditLogs.js → fixtures/js-stubs/auditLogs.tsx

@@ -1,4 +1,6 @@
-export function AuditLogs(params = []) {
+import type {AuditLog as AuditLogType} from 'sentry/types';
+
+export function AuditLogs(params: AuditLogType[] = []): AuditLogType[] {
   return [
     {
       note: 'edited project ludic-science',

+ 2 - 1
fixtures/js-stubs/auditLogsApiEventNames.js → fixtures/js-stubs/auditLogsApiEventNames.tsx

@@ -1,4 +1,5 @@
-export function AuditLogsApiEventNames(params = []) {
+// Could not find any strong types for this when converting to typescript
+export function AuditLogsApiEventNames(params: string[] = []): string[] {
   return [
     ...params,
     'member.invite',

Некоторые файлы не были показаны из-за большого количества измененных файлов