@sapui5/sap.suite.ui.commons 1.140.0 → 1.142.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/package.json +1 -1
  2. package/src/sap/suite/ui/commons/.library +1 -1
  3. package/src/sap/suite/ui/commons/AriaProperties.js +1 -1
  4. package/src/sap/suite/ui/commons/CalculationBuilder.js +13 -2
  5. package/src/sap/suite/ui/commons/CalculationBuilderExpression.js +11 -7
  6. package/src/sap/suite/ui/commons/CalculationBuilderFunction.js +1 -1
  7. package/src/sap/suite/ui/commons/CalculationBuilderGroup.js +1 -1
  8. package/src/sap/suite/ui/commons/CalculationBuilderItem.js +12 -6
  9. package/src/sap/suite/ui/commons/CalculationBuilderValidationResult.js +1 -1
  10. package/src/sap/suite/ui/commons/CalculationBuilderVariable.js +1 -1
  11. package/src/sap/suite/ui/commons/CloudFilePicker.js +21 -21
  12. package/src/sap/suite/ui/commons/MicroProcessFlow.js +2 -2
  13. package/src/sap/suite/ui/commons/MicroProcessFlowItem.js +7 -9
  14. package/src/sap/suite/ui/commons/Timeline.js +22 -24
  15. package/src/sap/suite/ui/commons/TimelineItemRenderer.js +12 -2
  16. package/src/sap/suite/ui/commons/TimelineRenderManager.js +25 -13
  17. package/src/sap/suite/ui/commons/collaboration/BaseHelperService.js +12 -12
  18. package/src/sap/suite/ui/commons/collaboration/CollaborationCardHelper.js +6 -5
  19. package/src/sap/suite/ui/commons/collaboration/CollaborationContactInfoHelper.js +15 -15
  20. package/src/sap/suite/ui/commons/collaboration/CollaborationHelper.js +94 -76
  21. package/src/sap/suite/ui/commons/collaboration/CollaborationManagerService.js +41 -41
  22. package/src/sap/suite/ui/commons/collaboration/ContactHelper.js +288 -286
  23. package/src/sap/suite/ui/commons/collaboration/ServiceContainer.js +33 -33
  24. package/src/sap/suite/ui/commons/collaboration/TeamsHelperService.js +446 -150
  25. package/src/sap/suite/ui/commons/collaboration/UniversalCollaborationBar.js +366 -0
  26. package/src/sap/suite/ui/commons/collaboration/flpplugins/msplugin/Component-preload.js +6 -3
  27. package/src/sap/suite/ui/commons/collaboration/flpplugins/msplugin/Component.js +11 -13
  28. package/src/sap/suite/ui/commons/flexibility/changeHandler/PropertyChangeMapper.js +1 -1
  29. package/src/sap/suite/ui/commons/imageeditor/CropCustomShapeHistoryItem.js +1 -1
  30. package/src/sap/suite/ui/commons/imageeditor/CropEllipseHistoryItem.js +1 -1
  31. package/src/sap/suite/ui/commons/imageeditor/CropRectangleHistoryItem.js +1 -1
  32. package/src/sap/suite/ui/commons/imageeditor/CustomSizeItem.js +1 -1
  33. package/src/sap/suite/ui/commons/imageeditor/FilterHistoryItem.js +1 -1
  34. package/src/sap/suite/ui/commons/imageeditor/FlipHistoryItem.js +1 -1
  35. package/src/sap/suite/ui/commons/imageeditor/HistoryItem.js +1 -1
  36. package/src/sap/suite/ui/commons/imageeditor/ImageEditor.js +1 -1
  37. package/src/sap/suite/ui/commons/imageeditor/ImageEditorContainer.js +1 -1
  38. package/src/sap/suite/ui/commons/imageeditor/ImageEditorResponsiveContainer.js +1 -1
  39. package/src/sap/suite/ui/commons/imageeditor/ResizeHistoryItem.js +1 -1
  40. package/src/sap/suite/ui/commons/imageeditor/RotateHistoryItem.js +1 -1
  41. package/src/sap/suite/ui/commons/library.js +1 -1
  42. package/src/sap/suite/ui/commons/messagebundle.properties +16 -1
  43. package/src/sap/suite/ui/commons/messagebundle_en.properties +3 -0
  44. package/src/sap/suite/ui/commons/networkgraph/Graph.js +105 -5
  45. package/src/sap/suite/ui/commons/networkgraph/Node.js +33 -11
  46. package/src/sap/suite/ui/commons/networkgraph/util/DragDropManager.js +197 -0
  47. package/src/sap/suite/ui/commons/statusindicator/Circle.js +1 -1
  48. package/src/sap/suite/ui/commons/statusindicator/CustomShape.js +1 -1
  49. package/src/sap/suite/ui/commons/statusindicator/DiscreteThreshold.js +1 -1
  50. package/src/sap/suite/ui/commons/statusindicator/FillingOption.js +1 -1
  51. package/src/sap/suite/ui/commons/statusindicator/LibraryShape.js +1 -1
  52. package/src/sap/suite/ui/commons/statusindicator/Path.js +1 -1
  53. package/src/sap/suite/ui/commons/statusindicator/PropertyThreshold.js +1 -1
  54. package/src/sap/suite/ui/commons/statusindicator/Rectangle.js +1 -1
  55. package/src/sap/suite/ui/commons/statusindicator/Shape.js +1 -1
  56. package/src/sap/suite/ui/commons/statusindicator/ShapeGroup.js +1 -1
  57. package/src/sap/suite/ui/commons/statusindicator/SimpleShape.js +1 -1
  58. package/src/sap/suite/ui/commons/statusindicator/StatusIndicator.js +1 -1
  59. package/src/sap/suite/ui/commons/taccount/TAccount.js +1 -1
  60. package/src/sap/suite/ui/commons/taccount/TAccountGroup.js +1 -1
  61. package/src/sap/suite/ui/commons/taccount/TAccountItem.js +1 -1
  62. package/src/sap/suite/ui/commons/taccount/TAccountItemProperty.js +1 -1
  63. package/src/sap/suite/ui/commons/taccount/TAccountPanel.js +1 -1
  64. package/src/sap/suite/ui/commons/themes/base/CollaborationPopover.less +29 -1
  65. package/src/sap/suite/ui/commons/themes/base/NetworkGraph.less +5 -0
