Co-authored-by: gorbenko.pavel <gorbenko.pavel@tansu.kz> Reviewed-on: http://git.tnsu.kz/timur.gorodetskiy/request-portal/pulls/8
This commit was merged in pull request #8.
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
import { Version } from '@microsoft/sp-core-library';
|
||||
import {
|
||||
type IPropertyPaneConfiguration,
|
||||
PropertyPaneTextField
|
||||
} from '@microsoft/sp-property-pane';
|
||||
import { type IPropertyPaneConfiguration } from '@microsoft/sp-property-pane';
|
||||
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
||||
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||
|
||||
@@ -13,13 +10,15 @@ import RequestPortal from './components/RequestPortal';
|
||||
import { IRequestPortalProps } from './components/IRequestPortalProps';
|
||||
import { initSP } from './shared/pnp/pnpjs';
|
||||
import { installErrorLogging } from './shared/diagnostics';
|
||||
import { setImpersonatedEmail } from './shared/impersonation';
|
||||
import { setImpersonatedIdentity } from './shared/impersonation';
|
||||
import { ErrorOverlay } from './shared/ui';
|
||||
import { PropertyPaneDebugUser } from './propertyPane/PropertyPaneDebugUser';
|
||||
|
||||
export interface IRequestPortalWebPartProps {
|
||||
description: string;
|
||||
/** Отладочная подмена личности — см. shared/impersonation.ts. На бою пусто. */
|
||||
debugUserQuery: string;
|
||||
debugUserEmail: string;
|
||||
debugUserDisplayName: string;
|
||||
}
|
||||
|
||||
export default class RequestPortalWebPart extends BaseClientSideWebPart<IRequestPortalWebPartProps> {
|
||||
@@ -30,13 +29,17 @@ export default class RequestPortalWebPart extends BaseClientSideWebPart<IRequest
|
||||
public render(): void {
|
||||
// Именно здесь, а не в onInit: свойство меняется в панели без перезапуска
|
||||
// веб-части, и render вызывается на каждое такое изменение.
|
||||
setImpersonatedEmail(this.properties.debugUserEmail);
|
||||
setImpersonatedIdentity(this.properties.debugUserEmail, this.properties.debugUserDisplayName);
|
||||
|
||||
const element: React.ReactElement = React.createElement(
|
||||
ErrorOverlay,
|
||||
undefined,
|
||||
React.createElement<IRequestPortalProps>(RequestPortal, {
|
||||
description: this.properties.description,
|
||||
// key на подменённом e-mail: смена подмены в property pane должна
|
||||
// пересобрать раздел заново — иначе счётчики в боковом меню и открытые
|
||||
// таблицы остались бы от прежнего пользователя (их эффекты завязаны на
|
||||
// монтирование/context, а не на identity подмены).
|
||||
key: this.properties.debugUserEmail || '__self__',
|
||||
isDarkTheme: this._isDarkTheme,
|
||||
environmentMessage: this._environmentMessage,
|
||||
hasTeamsContext: !!this.context.sdks.microsoftTeams,
|
||||
@@ -62,7 +65,7 @@ export default class RequestPortalWebPart extends BaseClientSideWebPart<IRequest
|
||||
if (!!this.context.sdks.microsoftTeams) { // running in Teams, office.com or Outlook
|
||||
return this.context.sdks.microsoftTeams.teamsJs.app.getContext()
|
||||
.then(context => {
|
||||
let environmentMessage: string = '';
|
||||
let environmentMessage: string;
|
||||
switch (context.app.host.name) {
|
||||
case 'Office': // running in Office
|
||||
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment;
|
||||
@@ -122,13 +125,17 @@ export default class RequestPortalWebPart extends BaseClientSideWebPart<IRequest
|
||||
{
|
||||
groupName: strings.BasicGroupName,
|
||||
groupFields: [
|
||||
PropertyPaneTextField('description', {
|
||||
label: strings.DescriptionFieldLabel
|
||||
}),
|
||||
PropertyPaneTextField('debugUserEmail', {
|
||||
label: strings.DebugUserEmailFieldLabel,
|
||||
description: strings.DebugUserEmailFieldDescription,
|
||||
placeholder: 'employee@tnsu.kz'
|
||||
PropertyPaneDebugUser('debugUserQuery', {
|
||||
label: strings.DebugUserFieldLabel,
|
||||
description: strings.DebugUserFieldDescription,
|
||||
context: this.context,
|
||||
initialQuery: this.properties.debugUserQuery,
|
||||
onResolved: (query, email, displayName) => {
|
||||
this.properties.debugUserQuery = query;
|
||||
this.properties.debugUserEmail = email;
|
||||
this.properties.debugUserDisplayName = displayName;
|
||||
this.render();
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user