@craftercms/studio-ui
Version:
Services, components, models & utils to build CrafterCMS authoring extensions.
85 lines (83 loc) • 3.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-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 ListItem from '@mui/material/ListItem';
import ListItemAvatar from '@mui/material/ListItemAvatar';
import PublishingStatusAvatar from '../PublishingStatusAvatar';
import ListItemText from '@mui/material/ListItemText';
import Skeleton from '@mui/material/Skeleton';
import * as React from 'react';
import { useIntl } from 'react-intl';
import { getPublishingStatusMessage, publishingStatusMessages } from './utils';
export function PublishingStatusDisplay(props) {
const { isFetching, status, enabled, lockOwner, lockTTL } = props;
const { formatMessage } = useIntl();
return React.createElement(
React.Fragment,
null,
React.createElement(
ListItem,
{ component: 'div' },
React.createElement(
ListItemAvatar,
null,
React.createElement(PublishingStatusAvatar, { enabled: enabled, status: isFetching ? null : status })
),
React.createElement(ListItemText, {
primary: isFetching ? React.createElement(Skeleton, null) : getPublishingStatusMessage(props, formatMessage),
secondary: isFetching
? React.createElement(Skeleton, null)
: React.createElement(
React.Fragment,
null,
lockOwner &&
React.createElement(
React.Fragment,
null,
formatMessage(publishingStatusMessages.lockOwner, { lockOwner }),
React.createElement('br', null)
),
lockTTL &&
React.createElement(
React.Fragment,
null,
formatMessage(publishingStatusMessages.lockTTL, { lockTTL }),
React.createElement('br', null)
),
status === 'readyWithErrors' &&
formatMessage({
defaultMessage: 'Last publish completed with errors, please see the logs for more information.'
})
)
})
)
);
}
export default PublishingStatusDisplay;