final TS corrections

This commit is contained in:
Niels Lyngsø
2023-12-05 21:25:44 +01:00
parent dbe7f7cc5d
commit 5859fcfd81
22 changed files with 121 additions and 114 deletions

View File

@@ -1,13 +1,15 @@
import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
export type UmbExamineFieldsSettingsModalData = Array<{
export type UmbExamineFieldsSettingsModalData = never;
type FieldSettingsType = {
name: string;
exposed: boolean;
}>;
};
export interface UmbExamineFieldsSettingsModalValue {
fields?: UmbExamineFieldsSettingsModalData;
}
export type UmbExamineFieldsSettingsModalValue = {
fields: Array<FieldSettingsType>;
};
export const UMB_EXAMINE_FIELDS_SETTINGS_MODAL = new UmbModalToken<
UmbExamineFieldsSettingsModalData,

View File

@@ -75,10 +75,12 @@ export class UmbInputDocumentGranularPermissionElement extends FormControlMixin(
async #removeItem(item: DocumentItemResponseModel) {
const modalContext = this.#modalContext?.open(UMB_CONFIRM_MODAL, {
color: 'danger',
headline: `Remove ${item.name}?`,
content: 'Are you sure you want to remove this item',
confirmLabel: 'Remove',
data: {
color: 'danger',
headline: `Remove ${item.name}?`,
content: 'Are you sure you want to remove this item',
confirmLabel: 'Remove',
},
});
await modalContext?.onSubmit();

View File

@@ -27,7 +27,9 @@ export class UmbCreateDocumentEntityAction extends UmbEntityActionBase<UmbDocume
// TODO: what to do if modal service is not available?
if (!this.#modalContext) return;
const modalContext = this.#modalContext.open(UMB_CREATE_DOCUMENT_MODAL, {
id,
data: {
id,
},
});
const { documentTypeId: documentTypeKey } = await modalContext.onSubmit();

View File

@@ -113,10 +113,12 @@ export class UmbPermissionsModalElement extends UmbLitElement {
const userGroupRef = this._userGroupRefs.find((userGroup) => userGroup.id == id);
const modalContext = this.#modalManagerContext?.open(UMB_ENTITY_USER_PERMISSION_MODAL, {
unique: id,
entityType: this.data.entityType,
allowedPermissions: userGroupRef?.permissions || [],
headline: `Permissions for ${userGroupRef?.name}`,
data: {
unique: id,
entityType: this.data.entityType,
allowedPermissions: userGroupRef?.permissions || [],
headline: `Permissions for ${userGroupRef?.name}`,
},
});
modalContext?.onSubmit().then((value) => {

View File

@@ -23,8 +23,10 @@ export class UmbDocumentPermissionsEntityAction extends UmbEntityActionBase<UmbD
if (!this.#modalManagerContext) return;
this.#modalManagerContext.open(UMB_PERMISSIONS_MODAL, {
unique: this.unique,
entityType: 'document',
data: {
unique: this.unique,
entityType: 'document',
},
});
}
}

View File

