Skip to content

[WEB-1501] chore: added primary variant to the alert modal #4664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2024
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
2 changes: 1 addition & 1 deletion web/components/api-token/delete-token-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const DeleteApiTokenModal: FC<Props> = (props) => {
<AlertModalCore
handleClose={handleClose}
handleSubmit={handleDeletion}
isDeleting={deleteLoading}
isSubmitting={deleteLoading}
isOpen={isOpen}
title="Delete API token"
content={
Expand Down
15 changes: 9 additions & 6 deletions web/components/core/modals/alert-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { AlertTriangle, LucideIcon } from "lucide-react";
import { AlertTriangle, Info, LucideIcon } from "lucide-react";
// ui
import { Button, TButtonVariant } from "@plane/ui";
// components
import { EModalPosition, EModalWidth, ModalCore } from "@/components/core";
// helpers
import { cn } from "@/helpers/common.helper";

export type TModalVariant = "danger";
export type TModalVariant = "danger" | "primary";

type Props = {
content: React.ReactNode | string;
handleClose: () => void;
handleSubmit: () => Promise<void>;
hideIcon?: boolean;
isDeleting: boolean;
isSubmitting: boolean;
isOpen: boolean;
position?: EModalPosition;
primaryButtonText?: {
Expand All @@ -28,14 +28,17 @@ type Props = {

const VARIANT_ICONS: Record<TModalVariant, LucideIcon> = {
danger: AlertTriangle,
primary: Info,
};

const BUTTON_VARIANTS: Record<TModalVariant, TButtonVariant> = {
danger: "danger",
primary: "primary",
};

const VARIANT_CLASSES: Record<TModalVariant, string> = {
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) => {
Expand All @@ -44,7 +47,7 @@ export const AlertModalCore: React.FC<Props> = (props) => {
handleClose,
handleSubmit,
hideIcon = false,
isDeleting,
isSubmitting,
isOpen,
position = EModalPosition.CENTER,
primaryButtonText = {
Expand Down Expand Up @@ -81,8 +84,8 @@ export const AlertModalCore: React.FC<Props> = (props) => {
<Button variant="neutral-primary" size="sm" onClick={handleClose}>
{secondaryButtonText}
</Button>
<Button variant={BUTTON_VARIANTS[variant]} size="sm" tabIndex={1} onClick={handleSubmit} loading={isDeleting}>
{isDeleting ? primaryButtonText.loading : primaryButtonText.default}
<Button variant={BUTTON_VARIANTS[variant]} size="sm" tabIndex={1} onClick={handleSubmit} loading={isSubmitting}>
{isSubmitting ? primaryButtonText.loading : primaryButtonText.default}
</Button>
</div>
</ModalCore>
Expand Down
2 changes: 1 addition & 1 deletion web/components/cycles/delete-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const CycleDeleteModal: React.FC<ICycleDelete> = observer((props) => {
<AlertModalCore
handleClose={handleClose}
handleSubmit={formSubmit}
isDeleting={loader}
isSubmitting={loader}
isOpen={isOpen}
title="Delete Cycle"
content={
Expand Down
2 changes: 1 addition & 1 deletion web/components/estimates/delete-estimate-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const DeleteEstimateModal: React.FC<Props> = observer((props) => {
<AlertModalCore
handleClose={onClose}
handleSubmit={handleEstimateDelete}
isDeleting={isDeleteLoading}
isSubmitting={isDeleteLoading}
isOpen={isOpen}
title="Delete Estimate"
content={
Expand Down
2 changes: 1 addition & 1 deletion web/components/inbox/modals/decline-issue-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const DeclineIssueModal: React.FC<Props> = (props) => {
<AlertModalCore
handleClose={handleClose}
handleSubmit={handleDecline}
isDeleting={isDeclining}
isSubmitting={isDeclining}
isOpen={isOpen}
title="Decline Issue"
content={
Expand Down
2 changes: 1 addition & 1 deletion web/components/inbox/modals/delete-issue-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const DeleteInboxIssueModal: React.FC<Props> = observer(({ isOpen, onClos
<AlertModalCore
handleClose={handleClose}
handleSubmit={handleDelete}
isDeleting={isDeleting}
isSubmitting={isDeleting}
isOpen={isOpen}
title="Delete Issue"
content={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const IssueAttachmentDeleteModal: FC<Props> = (props) => {
<AlertModalCore
handleClose={handleClose}
handleSubmit={() => handleDeletion(data.id)}
isDeleting={loader}
isSubmitting={loader}
isOpen={isOpen}
title="Delete attachment"
content={
Expand Down
2 changes: 1 addition & 1 deletion web/components/issues/delete-issue-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const DeleteIssueModal: React.FC<Props> = (props) => {
<AlertModalCore
handleClose={onClose}
handleSubmit={handleIssueDelete}
isDeleting={isDeleting}
isSubmitting={isDeleting}
isOpen={isOpen}
title="Delete Issue"
content={
Expand Down
2 changes: 1 addition & 1 deletion web/components/labels/delete-label-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const DeleteLabelModal: React.FC<Props> = observer((props) => {
<AlertModalCore
handleClose={handleClose}
handleSubmit={handleDeletion}
isDeleting={isDeleteLoading}
isSubmitting={isDeleteLoading}
isOpen={isOpen}
title="Delete Label"
content={
Expand Down
2 changes: 1 addition & 1 deletion web/components/modules/delete-module-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const DeleteModuleModal: React.FC<Props> = observer((props) => {
<AlertModalCore
handleClose={handleClose}
handleSubmit={handleDeletion}
isDeleting={isDeleteLoading}
isSubmitting={isDeleteLoading}
isOpen={isOpen}
title="Delete Module"
content={
Expand Down
2 changes: 1 addition & 1 deletion web/components/pages/modals/delete-page-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const DeletePageModal: React.FC<TConfirmPageDeletionProps> = observer((pr
<AlertModalCore
handleClose={handleClose}
handleSubmit={handleDelete}
isDeleting={isDeleting}
isSubmitting={isDeleting}
isOpen={isOpen}
title="Delete Page"
content={
Expand Down
2 changes: 1 addition & 1 deletion web/components/states/delete-state-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const DeleteStateModal: React.FC<Props> = observer((props) => {
<AlertModalCore
handleClose={handleClose}
handleSubmit={handleDeletion}
isDeleting={isDeleteLoading}
isSubmitting={isDeleteLoading}
isOpen={isOpen}
title="Delete State"
content={
Expand Down
2 changes: 1 addition & 1 deletion web/components/views/delete-view-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const DeleteProjectViewModal: React.FC<Props> = observer((props) => {
<AlertModalCore
handleClose={handleClose}
handleSubmit={handleDeleteView}
isDeleting={isDeleteLoading}
isSubmitting={isDeleteLoading}
isOpen={isOpen}
title="Delete View"
content={
Expand Down
2 changes: 1 addition & 1 deletion web/components/web-hooks/delete-webhook-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const DeleteWebhookModal: FC<IDeleteWebhook> = (props) => {
<AlertModalCore
handleClose={handleClose}
handleSubmit={handleDelete}
isDeleting={isDeleting}
isSubmitting={isDeleting}
isOpen={isOpen}
title="Delete webhook"
content={
Expand Down
2 changes: 1 addition & 1 deletion web/components/workspace/views/delete-view-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const DeleteGlobalViewModal: React.FC<Props> = observer((props) => {
<AlertModalCore
handleClose={handleClose}
handleSubmit={handleDeletion}
isDeleting={isDeleteLoading}
isSubmitting={isDeleteLoading}
isOpen={isOpen}
title="Delete View"
content={
Expand Down