Skip to content

Commit

Permalink
Update modals (after rebase)
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Dec 5, 2024
1 parent 97fca6b commit f972fd5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Modal from 'rdmo/core/assets/js/components/Modal'

const PageHeadDeleteModal = ({ title, show, onClose, onSubmit }) => {
return (
<Modal title={title} show={show} submitText={gettext('Delete')} submitColor="danger"
<Modal title={title} show={show} submitLabel={gettext('Delete')} submitProps={{className: 'btn btn-danger'}}
onClose={onClose} onSubmit={onSubmit}>
<p>{gettext('You are about to permanently delete this tab.')}</p>
<p>{gettext('This includes all given answers for this tab on all pages, not just this one.')}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ const PageHeadFormModal = ({ title, show, initial, onClose, onSubmit }) => {
const ref = useRef(null)
const [inputValue, setInputValue] = useState('')
const [hasError, setHasError] = useState(false)
const submitText = isEmpty(initial) ? gettext('Create') : gettext('Update')
const submitColor = isEmpty(initial) ? 'success' : 'primary'
const submitLabel = isEmpty(initial) ? gettext('Create') : gettext('Update')
const submitProps = {
className: classNames('btn', {
'btn-success': isEmpty(initial),
'btn-primary': !isEmpty(initial),
})
}

const handleSubmit = () => {
if (isEmpty(inputValue) && !isNil(initial)) {
Expand Down Expand Up @@ -41,7 +46,7 @@ const PageHeadFormModal = ({ title, show, initial, onClose, onSubmit }) => {
useFocusEffect(ref, show)

return (
<Modal title={title} show={show} submitText={submitText} submitColor={submitColor}
<Modal title={title} show={show} submitLabel={submitLabel} submitProps={submitProps}
onClose={onClose} onSubmit={handleSubmit} disableSubmit={hasError}>
{
isNil(initial) ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Modal from 'rdmo/core/assets/js/components/Modal'

const QuestionSetDeleteModal = ({ title, show, onClose, onSubmit }) => {
return (
<Modal title={title} show={show} submitText={gettext('Delete')} submitColor="danger"
<Modal title={title} show={show} submitLabel={gettext('Delete')} submitProps={{className: 'btn btn-danger'}}
onClose={onClose} onSubmit={onSubmit}>
<p>{gettext('You are about to permanently delete this block.')}</p>
<p className="text-danger">{gettext('This action cannot be undone!')}</p>
Expand Down

0 comments on commit f972fd5

Please sign in to comment.