@@ -105,7 +105,7 @@ export class UmbDocumentInfoWorkspaceViewElement extends UmbLitElement {
new UmbModalRouteRegistrationController(this, UMB_WORKSPACE_MODAL)
.addAdditionalPath('document-type')
.onSetup(() => {
return { entityType: 'document-type', preset: {} };
return { data: { entityType: 'document-type', preset: {} } };
})
.observeRouteBuilder((routeBuilder) => {
this._editDocumentTypePath = routeBuilder({});

View File

@@ -132,7 +132,9 @@ export class UmbLogViewerSearchInputElement extends UmbLitElement {
}
#openSaveSearchDialog() {
this.modalContext = this._modalContext?.open(UMB_LOG_VIEWER_SAVE_SEARCH_MODAL, { query: this._inputQuery });
this.modalContext = this._modalContext?.open(UMB_LOG_VIEWER_SAVE_SEARCH_MODAL, {
data: { query: this._inputQuery },
});
this.modalContext?.onSubmit().then((savedSearch) => {
if (savedSearch) {
this.#saveSearch(savedSearch);

View File

@@ -20,7 +20,9 @@ export class UmbCreateMediaTypeEntityAction extends UmbEntityActionBase<UmbMedia
if (!this.repository) throw new Error('Repository is not available');
this.#modalManagerContext?.open(UMB_MEDIA_TYPE_CREATE_OPTIONS_MODAL, {
parentKey: this.unique,
data: {
parentKey: this.unique,
},
});
}
}

View File

@@ -30,7 +30,9 @@ export class UmbDataTypeCreateOptionsModalElement extends UmbLitElement {
#onClick(event: PointerEvent) {
event.stopPropagation();
const folderModalHandler = this.#modalContext?.open(UMB_FOLDER_MODAL, {
repositoryAlias: UMB_MEDIA_TYPE_DETAIL_REPOSITORY_ALIAS,
data: {
repositoryAlias: UMB_MEDIA_TYPE_DETAIL_REPOSITORY_ALIAS,
},
});
folderModalHandler?.onSubmit().then(() => this.modalContext?.submit());
}

View File

