UNPKG

@craftercms/studio-ui

Version:

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

107 lines (105 loc) 3.87 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 { FormattedMessage } from 'react-intl'; import DialogBody from '../DialogBody/DialogBody'; import DialogFooter from '../DialogFooter/DialogFooter'; import SecondaryButton from '../SecondaryButton'; import PrimaryButton from '../PrimaryButton'; import DeleteDialogUIBody from './DeleteDialogUIBody'; import { ApiResponseErrorState } from '../ApiResponseErrorState'; import { LoadingState } from '../LoadingState'; export function DeleteDialogUI(props) { const { items, childItems, dependentItems, error, submitError, isFetching, selectedItems, comment, onCommentChange, isDisabled, isSubmitting, onSubmit, onCloseButtonClick, isConfirmDeleteChecked, isCommentRequired, isSubmitButtonDisabled, onItemClicked, onSelectAllClicked, onConfirmDeleteChange, onEditDependantClick } = props; return React.createElement( React.Fragment, null, React.createElement( DialogBody, { minHeight: true }, error || submitError ? React.createElement(ApiResponseErrorState, { error: error ?? submitError }) : isFetching || (!childItems && !dependentItems) ? React.createElement(LoadingState, null) : React.createElement(DeleteDialogUIBody, { isDisabled: isDisabled, onItemClicked: onItemClicked, onSelectAllClicked: onSelectAllClicked, selectedItems: selectedItems, items: items, childItems: childItems, dependentItems: dependentItems, comment: comment, onCommentChange: onCommentChange, isCommentRequired: isCommentRequired, onConfirmDeleteChange: onConfirmDeleteChange, isConfirmDeleteChecked: isConfirmDeleteChecked, onEditDependantClick: onEditDependantClick }) ), React.createElement( DialogFooter, null, React.createElement( SecondaryButton, { onClick: onCloseButtonClick, disabled: isDisabled }, React.createElement(FormattedMessage, { id: 'words.cancel', defaultMessage: 'Cancel' }) ), React.createElement( PrimaryButton, { onClick: onSubmit, disabled: isSubmitButtonDisabled || isDisabled, loading: isSubmitting }, React.createElement(FormattedMessage, { id: 'words.delete', defaultMessage: 'Delete' }) ) ) ); } export default DeleteDialogUI;