Filter related collections if meta is not set (#20756)

Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
This commit is contained in:
Kelf
2024-01-10 15:54:29 +01:00
committed by GitHub
parent a6e2712e09
commit 44e38be577
7 changed files with 22 additions and 8 deletions

View File

@@ -0,0 +1,5 @@
---
"@directus/app": patch
---
Ensured unconfigured tables are not displayed/selectable as releated collection

View File

@@ -34,14 +34,17 @@ const currentPrimaryKey = computed(() => fieldsStore.getPrimaryKeyFieldForCollec
const availableCollections = computed(() => {
return [
...orderBy(collectionsStore.databaseCollections, ['collection'], ['asc']),
...orderBy(
collectionsStore.databaseCollections.filter((collection) => collection.meta),
['meta.sort', 'collection'],
),
{
divider: true,
},
{
collection: t('system'),
selectable: false,
children: orderBy(collectionsStore.crudSafeSystemCollections, ['collection'], ['asc']),
children: collectionsStore.crudSafeSystemCollections,
},
];
});

View File

@@ -22,14 +22,17 @@ const oneAllowedCollections = syncFieldDetailStoreProperty('relations.m2o.meta.o
const availableCollections = computed(() => {
return [
...orderBy(collectionsStore.databaseCollections, ['collection'], ['asc']),
...orderBy(
collectionsStore.databaseCollections.filter((collection) => collection.meta),
['meta.sort', 'collection'],
),
{
divider: true,
},
{
collection: t('system'),
selectable: false,
children: orderBy(collectionsStore.crudSafeSystemCollections, ['collection'], ['asc']),
children: collectionsStore.crudSafeSystemCollections,
},
];
});

View File

@@ -19,7 +19,10 @@ const collectionExists = computed(() => {
});
const availableCollections = computed(() => {
return orderBy(collectionsStore.databaseCollections, ['sort', 'collection'], ['asc']);
return orderBy(
collectionsStore.databaseCollections.filter((collection) => collection.meta),
['meta.sort', 'collection'],
);
});
const systemCollections = collectionsStore.crudSafeSystemCollections;

View File

@@ -21,7 +21,7 @@ const { t } = useI18n();
const collectionsStore = useCollectionsStore();
const regularCollections = computed(() => collectionsStore.databaseCollections);
const regularCollections = computed(() => orderBy(collectionsStore.databaseCollections, ['meta.sort', 'collection']));
const systemCollections = computed(() =>
orderBy(

View File

@@ -33,8 +33,7 @@ export const useCollectionsStore = defineStore('collectionsStore', () => {
collections.value.filter((collection) => {
return collection.collection.startsWith('directus_') === true;
}),
['collection'],
['asc'],
'collection',
).filter((collection) => COLLECTIONS_DENY_LIST.includes(collection.collection) === false),
);

View File

@@ -103,3 +103,4 @@
- mahendraHegde
- nassan
- emahuni
- khako