Add the option to change the confirm and cancel button texts within the confirmation modals (#13966)

* Add button parameters to actions

* Add button states to confirmation store

* Set text of buttons if values are exist

* Pass stored values through to the modal

* Add missing duplicate text map

* Fix lint issues

---------

Co-authored-by: melohagan <101575380+melohagan@users.noreply.github.com>
This commit is contained in:
Conor Webb 2024-06-21 11:57:46 +01:00 committed by GitHub
parent f42d302f48
commit 9a375d6716
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 53 additions and 2 deletions

View File

@ -53,6 +53,12 @@
placeholder="Are you sure you want to delete?"
bind:value={parameters.confirmText}
/>
<Label small>Confirm Text</Label>
<Input placeholder="Confirm" bind:value={parameters.confirmButtonText} />
<Label small>Cancel Text</Label>
<Input placeholder="Cancel" bind:value={parameters.cancelButtonText} />
{/if}
</div>
</div>

View File

@ -83,6 +83,12 @@
placeholder="Are you sure you want to duplicate this row?"
bind:value={parameters.confirmText}
/>
<Label small>Confirm Text</Label>
<Input placeholder="Confirm" bind:value={parameters.confirmButtonText} />
<Label small>Cancel Text</Label>
<Input placeholder="Cancel" bind:value={parameters.cancelButtonText} />
{/if}
</div>

View File

@ -74,6 +74,18 @@
placeholder="Are you sure you want to execute this query?"
bind:value={parameters.confirmText}
/>
<Input
label="Confirm Text"
placeholder="Confirm"
bind:value={parameters.confirmButtonText}
/>
<Input
label="Cancel Text"
placeholder="Cancel"
bind:value={parameters.cancelButtonText}
/>
{/if}
{#if query?.parameters?.length > 0}

View File

@ -80,6 +80,12 @@
placeholder="Are you sure you want to save this row?"
bind:value={parameters.confirmText}
/>
<Label small>Confirm Text</Label>
<Input placeholder="Confirm" bind:value={parameters.confirmButtonText} />
<Label small>Cancel Text</Label>
<Input placeholder="Cancel" bind:value={parameters.cancelButtonText} />
{/if}
</div>

View File

@ -8,6 +8,8 @@
<ModalContent
title={$confirmationStore.title}
onConfirm={confirmationStore.actions.confirm}
confirmText={$confirmationStore.confirmButtonText}
cancelText={$confirmationStore.cancelButtonText}
>
{$confirmationStore.text}
</ModalContent>

View File

@ -4,6 +4,8 @@ const initialState = {
showConfirmation: false,
title: null,
text: null,
confirmButtonText: null,
cancelButtonText: null,
onConfirm: null,
onCancel: null,
}
@ -11,11 +13,20 @@ const initialState = {
const createConfirmationStore = () => {
const store = writable(initialState)
const showConfirmation = (title, text, onConfirm, onCancel) => {
const showConfirmation = (
title,
text,
onConfirm,
onCancel,
confirmButtonText,
cancelButtonText
) => {
store.set({
showConfirmation: true,
title,
text,
confirmButtonText,
cancelButtonText,
onConfirm,
onCancel,
})

View File

@ -522,6 +522,7 @@ const confirmTextMap = {
["Execute Query"]: "Are you sure you want to execute this query?",
["Trigger Automation"]: "Are you sure you want to trigger this automation?",
["Prompt User"]: "Are you sure you want to continue?",
["Duplicate Row"]: "Are you sure you want to duplicate this row?",
}
/**
@ -582,6 +583,11 @@ export const enrichButtonActions = (actions, context) => {
const defaultTitleText = action["##eventHandlerType"]
const customTitleText =
action.parameters?.customTitleText || defaultTitleText
const cancelButtonText =
action.parameters?.cancelButtonText || "Cancel"
const confirmButtonText =
action.parameters?.confirmButtonText || "Confirm"
confirmationStore.actions.showConfirmation(
customTitleText,
confirmText,
@ -612,7 +618,9 @@ export const enrichButtonActions = (actions, context) => {
},
() => {
resolve(false)
}
},
confirmButtonText,
cancelButtonText
)
})
}