From a4115c84d4e66abb753f9fc9d0a60aea8b69c2b7 Mon Sep 17 00:00:00 2001 From: Dima Grossman Date: Mon, 2 Dec 2024 23:13:12 +0200 Subject: [PATCH] feat(dashboard): add button loading state prop (#7191) --- .../src/components/confirmation-modal.tsx | 2 +- .../src/components/create-workflow-button.tsx | 2 +- .../edit-bridge-url-button.tsx | 1 + .../src/components/primitives/button.tsx | 27 +++++++++++++++++-- .../test-workflow/test-workflow-tabs.tsx | 6 ++--- .../src/pages/usecase-select-page.tsx | 4 +-- apps/dashboard/tailwind.config.js | 8 +++++- 7 files changed, 39 insertions(+), 11 deletions(-) diff --git a/apps/dashboard/src/components/confirmation-modal.tsx b/apps/dashboard/src/components/confirmation-modal.tsx index b3c5a34a490..7ad1120a058 100644 --- a/apps/dashboard/src/components/confirmation-modal.tsx +++ b/apps/dashboard/src/components/confirmation-modal.tsx @@ -53,7 +53,7 @@ export const ConfirmationModal = ({ - diff --git a/apps/dashboard/src/components/create-workflow-button.tsx b/apps/dashboard/src/components/create-workflow-button.tsx index 1fedb2ce178..5ca61fe9681 100644 --- a/apps/dashboard/src/components/create-workflow-button.tsx +++ b/apps/dashboard/src/components/create-workflow-button.tsx @@ -188,7 +188,7 @@ export const CreateWorkflowButton = (props: CreateWorkflowButtonProps) => { - diff --git a/apps/dashboard/src/components/header-navigation/edit-bridge-url-button.tsx b/apps/dashboard/src/components/header-navigation/edit-bridge-url-button.tsx index e2ec8072884..8715026d995 100644 --- a/apps/dashboard/src/components/header-navigation/edit-bridge-url-button.tsx +++ b/apps/dashboard/src/components/header-navigation/edit-bridge-url-button.tsx @@ -109,6 +109,7 @@ export const EditBridgeUrlButton = () => { type="submit" variant="primary" size="xs" + isLoading={isUpdatingBridgeUrl} disabled={!isDirty || isValidatingBridgeUrl || isUpdatingBridgeUrl} > Update endpoint diff --git a/apps/dashboard/src/components/primitives/button.tsx b/apps/dashboard/src/components/primitives/button.tsx index e5bf280f616..632308afbf3 100644 --- a/apps/dashboard/src/components/primitives/button.tsx +++ b/apps/dashboard/src/components/primitives/button.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { Slot } from '@radix-ui/react-slot'; import { cva, type VariantProps } from 'class-variance-authority'; import { cn } from '@/utils/ui'; +import { RiLoader4Line } from 'react-icons/ri'; export const buttonVariants = cva( `relative isolate inline-flex items-center justify-center whitespace-nowrap rounded-lg gap-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50`, @@ -43,12 +44,34 @@ export interface ButtonProps extends React.ButtonHTMLAttributes, VariantProps { asChild?: boolean; + isLoading?: boolean; } const Button = React.forwardRef( - ({ className, variant, size, asChild = false, ...props }, ref) => { + ({ className, variant, size, asChild = false, isLoading = false, children, disabled, ...props }, ref) => { const Comp = asChild ? Slot : 'button'; - return ; + return ( + + + {children} + + {isLoading && ( +
+ +
+ )} +
+ ); } ); Button.displayName = 'Button'; diff --git a/apps/dashboard/src/components/workflow-editor/test-workflow/test-workflow-tabs.tsx b/apps/dashboard/src/components/workflow-editor/test-workflow/test-workflow-tabs.tsx index 3ac1458f725..df8b490e2c9 100644 --- a/apps/dashboard/src/components/workflow-editor/test-workflow/test-workflow-tabs.tsx +++ b/apps/dashboard/src/components/workflow-editor/test-workflow/test-workflow-tabs.tsx @@ -1,6 +1,6 @@ import { useMemo } from 'react'; import { Link, useParams } from 'react-router-dom'; -import { RiPlayCircleLine, RiProgress1Fill } from 'react-icons/ri'; +import { RiPlayCircleLine } from 'react-icons/ri'; import { useForm } from 'react-hook-form'; // eslint-disable-next-line // @ts-ignore @@ -127,8 +127,8 @@ export const TestWorkflowTabs = ({ testData }: { testData: WorkflowTestDataRespo
-
diff --git a/apps/dashboard/src/pages/usecase-select-page.tsx b/apps/dashboard/src/pages/usecase-select-page.tsx index 30f44a99ef9..89119615a52 100644 --- a/apps/dashboard/src/pages/usecase-select-page.tsx +++ b/apps/dashboard/src/pages/usecase-select-page.tsx @@ -8,7 +8,6 @@ import { useNavigate } from 'react-router-dom'; import { OnboardingArrowLeft } from '../components/icons/onboarding-arrow-left'; import { updateClerkOrgMetadata } from '../api/organization'; import { ChannelTypeEnum } from '@novu/shared'; -import { RiLoader2Line } from 'react-icons/ri'; import { PageMeta } from '../components/page-meta'; import { useTelemetry } from '../hooks'; import { TelemetryEvent } from '../utils/telemetry'; @@ -79,9 +78,8 @@ export function UsecaseSelectPage() { />
-