From 587895e387bb7fedd78116e18c746b2a99540dc5 Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Wed, 30 Jun 2021 13:30:48 -0400 Subject: [PATCH] Add system collections to pane dropdown --- app/src/constants.ts | 14 ++++++++ .../system-collection/system-collection.vue | 9 +++-- app/src/panels/metric/index.ts | 3 ++ app/src/panels/time-series/index.ts | 3 ++ app/src/panels/time-series/time-series.vue | 36 ++++++++++--------- app/src/stores/collections.ts | 11 ++++++ 6 files changed, 55 insertions(+), 21 deletions(-) diff --git a/app/src/constants.ts b/app/src/constants.ts index 0bf57576c6..d3eee8ae12 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -21,3 +21,17 @@ export const DIRECTUS_LOGO = ` ⠀⠀⠀⠀⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ `; + +/** + * These are the system endpoints that don't have full/regular CRUD operations available. + */ +export const COLLECTIONS_DENY_LIST = [ + 'directus_activity', + 'directus_collections', + 'directus_fields', + 'directus_migrations', + 'directus_relations', + 'directus_revisions', + 'directus_sessions', + 'directus_settings', +]; diff --git a/app/src/interfaces/_system/system-collection/system-collection.vue b/app/src/interfaces/_system/system-collection/system-collection.vue index f86b31c00e..2bfa1baf8e 100644 --- a/app/src/interfaces/_system/system-collection/system-collection.vue +++ b/app/src/interfaces/_system/system-collection/system-collection.vue @@ -35,11 +35,10 @@ export default defineComponent({ const collectionsStore = useCollectionsStore(); const collections = computed(() => { - if (props.includeSystem) return collectionsStore.collections; - - return collectionsStore.collections.filter( - (collection) => collection.collection.startsWith('directus_') === false - ); + return [ + ...collectionsStore.collections.filter((collection) => collection.collection.startsWith('directus_') === false), + ...(props.includeSystem ? collectionsStore.crudSafeSystemCollections : []), + ]; }); const items = computed(() => { diff --git a/app/src/panels/metric/index.ts b/app/src/panels/metric/index.ts index df3875b6ae..0a5fc569bf 100644 --- a/app/src/panels/metric/index.ts +++ b/app/src/panels/metric/index.ts @@ -14,6 +14,9 @@ export default definePanel({ name: '$t:collection', meta: { interface: 'system-collection', + options: { + includeSystem: true, + }, width: 'half', }, }, diff --git a/app/src/panels/time-series/index.ts b/app/src/panels/time-series/index.ts index b55a52bde0..abe1b5a20b 100644 --- a/app/src/panels/time-series/index.ts +++ b/app/src/panels/time-series/index.ts @@ -14,6 +14,9 @@ export default definePanel({ name: '$t:collection', meta: { interface: 'system-collection', + options: { + includeSystem: true, + }, width: 'half', }, }, diff --git a/app/src/panels/time-series/time-series.vue b/app/src/panels/time-series/time-series.vue index 1f8f604fcb..df8fdd990c 100644 --- a/app/src/panels/time-series/time-series.vue +++ b/app/src/panels/time-series/time-series.vue @@ -215,9 +215,9 @@ export default defineComponent({ }, markers: { hover: { - size: undefined, - sizeOffset: 4, - } + size: undefined, + sizeOffset: 4, + }, }, fill: { type: 'gradient', @@ -292,10 +292,10 @@ export default defineComponent({ }, }, crosshairs: { - stroke: { - color: 'var(--border-normal)', - }, - }, + stroke: { + color: 'var(--border-normal)', + }, + }, }, yaxis: { forceNiceScale: true, @@ -330,23 +330,27 @@ export default defineComponent({ height: 100%; } + \ No newline at end of file + +.apexcharts-tooltip-series-group:last-child { + padding-bottom: 0; +} + diff --git a/app/src/stores/collections.ts b/app/src/stores/collections.ts index 2d02e85c16..d701a79b11 100644 --- a/app/src/stores/collections.ts +++ b/app/src/stores/collections.ts @@ -7,6 +7,8 @@ import { unexpectedError } from '@/utils/unexpected-error'; import formatTitle from '@directus/format-title'; import { defineStore } from 'pinia'; import { TranslateResult } from 'vue-i18n'; +import { COLLECTIONS_DENY_LIST } from '@/constants'; +import { orderBy } from 'lodash'; export const useCollectionsStore = defineStore({ id: 'collectionsStore', @@ -24,6 +26,15 @@ export const useCollectionsStore = defineStore({ .filter(({ collection }) => collection.startsWith('directus_') === false) .filter((collection) => collection.meta?.hidden !== false); }, + crudSafeSystemCollections(): Collection[] { + return orderBy( + this.collections.filter((collection) => { + return collection.collection.startsWith('directus_') === true; + }), + ['collection'], + ['asc'] + ).filter((collection) => COLLECTIONS_DENY_LIST.includes(collection.collection) === false); + }, }, actions: { async hydrate() {