Hide property has sensitive data with normal user (#19857)
Co-authored-by: Lan Nguyen Thuy <lnt@umbraco.dk>
This commit is contained in:
@@ -5,6 +5,7 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
|
||||
import { UMB_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/property';
|
||||
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
import { UmbDataPathPropertyValueQuery } from '@umbraco-cms/backoffice/validation';
|
||||
import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user';
|
||||
|
||||
@customElement('umb-content-workspace-property')
|
||||
export class UmbContentWorkspacePropertyElement extends UmbLitElement {
|
||||
@@ -37,6 +38,9 @@ export class UmbContentWorkspacePropertyElement extends UmbLitElement {
|
||||
@state()
|
||||
_propertyType?: UmbPropertyTypeModel;
|
||||
|
||||
@state()
|
||||
private _hasAccessToSensitiveData = false;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -51,6 +55,12 @@ export class UmbContentWorkspacePropertyElement extends UmbLitElement {
|
||||
this._workspaceContext = workspaceContext;
|
||||
this.#observePropertyType();
|
||||
});
|
||||
|
||||
this.consumeContext(UMB_CURRENT_USER_CONTEXT, (context) => {
|
||||
this.observe(context?.hasAccessToSensitiveData, (hasAccessToSensitiveData) => {
|
||||
this._hasAccessToSensitiveData = hasAccessToSensitiveData === true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async #observePropertyType() {
|
||||
@@ -119,6 +129,7 @@ export class UmbContentWorkspacePropertyElement extends UmbLitElement {
|
||||
override render() {
|
||||
if (!this._viewable) return nothing;
|
||||
if (!this._dataPath || this._writeable === undefined) return nothing;
|
||||
if (!this._hasAccessToSensitiveData && this._propertyType?.isSensitive) return nothing;
|
||||
|
||||
return html`<umb-property-type-based-property
|
||||
data-path=${this._dataPath}
|
||||
|
||||
Reference in New Issue
Block a user