Files
tnsu-approval-route/frontend/lib-commonjs/webparts/approvalAdmin/ApprovalAdminWebPart.js
T
2026-07-28 18:00:40 +05:00

106 lines
4.9 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var ReactDom = tslib_1.__importStar(require("react-dom"));
var sp_core_library_1 = require("@microsoft/sp-core-library");
var sp_property_pane_1 = require("@microsoft/sp-property-pane");
var sp_webpart_base_1 = require("@microsoft/sp-webpart-base");
var strings = tslib_1.__importStar(require("ApprovalAdminWebPartStrings"));
var ApprovalAdmin_1 = tslib_1.__importDefault(require("./components/ApprovalAdmin"));
var ApprovalAdminWebPart = /** @class */ (function (_super) {
tslib_1.__extends(ApprovalAdminWebPart, _super);
function ApprovalAdminWebPart() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._isDarkTheme = false;
_this._environmentMessage = '';
return _this;
}
ApprovalAdminWebPart.prototype.render = function () {
var element = React.createElement(ApprovalAdmin_1.default, {
description: this.properties.description,
isDarkTheme: this._isDarkTheme,
environmentMessage: this._environmentMessage,
hasTeamsContext: !!this.context.sdks.microsoftTeams,
userDisplayName: this.context.pageContext.user.displayName
});
ReactDom.render(element, this.domElement);
};
ApprovalAdminWebPart.prototype.onInit = function () {
var _this = this;
return this._getEnvironmentMessage().then(function (message) {
_this._environmentMessage = message;
});
};
ApprovalAdminWebPart.prototype._getEnvironmentMessage = function () {
var _this = this;
if (!!this.context.sdks.microsoftTeams) { // running in Teams, office.com or Outlook
return this.context.sdks.microsoftTeams.teamsJs.app.getContext()
.then(function (context) {
var environmentMessage = '';
switch (context.app.host.name) {
case 'Office': // running in Office
environmentMessage = _this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment;
break;
case 'Outlook': // running in Outlook
environmentMessage = _this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOutlook : strings.AppOutlookEnvironment;
break;
case 'Teams': // running in Teams
case 'TeamsModern':
environmentMessage = _this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
break;
default:
environmentMessage = strings.UnknownEnvironment;
}
return environmentMessage;
});
}
return Promise.resolve(this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment);
};
ApprovalAdminWebPart.prototype.onThemeChanged = function (currentTheme) {
if (!currentTheme) {
return;
}
this._isDarkTheme = !!currentTheme.isInverted;
var semanticColors = currentTheme.semanticColors;
if (semanticColors) {
this.domElement.style.setProperty('--bodyText', semanticColors.bodyText || null);
this.domElement.style.setProperty('--link', semanticColors.link || null);
this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered || null);
}
};
ApprovalAdminWebPart.prototype.onDispose = function () {
ReactDom.unmountComponentAtNode(this.domElement);
};
Object.defineProperty(ApprovalAdminWebPart.prototype, "dataVersion", {
get: function () {
return sp_core_library_1.Version.parse('1.0');
},
enumerable: false,
configurable: true
});
ApprovalAdminWebPart.prototype.getPropertyPaneConfiguration = function () {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
(0, sp_property_pane_1.PropertyPaneTextField)('description', {
label: strings.DescriptionFieldLabel
})
]
}
]
}
]
};
};
return ApprovalAdminWebPart;
}(sp_webpart_base_1.BaseClientSideWebPart));
exports.default = ApprovalAdminWebPart;
//# sourceMappingURL=ApprovalAdminWebPart.js.map