make types nullable
This commit is contained in:
@@ -33,7 +33,9 @@ export class UmbHeaderAppCurrentUser extends UmbContextConsumerMixin(UmbObserver
|
||||
|
||||
private async _observeCurrentUser() {
|
||||
this.observe<UserDetails>(umbCurrentUserService.currentUser, (currentUser) => {
|
||||
this._currentUser = currentUser;
|
||||
if(currentUser) {
|
||||
this._currentUser = currentUser;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -259,8 +259,9 @@ export class UmbUserGroupWorkspaceElement extends UmbLitElement {
|
||||
|
||||
// TODO: Create method to only get users from this userGroup
|
||||
// TODO: Find a better way to only call this once at the start
|
||||
this.observe(this._userStore.getAll(), (users: Array<UserDetails>) => {
|
||||
if (!this._userKeys && users.length > 0) {
|
||||
this.observe<Array<UserDetails>>(this._userStore.getAll(), (users) => {
|
||||
// TODO: handle if there is no users.
|
||||
if (!this._userKeys && users && users.length > 0) {
|
||||
this._userKeys = users.filter((user) => user.userGroups.includes(this.entityKey)).map((user) => user.key);
|
||||
this._updateProperty('users', this._userKeys);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,9 @@ export class UmbWorkspaceUserElement extends UmbLitElement {
|
||||
private async _observeCurrentUser() {
|
||||
// TODO: do not have static current user service, we need to make a ContextAPI for this.
|
||||
this.observe<UserDetails>(umbCurrentUserService.currentUser, (currentUser) => {
|
||||
this._currentUser = currentUser;
|
||||
if(currentUser) {
|
||||
this._currentUser = currentUser;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,17 @@ import { css, html, LitElement } from 'lit';
|
||||
import { customElement, state } from 'lit/decorators.js';
|
||||
import { distinctUntilChanged } from 'rxjs';
|
||||
import { UmbWorkspaceDataTypeContext } from '../../workspace-data-type.context';
|
||||
import type { DataTypeDetails } from '@umbraco-cms/models';
|
||||
import type { UmbDataTypeStoreItemType } from '../../../data-type.store';
|
||||
import { UmbObserverMixin } from '@umbraco-cms/observable-api';
|
||||
import { UmbContextConsumerMixin } from '@umbraco-cms/context-api';
|
||||
import type { DataTypeDetails } from '@umbraco-cms/models';
|
||||
|
||||
@customElement('umb-workspace-view-data-type-info')
|
||||
export class UmbWorkspaceViewDataTypeInfoElement extends UmbContextConsumerMixin(UmbObserverMixin(LitElement)) {
|
||||
static styles = [UUITextStyles, css``];
|
||||
|
||||
@state()
|
||||
_dataType?: DataTypeDetails;
|
||||
_dataType?: DataTypeDetails | null;
|
||||
|
||||
private _workspaceContext?: UmbWorkspaceDataTypeContext;
|
||||
|
||||
@@ -28,8 +29,9 @@ export class UmbWorkspaceViewDataTypeInfoElement extends UmbContextConsumerMixin
|
||||
private _observeDataType() {
|
||||
if (!this._workspaceContext) return;
|
||||
|
||||
this.observe<DataTypeDetails>(this._workspaceContext.data.pipe(distinctUntilChanged()), (dataType) => {
|
||||
this._dataType = dataType;
|
||||
this.observe<UmbDataTypeStoreItemType>(this._workspaceContext.data.pipe(distinctUntilChanged()), (dataType) => {
|
||||
// TODO: Make method to identify wether data is of type DataTypeDetails
|
||||
this._dataType = (dataType as DataTypeDetails | null);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
|
||||
import { css, html } from 'lit';
|
||||
import { customElement, property, state } from 'lit/decorators.js';
|
||||
import { distinctUntilChanged } from 'rxjs';
|
||||
import type { UmbDataTypeStoreItemType } from '../data-type.store';
|
||||
import { UmbWorkspaceDataTypeContext } from './workspace-data-type.context';
|
||||
import type { DataTypeDetails } from '@umbraco-cms/models';
|
||||
import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry';
|
||||
import { UmbLitElement } from 'src/core/element/lit-element.element';
|
||||
|
||||
@@ -111,7 +111,7 @@ export class UmbWorkspaceDataTypeElement extends UmbLitElement {
|
||||
private _observeWorkspace() {
|
||||
if (!this._workspaceContext) return;
|
||||
|
||||
this.observe<DataTypeDetails>(this._workspaceContext.data.pipe(distinctUntilChanged()), (dataType) => {
|
||||
this.observe<UmbDataTypeStoreItemType>(this._workspaceContext.data.pipe(distinctUntilChanged()), (dataType) => {
|
||||
if (dataType && dataType.name !== this._dataTypeName) {
|
||||
this._dataTypeName = dataType.name ?? '';
|
||||
}
|
||||
|
||||
@@ -88,10 +88,10 @@ export class UmbModalLayoutCurrentUserElement extends UmbLitElement {
|
||||
private _currentUser?: UserDetails;
|
||||
|
||||
@state()
|
||||
private _externalLoginProviders: Array<ManifestExternalLoginProvider> = [];
|
||||
private _externalLoginProviders: Array<ManifestExternalLoginProvider> | null = null;
|
||||
|
||||
@state()
|
||||
private _userDashboards: Array<ManifestUserDashboard> = [];
|
||||
private _userDashboards: Array<ManifestUserDashboard> | null = null;
|
||||
|
||||
@state()
|
||||
private _history: Array<UmbCurrentUserHistoryItem> = [];
|
||||
@@ -124,13 +124,17 @@ export class UmbModalLayoutCurrentUserElement extends UmbLitElement {
|
||||
|
||||
private async _observeCurrentUser() {
|
||||
this.observe<UserDetails>(umbCurrentUserService.currentUser, (currentUser) => {
|
||||
this._currentUser = currentUser;
|
||||
if(currentUser) {
|
||||
this._currentUser = currentUser;
|
||||
}
|
||||
});
|
||||
}
|
||||
private async _observeHistory() {
|
||||
if (this._currentUserHistoryStore) {
|
||||
this.observe<Array<UmbCurrentUserHistoryItem>>(this._currentUserHistoryStore.getLatestHistory(), (history) => {
|
||||
this._history = history;
|
||||
if(history) {
|
||||
this._history = history;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -195,14 +199,14 @@ export class UmbModalLayoutCurrentUserElement extends UmbLitElement {
|
||||
</uui-box>
|
||||
<uui-box>
|
||||
<b slot="headline">External login providers</b>
|
||||
${this._externalLoginProviders.map(
|
||||
${this._externalLoginProviders?.map(
|
||||
(provider) =>
|
||||
html`<umb-external-login-provider-extension
|
||||
.externalLoginProvider=${provider}></umb-external-login-provider-extension>`
|
||||
)}
|
||||
</uui-box>
|
||||
<div>
|
||||
${this._userDashboards.map(
|
||||
${this._userDashboards?.map(
|
||||
(provider) =>
|
||||
html`<umb-user-dashboard-extension .userDashboard=${provider}></umb-user-dashboard-extension>`
|
||||
)}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { UmbModalService } from 'src/backoffice/core/services/modal';
|
||||
|
||||
import '../../../core/property-editors/uis/icon-picker/property-editor-ui-icon-picker.element';
|
||||
import { UmbLitElement } from 'src/core/element/lit-element.element';
|
||||
import { UmbDocumentTypeStoreItemType } from '../document-type.store';
|
||||
|
||||
@customElement('umb-document-type-workspace')
|
||||
export class UmbDocumentTypeWorkspaceElement extends UmbLitElement {
|
||||
@@ -60,7 +61,7 @@ export class UmbDocumentTypeWorkspaceElement extends UmbLitElement {
|
||||
private _workspaceContext?: UmbWorkspaceDocumentTypeContext;
|
||||
|
||||
@state()
|
||||
private _documentType?: DocumentTypeDetails;
|
||||
private _documentType?: DocumentTypeDetails | null;
|
||||
|
||||
private _modalService?: UmbModalService;
|
||||
|
||||
@@ -83,8 +84,9 @@ export class UmbDocumentTypeWorkspaceElement extends UmbLitElement {
|
||||
private async _observeWorkspace() {
|
||||
if (!this._workspaceContext) return;
|
||||
|
||||
this.observe<DocumentTypeDetails>(this._workspaceContext.data.pipe(distinctUntilChanged()), (data) => {
|
||||
this._documentType = data;
|
||||
this.observe<UmbDocumentTypeStoreItemType>(this._workspaceContext.data.pipe(distinctUntilChanged()), (data) => {
|
||||
// TODO: make method to identify if data is of type DocumentTypeDetails
|
||||
this._documentType = (data as DocumentTypeDetails | null);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ interface ResolvedContexts {
|
||||
}
|
||||
|
||||
export declare class UmbElementMixinInterface extends UmbControllerHostInterface {
|
||||
observe<T = unknown | null>(source: Observable<T>, callback: (_value: T) => void): UmbObserverController<T>;
|
||||
observe<T = unknown | null>(source: Observable<T | null>, callback: (_value: T | null) => void): UmbObserverController<T | null>;
|
||||
provideContext(alias: string, instance: unknown): UmbContextProviderController;
|
||||
consumeContext(alias: string, callback: UmbContextCallback): UmbContextConsumerController;
|
||||
consumeAllContexts(contextAliases: string[], callback: (_instances: ResolvedContexts) => void): void;
|
||||
@@ -28,7 +28,7 @@ export const UmbElementMixin = <T extends HTMLElementConstructor>(superClass: T)
|
||||
* @return {UmbObserverController} Reference to a Observer Controller instance
|
||||
* @memberof UmbElementMixin
|
||||
*/
|
||||
observe<T = unknown | null>(source: Observable<T>, callback: (_value: T | null) => void): UmbObserverController<T> {
|
||||
observe<T = unknown | null>(source: Observable<T | null>, callback: (_value: T | null) => void): UmbObserverController<T | null> {
|
||||
return new UmbObserverController<T>(this, source, callback);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user