UNPKG

@craftercms/studio-ui

Version:

Services, components, models & utils to build CrafterCMS authoring extensions.

255 lines (253 loc) 10.5 kB
/* * Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* * Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import React, { Fragment } from 'react'; import Table from '@mui/material/Table'; import TableHead from '@mui/material/TableHead'; import GlobalAppGridRow from '../../GlobalAppGridRow'; import GlobalAppGridCell from '../../GlobalAppGridCell'; import TableBody from '@mui/material/TableBody'; import TableContainer from '@mui/material/TableContainer'; import { FormattedMessage } from 'react-intl'; import Typography from '@mui/material/Typography'; import IconButton from '@mui/material/IconButton'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import ExpandLessIcon from '@mui/icons-material/ExpandLess'; import Collapse from '@mui/material/Collapse'; import ItemDisplay from '../../ItemDisplay'; import MoreVertRounded from '@mui/icons-material/MoreVertRounded'; import Box from '@mui/material/Box'; import useStyles from './styles'; import { asLocalizedDateTime } from '../../../utils/datetime'; import Tooltip from '@mui/material/Tooltip'; import { getDatePublished } from '../../../utils/content'; export function LegacyRecentlyPublishedDashletUI(props) { const { parentItems, expandedItems, setExpandedItems, itemsLookup, onItemMenuClick, localeBranch } = props; const { classes, cx: clsx } = useStyles(); const toggleExpand = (name) => { setExpandedItems({ [name]: !expandedItems[name] }); }; return React.createElement( TableContainer, null, React.createElement( Table, { size: 'small', className: classes.tableRoot }, React.createElement( TableHead, null, React.createElement( GlobalAppGridRow, { className: 'hoverDisabled' }, React.createElement( GlobalAppGridCell, { className: 'width40 pl20' }, React.createElement( Typography, { variant: 'subtitle2' }, React.createElement(FormattedMessage, { id: 'words.item', defaultMessage: 'Item' }) ) ), React.createElement( GlobalAppGridCell, { className: 'width20 ellipsis' }, React.createElement( Typography, { variant: 'subtitle2' }, React.createElement(FormattedMessage, { id: 'recentlyPublished.publishedTo', defaultMessage: 'Published To' }) ) ), React.createElement( GlobalAppGridCell, { className: 'width20 ellipsis' }, React.createElement( Typography, { variant: 'subtitle2' }, React.createElement(FormattedMessage, { id: 'recentlyPublished.publishDate', defaultMessage: 'Publish Date' }) ) ), React.createElement( GlobalAppGridCell, { className: 'width20 ellipsis' }, React.createElement( Typography, { variant: 'subtitle2' }, React.createElement(FormattedMessage, { id: 'recentlyPublished.publishedBy', defaultMessage: 'Published By' }) ) ), React.createElement(GlobalAppGridCell, { className: 'checkbox' }) ) ), React.createElement( TableBody, null, parentItems.map((item, i) => React.createElement( Fragment, { key: i }, React.createElement( GlobalAppGridRow, { key: item.label, onClick: () => toggleExpand(item.label) }, React.createElement( GlobalAppGridCell, { colSpan: 5, className: 'expandableCell' }, React.createElement( Box, { display: 'flex', alignItems: 'center' }, React.createElement( IconButton, { size: 'small' }, expandedItems[item.label] ? React.createElement(ExpandLessIcon, null) : React.createElement(ExpandMoreIcon, null) ), React.createElement(Typography, null, item.label, ' (', item.children.length, ')') ) ) ), React.createElement( GlobalAppGridRow, { className: 'hoverDisabled' }, React.createElement( GlobalAppGridCell, { colSpan: 5, className: 'padded0 bb0' }, React.createElement( Collapse, { in: expandedItems[item.label] }, React.createElement( Table, { size: 'small', className: classes.tableRoot }, React.createElement( TableBody, null, item.children.map((path, i) => React.createElement( GlobalAppGridRow, { key: i }, React.createElement( GlobalAppGridCell, { className: 'ellipsis width40 pl20' }, React.createElement(ItemDisplay, { item: itemsLookup[path], showNavigableAsLinks: false, showPublishingTarget: false, showWorkflowState: false }), React.createElement( Typography, { title: itemsLookup[path].path, variant: 'caption', component: 'p', className: clsx(classes.itemPath, classes.ellipsis) }, itemsLookup[path].path ) ), React.createElement( GlobalAppGridCell, { className: 'width20' }, itemsLookup[path].stateMap.live ? React.createElement(FormattedMessage, { id: 'words.live', defaultMessage: 'Live' }) : React.createElement(FormattedMessage, { id: 'words.staging', defaultMessage: 'Staging' }) ), React.createElement( GlobalAppGridCell, { className: 'width20 ellipsis', title: asLocalizedDateTime( getDatePublished(itemsLookup[path]), localeBranch.localeCode, localeBranch.dateTimeFormatOptions ) }, asLocalizedDateTime( getDatePublished(itemsLookup[path]), localeBranch.localeCode, localeBranch.dateTimeFormatOptions ) ), React.createElement( GlobalAppGridCell, { className: 'width20' }, itemsLookup[path].stateMap.live ? itemsLookup[path].live.publisher : itemsLookup[path].staging.publisher ), React.createElement( GlobalAppGridCell, { className: 'checkbox' }, React.createElement( Tooltip, { title: React.createElement(FormattedMessage, { id: 'words.options', defaultMessage: 'Options' }) }, React.createElement( IconButton, { size: 'small', onClick: (e) => { e.stopPropagation(); onItemMenuClick(e, itemsLookup[path]); } }, React.createElement(MoreVertRounded, null) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ); } export default LegacyRecentlyPublishedDashletUI;