mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: added primary variant to the alert modal (#4664)
This commit is contained in:
parent
830f0861c1
commit
608e193c36
@ -69,7 +69,7 @@ export const DeleteApiTokenModal: FC<Props> = (props) => {
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
handleSubmit={handleDeletion}
|
handleSubmit={handleDeletion}
|
||||||
isDeleting={deleteLoading}
|
isSubmitting={deleteLoading}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete API token"
|
title="Delete API token"
|
||||||
content={
|
content={
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AlertTriangle, LucideIcon } from "lucide-react";
|
import { AlertTriangle, Info, LucideIcon } from "lucide-react";
|
||||||
// ui
|
// ui
|
||||||
import { Button, TButtonVariant } from "@plane/ui";
|
import { Button, TButtonVariant } from "@plane/ui";
|
||||||
// components
|
// components
|
||||||
@ -6,14 +6,14 @@ import { EModalPosition, EModalWidth, ModalCore } from "@/components/core";
|
|||||||
// helpers
|
// helpers
|
||||||
import { cn } from "@/helpers/common.helper";
|
import { cn } from "@/helpers/common.helper";
|
||||||
|
|
||||||
export type TModalVariant = "danger";
|
export type TModalVariant = "danger" | "primary";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
content: React.ReactNode | string;
|
content: React.ReactNode | string;
|
||||||
handleClose: () => void;
|
handleClose: () => void;
|
||||||
handleSubmit: () => Promise<void>;
|
handleSubmit: () => Promise<void>;
|
||||||
hideIcon?: boolean;
|
hideIcon?: boolean;
|
||||||
isDeleting: boolean;
|
isSubmitting: boolean;
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
position?: EModalPosition;
|
position?: EModalPosition;
|
||||||
primaryButtonText?: {
|
primaryButtonText?: {
|
||||||
@ -28,14 +28,17 @@ type Props = {
|
|||||||
|
|
||||||
const VARIANT_ICONS: Record<TModalVariant, LucideIcon> = {
|
const VARIANT_ICONS: Record<TModalVariant, LucideIcon> = {
|
||||||
danger: AlertTriangle,
|
danger: AlertTriangle,
|
||||||
|
primary: Info,
|
||||||
};
|
};
|
||||||
|
|
||||||
const BUTTON_VARIANTS: Record<TModalVariant, TButtonVariant> = {
|
const BUTTON_VARIANTS: Record<TModalVariant, TButtonVariant> = {
|
||||||
danger: "danger",
|
danger: "danger",
|
||||||
|
primary: "primary",
|
||||||
};
|
};
|
||||||
|
|
||||||
const VARIANT_CLASSES: Record<TModalVariant, string> = {
|
const VARIANT_CLASSES: Record<TModalVariant, string> = {
|
||||||
danger: "bg-red-500/20 text-red-500",
|
danger: "bg-red-500/20 text-red-500",
|
||||||
|
primary: "bg-custom-primary-100/20 text-custom-primary-100",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AlertModalCore: React.FC<Props> = (props) => {
|
export const AlertModalCore: React.FC<Props> = (props) => {
|
||||||
@ -44,7 +47,7 @@ export const AlertModalCore: React.FC<Props> = (props) => {
|
|||||||
handleClose,
|
handleClose,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
hideIcon = false,
|
hideIcon = false,
|
||||||
isDeleting,
|
isSubmitting,
|
||||||
isOpen,
|
isOpen,
|
||||||
position = EModalPosition.CENTER,
|
position = EModalPosition.CENTER,
|
||||||
primaryButtonText = {
|
primaryButtonText = {
|
||||||
@ -81,8 +84,8 @@ export const AlertModalCore: React.FC<Props> = (props) => {
|
|||||||
<Button variant="neutral-primary" size="sm" onClick={handleClose}>
|
<Button variant="neutral-primary" size="sm" onClick={handleClose}>
|
||||||
{secondaryButtonText}
|
{secondaryButtonText}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant={BUTTON_VARIANTS[variant]} size="sm" tabIndex={1} onClick={handleSubmit} loading={isDeleting}>
|
<Button variant={BUTTON_VARIANTS[variant]} size="sm" tabIndex={1} onClick={handleSubmit} loading={isSubmitting}>
|
||||||
{isDeleting ? primaryButtonText.loading : primaryButtonText.default}
|
{isSubmitting ? primaryButtonText.loading : primaryButtonText.default}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</ModalCore>
|
</ModalCore>
|
||||||
|
@ -73,7 +73,7 @@ export const CycleDeleteModal: React.FC<ICycleDelete> = observer((props) => {
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
handleSubmit={formSubmit}
|
handleSubmit={formSubmit}
|
||||||
isDeleting={loader}
|
isSubmitting={loader}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete Cycle"
|
title="Delete Cycle"
|
||||||
content={
|
content={
|
||||||
|
@ -64,7 +64,7 @@ export const DeleteEstimateModal: React.FC<Props> = observer((props) => {
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={onClose}
|
handleClose={onClose}
|
||||||
handleSubmit={handleEstimateDelete}
|
handleSubmit={handleEstimateDelete}
|
||||||
isDeleting={isDeleteLoading}
|
isSubmitting={isDeleteLoading}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete Estimate"
|
title="Delete Estimate"
|
||||||
content={
|
content={
|
||||||
|
@ -36,7 +36,7 @@ export const DeclineIssueModal: React.FC<Props> = (props) => {
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
handleSubmit={handleDecline}
|
handleSubmit={handleDecline}
|
||||||
isDeleting={isDeclining}
|
isSubmitting={isDeclining}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Decline Issue"
|
title="Decline Issue"
|
||||||
content={
|
content={
|
||||||
|
@ -36,7 +36,7 @@ export const DeleteInboxIssueModal: React.FC<Props> = observer(({ isOpen, onClos
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
handleSubmit={handleDelete}
|
handleSubmit={handleDelete}
|
||||||
isDeleting={isDeleting}
|
isSubmitting={isDeleting}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete Issue"
|
title="Delete Issue"
|
||||||
content={
|
content={
|
||||||
|
@ -35,7 +35,7 @@ export const IssueAttachmentDeleteModal: FC<Props> = (props) => {
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
handleSubmit={() => handleDeletion(data.id)}
|
handleSubmit={() => handleDeletion(data.id)}
|
||||||
isDeleting={loader}
|
isSubmitting={loader}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete attachment"
|
title="Delete attachment"
|
||||||
content={
|
content={
|
||||||
|
@ -66,7 +66,7 @@ export const DeleteIssueModal: React.FC<Props> = (props) => {
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={onClose}
|
handleClose={onClose}
|
||||||
handleSubmit={handleIssueDelete}
|
handleSubmit={handleIssueDelete}
|
||||||
isDeleting={isDeleting}
|
isSubmitting={isDeleting}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete Issue"
|
title="Delete Issue"
|
||||||
content={
|
content={
|
||||||
|
@ -56,7 +56,7 @@ export const DeleteLabelModal: React.FC<Props> = observer((props) => {
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
handleSubmit={handleDeletion}
|
handleSubmit={handleDeletion}
|
||||||
isDeleting={isDeleteLoading}
|
isSubmitting={isDeleteLoading}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete Label"
|
title="Delete Label"
|
||||||
content={
|
content={
|
||||||
|
@ -73,7 +73,7 @@ export const DeleteModuleModal: React.FC<Props> = observer((props) => {
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
handleSubmit={handleDeletion}
|
handleSubmit={handleDeletion}
|
||||||
isDeleting={isDeleteLoading}
|
isSubmitting={isDeleteLoading}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete Module"
|
title="Delete Module"
|
||||||
content={
|
content={
|
||||||
|
@ -74,7 +74,7 @@ export const DeletePageModal: React.FC<TConfirmPageDeletionProps> = observer((pr
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
handleSubmit={handleDelete}
|
handleSubmit={handleDelete}
|
||||||
isDeleting={isDeleting}
|
isSubmitting={isDeleting}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete Page"
|
title="Delete Page"
|
||||||
content={
|
content={
|
||||||
|
@ -81,7 +81,7 @@ export const DeleteStateModal: React.FC<Props> = observer((props) => {
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
handleSubmit={handleDeletion}
|
handleSubmit={handleDeletion}
|
||||||
isDeleting={isDeleteLoading}
|
isSubmitting={isDeleteLoading}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete State"
|
title="Delete State"
|
||||||
content={
|
content={
|
||||||
|
@ -62,7 +62,7 @@ export const DeleteProjectViewModal: React.FC<Props> = observer((props) => {
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
handleSubmit={handleDeleteView}
|
handleSubmit={handleDeleteView}
|
||||||
isDeleting={isDeleteLoading}
|
isSubmitting={isDeleteLoading}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete View"
|
title="Delete View"
|
||||||
content={
|
content={
|
||||||
|
@ -55,7 +55,7 @@ export const DeleteWebhookModal: FC<IDeleteWebhook> = (props) => {
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
handleSubmit={handleDelete}
|
handleSubmit={handleDelete}
|
||||||
isDeleting={isDeleting}
|
isSubmitting={isDeleting}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete webhook"
|
title="Delete webhook"
|
||||||
content={
|
content={
|
||||||
|
@ -67,7 +67,7 @@ export const DeleteGlobalViewModal: React.FC<Props> = observer((props) => {
|
|||||||
<AlertModalCore
|
<AlertModalCore
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
handleSubmit={handleDeletion}
|
handleSubmit={handleDeletion}
|
||||||
isDeleting={isDeleteLoading}
|
isSubmitting={isDeleteLoading}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
title="Delete View"
|
title="Delete View"
|
||||||
content={
|
content={
|
||||||
|
Loading…
Reference in New Issue
Block a user