-
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.
* Task: create preview grid * Task: create preview grid * Task: create preview grid * Automatic frontend build * Task: implement feedback --------- Co-authored-by: robertSt7 <[email protected]> Co-authored-by: vin0401 <[email protected]>
- Loading branch information
1 parent
7ee342c
commit 174a8e8
Showing
17 changed files
with
234 additions
and
18 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
57 changes: 57 additions & 0 deletions
57
assets/js/src/modules/asset/types/folder/editor-tabs/tabs/preview-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,57 @@ | ||
import { useApiAssetsGetCollectionQuery } from '@Pimcore/modules/asset/asset-api-slice.gen' | ||
import { AssetContext } from '@Pimcore/modules/asset/asset-container' | ||
import React, { useContext, useState } from 'react' | ||
import { GridToolbarContainer } from './list/grid-toolbar-container' | ||
import { ContentToolbarSidebarView } from '@Pimcore/modules/element-editor/tab-layouts/content-toolbar-sidebar-view' | ||
import { FlexContainer } from '@Pimcore/modules/asset/types/folder/editor-tabs/tabs/preview/flex-container' | ||
import { useAssetDraft } from '@Pimcore/modules/asset/hooks/use-asset-draft' | ||
|
||
const PreviewContainer = (): React.JSX.Element => { | ||
const assetContext = useContext(AssetContext) | ||
const [currentPage, setCurrentPage] = useState(1) | ||
const [pageSize, setPageSize] = useState(20) | ||
const assetId = assetContext.id! | ||
const { asset } = useAssetDraft(assetId) | ||
|
||
const { isLoading, isError, data } = useApiAssetsGetCollectionQuery({ | ||
assetPathIncludeDescendants: true, | ||
page: currentPage, | ||
itemsPerPage: pageSize, | ||
excludeFolders: true, | ||
assetPath: asset?.fullPath | ||
}) | ||
|
||
if (isLoading || data === undefined) { | ||
return <div>Loading...</div> | ||
} | ||
|
||
if (isError) { | ||
return <div>Error</div> | ||
} | ||
|
||
const total = data['hydra:totalItems']! | ||
|
||
function onPagerChange (page: number, pageSize: number): void { | ||
setCurrentPage(page) | ||
setPageSize(pageSize) | ||
} | ||
|
||
return ( | ||
<ContentToolbarSidebarView | ||
renderToolbar={ | ||
<GridToolbarContainer | ||
pager={{ | ||
current: currentPage, | ||
total, | ||
pageSize, | ||
onChange: onPagerChange | ||
}} | ||
/> | ||
} | ||
> | ||
<FlexContainer assets={data['hydra:member']} /> | ||
</ContentToolbarSidebarView> | ||
) | ||
} | ||
|
||
export { PreviewContainer } |
13 changes: 13 additions & 0 deletions
13
.../js/src/modules/asset/types/folder/editor-tabs/tabs/preview/flex-container-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,13 @@ | ||
import { createStyles } from 'antd-style' | ||
|
||
export const useStyles = createStyles(({ css, token }) => { | ||
return { | ||
flexContainer: css` | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: ${token.marginXS}px; | ||
padding: ${token.marginXS}px ${token.paddingSM}px ${token.marginXS}px ${token.paddingXS}px; | ||
align-self: baseline; | ||
` | ||
} | ||
}) |
18 changes: 18 additions & 0 deletions
18
assets/js/src/modules/asset/types/folder/editor-tabs/tabs/preview/flex-container-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,18 @@ | ||
import React, { type ReactNode } from 'react' | ||
import { useStyles } from '@Pimcore/modules/asset/types/folder/editor-tabs/tabs/preview/flex-container-view.styles' | ||
|
||
interface FlexContainerProps { | ||
renderElements: ReactNode[] | ||
className?: string | ||
} | ||
|
||
const FlexContainerView = (props: FlexContainerProps): React.JSX.Element => { | ||
const { styles } = useStyles() | ||
return ( | ||
<div className={styles.flexContainer + ' ' + props.className ?? ''}> | ||
{props.renderElements} | ||
</div> | ||
) | ||
} | ||
|
||
export { FlexContainerView } |
72 changes: 72 additions & 0 deletions
72
assets/js/src/modules/asset/types/folder/editor-tabs/tabs/preview/flex-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,72 @@ | ||
import React, { type ReactNode } from 'react' | ||
import { type ApiAssetsGetCollection } from '@Pimcore/modules/asset/asset-api' | ||
import { useTranslation } from 'react-i18next' | ||
import { FlexContainerView } from '@Pimcore/modules/asset/types/folder/editor-tabs/tabs/preview/flex-container-view' | ||
import { PreviewCard } from '@Pimcore/components/preview-card/preview-card' | ||
import type { DropdownMenuItemProps } from '@Pimcore/components/dropdown-menu/dropdown-menu' | ||
import { useAsset } from '@Pimcore/modules/asset/hooks/use-asset' | ||
|
||
interface FlexContainerProps { | ||
assets: ApiAssetsGetCollection | ||
} | ||
|
||
const FlexContainer = (props: FlexContainerProps): React.JSX.Element => { | ||
const { assets } = props | ||
const { t } = useTranslation() | ||
const { openAsset } = useAsset() | ||
|
||
const dropdownItems: DropdownMenuItemProps[] = [ | ||
{ | ||
iconLeft: 'target', | ||
label: t('preview-card.locate-in-tree') | ||
}, | ||
{ | ||
iconLeft: 'info-circle-outlined', | ||
label: t('preview-card.info'), | ||
iconRight: { | ||
name: 'right-outlined' | ||
} | ||
}, | ||
{ | ||
iconLeft: 'rich-edit', | ||
label: t('preview-card.rename') | ||
}, | ||
{ | ||
iconLeft: 'download-02', | ||
label: t('preview-card.download-zip') | ||
}, | ||
{ | ||
iconLeft: 'delete-outlined', | ||
label: t('preview-card.delete') | ||
} | ||
] | ||
|
||
const cards: ReactNode[] = [] | ||
assets.forEach((asset) => { | ||
const onClickCard = (e): void => { | ||
openAsset({ | ||
name: asset.filename, | ||
icon: asset.iconName ?? 'file-question-02', | ||
|
||
config: { | ||
id: asset.id! | ||
} | ||
}) | ||
} | ||
|
||
cards.push( | ||
<PreviewCard key={asset.id} | ||
name={asset.filename} | ||
dropdownItems={dropdownItems} | ||
imgSrc={asset.fullPath} | ||
onClick={onClickCard} | ||
/> | ||
) | ||
}) | ||
|
||
return ( | ||
<FlexContainerView renderElements={cards} /> | ||
) | ||
} | ||
|
||
export { FlexContainer } |
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
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
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 was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
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