@craftercms/studio-ui
Version:
Services, components, models & utils to build CrafterCMS authoring extensions.
145 lines (143 loc) • 5.3 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 DialogBody from '../DialogBody/DialogBody';
import { FormattedMessage } from 'react-intl';
import DialogFooter from '../DialogFooter/DialogFooter';
import SecondaryButton from '../SecondaryButton';
import PrimaryButton from '../PrimaryButton';
import React from 'react';
import PublishDialogContentUI from './PublishDialogContentUI';
import { ApiResponseErrorState } from '../ApiResponseErrorState';
import { LoadingState } from '../LoadingState';
import { EmptyState } from '../EmptyState';
export function PublishDialogUI(props) {
// region const { ... } = props
const {
items,
publishingTargets,
isFetching,
error,
published,
publishingTargetsStatus,
onPublishingChannelsFailRetry,
onCloseButtonClick,
handleSubmit,
isSubmitting,
submitDisabled,
state,
selectedItems,
onItemClicked,
dependencies,
onSelectAll,
onSelectAllSoftDependencies,
onClickShowAllDeps,
isRequestPublish,
showRequestApproval,
classes,
submitLabel,
mixedPublishingDates,
mixedPublishingTargets,
submissionCommentRequired,
onPublishingArgumentChange
} = props;
// endregion
return React.createElement(
React.Fragment,
null,
React.createElement(
DialogBody,
null,
error
? React.createElement(ApiResponseErrorState, { error: error })
: isFetching
? React.createElement(LoadingState, null)
: items && publishingTargets
? items.length
? React.createElement(PublishDialogContentUI, {
items: items,
publishingTargets: publishingTargets,
published: published,
selectedItems: selectedItems,
onItemClicked: onItemClicked,
dependencies: dependencies,
onSelectAll: onSelectAll,
onSelectAllSoftDependencies: onSelectAllSoftDependencies,
state: state,
isRequestPublish: isRequestPublish,
showRequestApproval: showRequestApproval,
publishingTargetsStatus: publishingTargetsStatus,
onPublishingChannelsFailRetry: onPublishingChannelsFailRetry,
mixedPublishingDates: mixedPublishingDates,
mixedPublishingTargets: mixedPublishingTargets,
submissionCommentRequired: submissionCommentRequired,
onPublishingArgumentChange: onPublishingArgumentChange,
isSubmitting: isSubmitting
})
: React.createElement(EmptyState, {
title: React.createElement(FormattedMessage, {
id: 'publishDialog.noItemsSelected',
defaultMessage: 'No items have been selected'
})
})
: React.createElement(React.Fragment, null)
),
React.createElement(
DialogFooter,
null,
published &&
React.createElement(
SecondaryButton,
{
color: 'primary',
onClick: onClickShowAllDeps,
className: classes.leftAlignedAction,
disabled: isSubmitting || state.fetchingDependencies,
loading: state.fetchingDependencies
},
React.createElement(FormattedMessage, {
id: 'publishDialog.showAllDependencies',
defaultMessage: 'Show All Dependencies'
})
),
React.createElement(
SecondaryButton,
{ onClick: onCloseButtonClick, disabled: isSubmitting },
React.createElement(FormattedMessage, { id: 'requestPublishDialog.cancel', defaultMessage: 'Cancel' })
),
React.createElement(
PrimaryButton,
{ onClick: handleSubmit, disabled: submitDisabled, loading: isSubmitting },
submitLabel
)
)
);
}
export default PublishDialogUI;