Skip to content

Commit

Permalink
fix: hide sheet should operation right sheet (#3468)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybzky authored Sep 19, 2024
1 parent 4bc700b commit a4bfe0d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { UnitAction } from '@univerjs/protocol';
import { ClearSelectionContentCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, getSheetCommandTarget, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, MoveColsCommand, MoveRangeCommand, MoveRowsCommand, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, SetBackgroundColorCommand, SetColWidthCommand, SetRangeValuesCommand, SetRowHeightCommand, SetSelectedColsVisibleCommand, SetSelectedRowsVisibleCommand, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetNameCommand, SetWorksheetNameMutation, SetWorksheetOrderCommand, SetWorksheetRowIsAutoHeightCommand, SetWorksheetShowCommand, SheetsSelectionsService, WorkbookCopyPermission, WorkbookEditablePermission, WorkbookHideSheetPermission, WorkbookManageCollaboratorPermission, WorkbookMoveSheetPermission, WorkbookRenameSheetPermission, WorksheetCopyPermission, WorksheetEditPermission, WorksheetProtectionRuleModel, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, WorksheetViewPermission } from '@univerjs/sheets';
import { IDialogService } from '@univerjs/ui';
import type { ICellData, ICellDataForSheetInterceptor, ICommandInfo, IObjectMatrixPrimitiveType, IPermissionTypes, IRange, Nullable, Workbook, WorkbookPermissionPointConstructor, Worksheet } from '@univerjs/core';
import type { IMoveColsCommandParams, IMoveRangeCommandParams, IMoveRowsCommandParams, ISetRangeValuesCommandParams, ISetSpecificColsVisibleCommandParams, ISetSpecificRowsVisibleCommandParams, ISetWorksheetNameMutationParams } from '@univerjs/sheets';
import type { IMoveColsCommandParams, IMoveRangeCommandParams, IMoveRowsCommandParams, ISetRangeValuesCommandParams, ISetSpecificColsVisibleCommandParams, ISetSpecificRowsVisibleCommandParams, ISetWorksheetNameMutationParams, ISetWorksheetShowCommandParams } from '@univerjs/sheets';
import { AutoFillCommand } from '../../commands/commands/auto-fill.command';
import { SheetCopyCommand, SheetCutCommand, SheetPasteColWidthCommand, SheetPasteShortKeyCommand } from '../../commands/commands/clipboard.command';
import { SetRangeBoldCommand, SetRangeItalicCommand, SetRangeStrickThroughCommand, SetRangeUnderlineCommand } from '../../commands/commands/inline-format.command';
Expand Down Expand Up @@ -238,10 +238,13 @@ export class SheetPermissionInterceptorBaseController extends Disposable {
}
break;
case SetWorksheetShowCommand.id:
permission = this._permissionCheckByWorksheetCommand([WorkbookEditablePermission, WorkbookHideSheetPermission]);
errorMsg = this._localeService.t('permission.dialog.operatorSheetErr');
if (permission === false) {
this._worksheetProtectionRuleModel.resetOrder();
{
const { unitId, subUnitId } = params as ISetWorksheetShowCommandParams;
permission = this._permissionCheckByWorksheetCommand([WorkbookEditablePermission, WorkbookHideSheetPermission], unitId, subUnitId);
errorMsg = this._localeService.t('permission.dialog.operatorSheetErr');
if (permission === false) {
this._worksheetProtectionRuleModel.resetOrder();
}
}
break;

Expand Down Expand Up @@ -369,8 +372,8 @@ export class SheetPermissionInterceptorBaseController extends Disposable {
return true;
}

private _permissionCheckByWorksheetCommand(types: WorkbookPermissionPointConstructor[]) {
const target = getSheetCommandTarget(this._univerInstanceService);
private _permissionCheckByWorksheetCommand(types: WorkbookPermissionPointConstructor[], targetUnitId?: string, targetSubUnitId?: string) {
const target = getSheetCommandTarget(this._univerInstanceService, { unitId: targetUnitId, subUnitId: targetSubUnitId });
if (!target) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions packages/sheets/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export {
type ISetWorksheetRowIsAutoHeightCommandParams,
} from './commands/commands/set-worksheet-row-height.command';
export { SetWorksheetShowCommand } from './commands/commands/set-worksheet-show.command';
export type { ISetWorksheetShowCommandParams } from './commands/commands/set-worksheet-show.command';
export { AddRangeProtectionMutation, FactoryAddRangeProtectionMutation, type IAddRangeProtectionMutationParams } from './commands/mutations/add-range-protection.mutation';
export { AddWorksheetMergeMutation, AddMergeUndoMutationFactory } from './commands/mutations/add-worksheet-merge.mutation';
export { AddWorksheetProtectionMutation, type IAddWorksheetProtectionParams } from './commands/mutations/add-worksheet-protection.mutation';
Expand Down

0 comments on commit a4bfe0d

Please sign in to comment.