Skip to content

Commit

Permalink
feat: add record-locking feature to WCP license (#4073)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j authored Apr 9, 2024
1 parent 5b01770 commit 7f3380f
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/api-aco/__tests__/utils/createTestWcpLicense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export const createTestWcpLicense = (): DecryptedWcpProjectLicense => {
[PROJECT_PACKAGE_FEATURE_NAME.AUDIT_LOGS]: {
enabled: false
},
[PROJECT_PACKAGE_FEATURE_NAME.RECORD_LOCKING]: {
enabled: false
},
[PROJECT_PACKAGE_FEATURE_NAME.SEATS]: {
enabled: true,
options: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export const createTestWcpLicense = (): DecryptedWcpProjectLicense => {
[PROJECT_PACKAGE_FEATURE_NAME.AUDIT_LOGS]: {
enabled: false
},
[PROJECT_PACKAGE_FEATURE_NAME.RECORD_LOCKING]: {
enabled: false
},
[PROJECT_PACKAGE_FEATURE_NAME.SEATS]: {
enabled: true,
options: {
Expand Down
2 changes: 2 additions & 0 deletions packages/api-wcp/__tests__/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ describe("context", () => {
canUseFolderLevelPermissions: expect.any(Function),
canUsePrivateFiles: expect.any(Function),
canUseTeams: expect.any(Function),
canUseAuditLogs: expect.any(Function),
canUseRecordLocking: expect.any(Function),
decrementSeats: expect.any(Function),
incrementTenants: expect.any(Function),
decrementTenants: expect.any(Function)
Expand Down
8 changes: 8 additions & 0 deletions packages/api-wcp/src/createWcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ export const createWcp = async (params: CreateWcpParams = {}): Promise<WcpContex
return license!.package.features.advancedAccessControlLayer.options.privateFiles;
},

canUseAuditLogs() {
return this.canUseFeature("auditLogs");
},

canUseRecordLocking() {
return this.canUseFeature("recordLocking");
},

ensureCanUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL) {
if (this.canUseFeature(wcpFeatureId)) {
return;
Expand Down
14 changes: 13 additions & 1 deletion packages/app-wcp/src/hooks/useWcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ interface UseWcpHook {
canUseTeams: () => boolean;
canUsePrivateFiles: () => boolean;
canUseFolderLevelPermissions: () => boolean;
canUseAuditLogs: () => boolean;
canUseRecordLocking: () => boolean;
}

export function useWcp(): UseWcpHook {
Expand Down Expand Up @@ -65,12 +67,22 @@ export function useWcp(): UseWcpHook {
return advancedAccessControlLayer.options.privateFiles;
};

const canUseAuditLogs = () => {
return canUseFeature("auditLogs");
};

const canUseRecordLocking = () => {
return canUseFeature("recordLocking");
};

return {
getProject,
canUseFeature,
canUseAacl,
canUseTeams,
canUseFolderLevelPermissions,
canUsePrivateFiles
canUsePrivateFiles,
canUseAuditLogs,
canUseRecordLocking
};
}
3 changes: 3 additions & 0 deletions packages/app-wcp/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export type WcpProjectPackage = {
auditLogs: {
enabled: boolean;
};
recordLocking: {
enabled: boolean;
};
};
};

Expand Down
3 changes: 2 additions & 1 deletion packages/wcp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export const WCP_FEATURE_LABEL = {
multiTenancy: "Multi-tenancy",
advancedPublishingWorkflow: "Advanced Publishing Workflow (APW)",
advancedAccessControlLayer: "Advanced Access Control Layer (ACL)",
auditLogs: "Audit Logs"
auditLogs: "Audit Logs",
recordLocking: "Record Locking"
};
6 changes: 5 additions & 1 deletion packages/wcp/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export enum PROJECT_PACKAGE_FEATURE_NAME {
APW = "advancedPublishingWorkflow",
AACL = "advancedAccessControlLayer",
AL = "auditLogs",
AUDIT_LOGS = "auditLogs"
AUDIT_LOGS = "auditLogs",
RECORD_LOCKING = "recordLocking"
}

export enum MT_OPTIONS_MAX_COUNT_TYPE {
Expand Down Expand Up @@ -49,6 +50,9 @@ export interface ProjectPackageFeatures {
[PROJECT_PACKAGE_FEATURE_NAME.AUDIT_LOGS]: {
enabled: boolean;
};
[PROJECT_PACKAGE_FEATURE_NAME.RECORD_LOCKING]: {
enabled: boolean;
};
[PROJECT_PACKAGE_FEATURE_NAME.AACL]: {
enabled: boolean;
options: { teams: boolean; privateFiles: boolean; folderLevelPermissions: boolean };
Expand Down

0 comments on commit 7f3380f

Please sign in to comment.