Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
revert(sheets): "fix: sheet protection not work" (#6141)
WEI ZHANGf31e2cf1cf14
diff --git a/packages/sheets/src/commands/commands/add-worksheet-protection.command.ts b/packages/sheets/src/commands/commands/add-worksheet-protection.command.tsindex a594868207..29f7fc20a9 100644--- a/packages/sheets/src/commands/commands/add-worksheet-protection.command.ts+++ b/packages/sheets/src/commands/commands/add-worksheet-protection.command.ts@@ -19,7 +19,6 @@ import type { IWorksheetProtectionRule } from '../../services/permission/type';import { CommandType, ICommandService, IUndoRedoService } from '@univerjs/core';import { AddWorksheetProtectionMutation } from '../mutations/add-worksheet-protection.mutation';import { DeleteWorksheetProtectionMutation } from '../mutations/delete-worksheet-protection.mutation';-import { SetWorksheetPermissionPointsMutation } from '../mutations/set-worksheet-permission-points.mutation';export interface IAddWorksheetProtectionParams {unitId: string;@@ -38,17 +37,6 @@ export const AddWorksheetProtectionCommand: ICommand<IAddWorksheetProtectionParaconst { rule, unitId } = params;const subUnitId = rule.subUnitId;- // Add the permission point rule first- await commandService.executeCommand(SetWorksheetPermissionPointsMutation.id, {- rule: {- unitId,- subUnitId,- permissionId: rule.permissionId,- },- unitId,- subUnitId,- });-const result = await commandService.executeCommand(AddWorksheetProtectionMutation.id, {unitId,rule,@@ -56,10 +44,7 @@ export const AddWorksheetProtectionCommand: ICommand<IAddWorksheetProtectionPara});if (result) {- const redoMutations = [- { id: SetWorksheetPermissionPointsMutation.id, params: { rule: { unitId, subUnitId, permissionId: rule.permissionId }, unitId, subUnitId } },- { id: AddWorksheetProtectionMutation.id, params: { unitId, rule, subUnitId: rule.subUnitId } },- ];+ const redoMutations = [{ id: AddWorksheetProtectionMutation.id, params: { unitId, rule, subUnitId: rule.subUnitId } }];const undoMutations = [{ id: DeleteWorksheetProtectionMutation.id, params: { unitId, subUnitId } }];undoRedoService.pushUndoRedo({unitID: unitId,diff --git a/packages/sheets/src/commands/commands/delete-worksheet-protection.command.ts b/packages/sheets/src/commands/commands/delete-worksheet-protection.command.tsindex b8fd06b674..d1f75d6e57 100644--- a/packages/sheets/src/commands/commands/delete-worksheet-protection.command.ts+++ b/packages/sheets/src/commands/commands/delete-worksheet-protection.command.ts@@ -19,7 +19,6 @@ import type { IWorksheetProtectionRule } from '../../services/permission/type';import { CommandType, ICommandService, IUndoRedoService } from '@univerjs/core';import { AddWorksheetProtectionMutation } from '../mutations/add-worksheet-protection.mutation';import { DeleteWorksheetProtectionMutation } from '../mutations/delete-worksheet-protection.mutation';-import { SetWorksheetPermissionPointsMutation } from '../mutations/set-worksheet-permission-points.mutation';export interface IDeleteWorksheetProtectionParams {unitId: string;@@ -44,10 +43,7 @@ export const DeleteWorksheetProtectionCommand: ICommand<IDeleteWorksheetProtecti});const redoMutations = [{ id: DeleteWorksheetProtectionMutation.id, params: { unitId, subUnitId } }];- const undoMutations = [- { id: AddWorksheetProtectionMutation.id, params: { unitId, rule, subUnitId } },- { id: SetWorksheetPermissionPointsMutation.id, params: { rule: { unitId, subUnitId, permissionId: rule.permissionId }, unitId, subUnitId } },- ];+ const undoMutations = [{ id: AddWorksheetProtectionMutation.id, params: { unitId, rule, subUnitId } }];undoRedoService.pushUndoRedo({unitID: unitId,redoMutations,diff --git a/packages/sheets/src/commands/mutations/delete-worksheet-protection.mutation.ts b/packages/sheets/src/commands/mutations/delete-worksheet-protection.mutation.tsindex fcd86234dc..8a0ce8594e 100644--- a/packages/sheets/src/commands/mutations/delete-worksheet-protection.mutation.ts+++ b/packages/sheets/src/commands/mutations/delete-worksheet-protection.mutation.ts@@ -17,7 +17,6 @@import type { IMutation } from '@univerjs/core';import { CommandType } from '@univerjs/core';import { SheetPermissionInitController } from '../../controllers/permission/sheet-permission-init.controller';-import { WorksheetProtectionPointModel } from '../../services/permission/worksheet-permission/worksheet-permission-point.model';import { WorksheetProtectionRuleModel } from '../../services/permission/worksheet-permission/worksheet-permission-rule.model';export interface IDeleteWorksheetProtectionParams {@@ -30,7 +29,6 @@ export const DeleteWorksheetProtectionMutation: IMutation<IDeleteWorksheetProtectype: CommandType.MUTATION,handler: (accessor, params) => {const worksheetProtectionRuleModel = accessor.get(WorksheetProtectionRuleModel);- const worksheetProtectionPointModel = accessor.get(WorksheetProtectionPointModel);const sheetPermissionInitController = accessor.get(SheetPermissionInitController);if (!sheetPermissionInitController.getIsPermissionInitFinish()) {sheetPermissionInitController.addCmdToBufferList({@@ -42,7 +40,6 @@ export const DeleteWorksheetProtectionMutation: IMutation<IDeleteWorksheetProtecconst { unitId, subUnitId } = params;worksheetProtectionRuleModel.deleteRule(unitId, subUnitId);- worksheetProtectionPointModel.deleteRule(unitId, subUnitId);return true;},};