mirror of
https://github.com/strapi/strapi.git
synced 2025-10-28 08:32:08 +00:00
Move DynamicTable to helper plugin
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
0b01fca1a3
commit
737568a10c
@ -86,6 +86,7 @@ const TableRows = ({
|
|||||||
|
|
||||||
TableRows.defaultProps = {
|
TableRows.defaultProps = {
|
||||||
canDelete: false,
|
canDelete: false,
|
||||||
|
entriesToDelete: [],
|
||||||
onClickDelete: () => {},
|
onClickDelete: () => {},
|
||||||
onSelectRow: () => {},
|
onSelectRow: () => {},
|
||||||
rows: [],
|
rows: [],
|
||||||
@ -95,7 +96,7 @@ TableRows.defaultProps = {
|
|||||||
|
|
||||||
TableRows.propTypes = {
|
TableRows.propTypes = {
|
||||||
canDelete: PropTypes.bool,
|
canDelete: PropTypes.bool,
|
||||||
entriesToDelete: PropTypes.array.isRequired,
|
entriesToDelete: PropTypes.array,
|
||||||
headers: PropTypes.array.isRequired,
|
headers: PropTypes.array.isRequired,
|
||||||
onClickDelete: PropTypes.func,
|
onClickDelete: PropTypes.func,
|
||||||
onSelectRow: PropTypes.func,
|
onSelectRow: PropTypes.func,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import {
|
import {
|
||||||
CustomContentLayout,
|
CustomContentLayout,
|
||||||
|
DynamicTable,
|
||||||
Search,
|
Search,
|
||||||
SettingsPageTitle,
|
SettingsPageTitle,
|
||||||
useRBAC,
|
useRBAC,
|
||||||
@ -14,7 +15,7 @@ import { useIntl } from 'react-intl';
|
|||||||
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
import adminPermissions from '../../../../../permissions';
|
import adminPermissions from '../../../../../permissions';
|
||||||
import DynamicTable from './DynamicTable';
|
import TableRows from './DynamicTable/TableRows';
|
||||||
import Filters from './Filters';
|
import Filters from './Filters';
|
||||||
import ModalForm from './ModalForm';
|
import ModalForm from './ModalForm';
|
||||||
import PaginationFooter from './PaginationFooter';
|
import PaginationFooter from './PaginationFooter';
|
||||||
@ -117,15 +118,25 @@ const ListPage = () => {
|
|||||||
{canRead && (
|
{canRead && (
|
||||||
<>
|
<>
|
||||||
<DynamicTable
|
<DynamicTable
|
||||||
canCreate={canCreate}
|
contentType="Users"
|
||||||
canDelete={canDelete}
|
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
onConfirmDeleteAll={deleteAllMutation.mutateAsync}
|
onConfirmDeleteAll={deleteAllMutation.mutateAsync}
|
||||||
headers={tableHeaders}
|
headers={tableHeaders}
|
||||||
rows={data?.results}
|
rows={data?.results}
|
||||||
withBulkActions
|
withBulkActions
|
||||||
withMainAction={canDelete}
|
withMainAction={canDelete}
|
||||||
|
>
|
||||||
|
<TableRows
|
||||||
|
canDelete={canDelete}
|
||||||
|
// entriesToDelete={entriesToDelete}
|
||||||
|
headers={tableHeaders}
|
||||||
|
// onClickDelete={handleClickDelete}
|
||||||
|
// onSelectRow={handleSelectRow}
|
||||||
|
rows={data?.results || []}
|
||||||
|
withBulkActions
|
||||||
|
withMainAction={canDelete}
|
||||||
/>
|
/>
|
||||||
|
</DynamicTable>
|
||||||
<PaginationFooter pagination={data?.pagination} />
|
<PaginationFooter pagination={data?.pagination} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -9,9 +9,10 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
VisuallyHidden,
|
VisuallyHidden,
|
||||||
} from '@strapi/parts';
|
} from '@strapi/parts';
|
||||||
import { SortIcon, useQueryParams } from '@strapi/helper-plugin';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
|
import SortIcon from '../../../icons/SortIcon';
|
||||||
|
import useQueryParams from '../../../hooks/useQueryParams';
|
||||||
|
|
||||||
const TableHead = ({
|
const TableHead = ({
|
||||||
areAllEntriesSelected,
|
areAllEntriesSelected,
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { Children, cloneElement, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Box, Row, Button, Table as TableCompo, Subtitle } from '@strapi/parts';
|
import { Box, Row, Button, Table as TableCompo, Subtitle } from '@strapi/parts';
|
||||||
import { ConfirmDialog, EmptyBodyTable, useQueryParams } from '@strapi/helper-plugin';
|
import { ConfirmDialog, EmptyBodyTable, useQueryParams } from '@strapi/helper-plugin';
|
||||||
@ -6,7 +6,6 @@ import { useIntl } from 'react-intl';
|
|||||||
import { DeleteIcon } from '@strapi/icons';
|
import { DeleteIcon } from '@strapi/icons';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import TableHead from './TableHead';
|
import TableHead from './TableHead';
|
||||||
import TableRows from './TableRows';
|
|
||||||
|
|
||||||
const BlockActions = styled(Row)`
|
const BlockActions = styled(Row)`
|
||||||
& > * + * {
|
& > * + * {
|
||||||
@ -17,7 +16,8 @@ const BlockActions = styled(Row)`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const Table = ({
|
const Table = ({
|
||||||
canDelete,
|
children,
|
||||||
|
contentType,
|
||||||
headers,
|
headers,
|
||||||
isLoading,
|
isLoading,
|
||||||
onConfirmDeleteAll,
|
onConfirmDeleteAll,
|
||||||
@ -40,7 +40,7 @@ const Table = ({
|
|||||||
? {
|
? {
|
||||||
id: 'content-manager.components.TableEmpty.withFilters',
|
id: 'content-manager.components.TableEmpty.withFilters',
|
||||||
defaultMessage: 'There are no {contentType} with the applied filters...',
|
defaultMessage: 'There are no {contentType} with the applied filters...',
|
||||||
values: { contentType: 'Users' },
|
values: { contentType },
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
@ -145,16 +145,13 @@ const Table = ({
|
|||||||
{!rows.length || isLoading ? (
|
{!rows.length || isLoading ? (
|
||||||
<EmptyBodyTable colSpan={COL_COUNT} content={content} isLoading={isLoading} />
|
<EmptyBodyTable colSpan={COL_COUNT} content={content} isLoading={isLoading} />
|
||||||
) : (
|
) : (
|
||||||
<TableRows
|
Children.toArray(children).map(child =>
|
||||||
canDelete={canDelete}
|
cloneElement(child, {
|
||||||
entriesToDelete={entriesToDelete}
|
entriesToDelete,
|
||||||
headers={headers}
|
onClickDelete: handleClickDelete,
|
||||||
onClickDelete={handleClickDelete}
|
onSelectRow: handleSelectRow,
|
||||||
onSelectRow={handleSelectRow}
|
})
|
||||||
rows={rows}
|
)
|
||||||
withBulkActions={withBulkActions}
|
|
||||||
withMainAction={withMainAction}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</TableCompo>
|
</TableCompo>
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
@ -174,6 +171,7 @@ const Table = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
Table.defaultProps = {
|
Table.defaultProps = {
|
||||||
|
children: undefined,
|
||||||
headers: [],
|
headers: [],
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
onConfirmDeleteAll: () => {},
|
onConfirmDeleteAll: () => {},
|
||||||
@ -183,7 +181,8 @@ Table.defaultProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Table.propTypes = {
|
Table.propTypes = {
|
||||||
canDelete: PropTypes.bool.isRequired,
|
children: PropTypes.node,
|
||||||
|
contentType: PropTypes.string.isRequired,
|
||||||
headers: PropTypes.array,
|
headers: PropTypes.array,
|
||||||
isLoading: PropTypes.bool,
|
isLoading: PropTypes.bool,
|
||||||
onConfirmDeleteAll: PropTypes.func,
|
onConfirmDeleteAll: PropTypes.func,
|
||||||
@ -182,6 +182,7 @@ export { default as CheckPermissions } from './components/CheckPermissions';
|
|||||||
export { default as ConfirmDialog } from './components/ConfirmDialog';
|
export { default as ConfirmDialog } from './components/ConfirmDialog';
|
||||||
export { default as ContentBox } from './components/ContentBox';
|
export { default as ContentBox } from './components/ContentBox';
|
||||||
export { default as CustomContentLayout } from './components/CustomContentLayout';
|
export { default as CustomContentLayout } from './components/CustomContentLayout';
|
||||||
|
export { default as DynamicTable } from './components/DynamicTable';
|
||||||
export { default as EmptyStateLayout } from './components/EmptyStateLayout';
|
export { default as EmptyStateLayout } from './components/EmptyStateLayout';
|
||||||
export { default as EmptyBodyTable } from './components/EmptyBodyTable';
|
export { default as EmptyBodyTable } from './components/EmptyBodyTable';
|
||||||
export { default as GenericInput } from './components/GenericInput';
|
export { default as GenericInput } from './components/GenericInput';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user