Skip to content

Commit 6b68bef

Browse files
committed
feat: add asset type resolution and update data source fetching logic
1 parent f2cf435 commit 6b68bef

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/components/inspector/options-list.vue

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ export default {
341341
},
342342
],
343343
valueTypeReturned: '',
344+
assetType: null,
345+
assetTypeResolved: false,
346+
screenId: null,
344347
};
345348
},
346349
watch: {
@@ -504,9 +507,37 @@ export default {
504507
monacoMounted(editor) {
505508
editor.getAction('editor.action.formatDocument').run();
506509
},
507-
getDataSourceList() {
510+
resolveAssetType() {
511+
if (this.assetTypeResolved) {
512+
return Promise.resolve(this.assetType);
513+
}
514+
const match = window.location.pathname.match(/screen-builder\/(\d+)\/edit/);
515+
if (!match) {
516+
this.assetTypeResolved = true;
517+
return Promise.resolve(this.assetType);
518+
}
519+
this.screenId = match[1];
520+
return this.$dataProvider
521+
.get(`/screens/${this.screenId}`)
522+
.then(response => {
523+
this.assetType = response.data.asset_type || null;
524+
this.assetTypeResolved = true;
525+
return this.assetType;
526+
})
527+
.catch(() => {
528+
this.assetTypeResolved = true;
529+
return this.assetType;
530+
});
531+
},
532+
async getDataSourceList() {
533+
await this.resolveAssetType();
534+
const params = {};
535+
if (this.assetType) {
536+
// For PM Block screens, expose both regular and PM Block connectors.
537+
params.asset_type = this.assetType === 'PM_BLOCK' ? 'all' : this.assetType;
538+
}
508539
this.$dataProvider
509-
.get('/data_sources')
540+
.get('/data_sources', { params })
510541
.then(response => {
511542
let jsonData = response.data.data;
512543
// Map the data sources response to value/text items list

0 commit comments

Comments
 (0)