@craftercms/studio-ui
Version:
Services, components, models & utils to build CrafterCMS authoring extensions.
111 lines (109 loc) • 4.13 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 { FormattedMessage, useIntl } from 'react-intl';
import translations from './translations';
import React from 'react';
import List from '@mui/material/List';
import { DraggablePanelListItem } from '../DraggablePanelListItem/DraggablePanelListItem';
import EmptyState from '../EmptyState/EmptyState';
import { useComponentsPanelUI } from './styles';
import FormHelperText from '@mui/material/FormHelperText';
import Pagination from '../Pagination';
import HourglassEmptyRounded from '@mui/icons-material/HourglassEmptyRounded';
import Alert from '@mui/material/Alert';
export function PreviewBrowseComponentsPanelUI(props) {
const {
awaitingGuestCheckIn,
items,
onPageChanged,
onDragStart,
onDragEnd,
onRowsPerPageChange,
count,
pageNumber,
limit
} = props;
const { formatMessage } = useIntl();
const { classes } = useComponentsPanelUI();
return awaitingGuestCheckIn
? React.createElement(
Alert,
{
severity: 'info',
variant: 'outlined',
icon: React.createElement(HourglassEmptyRounded, null),
sx: { border: 0 }
},
React.createElement(FormattedMessage, { defaultMessage: 'Waiting for the preview application to load.' })
)
: React.createElement(
React.Fragment,
null,
React.createElement(Pagination, {
count: count,
rowsPerPage: limit,
page: pageNumber,
onPageChange: (e, page) => onPageChanged(page * limit),
onRowsPerPageChange: onRowsPerPageChange
}),
React.createElement(
'div',
{ className: classes.browsePanelWrapper },
React.createElement(
List,
null,
items.map((item) =>
React.createElement(DraggablePanelListItem, {
key: item.craftercms.id,
primaryText: item.craftercms.label,
avatarColorBase: item.craftercms.contentTypeId,
onDragStart: () => onDragStart(item),
onDragEnd: onDragEnd
})
)
),
count === 0 &&
React.createElement(EmptyState, {
title: formatMessage(translations.noResults),
classes: { image: classes.noResultsImage, title: classes.noResultsTitle }
}),
React.createElement(
FormHelperText,
{ className: classes.helperTextWrapper },
React.createElement(FormattedMessage, {
id: 'previewBrowseComponentsPanel.sharedComponentsHelperText',
defaultMessage: 'Only shared components are shown here'
})
)
)
);
}
export default PreviewBrowseComponentsPanelUI;