Skip to content

Commit fa2e7f0

Browse files
authored
Merge pull request #156 from fhlavac/clean6
Move new changes to v6
2 parents f350034 + d511ebf commit fa2e7f0

29 files changed

+669
-480
lines changed

cypress/e2e/DataView.spec.cy.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
describe('Test the Data view docs page', () => {
2-
2+
33
it('displays a layout with a table and paginates', () => {
44
const ouiaId = 'LayoutExample';
5+
cy.viewport(1400, 2800)
56

6-
cy.visit('http://localhost:8006/extensions/data-view/layout');
7+
cy.visit('http://localhost:8006/extensions/data-view/overview');
78

9+
cy.get(`[data-ouia-component-id="${ouiaId}-th-0"]`).scrollIntoView().contains('Repository');
810
cy.get(`[data-ouia-component-id="${ouiaId}Header-pagination"]`).should('exist');
911
cy.get(`[data-ouia-component-id="${ouiaId}Header-bulk-select"]`).should('exist');
1012

1113
cy.get(`[data-ouia-component-id="${ouiaId}Footer-pagination"]`).should('exist');
1214
cy.get(`[data-ouia-component-id="${ouiaId}Footer-bulk-select"]`).should('not.exist');
1315

14-
cy.get(`[data-ouia-component-id="${ouiaId}-th-0"]`).contains('Repositories');
16+
cy.get(`[data-ouia-component-id="${ouiaId}-th-0"]`).contains('Repository');
1517
cy.get(`[data-ouia-component-id="${ouiaId}-th-4"]`).contains('Last commit');
1618

1719
cy.get(`[data-ouia-component-id="${ouiaId}-td-0-0"]`).contains('Repository one');
@@ -27,33 +29,27 @@ describe('Test the Data view docs page', () => {
2729
cy.get(`[data-ouia-component-id="${ouiaId}-td-0-4"]`).contains('Timestamp one');
2830

2931
// test bulk select
30-
cy.get(`input[type="checkbox"`).each(($checkbox) => {cy.wrap($checkbox).should('not.be.checked')});
32+
cy.get(`[data-ouia-component-id="LayoutExample"] input[type="checkbox"]`).each(($checkbox) => {cy.wrap($checkbox).should('not.be.checked')});
3133

3234
// page checkbox select
3335
cy.get(`[data-ouia-component-id="BulkSelect-checkbox"`).first().click();
34-
cy.get(`input[type="checkbox"`).each(($checkbox) => {cy.wrap($checkbox).should('be.checked')});
36+
cy.get(`[data-ouia-component-id="LayoutExample"] input[type="checkbox"]`).each(($checkbox) => {cy.wrap($checkbox).should('be.checked')});
3537
cy.contains('5 selected').should('exist');
3638

37-
// select none
38-
cy.get(`[data-ouia-component-id="BulkSelect-toggle"`).first().click({ force: true });
39-
cy.get(`[data-ouia-component-id="BulkSelect-select-none"`).first().click();
40-
cy.contains('5 selected').should('not.exist');
41-
42-
// select all
43-
cy.get(`[data-ouia-component-id="BulkSelect-toggle"`).first().click({ force: true });
44-
cy.get(`[data-ouia-component-id="BulkSelect-select-all"`).first().click();
45-
cy.get(`input[type="checkbox"`).each(($checkbox) => {cy.wrap($checkbox).should('be.checked')});
46-
cy.contains('6 selected').should('exist');
47-
4839
// page checkbox deselect
4940
cy.get(`[data-ouia-component-id="BulkSelect-checkbox"`).first().click();
50-
cy.get(`input[type="checkbox"`).each(($checkbox) => {cy.wrap($checkbox).should('not.be.checked')});
51-
cy.contains('1 selected').should('exist');
41+
cy.get('[data-ouia-component-id="LayoutExample"] input[type="checkbox"]')
42+
.each(($checkbox) => {
43+
cy.wrap($checkbox).should('not.be.checked');
44+
});
5245

5346
// select page
5447
cy.get(`[data-ouia-component-id="BulkSelect-toggle"`).first().click({ force: true });
5548
cy.get(`[data-ouia-component-id="BulkSelect-select-page"`).first().click();
56-
cy.get(`input[type="checkbox"`).each(($checkbox) => {cy.wrap($checkbox).should('be.checked')});
57-
cy.contains('6 selected').should('exist');
49+
cy.get('[data-ouia-component-id="LayoutExample"] input[type="checkbox"]')
50+
.each(($checkbox) => {
51+
cy.wrap($checkbox).should('be.checked');
52+
});
53+
cy.contains('5 selected').should('exist');
5854
})
5955
});

cypress/e2e/DataViewEvents.spec.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ describe('Test the Data view docs page', () => {
33
it('displays a table and opens detail', () => {
44
const ouiaId = 'ContextExample';
55

6-
cy.visit('http://localhost:8006/extensions/data-view/events-context');
6+
cy.visit('http://localhost:8006/extensions/data-view/overview');
77

88
cy.get(`[data-ouia-component-id="${ouiaId}-th-0"]`).contains('Repositories');
99
cy.get(`[data-ouia-component-id="${ouiaId}-th-4"]`).contains('Last commit');
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ describe('Test the Data view docs with tree table', () => {
33
it('displays a a components page with tree table', () => {
44
const ouiaId = 'TreeTableExample';
55

6-
cy.visit('http://localhost:8006/extensions/data-view/components');
6+
cy.visit('http://localhost:8006/extensions/data-view/table');
77

88
cy.get(`[data-ouia-component-id="${ouiaId}-th-0"]`).scrollIntoView().contains('Repositories');
99
cy.get(`[data-ouia-component-id="${ouiaId}-th-1"]`).contains('Branches');

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/module/patternfly-docs/content/extensions/data-view/about-data-view.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/module/patternfly-docs/content/extensions/data-view/examples/Components/Components.md

Lines changed: 0 additions & 108 deletions
This file was deleted.

packages/module/patternfly-docs/content/extensions/data-view/examples/Components/DataViewToolbarExample.tsx

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/module/patternfly-docs/content/extensions/data-view/examples/Layout/AbstractLayoutExample.tsx renamed to packages/module/patternfly-docs/content/extensions/data-view/examples/DataView/AbstractLayoutExample.tsx

File renamed without changes.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
section: extensions
3+
subsection: Data view
4+
id: Overview
5+
title: Data view overview
6+
propComponents: ['DataView']
7+
sortValue: 1
8+
sourceLink: https://github.com/patternfly/react-data-view/blob/main/packages/module/patternfly-docs/content/extensions/data-view/examples/DataView/DataView.md
9+
---
10+
import { useState, useEffect, useRef, useMemo } from 'react';
11+
import { Drawer, DrawerContent, DrawerContentBody } from '@patternfly/react-core';
12+
import { CubesIcon } from '@patternfly/react-icons';
13+
import { useDataViewPagination, useDataViewSelection, useDataViewFilters, useDataViewSort } from '@patternfly/react-data-view/dist/dynamic/Hooks';
14+
import { BulkSelect, BulkSelectValue, ErrorState, ResponsiveAction, ResponsiveActions, SkeletonTableHead, SkeletonTableBody } from '@patternfly/react-component-groups';
15+
import { DataView } from '@patternfly/react-data-view/dist/dynamic/DataView';
16+
import { DataViewToolbar } from '@patternfly/react-data-view/dist/dynamic/DataViewToolbar';
17+
import { DataViewTable } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
18+
import { useDataViewEventsContext, DataViewEventsContext, DataViewEventsProvider, EventTypes } from '@patternfly/react-data-view/dist/dynamic/DataViewEventsContext';
19+
import { DataViewFilters } from '@patternfly/react-data-view/dist/dynamic/DataViewFilters';
20+
import { DataViewTextFilter } from '@patternfly/react-data-view/dist/dynamic/DataViewTextFilter';
21+
import { DataViewCheckboxFilter } from '@patternfly/react-data-view/dist/dynamic/DataViewCheckboxFilter';
22+
23+
**Note:** Data view lives in its own package [`@patternfly/react-data-view`](https://www.npmjs.com/package/@patternfly/react-data-view)
24+
25+
If you notice a bug, or if you have a suggestion for improving the data view extension or its documentation, please file an issue in the [react-data-view](https://github.com/patternfly/react-data-view/issues) repository. Before doing so, please make sure there is not already a pre-existing issue.
26+
27+
---
28+
29+
The **data view** extension enables you to display datasets in organized layouts, with data representations and interactive toolbars for actions like selection and pagination.
30+
31+
### Layout
32+
33+
A data view should contain a header, the data representation, and a footer. These parts are organized in a [stack layout](/layouts/stack).
34+
35+
The data view toolbars and sub-components that display the data (like a card view or table) are always passed as `children` to the `<DataView>` component.
36+
37+
```js file="./AbstractLayoutExample.tsx"
38+
39+
```
40+
41+
### Modularity
42+
43+
The extension's modular architecture lets you efficiently create consistent data views, either by using predefined sub-components and hooks, or by defining your own. You can choose the tools that suit your needs and easily replace any part with a custom implementation.
44+
45+
The `<DataViewToolbar>` component extends the [PatternFly toolbar](/components/toolbar) to support the most common needs. For more details, refer to the [data view toolbar](/extensions/data-view/toolbar) examples. You can also use a custom toolbar component if needed for your use case.
46+
47+
Data can be presented using the predefined `<DataViewTable>` component, which is an abstraction above the [PatternFly table](/components/table). For more details, refer to the [data view table](/extensions/data-view/table) examples. If you have more specific data display needs, you can pass a custom implementation as a `<DataView>` child. In the near future, we are also planning to introduce a predefined card view component.
48+
49+
```js file="./PredefinedLayoutFullExample.tsx"
50+
51+
```
52+
53+
## Events context
54+
55+
The `<DataViewEventsContext>` component is an advanced feature that enables external listening of data view events. In order to share data view context with your other UI components, both your components and your data view should be wrapped with the `<DataViewEventsProvider>`. This is demonstrated in the following example.
56+
57+
### Row click subscription example
58+
This example uses the `<DataViewEventsProvider>` to display details about a selected row in a [drawer component](/components/drawer).
59+
60+
61+
```js file="./EventsExample.tsx"
62+
63+
```

packages/module/patternfly-docs/content/extensions/data-view/examples/EventsContext/EventsExample.tsx renamed to packages/module/patternfly-docs/content/extensions/data-view/examples/DataView/EventsExample.tsx

File renamed without changes.

0 commit comments

Comments
 (0)