mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-08-23 03:26:37 +00:00
refactor(frontend): drop verbose suffixes from overwrite module names
Within `components/shared/overwrite/` the folder name already supplies context, so the file/component names don't need to repeat it. Rename overwrite-confirm-dialog → overwrite-dialog and overwrite-cta-buttons → overwrite-buttons (and matching exports OverwriteConfirmDialog → OverwriteDialog, OverwriteCtaButtons → OverwriteButtons) so the module matches the file-and-export naming convention used by detail-navigation.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
export { OverwriteConfirmDialog } from './overwrite-confirm-dialog';
|
||||
export type { OverwriteConflict } from './overwrite-confirm-dialog';
|
||||
export { OverwriteCtaButtons } from './overwrite-cta-buttons';
|
||||
export { OverwriteButtons } from './overwrite-buttons';
|
||||
export { OverwriteDialog } from './overwrite-dialog';
|
||||
export type { OverwriteConflict } from './overwrite-dialog';
|
||||
export { useOverwriteAction } from './use-overwrite-action';
|
||||
export type { OverwriteOutcome } from './use-overwrite-action';
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@ import { Loader2, Replace } from 'lucide-react';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
interface OverwriteCtaButtonsProps {
|
||||
interface OverwriteButtonsProps {
|
||||
/**
|
||||
* When `true` both buttons are greyed-out and clicks are ignored. Use to
|
||||
* disable the CTAs based on form validity, selection emptiness, or any
|
||||
@@ -47,7 +47,7 @@ interface OverwriteCtaButtonsProps {
|
||||
* The component owns the spinner / icon swap, so callers don't repeat that
|
||||
* boilerplate in five different dialogs.
|
||||
*/
|
||||
export const OverwriteCtaButtons = ({
|
||||
export const OverwriteButtons = ({
|
||||
isDisabled,
|
||||
isProcessing,
|
||||
onOverwrite,
|
||||
@@ -56,7 +56,7 @@ export const OverwriteCtaButtons = ({
|
||||
primaryIcon: PrimaryIcon,
|
||||
primaryLabel,
|
||||
primaryType = 'button',
|
||||
}: OverwriteCtaButtonsProps) => {
|
||||
}: OverwriteButtonsProps) => {
|
||||
const disabled = isDisabled || isProcessing;
|
||||
|
||||
return (
|
||||
+3
-3
@@ -8,7 +8,7 @@ export interface OverwriteConflict {
|
||||
destinationName: string;
|
||||
}
|
||||
|
||||
interface OverwriteConfirmDialogProps {
|
||||
interface OverwriteDialogProps {
|
||||
/**
|
||||
* Overrides the auto-generated confirm button label. Defaults to
|
||||
* `"Replace"` for a single conflict and `"Replace all"` for a batch.
|
||||
@@ -57,14 +57,14 @@ const buildDefaultConfirmText = (count: number): string => (count > 1 ? 'Replace
|
||||
* file-manager UX and keeps the user from being prompted N times for the
|
||||
* same destination directory.
|
||||
*/
|
||||
export const OverwriteConfirmDialog = ({
|
||||
export const OverwriteDialog = ({
|
||||
confirmText,
|
||||
conflicts,
|
||||
description,
|
||||
onCancel,
|
||||
onReplaceAll,
|
||||
title = 'Replace existing item?',
|
||||
}: OverwriteConfirmDialogProps) => (
|
||||
}: OverwriteDialogProps) => (
|
||||
<ConfirmationDialog
|
||||
cancelText="Cancel"
|
||||
confirmIcon={<Replace />}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import type { OverwriteConflict } from './overwrite-confirm-dialog';
|
||||
import type { OverwriteConflict } from './overwrite-dialog';
|
||||
|
||||
/**
|
||||
* Discriminated outcome of a server action that supports an overwrite flag.
|
||||
@@ -23,7 +23,7 @@ export type OverwriteOutcome =
|
||||
* Anonymous fallback descriptor used when a 409 sneaks through after a clean
|
||||
* preflight and the caller didn't provide `synthesizeFallbackConflicts`. Falls
|
||||
* back to the count-based copy ("N items already exist...") in
|
||||
* `OverwriteConfirmDialog`.
|
||||
* `OverwriteDialog`.
|
||||
*/
|
||||
const ANONYMOUS_FALLBACK_CONFLICT: OverwriteConflict = {
|
||||
destination: '',
|
||||
@@ -39,7 +39,7 @@ interface UseOverwriteActionOptions<TPlan> {
|
||||
/**
|
||||
* Pure function: inspect the local snapshot and return any destinations
|
||||
* that would conflict. Empty array → primary execute proceeds with
|
||||
* `force=false`; non-empty → the OverwriteConfirmDialog is opened
|
||||
* `force=false`; non-empty → the OverwriteDialog is opened
|
||||
* pre-populated with these descriptors.
|
||||
*/
|
||||
findConflicts: (plan: TPlan) => OverwriteConflict[];
|
||||
@@ -55,21 +55,21 @@ interface UseOverwriteActionOptions<TPlan> {
|
||||
}
|
||||
|
||||
interface UseOverwriteActionResult<TPlan> {
|
||||
/** Live conflict descriptors. Wire to `<OverwriteConfirmDialog conflicts={…} />`. */
|
||||
/** Live conflict descriptors. Wire to `<OverwriteDialog conflicts={…} />`. */
|
||||
conflicts: OverwriteConflict[];
|
||||
/**
|
||||
* Execute the action with `force=true` immediately, bypassing the
|
||||
* preflight and the conflict prompt. Wire to the secondary CTA.
|
||||
*/
|
||||
forceExecute: (plan: TPlan) => Promise<void>;
|
||||
/** Wire to the `onReplaceAll` handler of `<OverwriteConfirmDialog />`. */
|
||||
/** Wire to the `onReplaceAll` handler of `<OverwriteDialog />`. */
|
||||
handleReplaceAll: () => Promise<void>;
|
||||
/**
|
||||
* Execute the action with the preflight + race-fallback workflow. Wire
|
||||
* to the primary CTA.
|
||||
*/
|
||||
primaryExecute: (plan: TPlan) => Promise<void>;
|
||||
/** Wire to the `onCancel` handler of `<OverwriteConfirmDialog />`. */
|
||||
/** Wire to the `onCancel` handler of `<OverwriteDialog />`. */
|
||||
resetConflicts: () => void;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ interface UseOverwriteActionResult<TPlan> {
|
||||
* Workflow:
|
||||
* 1. The user clicks the **primary CTA** → `primaryExecute(plan)` runs.
|
||||
* `findConflicts` is consulted on the local snapshot first; if anything
|
||||
* collides, the OverwriteConfirmDialog opens with those descriptors.
|
||||
* collides, the OverwriteDialog opens with those descriptors.
|
||||
* Otherwise `execute(plan, false)` is dispatched. A 409 from the server
|
||||
* (race) auto-opens the dialog with `synthesizeFallbackConflicts` (or an
|
||||
* anonymous fallback).
|
||||
|
||||
@@ -2,7 +2,7 @@ import { FolderInput, Search, X } from 'lucide-react';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
|
||||
import { FileManager, type FileNode } from '@/components/shared/file-manager';
|
||||
import { OverwriteConfirmDialog, OverwriteCtaButtons, useOverwriteAction } from '@/components/shared/overwrite';
|
||||
import { OverwriteButtons, OverwriteDialog, useOverwriteAction } from '@/components/shared/overwrite';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
@@ -251,7 +251,7 @@ const FlowFilesAttachResourcesDialogBody = ({
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<OverwriteCtaButtons
|
||||
<OverwriteButtons
|
||||
isDisabled={isAttachDisabled}
|
||||
isProcessing={isAttaching}
|
||||
onOverwrite={handleOverwrite}
|
||||
@@ -264,7 +264,7 @@ const FlowFilesAttachResourcesDialogBody = ({
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
|
||||
<OverwriteConfirmDialog
|
||||
<OverwriteDialog
|
||||
conflicts={overwriteAction.conflicts}
|
||||
onCancel={overwriteAction.resetConflicts}
|
||||
onReplaceAll={overwriteAction.handleReplaceAll}
|
||||
|
||||
@@ -28,7 +28,7 @@ const containerPathToCachePath = (containerPath: string): string => {
|
||||
* (re-pulling a file the user already has) without an extra REST round-trip.
|
||||
* Nested conflicts (the user pulls `/etc/` while only `/etc/nginx.conf` is
|
||||
* cached) still surface server-side as a 409 and are auto-redialed by the
|
||||
* caller through the same `OverwriteConfirmDialog` flow.
|
||||
* caller through the same `OverwriteDialog` flow.
|
||||
*/
|
||||
export const findPullConflicts = (
|
||||
pullTargets: readonly string[],
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useForm } from 'react-hook-form';
|
||||
import type { FileNode } from '@/components/shared/file-manager';
|
||||
import type { OverwriteConflict } from '@/components/shared/overwrite';
|
||||
|
||||
import { OverwriteConfirmDialog, OverwriteCtaButtons, useOverwriteAction } from '@/components/shared/overwrite';
|
||||
import { OverwriteButtons, OverwriteDialog, useOverwriteAction } from '@/components/shared/overwrite';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
|
||||
@@ -234,7 +234,7 @@ const FlowFilesPromoteDialogForm = ({ files, flowId, onClose }: FlowFilesPromote
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<OverwriteCtaButtons
|
||||
<OverwriteButtons
|
||||
isDisabled={isSubmitDisabled}
|
||||
isProcessing={isPromoting}
|
||||
onOverwrite={() => {
|
||||
@@ -250,7 +250,7 @@ const FlowFilesPromoteDialogForm = ({ files, flowId, onClose }: FlowFilesPromote
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
||||
<OverwriteConfirmDialog
|
||||
<OverwriteDialog
|
||||
conflicts={overwriteAction.conflicts}
|
||||
onCancel={overwriteAction.resetConflicts}
|
||||
onReplaceAll={overwriteAction.handleReplaceAll}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
type FileManagerBulkAction,
|
||||
type FileNode,
|
||||
} from '@/components/shared/file-manager';
|
||||
import { OverwriteConfirmDialog, OverwriteCtaButtons, useOverwriteAction } from '@/components/shared/overwrite';
|
||||
import { OverwriteButtons, OverwriteDialog, useOverwriteAction } from '@/components/shared/overwrite';
|
||||
import {
|
||||
Autocomplete,
|
||||
AutocompleteContent,
|
||||
@@ -428,7 +428,7 @@ const FlowFilesPullDialogForm = ({ cachedFiles, flowId, onClose, onSuccess }: Fl
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<OverwriteCtaButtons
|
||||
<OverwriteButtons
|
||||
isDisabled={isPullDisabled}
|
||||
isProcessing={isPulling}
|
||||
onOverwrite={() => {
|
||||
@@ -444,7 +444,7 @@ const FlowFilesPullDialogForm = ({ cachedFiles, flowId, onClose, onSuccess }: Fl
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
|
||||
<OverwriteConfirmDialog
|
||||
<OverwriteDialog
|
||||
conflicts={overwriteAction.conflicts}
|
||||
onCancel={overwriteAction.resetConflicts}
|
||||
onReplaceAll={overwriteAction.handleReplaceAll}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useForm } from 'react-hook-form';
|
||||
import type { FileNode } from '@/components/shared/file-manager';
|
||||
import type { OverwriteConflict } from '@/components/shared/overwrite';
|
||||
|
||||
import { OverwriteConfirmDialog, OverwriteCtaButtons, useOverwriteAction } from '@/components/shared/overwrite';
|
||||
import { OverwriteButtons, OverwriteDialog, useOverwriteAction } from '@/components/shared/overwrite';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
|
||||
@@ -225,7 +225,7 @@ const ResourcesCopyDialogForm = ({ files, onClose }: ResourcesCopyDialogFormProp
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<OverwriteCtaButtons
|
||||
<OverwriteButtons
|
||||
isDisabled={isSubmitDisabled}
|
||||
isProcessing={isCopying}
|
||||
onOverwrite={() => {
|
||||
@@ -241,7 +241,7 @@ const ResourcesCopyDialogForm = ({ files, onClose }: ResourcesCopyDialogFormProp
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
||||
<OverwriteConfirmDialog
|
||||
<OverwriteDialog
|
||||
conflicts={overwriteAction.conflicts}
|
||||
onCancel={overwriteAction.resetConflicts}
|
||||
onReplaceAll={overwriteAction.handleReplaceAll}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useForm } from 'react-hook-form';
|
||||
import type { FileNode } from '@/components/shared/file-manager';
|
||||
import type { OverwriteConflict } from '@/components/shared/overwrite';
|
||||
|
||||
import { OverwriteConfirmDialog, OverwriteCtaButtons, useOverwriteAction } from '@/components/shared/overwrite';
|
||||
import { OverwriteButtons, OverwriteDialog, useOverwriteAction } from '@/components/shared/overwrite';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
|
||||
@@ -230,7 +230,7 @@ const ResourcesMoveDialogForm = ({ files, onClose }: ResourcesMoveDialogFormProp
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<OverwriteCtaButtons
|
||||
<OverwriteButtons
|
||||
isDisabled={isSubmitDisabled}
|
||||
isProcessing={isMoving}
|
||||
onOverwrite={() => {
|
||||
@@ -246,7 +246,7 @@ const ResourcesMoveDialogForm = ({ files, onClose }: ResourcesMoveDialogFormProp
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
||||
<OverwriteConfirmDialog
|
||||
<OverwriteDialog
|
||||
conflicts={overwriteAction.conflicts}
|
||||
onCancel={overwriteAction.resetConflicts}
|
||||
onReplaceAll={overwriteAction.handleReplaceAll}
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
formatModifiedRelative,
|
||||
} from '@/components/shared/file-manager';
|
||||
import { HeaderButton } from '@/components/shared/header-button';
|
||||
import { OverwriteConfirmDialog, useOverwriteAction } from '@/components/shared/overwrite';
|
||||
import { OverwriteDialog, useOverwriteAction } from '@/components/shared/overwrite';
|
||||
import { Breadcrumb, BreadcrumbItem, BreadcrumbList, BreadcrumbPage } from '@/components/ui/breadcrumb';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
@@ -574,7 +574,7 @@ const Resources = () => {
|
||||
onClose={() => setFilesToCopy(null)}
|
||||
/>
|
||||
|
||||
<OverwriteConfirmDialog
|
||||
<OverwriteDialog
|
||||
conflicts={dndMoveAction.conflicts}
|
||||
onCancel={dndMoveAction.resetConflicts}
|
||||
onReplaceAll={dndMoveAction.handleReplaceAll}
|
||||
|
||||
Reference in New Issue
Block a user