Skip to content

Commit

Permalink
188104291 v3 DI Return Table to Normal after Sharing (#1406)
Browse files Browse the repository at this point in the history
* Remove managingController when dataset is updated with unrecognized id.

* Disable delete menu item when attribute is not deleteable.
  • Loading branch information
tealefristoe authored Aug 15, 2024
1 parent 3bcce62 commit f0767c4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const AttributeMenuListComp = forwardRef<HTMLDivElement, IProps>(
{
itemKey: "DG.TableController.headerMenuItems.deleteAttribute",
isEnabled: () => {
if (!data) return false
if (!attribute?.deleteable || !data) return false

// If preventTopLevelReorg is true...
if (preventTopLevelReorg(data)) {
Expand Down
3 changes: 3 additions & 0 deletions v3/src/data-interactive/handlers/data-context-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
})
})
2 changes: 1 addition & 1 deletion v3/src/data-interactive/handlers/data-context-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions v3/src/models/data/data-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f0767c4

Please sign in to comment.