Skip to content

feat: DH-14630 - ACL Editor Hooks#1257

Merged
bmingles merged 54 commits intodeephaven:mainfrom
bmingles:web_DH-14630_hooks
May 4, 2023
Merged

feat: DH-14630 - ACL Editor Hooks#1257
bmingles merged 54 commits intodeephaven:mainfrom
bmingles:web_DH-14630_hooks

Conversation

@bmingles
Copy link
Copy Markdown
Contributor

@bmingles bmingles commented May 1, 2023

Supports enterprise DH-14630

closes #1260

BREAKING CHANGE: generateEmptyKeyedItemsRange previously required a single count arg, but now requires a start and end index

@bmingles bmingles changed the title DH-14630: ACL Editor Hooks feat: DH-14630: ACL Editor Hooks May 1, 2023
@bmingles bmingles changed the title feat: DH-14630: ACL Editor Hooks feat: DH-14630 - ACL Editor Hooks May 1, 2023
@bmingles bmingles force-pushed the web_DH-14630_hooks branch 3 times, most recently from 82d1f74 to ead50c4 Compare May 2, 2023 14:54
@bmingles bmingles force-pushed the web_DH-14630_hooks branch from e099c9a to 7ce7ea0 Compare May 2, 2023 20:44
@bmingles bmingles force-pushed the web_DH-14630_hooks branch from 511b47f to 21d7b82 Compare May 2, 2023 21:07
@bmingles bmingles marked this pull request as ready for review May 2, 2023 21:16
@bmingles bmingles requested a review from mofojed May 2, 2023 21:25
@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2023

Codecov Report

Merging #1257 (3a6c828) into main (769d753) will increase coverage by 0.18%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1257      +/-   ##
==========================================
+ Coverage   45.57%   45.76%   +0.18%     
==========================================
  Files         484      490       +6     
  Lines       34077    34202     +125     
  Branches     8532     8554      +22     
==========================================
+ Hits        15531    15652     +121     
- Misses      18495    18499       +4     
  Partials       51       51              
Flag Coverage Δ
unit 45.76% <100.00%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...api-components/src/useSetPaddedViewportCallback.ts 100.00% <ø> (ø)
...jsapi-components/src/useDebouncedViewportSearch.ts 100.00% <100.00%> (ø)
.../jsapi-components/src/useInitializeViewportData.ts 100.00% <100.00%> (+11.11%) ⬆️
...ges/jsapi-components/src/useSelectDistinctTable.ts 100.00% <100.00%> (ø)
packages/jsapi-components/src/useTableClose.ts 100.00% <100.00%> (ø)
packages/jsapi-components/src/useTableSize.ts 100.00% <100.00%> (ø)
packages/jsapi-components/src/useViewportData.ts 100.00% <100.00%> (ø)
packages/jsapi-utils/src/TableUtils.ts 88.76% <100.00%> (+1.39%) ⬆️
packages/jsapi-utils/src/ViewportDataUtils.ts 100.00% <100.00%> (ø)
...react-hooks/src/useFormWithDetachedSubmitButton.ts 100.00% <100.00%> (ø)
... and 1 more

... and 10 files with indirect coverage changes

Comment on lines +6 to +9
* React hook that closes a given table when the component unmounts.
* @param table
*/
export default function useTableCloseOnUnmount(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being pedantic, this would close the table on unmount OR if the table changes. I can't think of a better name though and don't feel too strongly about it.

Comment thread packages/jsapi-components/src/useDebouncedViewportSearch.test.ts Outdated
expect(TableUtils.makeFilterValue).not.toHaveBeenCalled();
expect(viewportData.applyFiltersAndRefresh).toHaveBeenCalledWith([]);
}
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add another test:

it('should cancel debounce on unmount', () => {
  const searchText = 'mock.searchText';
  const debounceMs = 400;

  const { result, unmount } = renderHook(() =>
    useDebouncedViewportSearch(viewportData, 'mock.column', debounceMs)
  );

  result.current(searchText);
  jest.advanceTimersByTime(5);
  unmount();
  jest.advanceTimersByTime(debounceMs);

  expect(TableUtils.makeFilterValue).not.toHaveBeenCalled();
  expect(viewportData.applyFiltersAndRefresh).not.toHaveBeenCalled();
});

): (searchText: string) => void {
return useMemo(
() =>
debounce((searchText: string) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be cancelling the debounce on unmount.

expect(maybeTable.close).not.toHaveBeenCalled();
}
}
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add a case that it closes the old table if the table provided changes.

Comment thread packages/jsapi-utils/src/TableUtils.ts Outdated
Comment thread packages/jsapi-utils/src/ViewportDataUtils.ts
Comment thread packages/react-hooks/src/useFormWithDetachedSubmitButton.ts Outdated
Comment thread packages/react-hooks/src/useFormWithDetachedSubmitButton.ts Outdated
Comment thread packages/react-hooks/src/useFormWithDetachedSubmitButton.ts Outdated
@bmingles bmingles requested a review from mofojed May 4, 2023 16:46
mofojed
mofojed previously approved these changes May 4, 2023

rerender(nextTable);

expect(table.close).toHaveBeenCalled();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(table.close).toHaveBeenCalled();
expect(table.close).toHaveBeenCalled();
expect(nextTable.close).not.toHaveBeenCalled();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed and pushed

@bmingles bmingles merged commit e0a2a36 into deephaven:main May 4, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators May 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DH-14630: Hooks and utils to support ACL Editor User List

2 participants