@craftercms/studio-ui
Version:
Services, components, models & utils to build CrafterCMS authoring extensions.
252 lines (250 loc) • 9.4 kB
JavaScript
/*
* 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-2023 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 from 'react';
import TableContainer from '@mui/material/TableContainer';
import useStyles from '../LegacyRecentActivityDashletGrid/styles';
import TableHead from '@mui/material/TableHead';
import Table from '@mui/material/Table';
import GlobalAppGridRow from '../../GlobalAppGridRow';
import GlobalAppGridCell from '../../GlobalAppGridCell';
import Checkbox from '@mui/material/Checkbox';
import Typography from '@mui/material/Typography';
import { FormattedMessage } from 'react-intl';
import TableBody from '@mui/material/TableBody';
import ItemDisplay from '../../ItemDisplay';
import { asLocalizedDateTime } from '../../../utils/datetime';
import IconButton from '@mui/material/IconButton';
import MoreVertRounded from '@mui/icons-material/MoreVertRounded';
import Tooltip from '@mui/material/Tooltip';
import { getDateScheduled } from '../../../utils/content';
export function LegacyInReviewDashletGridUI(props) {
const {
items,
locale,
onOptionsButtonClick,
selectedLookup,
onItemChecked,
isAllChecked,
isIndeterminate,
onClickSelectAll
} = props;
const { classes, cx } = useStyles();
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: 'checkbox' },
React.createElement(Checkbox, {
disabled: (items === null || items === void 0 ? void 0 : items.length) === 1 && items[0].stateMap.deleted,
indeterminate: isIndeterminate,
checked: isAllChecked,
onChange: () => onClickSelectAll()
})
),
React.createElement(
GlobalAppGridCell,
{ className: 'width40 pl0' },
React.createElement(
Typography,
{ variant: 'subtitle2' },
React.createElement(FormattedMessage, { id: 'words.item', defaultMessage: 'Item' })
)
),
React.createElement(
GlobalAppGridCell,
{ className: 'width15 ellipsis' },
React.createElement(
Typography,
{ variant: 'subtitle2' },
React.createElement(FormattedMessage, {
id: 'inReviewDashlet.publishingTarget',
defaultMessage: 'Publishing Target'
})
)
),
React.createElement(
GlobalAppGridCell,
{ className: 'width15 ellipsis' },
React.createElement(
Typography,
{ variant: 'subtitle2' },
React.createElement(FormattedMessage, { defaultMessage: 'Publishing Date' })
)
),
React.createElement(
GlobalAppGridCell,
{ className: 'width15 ellipsis' },
React.createElement(
Typography,
{ variant: 'subtitle2' },
React.createElement(FormattedMessage, {
id: 'inReviewDashlet.lastEditedBy',
defaultMessage: 'Last Edited By'
})
)
),
React.createElement(
GlobalAppGridCell,
{ className: 'width15 ellipsis' },
React.createElement(
Typography,
{ variant: 'subtitle2' },
React.createElement(FormattedMessage, { id: 'inReviewDashlet.lastEdited', defaultMessage: 'Last Edited' })
)
),
React.createElement(GlobalAppGridCell, { className: 'checkbox' })
)
),
React.createElement(
TableBody,
null,
items.map((item) =>
React.createElement(
GlobalAppGridRow,
{
key: item.id,
onClick: item.stateMap.deleted
? null
: () => {
onItemChecked(item.path);
}
},
React.createElement(
GlobalAppGridCell,
{ className: 'checkbox' },
React.createElement(Checkbox, {
disabled: item.stateMap.deleted,
checked: item.stateMap.deleted ? false : Boolean(selectedLookup[item.path]),
onClick: (e) => {
e.stopPropagation();
},
onChange: () => {
onItemChecked(item.path);
}
})
),
React.createElement(
GlobalAppGridCell,
{ className: 'ellipsis width40 pl0' },
React.createElement(ItemDisplay, {
item: item,
showNavigableAsLinks: false,
showPublishingTarget: false
}),
React.createElement(
Typography,
{
title: item.path,
variant: 'caption',
component: 'p',
className: cx(classes.itemPath, classes.ellipsis)
},
item.path
)
),
React.createElement(
GlobalAppGridCell,
{ className: 'width15' },
item.stateMap.submittedToLive
? React.createElement(FormattedMessage, { id: 'words.live', defaultMessage: 'Live' })
: React.createElement(FormattedMessage, { id: 'words.staging', defaultMessage: 'Staging' })
),
React.createElement(
GlobalAppGridCell,
{
className: 'width15',
title:
getDateScheduled(item) &&
asLocalizedDateTime(getDateScheduled(item), locale.localeCode, locale.dateTimeFormatOptions)
},
getDateScheduled(item)
? asLocalizedDateTime(getDateScheduled(item), locale.localeCode, locale.dateTimeFormatOptions)
: React.createElement(
Typography,
{ variant: 'caption', color: 'textSecondary' },
React.createElement(FormattedMessage, { id: 'words.now', defaultMessage: 'Now' })
)
),
React.createElement(
GlobalAppGridCell,
{ className: 'width15 ellipsis', title: item.sandbox.modifier },
item.sandbox.modifier
),
React.createElement(
GlobalAppGridCell,
{ className: 'width15 ellipsis' },
item.sandbox.dateModified &&
asLocalizedDateTime(item.sandbox.dateModified, locale.localeCode, locale.dateTimeFormatOptions)
),
React.createElement(
GlobalAppGridCell,
{ className: 'checkbox' },
item.stateMap.deleted
? React.createElement(
IconButton,
{ disabled: true, size: 'large' },
React.createElement(MoreVertRounded, null)
)
: React.createElement(
Tooltip,
{
title: React.createElement(FormattedMessage, { id: 'words.options', defaultMessage: 'Options' })
},
React.createElement(
IconButton,
{
onClick: (e) => {
e.stopPropagation();
onOptionsButtonClick(e, item);
},
size: 'large'
},
React.createElement(MoreVertRounded, null)
)
)
)
)
)
)
)
);
}
export default LegacyInReviewDashletGridUI;