forked from DevExpress/DevExtreme
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renovated DataGrid: Separate the common part of the DataGrid and Tree…
…List (DevExpress#16730) * Renovated DataGrid: Separate the common part of the DataGrid and TreeList * Eliminated the faults * Fix test
- Loading branch information
Showing
19 changed files
with
137 additions
and
76 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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,6 @@ | ||
import dxDataGrid from '../../../../../ui/data_grid'; | ||
|
||
export interface GridInstance extends dxDataGrid { | ||
getView: (name: string) => any; | ||
getController: (name: string) => any; | ||
} |
This file contains 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
17 changes: 7 additions & 10 deletions
17
...novation/ui/data_grid/data_grid_views.tsx → ...on/ui/grids/data_grid/data_grid_views.tsx
This file contains 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
4 changes: 2 additions & 2 deletions
4
...vation/ui/data_grid/datagrid_component.ts → .../ui/grids/data_grid/datagrid_component.ts
This file contains 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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ui/data_grid/utils/get_updated_options.ts → ...ds/data_grid/utils/get_updated_options.ts
This file contains 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
This file contains 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
33 changes: 33 additions & 0 deletions
33
js/renovation/ui/grids/grid_base/__tests__/grid_base_views.test.tsx
This file contains 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,33 @@ | ||
import { mount } from 'enzyme'; | ||
import { GridBaseViews, viewFunction } from '../grid_base_views'; | ||
import { GridBaseViewWrapper } from '../grid_base_view_wrapper'; | ||
|
||
jest.mock('../grid_base_view_wrapper', () => ({ GridBaseViewWrapper: () => null })); | ||
|
||
const GRIDBASE_CONTAINER_CLASS = 'dx-gridbase-container'; | ||
|
||
describe('GridBaseViews', () => { | ||
describe('View', () => { | ||
it('default render', () => { | ||
const options = { | ||
props: { | ||
views: [ | ||
{ name: 'view1', view: 'viewComponent1' }, | ||
{ name: 'view2', view: 'viewComponent2' }, | ||
], | ||
className: 'myClass', | ||
}, | ||
} as unknown as GridBaseViews; | ||
const tree = mount(viewFunction(options)); | ||
|
||
expect(tree.hasClass('myClass')).toBe(true); | ||
expect(tree.hasClass(GRIDBASE_CONTAINER_CLASS)).toBe(true); | ||
expect(tree.children().length).toBe(2); | ||
expect(tree.find(GridBaseViewWrapper).length).toBe(2); | ||
expect(tree.find(GridBaseViewWrapper).get(0).key).toBe('view1'); | ||
expect(tree.find(GridBaseViewWrapper).get(0).props.view).toBe('viewComponent1'); | ||
expect(tree.find(GridBaseViewWrapper).get(1).key).toBe('view2'); | ||
expect(tree.find(GridBaseViewWrapper).get(1).props.view).toBe('viewComponent2'); | ||
}); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
js/renovation/ui/grids/grid_base/common/grid_base_view_props.ts
This file contains 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,9 @@ | ||
import { ComponentBindings, OneWay } from 'devextreme-generator/component_declaration/common'; | ||
import { GridBaseView } from './types'; | ||
|
||
@ComponentBindings() | ||
export class GridBaseViewProps { | ||
@OneWay() views!: { name: string; view: GridBaseView }[]; | ||
|
||
@OneWay() className!: string; | ||
} |
This file contains 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,13 @@ | ||
// eslint-disable-next-line import/named | ||
import { GridBase } from '../../../../../ui/data_grid'; | ||
|
||
export interface GridBaseInstance extends GridBase { | ||
getView: (name: string) => any; | ||
getController: (name: string) => any; | ||
} | ||
|
||
export interface GridBaseView { | ||
name: string; | ||
_$element: any; | ||
render: () => any; | ||
} |
12 changes: 6 additions & 6 deletions
12
...n/ui/data_grid/data_grid_view_wrapper.tsx → ...rids/grid_base/grid_base_view_wrapper.tsx
This file contains 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
This file contains 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,24 @@ | ||
import { | ||
JSXComponent, Component, | ||
} from 'devextreme-generator/component_declaration/common'; | ||
import { GridBaseViewProps } from './common/grid_base_view_props'; | ||
import { GridBaseViewWrapper } from './grid_base_view_wrapper'; | ||
|
||
const GRIDBASE_CONTAINER_CLASS = 'dx-gridbase-container'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
export const viewFunction = ({ | ||
props: { | ||
views, | ||
className, | ||
}, | ||
}: GridBaseViews) => ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<div className={`${className} ${GRIDBASE_CONTAINER_CLASS}`}> | ||
{(views.map(({ name, view }) => (<GridBaseViewWrapper key={name} view={view} />)))} | ||
</div> | ||
); | ||
|
||
@Component({ defaultOptionRules: null, view: viewFunction }) | ||
export class GridBaseViews extends JSXComponent<GridBaseViewProps, 'views'>() { | ||
} |