Override deprecated values on sync
This commit is contained in:
parent
a6e3d4d244
commit
f0c25a6996
|
@ -616,7 +616,7 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction";
|
||||||
{
|
{
|
||||||
provide: OrganizationServiceAbstraction,
|
provide: OrganizationServiceAbstraction,
|
||||||
useClass: OrganizationService,
|
useClass: OrganizationService,
|
||||||
deps: [StateServiceAbstraction],
|
deps: [StateServiceAbstraction, ConfigServiceAbstraction],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: InternalOrganizationServiceAbstraction,
|
provide: InternalOrganizationServiceAbstraction,
|
||||||
|
|
|
@ -184,14 +184,29 @@ export class Organization {
|
||||||
return this.canEditAnyCollection || this.canDeleteAnyCollection;
|
return this.canEditAnyCollection || this.canDeleteAnyCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* This is deprecated with the introduction of Flexible Collections.
|
||||||
|
* This will always return false if FlexibleCollections flag is on.
|
||||||
|
*/
|
||||||
get canEditAssignedCollections() {
|
get canEditAssignedCollections() {
|
||||||
return this.isManager || this.permissions.editAssignedCollections;
|
return this.isManager || this.permissions.editAssignedCollections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* This is deprecated with the introduction of Flexible Collections.
|
||||||
|
* This will always return false if FlexibleCollections flag is on.
|
||||||
|
*/
|
||||||
get canDeleteAssignedCollections() {
|
get canDeleteAssignedCollections() {
|
||||||
return this.isManager || this.permissions.deleteAssignedCollections;
|
return this.isManager || this.permissions.deleteAssignedCollections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* This is deprecated with the introduction of Flexible Collections.
|
||||||
|
* This will always return false if FlexibleCollections flag is on.
|
||||||
|
*/
|
||||||
get canViewAssignedCollections() {
|
get canViewAssignedCollections() {
|
||||||
return this.canDeleteAssignedCollections || this.canEditAssignedCollections;
|
return this.canDeleteAssignedCollections || this.canEditAssignedCollections;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import { BehaviorSubject, concatMap, map, Observable } from "rxjs";
|
import { BehaviorSubject, concatMap, map, Observable } from "rxjs";
|
||||||
|
|
||||||
|
import { FeatureFlag } from "../../../enums/feature-flag.enum";
|
||||||
|
import { ConfigServiceAbstraction } from "../../../platform/abstractions/config/config.service.abstraction";
|
||||||
import { StateService } from "../../../platform/abstractions/state.service";
|
import { StateService } from "../../../platform/abstractions/state.service";
|
||||||
import {
|
import {
|
||||||
InternalOrganizationServiceAbstraction,
|
InternalOrganizationServiceAbstraction,
|
||||||
isMember,
|
isMember,
|
||||||
} from "../../abstractions/organization/organization.service.abstraction";
|
} from "../../abstractions/organization/organization.service.abstraction";
|
||||||
|
import { OrganizationUserType } from "../../enums";
|
||||||
import { OrganizationData } from "../../models/data/organization.data";
|
import { OrganizationData } from "../../models/data/organization.data";
|
||||||
import { Organization } from "../../models/domain/organization";
|
import { Organization } from "../../models/domain/organization";
|
||||||
|
|
||||||
|
@ -14,7 +17,7 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
|
||||||
organizations$ = this._organizations.asObservable();
|
organizations$ = this._organizations.asObservable();
|
||||||
memberOrganizations$ = this.organizations$.pipe(map((orgs) => orgs.filter(isMember)));
|
memberOrganizations$ = this.organizations$.pipe(map((orgs) => orgs.filter(isMember)));
|
||||||
|
|
||||||
constructor(private stateService: StateService) {
|
constructor(private stateService: StateService, private configService: ConfigServiceAbstraction) {
|
||||||
this.stateService.activeAccountUnlocked$
|
this.stateService.activeAccountUnlocked$
|
||||||
.pipe(
|
.pipe(
|
||||||
concatMap(async (unlocked) => {
|
concatMap(async (unlocked) => {
|
||||||
|
@ -103,6 +106,20 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
|
||||||
}
|
}
|
||||||
|
|
||||||
async replace(organizations: { [id: string]: OrganizationData }) {
|
async replace(organizations: { [id: string]: OrganizationData }) {
|
||||||
|
// If Flexible Collections is enabled, treat Managers as Users and ignore deprecated permissions
|
||||||
|
if (await this.configService.getFeatureFlag(FeatureFlag.FlexibleCollections)) {
|
||||||
|
Object.values(organizations).forEach((o) => {
|
||||||
|
if (o.type === OrganizationUserType.Manager) {
|
||||||
|
o.type = OrganizationUserType.User;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o.permissions != null) {
|
||||||
|
o.permissions.editAssignedCollections = false;
|
||||||
|
o.permissions.deleteAssignedCollections = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await this.stateService.setOrganizations(organizations);
|
await this.stateService.setOrganizations(organizations);
|
||||||
this.updateObservables(organizations);
|
this.updateObservables(organizations);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue