From f0767c4ca72cb8c38774dddb74fcf26676c7cc92 Mon Sep 17 00:00:00 2001 From: Teale Fristoe Date: Thu, 15 Aug 2024 07:48:31 -0700 Subject: [PATCH] 188104291 v3 DI Return Table to Normal after Sharing (#1406) * Remove managingController when dataset is updated with unrecognized id. * Disable delete menu item when attribute is not deleteable. --- .../case-table/attribute-menu/attribute-menu-list.tsx | 2 +- v3/src/data-interactive/handlers/data-context-handler.test.ts | 3 +++ v3/src/data-interactive/handlers/data-context-handler.ts | 2 +- v3/src/models/data/data-set.ts | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/v3/src/components/case-table/attribute-menu/attribute-menu-list.tsx b/v3/src/components/case-table/attribute-menu/attribute-menu-list.tsx index 6ab1fd7c79..6453da4493 100644 --- a/v3/src/components/case-table/attribute-menu/attribute-menu-list.tsx +++ b/v3/src/components/case-table/attribute-menu/attribute-menu-list.tsx @@ -148,7 +148,7 @@ const AttributeMenuListComp = forwardRef( { itemKey: "DG.TableController.headerMenuItems.deleteAttribute", isEnabled: () => { - if (!data) return false + if (!attribute?.deleteable || !data) return false // If preventTopLevelReorg is true... if (preventTopLevelReorg(data)) { diff --git a/v3/src/data-interactive/handlers/data-context-handler.test.ts b/v3/src/data-interactive/handlers/data-context-handler.test.ts index 3270e86dd3..a48f4f9197 100644 --- a/v3/src/data-interactive/handlers/data-context-handler.test.ts +++ b/v3/src/data-interactive/handlers/data-context-handler.test.ts @@ -99,5 +99,8 @@ describe("DataInteractive DataContextHandler", () => { expect(dataset.title).toEqual(title) expect(dataset.description).toEqual(description) expect(dataset.managingControllerId).toBe(tile.id) + + expect(handler.update?.({ dataContext: dataset }, { managingController: "__none__" }).success).toBe(true) + expect(dataset.managingControllerId).toBe("") }) }) diff --git a/v3/src/data-interactive/handlers/data-context-handler.ts b/v3/src/data-interactive/handlers/data-context-handler.ts index 61147b18ae..8b75b670d1 100644 --- a/v3/src/data-interactive/handlers/data-context-handler.ts +++ b/v3/src/data-interactive/handlers/data-context-handler.ts @@ -88,7 +88,7 @@ export const diDataContextHandler: DIHandler = { if (managingController) { const tile = findTileFromNameOrId(managingController) - if (tile) dataContext.setManagingControllerId(tile.id) + dataContext.setManagingControllerId(tile?.id) } if (sort?.attr) { diff --git a/v3/src/models/data/data-set.ts b/v3/src/models/data/data-set.ts index 33c83796e9..b54efba612 100644 --- a/v3/src/models/data/data-set.ts +++ b/v3/src/models/data/data-set.ts @@ -423,8 +423,8 @@ export const DataSet = V2Model.named("DataSet").props({ } }) .actions(self => ({ - setManagingControllerId(id: string) { - self.managingControllerId = id + setManagingControllerId(id?: string) { + self.managingControllerId = id ?? "" }, moveAttribute(attributeID: string, options?: IMoveAttributeCollectionOptions): IAttributeChangeResult { let removedCollectionId: string | undefined