Skip to content
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
10 changes: 10 additions & 0 deletions src/app/dashboard/storage/restore/restore-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface AdapterConfig {
id: string;
name: string;
adapterId: string;
metadata?: string;
}

interface DbConfig {
Expand Down Expand Up @@ -520,6 +521,15 @@ export function RestoreClient() {
<SelectContent>
{sources
.filter(s => {
// Filter out restore-excluded sources
try {
if (s.metadata) {
const meta = JSON.parse(s.metadata);
if (meta.isRestoreExcluded) return false;
}
} catch { }

// Filter by source type compatibility
if (!file?.sourceType) return true;
const type = file.sourceType.toLowerCase();
const adapter = s.adapterId.toLowerCase();
Expand Down
7 changes: 6 additions & 1 deletion src/components/adapter/adapter-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export function AdapterForm({ type, adapters, onSuccess, initialData, onBack }:
const initialMeta = initialData?.metadata ? JSON.parse(initialData.metadata) : {};
const [healthNotificationsDisabled, setHealthNotificationsDisabled] = useState<boolean>(initialMeta.healthNotificationsDisabled === true);

// Exclude from restore (database only)
const [isRestoreExcluded, setIsRestoreExcluded] = useState<boolean>(initialMeta.isRestoreExcluded === true);

// Credential profile assignments (Phase 4 - Generic Credential Profile System)
const [primaryCredentialId, setPrimaryCredentialId] = useState<string | null>(initialData?.primaryCredentialId ?? null);
const [sshCredentialId, setSshCredentialId] = useState<string | null>(initialData?.sshCredentialId ?? null);
Expand Down Expand Up @@ -198,7 +201,7 @@ export function AdapterForm({ type, adapters, onSuccess, initialData, onBack }:
// Build metadata with health notification preference for database/storage adapters
const existingMeta = initialData?.metadata ? JSON.parse(initialData.metadata) : {};
const metadata = (type === 'database' || type === 'storage')
? { ...existingMeta, healthNotificationsDisabled }
? { ...existingMeta, healthNotificationsDisabled, ...(type === 'database' ? { isRestoreExcluded } : {}) }
: existingMeta;

const payload = {
Expand Down Expand Up @@ -394,6 +397,8 @@ export function AdapterForm({ type, adapters, onSuccess, initialData, onBack }:
detectedVersion={detectedVersion}
healthNotificationsDisabled={healthNotificationsDisabled}
onHealthNotificationsDisabledChange={setHealthNotificationsDisabled}
isRestoreExcluded={isRestoreExcluded}
onIsRestoreExcludedChange={setIsRestoreExcluded}
primaryCredentialId={primaryCredentialId}
sshCredentialId={sshCredentialId}
onPrimaryChange={setPrimaryCredentialId}
Expand Down
64 changes: 64 additions & 0 deletions src/components/adapter/form-sections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ interface SectionProps extends CredentialPickerHostProps {
detectedVersion?: string | null;
healthNotificationsDisabled?: boolean;
onHealthNotificationsDisabledChange?: (disabled: boolean) => void;
isRestoreExcluded?: boolean;
onIsRestoreExcludedChange?: (excluded: boolean) => void;
}

/**
Expand Down Expand Up @@ -127,11 +129,37 @@ function HealthCheckNotificationSwitch({
);
}

function RestoreExcludedSwitch({
excluded,
onChange,
}: {
excluded: boolean;
onChange: (excluded: boolean) => void;
}) {
return (
<div className="flex items-center justify-between rounded-lg border p-4">
<div className="space-y-0.5">
<Label htmlFor="restore-excluded">Exclude from Restore</Label>
<p className="text-sm text-muted-foreground">
This source will not appear as a restore target when recovering backups.
</p>
</div>
<Switch
id="restore-excluded"
checked={excluded}
onCheckedChange={onChange}
/>
</div>
);
}

export function DatabaseFormContent({
adapter,
detectedVersion,
healthNotificationsDisabled,
onHealthNotificationsDisabledChange,
isRestoreExcluded,
onIsRestoreExcludedChange,
primaryCredentialId,
sshCredentialId,
onPrimaryChange,
Expand Down Expand Up @@ -200,6 +228,12 @@ export function DatabaseFormContent({
onChange={onHealthNotificationsDisabledChange}
/>
)}
{onIsRestoreExcludedChange && (
<RestoreExcludedSwitch
excluded={isRestoreExcluded ?? false}
onChange={onIsRestoreExcludedChange}
/>
)}
</div>
) : (
<Tabs defaultValue="connection" className="w-full pt-2">
Expand Down Expand Up @@ -258,6 +292,12 @@ export function DatabaseFormContent({
onChange={onHealthNotificationsDisabledChange}
/>
)}
{onIsRestoreExcludedChange && (
<RestoreExcludedSwitch
excluded={isRestoreExcluded ?? false}
onChange={onIsRestoreExcludedChange}
/>
)}
</TabsContent>
</Tabs>
)}
Expand Down Expand Up @@ -293,6 +333,8 @@ export function DatabaseFormContent({
detectedVersion={detectedVersion}
healthNotificationsDisabled={healthNotificationsDisabled}
onHealthNotificationsDisabledChange={onHealthNotificationsDisabledChange}
isRestoreExcluded={isRestoreExcluded}
onIsRestoreExcludedChange={onIsRestoreExcludedChange}
primaryCredentialId={primaryCredentialId}
sshCredentialId={sshCredentialId}
onPrimaryChange={onPrimaryChange}
Expand Down Expand Up @@ -364,6 +406,12 @@ export function DatabaseFormContent({
onChange={onHealthNotificationsDisabledChange}
/>
)}
{onIsRestoreExcludedChange && (
<RestoreExcludedSwitch
excluded={isRestoreExcluded ?? false}
onChange={onIsRestoreExcludedChange}
/>
)}
</TabsContent>

{isMSSQL && (
Expand Down Expand Up @@ -406,6 +454,8 @@ function SshAwareTabLayout({
detectedVersion,
healthNotificationsDisabled,
onHealthNotificationsDisabledChange,
isRestoreExcluded,
onIsRestoreExcludedChange,
primaryCredentialId,
sshCredentialId,
onPrimaryChange,
Expand All @@ -418,6 +468,8 @@ function SshAwareTabLayout({
detectedVersion?: string | null;
healthNotificationsDisabled?: boolean;
onHealthNotificationsDisabledChange?: (disabled: boolean) => void;
isRestoreExcluded?: boolean;
onIsRestoreExcludedChange?: (excluded: boolean) => void;
} & CredentialPickerHostProps) {
return (
<div className="space-y-4 pt-2">
Expand Down Expand Up @@ -478,6 +530,12 @@ function SshAwareTabLayout({
onChange={onHealthNotificationsDisabledChange}
/>
)}
{onIsRestoreExcludedChange && (
<RestoreExcludedSwitch
excluded={isRestoreExcluded ?? false}
onChange={onIsRestoreExcludedChange}
/>
)}
</TabsContent>
</Tabs>
) : (
Expand Down Expand Up @@ -515,6 +573,12 @@ function SshAwareTabLayout({
onChange={onHealthNotificationsDisabledChange}
/>
)}
{onIsRestoreExcludedChange && (
<RestoreExcludedSwitch
excluded={isRestoreExcluded ?? false}
onChange={onIsRestoreExcludedChange}
/>
)}
</TabsContent>
</Tabs>
)}
Expand Down
Loading