You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "hyonun321 (via GitHub)" <gi...@apache.org> on 2026/03/05 13:27:46 UTC

[PR] refactor(console): extract reusable FormField component to reduce form boilerplate [polaris-tools]

hyonun321 opened a new pull request, #182:
URL: https://github.com/apache/polaris-tools/pull/182

   ### What
   
   Extract a reusable `FormField` component and apply it across 11 form modals to eliminate repeated Label + Input + Error + Hint boilerplate.
   
   ### Why
   
   The console has 17 form modals, and most repeat the same pattern:
   
   ```tsx
   <div className="space-y-2">
     <Label htmlFor="name">Name</Label>
     <Input id="name" {...register("name")} />
     {errors.name && <p className="text-sm text-red-600">{errors.name.message}</p>}
     <p className="text-xs text-muted-foreground">Some hint text</p>
   </div>
   ```
   
   This 4–6 line pattern appears ~50 times across the codebase. A simple wrapper component reduces each instance to a single declarative block.
   
   ## Changes
   - New: components/ui/form-field.tsx — lightweight wrapper that renders Label, children, error message, and optional hint
   - Modified: 11 form modals to use FormField:
     - CreateViewModal, CreatePrincipalRoleModal, EditPrincipalModal
     - CreateNamespaceModal, CreateCatalogRoleModal
     - CreateCatalogModal, EditCatalogModal
     - GrantPrivilegeModal, ConfigureConnectionModal, ResetCredentialsModal
   
   ## What this does NOT change
   - No behavioral changes — all forms work exactly as before
   - Provider-specific sections (S3/Azure/GCS options) and dynamic key-value UIs are left as-is where FormField would add complexity
   - Files without react-hook-form or with Select-only fields are not modified
   
   ## Testing
   - make lint ✅
   - make format-check ✅
   - Manual verification of all modified modals


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] refactor(console): extract reusable FormField component to reduce form boilerplate [polaris-tools]

Posted by "jbonofre (via GitHub)" <gi...@apache.org>.
jbonofre merged PR #182:
URL: https://github.com/apache/polaris-tools/pull/182


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] refactor(console): extract reusable FormField component to reduce form boilerplate [polaris-tools]

Posted by "jbonofre (via GitHub)" <gi...@apache.org>.
jbonofre commented on PR #182:
URL: https://github.com/apache/polaris-tools/pull/182#issuecomment-4021184623

   > @jbonofre Hi! Could you please review this approach to component reuse?
   
   Absolutely. I will do the review later today or tomorrow.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] refactor(console): extract reusable FormField component to reduce form boilerplate [polaris-tools]

Posted by "jbonofre (via GitHub)" <gi...@apache.org>.
jbonofre commented on code in PR #182:
URL: https://github.com/apache/polaris-tools/pull/182#discussion_r2964487846


##########
console/src/components/ui/form-field.tsx:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as React from "react"
+import { Label } from "@/components/ui/label"
+
+interface FormFieldProps {
+  label: React.ReactNode
+  htmlFor?: string
+  error?: string
+  hint?: React.ReactNode
+  children: React.ReactNode
+  className?: string
+}
+
+function FormField({ label, htmlFor, error, hint, children, className }: FormFieldProps) {
+  return (
+    <div className={className ?? "space-y-2"}>
+      <Label htmlFor={htmlFor}>{label}</Label>
+      {children}
+      {error && <p className="text-sm text-red-600">{error}</p>}

Review Comment:
   @hyonun321 thanks ! I will merge just after your update.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] refactor(console): extract reusable FormField component to reduce form boilerplate [polaris-tools]

Posted by "hyonun321 (via GitHub)" <gi...@apache.org>.
hyonun321 commented on code in PR #182:
URL: https://github.com/apache/polaris-tools/pull/182#discussion_r2964370071


##########
console/src/components/ui/form-field.tsx:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as React from "react"
+import { Label } from "@/components/ui/label"
+
+interface FormFieldProps {
+  label: React.ReactNode
+  htmlFor?: string
+  error?: string
+  hint?: React.ReactNode
+  children: React.ReactNode
+  className?: string
+}
+
+function FormField({ label, htmlFor, error, hint, children, className }: FormFieldProps) {
+  return (
+    <div className={className ?? "space-y-2"}>

Review Comment:
   I had a bit of a dilemma. I debated whether to specify the classname separately in the props or use it conditionally internally like this. I believe space-y-2 should be removed to better consider the extensibility of the formfield, but for now, I used ?? to focus on the 'boilerplate'.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] refactor(console): extract reusable FormField component to reduce form boilerplate [polaris-tools]

Posted by "hyonun321 (via GitHub)" <gi...@apache.org>.
hyonun321 commented on PR #182:
URL: https://github.com/apache/polaris-tools/pull/182#issuecomment-4021012763

   @jbonofre Hi! Could you please review this approach to component reuse?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] refactor(console): extract reusable FormField component to reduce form boilerplate [polaris-tools]

Posted by "hyonun321 (via GitHub)" <gi...@apache.org>.
hyonun321 commented on code in PR #182:
URL: https://github.com/apache/polaris-tools/pull/182#discussion_r2964372025


##########
console/src/components/forms/ResetCredentialsModal.tsx:
##########
@@ -34,6 +34,7 @@ import { Button } from "@/components/ui/button"
 import { Input } from "@/components/ui/input"
 import { Label } from "@/components/ui/label"

Review Comment:
   Thanks for pointing this out! Label is still used directly in a few places where FormField doesn't fit — such as the Switch with horizontal layout, section headers, and checkbox labels. 
   
   FormField wraps Label internally for standard form groups, but these other use cases still need Label on its own. So the import needs to stay for now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] refactor(console): extract reusable FormField component to reduce form boilerplate [polaris-tools]

Posted by "hyonun321 (via GitHub)" <gi...@apache.org>.
hyonun321 commented on code in PR #182:
URL: https://github.com/apache/polaris-tools/pull/182#discussion_r2964308529


##########
console/src/components/ui/form-field.tsx:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as React from "react"
+import { Label } from "@/components/ui/label"
+
+interface FormFieldProps {
+  label: React.ReactNode
+  htmlFor?: string
+  error?: string
+  hint?: React.ReactNode
+  children: React.ReactNode
+  className?: string
+}
+
+function FormField({ label, htmlFor, error, hint, children, className }: FormFieldProps) {
+  return (
+    <div className={className ?? "space-y-2"}>
+      <Label htmlFor={htmlFor}>{label}</Label>
+      {children}
+      {error && <p className="text-sm text-red-600">{error}</p>}

Review Comment:
   You're right. I didn't consider dark mode. I will change it to text-destructive. Thank you.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org