@@ -28,7 +28,7 @@ sap.ui.define([
28
28
  "sap/base/i18n/Localization",
29
29
  "./CollaborationManagerService",
30
30
  "sap/m/FlexItemData"
31
- ], function (Log, Core, URLListValidator, CollaborationHelper, BaseHelperService, Element, ContactHelper, Device, CollaborationCardHelper, Fragment, MessageBox, Library, Popover, HBox, VBox, MessageStrip, Button, CollaborationContactInfoHelper, sapMLibrary, FlexBox, Localization, CollaborationManagerService, FlexItemData) {
31
+ ], function(Log, Core, URLListValidator, CollaborationHelper, BaseHelperService, Element, ContactHelper, Device, CollaborationCardHelper, Fragment, MessageBox, Library, Popover, HBox, VBox, MessageStrip, Button, CollaborationContactInfoHelper, sapMLibrary, FlexBox, Localization, CollaborationManagerService, FlexItemData) {
32
32
  "use strict";
33
33
 
34
34
  /**
@@ -41,7 +41,7 @@ sap.ui.define([
41
41
  * @experimental Since 1.108
42
42
  */
43
43
  var TeamsHelperService = BaseHelperService.extend("sap.suite.ui.commons.collaboration.TeamsHelperService", {
44
- constructor: function (oProviderConfig) {
44
+ constructor: function(oProviderConfig) {
45
45
  this._providerConfig = oProviderConfig;
46
46
  this._providerConfig.shareAsLinkUrl = "https://teams.microsoft.com/share";
47
47
  this._getShareAsTabUrl().then(function(sShareAsTabUrl) {
@@ -53,18 +53,32 @@ sap.ui.define([
53
53
  /**
54
54
  * sTeamsAppID is hardcoded as of now, will be changed when app is published at org level.
55
55
  */
56
- var COLLABORATION_MSTEAMS_APPID = 'db5b69c6-0430-4ae1-8d6e-a65c2220b50c';
57
- var oLogger = Log.getLogger("sap.suite.ui.commons.collaboration.TeamsHelperService");
58
- var CARD_URL_PREFIX = "https://saps4hana.azure-api.net/bot/redirect?target-url=";
56
+ const COLLABORATION_MSTEAMS_APPID = 'db5b69c6-0430-4ae1-8d6e-a65c2220b50c';
57
+ const oLogger = Log.getLogger("sap.suite.ui.commons.collaboration.TeamsHelperService");
58
+ const CARD_URL_PREFIX = "https://saps4hana.azure-api.net/bot/redirect?target-url=";
59
+ const oResourceBundle = Library.getResourceBundleFor("sap.suite.ui.commons");
60
+ const PARAM_SAP_CARD_INFO = "info";
59
61
 
60
- var oResourceBundle = Library.getResourceBundleFor("sap.suite.ui.commons");
61
- var PARAM_SAP_CARD_INFO = "info";
62
-
63
- var oBusyDailog;
64
- let iTimeoutId;
65
- const AUTO_CLOSE_BUSY_DIALOG_TIME = 60 * 1000; // 1 sec = 1000, here 60 sec
66
- var oTeamsParams = {};
67
- var windowWidthAndHeight = "width=720,height=720";
62
+ let oBusyDialog;
63
+ let iBusyDialogTimeoutId;
64
+ const AUTO_CLOSE_BUSY_DIALOG_TIME = 60 * 1000; //60 sec
65
+ let oTeamsParams = {};
66
+ const windowWidthAndHeight = "width=720,height=720";
67
+ const validDomains = [
68
+ "*.s4hana.ondemand.com",
69
+ "*.*.s4hana.ondemand.com",
70
+ "*.*.*.s4hana.ondemand.com",
71
+ "*.cloud.sap",
72
+ "*.*.cloud.sap",
73
+ "*.*.*.cloud.sap",
74
+ "*.sapcloud.cn",
75
+ "*.*.sapcloud.cn",
76
+ "*.*.*.sapcloud.cn",
77
+ "*.saps4hanacloud.cn",
78
+ "*.*.saps4hanacloud.cn",
79
+ "*.*.*.saps4hanacloud.cn",
80
+ "*.sap.com"
81
+ ];
68
82
 
69
83
  /**
70
84
  * Gives list of all Collaboration Options
@@ -77,7 +91,7 @@ sap.ui.define([
77
91
  * @ui5-restricted
78
92
  * @experimental Since 1.108
79
93
  */
80
- TeamsHelperService.prototype.getOptions = function (oParams) {
94
+ TeamsHelperService.prototype.getOptions = function(oParams) {
81
95
  oTeamsParams = {
82
96
  isShareAsLinkEnabled: (oParams && typeof oParams.isShareAsLinkEnabled !== 'undefined') ? oParams.isShareAsLinkEnabled : true,
83
97
  isShareAsTabEnabled: (oParams && typeof oParams.isShareAsTabEnabled !== 'undefined') ? oParams.isShareAsTabEnabled : true,
@@ -195,7 +209,7 @@ sap.ui.define([
195
209
  * @ui5-restricted
196
210
  * @experimental Since 1.108
197
211
  */
198
- TeamsHelperService.prototype.share = function (oOption, oParams) {
212
+ TeamsHelperService.prototype.share = function(oOption, oParams) {
199
213
 
200
214
  if (!oParams.url) {
201
215
  oLogger.error("url is not supplied in object so terminating Click");
@@ -236,7 +250,7 @@ sap.ui.define([
236
250
  * @ui5-restricted
237
251
  * @experimental Since 1.108
238
252
  */
239
- TeamsHelperService.prototype._shareAsChat = function (oParams) {
253
+ TeamsHelperService.prototype._shareAsChat = function(oParams) {
240
254
  var newWindow = window.open(
241
255
  "",
242
256
  "_blank",
@@ -249,13 +263,13 @@ sap.ui.define([
249
263
 
250
264
  newWindow.opener = null;
251
265
  if (oParams.minifyUrlForChat) {
252
- CollaborationHelper.compactHash(oParams.url, []).then(async function (sShortURL) {
266
+ CollaborationHelper.compactHash(oParams.url, []).then(async function(sShortURL) {
253
267
  var sModifiedUrl = await this._modifyUrlForNavigationContext(oParams.url, sShortURL.url);
254
- newWindow.location = this._providerConfig.shareAsLinkUrl + "?msgText=" + encodeURIComponent(sMessage) + "&preview=false" + "&href=" + encodeURIComponent(sModifiedUrl);
255
- }.bind(this));
256
- } else {
257
- newWindow.location = this._providerConfig.shareAsLinkUrl + "?msgText=" + encodeURIComponent(sMessage) + "&preview=false" + "&href=" + encodeURIComponent(oParams.url);
258
- }
268
+ newWindow.location = this._providerConfig.shareAsLinkUrl + "?msgText=" + encodeURIComponent(sMessage) + "&preview=false" + "&href=" + encodeURIComponent(sModifiedUrl);
269
+ }.bind(this));
270
+ } else {
271
+ newWindow.location = this._providerConfig.shareAsLinkUrl + "?msgText=" + encodeURIComponent(sMessage) + "&preview=false" + "&href=" + encodeURIComponent(oParams.url);
272
+ }
259
273
  };
260
274
 
261
275
  /**
@@ -297,7 +311,7 @@ sap.ui.define([
297
311
  * @ui5-restricted
298
312
  * @experimental Since 1.108
299
313
  */
300
- TeamsHelperService.prototype._shareAsTab = async function (oParams) {
314
+ TeamsHelperService.prototype._shareAsTab = async function(oParams) {
301
315
  var sAppUri = await this._modifyUrlForShareAsTab(oParams.url, "MST:T");
302
316
  var oData = {
303
317
  "subEntityId": {
@@ -308,19 +322,19 @@ sap.ui.define([
308
322
  }
309
323
  };
310
324
  if (oParams.minifyUrlForChat) {
311
- CollaborationHelper.compactHash(sAppUri, []).then(async function (sShortURL) {
325
+ CollaborationHelper.compactHash(sAppUri, []).then(async function(sShortURL) {
312
326
  var sModifiedUrl = await this._modifyUrlForNavigationContext(sAppUri, sShortURL.url);
313
- oData.subEntityId.url = await this._addNavmodeInUrl(sModifiedUrl, 'explace');
314
- var sURL = this._providerConfig.shareAsTabUrl + "?&context=" + encodeURIComponent(JSON.stringify(oData));
315
- sap.m.URLHelper.redirect(sURL, true);
316
- }.bind(this));
317
- } else {
318
- var sURL = this._providerConfig.shareAsTabUrl + "?&context=" + encodeURIComponent(JSON.stringify(oData));
319
- sap.m.URLHelper.redirect(sURL, true);
320
- }
327
+ oData.subEntityId.url = await this._addNavmodeInUrl(sModifiedUrl, 'explace');
328
+ var sURL = this._providerConfig.shareAsTabUrl + "?&context=" + encodeURIComponent(JSON.stringify(oData));
329
+ sap.m.URLHelper.redirect(sURL, true);
330
+ }.bind(this));
331
+ } else {
332
+ var sURL = this._providerConfig.shareAsTabUrl + "?&context=" + encodeURIComponent(JSON.stringify(oData));
333
+ sap.m.URLHelper.redirect(sURL, true);
334
+ }
321
335
  };
322
336
 
323
- TeamsHelperService.prototype._addNavmodeInUrl = function (sURL, sNavMode) {
337
+ TeamsHelperService.prototype._addNavmodeInUrl = function(sURL, sNavMode) {
324
338
  const UshellContainer = sap.ui.require("sap/ushell/Container");
325
339
  return UshellContainer && UshellContainer.getServiceAsync("URLParsing").then(function(oURLParsing) {
326
340
  var sAppUri = sURL;
@@ -347,7 +361,7 @@ sap.ui.define([
347
361
  var oHashPartOfUri = oURLParsing.parseShellHash(sAppUri.substring(iIndexOfHash));
348
362
  var iParamsCount = Object.keys(oHashPartOfUri.params).length;
349
363
  var oUrl = new URL(sURL);
350
- if (iParamsCount > 0){
364
+ if (iParamsCount > 0) {
351
365
  if (!oUrl.searchParams.has("sap-collaboration-teams")) {
352
366
  oUrl.searchParams.set("sap-collaboration-teams", "true");
353
367
  } else {
@@ -368,125 +382,256 @@ sap.ui.define([
368
382
  * @ui5-restricted
369
383
  * @experimental Since 1.108
370
384
  */
371
- TeamsHelperService.prototype._shareAsCard = function (oParams) {
372
- if (oParams.cardId && oParams.cardId.length > 0 && oParams.cardManifest && this.isFeatureFlagEnabled()) {
373
- // Card Id and Card Manifest Passed. It will show busy helper and store card into DB.
374
- oParams.cardManifest["rtl"]= Localization.getRTL();
375
- Fragment.load({
376
- name: "sap.suite.ui.commons.collaboration.CollaborationBusyDialog",
377
- controller: this,
378
- type: "XML"
379
- }).then(function (oDialog) {
380
- oBusyDailog = oDialog;
381
- oBusyDailog.open();
382
- iTimeoutId = setTimeout(function() {
383
- oBusyDailog.close();
384
- oBusyDailog.destroy();
385
- }, AUTO_CLOSE_BUSY_DIALOG_TIME);
386
- CollaborationCardHelper.postCard(oParams.cardId, oParams.cardManifest).then(function (response) {
387
- var bSuccessScenario = true;
388
- var oResponseData = {
389
- cardId: response.card_id,
390
- version: response.version
391
- };
392
- if (response.error) {
393
- if (response.error.code === "APS_UI_MSG/001") {
394
- // Card ID with same CardManifest detail is present so it will get version and open Teams Dialog
395
- bSuccessScenario = true;
396
- oResponseData.cardId = oParams.cardId;
397
- if (response.error.message.length > 0){
398
- try {
399
- var sCardVersion = JSON.parse(atob(response.error.message)).version;
400
- oResponseData.version = sCardVersion;
401
- } catch (e) {
402
- bSuccessScenario = false;
403
- }
404
- }
405
- } else {
406
- bSuccessScenario = false;
407
- }
408
- }
409
- if (bSuccessScenario) {
410
- this._updateUrl(oParams, oResponseData);
411
- } else {
412
- MessageBox.error(oResourceBundle.getText("SAVE_CARD_ERROR"));
413
- this._closeBusyDailog();
414
- }
415
- }.bind(this));
416
- }.bind(this));
417
- } else {
385
+ TeamsHelperService.prototype._shareAsCard = async function (oParams) {
386
+ if (!oParams?.cardId || !oParams.cardId.length || !oParams.cardManifest || !this.isFeatureFlagEnabled()) {
418
387
  // Base Card to unfurl
419
388
  this._updateUrl(oParams, {});
389
+ return;
390
+ }
391
+ let oCardData = {};
392
+ try {
393
+ // Card Id and Card Manifest Passed. It will show busy helper and store card into DB.
394
+ try {
395
+ const oDialog = await Fragment.load({
396
+ name: "sap.suite.ui.commons.collaboration.CollaborationBusyDialog",
397
+ controller: this,
398
+ type: "XML"
399
+ });
400
+ oBusyDialog = oDialog;
401
+ oBusyDialog.open();
402
+
403
+ // Automatically close the dialog after a fixed time
404
+ iBusyDialogTimeoutId = setTimeout(() => {
405
+ oBusyDialog.close();
406
+ oBusyDialog.destroy();
407
+ }, AUTO_CLOSE_BUSY_DIALOG_TIME);
408
+ } catch (err) {
409
+ oLogger.error("Fragment load failed: " + err.message);
410
+ }
411
+
412
+ oCardData = await this._buildCardInfo(oParams);
413
+ } catch (err) {
414
+ oLogger.error("buildCardInfo failed: " + err.message);
415
+ } finally {
416
+ if (oCardData && Object.keys(oCardData).length === 0) {
417
+ oLogger.warn("Card info could not be saved.");
418
+ }
419
+
420
+ // Auth/Base card to unfurl
421
+ this._updateUrl(oParams, oCardData);
420
422
  }
421
423
  };
422
424
 
423
- TeamsHelperService.prototype._updateUrl = async function(oParams, oResponseData) {
424
- if (oParams.minifyUrlForChat) {
425
- CollaborationHelper.compactHash(oParams.url, []).then(async function (sShortURL) {
426
- var sModifiedUrl = await this._modifyUrlForNavigationContext(oParams.url, sShortURL.url);
427
- var sUrlForTab = await this._modifyUrlForShareAsTab(oParams.url, "MST:C");
428
- var sShortURLTab = await CollaborationHelper.compactHash(sUrlForTab, []);
429
- var sStageViewHash = sShortURLTab.url.split("sap-url-hash=")[1];
430
- // Scenario in which URL shortening is enabled, but the iAppState is set to Transient.
431
- if (sStageViewHash) {
432
- sModifiedUrl += `,${sStageViewHash}`;
433
- } else {
434
- sUrlForTab = await this._modifyUrlForShareAsTab(sModifiedUrl, "MST:C");
435
- sModifiedUrl = await this._addNavmodeInUrl(sUrlForTab, 'inplace');
425
+ /**
426
+ * Builds card information for a Teams collaboration card.
427
+ * This method calls the postCard API to create or retrieve card info.
428
+ * - On success: returns { cardId, version }.
429
+ * - On business error (e.g., APS_UI_MSG/001 when card already exists):
430
+ * tries to recover the card version from the error message and still returns { cardId, version }.
431
+ * - On other business errors: returns an empty object {}.
432
+ * - On technical errors (network/CSRF/JSON parsing): the promise rejects and should be caught by the caller.
433
+ *
434
+ * @param {Object} oParams - Parameters for building the card
435
+ * @param {string} oParams.cardId - The card ID
436
+ * @param {Object} oParams.cardManifest - The card manifest metadata
437
+ * @returns {Promise<Object>} - Resolves with card information { cardId, version } or {} if not available
438
+ * (may reject on technical errors)
439
+ */
440
+ TeamsHelperService.prototype._buildCardInfo = async function (oParams) {
441
+ // Set right-to-left layout based on localization settings
442
+ oParams.cardManifest.rtl = Localization.getRTL();
443
+ const postCardResponse = await CollaborationCardHelper.postCard(oParams.cardId, oParams.cardManifest);
444
+
445
+ let oCardData = {
446
+ cardId: postCardResponse.card_id,
447
+ version: postCardResponse.version
448
+ };
449
+
450
+ // Handle special error scenario where the card already exists
451
+ if (postCardResponse.error) {
452
+ if (postCardResponse.error.code === "APS_UI_MSG/001") {
453
+ // Card ID with same CardManifest detail is present so it will get version and open Teams Dialog
454
+ oCardData.cardId = oParams.cardId;
455
+ if (postCardResponse.error.message.length > 0){
456
+ try {
457
+ const sCardVersion = JSON.parse(atob(postCardResponse.error.message)).version;
458
+ oCardData.version = sCardVersion;
459
+ } catch (e) {
460
+ oCardData = {};
461
+ }
436
462
  }
437
- this._closeBusyDialogAndOpenTeamsDialog(sModifiedUrl, oParams, oResponseData);
438
- }.bind(this));
439
- } else {
440
- var sModifiedUrl = oParams.url;
441
- if (oTeamsParams.isShareAsTabEnabled && this._providerConfig.isShareAsTabEnabled) {
442
- var sUrlForTab = await this._modifyUrlForShareAsTab(sModifiedUrl, "MST:C");
463
+ } else {
464
+ oCardData = {};
465
+ }
466
+ }
467
+ return oCardData;
468
+ };
469
+
470
+ /**
471
+ * Updates the URL based on parameters, optionally minifying it for chat,
472
+ * and then opens the Teams dialog with the processed URL.
473
+ *
474
+ * @param {Object} oParams - Parameters including original URL and flags.
475
+ * @param {Object} oCardData - The card data containing cardId and version.
476
+ */
477
+ TeamsHelperService.prototype._updateUrl = async function(oParams, oCardData) {
478
+ let sModifiedUrl = oParams?.url || window.location.href;
479
+ try {
480
+ if (oParams.minifyUrlForChat) {
481
+ sModifiedUrl = await this._getModifiedUrlForSharing(oParams);
482
+ } else if (oTeamsParams.isShareAsTabEnabled && this._providerConfig.isShareAsTabEnabled) {
483
+ const sUrlForTab = await this._modifyUrlForShareAsTab(sModifiedUrl, "MST:C");
443
484
  sModifiedUrl = await this._addNavmodeInUrl(sUrlForTab, 'inplace');
444
485
  }
445
- this._closeBusyDialogAndOpenTeamsDialog(sModifiedUrl, oParams, oResponseData);
486
+ } catch (error) {
487
+ oLogger.error("Error while modifying URL for sharing: " + error.message);
488
+ } finally {
489
+ // Close busy dialog and open the Teams dialog with the final URL
490
+ this._closeBusyDialogAndOpenTeamsDialog(sModifiedUrl, oParams, oCardData);
446
491
  }
447
492
  };
448
493
 
449
- TeamsHelperService.prototype._closeBusyDailog = function() {
450
- if (oBusyDailog) {
451
- oBusyDailog.close();
452
- oBusyDailog.destroy();
453
- clearTimeout(iTimeoutId);
494
+ /**
495
+ * Generates a modified URL for sharing in Microsoft Teams.
496
+ * @param {Object} oParams - Parameters containing the original URL and flags.
497
+ * @returns {Promise<string>} - A fully processed URL ready to be used for sharing.
498
+ */
499
+ TeamsHelperService.prototype._getModifiedUrlForSharing = async function(oParams) {
500
+ const sShortURL = await CollaborationHelper.compactHash(oParams.url, []);
501
+ let sModifiedUrl = await this._modifyUrlForNavigationContext(oParams.url, sShortURL.url);
502
+ let sUrlForTab = await this._modifyUrlForShareAsTab(oParams.url, "MST:C");
503
+ const sShortURLTab = await CollaborationHelper.compactHash(sUrlForTab, []);
504
+ const sStageViewHash = sShortURLTab.url.split("sap-url-hash=")[1];
505
+
506
+ if (sStageViewHash) {
507
+ sModifiedUrl += `,${sStageViewHash}`;
508
+ } else {
509
+ sUrlForTab = await this._modifyUrlForShareAsTab(sModifiedUrl, "MST:C");
510
+ sModifiedUrl = await this._addNavmodeInUrl(sUrlForTab, 'inplace');
454
511
  }
512
+
513
+ return sModifiedUrl;
455
514
  };
456
515
 
457
- TeamsHelperService.prototype._closeBusyDialogAndOpenTeamsDialog = function(sUrl, oParams, response) {
458
- this._closeBusyDailog();
459
- var newWindow = window.open(
516
+ /**
517
+ * Closes and destroys the busy dialog, and clears timeout.
518
+ */
519
+ TeamsHelperService.prototype._closeBusyDialog = function() {
520
+ if (oBusyDialog) {
521
+ oBusyDialog.close();
522
+ oBusyDialog.destroy();
523
+ clearTimeout(iBusyDialogTimeoutId);
524
+ }
525
+ };
526
+
527
+ /**
528
+ * Closes the busy dialog and opens a new Teams dialog window with card info in the URL.
529
+ *
530
+ * @param {string} sUrl - URL with card info.
531
+ * @param {Object} oParams - Parameters including original URL and flags.
532
+ * @param {Object} oCardData - The card data containing cardId and version.
533
+ */
534
+ TeamsHelperService.prototype._closeBusyDialogAndOpenTeamsDialog = function(sUrl, oParams, oCardData) {
535
+ this._closeBusyDialog();
536
+ const newWindow = window.open(
460
537
  "",
461
538
  "_blank",
462
539
  windowWidthAndHeight
463
540
  );
464
541
  newWindow.opener = null;
465
- newWindow.location = this._addCardParamsInUrl(sUrl, oParams.appTitle, response);
542
+ newWindow.location = this._generateShareAsCardUrl(sUrl, oParams.appTitle, oCardData);
543
+ };
544
+
545
+ /**
546
+ * Converts a wildcard pattern to a regular expression
547
+ * @param {string} pattern - The wildcard pattern to convert
548
+ * @returns {RegExp} The resulting regular expression
549
+ */
550
+ TeamsHelperService.prototype._wildcardToRegExp = function(pattern) {
551
+ return new RegExp('^' + pattern.split('*').map(function(part) {
552
+ return part.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
553
+ }).join('[^.]+') + '$', 'i');
554
+ };
555
+
556
+ /**
557
+ * Checks if a given URL's domain is valid according to the validDomains list
558
+ * @param {string} url - The URL to check
559
+ * @returns {boolean} True if the domain is valid, false otherwise
560
+ */
561
+ TeamsHelperService.prototype._isValidDomain = function(url) {
562
+ try {
563
+ const domain = new URL(url).hostname;
564
+ return validDomains.some((pattern) =>
565
+ this._wildcardToRegExp(pattern).test(domain)
566
+ );
567
+ } catch (e) {
568
+ return false;
569
+ }
570
+ };
571
+
572
+ /**
573
+ * Generates the card info URL based on the provided parameters.
574
+ *
575
+ * @param {string} sUrl - The base URL to be processed.
576
+ * @param {Object} oParams - An object containing additional parameters.
577
+ * @param {string} oParams.appTitle - The title of the application.
578
+ * @param {Object} oCardData - The card data object.
579
+ * @returns {string} The processed URL with card info parameters.
580
+ */
581
+ TeamsHelperService.prototype._getCardInfoUrl = function(sUrl, oParams, oCardData) {
582
+ const isValid = this._isValidDomain(sUrl);
583
+ const sAppTitle = oParams?.appTitle;
584
+ if (isValid) {
585
+ return this._generateCardUnfurlingUrl(sUrl, oCardData, { appTitle: sAppTitle });
586
+ } else {
587
+ return this._generateShareAsCardUrl(sUrl, sAppTitle, oCardData);
588
+ }
466
589
  };
467
590
 
468
- TeamsHelperService.prototype._addCardParamsInUrl = function(sUrl, sAppTitle, response) {
469
- var aInfoField = [
470
- response.cardId || "",
471
- response.version || "",
472
- encodeURIComponent(sAppTitle)
473
- ].filter(Boolean);
474
- sUrl += `&${PARAM_SAP_CARD_INFO}=${aInfoField.join(",")}`;
475
- const encodeUrl = encodeURIComponent(sUrl);
591
+ /**
592
+ * Generates the full shareable Teams URL with card info.
593
+ *
594
+ * @param {string} sUrl - The card URL.
595
+ * @param {string} sAppTitle - The application title.
596
+ * @param {Object} oCardData - The card data containing cardId and version.
597
+ * @returns {string} Teams shareable URL.
598
+ */
599
+ TeamsHelperService.prototype._generateShareAsCardUrl = function(sUrl, sAppTitle, oCardData) {
600
+ const sCardInfoUrl = this._generateCardUnfurlingUrl(sUrl, oCardData, { appTitle: sAppTitle });
601
+
476
602
  // add the domain prefix to solve link unfurling issue for systems with different domain patterns
477
- return `${this._providerConfig.shareAsLinkUrl}?href=${encodeURIComponent(CARD_URL_PREFIX + encodeUrl)}`;
603
+ return `${this._providerConfig.shareAsLinkUrl}?href=${encodeURIComponent(CARD_URL_PREFIX + encodeURIComponent(sCardInfoUrl))}`;
478
604
  };
479
605
 
480
- TeamsHelperService.prototype._getShareAsTabUrl = function () {
606
+ /**
607
+ * Generates the unfurling URL with card info.
608
+ * Appends the SAP card info parameters (cardId, version, appTitle) to the given URL.
609
+ *
610
+ * @param {string} cardUrl - The base card URL to which the parameter will be appended.
611
+ * @param {Object} oCardData - The card data object containing cardId and version.
612
+ * @param {Object} oParams - The parameter object containing appTitle.
613
+ * @returns {string} The updated URL with the appended sap-card-info query parameter.
614
+ */
615
+ TeamsHelperService.prototype._generateCardUnfurlingUrl = function(cardUrl, oCardData, oParams) {
616
+ const infoFields = [
617
+ oCardData.cardId || "",
618
+ oCardData.version || "",
619
+ encodeURIComponent(oParams.appTitle || "")
620
+ ].filter(Boolean);
621
+
622
+ return `${cardUrl}&${PARAM_SAP_CARD_INFO}=${infoFields.join(",")}`;
623
+ };
624
+
625
+ TeamsHelperService.prototype._getShareAsTabUrl = function() {
481
626
  return this._getApplicationID().then(function(sTeamsAppID) {
482
627
  return "https://teams.microsoft.com/l/entity/" + sTeamsAppID + "/tab";
483
628
  });
484
629
  };
485
630
 
486
- TeamsHelperService.prototype._getApplicationID = function () {
631
+ TeamsHelperService.prototype._getApplicationID = function() {
487
632
  const UshellContainer = sap.ui.require("sap/ushell/Container");
488
633
  return UshellContainer && UshellContainer.getServiceAsync("URLParsing").then(function(oURLParsing) {
489
- return CollaborationHelper._getCurrentUrl().then(function (sCurrentUrl) {
634
+ return CollaborationHelper._getCurrentUrl().then(function(sCurrentUrl) {
490
635
  var sBeforeHashURL = sCurrentUrl.split("#")[0];
491
636
  if (sBeforeHashURL.indexOf('?') !== -1) {
492
637
  var oParsedUrl = oURLParsing && oURLParsing.parseParameters(sBeforeHashURL.substring(sBeforeHashURL.indexOf('?')));
@@ -509,7 +654,7 @@ sap.ui.define([
509
654
  * @returns {boolean} If set to true, Adaptive Card Generation is enabled
510
655
  * @private
511
656
  */
512
- TeamsHelperService.prototype.isFeatureFlagEnabled = function () {
657
+ TeamsHelperService.prototype.isFeatureFlagEnabled = function() {
513
658
  const bIsShareAsCardEnabled = this._providerConfig.isShareAsCardEnabled;
514
659
  return bIsShareAsCardEnabled === "AUTHENABLE";
515
660
  };
@@ -521,7 +666,7 @@ sap.ui.define([
521
666
  * @private
522
667
  */
523
668
 
524
- TeamsHelperService.prototype.isContactsCollaborationSupported = function () {
669
+ TeamsHelperService.prototype.isContactsCollaborationSupported = function() {
525
670
  return true;
526
671
  };
527
672
 
@@ -534,7 +679,7 @@ sap.ui.define([
534
679
  * @private
535
680
  */
536
681
 
537
- TeamsHelperService.prototype.enableContactsCollaboration = async function (sEmail, oParams) {
682
+ TeamsHelperService.prototype.enableContactsCollaboration = async function(sEmail, oParams) {
538
683
  const isTeamMode = await CollaborationHelper.isTeamsModeActive();
539
684
  const isContactServiceAvailable = await CollaborationContactInfoHelper.fetchServiceStatus();
540
685
  if (sEmail && isContactServiceAvailable.value && isContactServiceAvailable.value && isContactServiceAvailable.value[0].FetchContacts === "Active") {
@@ -563,7 +708,7 @@ sap.ui.define([
563
708
  * @private
564
709
  */
565
710
 
566
- TeamsHelperService.prototype.getTeamsContactCollabOptions = async function () {
711
+ TeamsHelperService.prototype.getTeamsContactCollabOptions = async function() {
567
712
  const isTeamMode = await CollaborationHelper.isTeamsModeActive();
568
713
  if (isTeamMode || this._providerConfig.isDirectCommunicationEnabled !== "ENABLED") {
569
714
  return Promise.reject();
@@ -581,7 +726,7 @@ sap.ui.define([
581
726
  * @private
582
727
  */
583
728
 
584
- TeamsHelperService.prototype.getTeamsContactStatus = async function (sEmail) {
729
+ TeamsHelperService.prototype.getTeamsContactStatus = async function(sEmail) {
585
730
  const isTeamMode = await CollaborationHelper.isTeamsModeActive();
586
731
  if (isTeamMode) {
587
732
  return Promise.reject();
@@ -592,25 +737,24 @@ sap.ui.define([
592
737
  return this.oContactHelper.getTeamsContactStatus(sEmail);
593
738
  };
594
739
 
595
-
596
-
597
740
  /**
598
741
  * Opens a Popup that helps to share content to teams, mail.
599
742
  * @param { object } oParams Optional argument in case consumer wants to influence the options, otherwise pass as undefined
600
743
  * @param { object } oData Title and data to share
601
744
  * @param { string } oSource The source to which the popover is rendered.
602
745
  * @param { boolean } isLink Indicates the data is a URL or not.
746
+ * @param { object } oCollaborationOptionsConfig Configuration options for collaboration (e.g., shareToTeams, shareToEmail, shareToCM).
603
747
  *
604
748
  */
605
749
  TeamsHelperService.prototype.getCollaborationPopover = function(oParams, oData, oSource, isLink, oCollaborationOptionsConfig) {
606
750
  if (oData.data === undefined || oData.data.trim() === "") {
607
- oLogger.error("Popover cannnot be opened without data");
608
- return;
609
- }
751
+ oLogger.error("Popover cannnot be opened without data");
752
+ return;
753
+ }
610
754
  var oTeamsParams = {
611
755
  isShareAsLinkEnabled: (oParams && typeof oParams.isShareAsLinkEnabled !== 'undefined') ? oParams.isShareAsLinkEnabled : true
612
756
  };
613
- var oCollaborationOptionsConfig = {
757
+ var oCollaborationOptionsCfg = {
614
758
  shareToTeams: oCollaborationOptionsConfig && typeof oCollaborationOptionsConfig.shareToTeams !== "undefined" ? oCollaborationOptionsConfig.shareToTeams : true,
615
759
  shareToEmail: oCollaborationOptionsConfig && typeof oCollaborationOptionsConfig.shareToEmail !== "undefined" ? oCollaborationOptionsConfig.shareToEmail : true,
616
760
  shareToCM: oCollaborationOptionsConfig && typeof oCollaborationOptionsConfig.shareToCM !== "undefined" ? oCollaborationOptionsConfig.shareToCM : false
@@ -618,7 +762,7 @@ sap.ui.define([
618
762
  var aOptions = [];
619
763
  if (Device.system.desktop) {
620
764
  if (oTeamsParams.isShareAsLinkEnabled) {
621
- if (this._providerConfig.isShareAsLinkEnabled === "X" && oCollaborationOptionsConfig.shareToTeams) {
765
+ if (this._providerConfig.isShareAsLinkEnabled === "X" && oCollaborationOptionsCfg.shareToTeams) {
622
766
  aOptions.push({
623
767
  "text": oResourceBundle.getText("COLLABORATION_POPOVER_TEAMS"),
624
768
  "icon": "sap-icon://discussion",
@@ -634,7 +778,7 @@ sap.ui.define([
634
778
  } else {
635
779
  oLogger.info("Share as Chat option is not supported in Phone and Tablet");
636
780
  }
637
- if (oCollaborationOptionsConfig.shareToEmail) {
781
+ if (oCollaborationOptionsCfg.shareToEmail) {
638
782
  aOptions.push({
639
783
  "text": oResourceBundle.getText("COLLABORATION_POPOVER_MAIL"),
640
784
  "icon": "sap-icon://email",
@@ -643,7 +787,7 @@ sap.ui.define([
643
787
  }
644
788
  this.oCollaborationManager = new CollaborationManagerService();
645
789
  var oCMOption = this.oCollaborationManager.getOptions();
646
- if (oCMOption && oCollaborationOptionsConfig.shareToCM) {
790
+ if (oCMOption && oCollaborationOptionsCfg.shareToCM) {
647
791
  aOptions.push({
648
792
  "text": oCMOption.text,
649
793
  "icon": oCMOption.icon,
@@ -663,9 +807,9 @@ sap.ui.define([
663
807
  * @param { object } oData Title and data to share
664
808
  * @param { array } aOptions Array of available options
665
809
  * @param { boolean } isLink Indicates the data is a URL or not.
666
- * @returns Returns the final Popover to the control.
810
+ * @returns {sap.m.Popover} Returns the final Popover to the control.
667
811
  */
668
- TeamsHelperService.prototype._getPopover = function(oData,aOptions,isLink) {
812
+ TeamsHelperService.prototype._getPopover = function(oData, aOptions, isLink) {
669
813
  var oCollaborationPopover = new Popover({
670
814
  showHeader: false,
671
815
  placement: oData.placement ? oData.placement : "Auto",
@@ -681,10 +825,11 @@ sap.ui.define([
681
825
  * @param { object } oData Title and data to share
682
826
  * @param { array } aOptions Array of available options
683
827
  * @param { boolean } isLink Indicates the data is a URL or not.
828
+ * @returns {sap.m.FlexBox} Returns the FlexBox containing the popover content.
684
829
  */
685
830
  TeamsHelperService.prototype._getPopoverContent = function(oData, aOptions, isLink) {
686
831
  var oMainFBox = new FlexBox({
687
- items:[],
832
+ items: [],
688
833
  direction: sapMLibrary.FlexDirection.Column
689
834
  });
690
835
  var oOptionFBox = new FlexBox({
@@ -694,8 +839,8 @@ sap.ui.define([
694
839
  });
695
840
  aOptions.forEach((oOption) => {
696
841
  var button = new Button({
697
- text:oOption.text,
698
- icon:oOption.icon,
842
+ text: oOption.text,
843
+ icon: oOption.icon,
699
844
  width: oData.sFormat === "Horizontal" && aOptions.length === 3 ? "120px" : "180px",
700
845
  press: (oEvent) => {
701
846
  oEvent.getSource().getParent().getParent().getParent().close();
@@ -722,7 +867,7 @@ sap.ui.define([
722
867
  new Button({
723
868
  text: oResourceBundle.getText("COLLABORATION_POPOVER_COPYURL_BUTTON"),
724
869
  width: oData.sFormat === "Vertical" ? "150px" : "",
725
- press: async() => {
870
+ press: async () => {
726
871
  await this._writeToClipBoard(oData.data);
727
872
  }
728
873
  }).addStyleClass("sapUiTinyMarginBeginEnd")
@@ -756,13 +901,13 @@ sap.ui.define([
756
901
  * @param { text } sText Text to copy to the cilpboard
757
902
  * Writes the given URL to the clipboard
758
903
  */
759
- TeamsHelperService.prototype._writeToClipBoard = async function (sText) {
904
+ TeamsHelperService.prototype._writeToClipBoard = async function(sText) {
760
905
  try {
761
- await navigator.clipboard.writeText(sText);
906
+ await window.navigator.clipboard.writeText(sText);
762
907
  } catch (e) {
763
908
  oLogger.info(e);
764
909
  }
765
- }
910
+ };
766
911
 
767
912
  /**
768
913
  *
@@ -773,23 +918,23 @@ sap.ui.define([
773
918
  TeamsHelperService.prototype._shareData = function(oData, oOption, isLink) {
774
919
  if (oOption.key === "COLLABORATION_POPOVER_TEAMS") {
775
920
  if (isLink) {
776
- var oShareData = {
921
+ var oShareDataLink = {
777
922
  url: oData.data,
778
923
  appTitle: oData.title ? oData.title : "",
779
924
  subTitle: "",
780
925
  minifyUrlForChat: true
781
926
  };
782
- this._shareAsChat(oShareData);
927
+ this._shareAsChat(oShareDataLink);
783
928
  } else {
784
- var oShareData = {
929
+ var oShareDataSummary = {
785
930
  appTitle: oData.title ? oData.title : "",
786
931
  message: oData.data,
787
932
  showPreview: typeof oData.showPreview !== "undefined" ? oData.showPreview : true
788
933
  };
789
- this._shareSummary(oShareData);
934
+ this._shareSummary(oShareDataSummary);
790
935
  }
791
936
  } else if (oOption.key === "COLLABORATION_POPOVER_MAIL") {
792
- sap.m.URLHelper.triggerEmail(null, oData.title && oData.title.trim() !== "" ? oData.title: null, oData.data);
937
+ sap.m.URLHelper.triggerEmail(null, oData.title && oData.title.trim() !== "" ? oData.title : null, oData.data);
793
938
  } else if (oOption.key === "COLLABORATION_POPOVER_CM") {
794
939
  this.oCollaborationManager.triggerH2HChat(oData.title, oData.data);
795
940
  }
@@ -813,5 +958,156 @@ sap.ui.define([
813
958
  sap.m.URLHelper.redirect(sURL, true);
814
959
 
815
960
  };
961
+
962
+ /**
963
+ * Shares the current or unfurled URL via email.
964
+ * @param {Object} oParams - Parameters for sharing.
965
+ * @param {string} [oParams.url] - The base URL to share.
966
+ * @param {string} [oParams.appTitle] - The subject of the email.
967
+ * @returns {Promise<void>} A promise that resolves when the email sharing process is complete.
968
+ */
969
+ TeamsHelperService.prototype._shareToEmail = async function (oParams) {
970
+ let sUnfurlingUrl = oParams?.url || window.location.href;
971
+ try {
972
+ sUnfurlingUrl = await this._getUnfurlingUrl(oParams);
973
+ } catch (error) {
974
+ oLogger.error("getUnfurlingUrl failed: " + error.message);
975
+ }
976
+
977
+ const sSubject = oParams?.appTitle?.trim() ? oParams.appTitle : null;
978
+ sap.m.URLHelper.triggerEmail(null, sSubject, sUnfurlingUrl);
979
+ };
980
+
981
+ /**
982
+ * Shares a card from the collaboration bar.
983
+ * @param {Object} params - Parameters for sharing the card.
984
+ */
985
+ TeamsHelperService.prototype._shareAsChatFromCollabBar = async function (params) {
986
+ try {
987
+ await this._shareAsCard(params);
988
+ } catch (error) {
989
+ oLogger.error("Failed to share card from collaboration bar: " + error.message);
990
+ }
991
+ };
992
+
993
+ /**
994
+ * Copies the unfurled card URL to the clipboard.
995
+ * @param {Object} oParams - Parameters for sharing.
996
+ * @param {string} [oParams.url] - The base URL to copy.
997
+ * @returns {Promise<void>} A promise that resolves when the URL has been copied to the clipboard.
998
+ */
999
+ TeamsHelperService.prototype._copyLink = async function (oParams) {
1000
+ let sUnfurlingUrl = oParams?.url || window.location.href;
1001
+ try {
1002
+ sUnfurlingUrl = await this._getUnfurlingUrl(oParams);
1003
+ } catch (error) {
1004
+ oLogger.error("getUnfurlingUrl failed: " + error.message);
1005
+ }
1006
+
1007
+ this._copyCardUrlToClipboard(sUnfurlingUrl);
1008
+ };
1009
+
1010
+ /**
1011
+ * Copies a given URL string into the clipboard.
1012
+ * @param {string} sUrl - The URL to copy into the clipboard.
1013
+ * @returns {Promise<void>} A promise that resolves when the URL has been copied to the clipboard.
1014
+ */
1015
+ TeamsHelperService.prototype._copyCardUrlToClipboard = async function(sUrl) {
1016
+ try {
1017
+ if (typeof window.navigator !== "undefined" &&
1018
+ window.navigator.clipboard &&
1019
+ typeof window.navigator.clipboard.writeText === "function") {
1020
+ try {
1021
+ await window.navigator.clipboard.writeText(sUrl);
1022
+ oLogger.info("Card URL copied to clipboard successfully.");
1023
+ sap.m.MessageToast.show(oResourceBundle.getText("COLLABORATION_POPOVER_MSGSTRIP_SUCCESS"));
1024
+ } catch (e) {
1025
+ oLogger.error("Clipboard write failed: " + e.message);
1026
+ }
1027
+ } else {
1028
+ oLogger.error("Clipboard API is not available.");
1029
+ }
1030
+
1031
+ } catch (err) {
1032
+ oLogger.error("Failed to generate or copy Card URL", err);
1033
+ }
1034
+ };
1035
+
1036
+ /**
1037
+ * Gets the unfurling URL for a card.
1038
+ * If cardId and cardManifest are provided, saves the card data and shows a busy dialog.
1039
+ * Otherwise, returns a base unfurling URL.
1040
+ * @param {Object} oParams - Parameters for the card.
1041
+ * @param {string} [oParams.url] - Base URL for the card.
1042
+ * @param {string} [oParams.cardId] - The card ID.
1043
+ * @param {Object} [oParams.cardManifest] - The card manifest definition.
1044
+ * @returns {Promise<string>} The unfurling URL.
1045
+ */
1046
+ TeamsHelperService.prototype._getUnfurlingUrl = async function(oParams) {
1047
+ if (!oParams?.cardId || !oParams.cardId.length || !oParams.cardManifest || !this.isFeatureFlagEnabled()) {
1048
+ // Base Card to unfurl
1049
+ return this._generateUnfurlingUrl(oParams, {});
1050
+ }
1051
+
1052
+ let sUnfurlingUrl = "";
1053
+ let oCardData = {};
1054
+ try {
1055
+ // Card Id and Card Manifest Passed. It will show busy helper and store card into DB.
1056
+ try {
1057
+ const oDialog = await Fragment.load({
1058
+ name: "sap.suite.ui.commons.collaboration.CollaborationBusyDialog",
1059
+ controller: this,
1060
+ type: "XML"
1061
+ });
1062
+ oBusyDialog = oDialog;
1063
+ oBusyDialog.open();
1064
+
1065
+ // Automatically close the dialog after a fixed time
1066
+ iBusyDialogTimeoutId = setTimeout(() => {
1067
+ oBusyDialog.close();
1068
+ oBusyDialog.destroy();
1069
+ }, AUTO_CLOSE_BUSY_DIALOG_TIME);
1070
+ } catch (err) {
1071
+ oLogger.error("Fragment load failed: " + err.message);
1072
+ }
1073
+
1074
+ oCardData = await this._buildCardInfo(oParams);
1075
+ } catch (err) {
1076
+ oLogger.error("buildCardInfo failed: " + err.message);
1077
+ } finally {
1078
+ if (oCardData && Object.keys(oCardData).length === 0) {
1079
+ oLogger.warn("Card info could not be saved.");
1080
+ }
1081
+
1082
+ // Auth/Base card to unfurl
1083
+ sUnfurlingUrl = this._generateUnfurlingUrl(oParams, oCardData);
1084
+ this._closeBusyDialog();
1085
+ }
1086
+
1087
+ return sUnfurlingUrl;
1088
+ };
1089
+
1090
+ /**
1091
+ * Generates a URL for unfurling a card in Microsoft Teams.
1092
+ * Handles minification, share-as-tab logic, and adds navigation modes.
1093
+ * @param {Object} oParams - Parameters for the card.
1094
+ * @param {Object} oCardData - The card data (id, version, etc.).
1095
+ * @returns {Promise<string>} The generated unfurling URL.
1096
+ */
1097
+ TeamsHelperService.prototype._generateUnfurlingUrl = async function(oParams, oCardData) {
1098
+ let sModifiedUrl = oParams?.url || window.location.href;
1099
+ try {
1100
+ if (oParams?.minifyUrlForChat) {
1101
+ sModifiedUrl = await this._getModifiedUrlForSharing(oParams);
1102
+ } else if (oTeamsParams.isShareAsTabEnabled && this._providerConfig.isShareAsTabEnabled) {
1103
+ const sUrlForTab = await this._modifyUrlForShareAsTab(sModifiedUrl, "MST:C");
1104
+ sModifiedUrl = await this._addNavmodeInUrl(sUrlForTab, 'inplace');
1105
+ }
1106
+ } catch (error) {
1107
+ oLogger.error("Error while modifying URL for sharing: " + error.message);
1108
+ }
1109
+ return this._getCardInfoUrl(sModifiedUrl, oParams, oCardData);
1110
+ };
1111
+
816
1112
  return TeamsHelperService;
817
1113
  });