UNPKG

@craftercms/studio-ui

Version:

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

309 lines (307 loc) 13.3 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 TableContainer from '@mui/material/TableContainer'; import useStyles from './styles'; import Table from '@mui/material/Table'; import TableHead from '@mui/material/TableHead'; import Typography from '@mui/material/Typography'; import { FormattedMessage } from 'react-intl'; import TableBody from '@mui/material/TableBody'; import IconButton from '@mui/material/IconButton'; import Collapse from '@mui/material/Collapse'; import Box from '@mui/material/Box'; import ExpandMoreIcon from '@mui/icons-material/ExpandMoreRounded'; import GlobalAppGridRow from '../../GlobalAppGridRow'; import GlobalAppGridCell from '../../GlobalAppGridCell'; import Checkbox from '@mui/material/Checkbox'; import MoreVertRounded from '@mui/icons-material/MoreVertRounded'; import ItemDisplay from '../../ItemDisplay'; import ExpandLessIcon from '@mui/icons-material/ExpandLessRounded'; import { asLocalizedDateTime } from '../../../utils/datetime'; import Tooltip from '@mui/material/Tooltip'; import { useLocale } from '../../../hooks/useLocale'; import { getDateScheduled } from '../../../utils/content'; export function AwaitingApprovalDashletGridUI(props) { const { items, onExpandedRow, expandedLookup, publishingTargetLookup, itemsLookup, selectedLookup, onItemMenuClick, onItemChecked, isAllChecked, isIndeterminate, onToggleCheckedAll } = props; const { classes, cx: clsx } = useStyles(); const locale = useLocale(); return React.createElement( TableContainer, null, React.createElement( Table, { className: classes.tableRoot, size: 'small' }, React.createElement( TableHead, null, React.createElement( GlobalAppGridRow, { className: 'hoverDisabled' }, React.createElement( GlobalAppGridCell, { className: 'checkbox' }, React.createElement(Checkbox, { indeterminate: isIndeterminate, checked: isAllChecked || isIndeterminate, onChange: onToggleCheckedAll }) ), React.createElement( GlobalAppGridCell, { className: 'width40 pl0' }, React.createElement(FormattedMessage, { id: 'awaitingApprovalDashlet.item', defaultMessage: 'Item' }) ), React.createElement( GlobalAppGridCell, { className: 'width15 ellipsis' }, React.createElement(FormattedMessage, { id: 'awaitingApprovalDashlet.publishingTarget', defaultMessage: 'Publishing Target' }) ), React.createElement( GlobalAppGridCell, { className: 'width15 ellipsis' }, React.createElement(FormattedMessage, { defaultMessage: 'Publishing Date' }) ), React.createElement( GlobalAppGridCell, { className: 'width15 ellipsis' }, React.createElement(FormattedMessage, { id: 'awaitingApprovalDashlet.lastEditedBy', defaultMessage: 'Last Edited By' }) ), React.createElement( GlobalAppGridCell, { className: 'width15 ellipsis' }, React.createElement(FormattedMessage, { id: 'awaitingApprovalDashlet.lastEdited', defaultMessage: 'Last Edited' }) ), React.createElement(GlobalAppGridCell, { className: 'checkbox' }) ) ), React.createElement( TableBody, null, items.map((dashboardItem, i) => React.createElement( Fragment, { key: i }, React.createElement( GlobalAppGridRow, { onClick: () => onExpandedRow(dashboardItem.path, !expandedLookup[dashboardItem.path]) }, React.createElement( GlobalAppGridCell, { colSpan: 7 }, React.createElement( Box, { display: 'flex', alignItems: 'center' }, React.createElement( IconButton, { size: 'small' }, expandedLookup[dashboardItem.path] ? React.createElement(ExpandLessIcon, null) : React.createElement(ExpandMoreIcon, null) ), React.createElement(Typography, null, dashboardItem.label, ' (', dashboardItem.children.length, ')') ) ) ), React.createElement( GlobalAppGridRow, { className: 'hoverDisabled' }, React.createElement( GlobalAppGridCell, { colSpan: 7, className: 'padded0 bb0' }, React.createElement( Collapse, { in: expandedLookup[dashboardItem.path] }, React.createElement( Table, { size: 'small', className: classes.tableRoot }, React.createElement( TableBody, null, dashboardItem.children.map( (path, i) => itemsLookup[path] && React.createElement( GlobalAppGridRow, { key: i, onClick: () => { onItemChecked(path); } }, React.createElement( GlobalAppGridCell, { className: 'checkbox' }, React.createElement(Checkbox, { checked: Boolean(selectedLookup[itemsLookup[path].path]), onClick: (e) => { e.stopPropagation(); }, onChange: () => { onItemChecked(path); } }) ), React.createElement( GlobalAppGridCell, { className: 'ellipsis width40 pl0' }, React.createElement(ItemDisplay, { item: itemsLookup[path], showNavigableAsLinks: false, showPublishingTarget: 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: 'width15' }, publishingTargetLookup[itemsLookup[path].path] ), React.createElement( GlobalAppGridCell, { className: 'width15', title: getDateScheduled(itemsLookup[path]) && asLocalizedDateTime( getDateScheduled(itemsLookup[path]), locale.localeCode, locale.dateTimeFormatOptions ) }, getDateScheduled(itemsLookup[path]) ? asLocalizedDateTime( getDateScheduled(itemsLookup[path]), locale.localeCode, locale.dateTimeFormatOptions ) : React.createElement( Typography, { variant: 'caption', color: 'textSecondary' }, publishingTargetLookup[itemsLookup[path].path] ? React.createElement(FormattedMessage, { id: 'words.now', defaultMessage: 'Now' }) : React.createElement(FormattedMessage, { id: 'words.unpublished', defaultMessage: 'Unpublished' }) ) ), React.createElement( GlobalAppGridCell, { className: 'width15 ellipsis', title: itemsLookup[path].sandbox.modifier }, itemsLookup[path].sandbox.modifier ), React.createElement( GlobalAppGridCell, { className: 'width15 ellipsis', title: asLocalizedDateTime( itemsLookup[path].sandbox.dateModified, locale.localeCode, locale.dateTimeFormatOptions ) }, asLocalizedDateTime( itemsLookup[path].sandbox.dateModified, locale.localeCode, locale.dateTimeFormatOptions ) ), 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 AwaitingApprovalDashletGridUI;