mirror of
https://github.com/directus/directus.git
synced 2026-02-11 09:55:06 -05:00
Add support for a package extension bundle type (#15672)
* Add bundle type to constants and types * Add support for API bundle extensions * Rename generateExtensionsEntry to generateExtensionsEntrypoint * Add support for App bundle extensions * Refactor App extension registration * Replace extensions inject with useExtensions() * Replace getInterfaces() with useExtensions() * Replace getDisplays() with useExtensions() * Replace getLayouts() with useExtensions() * Replace getModules() with useExtensions() * Replace getPanels() with useExtensions() * Replace getOperations() with useExtensions() * Add useExtension() composable * Replace useExtensions() with useExtension() where applicable * Remove interface getters * Remove display getters * Remove layout getters * Remove module getter * Remove panel getters * Remove operation getters * Rename extension register.ts files to index.ts * Perform module pre register check in parallel * Remove Refs from AppExtensionConfigs type * Remove old extension shims * Ensure registration of modules is awaited when hydrating * Add support for scaffolding package extensions * Add support for building bundle extensions * Add JsonValue type * Use json for complex command line flags * Load internal extensions if custom ones are not available * Fix extension manifest validation for pack extensions * Fix tests in shared * Add SplitEntrypoint type * Move command specific utils to helpers * Add SDK version getter * Move extension dev deps generation to helpers * Move template path to getter util * Move template copying to a helper * Only rename copied template files * Add directus-extension add command * Convert provided extension source path to url * Replace deprecated import.meta.globEager * Mock URL.createObjectURL to make App unit tests pass * Update rollup-plugin-typescript2 * indentation * sort vite glob imported modules * fix unintentional wrong commit * Simplify app extension import logic * reinstall @rollup/plugin-virtual * add test for getInterfaces() expected sort order Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com> Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
0859102a61
commit
7bf90efa62
@@ -1,6 +1,7 @@
|
||||
import { getDisplay } from '@/displays';
|
||||
import { useExtension } from '@/composables/use-extension';
|
||||
import { useFieldsStore } from '@/stores/fields';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { computed } from 'vue';
|
||||
|
||||
export function adjustFieldsForDisplays(fields: readonly string[], parentCollection: string): string[] {
|
||||
const fieldsStore = useFieldsStore();
|
||||
@@ -12,19 +13,22 @@ export function adjustFieldsForDisplays(fields: readonly string[], parentCollect
|
||||
if (!field) return fieldKey;
|
||||
if (field.meta?.display === null) return fieldKey;
|
||||
|
||||
const display = getDisplay(field.meta?.display);
|
||||
const display = useExtension(
|
||||
'display',
|
||||
computed(() => field.meta?.display ?? null)
|
||||
);
|
||||
|
||||
if (!display) return fieldKey;
|
||||
if (!display?.fields) return fieldKey;
|
||||
if (!display.value?.fields) return fieldKey;
|
||||
|
||||
let fieldKeys: string[] | null = null;
|
||||
|
||||
if (Array.isArray(display.fields)) {
|
||||
fieldKeys = display.fields.map((relatedFieldKey: string) => `${fieldKey}.${relatedFieldKey}`);
|
||||
if (Array.isArray(display.value.fields)) {
|
||||
fieldKeys = display.value.fields.map((relatedFieldKey: string) => `${fieldKey}.${relatedFieldKey}`);
|
||||
}
|
||||
|
||||
if (typeof display.fields === 'function') {
|
||||
fieldKeys = display
|
||||
if (typeof display.value.fields === 'function') {
|
||||
fieldKeys = display.value
|
||||
.fields(field.meta?.display_options, {
|
||||
collection: field.collection,
|
||||
field: field.field,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useAliasFields } from '@/composables/use-alias-fields';
|
||||
import { getDisplay } from '@/displays';
|
||||
import { useFieldsStore } from '@/stores/fields';
|
||||
import { DisplayConfig, Field } from '@directus/shared/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import { render, renderFn } from 'micromustache';
|
||||
import { computed, ComputedRef, Ref, ref, unref } from 'vue';
|
||||
import { get, set } from 'lodash';
|
||||
import { useExtension } from '@/composables/use-extension';
|
||||
|
||||
type StringTemplate = {
|
||||
fieldsInTemplate: ComputedRef<string[]>;
|
||||
@@ -77,18 +77,17 @@ export function renderDisplayStringTemplate(
|
||||
? get(item, key)
|
||||
: get(item, aliasFields.value[key].fullAlias);
|
||||
|
||||
let display: DisplayConfig | undefined;
|
||||
|
||||
if (fieldsUsed[key]?.meta?.display) {
|
||||
display = getDisplay(fieldsUsed[key]!.meta!.display);
|
||||
}
|
||||
const display = useExtension(
|
||||
'display',
|
||||
computed(() => fieldsUsed[key]?.meta?.display ?? null)
|
||||
);
|
||||
|
||||
if (value !== undefined && value !== null) {
|
||||
set(
|
||||
parsedItem,
|
||||
key,
|
||||
display?.handler
|
||||
? display.handler(value, fieldsUsed[key]?.meta?.display_options ?? {}, {
|
||||
display.value?.handler
|
||||
? display.value.handler(value, fieldsUsed[key]?.meta?.display_options ?? {}, {
|
||||
interfaceOptions: fieldsUsed[key]?.meta?.options ?? {},
|
||||
field: fieldsUsed[key] ?? undefined,
|
||||
collection: collection,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useAliasFields } from '@/composables/use-alias-fields';
|
||||
import { getDisplay } from '@/displays';
|
||||
import { useFieldsStore } from '@/stores/fields';
|
||||
import { get } from '@directus/shared/utils';
|
||||
import { DisplayConfig, Field, Item } from '@directus/shared/types';
|
||||
import { Field, Item } from '@directus/shared/types';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { parse } from 'json2csv';
|
||||
import { ref } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useExtension } from '@/composables/use-extension';
|
||||
|
||||
/**
|
||||
* Saves the given collection + items combination as a CSV file
|
||||
@@ -48,15 +48,14 @@ export async function saveAsCSV(collection: string, fields: string[], items: Ite
|
||||
? get(item, key)
|
||||
: get(item, aliasFields.value[key].fullAlias);
|
||||
|
||||
let display: DisplayConfig | undefined;
|
||||
|
||||
if (fieldsUsed[key]?.meta?.display) {
|
||||
display = getDisplay(fieldsUsed[key]!.meta!.display);
|
||||
}
|
||||
const display = useExtension(
|
||||
'display',
|
||||
computed(() => fieldsUsed[key]?.meta?.display ?? null)
|
||||
);
|
||||
|
||||
if (value !== undefined && value !== null) {
|
||||
parsedItem[name] = display?.handler
|
||||
? await display.handler(value, fieldsUsed[key]?.meta?.display_options ?? {}, {
|
||||
parsedItem[name] = display.value?.handler
|
||||
? await display.value.handler(value, fieldsUsed[key]?.meta?.display_options ?? {}, {
|
||||
interfaceOptions: fieldsUsed[key]?.meta?.options ?? {},
|
||||
field: fieldsUsed[key] ?? undefined,
|
||||
collection: collection,
|
||||
|
||||
Reference in New Issue
Block a user