-
Notifications
You must be signed in to change notification settings - Fork 247
feat(compass-crud): enable resizable column widths in document table view COMPASS-2218 #7573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
7MIMIRA
wants to merge
14
commits into
mongodb-js:main
Choose a base branch
from
7MIMIRA:make_table_view_col_width_resizeable
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7dd05c8
Set column headers in table view as resizeable
7MIMIRA 4cc8c83
Persist column width changes between table data refreshes (queries, r…
7MIMIRA 107aacd
Persist column width data when switching between tabs
7MIMIRA 3ef14b4
Update implementation to address visual bug
7MIMIRA da65852
Scope tableData to each tab so we don't have to manage
7MIMIRA 26194e4
Update implementation to persist previously adjusted column widths wh…
7MIMIRA 2021e77
Add test
7MIMIRA 7f9b1c5
Merge branch 'main' into make_table_view_col_width_resizeable
7MIMIRA 24f08bc
Update packages/compass-crud/src/components/table-view/document-table…
7MIMIRA 7240a65
Use existing useTabState hook
7MIMIRA 1ec1c9a
Merge branch 'main' into make_table_view_col_width_resizeable
7MIMIRA 2fbe466
Merge branch 'main' into make_table_view_col_width_resizeable
7MIMIRA 3273d6c
Update implementation to follow established conventions
7MIMIRA 69b2cad
Merge branch 'main' into make_table_view_col_width_resizeable
7MIMIRA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
packages/compass-crud/src/components/table-view/document-table-view.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import React from 'react'; | ||
| import { mount } from 'enzyme'; | ||
| import type { ReactWrapper } from 'enzyme'; | ||
| import HadronDocument from 'hadron-document'; | ||
| import { expect } from 'chai'; | ||
| import sinon from 'sinon'; | ||
|
|
||
| import DocumentTableView, { | ||
| DocumentTableView as RawDocumentTableView, | ||
| } from './document-table-view'; | ||
|
|
||
| describe('<DocumentTableView />', function () { | ||
| describe('#render', function () { | ||
| context('when the documents have objects for ids', function () { | ||
| const docs = [{ _id: '6909a21e9e548506e786c1e5', name: 'test-1' }]; | ||
| const hadronDocs = docs.map((doc) => new HadronDocument(doc)); | ||
|
|
||
| let component: ReactWrapper; | ||
| beforeEach(function () { | ||
| component = mount( | ||
| <DocumentTableView | ||
| docs={hadronDocs} | ||
| ns={'database.collection'} | ||
| namespace={'database.collection'} | ||
| pathChanged={sinon.spy()} | ||
| table={{ | ||
| doc: null, | ||
| editParams: null, | ||
| path: [], | ||
| types: [], | ||
| }} | ||
| store={{ | ||
| gridStore: { | ||
| listen: sinon.spy(), | ||
| }, | ||
| }} | ||
| resetColumns={sinon.spy()} | ||
| columnWidths={{ | ||
| name: 1337, | ||
| }} | ||
| start={1} | ||
| /> | ||
| ); | ||
| }); | ||
|
|
||
| afterEach(function () { | ||
| component?.unmount(); | ||
| }); | ||
|
|
||
| it('columnWidths data is applied to the relevant grid column', async function () { | ||
| // Ensure we wait for GridReadyEvent so columnApi is set | ||
| await new Promise(setImmediate); | ||
|
|
||
| const instance = component.find(RawDocumentTableView).instance(); | ||
| expect(instance).to.not.be.undefined; | ||
|
|
||
| const columnState = instance.columnApi.getColumnState(); | ||
| const nameCol = columnState.find((column) => column.colId === 'name'); | ||
| const idCol = columnState.find((column) => column.colId === '_id'); | ||
|
|
||
| expect(nameCol.width).to.equal(1337); | ||
| expect(idCol.width).to.equal(200); // Default width is 200 | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.