@@ -92,7 +92,7 @@ export class UmbMediaTypeWorkspacePropertyElement extends UmbLitElement {
if (mediaTypeId === undefined) return false;
const propertyData = this.property;
if (propertyData === undefined) return false;
return { propertyData, documentTypeId: mediaTypeId }; //TODO: Should we have a separate modal for mediaTypes?
return { data: { documentTypeId: mediaTypeId }, value: propertyData }; //TODO: Should we have a separate modal for mediaTypes?
})
.onSubmit((result) => {
this._partialUpdate(result);
@@ -104,7 +104,7 @@ export class UmbMediaTypeWorkspacePropertyElement extends UmbLitElement {
new UmbModalRouteRegistrationController(this, UMB_WORKSPACE_MODAL)
.addAdditionalPath('media-type')
.onSetup(() => {
return { entityType: 'media-type', preset: {} };
return { data: { entityType: 'media-type', preset: {} } };
})
.observeRouteBuilder((routeBuilder) => {
this._editMediaTypePath = routeBuilder({});
@@ -138,7 +138,7 @@ export class UmbMediaTypeWorkspacePropertyElement extends UmbLitElement {
e.stopImmediatePropagation();
if (!this.property || !this.property.id) return;
const Message: UmbConfirmModalData = {
const modalData: UmbConfirmModalData = {
headline: `${this.localize.term('actions_delete')} property`,
content: html`<umb-localize key="contentTypeEditor_confirmDeletePropertyMessage" .args=${[
this.property.name || this.property.id,
@@ -150,7 +150,7 @@ export class UmbMediaTypeWorkspacePropertyElement extends UmbLitElement {
color: 'danger',
};
const modalHandler = this._modalManagerContext?.open(UMB_CONFIRM_MODAL, Message);
const modalHandler = this._modalManagerContext?.open(UMB_CONFIRM_MODAL, { data: modalData });
modalHandler
?.onSubmit()

View File

@@ -186,7 +186,7 @@ export class UmbMediaTypeWorkspaceViewEditElement extends UmbLitElement implemen
}
#requestRemoveTab(tab: PropertyTypeContainerModelBaseModel | undefined) {
const Message: UmbConfirmModalData = {
const modalData: UmbConfirmModalData = {
headline: 'Delete tab',
content: html`<umb-localize key="contentTypeEditor_confirmDeleteTabMessage" .args=${[tab?.name ?? tab?.id]}>
Are you sure you want to delete the tab <strong>${tab?.name ?? tab?.id}</strong>
@@ -202,7 +202,7 @@ export class UmbMediaTypeWorkspaceViewEditElement extends UmbLitElement implemen
// TODO: If this tab is composed of other tabs, then notify that it will only delete the local tab.
const modalHandler = this._modalManagerContext?.open(UMB_CONFIRM_MODAL, Message);
const modalHandler = this._modalManagerContext?.open(UMB_CONFIRM_MODAL, { data: modalData });
modalHandler?.onSubmit().then(() => {
this.#remove(tab?.id);

View File

@@ -109,10 +109,12 @@ export class UmbPackagesCreatedOverviewElement extends UmbLitElement {
async #deletePackage(p: PackageDefinitionResponseModel) {
if (!p.id) return;
const modalContext = this._modalContext?.open(UMB_CONFIRM_MODAL, {
color: 'danger',
headline: `Remove ${p.name}?`,
content: 'Are you sure you want to delete this package',
confirmLabel: 'Delete',
data: {
color: 'danger',
headline: `Remove ${p.name}?`,
content: 'Are you sure you want to delete this package',
confirmLabel: 'Delete',
},
});
await modalContext?.onSubmit();

View File

@@ -78,10 +78,12 @@ export class UmbInstalledPackagesSectionViewItemElement extends UmbLitElement {
async _onMigration() {
if (!this.name) return;
const modalContext = this.#modalContext?.open(UMB_CONFIRM_MODAL, {
color: 'positive',
headline: `Run migrations for ${this.name}?`,
content: `Do you want to start run migrations for ${this.name}`,
confirmLabel: 'Run migrations',
data: {
color: 'positive',
headline: `Run migrations for ${this.name}?`,
content: `Do you want to start run migrations for ${this.name}`,
confirmLabel: 'Run migrations',
},
});
await modalContext?.onSubmit();

View File

@@ -1,61 +1,42 @@
import { html, css, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { html, css, customElement } from '@umbraco-cms/backoffice/external/lit';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import {
UmbExamineFieldsSettingsModalValue,
UmbExamineFieldsSettingsModalData,
UmbModalBaseElement,
} from '@umbraco-cms/backoffice/modal';
import { ManifestModal, UmbModalExtensionElement } from '@umbraco-cms/backoffice/extension-registry';
@customElement('umb-examine-fields-settings-modal')
export default class UmbExamineFieldsSettingsModalElement
extends UmbModalBaseElement<UmbExamineFieldsSettingsModalData, UmbExamineFieldsSettingsModalValue>
implements UmbModalExtensionElement<any, any, ManifestModal>
{
@state()
private _fields?: UmbExamineFieldsSettingsModalData;
private _handleClose() {
this._value = { fields: this._fields };
this.modalContext?.submit();
}
disconnectedCallback(): void {
super.disconnectedCallback();
this._handleClose();
}
firstUpdated() {
this._fields =
this.data?.map((field) => {
return { name: field.name, exposed: field.exposed };
}) || undefined;
}
export default class UmbExamineFieldsSettingsModalElement extends UmbModalBaseElement<
UmbExamineFieldsSettingsModalData,
UmbExamineFieldsSettingsModalValue
> {
render() {
if (this._fields) {
if (this._value.fields) {
return html`
<uui-dialog-layout headline="Show fields">
<uui-scroll-container id="field-settings">
<span>
${Object.values(this._fields).map((field, index) => {
${Object.values(this._value.fields).map((field, index) => {
return html`<uui-toggle
name="${field.name}"
label="${field.name}"
.checked="${field.exposed}"
@change="${() => {
this._fields ? (this._fields[index].exposed = !field.exposed) : '';
this._value.fields ? (this._value.fields[index].exposed = !field.exposed) : '';
}}"></uui-toggle>
<br />`;
})}
</span>
</uui-scroll-container>
<div>
<uui-button look="primary" label="Close sidebar" @click="${this._handleClose}">Close</uui-button>
<uui-button look="primary" label="Close sidebar" @click="${this._submitModal}">Close</uui-button>
</div>
</uui-dialog-layout>
`;
} else return html``;
} else {
return '';
}
}
static styles = [

View File

@@ -58,15 +58,17 @@ export class UmbDashboardExamineIndexElement extends UmbLitElement {
private async _onRebuildHandler() {
const modalContext = this._modalContext?.open(UMB_CONFIRM_MODAL, {
headline: `Rebuild ${this.indexName}`,
content: html`
This will cause the index to be rebuilt.<br />
Depending on how much content there is in your site this could take a while.<br />
It is not recommended to rebuild an index during times of high website traffic or when editors are editing
content.
`,
color: 'danger',
confirmLabel: 'Rebuild',
data: {
headline: `Rebuild ${this.indexName}`,
content: html`
This will cause the index to be rebuilt.<br />
Depending on how much content there is in your site this could take a while.<br />
It is not recommended to rebuild an index during times of high website traffic or when editors are editing
content.
`,
color: 'danger',
confirmLabel: 'Rebuild',
},
});
modalContext?.onSubmit().then(() => {
this._rebuild();

View File

@@ -14,10 +14,10 @@ import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
import './modal-views/fields-viewer.element.js';
import './modal-views/fields-settings.element.js';
import './modal-views/fields-settings-modal.element.js';
interface ExposedSearchResultField {
name?: string | null;
name: string;
exposed: boolean;
}
@@ -82,9 +82,10 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
});
if (document) {
const newFieldNames = document.map((field) => {
return field.name;
return field.name ?? '';
});
// TODO: I don't get this code, not sure what the purpose is, it seems like a mistake:
this._exposedFields = this._exposedFields
? this._exposedFields.filter((field) => {
return { name: field.name, exposed: field.exposed };
@@ -98,11 +99,10 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
private _onFieldFilterClick() {
const modalContext = this._modalContext?.open(UMB_EXAMINE_FIELDS_SETTINGS_MODAL, {
...this._exposedFields,
value: { fields: this._exposedFields ?? [] },
});
modalContext?.onSubmit().then(({ fields } = {}) => {
if (!fields) return;
this._exposedFields = fields;
modalContext?.onSubmit().then((value) => {
this._exposedFields = value.fields;
});
}
@@ -163,8 +163,10 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
label="Open sidebar to see all fields"
@click="${() =>
this._modalContext?.open('umb-modal-element-fields-viewer', {
type: 'sidebar',
size: 'medium',
config: {
type: 'sidebar',
size: 'medium',
},
data: { ...rowData, name: this.getSearchResultNodeName(rowData) },
})}">
${rowData.fields ? Object.keys(rowData.fields).length : ''} fields
@@ -197,7 +199,7 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
compact
@click="${() => {
this._exposedFields = this._exposedFields?.map((f) => {
return f.name == field.name ? { name: f.name, exposed: false } : f;
return f.name === field.name ? { name: f.name, exposed: false } : f;
});
}}"
>x</uui-button

View File

@@ -41,6 +41,6 @@ export const manifests: Array<ManifestTypes> = [
type: 'modal',
alias: 'Umb.Modal.ExamineFieldsSettings',
name: 'Examine Field Settings Modal',
js: () => import('./examine-management-dashboard/views/modal-views/fields-settings.element.js'),
js: () => import('./examine-management-dashboard/views/modal-views/fields-settings-modal.element.js'),
},
];

View File

@@ -72,10 +72,12 @@ export class UmbDashboardPublishedStatusElement extends UmbLitElement {
}
private async _onReloadCacheHandler() {
const modalContext = this._modalContext?.open(UMB_CONFIRM_MODAL, {
headline: 'Reload',
content: html` Trigger a in-memory and local file cache reload on all servers.`,
color: 'danger',
confirmLabel: 'Continue',
data: {
headline: 'Reload',
content: html` Trigger a in-memory and local file cache reload on all servers.`,
color: 'danger',
confirmLabel: 'Continue',
},
});
modalContext?.onSubmit().then(() => {
this._reloadMemoryCache();
@@ -95,10 +97,12 @@ export class UmbDashboardPublishedStatusElement extends UmbLitElement {
private async _onRebuildCacheHandler() {
const modalContex = this._modalContext?.open(UMB_CONFIRM_MODAL, {
headline: 'Rebuild',
content: html` Rebuild content in cmsContentNu database table. Expensive.`,
color: 'danger',
confirmLabel: 'Continue',
data: {
headline: 'Rebuild',
content: html` Rebuild content in cmsContentNu database table. Expensive.`,
color: 'danger',
confirmLabel: 'Continue',
},
});
modalContex?.onSubmit().then(() => {
this._rebuildDatabaseCache();
@@ -118,10 +122,12 @@ export class UmbDashboardPublishedStatusElement extends UmbLitElement {
private async _onSnapshotCacheHandler() {
const modalContex = this._modalContext?.open(UMB_CONFIRM_MODAL, {
headline: 'Snapshot',
content: html` Trigger a NuCache snapshots collection.`,
color: 'danger',
confirmLabel: 'Continue',
data: {
headline: 'Snapshot',
content: html` Trigger a NuCache snapshots collection.`,
color: 'danger',
confirmLabel: 'Continue',
},
});
modalContex?.onSubmit().then(() => {
this._cacheCollect();

View File

@@ -1,6 +1,5 @@
import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { map } from '@umbraco-cms/backoffice/external/rxjs';
import { isManifestElementNameType } from '@umbraco-cms/backoffice/extension-api';
import { ManifestTypes, umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import {
@@ -48,10 +47,12 @@ export class UmbExtensionRootWorkspaceElement extends UmbLitElement {
async #removeExtension(extension: ManifestTypes) {
const modalContext = this._modalContext?.open(UMB_CONFIRM_MODAL, {
headline: 'Unload extension',
confirmLabel: 'Unload',
content: html`<p>Are you sure you want to unload the extension <strong>${extension.alias}</strong>?</p>`,
color: 'danger',
data: {
headline: 'Unload extension',
confirmLabel: 'Unload',
content: html`<p>Are you sure you want to unload the extension <strong>${extension.alias}</strong>?</p>`,
color: 'danger',
},
});
await modalContext?.onSubmit();

View File

@@ -34,7 +34,9 @@ export class UmbCreateFromSnippetPartialViewAction<
const snippets = (await this.repository?.getSnippets({}))?.data?.items ?? [];
const modalContext = this.#modalContext?.open(UMB_PARTIAL_VIEW_FROM_SNIPPET_MODAL, {
snippets,
data: {
snippets,
},
});
await modalContext?.onSubmit().then((snippetName) => {

View File

@@ -18,7 +18,8 @@ export default class UmbPartialViewCreateFromSnippetModalElement extends UmbModa
}
private _submit(snippetName: string) {
this.modalContext?.submit(snippetName);
this._value = snippetName;
this.modalContext?.submit();
}
private _close() {

View File

@@ -55,14 +55,6 @@ export class UmbUserGroupPickerModalElement extends UmbModalBaseElement<any, any
this.modalContext?.updateValue({ selection: this.#selectionManager.getSelection() });
}
#submit() {
this.modalContext?.submit(this._value);
}
#close() {
this.modalContext?.reject();
}
render() {
return html`
<umb-body-layout headline=${this.localize.term('user_selectUserGroup', false)}>
@@ -81,8 +73,8 @@ export class UmbUserGroupPickerModalElement extends UmbModalBaseElement<any, any
)}
</uui-box>
<div slot="actions">
<uui-button label="Close" @click=${this.#close}></uui-button>
<uui-button label="Submit" look="primary" color="positive" @click=${this.#submit}></uui-button>
<uui-button label="Close" @click=${this._rejectModal}></uui-button>
<uui-button label="Submit" look="primary" color="positive" @click=${this._submitModal}></uui-button>
</div>
</umb-body-layout>
`;