Skip to content

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.

fix: fix permissions wrong reference render-engine in sheets package (#2396)

ybzky10387e48b92a
diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts
index afd711961d..aa379026fb 100644
--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts
+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.render.controller.ts
@@ -16,8 +16,9 @@
import type { Workbook } from '@univerjs/core';
import { Disposable, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
-import type { IRangeProtectionRenderCellData, IRangeProtectionRule, IWorksheetProtectionRenderCellData } from '@univerjs/sheets';
+import type { IRangeProtectionRule, IWorksheetProtectionRenderCellData } from '@univerjs/sheets';
import { INTERCEPTOR_POINT, RangeProtectionRenderModel, RangeProtectionRuleModel, SheetInterceptorService, WorksheetEditPermission, WorksheetProtectionRuleModel, WorksheetViewPermission } from '@univerjs/sheets';
+import type { IRangeProtectionRenderCellData } from '@univerjs/sheets-ui';
import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';
import { Inject } from '@wendellhu/redi';
import { bufferTime, filter } from 'rxjs/operators';
diff --git a/packages/sheets-ui/src/controllers/permission/sheet-permission-init.controller.ts b/packages/sheets-ui/src/controllers/permission/sheet-permission-init.controller.ts
index ee85313934..9f26626a4e 100644
--- a/packages/sheets-ui/src/controllers/permission/sheet-permission-init.controller.ts
+++ b/packages/sheets-ui/src/controllers/permission/sheet-permission-init.controller.ts
@@ -17,7 +17,7 @@
import type { Workbook } from '@univerjs/core';
import { Disposable, IAuthzIoService, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType, UserManagerService } from '@univerjs/core';
-import type { IRangeProtectionRenderCellData, IRangeProtectionRule, IWorksheetProtectionRenderCellData } from '@univerjs/sheets';
+import type { IRangeProtectionRule, IWorksheetProtectionRenderCellData } from '@univerjs/sheets';
import { defaultWorkbookPermissionPoints, defaultWorksheetPermissionPoint, getAllRangePermissionPoint, getAllWorkbookPermissionPoint, getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel, INTERCEPTOR_POINT, RangeProtectionRenderModel, RangeProtectionRuleModel, SheetInterceptorService, WorksheetEditPermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetViewPermission } from '@univerjs/sheets';
import { Inject } from '@wendellhu/redi';
import { IDialogService } from '@univerjs/ui';
@@ -26,6 +26,7 @@ import { UnitAction, UnitObject, UniverType } from '@univerjs/protocol';
import type { ISheetFontRenderExtension, ISheetRenderExtension } from '@univerjs/engine-render';
import { changeRenderExtensionSkip } from '../menu/permission-menu-util';
+import type { IRangeProtectionRenderCellData } from '../../views/permission/extensions/range-protection.render';
@OnLifecycle(LifecycleStages.Rendered, SheetPermissionInitController)
export class SheetPermissionInitController extends Disposable {
@@ -120,7 +121,7 @@ export class SheetPermissionInitController extends Disposable {
const unitActionName = instance.subType;
const action = actionList.find((item) => item.action === unitActionName);
if (action) {
- this._permissionService.updatePermissionPoint(instance.id, false);
+ this._permissionService.updatePermissionPoint(instance.id, action.allowed);
}
});
});
diff --git a/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-formula-render.controller.ts b/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-formula-render.controller.ts
index 4cbd15be3f..ccd1f02087 100644
--- a/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-formula-render.controller.ts
+++ b/packages/sheets-ui/src/controllers/permission/sheet-permission-interceptor-formula-render.controller.ts
@@ -16,7 +16,7 @@
import type { ICellDataForSheetInterceptor, IRange, Nullable, Workbook } from '@univerjs/core';
import { DisposableCollection, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, Rectangle, RxDisposable, UniverInstanceType } from '@univerjs/core';
-import { getSheetCommandTarget, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, WorksheetEditPermission } from '@univerjs/sheets';
+import { getSheetCommandTarget, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, WorksheetViewPermission } from '@univerjs/sheets';
import { Inject, Injector } from '@wendellhu/redi';
import { debounceTime, filter } from 'rxjs/operators';
import type { IRenderContext, IRenderController } from '@univerjs/engine-render';
@@ -91,7 +91,7 @@ export class SheetPermissionInterceptorFormulaRenderController extends RxDisposa
}
const { unitId, subUnitId } = target;
- const worksheetViewPermission = this._permissionService.getPermissionPoint(new WorksheetEditPermission(unitId, subUnitId).id)?.value ?? false;
+ const worksheetViewPermission = this._permissionService.getPermissionPoint(new WorksheetViewPermission(unitId, subUnitId).id)?.value ?? false;
if (!worksheetViewPermission) {
return false;
}
diff --git a/packages/sheets-ui/src/index.ts b/packages/sheets-ui/src/index.ts
index 2d19b61e52..baf11d4f2d 100644
--- a/packages/sheets-ui/src/index.ts
+++ b/packages/sheets-ui/src/index.ts
@@ -104,3 +104,4 @@ export { HeaderFreezeRenderController } from './controllers/render-controllers/f
export { FormulaEditorController } from './controllers/editor/formula-editor.controller';
export { StatusBarController } from './controllers/status-bar.controller';
export { SheetPermissionInterceptorBaseController } from './controllers/permission/sheet-permission-interceptor-base.controller';
+export type { IRangeProtectionRenderCellData } from './views/permission/extensions/range-protection.render';
diff --git a/packages/sheets-ui/src/services/permission/permission-render.service.ts b/packages/sheets-ui/src/services/permission/permission-render.service.ts
index 4d127ab151..4ca9c72016 100644
--- a/packages/sheets-ui/src/services/permission/permission-render.service.ts
+++ b/packages/sheets-ui/src/services/permission/permission-render.service.ts
@@ -20,9 +20,10 @@ import type { Spreadsheet } from '@univerjs/engine-render';
import { throttleTime } from 'rxjs/operators';
import type { Workbook } from '@univerjs/core';
import { Disposable, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
-import { RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY, RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY, RangeProtectionCanNotViewRenderExtension, RangeProtectionCanViewRenderExtension, RangeProtectionRuleModel } from '@univerjs/sheets';
import { merge } from 'rxjs';
+import { RangeProtectionRuleModel } from '@univerjs/sheets';
import { SheetSkeletonManagerService } from '../sheet-skeleton-manager.service';
+import { RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY, RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY, RangeProtectionCanNotViewRenderExtension, RangeProtectionCanViewRenderExtension } from '../../views/permission/extensions/range-protection.render';
@OnLifecycle(LifecycleStages.Ready, PermissionRenderService)
export class PermissionRenderService extends Disposable {
diff --git a/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission-render.service.ts b/packages/sheets-ui/src/services/permission/worksheet-permission-render.service.ts
similarity index 96%
rename from packages/sheets/src/services/permission/worksheet-permission/worksheet-permission-render.service.ts
rename to packages/sheets-ui/src/services/permission/worksheet-permission-render.service.ts
index 9e1332229a..92c6f4dfc0 100644
--- a/packages/sheets/src/services/permission/worksheet-permission/worksheet-permission-render.service.ts
+++ b/packages/sheets-ui/src/services/permission/worksheet-permission-render.service.ts
@@ -18,7 +18,7 @@ import { Inject } from '@wendellhu/redi';
import { IRenderManagerService } from '@univerjs/engine-render';
import type { Spreadsheet } from '@univerjs/engine-render';
import { Disposable, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
-import { worksheetProtectionKey, WorksheetProtectionRenderExtension } from '../../../render/worksheet-protection/worksheet-permission.render';
+import { worksheetProtectionKey, WorksheetProtectionRenderExtension } from '../../views/permission/extensions/worksheet-permission.render';
@OnLifecycle(LifecycleStages.Ready, WorksheetProtectionRenderService)
export class WorksheetProtectionRenderService extends Disposable {
diff --git a/packages/sheets-ui/src/sheets-ui-plugin.ts b/packages/sheets-ui/src/sheets-ui-plugin.ts
index 5496948686..30bc5788aa 100644
--- a/packages/sheets-ui/src/sheets-ui-plugin.ts
+++ b/packages/sheets-ui/src/sheets-ui-plugin.ts
@@ -21,7 +21,7 @@ import { Inject, Injector } from '@wendellhu/redi';
import { filter } from 'rxjs/operators';
import { IRenderManagerService } from '@univerjs/engine-render';
-import { UniverSheetsPlugin, WorksheetProtectionRenderService } from '@univerjs/sheets';
+import { UniverSheetsPlugin } from '@univerjs/sheets';
import { UniverUIPlugin } from '@univerjs/ui';
import { ActiveWorksheetController } from './controllers/active-worksheet/active-worksheet.controller';
import { AutoHeightController } from './controllers/auto-height.controller';
@@ -84,6 +84,7 @@ import { SheetPermissionInterceptorFormulaRenderController } from './controllers
import { SheetPermissionPanelModel } from './services/permission/sheet-permission-panel.model';
import { SheetPermissionUserManagerService } from './services/permission/sheet-permission-user-list.service';
import { PermissionRenderService } from './services/permission/permission-render.service';
+import { WorksheetProtectionRenderService } from './services/permission/worksheet-permission-render.service';
@DependentOn(UniverSheetsPlugin, UniverUIPlugin)
export class UniverSheetsUIPlugin extends Plugin {
@@ -147,7 +148,6 @@ export class UniverSheetsUIPlugin extends Plugin {
// permission
[SheetPermissionPanelModel],
-
[SheetPermissionUserManagerService],
[PermissionRenderService],
[WorksheetProtectionRenderService],
diff --git a/packages/sheets/src/render/image/protect-background-img.ts b/packages/sheets-ui/src/views/permission/extensions/protect-background-img.ts
similarity index 100%
rename from packages/sheets/src/render/image/protect-background-img.ts
rename to packages/sheets-ui/src/views/permission/extensions/protect-background-img.ts
diff --git a/packages/sheets/src/render/range-protection/range-protection.render.ts b/packages/sheets-ui/src/views/permission/extensions/range-protection.render.ts
similarity index 97%
rename from packages/sheets/src/render/range-protection/range-protection.render.ts
rename to packages/sheets-ui/src/views/permission/extensions/range-protection.render.ts
index 694073e85d..637e17bba9 100644
--- a/packages/sheets/src/render/range-protection/range-protection.render.ts
+++ b/packages/sheets-ui/src/views/permission/extensions/range-protection.render.ts
@@ -19,8 +19,8 @@ import { Range } from '@univerjs/core';
import type { SpreadsheetSkeleton, UniverRenderingContext } from '@univerjs/engine-render';
import { SheetExtension } from '@univerjs/engine-render';
import { UnitAction } from '@univerjs/protocol';
-import type { ICellPermission } from '../../model/range-protection-render.model';
-import { base64 } from '../image/protect-background-img';
+import type { ICellPermission } from '@univerjs/sheets';
+import { base64 } from './protect-background-img';
export const RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY = 'RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY';
export const RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY = 'RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY';
diff --git a/packages/sheets/src/render/worksheet-protection/worksheet-permission.render.ts b/packages/sheets-ui/src/views/permission/extensions/worksheet-permission.render.ts
similarity index 94%
rename from packages/sheets/src/render/worksheet-protection/worksheet-permission.render.ts
rename to packages/sheets-ui/src/views/permission/extensions/worksheet-permission.render.ts
index 5642c9dd86..a255a59bd8 100644
--- a/packages/sheets/src/render/worksheet-protection/worksheet-permission.render.ts
+++ b/packages/sheets-ui/src/views/permission/extensions/worksheet-permission.render.ts
@@ -18,8 +18,8 @@ import type { IRange, IScale } from '@univerjs/core';
import type { SpreadsheetSkeleton, UniverRenderingContext } from '@univerjs/engine-render';
import { SheetExtension } from '@univerjs/engine-render';
import { UnitAction } from '@univerjs/protocol';
-import type { IWorksheetProtectionRenderCellData } from '../../services/permission/worksheet-permission/type';
-import { base64 } from '../image/protect-background-img';
+import type { IWorksheetProtectionRenderCellData } from '@univerjs/sheets';
+import { base64 } from './protect-background-img';
export const worksheetProtectionKey = 'worksheet-protection';
const EXTENSION_CAN_VIEW_Z_INDEX = 25;
diff --git a/packages/sheets/src/index.ts b/packages/sheets/src/index.ts
index 65a27c4728..dd214fd139 100644
--- a/packages/sheets/src/index.ts
+++ b/packages/sheets/src/index.ts
@@ -308,7 +308,7 @@ export { getMoveRangeUndoRedoMutations } from './commands/commands/move-range.co
// permission
export { defaultWorksheetPermissionPoint, getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel } from './services/permission';
export type { IWorksheetProtectionRule } from './services/permission/type';
-export { WorksheetProtectionRuleModel, WorksheetProtectionPointModel, WorksheetProtectionRenderService } from './services/permission/worksheet-permission';
+export { WorksheetProtectionRuleModel, WorksheetProtectionPointModel } from './services/permission/worksheet-permission';
export { AddWorksheetProtectionMutation } from './commands/mutations/add-worksheet-protection.mutation';
export { SetWorksheetProtectionMutation } from './commands/mutations/set-worksheet-protection.mutation';
export { DeleteWorksheetProtectionMutation } from './commands/mutations/delete-worksheet-protection.mutation';
@@ -361,8 +361,6 @@ export { AddRangeProtectionMutation, FactoryAddRangeProtectionMutation, type IAd
export { DeleteRangeProtectionMutation, FactoryDeleteRangeProtectionMutation, type IDeleteSelectionProtectionMutationParams } from './commands/mutations/delete-range-protection.mutation';
export { SetRangeProtectionMutation, FactorySetRangeProtectionMutation, type ISetRangeProtectionMutationParams } from './commands/mutations/set-range-protection.mutation';
-export { RangeProtectionCanViewRenderExtension, RangeProtectionCanNotViewRenderExtension, type IRangeProtectionRenderCellData, RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY, RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY } from './render/range-protection/range-protection.render';
-
export { RangeProtectionRenderModel, type ICellPermission } from './model/range-protection-render.model';
export { RangeProtectionRuleModel, type IObjectModel, type IRangeProtectionRule, type IModel } from './model/range-protection-rule.model';
export type { IWorksheetProtectionRenderCellData } from './services/permission/worksheet-permission/type';
diff --git a/packages/sheets/src/services/permission/workbook-permission/util.ts b/packages/sheets/src/services/permission/workbook-permission/util.ts
index 77267151ff..9b993c57d2 100644
--- a/packages/sheets/src/services/permission/workbook-permission/util.ts
+++ b/packages/sheets/src/services/permission/workbook-permission/util.ts
@@ -35,9 +35,16 @@ export const getAllWorkbookPermissionPoint = () => [
export const defaultWorkbookPermissionPoints = [
UnitAction.Edit,
- UnitAction.View,
- UnitAction.Comment,
UnitAction.Print,
+ UnitAction.Comment,
+ UnitAction.View,
UnitAction.Copy,
+ UnitAction.Export,
UnitAction.ManageCollaborator,
+ UnitAction.CreateSheet,
+ UnitAction.DeleteSheet,
+ UnitAction.RenameSheet,
+ UnitAction.HideSheet,
+ UnitAction.Duplicate,
+ UnitAction.Share,
];
diff --git a/packages/sheets/src/services/permission/worksheet-permission/index.ts b/packages/sheets/src/services/permission/worksheet-permission/index.ts
index 6c89fee6fb..e8630b7c19 100644
--- a/packages/sheets/src/services/permission/worksheet-permission/index.ts
+++ b/packages/sheets/src/services/permission/worksheet-permission/index.ts
@@ -17,5 +17,4 @@
export { WorksheetPermissionService } from './worksheet-permission.service';
export { WorksheetProtectionRuleModel } from './worksheet-permission-rule.model';
export { WorksheetProtectionPointModel } from './worksheet-permission-point.model';
-export { WorksheetProtectionRenderService } from './worksheet-permission-render.service';
diff --git a/packages/sheets/src/services/permission/worksheet-permission/utils.ts b/packages/sheets/src/services/permission/worksheet-permission/utils.ts
index 41b6b83ee0..2a3c8998c0 100644
--- a/packages/sheets/src/services/permission/worksheet-permission/utils.ts
+++ b/packages/sheets/src/services/permission/worksheet-permission/utils.ts
@@ -22,6 +22,7 @@ export const getAllWorksheetPermissionPoint = () => [
WorksheetEditPermission,
];
+// Changes require synchronization of the following arrays
export const getAllWorksheetPermissionPointByPointPanel = () => [
WorksheetCopyPermission,
WorksheetDeleteColumnPermission,
@@ -29,8 +30,8 @@ export const getAllWorksheetPermissionPointByPointPanel = () => [
WorksheetEditExtraObjectPermission,
WorksheetFilterPermission,
WorksheetInsertColumnPermission,
- WorksheetInsertHyperlinkPermission,
WorksheetInsertRowPermission,
+ WorksheetInsertHyperlinkPermission,
WorksheetPivotTablePermission,
WorksheetSetCellStylePermission,
WorksheetSetCellValuePermission,
@@ -41,18 +42,18 @@ export const getAllWorksheetPermissionPointByPointPanel = () => [
export const defaultWorksheetPermissionPoint = [
UnitAction.Copy,
+ UnitAction.DeleteColumn,
+ UnitAction.DeleteRow,
+ UnitAction.EditExtraObject,
+ UnitAction.Filter,
+ UnitAction.InsertColumn,
+ UnitAction.InsertRow,
+ UnitAction.InsertHyperlink,
+ UnitAction.PivotTable,
UnitAction.SetCellStyle,
UnitAction.SetCellValue,
- UnitAction.SetRowStyle,
UnitAction.SetColumnStyle,
- UnitAction.InsertRow,
- UnitAction.InsertColumn,
- UnitAction.InsertHyperlink,
- UnitAction.DeleteRow,
- UnitAction.DeleteColumn,
+ UnitAction.SetRowStyle,
UnitAction.Sort,
- UnitAction.Filter,
- UnitAction.PivotTable,
- UnitAction.EditExtraObject,
];