Skip to content

Commit c5ecd26

Browse files
ref: remove loading of assets in frontend (#80893)
last used before 6b3d0fb <!-- Describe your PR here. -->
1 parent 5ece842 commit c5ecd26

File tree

4 files changed

+9
-53
lines changed

4 files changed

+9
-53
lines changed

static/app/plugins/registry.tsx

+9-48
Original file line numberDiff line numberDiff line change
@@ -22,57 +22,18 @@ export default class Registry {
2222
data: Plugin,
2323
callback: (instance: DefaultIssuePlugin | DefaultPlugin | SessionStackPlugin) => void
2424
) {
25-
let remainingAssets = data.assets.length;
2625
// TODO(dcramer): we should probably register all valid plugins
27-
const finishLoad = () => {
28-
if (!defined(this.plugins[data.id])) {
29-
if (data.type === 'issue-tracking') {
30-
this.plugins[data.id] = DefaultIssuePlugin;
31-
} else {
32-
this.plugins[data.id] = DefaultPlugin;
33-
}
34-
}
35-
console.info(
36-
'[plugins] Loaded ' + data.id + ' as {' + this.plugins[data.id].name + '}'
37-
);
38-
callback(this.get(data));
39-
};
40-
41-
if (remainingAssets === 0) {
42-
finishLoad();
43-
return;
44-
}
45-
46-
const onAssetLoaded = function () {
47-
remainingAssets--;
48-
if (remainingAssets === 0) {
49-
finishLoad();
50-
}
51-
};
52-
53-
const onAssetFailed = function (asset: {url: string}) {
54-
remainingAssets--;
55-
console.error('[plugins] Failed to load asset ' + asset.url);
56-
if (remainingAssets === 0) {
57-
finishLoad();
58-
}
59-
};
60-
61-
// TODO(dcramer): what do we do on failed asset loading?
62-
data.assets.forEach(asset => {
63-
if (!defined(this.assetCache[asset.url])) {
64-
console.info('[plugins] Loading asset for ' + data.id + ': ' + asset.url);
65-
const s = document.createElement('script');
66-
s.src = asset.url;
67-
s.onload = onAssetLoaded.bind(this);
68-
s.onerror = onAssetFailed.bind(this, asset);
69-
s.async = true;
70-
document.body.appendChild(s);
71-
this.assetCache[asset.url] = s;
26+
if (!defined(this.plugins[data.id])) {
27+
if (data.type === 'issue-tracking') {
28+
this.plugins[data.id] = DefaultIssuePlugin;
7229
} else {
73-
onAssetLoaded();
30+
this.plugins[data.id] = DefaultPlugin;
7431
}
75-
});
32+
}
33+
console.info(
34+
'[plugins] Loaded ' + data.id + ' as {' + this.plugins[data.id].name + '}'
35+
);
36+
callback(this.get(data));
7637
}
7738

7839
get(data: Plugin) {

static/app/types/integrations.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ export type IntegrationIssueConfig = {
457457
* Project Plugins
458458
*/
459459
export type PluginNoProject = {
460-
assets: Array<{url: string}>;
461460
canDisable: boolean;
462461
// TODO(ts)
463462
contexts: any[];

tests/js/fixtures/integrationListDirectory.ts

-3
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ export function SentryAppInstallsFixture() {
215215
export function PluginListConfigFixture() {
216216
return [
217217
{
218-
assets: [],
219218
author: {name: 'Sentry Team', url: 'https://github.com/getsentry/sentry'},
220219
canDisable: true,
221220
contexts: [],
@@ -259,7 +258,6 @@ export function PluginListConfigFixture() {
259258
hasConfiguration: true,
260259
shortName: 'PagerDuty',
261260
id: 'pagerduty',
262-
assets: [],
263261
featureDescriptions: [
264262
{
265263
description:
@@ -314,7 +312,6 @@ export function WebhookPluginConfigFixture(plugin?: Partial<Plugin>): Plugin {
314312
metadata: {},
315313
contexts: [],
316314
status: 'unknown',
317-
assets: [],
318315
doc: '',
319316
enabled: true,
320317
version: '24.1.0.dev0',

tests/js/fixtures/plugin.ts

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export function PluginFixture(params: Partial<Plugin> = {}): Plugin {
99
name: 'Amazon SQS',
1010
slug: 'amazon-sqs',
1111
version: '8.23.0.dev0',
12-
assets: [],
1312
hasConfiguration: true,
1413
canDisable: true,
1514
contexts: [],

0 commit comments

Comments
 (0)