Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Confirm before "Update keyword stats" spends credits (EVE-287) (#705)
Carter Smith4f835577c107
diff --git a/src/client/components/ConfirmDialog.tsx b/src/client/components/ConfirmDialog.tsxnew file mode 100644index 00000000..c07a4481--- /dev/null+++ b/src/client/components/ConfirmDialog.tsx@@ -0,0 +1,47 @@+import type { ReactNode } from "react";+import { FormDialog } from "@/client/components/FormDialog";++/** Asks before an action that cannot be undone, such as one that spends credits. */+export function ConfirmDialog({+ title,+ confirmLabel,+ onConfirm,+ onClose,+ children,+}: {+ title: string;+ confirmLabel: string;+ onConfirm: () => void;+ onClose: () => void;+ children: ReactNode;+}) {+ return (+ <FormDialog+ title={title}+ onClose={onClose}+ actions={+ <>+ <button+ type="button"+ className="btn btn-ghost btn-sm"+ onClick={onClose}+ >+ Cancel+ </button>+ <button+ type="button"+ className="btn btn-primary btn-sm"+ onClick={() => {+ onClose();+ onConfirm();+ }}+ >+ {confirmLabel}+ </button>+ </>+ }+ >+ <p className="text-sm text-base-content/70">{children}</p>+ </FormDialog>+ );+}diff --git a/src/client/features/ai-search/PromptExplorerPage.tsx b/src/client/features/ai-search/PromptExplorerPage.tsxindex 0ce70271..0b19a519 100644--- a/src/client/features/ai-search/PromptExplorerPage.tsx+++ b/src/client/features/ai-search/PromptExplorerPage.tsx@@ -159,6 +159,10 @@ export function PromptExplorerPage({ projectId, urlState, onSubmit }: Props) {);return;}+ if (form.models.length === 0) {+ setValidationError("Select at least one model");+ return;+ }setValidationError(null);onSubmit({...form,diff --git a/src/client/features/rank-tracking/RankTrackingDomainDetail.tsx b/src/client/features/rank-tracking/RankTrackingDomainDetail.tsxindex 462e0136..89439995 100644--- a/src/client/features/rank-tracking/RankTrackingDomainDetail.tsx+++ b/src/client/features/rank-tracking/RankTrackingDomainDetail.tsx@@ -167,6 +167,7 @@ export function RankTrackingDomainDetail({const rows = resultsData?.rows;const run = resultsData?.run;+ const trackedKeywordCount = costEstimate?.keywordCount ?? rows?.length ?? 0;const hasBothDevices = config.devices === "both";const { showDesktop, showMobile } = deviceVisibility(config.devices,@@ -296,11 +297,11 @@ export function RankTrackingDomainDetail({toast.success("Keywords copied to clipboard");}}onCheckNow={() => {- const count = costEstimate?.keywordCount ?? rows?.length ?? 0;- if (count > 0) requestCheck(count);+ if (trackedKeywordCount > 0) requestCheck(trackedKeywordCount);}}onRefreshMetrics={refreshMetrics}metricsRefreshing={metricsRefreshing}+ trackedKeywordCount={trackedKeywordCount}checkBusy={isBusy}checkDisabled={planStatus !== "paid"}hasData={filtered.length > 0}diff --git a/src/client/features/rank-tracking/RankTrackingTableToolbar.tsx b/src/client/features/rank-tracking/RankTrackingTableToolbar.tsxindex efbcecbe..1576aa01 100644--- a/src/client/features/rank-tracking/RankTrackingTableToolbar.tsx+++ b/src/client/features/rank-tracking/RankTrackingTableToolbar.tsx@@ -18,6 +18,7 @@ export function RankTrackingTableToolbar({onCheckNow,onRefreshMetrics,metricsRefreshing,+ trackedKeywordCount,checkBusy,checkDisabled,hasData,@@ -40,6 +41,7 @@ export function RankTrackingTableToolbar({onCheckNow: () => void;onRefreshMetrics: () => void;metricsRefreshing: boolean;+ trackedKeywordCount: number;checkBusy: boolean;checkDisabled: boolean;hasData: boolean;@@ -120,6 +122,7 @@ export function RankTrackingTableToolbar({checkDisabled={checkDisabled}onRefreshMetrics={onRefreshMetrics}metricsRefreshing={metricsRefreshing}+ trackedKeywordCount={trackedKeywordCount}hasData={hasData}/></div>diff --git a/src/client/features/rank-tracking/ToolbarMenus.tsx b/src/client/features/rank-tracking/ToolbarMenus.tsxindex 41ab74f9..441fdd4f 100644--- a/src/client/features/rank-tracking/ToolbarMenus.tsx+++ b/src/client/features/rank-tracking/ToolbarMenus.tsx@@ -9,6 +9,7 @@ import {RefreshCw,Sheet,} from "lucide-react";+import { ConfirmDialog } from "@/client/components/ConfirmDialog";function ToolbarMenu({label,@@ -91,6 +92,7 @@ export function MoreMenu({checkDisabled,onRefreshMetrics,metricsRefreshing,+ trackedKeywordCount,hasData,}: {onCheckNow: () => void;@@ -98,34 +100,51 @@ export function MoreMenu({checkDisabled: boolean;onRefreshMetrics: () => void;metricsRefreshing: boolean;+ trackedKeywordCount: number;hasData: boolean;}) {+ const [confirmingRefresh, setConfirmingRefresh] = useState(false);return (- <ToolbarMenu- icon={<MoreHorizontal className="size-4" />}- title="More actions"- >- {!checkDisabled && (+ <>+ <ToolbarMenu+ icon={<MoreHorizontal className="size-4" />}+ title="More actions"+ >+ {!checkDisabled && (+ <MenuItem+ icon={<Play className="size-3.5" />}+ label={checkBusy ? "Running..." : "Check rankings"}+ description="Fetch current Google positions"+ onClick={onCheckNow}+ disabled={checkBusy}+ />+ )}<MenuItem- icon={<Play className="size-3.5" />}- label={checkBusy ? "Running..." : "Check rankings"}- description="Fetch current Google positions"- onClick={onCheckNow}- disabled={checkBusy}+ icon={+ <RefreshCw+ className={`size-3.5 ${metricsRefreshing ? "animate-spin" : ""}`}+ />+ }+ label={metricsRefreshing ? "Refreshing..." : "Update keyword stats"}+ description="Volume, difficulty & CPC — not rankings"+ onClick={() => setConfirmingRefresh(true)}+ disabled={metricsRefreshing || !hasData}/>- )}- <MenuItem- icon={- <RefreshCw- className={`size-3.5 ${metricsRefreshing ? "animate-spin" : ""}`}- />- }- label={metricsRefreshing ? "Refreshing..." : "Update keyword stats"}- description="Volume, difficulty & CPC — not rankings"- onClick={onRefreshMetrics}- disabled={metricsRefreshing || !hasData}- />- </ToolbarMenu>+ </ToolbarMenu>+ {confirmingRefresh ? (+ <ConfirmDialog+ title="Update keyword stats?"+ confirmLabel="Update stats"+ onConfirm={onRefreshMetrics}+ onClose={() => setConfirmingRefresh(false)}+ >+ This fetches new volume, difficulty, and CPC for all{" "}+ {trackedKeywordCount} tracked keyword+ {trackedKeywordCount !== 1 ? "s" : ""}. Each keyword uses credits.+ Rankings do not change.+ </ConfirmDialog>+ ) : null}+ </>);}diff --git a/src/client/features/saved-keywords/SavedKeywordsHeader.tsx b/src/client/features/saved-keywords/SavedKeywordsHeader.tsxindex 6ff5e74a..b7e8f47e 100644--- a/src/client/features/saved-keywords/SavedKeywordsHeader.tsx+++ b/src/client/features/saved-keywords/SavedKeywordsHeader.tsx@@ -1,3 +1,4 @@+import { useState } from "react";import {ChevronDown,Download,@@ -6,6 +7,8 @@ import {RefreshCw,Sheet,} from "lucide-react";+import { ConfirmDialog } from "@/client/components/ConfirmDialog";+import { closeDropdown } from "@/client/lib/dropdown";export function SavedKeywordsHeader({totalCount,@@ -22,6 +25,7 @@ export function SavedKeywordsHeader({onExportSheets: () => void;onRefreshMetrics: () => void;}) {+ const [confirmingRefresh, setConfirmingRefresh] = useState(false);const disabled = totalCount === 0 || exporting != null;return (@@ -57,7 +61,10 @@ export function SavedKeywordsHeader({<li><buttontype="button"- onClick={onRefreshMetrics}+ onClick={() => {+ closeDropdown();+ setConfirmingRefresh(true);+ }}disabled={disabled || metricsRefreshing}><RefreshCw className="size-4" />@@ -112,6 +119,18 @@ export function SavedKeywordsHeader({</ul></div></div>++ {confirmingRefresh ? (+ <ConfirmDialog+ title="Update keyword stats?"+ confirmLabel="Update stats"+ onConfirm={onRefreshMetrics}+ onClose={() => setConfirmingRefresh(false)}+ >+ This fetches new volume, difficulty, and CPC for every saved keyword+ in this project. Each keyword uses credits.+ </ConfirmDialog>+ ) : null}</div>);}