From b0ad4e3102c1f1482209a5c2316309d3f74d8d6b Mon Sep 17 00:00:00 2001 From: DevContainer User Date: Wed, 4 Mar 2026 00:55:42 +0000 Subject: [PATCH] style: format all source files with Prettier Co-Authored-By: Claude Opus 4.6 --- src/components/DecryptDialog.tsx | 12 +- src/components/EncryptDialog.tsx | 16 +- src/components/ErrorBoundary.tsx | 4 +- src/components/LoadingSkeletons.tsx | 53 ++++- src/components/SealedSecretDetail.tsx | 278 ++++++++++++------------ src/components/SealedSecretList.tsx | 14 +- src/components/SealingKeysView.tsx | 10 +- src/components/SecretDetailsSection.tsx | 6 +- src/components/VersionWarning.tsx | 20 +- src/hooks/useSealedSecretEncryption.ts | 9 +- src/lib/SealedSecretCRD.ts | 2 +- src/lib/retry.test.ts | 10 +- src/lib/retry.ts | 14 +- src/types.ts | 4 +- 14 files changed, 255 insertions(+), 197 deletions(-) diff --git a/src/components/DecryptDialog.tsx b/src/components/DecryptDialog.tsx index 60cae67..79e2191 100644 --- a/src/components/DecryptDialog.tsx +++ b/src/components/DecryptDialog.tsx @@ -80,7 +80,9 @@ export function DecryptDialog({ sealedSecret, secretKey, onClose }: DecryptDialo - + ); @@ -103,7 +105,9 @@ export function DecryptDialog({ sealedSecret, secretKey, onClose }: DecryptDialo - + ); @@ -182,7 +186,9 @@ export function DecryptDialog({ sealedSecret, secretKey, onClose }: DecryptDialo - + ); diff --git a/src/components/EncryptDialog.tsx b/src/components/EncryptDialog.tsx index 0cd46ee..cf2096a 100644 --- a/src/components/EncryptDialog.tsx +++ b/src/components/EncryptDialog.tsx @@ -83,10 +83,12 @@ export function EncryptDialog({ open, onClose }: EncryptDialogProps) { const handleCreate = async () => { // Filter out empty rows - const validKeyValues = keyValues.filter(kv => kv.key || kv.value).map(kv => ({ - key: kv.key, - value: kv.value, - })); + const validKeyValues = keyValues + .filter(kv => kv.key || kv.value) + .map(kv => ({ + key: kv.key, + value: kv.value, + })); // Use the encryption hook const result = await encrypt({ @@ -232,7 +234,11 @@ export function EncryptDialog({ open, onClose }: EncryptDialogProps) { disabled={keyValues.length === 1} color="error" aria-label={`Remove key-value pair ${index + 1}`} - title={keyValues.length === 1 ? 'At least one key-value pair is required' : `Remove key-value pair ${index + 1}`} + title={ + keyValues.length === 1 + ? 'At least one key-value pair is required' + : `Remove key-value pair ${index + 1}` + } > diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index 8a5b9dc..50f0646 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -192,8 +192,8 @@ export class GenericErrorBoundary extends BaseErrorBoundary { Something Went Wrong - An unexpected error occurred. Please try reloading the page or contact your administrator - if the problem persists. + An unexpected error occurred. Please try reloading the page or contact your + administrator if the problem persists. {this.state.error && ( {/* Metadata section */} - + {/* Encrypted data section */} - + {/* Actions section */} - - + + ); @@ -66,10 +88,27 @@ export function SealingKeysListSkeleton() { {[1, 2].map(i => ( - + - - + + ))} diff --git a/src/components/SealedSecretDetail.tsx b/src/components/SealedSecretDetail.tsx index 0342b80..b86a0eb 100644 --- a/src/components/SealedSecretDetail.tsx +++ b/src/components/SealedSecretDetail.tsx @@ -87,9 +87,7 @@ export function SealedSecretDetail() { Failed to load SealedSecret - - {String(error)} - + {String(error)} ); @@ -162,165 +160,167 @@ export function SealedSecretDetail() { {sealedSecret.metadata.name} - {permissions?.canUpdate && ( - - )} - {permissions?.canDelete && ( - - )} + {permissions?.canUpdate && ( + + )} + {permissions?.canDelete && ( + + )} + - - } - > - - {sealedSecret.isSynced ? 'Synced' : 'Not Synced'} - - ), - }, - { - name: 'Status Message', - value: String(sealedSecret.syncMessage || 'Unknown'), - hide: !sealedSecret.syncCondition, - }, - { - name: 'Age', - value: String(sealedSecret.getAge() || ''), - }, - { - name: 'Created', - value: sealedSecret.metadata.creationTimestamp - ? new Date(sealedSecret.metadata.creationTimestamp).toLocaleString() - : 'Unknown', - }, - ]} - /> - - - - ({ - key, - value: sealedSecret.spec.encryptedData[key], - }))} - columns={[ - { - label: 'Key', - getter: (row: any) => row.key, - }, - { - label: 'Encrypted Value', - getter: (row: any) => { - const val = row.value; - return val.length > 40 ? val.substring(0, 40) + '...' : val; - }, - }, - { - label: 'Actions', - getter: (row: any) => - canDecrypt ? ( - - ) : ( - - ), - }, - ]} - /> - - - {sealedSecret.spec.template && ( - + } + > + {sealedSecret.isSynced ? 'Synced' : 'Not Synced'} + ), - hide: !sealedSecret.spec.template.metadata?.annotations, + }, + { + name: 'Status Message', + value: String(sealedSecret.syncMessage || 'Unknown'), + hide: !sealedSecret.syncCondition, + }, + { + name: 'Age', + value: String(sealedSecret.getAge() || ''), + }, + { + name: 'Created', + value: sealedSecret.metadata.creationTimestamp + ? new Date(sealedSecret.metadata.creationTimestamp).toLocaleString() + : 'Unknown', }, ]} /> - )} - - {secret ? ( - + ({ + key, + value: sealedSecret.spec.encryptedData[key], + }))} + columns={[ { - name: 'Status', - value: Secret exists, + label: 'Key', + getter: (row: any) => row.key, }, { - name: 'Keys', - value: String(Object.keys(secret.data || {}).join(', ') || 'None'), + label: 'Encrypted Value', + getter: (row: any) => { + const val = row.value; + return val.length > 40 ? val.substring(0, 40) + '...' : val; + }, }, { - name: 'Link', - value: ( - - View Secret - - ), + label: 'Actions', + getter: (row: any) => + canDecrypt ? ( + + ) : ( + + ), }, ]} /> - ) : ( - - Secret not yet created -

The controller will create the Secret once it processes this SealedSecret.

-
+
+ + {sealedSecret.spec.template && ( + + + )} - + + + {secret ? ( + Secret exists, + }, + { + name: 'Keys', + value: String(Object.keys(secret.data || {}).join(', ') || 'None'), + }, + { + name: 'Link', + value: ( + + View Secret + + ), + }, + ]} + /> + ) : ( + + Secret not yet created +

The controller will create the Secret once it processes this SealedSecret.

+
+ )} +
{decryptKey && ( diff --git a/src/components/SealedSecretList.tsx b/src/components/SealedSecretList.tsx index 9c5c9b9..a3af480 100644 --- a/src/components/SealedSecretList.tsx +++ b/src/components/SealedSecretList.tsx @@ -126,9 +126,7 @@ export function SealedSecretList() { // Show error if CRD is not installed if (error) { return ( - + Error @@ -139,7 +137,11 @@ export function SealedSecretList() { cluster.

- Install with: kubectl apply -f https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.24.0/controller.yaml + Install with:{' '} + + kubectl apply -f + https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.24.0/controller.yaml +

) : ( @@ -153,9 +155,7 @@ export function SealedSecretList() { return ( <> - + diff --git a/src/components/SealingKeysView.tsx b/src/components/SealingKeysView.tsx index 52c7ea2..1044a37 100644 --- a/src/components/SealingKeysView.tsx +++ b/src/components/SealingKeysView.tsx @@ -5,7 +5,11 @@ */ import { K8s } from '@kinvolk/headlamp-plugin/lib'; -import { SectionBox, SimpleTable, StatusLabel } from '@kinvolk/headlamp-plugin/lib/CommonComponents'; +import { + SectionBox, + SimpleTable, + StatusLabel, +} from '@kinvolk/headlamp-plugin/lib/CommonComponents'; import { Box, Button, Chip } from '@mui/material'; import { useSnackbar } from 'notistack'; import React from 'react'; @@ -27,7 +31,9 @@ interface SealingKey { */ export function SealingKeysView() { const config = getPluginConfig(); - const [secrets, , loading] = K8s.ResourceClasses.Secret.useList({ namespace: config.controllerNamespace }); + const [secrets, , loading] = K8s.ResourceClasses.Secret.useList({ + namespace: config.controllerNamespace, + }); const { enqueueSnackbar } = useSnackbar(); // Filter for sealing key secrets diff --git a/src/components/SecretDetailsSection.tsx b/src/components/SecretDetailsSection.tsx index 0d7acf5..78ef473 100644 --- a/src/components/SecretDetailsSection.tsx +++ b/src/components/SecretDetailsSection.tsx @@ -6,7 +6,11 @@ */ import { Link } from '@kinvolk/headlamp-plugin/lib/CommonComponents'; -import { NameValueTable, SectionBox, StatusLabel } from '@kinvolk/headlamp-plugin/lib/CommonComponents'; +import { + NameValueTable, + SectionBox, + StatusLabel, +} from '@kinvolk/headlamp-plugin/lib/CommonComponents'; import React from 'react'; import { SealedSecret } from '../lib/SealedSecretCRD'; diff --git a/src/components/VersionWarning.tsx b/src/components/VersionWarning.tsx index d221068..275352d 100644 --- a/src/components/VersionWarning.tsx +++ b/src/components/VersionWarning.tsx @@ -41,9 +41,7 @@ export function VersionWarning({ autoDetect = true, showDetails = false }: Versi } else if (result.ok === false) { setDetectedVersion(null); // Ensure error is always a string - const errorMessage = typeof result.error === 'string' - ? result.error - : String(result.error); + const errorMessage = typeof result.error === 'string' ? result.error : String(result.error); setError(errorMessage); } } catch (e) { @@ -70,11 +68,14 @@ export function VersionWarning({ autoDetect = true, showDetails = false }: Versi if (error) { return ( - - Retry - - }> + + Retry + + } + > API Version Detection Failed
{String(error)} @@ -84,7 +85,8 @@ export function VersionWarning({ autoDetect = true, showDetails = false }: Versi
Install Sealed Secrets with:{' '} - kubectl apply -f https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.24.0/controller.yaml + kubectl apply -f + https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.24.0/controller.yaml
Or visit:{' '} diff --git a/src/hooks/useSealedSecretEncryption.ts b/src/hooks/useSealedSecretEncryption.ts index d9ac0a9..c89b7fe 100644 --- a/src/hooks/useSealedSecretEncryption.ts +++ b/src/hooks/useSealedSecretEncryption.ts @@ -15,14 +15,7 @@ import { parsePublicKeyFromCert, } from '../lib/crypto'; import { validateSecretKey, validateSecretName, validateSecretValue } from '../lib/validators'; -import { - AsyncResult, - CertificateInfo, - Err, - Ok, - PlaintextValue, - SealedSecretScope, -} from '../types'; +import { AsyncResult, CertificateInfo, Err, Ok, PlaintextValue, SealedSecretScope } from '../types'; /** * Request parameters for encryption diff --git a/src/lib/SealedSecretCRD.ts b/src/lib/SealedSecretCRD.ts index 86677be..e7764c8 100644 --- a/src/lib/SealedSecretCRD.ts +++ b/src/lib/SealedSecretCRD.ts @@ -2,7 +2,7 @@ * SealedSecret Custom Resource Definition */ -import { ApiProxy,K8s } from '@kinvolk/headlamp-plugin/lib'; +import { ApiProxy, K8s } from '@kinvolk/headlamp-plugin/lib'; const { apiFactoryWithNamespace } = ApiProxy; const { KubeObject } = K8s.cluster; diff --git a/src/lib/retry.test.ts b/src/lib/retry.test.ts index 38c2ab1..76fb2db 100644 --- a/src/lib/retry.test.ts +++ b/src/lib/retry.test.ts @@ -39,7 +39,10 @@ describe('retry logic', () => { .mockResolvedValueOnce({ ok: false, error: 'error2' }) .mockResolvedValueOnce({ ok: true, value: 'success' }); - const promise = retryWithBackoff(failTwiceThenSucceed, { maxAttempts: 3, initialDelayMs: 100 }); + const promise = retryWithBackoff(failTwiceThenSucceed, { + maxAttempts: 3, + initialDelayMs: 100, + }); await vi.runAllTimersAsync(); const result = await promise; @@ -72,7 +75,10 @@ describe('retry logic', () => { .mockResolvedValueOnce({ ok: false, error: 'error2' }) .mockResolvedValueOnce({ ok: true, value: 'success' }); - const promise = retryWithBackoff(failTwiceThenSucceed, { maxAttempts: 3, initialDelayMs: 1000 }); + const promise = retryWithBackoff(failTwiceThenSucceed, { + maxAttempts: 3, + initialDelayMs: 1000, + }); // Fast-forward through retries await vi.runAllTimersAsync(); diff --git a/src/lib/retry.ts b/src/lib/retry.ts index 6561b84..4e8239a 100644 --- a/src/lib/retry.ts +++ b/src/lib/retry.ts @@ -109,9 +109,7 @@ export async function retryWithBackoff( const isLastAttempt = attempt === opts.maxAttempts - 1; if (isLastAttempt) { // No more retries, return final error - return Err( - `Operation failed after ${opts.maxAttempts} attempts:\n${errors.join('\n')}` - ); + return Err(`Operation failed after ${opts.maxAttempts} attempts:\n${errors.join('\n')}`); } // Wait before retrying @@ -124,9 +122,7 @@ export async function retryWithBackoff( const isLastAttempt = attempt === opts.maxAttempts - 1; if (isLastAttempt) { - return Err( - `Operation failed after ${opts.maxAttempts} attempts:\n${errors.join('\n')}` - ); + return Err(`Operation failed after ${opts.maxAttempts} attempts:\n${errors.join('\n')}`); } const delay = calculateDelay(attempt, opts); @@ -171,10 +167,12 @@ export function isRetryableHttpError(error: Error): boolean { } // Check for specific retryable status codes - return message.includes('429') || // Too Many Requests + return ( + message.includes('429') || // Too Many Requests message.includes('408') || // Request Timeout message.includes('503') || // Service Unavailable - message.includes('504'); // Gateway Timeout + message.includes('504') + ); // Gateway Timeout } /** diff --git a/src/types.ts b/src/types.ts index 280c604..b9f5ee5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -16,9 +16,7 @@ type KubeObjectInterface = K8s.cluster.KubeObjectInterface; * return Ok(a / b); * } */ -export type Result = - | { ok: true; value: T } - | { ok: false; error: E }; +export type Result = { ok: true; value: T } | { ok: false; error: E }; /** * Async result type for promises that can fail