Skip to content

Commit 52d53a4

Browse files
committed
Code cleanup pass
1 parent f89a2e4 commit 52d53a4

6 files changed

Lines changed: 9 additions & 22 deletions

File tree

frontend/src/components/pages/rp-connect/onboarding/add-topic-step.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ export const AddTopicStep = forwardRef<BaseStepRef<AddTopicFormData>, AddTopicSt
366366
)}
367367
/>
368368

369-
{watchedTopicName !== '' && watchedTopicName.length > 0 && (
369+
{watchedTopicName && (
370370
<Button disabled={isPending} onClick={handleClearTopicName} size="icon" variant="ghost">
371371
<XIcon size={16} />
372372
</Button>

frontend/src/components/pages/rp-connect/onboarding/add-user-step.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ export const AddUserStep = forwardRef<UserStepRef, AddUserStepProps & MotionProp
510510
)}
511511
/>
512512

513-
{watchedUsername !== '' && watchedUsername.length > 0 && (
513+
{watchedUsername && (
514514
<Button disabled={isPending} onClick={handleClearUsername} size="icon" variant="ghost">
515515
<XIcon size={16} />
516516
</Button>
@@ -762,7 +762,7 @@ export const AddUserStep = forwardRef<UserStepRef, AddUserStepProps & MotionProp
762762
)}
763763
/>
764764

765-
{watchedConsumerGroup !== '' && watchedConsumerGroup && watchedConsumerGroup.length > 0 && (
765+
{watchedConsumerGroup && (
766766
<Button disabled={isPending} onClick={handleClearConsumerGroup} size="icon" variant="ghost">
767767
<XIcon size={16} />
768768
</Button>

frontend/src/components/pages/rp-connect/pipeline/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,6 @@ export default function PipelinePage() {
752752
const [slashTipVisible, setSlashTipVisible] = useState(isSlashMenuEnabled && mode !== 'view');
753753
const [isTemplateDialogOpen, setIsTemplateDialogOpen] = useState(false);
754754
const isTemplateGalleryEnabled = isFeatureFlagEnabled('enableConnectTemplateGallery');
755-
const lintPanelRef = useRef<ImperativePanelHandle>(null);
756755

757756
const form = useForm<PipelineFormValues>({
758757
resolver: zodResolver(pipelineFormSchema) as Resolver<PipelineFormValues>,

frontend/src/components/pages/rp-connect/template-gallery/template-deploy.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { getSecretSyntax } from '../types/constants';
1414

1515
export type SlotValues = Record<string, string>;
1616

17+
const isBlank = (v: string | undefined): boolean => !v?.trim();
18+
1719
// Secret slots become `${secrets.NAME}`; everything else inlines as-is.
1820
const substituteToken = (slot: TemplateSlot, raw: string): string => {
1921
if (slot.kind === 'secret') {
@@ -51,7 +53,7 @@ export const stitchTemplateYaml = ({
5153
const kept: string[] = [];
5254
for (const line of template.baseYaml.split('\n')) {
5355
const refs = referencedSlotIdsIn(line);
54-
if (refs.length > 0 && refs.some((id) => !values[id]?.trim())) {
56+
if (refs.length > 0 && refs.some((id) => isBlank(values[id]))) {
5557
continue;
5658
}
5759
kept.push(
@@ -72,7 +74,7 @@ export const stitchTemplateYaml = ({
7274

7375
export const findMissingRequiredSlot = (template: PipelineTemplate, values: SlotValues): string | undefined => {
7476
for (const slot of template.slots) {
75-
if (slot.required && !values[slot.id]?.trim()) {
77+
if (slot.required && isBlank(values[slot.id])) {
7678
return slot.id;
7779
}
7880
}

frontend/src/components/pages/rp-connect/template-gallery/template-form-panel.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,7 @@ const defaultValuesFor = (template: PipelineTemplate, slots: TemplateSlot[]): Re
8585
[PIPELINE_NAME_FIELD]: template.defaultPipelineName,
8686
};
8787
for (const slot of slots) {
88-
if (slot.kind === 'string' && slot.default) {
89-
defaults[slot.id] = slot.default;
90-
} else if (slot.kind === 'topic' && slot.default) {
91-
defaults[slot.id] = slot.default;
92-
} else if (slot.kind === 'select' && slot.default) {
93-
defaults[slot.id] = slot.default;
94-
} else {
95-
defaults[slot.id] = '';
96-
}
88+
defaults[slot.id] = slot.kind === 'secret' ? '' : (slot.default ?? '');
9789
}
9890
return defaults;
9991
};

frontend/src/components/pages/rp-connect/template-gallery/template-schema.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,9 @@ export function applySchemaToSlots(template: PipelineTemplate, componentList?: C
5151
required: slot.required ?? checkRequired(field as unknown as RawFieldSpec),
5252
};
5353

54-
// Default only applies to kinds that expose one.
55-
if (
56-
(merged.kind === 'string' || merged.kind === 'topic' || merged.kind === 'select') &&
57-
!merged.default &&
58-
field.defaultValue
59-
) {
54+
if (merged.kind !== 'secret' && !merged.default && field.defaultValue) {
6055
return { ...merged, default: field.defaultValue };
6156
}
62-
6357
return merged;
6458
});
6559
}

0 commit comments

Comments
 (0)