diff --git a/api/package.json b/api/package.json index dee8d28a46..4773f11fef 100644 --- a/api/package.json +++ b/api/package.json @@ -1,6 +1,6 @@ { "name": "directus", - "version": "9.14.3", + "version": "9.14.5", "license": "GPL-3.0-only", "homepage": "https://github.com/directus/directus#readme", "description": "Directus is a real-time API and App dashboard for managing SQL database content.", diff --git a/api/src/services/graphql/index.ts b/api/src/services/graphql/index.ts index 77b9322ca5..bce34f6d4b 100644 --- a/api/src/services/graphql/index.ts +++ b/api/src/services/graphql/index.ts @@ -1250,7 +1250,7 @@ export class GraphQLService { if (!selections) return null; const args: Record = this.parseArgs(info.fieldNodes[0].arguments || [], info.variableValues); - let query: Record; + let query: Query; const isAggregate = collection.endsWith('_aggregated') && collection in this.schema.collections === false; @@ -1280,13 +1280,15 @@ export class GraphQLService { } // Transform count(a.b.c) into a.b.count(c) - for (let fieldIndex = 0; fieldIndex < query.fields.length; fieldIndex++) { - if (query.fields[fieldIndex].includes('(') && query.fields[fieldIndex].includes(')')) { - const functionName = query.fields[fieldIndex].split('(')[0]; - const columnNames = query.fields[fieldIndex].match(REGEX_BETWEEN_PARENS)![1].split('.'); - if (columnNames.length > 1) { - const column = columnNames.pop(); - query.fields[fieldIndex] = columnNames.join('.') + '.' + functionName + '(' + column + ')'; + if (query.fields?.length) { + for (let fieldIndex = 0; fieldIndex < query.fields.length; fieldIndex++) { + if (query.fields[fieldIndex].includes('(') && query.fields[fieldIndex].includes(')')) { + const functionName = query.fields[fieldIndex].split('(')[0]; + const columnNames = query.fields[fieldIndex].match(REGEX_BETWEEN_PARENS)![1].split('.'); + if (columnNames.length > 1) { + const column = columnNames.pop(); + query.fields[fieldIndex] = columnNames.join('.') + '.' + functionName + '(' + column + ')'; + } } } } diff --git a/app/package.json b/app/package.json index 8ea5761992..862bc8b517 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "@directus/app", - "version": "9.14.3", + "version": "9.14.5", "private": false, "description": "Directus is an Open-Source Headless CMS & API for Managing Custom Databases", "author": "Rijk van Zanten ", diff --git a/app/src/api.ts b/app/src/api.ts index 174e75ca1c..23c9a46ee6 100644 --- a/app/src/api.ts +++ b/app/src/api.ts @@ -1,5 +1,5 @@ import { logout, LogoutReason, refresh } from '@/auth'; -import { useRequestsStore } from '@/stores/'; +import { useRequestsStore } from '@/stores/requests'; import { getRootPath } from '@/utils/get-root-path'; import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'; import { addQueryToPath } from './utils/add-query-to-path'; diff --git a/app/src/app.vue b/app/src/app.vue index b20d92cad5..b0836d0e1a 100644 --- a/app/src/app.vue +++ b/app/src/app.vue @@ -23,11 +23,13 @@ - - -``` - -## Sizes - -The circular progress component supports the following sizes through the use of props: - -- x-small -- small -- (default) -- large -- x-large - -```html - - - - - -``` - -## Props - -| Prop | Description | Default | -| --------------- | ------------------------------ | ------- | -| `value` | The percentage value | `0` | -| `indeterminate` | Displays the loading animation | `false` | -| `x-small` | Render extra small | `false` | -| `small` | Render small | `false` | -| `large` | Render large | `false` | -| `x-large` | Render extra large | `false` | - -## Slots - -| Slot | Description | Data | -| --------- | ------------------------------------ | ---- | -| _default_ | Rendered in the center of the circle | -- | - -## Events - -n/a - -## CSS Variables - -| Variable | Default | -| ---------------------------------------- | ---------------------------------------- | -| `--v-progress-circular-color` | `var(--loading-background-color-accent)` | -| `--v-progress-circular-background-color` | `var(--loading-background-color)` | -| `--v-progress-circular-transition` | `400ms` | -| `--v-progress-circular-speed` | `1s` | -| `--v-progress-circular-size` | `28px` | -| `--v-progress-circular-line-size` | `3px` | diff --git a/app/src/components/v-progress/linear/index.ts b/app/src/components/v-progress/linear/index.ts deleted file mode 100644 index 348de049d4..0000000000 --- a/app/src/components/v-progress/linear/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import VProgressLinear from './v-progress-linear.vue'; - -export { VProgressLinear }; -export default VProgressLinear; diff --git a/app/src/components/v-progress/linear/readme.md b/app/src/components/v-progress/linear/readme.md deleted file mode 100644 index bdba50edf3..0000000000 --- a/app/src/components/v-progress/linear/readme.md +++ /dev/null @@ -1,55 +0,0 @@ -# Progress (Linear) - -```html - -``` - -## Colors - -The linear progress component supports colors. Colors can be changed via the css variables `--v-progress-linear-color` -and `--v-progress-linear-background-color` - -```html - - -``` - -## Indeterminate - -The progress indicator can be rendered in indeterminate mode by passing the `indeterminate` prop. Use this when it's -unclear when the progress will be done. - -## Props - -| Prop | Description | Default | -| --------------- | ------------------------------------------------------ | ------- | -| `absolute` | Applies `position: absolute` | `false` | -| `bottom` | Align the progress bar to the bottom | `false` | -| `fixed` | Applies `position: fixed;` to the element | `false` | -| `indeterminate` | Animates the bar, use when loading progress is unknown | `false` | -| `rounded` | Add a border radius to the bar | `false` | -| `top` | Align progress bar to the top of the parent container | `false` | -| `value` | Percentage value for current progress | `0` | - -## Events - -n/a - -## Slots - -| Slots | Description | Value | -| --------- | ----------- | ----- | -| _default_ | | -- | - -## CSS Variables - -| Variable | Default | -| -------------------------------------- | -------------------------- | -| `--v-progress-linear-height` | `4px` | -| `--v-progress-linear-color` | `var(--foreground-normal)` | -| `--v-progress-linear-background-color` | `var(--border-normal)` | diff --git a/app/src/components/v-radio/v-radio.vue b/app/src/components/v-radio.vue similarity index 100% rename from app/src/components/v-radio/v-radio.vue rename to app/src/components/v-radio.vue diff --git a/app/src/components/v-radio/index.ts b/app/src/components/v-radio/index.ts deleted file mode 100644 index 755279ee90..0000000000 --- a/app/src/components/v-radio/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import VRadio from './v-radio.vue'; - -export { VRadio }; -export default VRadio; diff --git a/app/src/components/v-select/index.ts b/app/src/components/v-select/index.ts deleted file mode 100644 index e4cef8f144..0000000000 --- a/app/src/components/v-select/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import VSelect from './v-select.vue'; - -export { VSelect }; -export default VSelect; diff --git a/app/src/components/v-sheet/v-sheet.vue b/app/src/components/v-sheet.vue similarity index 100% rename from app/src/components/v-sheet/v-sheet.vue rename to app/src/components/v-sheet.vue diff --git a/app/src/components/v-sheet/index.ts b/app/src/components/v-sheet/index.ts deleted file mode 100644 index d8f1b19758..0000000000 --- a/app/src/components/v-sheet/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import VSheet from './v-sheet.vue'; - -export { VSheet }; -export default VSheet; diff --git a/app/src/components/v-skeleton-loader/v-skeleton-loader.vue b/app/src/components/v-skeleton-loader.vue similarity index 100% rename from app/src/components/v-skeleton-loader/v-skeleton-loader.vue rename to app/src/components/v-skeleton-loader.vue diff --git a/app/src/components/v-skeleton-loader/index.ts b/app/src/components/v-skeleton-loader/index.ts deleted file mode 100644 index 7f97a751d0..0000000000 --- a/app/src/components/v-skeleton-loader/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import VSkeletonLoader from './v-skeleton-loader.vue'; - -export { VSkeletonLoader }; -export default VSkeletonLoader; diff --git a/app/src/components/v-slider/v-slider.vue b/app/src/components/v-slider.vue similarity index 100% rename from app/src/components/v-slider/v-slider.vue rename to app/src/components/v-slider.vue diff --git a/app/src/components/v-slider/index.ts b/app/src/components/v-slider/index.ts deleted file mode 100644 index 2aba9554cd..0000000000 --- a/app/src/components/v-slider/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import VSlider from './v-slider.vue'; - -export { VSlider }; -export default VSlider; diff --git a/app/src/components/v-switch/v-switch.vue b/app/src/components/v-switch.vue similarity index 100% rename from app/src/components/v-switch/v-switch.vue rename to app/src/components/v-switch.vue diff --git a/app/src/components/v-switch/index.ts b/app/src/components/v-switch/index.ts deleted file mode 100644 index 69b3a8107d..0000000000 --- a/app/src/components/v-switch/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import VSwitch from './v-switch.vue'; - -export { VSwitch }; -export default VSwitch; diff --git a/app/src/components/v-tabs/v-tab-item/v-tab-item.vue b/app/src/components/v-tab-item.vue similarity index 87% rename from app/src/components/v-tabs/v-tab-item/v-tab-item.vue rename to app/src/components/v-tab-item.vue index bab1f82666..00e3f8cf56 100644 --- a/app/src/components/v-tabs/v-tab-item/v-tab-item.vue +++ b/app/src/components/v-tab-item.vue @@ -6,7 +6,7 @@ -``` diff --git a/app/src/composables/use-event-listener/use-event-listener.ts b/app/src/composables/use-event-listener.ts similarity index 85% rename from app/src/composables/use-event-listener/use-event-listener.ts rename to app/src/composables/use-event-listener.ts index 386516c8ea..dae7bf3e78 100644 --- a/app/src/composables/use-event-listener/use-event-listener.ts +++ b/app/src/composables/use-event-listener.ts @@ -1,6 +1,6 @@ import { onMounted, onBeforeUnmount, Ref, isRef } from 'vue'; -export default function useEventListener( +export function useEventListener( target: T | Ref, type: string, handler: (this: T, evt: E) => void, diff --git a/app/src/composables/use-event-listener/index.ts b/app/src/composables/use-event-listener/index.ts deleted file mode 100644 index d753738fd3..0000000000 --- a/app/src/composables/use-event-listener/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import useEventListener from './use-event-listener'; - -export { useEventListener }; -export default useEventListener; diff --git a/app/src/composables/use-event-listener/readme.md b/app/src/composables/use-event-listener/readme.md deleted file mode 100644 index ee4db4f539..0000000000 --- a/app/src/composables/use-event-listener/readme.md +++ /dev/null @@ -1,30 +0,0 @@ -# `useEventListener` - -```ts -function useEventListener( - target: HTMLElement, - type: string, - handler: (event: Event) => void, - options: AddEventListenerOptions -): void; -``` - -Can be used to attach an event listener to any DOM element that will automatically be attached / cleaned up whenever the -component mounts / unmounts. - -## Usage - -```js -import { defineComponent } from 'vue'; -import { useEventListener } from '@/composables/use-event-listener'; - -export default defineComponent({ - setup(props) { - useEventListener(document.querySelector('#example'), 'click', onExampleClick); - - function onExampleClick(event) { - // ... - } - }, -}); -``` diff --git a/app/src/composables/use-field-tree.ts b/app/src/composables/use-field-tree.ts index 54c8b956ec..080ce6b0e0 100644 --- a/app/src/composables/use-field-tree.ts +++ b/app/src/composables/use-field-tree.ts @@ -1,4 +1,5 @@ -import { useFieldsStore, useRelationsStore } from '@/stores/'; +import { useFieldsStore } from '@/stores/fields'; +import { useRelationsStore } from '@/stores/relations'; import { Field, Relation, Type } from '@directus/shared/types'; import { getRelationType } from '@directus/shared/utils'; import { isNil } from 'lodash'; diff --git a/app/src/composables/use-folders.ts b/app/src/composables/use-folders.ts index e52fb88fc1..56073f87ab 100644 --- a/app/src/composables/use-folders.ts +++ b/app/src/composables/use-folders.ts @@ -30,7 +30,7 @@ let openFolders: Ref | null = null; let error: Ref | null = null; -export default function useFolders(): UsableFolders { +export function useFolders(): UsableFolders { if (loading === null) loading = ref(false); if (folders === null) folders = ref(null); if (nestedFolders === null) nestedFolders = ref(null); diff --git a/app/src/composables/use-form-fields/use-form-fields.ts b/app/src/composables/use-form-fields.ts similarity index 94% rename from app/src/composables/use-form-fields/use-form-fields.ts rename to app/src/composables/use-form-fields.ts index a29fe38673..afe5d1d872 100644 --- a/app/src/composables/use-form-fields/use-form-fields.ts +++ b/app/src/composables/use-form-fields.ts @@ -6,7 +6,7 @@ import { cloneDeep, orderBy } from 'lodash'; import { computed, ComputedRef, Ref } from 'vue'; import { translate } from '@/utils/translate-object-values'; -export default function useFormFields(fields: Ref): { formFields: ComputedRef } { +export function useFormFields(fields: Ref): { formFields: ComputedRef } { const formFields = computed(() => { let formFields = cloneDeep(fields.value); diff --git a/app/src/composables/use-form-fields/index.ts b/app/src/composables/use-form-fields/index.ts deleted file mode 100644 index ede96c2125..0000000000 --- a/app/src/composables/use-form-fields/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import useFormFields from './use-form-fields'; - -export { useFormFields }; -export default useFormFields; diff --git a/app/src/composables/groupable/groupable.ts b/app/src/composables/use-groupable.ts similarity index 99% rename from app/src/composables/groupable/groupable.ts rename to app/src/composables/use-groupable.ts index 413c310784..4a7235cc44 100644 --- a/app/src/composables/groupable/groupable.ts +++ b/app/src/composables/use-groupable.ts @@ -1,4 +1,4 @@ -import { isEmpty, notEmpty } from '@/utils/is-empty/'; +import { isEmpty, notEmpty } from '@/utils/is-empty'; import { isEqual } from 'lodash'; import { computed, inject, nextTick, onBeforeUnmount, provide, ref, shallowRef, Ref, watch } from 'vue'; diff --git a/app/src/composables/use-item/use-item.ts b/app/src/composables/use-item.ts similarity index 98% rename from app/src/composables/use-item/use-item.ts rename to app/src/composables/use-item.ts index fd0964b562..6f6e214e56 100644 --- a/app/src/composables/use-item/use-item.ts +++ b/app/src/composables/use-item.ts @@ -1,8 +1,9 @@ import api from '@/api'; import { VALIDATION_TYPES } from '@/constants'; import { i18n } from '@/lang'; -import { useFieldsStore, useRelationsStore } from '@/stores/'; -import { APIError } from '@/types'; +import { useFieldsStore } from '@/stores/fields'; +import { useRelationsStore } from '@/stores/relations'; +import { APIError } from '@/types/error'; import { notify } from '@/utils/notify'; import { translate } from '@/utils/translate-object-values'; import { unexpectedError } from '@/utils/unexpected-error'; @@ -12,7 +13,7 @@ import { getEndpoint } from '@directus/shared/utils'; import { AxiosResponse } from 'axios'; import { merge } from 'lodash'; import { computed, ComputedRef, Ref, ref, watch } from 'vue'; -import { usePermissions } from '../use-permissions'; +import { usePermissions } from './use-permissions'; import { Field, Relation } from '@directus/shared/types'; type UsableItem = { diff --git a/app/src/composables/use-item/index.ts b/app/src/composables/use-item/index.ts deleted file mode 100644 index b17d753256..0000000000 --- a/app/src/composables/use-item/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { useItem } from './use-item'; - -export { useItem }; -export default useItem; diff --git a/app/src/composables/use-item/readme.md b/app/src/composables/use-item/readme.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/app/src/composables/use-local-storage.ts b/app/src/composables/use-local-storage.ts index e73acee620..6f7c33d7e4 100644 --- a/app/src/composables/use-local-storage.ts +++ b/app/src/composables/use-local-storage.ts @@ -1,6 +1,6 @@ import { ref, watch } from 'vue'; -export default function useLocalStorage(key: string) { +export function useLocalStorage(key: string) { const internalKey = `directus-${key}`; const data = ref(null); diff --git a/app/src/composables/use-m2m.ts b/app/src/composables/use-m2m.ts index 6ef2ca869e..eea1898e7f 100644 --- a/app/src/composables/use-m2m.ts +++ b/app/src/composables/use-m2m.ts @@ -1,7 +1,8 @@ import { useCollection } from '@directus/shared/composables'; -import { useCollectionsStore, useRelationsStore } from '@/stores/'; +import { useCollectionsStore } from '@/stores/collections'; +import { useRelationsStore } from '@/stores/relations'; import { Field, Relation } from '@directus/shared/types'; -import { Collection } from '@/types'; +import { Collection } from '@/types/collections'; import { computed, ComputedRef, Ref } from 'vue'; export type RelationInfo = { @@ -25,7 +26,7 @@ type UsableRelation = { relationFields: ComputedRef; }; -export default function useRelation(collection: Ref, field: Ref): UsableRelation { +export function useRelation(collection: Ref, field: Ref): UsableRelation { const relationsStore = useRelationsStore(); const collectionsStore = useCollectionsStore(); diff --git a/app/src/composables/use-permissions.ts b/app/src/composables/use-permissions.ts index 2f33b22e97..8f9b5fa885 100644 --- a/app/src/composables/use-permissions.ts +++ b/app/src/composables/use-permissions.ts @@ -1,4 +1,5 @@ -import { usePermissionsStore, useUserStore } from '@/stores'; +import { usePermissionsStore } from '@/stores/permissions'; +import { useUserStore } from '@/stores/user'; import { Field } from '@directus/shared/types'; import { computed, ComputedRef, Ref } from 'vue'; import { cloneDeep } from 'lodash'; diff --git a/app/src/composables/use-preset/use-preset.ts b/app/src/composables/use-preset.ts similarity index 98% rename from app/src/composables/use-preset/use-preset.ts rename to app/src/composables/use-preset.ts index 1a77bb9b08..db85fd8cb8 100644 --- a/app/src/composables/use-preset/use-preset.ts +++ b/app/src/composables/use-preset.ts @@ -1,4 +1,5 @@ -import { usePresetsStore, useUserStore } from '@/stores'; +import { usePresetsStore } from '@/stores/presets'; +import { useUserStore } from '@/stores/user'; import { translate } from '@/utils/translate-literal'; import { Filter, Preset } from '@directus/shared/types'; import { assign, debounce, isEqual } from 'lodash'; diff --git a/app/src/composables/use-preset/index.ts b/app/src/composables/use-preset/index.ts deleted file mode 100644 index 9596abf57b..0000000000 --- a/app/src/composables/use-preset/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { usePreset } from './use-preset'; - -export { usePreset }; -export default usePreset; diff --git a/app/src/composables/use-preset/types.ts b/app/src/composables/use-preset/types.ts deleted file mode 100644 index a25965fcce..0000000000 --- a/app/src/composables/use-preset/types.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Filter } from '@directus/shared/types'; - -export type Preset = { - id: number; - collection: string; - filter: Filter | null; - role: number | null; - search: string | null; - title: string | null; - user: number | null; - - layout_options: Record; - - layout_query: Record; - layout: string | null; -}; diff --git a/app/src/composables/use-relation/use-relation-m2a.ts b/app/src/composables/use-relation-m2a.ts similarity index 94% rename from app/src/composables/use-relation/use-relation-m2a.ts rename to app/src/composables/use-relation-m2a.ts index 346b7a5a02..822cd3d442 100644 --- a/app/src/composables/use-relation/use-relation-m2a.ts +++ b/app/src/composables/use-relation-m2a.ts @@ -1,5 +1,7 @@ -import { useCollectionsStore, useFieldsStore, useRelationsStore } from '@/stores'; -import { Collection } from '@/types'; +import { useCollectionsStore } from '@/stores/collections'; +import { useFieldsStore } from '@/stores/fields'; +import { useRelationsStore } from '@/stores/relations'; +import { Collection } from '@/types/collections'; import { Field, Relation } from '@directus/shared/types'; import { computed, Ref } from 'vue'; diff --git a/app/src/composables/use-relation/use-relation-m2m.ts b/app/src/composables/use-relation-m2m.ts similarity index 92% rename from app/src/composables/use-relation/use-relation-m2m.ts rename to app/src/composables/use-relation-m2m.ts index 57d4da690e..adf6fbf966 100644 --- a/app/src/composables/use-relation/use-relation-m2m.ts +++ b/app/src/composables/use-relation-m2m.ts @@ -1,6 +1,8 @@ -import { useCollectionsStore, useFieldsStore, useRelationsStore } from '@/stores'; +import { useCollectionsStore } from '@/stores/collections'; +import { useFieldsStore } from '@/stores/fields'; +import { useRelationsStore } from '@/stores/relations'; import { Field, Relation } from '@directus/shared/types'; -import { Collection } from '@/types'; +import { Collection } from '@/types/collections'; import { computed, Ref } from 'vue'; export type RelationM2M = { diff --git a/app/src/composables/use-relation/use-relation-m2o.ts b/app/src/composables/use-relation-m2o.ts similarity index 86% rename from app/src/composables/use-relation/use-relation-m2o.ts rename to app/src/composables/use-relation-m2o.ts index 7189668192..c06583903a 100644 --- a/app/src/composables/use-relation/use-relation-m2o.ts +++ b/app/src/composables/use-relation-m2o.ts @@ -1,6 +1,8 @@ -import { useCollectionsStore, useFieldsStore, useRelationsStore } from '@/stores'; +import { useCollectionsStore } from '@/stores/collections'; +import { useFieldsStore } from '@/stores/fields'; +import { useRelationsStore } from '@/stores/relations'; import { Field, Relation } from '@directus/shared/types'; -import { Collection } from '@/types'; +import { Collection } from '@/types/collections'; import { computed, Ref } from 'vue'; export type RelationM2O = { diff --git a/app/src/composables/use-relation/use-relation-multiple.ts b/app/src/composables/use-relation-multiple.ts similarity index 98% rename from app/src/composables/use-relation/use-relation-multiple.ts rename to app/src/composables/use-relation-multiple.ts index 1c5480ccf6..af5a6b1f86 100644 --- a/app/src/composables/use-relation/use-relation-multiple.ts +++ b/app/src/composables/use-relation-multiple.ts @@ -3,7 +3,9 @@ import { getEndpoint } from '@directus/shared/utils'; import { unexpectedError } from '@/utils/unexpected-error'; import { clamp, cloneDeep, isEqual, merge, isPlainObject } from 'lodash'; import { computed, ref, Ref, watch } from 'vue'; -import { RelationM2A, RelationM2M, RelationO2M } from '@/composables/use-relation'; +import { RelationM2A } from '@/composables/use-relation-m2a'; +import { RelationM2M } from '@/composables/use-relation-m2m'; +import { RelationO2M } from '@/composables/use-relation-o2m'; export type RelationQueryMultiple = { page: number; @@ -18,7 +20,7 @@ export type DisplayItem = { $edits?: number; }; -export type Item = { +export type ChangesItem = { create: Record[]; update: Record[]; delete: (string | number)[]; @@ -36,7 +38,7 @@ export function useRelationMultiple( const { cleanItem, getPage, localDelete } = useUtil(); - const _value = computed({ + const _value = computed({ get() { if (!value.value || Array.isArray(value.value)) return { @@ -44,7 +46,7 @@ export function useRelationMultiple( update: [], delete: [], }; - return value.value as Item; + return value.value as ChangesItem; }, set(newValue) { value.value = newValue; diff --git a/app/src/composables/use-relation/use-relation-o2m.ts b/app/src/composables/use-relation-o2m.ts similarity index 88% rename from app/src/composables/use-relation/use-relation-o2m.ts rename to app/src/composables/use-relation-o2m.ts index 6ec95c63a1..67d394a839 100644 --- a/app/src/composables/use-relation/use-relation-o2m.ts +++ b/app/src/composables/use-relation-o2m.ts @@ -1,6 +1,8 @@ -import { useCollectionsStore, useFieldsStore, useRelationsStore } from '@/stores'; +import { useCollectionsStore } from '@/stores/collections'; +import { useFieldsStore } from '@/stores/fields'; +import { useRelationsStore } from '@/stores/relations'; import { Field, Relation } from '@directus/shared/types'; -import { Collection } from '@/types'; +import { Collection } from '@/types/collections'; import { computed, Ref } from 'vue'; export type RelationO2M = { diff --git a/app/src/composables/use-relation/use-relation-single.ts b/app/src/composables/use-relation-single.ts similarity index 97% rename from app/src/composables/use-relation/use-relation-single.ts rename to app/src/composables/use-relation-single.ts index a1be2c35f9..7653351be4 100644 --- a/app/src/composables/use-relation/use-relation-single.ts +++ b/app/src/composables/use-relation-single.ts @@ -3,7 +3,7 @@ import { getEndpoint } from '@directus/shared/utils'; import { unexpectedError } from '@/utils/unexpected-error'; import { merge } from 'lodash'; import { ref, Ref, watch } from 'vue'; -import { RelationM2O } from '@/composables/use-relation'; +import { RelationM2O } from '@/composables/use-relation-m2o'; export type RelationQuerySingle = { fields: string[]; diff --git a/app/src/composables/use-relation/index.ts b/app/src/composables/use-relation/index.ts deleted file mode 100644 index c0787c56a7..0000000000 --- a/app/src/composables/use-relation/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { useRelationM2A } from './use-relation-m2a'; -import { useRelationM2M } from './use-relation-m2m'; -import { useRelationM2O } from './use-relation-m2o'; -import { useRelationO2M } from './use-relation-o2m'; -import { useRelationSingle } from './use-relation-single'; -import { useRelationMultiple } from './use-relation-multiple'; - -import type { RelationM2A } from './use-relation-m2a'; -import type { RelationM2M } from './use-relation-m2m'; -import type { RelationM2O } from './use-relation-m2o'; -import type { RelationO2M } from './use-relation-o2m'; -import type { RelationQuerySingle } from './use-relation-single'; -import type { RelationQueryMultiple, DisplayItem, Item as ChangesItem } from './use-relation-multiple'; - -export { - useRelationM2A, - RelationM2A, - RelationM2M, - RelationM2O, - RelationO2M, - DisplayItem, - ChangesItem, - useRelationM2M, - RelationQueryMultiple, - RelationQuerySingle, - useRelationM2O, - useRelationMultiple, - useRelationO2M, - useRelationSingle, -}; diff --git a/app/src/composables/use-scroll-distance/index.ts b/app/src/composables/use-scroll-distance/index.ts deleted file mode 100644 index 435be47f43..0000000000 --- a/app/src/composables/use-scroll-distance/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import useScrollDistance from './use-scroll-distance'; - -export { useScrollDistance }; -export default useScrollDistance; diff --git a/app/src/composables/use-scroll-distance/readme.md b/app/src/composables/use-scroll-distance/readme.md deleted file mode 100644 index baecbd6a41..0000000000 --- a/app/src/composables/use-scroll-distance/readme.md +++ /dev/null @@ -1,41 +0,0 @@ -# `useScrollDistance` - -```ts -function useScrollDistance( - t: T | Ref -): { top: Ref; left: Ref; target: Element }; -``` - -Returns a ref for the top and left scroll positions of the given element. Parameter supports Element, Ref, -Ref, and Ref. - -## Usage - -```html - - - -``` diff --git a/app/src/composables/use-scroll-distance/use-scroll-distance.ts b/app/src/composables/use-scroll-distance/use-scroll-distance.ts deleted file mode 100644 index efeeb81215..0000000000 --- a/app/src/composables/use-scroll-distance/use-scroll-distance.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { throttle } from 'lodash'; -import { ComponentPublicInstance, computed, isRef, onMounted, onUnmounted, ref, Ref, ComputedRef } from 'vue'; - -type UsableScrollDistance = { - top: Ref; - left: Ref; - target: ComputedRef; -}; - -export default function useScrollDistance( - t: T | Ref -): UsableScrollDistance { - const top = ref(); - const left = ref(); - - const onScroll = throttle((event: Event) => { - const target = event.target as Element; - top.value = target.scrollTop; - left.value = target.scrollLeft; - }, 20); - - const target = computed(() => { - const target = isRef(t) ? t.value : t; - - if (target === null) { - return null; - } - - if ('$el' in target) { - return (target as ComponentPublicInstance).$el as Element; - } - - return target as Element; - }); - - onMounted(() => { - target.value?.addEventListener('scroll', onScroll, { passive: true }); - }); - - onUnmounted(() => { - target.value?.removeEventListener('scroll', onScroll); - }); - - return { top, left, target }; -} diff --git a/app/src/composables/use-shortcut/use-shortcut.ts b/app/src/composables/use-shortcut.ts similarity index 98% rename from app/src/composables/use-shortcut/use-shortcut.ts rename to app/src/composables/use-shortcut.ts index 620204fef0..0efc5a8f9d 100644 --- a/app/src/composables/use-shortcut/use-shortcut.ts +++ b/app/src/composables/use-shortcut.ts @@ -17,7 +17,7 @@ document.body.addEventListener('keyup', (event: KeyboardEvent) => { keysdown.clear(); }); -export default function useShortcut( +export function useShortcut( shortcuts: string | string[], handler: ShortcutHandler, reference: Ref | Ref = ref(document.body) diff --git a/app/src/composables/use-shortcut/index.ts b/app/src/composables/use-shortcut/index.ts deleted file mode 100644 index 88ab7e094f..0000000000 --- a/app/src/composables/use-shortcut/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import useShortcut from './use-shortcut'; - -export { useShortcut }; -export default useShortcut; diff --git a/app/src/composables/use-shortcut/readme.md b/app/src/composables/use-shortcut/readme.md deleted file mode 100644 index 3c91912d30..0000000000 --- a/app/src/composables/use-shortcut/readme.md +++ /dev/null @@ -1,27 +0,0 @@ -# `useShortcut` - -```ts -function useShortcut( - shortcut: string | string[], - handler: handler: (evt?: ExtendedKeyboardEvent, combo?: string) => void -): void -``` - -Can be used to attach a global keyboard shortcut to a function. Removes the shortcut once the current component unmounts - -## Usage - -```js -import { defineComponent } from 'vue'; -import { useShortcut } from '@/composables/use-shortcut'; - -export default defineComponent({ - setup(props) { - useShortcut('meta+s', save); - - function save() { - // ... - } - }, -}); -``` diff --git a/app/src/composables/size-class/size-class.ts b/app/src/composables/use-size-class.ts similarity index 86% rename from app/src/composables/size-class/size-class.ts rename to app/src/composables/use-size-class.ts index cb6468c4c3..228ae45983 100644 --- a/app/src/composables/size-class/size-class.ts +++ b/app/src/composables/use-size-class.ts @@ -26,7 +26,7 @@ interface RequiredProps { xLarge: boolean; } -export default function useSizeClass(props: T & RequiredProps): ComputedRef { +export function useSizeClass(props: T & RequiredProps): ComputedRef { const sizeClass = computed(() => { if (props.xSmall) return 'x-small'; if (props.small) return 'small'; diff --git a/app/src/composables/use-system.ts b/app/src/composables/use-system.ts index 2133d2c50e..3a6c862c10 100644 --- a/app/src/composables/use-system.ts +++ b/app/src/composables/use-system.ts @@ -1,6 +1,5 @@ import { provide } from 'vue'; import api from '@/api'; -import * as stores from '@/stores'; import { API_INJECT, EXTENSIONS_INJECT, STORES_INJECT } from '@directus/shared/constants'; import { getInterfaces } from '@/interfaces'; import { getDisplays } from '@/displays'; @@ -8,9 +7,38 @@ import { getLayouts } from '@/layouts'; import { getModules } from '@/modules'; import { getPanels } from '@/panels'; import { getOperations } from '@/operations'; +import { useAppStore } from '@/stores/app'; +import { useCollectionsStore } from '@/stores/collections'; +import { useFieldsStore } from '@/stores/fields'; +import { useInsightsStore } from '@/stores/insights'; +import { useLatencyStore } from '@/stores/latency'; +import { useNotificationsStore } from '@/stores/notifications'; +import { usePermissionsStore } from '@/stores/permissions'; +import { usePresetsStore } from '@/stores/presets'; +import { useRelationsStore } from '@/stores/relations'; +import { useRequestsStore } from '@/stores/requests'; +import { useServerStore } from '@/stores/server'; +import { useSettingsStore } from '@/stores/settings'; +import { useUserStore } from '@/stores/user'; +import { useFlowsStore } from '@/stores/flows'; -export default function useSystem(): void { - provide(STORES_INJECT, stores); +export function useSystem(): void { + provide(STORES_INJECT, { + useAppStore, + useCollectionsStore, + useFieldsStore, + useInsightsStore, + useLatencyStore, + useNotificationsStore, + usePermissionsStore, + usePresetsStore, + useRelationsStore, + useRequestsStore, + useServerStore, + useSettingsStore, + useUserStore, + useFlowsStore, + }); provide(API_INJECT, api); diff --git a/app/src/composables/use-template-data.ts b/app/src/composables/use-template-data.ts index 34f95a8ada..4914dd4a14 100644 --- a/app/src/composables/use-template-data.ts +++ b/app/src/composables/use-template-data.ts @@ -1,5 +1,5 @@ import api from '@/api'; -import { Collection } from '@/types'; +import { Collection } from '@/types/collections'; import { getFieldsFromTemplate } from '@directus/shared/utils'; import { computed, Ref, ref, watch } from 'vue'; @@ -9,10 +9,7 @@ type UsableTemplateData = { error: Ref; }; -export default function useTemplateData( - collection: Ref, - primaryKey: Ref -): UsableTemplateData { +export function useTemplateData(collection: Ref, primaryKey: Ref): UsableTemplateData { const templateData = ref>(); const loading = ref(false); const error = ref(null); diff --git a/app/src/composables/use-tfa-setup.ts b/app/src/composables/use-tfa-setup.ts index 89a3ebd844..a215995117 100644 --- a/app/src/composables/use-tfa-setup.ts +++ b/app/src/composables/use-tfa-setup.ts @@ -2,7 +2,7 @@ import api from '@/api'; import { nanoid } from 'nanoid'; import { onMounted, ref } from 'vue'; import qrcode from 'qrcode'; -import { useUserStore } from '@/stores'; +import { useUserStore } from '@/stores/user'; export function useTFASetup(initialEnabled: boolean) { const loading = ref(false); diff --git a/app/src/composables/use-time-from-now/use-time-from-now.ts b/app/src/composables/use-time-from-now.ts similarity index 67% rename from app/src/composables/use-time-from-now/use-time-from-now.ts rename to app/src/composables/use-time-from-now.ts index 40c124d6a6..47d0606988 100644 --- a/app/src/composables/use-time-from-now/use-time-from-now.ts +++ b/app/src/composables/use-time-from-now.ts @@ -1,7 +1,7 @@ -import localizedFormatDistance from '@/utils/localized-format-distance/'; +import { localizedFormatDistance } from '@/utils/localized-format-distance/'; import { onMounted, onUnmounted, Ref, ref } from 'vue'; -export async function useTimeFromNow(date: Date | number, autoUpdate = 60000): Promise> { +export function useTimeFromNow(date: Date | number, autoUpdate = 60000): Ref { let interval: number; const formatOptions = { @@ -12,7 +12,7 @@ export async function useTimeFromNow(date: Date | number, autoUpdate = 60000): P if (autoUpdate !== 0) { onMounted(() => { - interval = window.setInterval(async () => { + interval = window.setInterval(() => { formattedDate.value = localizedFormatDistance(date, new Date(), formatOptions); }, autoUpdate); }); diff --git a/app/src/composables/use-time-from-now/index.ts b/app/src/composables/use-time-from-now/index.ts deleted file mode 100644 index 1e5c898b5c..0000000000 --- a/app/src/composables/use-time-from-now/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { useTimeFromNow } from './use-time-from-now'; - -export { useTimeFromNow }; -export default useTimeFromNow; diff --git a/app/src/composables/use-time-from-now/readme.md b/app/src/composables/use-time-from-now/readme.md deleted file mode 100644 index 75ea19efb1..0000000000 --- a/app/src/composables/use-time-from-now/readme.md +++ /dev/null @@ -1,21 +0,0 @@ -# `useTimeFromNow` - -```ts -function useTimeFromNow(date: Date | number, autoUpdate: number = 60000): Ref; -``` - -Composable that can be used to create a relative time format that is auto updated every `autoUpdate` milliseconds. - -## Usage - -```js -import { defineComponent } from 'vue'; -import { useTimeFromNow } from '@/composables/use-time-from-now'; - -export default defineComponent({ - setup(props) { - const timeFromNow = useTimeFromNow(Date.now()); - return { timeFromNow }; - }, -}); -``` diff --git a/app/src/composables/use-title/use-title.ts b/app/src/composables/use-title.ts similarity index 100% rename from app/src/composables/use-title/use-title.ts rename to app/src/composables/use-title.ts diff --git a/app/src/composables/use-title/index.ts b/app/src/composables/use-title/index.ts deleted file mode 100644 index 122f3049bb..0000000000 --- a/app/src/composables/use-title/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { useTitle } from './use-title'; - -export { useTitle }; -export default useTitle; diff --git a/app/src/composables/use-translation-strings.ts b/app/src/composables/use-translation-strings.ts index 3704c6f8bd..d61250bbef 100644 --- a/app/src/composables/use-translation-strings.ts +++ b/app/src/composables/use-translation-strings.ts @@ -2,7 +2,7 @@ import { ref, Ref } from 'vue'; import api from '@/api'; import { unexpectedError } from '@/utils/unexpected-error'; import { Language, i18n } from '@/lang'; -import { useUserStore } from '@/stores'; +import { useUserStore } from '@/stores/user'; export type Translation = { language: string; diff --git a/app/src/composables/use-window-size/use-window-size.ts b/app/src/composables/use-window-size.ts similarity index 87% rename from app/src/composables/use-window-size/use-window-size.ts rename to app/src/composables/use-window-size.ts index 5193eb6144..33c3d09281 100644 --- a/app/src/composables/use-window-size/use-window-size.ts +++ b/app/src/composables/use-window-size.ts @@ -5,7 +5,7 @@ type WindowSizeOptions = { throttle: number; }; -export default function useWindowSize(options: WindowSizeOptions = { throttle: 100 }): { +export function useWindowSize(options: WindowSizeOptions = { throttle: 100 }): { width: Ref; height: Ref; } { diff --git a/app/src/composables/use-window-size/index.ts b/app/src/composables/use-window-size/index.ts deleted file mode 100644 index b6fdd674f2..0000000000 --- a/app/src/composables/use-window-size/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import useWindowSize from './use-window-size'; - -export { useWindowSize }; -export default useWindowSize; diff --git a/app/src/composables/use-window-size/readme.md b/app/src/composables/use-window-size/readme.md deleted file mode 100644 index 67a9231b97..0000000000 --- a/app/src/composables/use-window-size/readme.md +++ /dev/null @@ -1,22 +0,0 @@ -# `useWindowSize` - -```ts -function useWindowSize(options: WindowSizeOptions = { throttle: 100 }): { width: Ref; height: Ref }; -``` - -Returns the window's width and height in an object. These values are reactive. - -The optional `options` parameter allows you to set the throttling speed. - -## Usage - -```js -import { defineComponent } from 'vue'; -import { useWindowSize } from '@/composables/use-window-size/'; - -export default defineComponent({ - setup(props) { - const { width, height } = useWindowSize(); - }, -}); -``` diff --git a/app/src/directives/click-outside/click-outside.ts b/app/src/directives/click-outside.ts similarity index 100% rename from app/src/directives/click-outside/click-outside.ts rename to app/src/directives/click-outside.ts diff --git a/app/src/directives/click-outside/index.ts b/app/src/directives/click-outside/index.ts deleted file mode 100644 index d8a51ac39c..0000000000 --- a/app/src/directives/click-outside/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import ClickOutside from './click-outside'; - -export { ClickOutside }; -export default ClickOutside; diff --git a/app/src/directives/click-outside/readme.md b/app/src/directives/click-outside/readme.md deleted file mode 100644 index 2621dc96af..0000000000 --- a/app/src/directives/click-outside/readme.md +++ /dev/null @@ -1,37 +0,0 @@ -# Click Outside - -Adds a handler when clicking outside the element. - -## Usage: - -```html - -``` - -For more control, you can pass an option with the following properties: - -```html - -``` - -### Options - -| Name | Description | Type | Default | -| ------------ | --------------------------------------------------------- | --------------------------- | ----------------- | -| `handler` | Function that is fired when the event is triggered | `(event: Event) => void` | `() => undefined` | -| `middleware` | Function that allows you to dynamically fire the handler. | `(event: Event) => boolean` | `() => true` | -| `events` | Array of individual events that the directive triggers on | `string[]` | `['pointerdown']` | -| `disabled` | Disable the directive completely | `boolean` | `false` | diff --git a/app/src/directives/context-menu/context-menu.ts b/app/src/directives/context-menu.ts similarity index 100% rename from app/src/directives/context-menu/context-menu.ts rename to app/src/directives/context-menu.ts diff --git a/app/src/directives/context-menu/index.ts b/app/src/directives/context-menu/index.ts deleted file mode 100644 index e291c8b125..0000000000 --- a/app/src/directives/context-menu/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import ContextMenu from './context-menu'; - -export { ContextMenu }; -export default ContextMenu; diff --git a/app/src/directives/context-menu/readme.md b/app/src/directives/context-menu/readme.md deleted file mode 100644 index 7170ec7582..0000000000 --- a/app/src/directives/context-menu/readme.md +++ /dev/null @@ -1,18 +0,0 @@ -# Context Menu - -## Usage - -This allows the element to open a context menu with the specified ref. It adds `contextmenu` event (right click) to -activate/open the context menu, and `pointerdown` event on document to deactivate/close when it's not the event target. - -```html - -``` - -Somewhere in the same component: - -```html - - - -``` diff --git a/app/src/directives/focus/focus.ts b/app/src/directives/focus.ts similarity index 100% rename from app/src/directives/focus/focus.ts rename to app/src/directives/focus.ts diff --git a/app/src/directives/focus/readme.md b/app/src/directives/focus/readme.md deleted file mode 100644 index 0c5a2158ca..0000000000 --- a/app/src/directives/focus/readme.md +++ /dev/null @@ -1,17 +0,0 @@ -# Focus - -The focus directive is basically `autofocus`, but works in Vue. Because of the way HTML works, `autofocus` isn't -triggered for DOM elements that are added after first load, which means that `autofocus` basically never works in the -context of the Directus app. That's where you can use `v-focus` instead: - -```html - -``` - -## Value - -You can pass it a boolean value if you need more fine grained control over when focus is set: - -```html - -``` diff --git a/app/src/directives/readme.md b/app/src/directives/readme.md deleted file mode 100644 index 92147936f9..0000000000 --- a/app/src/directives/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -# Directives - -Directives are functions that are available on Vue components in templates. For example `v-focus` or -`v-tooltip="'Hello world!'` diff --git a/app/src/directives/register.ts b/app/src/directives/register.ts index 745d143cb8..61e9049703 100644 --- a/app/src/directives/register.ts +++ b/app/src/directives/register.ts @@ -1,8 +1,8 @@ import { App } from 'vue'; -import ClickOutside from './click-outside/click-outside'; -import ContextMenu from './context-menu/context-menu'; -import Focus from './focus/focus'; -import Tooltip from './tooltip/tooltip'; +import ClickOutside from './click-outside'; +import ContextMenu from './context-menu'; +import Focus from './focus'; +import Tooltip from './tooltip'; import Markdown from './markdown'; export function registerDirectives(app: App): void { diff --git a/app/src/directives/tooltip/tooltip.ts b/app/src/directives/tooltip.ts similarity index 100% rename from app/src/directives/tooltip/tooltip.ts rename to app/src/directives/tooltip.ts diff --git a/app/src/directives/tooltip/index.ts b/app/src/directives/tooltip/index.ts deleted file mode 100644 index bba5e6fcfa..0000000000 --- a/app/src/directives/tooltip/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import Tooltip from './tooltip'; - -export { Tooltip }; -export default Tooltip; diff --git a/app/src/directives/tooltip/readme.md b/app/src/directives/tooltip/readme.md deleted file mode 100644 index 107fb2e931..0000000000 --- a/app/src/directives/tooltip/readme.md +++ /dev/null @@ -1,22 +0,0 @@ -# Tooltip - -The tooltip can display more detailed information about an element to clarify its use. - -```html -This is a button -``` - -## Options - -The tooltip is displayed at the bottom of an element by default. - -| Option | Description | -| ---------- | ----------------------------------------------- | -| `left` | Display the tooltip to the left of the element | -| `right` | Display the tooltip to the right of the element | -| `top` | Display the tooltip on top of the element | -| `bottom` | Display the tooltip on bottom of the element | -| `start` | Places the tooltip at the start of the element | -| `end` | Places the tooltip at the end of the element | -| `instant` | Shows the tooltip instantly on hover | -| `inverted` | Inverts all colors | diff --git a/app/src/displays/collection/index.ts b/app/src/displays/collection/index.ts index 54baa9c1ca..4b7ca895fe 100644 --- a/app/src/displays/collection/index.ts +++ b/app/src/displays/collection/index.ts @@ -1,6 +1,6 @@ import { defineDisplay } from '@directus/shared/utils'; import DisplayCollection from './collection.vue'; -import { useCollectionsStore } from '@/stores'; +import { useCollectionsStore } from '@/stores/collections'; export default defineDisplay({ id: 'collection', diff --git a/app/src/displays/color/color.vue b/app/src/displays/color/color.vue index 809a11ad22..beb3e12a7c 100644 --- a/app/src/displays/color/color.vue +++ b/app/src/displays/color/color.vue @@ -8,7 +8,7 @@ diff --git a/app/src/views/private/components/image-editor/index.ts b/app/src/views/private/components/image-editor/index.ts deleted file mode 100644 index f97f64ff0a..0000000000 --- a/app/src/views/private/components/image-editor/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import ImageEditor from './image-editor.vue'; - -export { ImageEditor }; -export default ImageEditor; diff --git a/app/src/views/private/components/latency-indicator/latency-indicator.vue b/app/src/views/private/components/latency-indicator.vue similarity index 97% rename from app/src/views/private/components/latency-indicator/latency-indicator.vue rename to app/src/views/private/components/latency-indicator.vue index 74e1bdea4b..c7f081cf25 100644 --- a/app/src/views/private/components/latency-indicator/latency-indicator.vue +++ b/app/src/views/private/components/latency-indicator.vue @@ -8,7 +8,7 @@