Fixed confirmation modal
This commit is contained in:
parent
1f18b20c90
commit
db18d98325
5 changed files with 17 additions and 16 deletions
|
|
@ -29,6 +29,7 @@ function ConfirmationModal({
|
||||||
cancelText,
|
cancelText,
|
||||||
confirmationText,
|
confirmationText,
|
||||||
children,
|
children,
|
||||||
|
destructive = false,
|
||||||
icon,
|
icon,
|
||||||
data,
|
data,
|
||||||
index,
|
index,
|
||||||
|
|
@ -56,9 +57,9 @@ function ConfirmationModal({
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseModal size={size ?? "x-small"} open={modalOpen} setOpen={setModalOpen}>
|
<BaseModal size={size} open={modalOpen} setOpen={setModalOpen}>
|
||||||
<BaseModal.Trigger asChild={asChild}>{triggerChild}</BaseModal.Trigger>
|
<BaseModal.Trigger asChild={asChild}>{triggerChild}</BaseModal.Trigger>
|
||||||
<BaseModal.Header description={titleHeader}>
|
<BaseModal.Header description={titleHeader ?? null}>
|
||||||
<span className="pr-2">{title}</span>
|
<span className="pr-2">{title}</span>
|
||||||
<Icon
|
<Icon
|
||||||
name="icon"
|
name="icon"
|
||||||
|
|
@ -67,7 +68,7 @@ function ConfirmationModal({
|
||||||
/>
|
/>
|
||||||
</BaseModal.Header>
|
</BaseModal.Header>
|
||||||
<BaseModal.Content>
|
<BaseModal.Content>
|
||||||
{modalContentTitle != "" && (
|
{modalContentTitle && modalContentTitle != "" && (
|
||||||
<>
|
<>
|
||||||
<strong>{modalContentTitle}</strong>
|
<strong>{modalContentTitle}</strong>
|
||||||
<br></br>
|
<br></br>
|
||||||
|
|
@ -78,7 +79,8 @@ function ConfirmationModal({
|
||||||
|
|
||||||
<BaseModal.Footer>
|
<BaseModal.Footer>
|
||||||
<Button
|
<Button
|
||||||
className="ml-3 mt-5"
|
className="ml-3"
|
||||||
|
variant={destructive ? "destructive" : "default"}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setModalOpen(false);
|
setModalOpen(false);
|
||||||
onConfirm(index, data);
|
onConfirm(index, data);
|
||||||
|
|
@ -88,7 +90,7 @@ function ConfirmationModal({
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className="mt-5"
|
className=""
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (onCancel) onCancel();
|
if (onCancel) onCancel();
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ export default function DeleteConfirmationModal({
|
||||||
</span>
|
</span>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<DialogClose>
|
<DialogClose>
|
||||||
<Button className="mr-3">Cancel</Button>
|
<Button className="mr-3" variant="outline">Cancel</Button>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ function BaseModal({
|
||||||
switch (size) {
|
switch (size) {
|
||||||
case "x-small":
|
case "x-small":
|
||||||
minWidth = "min-w-[20vw]";
|
minWidth = "min-w-[20vw]";
|
||||||
height = "h-[10vh]";
|
height = " ";
|
||||||
break;
|
break;
|
||||||
case "smaller":
|
case "smaller":
|
||||||
minWidth = "min-w-[40vw]";
|
minWidth = "min-w-[40vw]";
|
||||||
|
|
@ -150,7 +150,7 @@ function BaseModal({
|
||||||
<div className="truncate-doubleline word-break-break-word">
|
<div className="truncate-doubleline word-break-break-word">
|
||||||
{headerChild}
|
{headerChild}
|
||||||
</div>
|
</div>
|
||||||
<div className={`mt-2 flex flex-col ${height!} w-full `}>
|
<div className={`flex flex-col ${height!} w-full `}>
|
||||||
{ContentChild}
|
{ContentChild}
|
||||||
</div>
|
</div>
|
||||||
{ContentFooter && (
|
{ContentFooter && (
|
||||||
|
|
|
||||||
|
|
@ -278,11 +278,10 @@ export default function NodeToolbarComponent({
|
||||||
<ConfirmationModal
|
<ConfirmationModal
|
||||||
asChild
|
asChild
|
||||||
open={showOverrideModal}
|
open={showOverrideModal}
|
||||||
title={`Replace ${data.node?.display_name}`}
|
title={`Replace`}
|
||||||
titleHeader={`Please, confirm your save actions`}
|
cancelText="Create New"
|
||||||
modalContentTitle="Attention!"
|
|
||||||
cancelText="New"
|
|
||||||
confirmationText="Replace"
|
confirmationText="Replace"
|
||||||
|
size={"x-small"}
|
||||||
icon={"SaveAll"}
|
icon={"SaveAll"}
|
||||||
index={6}
|
index={6}
|
||||||
onConfirm={(index, user) => {
|
onConfirm={(index, user) => {
|
||||||
|
|
@ -293,8 +292,7 @@ export default function NodeToolbarComponent({
|
||||||
>
|
>
|
||||||
<ConfirmationModal.Content>
|
<ConfirmationModal.Content>
|
||||||
<span>
|
<span>
|
||||||
It seems {data.node?.display_name} already exists. Replacing it
|
It seems {data.node?.display_name} already exists. Do you want to replace it with the current or create a new one?
|
||||||
will switch the current component. Proceed with replacement?
|
|
||||||
</span>
|
</span>
|
||||||
</ConfirmationModal.Content>
|
</ConfirmationModal.Content>
|
||||||
<ConfirmationModal.Trigger>
|
<ConfirmationModal.Trigger>
|
||||||
|
|
|
||||||
|
|
@ -286,9 +286,10 @@ export type PaginatorComponentType = {
|
||||||
export type ConfirmationModalType = {
|
export type ConfirmationModalType = {
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
title: string;
|
title: string;
|
||||||
titleHeader: string;
|
titleHeader?: string;
|
||||||
asChild?: boolean;
|
asChild?: boolean;
|
||||||
modalContentTitle: string;
|
destructive?: boolean;
|
||||||
|
modalContentTitle?: string;
|
||||||
cancelText: string;
|
cancelText: string;
|
||||||
confirmationText: string;
|
confirmationText: string;
|
||||||
children: [
|
children: [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue