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:
parent
f42d302f48
commit
9a375d6716
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
<ModalContent
|
||||
title={$confirmationStore.title}
|
||||
onConfirm={confirmationStore.actions.confirm}
|
||||
confirmText={$confirmationStore.confirmButtonText}
|
||||
cancelText={$confirmationStore.cancelButtonText}
|
||||
>
|
||||
{$confirmationStore.text}
|
||||
</ModalContent>
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
|
|
|
@ -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
|
||||
)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue