From 6a68f6f69b978bc5d968ee03c253d7d6e995e0c5 Mon Sep 17 00:00:00 2001 From: anthony sottile Date: Mon, 18 Nov 2024 09:16:48 -0500 Subject: [PATCH] ref: remove loading of assets in frontend last used before 6b3d0fb43e95ee5ca2ee51d9e1962387dc554942 --- static/app/plugins/registry.tsx | 57 +++---------------- static/app/types/integrations.tsx | 1 - tests/js/fixtures/integrationListDirectory.ts | 3 - tests/js/fixtures/plugin.ts | 1 - 4 files changed, 9 insertions(+), 53 deletions(-) diff --git a/static/app/plugins/registry.tsx b/static/app/plugins/registry.tsx index a7d566866fafef..52635e140063b1 100644 --- a/static/app/plugins/registry.tsx +++ b/static/app/plugins/registry.tsx @@ -22,57 +22,18 @@ export default class Registry { data: Plugin, callback: (instance: DefaultIssuePlugin | DefaultPlugin | SessionStackPlugin) => void ) { - let remainingAssets = data.assets.length; // TODO(dcramer): we should probably register all valid plugins - const finishLoad = () => { - if (!defined(this.plugins[data.id])) { - if (data.type === 'issue-tracking') { - this.plugins[data.id] = DefaultIssuePlugin; - } else { - this.plugins[data.id] = DefaultPlugin; - } - } - console.info( - '[plugins] Loaded ' + data.id + ' as {' + this.plugins[data.id].name + '}' - ); - callback(this.get(data)); - }; - - if (remainingAssets === 0) { - finishLoad(); - return; - } - - const onAssetLoaded = function () { - remainingAssets--; - if (remainingAssets === 0) { - finishLoad(); - } - }; - - const onAssetFailed = function (asset: {url: string}) { - remainingAssets--; - console.error('[plugins] Failed to load asset ' + asset.url); - if (remainingAssets === 0) { - finishLoad(); - } - }; - - // TODO(dcramer): what do we do on failed asset loading? - data.assets.forEach(asset => { - if (!defined(this.assetCache[asset.url])) { - console.info('[plugins] Loading asset for ' + data.id + ': ' + asset.url); - const s = document.createElement('script'); - s.src = asset.url; - s.onload = onAssetLoaded.bind(this); - s.onerror = onAssetFailed.bind(this, asset); - s.async = true; - document.body.appendChild(s); - this.assetCache[asset.url] = s; + if (!defined(this.plugins[data.id])) { + if (data.type === 'issue-tracking') { + this.plugins[data.id] = DefaultIssuePlugin; } else { - onAssetLoaded(); + this.plugins[data.id] = DefaultPlugin; } - }); + } + console.info( + '[plugins] Loaded ' + data.id + ' as {' + this.plugins[data.id].name + '}' + ); + callback(this.get(data)); } get(data: Plugin) { diff --git a/static/app/types/integrations.tsx b/static/app/types/integrations.tsx index 76c2b232410e88..b6359122e9940f 100644 --- a/static/app/types/integrations.tsx +++ b/static/app/types/integrations.tsx @@ -457,7 +457,6 @@ export type IntegrationIssueConfig = { * Project Plugins */ export type PluginNoProject = { - assets: Array<{url: string}>; canDisable: boolean; // TODO(ts) contexts: any[]; diff --git a/tests/js/fixtures/integrationListDirectory.ts b/tests/js/fixtures/integrationListDirectory.ts index feff168fcc6b67..7f576f6469ebe6 100644 --- a/tests/js/fixtures/integrationListDirectory.ts +++ b/tests/js/fixtures/integrationListDirectory.ts @@ -215,7 +215,6 @@ export function SentryAppInstallsFixture() { export function PluginListConfigFixture() { return [ { - assets: [], author: {name: 'Sentry Team', url: 'https://github.com/getsentry/sentry'}, canDisable: true, contexts: [], @@ -259,7 +258,6 @@ export function PluginListConfigFixture() { hasConfiguration: true, shortName: 'PagerDuty', id: 'pagerduty', - assets: [], featureDescriptions: [ { description: @@ -314,7 +312,6 @@ export function WebhookPluginConfigFixture(plugin?: Partial): Plugin { metadata: {}, contexts: [], status: 'unknown', - assets: [], doc: '', enabled: true, version: '24.1.0.dev0', diff --git a/tests/js/fixtures/plugin.ts b/tests/js/fixtures/plugin.ts index 5b59f29fceebe0..18d437ffdbcd8f 100644 --- a/tests/js/fixtures/plugin.ts +++ b/tests/js/fixtures/plugin.ts @@ -9,7 +9,6 @@ export function PluginFixture(params: Partial = {}): Plugin { name: 'Amazon SQS', slug: 'amazon-sqs', version: '8.23.0.dev0', - assets: [], hasConfiguration: true, canDisable: true, contexts: [],