UNPKG

@craftercms/studio-ui

Version:

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

155 lines (153 loc) 6.04 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 from 'react'; import TableContainer from '@mui/material/TableContainer'; import Table from '@mui/material/Table'; import TableHead from '@mui/material/TableHead'; import GlobalAppGridRow from '../GlobalAppGridRow'; import GlobalAppGridCell from '../GlobalAppGridCell'; import Typography from '@mui/material/Typography'; import { FormattedMessage } from 'react-intl'; import TableBody from '@mui/material/TableBody'; import VisibilityRoundedIcon from '@mui/icons-material/VisibilityRounded'; import { IconButton } from '@mui/material'; import { useSelection } from '../../hooks/useSelection'; export function LogConsoleGridUI(props) { const { logEvents, onLogEventDetails, showSiteColumn } = props; const localeBranch = useSelection((state) => state.uiConfig.locale); return React.createElement( TableContainer, null, React.createElement( Table, null, React.createElement( TableHead, null, React.createElement( GlobalAppGridRow, { className: 'hoverDisabled' }, React.createElement( GlobalAppGridCell, { align: 'left', className: 'width10' }, React.createElement( Typography, { variant: 'subtitle2' }, React.createElement(FormattedMessage, { id: 'words.level', defaultMessage: 'Level' }) ) ), React.createElement( GlobalAppGridCell, { align: 'left', className: 'width15' }, React.createElement( Typography, { variant: 'subtitle2' }, React.createElement(FormattedMessage, { id: 'words.timestamp', defaultMessage: 'Timestamp' }) ) ), React.createElement( GlobalAppGridCell, { align: 'left', className: 'width15' }, React.createElement( Typography, { variant: 'subtitle2' }, React.createElement(FormattedMessage, { id: 'words.thread', defaultMessage: 'Thread' }) ) ), showSiteColumn && React.createElement( GlobalAppGridCell, { align: 'left' }, React.createElement( Typography, { variant: 'subtitle2' }, React.createElement(FormattedMessage, { id: 'words.project', defaultMessage: 'Project' }) ) ), React.createElement( GlobalAppGridCell, { align: 'left', className: 'width70' }, React.createElement( Typography, { variant: 'subtitle2' }, React.createElement(FormattedMessage, { id: 'words.message', defaultMessage: 'Message' }) ) ), React.createElement( GlobalAppGridCell, { align: 'left', className: 'width10' }, React.createElement(FormattedMessage, { id: 'words.details', defaultMessage: 'Details' }) ) ) ), React.createElement( TableBody, null, logEvents.map((logEvent, i) => React.createElement( GlobalAppGridRow, { key: i, className: 'hoverDisabled' }, React.createElement(GlobalAppGridCell, { align: 'left', className: 'ellipsis' }, logEvent.level), React.createElement( GlobalAppGridCell, { align: 'left', className: 'ellipsis' }, new Intl.DateTimeFormat(localeBranch.localeCode, localeBranch.dateTimeFormatOptions).format( new Date(logEvent.timestamp) ) ), React.createElement(GlobalAppGridCell, { align: 'left', className: 'ellipsis' }, logEvent.thread), showSiteColumn && React.createElement( GlobalAppGridCell, { title: logEvent.site, align: 'left', className: 'ellipsis' }, logEvent.site.replace(/(.{30})..+/, '$1...') ), React.createElement( GlobalAppGridCell, { title: logEvent.message, align: 'left', className: 'ellipsis maxWidth300' }, logEvent.message ), React.createElement( GlobalAppGridCell, { align: 'left', className: 'action' }, React.createElement( IconButton, { onClick: () => onLogEventDetails(logEvent), size: 'large' }, React.createElement(VisibilityRoundedIcon, null) ) ) ) ) ) ) ); } export default LogConsoleGridUI;