Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation';
@customElement('umb-input-content-type-collection-configuration')
export class UmbInputContentTypeCollectionConfigurationElement extends UmbFormControlMixin<
string,
typeof UmbLitElement
typeof UmbLitElement,
undefined
>(UmbLitElement) {
protected override getFormElement() {
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class UmbMediaTypeWorkspaceViewStructureElement extends UmbLitElement imp
const oldValue = this._allowedContentTypeIDs;
this._allowedContentTypeIDs = allowedContentTypes
?.map((x) => x.contentType.unique)
.filter((x) => x !== undefined) as Array<string>;
.filter((x) => x !== undefined);
this.requestUpdate('_allowedContentTypeIDs', oldValue);
},
'_allowedContentTypesObserver',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { UmbMediaTreeItemModel } from '../../tree/types.js';
import { isMediaTreeItem } from '../../tree/utils.js';
import { UmbPickerInputContext } from '@umbraco-cms/backoffice/picker-input';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import type { UmbMediaTypeEntityType } from '@umbraco-cms/backoffice/media-type';
import { isUmbracoFolder, type UmbMediaTypeEntityType } from '@umbraco-cms/backoffice/media-type';
import { UMB_VARIANT_CONTEXT } from '@umbraco-cms/backoffice/variant';

interface UmbMediaPickerInputContextOpenArgs {
Expand Down Expand Up @@ -63,6 +63,10 @@ export class UmbMediaPickerInputContext extends UmbPickerInputContext<
if (isMediaTreeItem(item) && item.noAccess) {
return false;
}
// Exclude folders - they don't have URLs
if (isUmbracoFolder(item.mediaType.unique)) {
return false;
}
if (allowedContentTypes && allowedContentTypes.length > 0) {
return allowedContentTypes
.map((contentTypeReference) => contentTypeReference.unique)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class UmbInputMediaElement extends UmbFormControlMixin<string | undefined
}

@property({ type: Array })
allowedContentTypeIds?: Array<string> | undefined;
allowedContentTypeIds?: Array<string>;

@property({ type: Boolean, attribute: 'include-trashed' })
includeTrashed = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class UmbInputRichMediaElement extends UmbFormControlMixin<
}

@property({ type: Array })
allowedContentTypeIds?: string[] | undefined;
allowedContentTypeIds?: string[];

@property({ type: Object, attribute: false })
startNode?: UmbTreeStartNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class UmbPropertyEditorUIMediaPickerElement

if (!config) return;

this._allowedMediaTypes = config.getValueByAlias<string>('filter')?.split(',') ?? [];
this._allowedMediaTypes = config.getValueByAlias<string>('filter')?.split(',') ?? undefined;
this._focalPointEnabled = Boolean(config.getValueByAlias('enableLocalFocalPoint'));
this._multiple = Boolean(config.getValueByAlias('multiple'));
this._preselectedCrops = config?.getValueByAlias<Array<UmbCropModel>>('crops') ?? [];
Expand Down Expand Up @@ -71,7 +71,7 @@ export class UmbPropertyEditorUIMediaPickerElement
private _preselectedCrops: Array<UmbCropModel> = [];

@state()
private _allowedMediaTypes: Array<string> = [];
private _allowedMediaTypes?: Array<string>;

@state()
private _multiple: boolean = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ export class UmbInputMemberGroupElement extends UmbFormControlMixin<string, type
return this.#pickerContext.getSelection();
}

@property({ type: Array })
allowedContentTypeIds?: string[] | undefined;

@property({ type: String })
public override set value(selectionString: string | undefined) {
this.selection = splitStringToArray(selectionString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class UmbInputMemberElement extends UmbFormControlMixin<string, typeof Um
}

@property({ type: Array })
allowedContentTypeIds?: string[] | undefined;
allowedContentTypeIds?: string[];

@property({ type: String })
public override set value(selectionString: string | undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type {
UmbLinkPickerModalValue,
} from './link-picker-modal.token.js';
import { css, customElement, html, nothing, query, state, when } from '@umbraco-cms/backoffice/external/lit';
import { isUmbracoFolder, UmbMediaTypeStructureRepository } from '@umbraco-cms/backoffice/media-type';
import {
umbBindToValidation,
UmbObserveValidationStateController,
Expand All @@ -32,9 +31,6 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement<UmbLinkPicker

#validationContext = new UmbValidationContext(this);

@state()
private _allowedMediaTypeUniques?: Array<string>;

@state()
private _config: UmbLinkPickerConfig = {
hideAnchor: false,
Expand Down Expand Up @@ -73,18 +69,9 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement<UmbLinkPicker
});
}

this.#getMediaTypes();
this.populateLinkUrl();
}

async #getMediaTypes() {
// Get all the media types, excluding the folders, so that files are selectable media items.
const mediaTypeStructureRepository = new UmbMediaTypeStructureRepository(this);
const { data: mediaTypes } = await mediaTypeStructureRepository.requestAllowedChildrenOf(null, null);
this._allowedMediaTypeUniques =
(mediaTypes?.items.map((x) => x.unique).filter((x) => x && !isUmbracoFolder(x)) as Array<string>) ?? [];
}

async populateLinkUrl() {
// Documents and media have URLs saved in the local link format. Display the actual URL to align with what
// the user sees when they selected it initially.
Expand Down Expand Up @@ -353,7 +340,6 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement<UmbLinkPicker
label=${this.localize.term('general_media')}>
<umb-input-media
slot="editor"
.allowedContentTypeIds=${this._allowedMediaTypeUniques}
.max=${1}
.value=${this.value.link.unique && this.value.link.type === 'media' ? this.value.link.unique : ''}
@change=${(e: UmbInputPickerEvent) => this.#onPickerSelection(e, 'media')}></umb-input-media>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export class UmbInputContentElement extends UmbFormControlMixin<string | undefin
startNode?: UmbTreeStartNode;

@property()
public set allowedContentTypeIds(value: string) {
this.#allowedContentTypeIds = value ? value.split(',') : [];
public set allowedContentTypeIds(value: string | undefined) {
this.#allowedContentTypeIds = value ? value.split(',') : undefined;
}
public get allowedContentTypeIds(): string {
return this.#allowedContentTypeIds.join(',');
public get allowedContentTypeIds(): string | undefined {
return this.#allowedContentTypeIds?.join(',');
}
#allowedContentTypeIds: Array<string> = [];
#allowedContentTypeIds?: Array<string>;

@property({ type: Array })
public set selection(values: Array<UmbReferenceByUniqueAndType>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class UmbPropertyEditorUIContentPickerElement
private _maxMessage = '';

@state()
private _allowedContentTypeUniques?: string | null;
private _allowedContentTypeUniques?: string;

@state()
private _rootUnique?: string | null;
Expand Down Expand Up @@ -208,7 +208,7 @@ export class UmbPropertyEditorUIContentPickerElement
.max=${this._max}
.maxMessage=${this._maxMessage}
.startNode=${startNode}
.allowedContentTypeIds=${this._allowedContentTypeUniques ?? ''}
.allowedContentTypeIds=${this._allowedContentTypeUniques}
?readonly=${this.readonly}
?required=${this.mandatory}
.requiredMessage=${this.mandatoryMessage}
Expand Down
Loading