Skip to content

Commit 28965e1

Browse files
fixing linter
1 parent fd97f90 commit 28965e1

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

src/components/ComponentsSelection/ComponentsSelectionContainer.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useRef, useState } from 'react';
1+
import React, { useEffect, useMemo, useRef, useState } from 'react';
22
import { ComponentsSelection } from './ComponentsSelection.tsx';
33

44
import IllustratedError from '../Shared/IllustratedError.tsx';
@@ -32,6 +32,13 @@ export const getSelectedComponents = (components: ComponentsListItem[]) => {
3232
});
3333
};
3434

35+
type TemplateDefaultComponent = {
36+
name: string;
37+
version: string;
38+
removable?: boolean;
39+
versionChangeable?: boolean;
40+
};
41+
3542
export const ComponentsSelectionContainer: React.FC<ComponentsSelectionProps> = ({
3643
setComponentsList,
3744
componentsList,
@@ -41,7 +48,10 @@ export const ComponentsSelectionContainer: React.FC<ComponentsSelectionProps> =
4148
const { t } = useTranslation();
4249
const initialized = useRef(false);
4350
const [templateDefaultsError, setTemplateDefaultsError] = useState<string | null>(null);
44-
const defaultComponents = managedControlPlaneTemplate?.spec?.spec?.components?.defaultComponents ?? [];
51+
const defaultComponents = useMemo<TemplateDefaultComponent[]>(
52+
() => managedControlPlaneTemplate?.spec?.spec?.components?.defaultComponents ?? [],
53+
[managedControlPlaneTemplate],
54+
);
4555

4656
useEffect(() => {
4757
if (
@@ -84,7 +94,7 @@ export const ComponentsSelectionContainer: React.FC<ComponentsSelectionProps> =
8494
}
8595

8696
const errs: string[] = [];
87-
defaultComponents.forEach((dc: any) => {
97+
defaultComponents.forEach((dc: TemplateDefaultComponent) => {
8898
if (!dc?.name) return;
8999
const item = items.find((it) => it.metadata.name === dc.name);
90100
if (!item) {

src/components/ControlPlanes/List/ControlPlaneListWorkspaceGridTile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function ControlPlaneListWorkspaceGridTile({ projectName, workspace }: Pr
7373
const seenKeys = new Set<string>();
7474
const fallbackNamespace = workspace.status?.namespace ?? '';
7575

76-
return (workspace.spec.members ?? []).filter((member: any) => {
76+
return (workspace.spec.members ?? []).filter((member: { name?: string; namespace?: string }) => {
7777
const memberNamespace = member?.namespace ?? fallbackNamespace;
7878
const memberName = String(member?.name ?? '')
7979
.trim()

src/components/Wizards/CreateManagedControlPlane/CreateManagedControlPlaneWizardContainer.tsx

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
7272
const normalizeChargingTargetType = useCallback((val?: string | null) => (val ?? '').trim().toLowerCase(), []);
7373

7474
// Here we will use OnboardingAPI to get all avaliable templates
75-
const templates: ManagedControlPlaneTemplate[] = [];
75+
const templates = useMemo<ManagedControlPlaneTemplate[]>(() => [], []);
7676

7777
const [selectedTemplateValue, setSelectedTemplateValue] = useState<string>(noTemplateValue);
7878

@@ -315,11 +315,11 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
315315
if (currentIndex > 0) {
316316
setSelectedStep(wizardStepOrder[currentIndex - 1]);
317317
}
318-
}, [selectedStep, wizardStepOrder]);
318+
}, [selectedStep]);
319319

320320
const normalizeMemberKind = useCallback((k?: string | null) => {
321321
const v = (k ?? '').toString().trim().toLowerCase();
322-
return v === 'group' ? 'Group' : 'User';
322+
return v === 'serviceaccount' ? 'ServiceAccount' : 'User';
323323
}, []);
324324

325325
const appliedTemplateMembersRef = useRef(false);
@@ -335,7 +335,8 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
335335
if (!selectedTemplate) return;
336336
if (appliedTemplateMembersRef.current) return;
337337

338-
const templateMembers = selectedTemplate?.spec?.spec?.authorization?.defaultMembers ?? [];
338+
const templateMembers = (selectedTemplate?.spec?.spec?.authorization?.defaultMembers ??
339+
[]) as ManagedControlPlaneTemplate['spec']['spec']['authorization']['defaultMembers'];
339340
if (!templateMembers?.length) {
340341
appliedTemplateMembersRef.current = true;
341342
return;
@@ -349,7 +350,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
349350
}
350351

351352
const mappedFromTemplate: Member[] = templateMembers
352-
.map((m: any) => ({
353+
.map((m) => ({
353354
name: stripIdpPrefix(String(m?.name ?? ''), idpPrefix),
354355
roles: [normalizeMemberRole(m?.role)],
355356
kind: normalizeMemberKind(m?.kind),
@@ -371,23 +372,15 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
371372

372373
setValue('members', normalizedMembers, { shouldValidate: true });
373374
appliedTemplateMembersRef.current = true;
374-
}, [
375-
selectedStep,
376-
selectedTemplate,
377-
watch,
378-
setValue,
379-
user?.email,
380-
normalizeMemberRole,
381-
normalizeMemberKind,
382-
idpPrefix,
383-
]);
375+
}, [selectedStep, selectedTemplate, watch, setValue, user?.email, normalizeMemberRole, normalizeMemberKind]);
384376

385377
useEffect(() => {
386378
if (selectedStep !== 'componentSelection') return;
387379
if (!selectedTemplate) return;
388380
if (appliedTemplateComponentsRef.current) return;
389381

390-
const defaults = selectedTemplate?.spec?.spec?.components?.defaultComponents ?? [];
382+
const defaults = (selectedTemplate?.spec?.spec?.components?.defaultComponents ??
383+
[]) as ManagedControlPlaneTemplate['spec']['spec']['components']['defaultComponents'];
391384
if (!defaults?.length) {
392385
appliedTemplateComponentsRef.current = true;
393386
return;
@@ -400,8 +393,8 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
400393
}
401394

402395
const mapped = defaults
403-
.filter((c: any) => !!c?.name && !!c?.version)
404-
.map((c: any) => ({
396+
.filter((c) => !!c?.name && !!c?.version)
397+
.map((c) => ({
405398
name: String(c.name),
406399
version: String(c.version),
407400
selectedVersion: String(c.version),

0 commit comments

Comments
 (0)