Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions resources/js/components/actions/ConfirmableAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,38 @@ defineExpose({
v-if="confirming"
:title="action.title"
:danger="action.dangerous"
:submittable="action.runnable"
:buttonText="runButtonText"
:busy="running"
@confirm="confirmed"
@cancel="reset"
>
<Description
v-if="confirmationText"
:text="confirmationText"
:class="{ 'mb-4': warningText || showDirtyWarning || action.fields.length }"
<component
v-if="action.component"
:is="action.component"
/>

<div
v-if="warningText"
v-text="warningText"
class="text-red-600"
:class="{ 'mb-4': showDirtyWarning || action.fields.length }"
/>

<div
v-if="showDirtyWarning"
v-text="dirtyText"
class="text-red-600"
:class="{ 'mb-4': action.fields.length }"
/>
<template v-else>
<Description
v-if="confirmationText"
:text="confirmationText"
:class="{ 'mb-4': warningText || showDirtyWarning || action.fields.length }"
/>

<div
v-if="warningText"
v-text="warningText"
class="text-red-600"
:class="{ 'mb-4': showDirtyWarning || action.fields.length }"
/>

<div
v-if="showDirtyWarning"
v-text="dirtyText"
class="text-red-600"
:class="{ 'mb-4': action.fields.length }"
/>
</template>

<PublishContainer
v-if="action.fields.length"
Expand Down
7 changes: 6 additions & 1 deletion resources/js/components/modals/ConfirmationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const props = defineProps({
type: Boolean,
default: true,
},
submittable: {
type: Boolean,
default: true,
},
cancelText: {
type: String,
default: () => __('Cancel'),
Expand Down Expand Up @@ -72,7 +76,7 @@ function submit() {
<p>{{ __('Are you sure?') }}</p>
</slot>

<template #footer>
<template v-if="cancellable || submittable" #footer>
<div class="flex items-center justify-end space-x-3 pt-3 pb-1">
<ModalClose asChild>
<Button
Expand All @@ -83,6 +87,7 @@ function submit() {
/>
</ModalClose>
<Button
v-if="submittable"
type="submit"
:variant="danger ? 'danger' : 'primary'"
:disabled="disabled || busy"
Expand Down
14 changes: 14 additions & 0 deletions src/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ abstract class Action implements Arrayable
protected $dangerous = false;
protected $fields = [];
protected $context = [];
protected $runnable = true;
protected $component;

public function __construct()
{
Expand Down Expand Up @@ -96,6 +98,16 @@ public function icon(): string
return $this->icon ?? '';
}

public function component(): ?string
{
return $this->component;
}

public function runnable(): bool
{
return $this->runnable;
}

public function buttonText()
{
/** @translation */
Expand Down Expand Up @@ -135,6 +147,8 @@ public function toArray()
'handle' => $this->handle(),
'title' => $this->title(),
'icon' => $this->icon(),
'component' => $this->component(),
'runnable' => $this->runnable(),
'confirm' => $this->confirm,
'buttonText' => $this->buttonText(),
'confirmationText' => $this->confirmationText(),
Expand Down