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
feat(sheets): update workbook permission point (#5615)
ybzky3a59614ae5d7
diff --git a/packages/sheets-ui/src/controllers/menu/delete.menu.ts b/packages/sheets-ui/src/controllers/menu/delete.menu.tsindex 0ff906787b..5b1cf54fb4 100644--- a/packages/sheets-ui/src/controllers/menu/delete.menu.ts+++ b/packages/sheets-ui/src/controllers/menu/delete.menu.ts@@ -17,7 +17,7 @@import type { IAccessor } from '@univerjs/core';import type { IMenuButtonItem, IMenuSelectorItem } from '@univerjs/ui';-import { RangeProtectionPermissionEditPoint, WorkbookEditablePermission, WorksheetDeleteColumnPermission, WorksheetDeleteRowPermission, WorksheetEditPermission } from '@univerjs/sheets';+import { RangeProtectionPermissionEditPoint, WorkbookDeleteColumnPermission, WorkbookDeleteRowPermission, WorkbookEditablePermission, WorksheetDeleteColumnPermission, WorksheetDeleteRowPermission, WorksheetEditPermission } from '@univerjs/sheets';import { MenuItemType } from '@univerjs/ui';import { DeleteRangeMoveLeftConfirmCommand } from '../../commands/commands/delete-range-move-left-confirm.command';import { DeleteRangeMoveUpConfirmCommand } from '../../commands/commands/delete-range-move-up-confirm.command';@@ -46,7 +46,7 @@ export function RemoveColMenuItemFactory(accessor: IAccessor): IMenuButtonItem {icon: 'DeleteColumnDoubleIcon',title: 'rightClick.deleteSelectedColumn',hidden$: getDeleteMenuHidden$(accessor, 'col'),- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetDeleteColumnPermission] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookDeleteColumnPermission], worksheetTypes: [WorksheetEditPermission, WorksheetDeleteColumnPermission] }),};}@@ -56,7 +56,7 @@ export function RemoveRowMenuItemFactory(accessor: IAccessor): IMenuButtonItem {type: MenuItemType.BUTTON,icon: 'DeleteRowDoubleIcon',title: 'rightClick.deleteSelectedRow',- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetDeleteRowPermission] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookDeleteRowPermission], worksheetTypes: [WorksheetEditPermission, WorksheetDeleteRowPermission] }),hidden$: getDeleteMenuHidden$(accessor, 'row'),};}diff --git a/packages/sheets-ui/src/controllers/menu/insert.menu.ts b/packages/sheets-ui/src/controllers/menu/insert.menu.tsindex b96dcf5efb..904ecc3d77 100644--- a/packages/sheets-ui/src/controllers/menu/insert.menu.ts+++ b/packages/sheets-ui/src/controllers/menu/insert.menu.ts@@ -30,6 +30,8 @@ import {SetSelectionsOperation,SheetsSelectionsService,WorkbookEditablePermission,+ WorkbookInsertColumnPermission,+ WorkbookInsertRowPermission,WorksheetEditPermission,WorksheetInsertColumnPermission,WorksheetInsertRowPermission,@@ -50,7 +52,7 @@ export function ColInsertMenuItemFactory(accessor: IAccessor): IMenuSelectorItemtitle: 'rightClick.insert',icon: 'InsertDoubleIcon',hidden$: getBaseRangeMenuHidden$(accessor),- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetInsertColumnPermission] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookInsertColumnPermission], worksheetTypes: [WorksheetEditPermission, WorksheetInsertColumnPermission] }),};}@@ -62,7 +64,7 @@ export function RowInsertMenuItemFactory(accessor: IAccessor): IMenuSelectorItemtitle: 'rightClick.insert',icon: 'InsertDoubleIcon',hidden$: getBaseRangeMenuHidden$(accessor),- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookInsertRowPermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),};}@@ -74,7 +76,7 @@ export function CellInsertMenuItemFactory(accessor: IAccessor): IMenuSelectorItetitle: 'rightClick.insert',icon: 'InsertDoubleIcon',hidden$: getObservableWithExclusiveRange$(accessor, getBaseRangeMenuHidden$(accessor)),- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertColumnPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookInsertColumnPermission], worksheetTypes: [WorksheetInsertColumnPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),};}@@ -89,7 +91,7 @@ export function InsertRowBeforeMenuItemFactory(accessor: IAccessor): IMenuButtontype: MenuItemType.BUTTON,title: 'rightClick.insertRowBefore',icon: 'InsertRowAboveDoubleIcon',- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookInsertRowPermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),hidden$: getInsertBeforeMenuHidden$(accessor, 'row'),};}@@ -138,7 +140,7 @@ export function InsertRowBeforeCellMenuItemFactory(accessor: IAccessor): IMenuBuupdate();return disposable.dispose;})),- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookInsertRowPermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),hidden$: getInsertBeforeMenuHidden$(accessor, 'row'),};}@@ -149,7 +151,7 @@ export function InsertRowAfterMenuItemFactory(accessor: IAccessor): IMenuButtonItype: MenuItemType.BUTTON,title: 'rightClick.insertRow',icon: 'InsertRowBelowDoubleIcon',- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookInsertRowPermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),hidden$: getInsertAfterMenuHidden$(accessor, 'row'),};}@@ -197,7 +199,7 @@ export function InsertColLeftCellMenuItemFactory(accessor: IAccessor): IMenuButtupdate();return disposable.dispose;})),- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertColumnPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookInsertColumnPermission], worksheetTypes: [WorksheetInsertColumnPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),hidden$: getInsertBeforeMenuHidden$(accessor, 'col'),};}@@ -208,7 +210,7 @@ export function InsertColBeforeMenuItemFactory(accessor: IAccessor): IMenuButtontype: MenuItemType.BUTTON,title: 'rightClick.insertColumnBefore',icon: 'LeftInsertColumnDoubleIcon',- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertColumnPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookInsertColumnPermission], worksheetTypes: [WorksheetInsertColumnPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),hidden$: getInsertBeforeMenuHidden$(accessor, 'col'),};}@@ -219,7 +221,7 @@ export function InsertColAfterMenuItemFactory(accessor: IAccessor): IMenuButtonItype: MenuItemType.BUTTON,title: 'rightClick.insertColumn',icon: 'RightInsertColumnDoubleIcon',- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertColumnPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookInsertColumnPermission], worksheetTypes: [WorksheetInsertColumnPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),hidden$: getInsertAfterMenuHidden$(accessor, 'col'),};}@@ -342,7 +344,7 @@ export function InsertMultiRowsAboveHeaderMenuItemFactory(accessor: IAccessor):update();return disposable.dispose;})),- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookInsertRowPermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),hidden$: getBaseRangeMenuHidden$(accessor),};}@@ -390,7 +392,7 @@ export function InsertMultiColsLeftHeaderMenuItemFactory(accessor: IAccessor): Iupdate();return disposable.dispose;})),- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookInsertRowPermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),hidden$: getBaseRangeMenuHidden$(accessor),};}@@ -438,7 +440,7 @@ export function InsertMultiColsRightHeaderMenuItemFactory(accessor: IAccessor):update();return disposable.dispose;})),- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission, WorkbookInsertRowPermission], worksheetTypes: [WorksheetInsertRowPermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),hidden$: getBaseRangeMenuHidden$(accessor),};}diff --git a/packages/sheets-ui/src/views/permission/panel-detail/PermissionDetailUserPart.tsx b/packages/sheets-ui/src/views/permission/panel-detail/PermissionDetailUserPart.tsxindex ac80d62af4..ee1cd31b77 100644--- a/packages/sheets-ui/src/views/permission/panel-detail/PermissionDetailUserPart.tsx+++ b/packages/sheets-ui/src/views/permission/panel-detail/PermissionDetailUserPart.tsx@@ -113,7 +113,8 @@ export const PermissionDetailUserPart = (props: IPermissionDetailUserPartProps){editState === EditStateEnum.DesignedUserCanEdit && (<divclassName={clsx(`- univer-mb-2 univer-flex univer-h-[270px] univer-flex-col univer-rounded-lg univer-p-3+ univer-mb-2 univer-flex univer-h-[270px] univer-flex-col univer-overflow-y-auto univer-rounded-lg+ univer-p-3`, borderClassName)}><div className="univer-flex univer-items-center univer-justify-between univer-text-sm">diff --git a/packages/sheets/src/services/permission/permission-point/index.ts b/packages/sheets/src/services/permission/permission-point/index.tsindex 8bc14ac5a6..6bffdec3bc 100644--- a/packages/sheets/src/services/permission/permission-point/index.ts+++ b/packages/sheets/src/services/permission/permission-point/index.ts@@ -21,12 +21,16 @@ export { WorkbookCopyPermission } from './workbook/copy';export { WorkbookCopySheetPermission } from './workbook/copy-sheet';export { WorkbookCreateProtectPermission } from './workbook/create-permission';export { WorkbookCreateSheetPermission } from './workbook/create-sheet';+export { WorkbookDeleteColumnPermission } from './workbook/delete-column';+export { WorkbookDeleteRowPermission } from './workbook/delete-row';export { WorkbookDeleteSheetPermission } from './workbook/delete-sheet';export { WorkbookDuplicatePermission } from './workbook/duplicate';export { WorkbookEditablePermission } from './workbook/editable';export { WorkbookExportPermission } from './workbook/export';export { WorkbookHideSheetPermission } from './workbook/hide-sheet';export { WorkbookHistoryPermission } from './workbook/history';+export { WorkbookInsertColumnPermission } from './workbook/insert-column';+export { WorkbookInsertRowPermission } from './workbook/insert-row';export { WorkbookManageCollaboratorPermission } from './workbook/manage-collaborator';export { WorkbookMoveSheetPermission } from './workbook/move-sheet';export { WorkbookPrintPermission } from './workbook/print';diff --git a/packages/sheets/src/services/permission/permission-point/workbook/delete-column.ts b/packages/sheets/src/services/permission/permission-point/workbook/delete-column.tsnew file mode 100644index 0000000000..a696fe3b92--- /dev/null+++ b/packages/sheets/src/services/permission/permission-point/workbook/delete-column.ts@@ -0,0 +1,30 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IPermissionPoint } from '@univerjs/core';+import { PermissionStatus } from '@univerjs/core';+import { UnitAction, UnitObject } from '@univerjs/protocol';++export class WorkbookDeleteColumnPermission implements IPermissionPoint {+ value = true;+ type = UnitObject.Workbook;+ status = PermissionStatus.INIT;+ id: string;+ subType = UnitAction.DeleteColumn;+ constructor(public unitId: string) {+ this.id = `${this.type}.${UnitAction.DeleteColumn}_${unitId}`;+ }+}diff --git a/packages/sheets/src/services/permission/permission-point/workbook/delete-row.ts b/packages/sheets/src/services/permission/permission-point/workbook/delete-row.tsnew file mode 100644index 0000000000..ba964d45bf--- /dev/null+++ b/packages/sheets/src/services/permission/permission-point/workbook/delete-row.ts@@ -0,0 +1,30 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IPermissionPoint } from '@univerjs/core';+import { PermissionStatus } from '@univerjs/core';+import { UnitAction, UnitObject } from '@univerjs/protocol';++export class WorkbookDeleteRowPermission implements IPermissionPoint {+ value = true;+ type = UnitObject.Workbook;+ status = PermissionStatus.INIT;+ id: string;+ subType = UnitAction.DeleteRow;+ constructor(public unitId: string) {+ this.id = `${this.type}.${UnitAction.DeleteRow}_${unitId}`;+ }+}diff --git a/packages/sheets/src/services/permission/permission-point/workbook/insert-column.ts b/packages/sheets/src/services/permission/permission-point/workbook/insert-column.tsnew file mode 100644index 0000000000..789a3288a7--- /dev/null+++ b/packages/sheets/src/services/permission/permission-point/workbook/insert-column.ts@@ -0,0 +1,30 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IPermissionPoint } from '@univerjs/core';+import { PermissionStatus } from '@univerjs/core';+import { UnitAction, UnitObject } from '@univerjs/protocol';++export class WorkbookInsertColumnPermission implements IPermissionPoint {+ value = true;+ type = UnitObject.Workbook;+ status = PermissionStatus.INIT;+ id: string;+ subType = UnitAction.InsertColumn;+ constructor(public unitId: string) {+ this.id = `${this.type}.${UnitAction.InsertColumn}_${unitId}`;+ }+}diff --git a/packages/sheets/src/services/permission/permission-point/workbook/insert-row.ts b/packages/sheets/src/services/permission/permission-point/workbook/insert-row.tsnew file mode 100644index 0000000000..074f7373df--- /dev/null+++ b/packages/sheets/src/services/permission/permission-point/workbook/insert-row.ts@@ -0,0 +1,30 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IPermissionPoint } from '@univerjs/core';+import { PermissionStatus } from '@univerjs/core';+import { UnitAction, UnitObject } from '@univerjs/protocol';++export class WorkbookInsertRowPermission implements IPermissionPoint {+ value = true;+ type = UnitObject.Workbook;+ status = PermissionStatus.INIT;+ id: string;+ subType = UnitAction.InsertRow;+ constructor(public unitId: string) {+ this.id = `${this.type}.${UnitAction.InsertRow}_${unitId}`;+ }+}