@c8y/ngx-components 1017.0.261 → 1017.0.263

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.
@@ -5544,11 +5544,9 @@ class Permissions {
5544
5544
  return currentUserName === data.owner;
5545
5545
  }
5546
5546
  checkWithRequest(mo) {
5547
- const moName = mo.name;
5548
5547
  const moId = mo.id;
5549
5548
  const partialUpdateObject = {
5550
- id: moId,
5551
- name: moName
5549
+ id: moId
5552
5550
  };
5553
5551
  return this.inventory
5554
5552
  .update(partialUpdateObject)
@@ -18511,7 +18509,8 @@ class PluginsService {
18511
18509
  async listPackages(params = {}) {
18512
18510
  const apps = await this.listApplicationsByCurrentTenant(params);
18513
18511
  const webApps = apps.filter(app => this.isPackage(app));
18514
- return webApps.sort((a, b) => a.name.localeCompare(b.name));
18512
+ const uniqueWebApps = this.removeDuplicates(webApps, 'contextPath');
18513
+ return uniqueWebApps.sort((a, b) => a.name.localeCompare(b.name));
18515
18514
  }
18516
18515
  /**
18517
18516
  * Checks if an application is a package.
@@ -18647,6 +18646,39 @@ class PluginsService {
18647
18646
  getMFRemotes(application) {
18648
18647
  return application?.config?.remotes;
18649
18648
  }
18649
+ /**
18650
+ * Verifies if an application is owned by management tenant.
18651
+ *
18652
+ * @param app The application to verify.
18653
+ * @returns True if owned by management tenant.
18654
+ */
18655
+ isOwnedByManagement(app) {
18656
+ const appOwner = get(app, 'owner.tenant.id');
18657
+ return appOwner === 'management';
18658
+ }
18659
+ removeDuplicates(apps, key) {
18660
+ const uniqueList = [];
18661
+ const groupedAppsByKey = groupBy(apps, key);
18662
+ const groupedApps = Object.keys(groupedAppsByKey).map(key => groupedAppsByKey[key]);
18663
+ for (const appsGroup of groupedApps) {
18664
+ if (appsGroup.length < 2) {
18665
+ uniqueList.push(...appsGroup);
18666
+ }
18667
+ else {
18668
+ const appFromCurrentTenant = appsGroup.find(app => this.isFromCurrentTenant(app));
18669
+ if (appFromCurrentTenant) {
18670
+ uniqueList.push(appFromCurrentTenant);
18671
+ continue;
18672
+ }
18673
+ const appNotOwnedByManagement = appsGroup.find(app => !this.isOwnedByManagement(app));
18674
+ uniqueList.push(appNotOwnedByManagement);
18675
+ }
18676
+ }
18677
+ return uniqueList;
18678
+ }
18679
+ isFromCurrentTenant(app) {
18680
+ return app.owner.tenant.id === this.appStateService.currentTenant.value.name;
18681
+ }
18650
18682
  /**
18651
18683
  * Modifies the list of plugins to have additional information such as id.
18652
18684
  * @ignore