-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pagination for folder listing (#113)
* Add grid pagination * Add default layouts for asset editor
- Loading branch information
Showing
23 changed files
with
349 additions
and
72 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 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
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
64 changes: 64 additions & 0 deletions
64
assets/js/src/modules/asset/types/folder/editor-tabs/tabs/list/grid-container.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,64 @@ | ||
import React from 'react' | ||
import { FormattedDate } from '@Pimcore/components/formatted-date/formatted-date' | ||
import { Grid } from '@Pimcore/components/grid/grid' | ||
import { createColumnHelper } from '@tanstack/react-table' | ||
import { Tag } from 'antd' | ||
import { PreviewContainer } from './grid-columns/preview-container' | ||
import { type ApiAssetsGetCollection, type ApiAssetsGetCollectionItem } from '@Pimcore/modules/asset/asset-api' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
interface GridContainerProps { | ||
assets: ApiAssetsGetCollection | ||
} | ||
|
||
const GridContainer = (props: GridContainerProps): React.JSX.Element => { | ||
const { assets } = props | ||
const { t } = useTranslation() | ||
const columnHelper = createColumnHelper<ApiAssetsGetCollectionItem>() | ||
|
||
const columns = [ | ||
columnHelper.accessor('fullPath', { | ||
header: t('asset.asset-editor-tabs.list.columns.preview'), | ||
cell: info => { | ||
if (info.row.original.type !== 'image') { | ||
return <></> | ||
} | ||
|
||
return <PreviewContainer cellInfo={info} /> | ||
}, | ||
id: 'preview', | ||
size: 110 | ||
}), | ||
|
||
columnHelper.accessor('id', { | ||
header: t('asset.asset-editor-tabs.list.columns.id') | ||
}), | ||
|
||
columnHelper.accessor('type', { | ||
header: t('asset.asset-editor-tabs.list.columns.type') | ||
}), | ||
|
||
columnHelper.accessor('fullPath', { | ||
header: t('asset.asset-editor-tabs.list.columns.fullPath'), | ||
cell: info => <Tag bordered={false} color='processing'>{info.getValue()!}</Tag>, | ||
id: 'fullPath', | ||
size: 300 | ||
}), | ||
|
||
columnHelper.accessor('creationDate', { | ||
header: t('asset.asset-editor-tabs.list.columns.creationDate'), | ||
cell: info => <FormattedDate timestamp={info.getValue() as number * 1000} /> | ||
}), | ||
|
||
columnHelper.accessor('modificationDate', { | ||
header: t('asset.asset-editor-tabs.list.columns.modificationDate'), | ||
cell: info => <FormattedDate timestamp={info.getValue() as number * 1000} /> | ||
}) | ||
] | ||
|
||
return ( | ||
<Grid data={assets} columns={columns} resizeable /> | ||
) | ||
} | ||
|
||
export { GridContainer } |
33 changes: 33 additions & 0 deletions
33
assets/js/src/modules/asset/types/folder/editor-tabs/tabs/list/grid-toolbar-container.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 React from 'react' | ||
import { GridToolbarView } from './grid-toolbar-view' | ||
import { Pagination } from 'antd' | ||
|
||
interface GridToolbarContainerProps { | ||
pager: { | ||
total: number | ||
pageSize: number | ||
current: number | ||
onChange: (page: number, pageSize: number) => void | ||
} | ||
} | ||
|
||
const GridToolbarContainer = (props: GridToolbarContainerProps): React.JSX.Element => { | ||
const { pager } = props | ||
|
||
return ( | ||
<GridToolbarView | ||
renderPagination={ | ||
<Pagination | ||
total={pager.total} | ||
showTotal={(total) => `Total ${total} items`} // @todo translation | ||
defaultPageSize={pager.pageSize} | ||
current={pager.current} | ||
onChange={pager.onChange} | ||
pageSizeOptions={['10', '20', '50', '100']} | ||
/> | ||
} | ||
/> | ||
) | ||
} | ||
|
||
export { GridToolbarContainer } |
17 changes: 17 additions & 0 deletions
17
assets/js/src/modules/asset/types/folder/editor-tabs/tabs/list/grid-toolbar-view.styles.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,17 @@ | ||
import { createStyles } from 'antd-style' | ||
|
||
export const useStyles = createStyles(({ css, token }) => { | ||
return { | ||
GridToolbar: css` | ||
display: flex; | ||
justify-content: space-between; | ||
background-color: ${token.colorBgToolbar}; | ||
border-top: 1px solid ${token.colorBorderTertiary}; | ||
padding-right: ${token.paddingSM}px; | ||
padding-left: ${token.paddingXS}px; | ||
height: ${token.sizeXXL}px; | ||
align-items: center; | ||
justify-content: space-between; | ||
` | ||
} | ||
}) |
20 changes: 20 additions & 0 deletions
20
assets/js/src/modules/asset/types/folder/editor-tabs/tabs/list/grid-toolbar-view.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,20 @@ | ||
import React, { type ReactNode } from 'react' | ||
import { useStyles } from './grid-toolbar-view.styles' | ||
|
||
export interface GridToolbarViewProps { | ||
renderPagination: ReactNode | ||
} | ||
|
||
const GridToolbarView = (props: GridToolbarViewProps): React.JSX.Element => { | ||
const { styles } = useStyles() | ||
|
||
return ( | ||
<div className={styles.GridToolbar}> | ||
<div /> {/* @todo tools */} | ||
|
||
{props.renderPagination} | ||
</div> | ||
) | ||
} | ||
|
||
export { GridToolbarView } |
13 changes: 10 additions & 3 deletions
13
assets/js/src/modules/asset/types/folder/folder-container.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
Oops, something went wrong.