Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
jerryshao merged PR #5524: URL: https://github.com/apache/gravitino/pull/5524 -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
LauraXia123 commented on PR #5524: URL: https://github.com/apache/gravitino/pull/5524#issuecomment-2472826768 Thank you very much for your contribution. LGTM -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
LauraXia123 commented on PR #5524: URL: https://github.com/apache/gravitino/pull/5524#issuecomment-2472551301 https://github.com/user-attachments/assets/c9406e87-3b70-4931-ae0f-7e2dadbcfadf";> https://github.com/user-attachments/assets/7026b108-31aa-4be0-94af-32cce82dd3ca";> Must have a column by default. Then you can't delete when there is only one column left -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
orenccl commented on PR #5524: URL: https://github.com/apache/gravitino/pull/5524#issuecomment-2472843518 Thank you very much for your time I will take extra care in future PRs. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
LauraXia123 commented on code in PR #5524:
URL: https://github.com/apache/gravitino/pull/5524#discussion_r1839681059
##
web/web/src/app/metalakes/metalake/rightContent/CreateTableDialog.js:
##
@@ -0,0 +1,688 @@
+/*
+ * 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.
+ */
+
+/**
+ * CreateTableDialog component
+ *
+ * A dialog component for creating and editing tables in a metalake catalog.
+ *
+ * Features:
+ * - Create new tables or edit existing ones
+ * - Configure table name, comment and properties
+ * - Add/edit/remove table columns with name, type, nullable, and comment
fields
+ * - Add/edit/remove custom table properties
+ * - Form validation using yup schema
+ * - Responsive dialog layout
+ *
+ * Props:
+ * @param {boolean} open - Controls dialog visibility
+ * @param {function} setOpen - Function to update dialog visibility
+ * @param {string} type - Dialog mode: 'create' or 'edit'
+ * @param {object} data - Table data for edit mode
+ */
+
+'use client'
+
+// Import required React hooks
+import { useState, forwardRef, useEffect, Fragment } from 'react'
+
+// Import Material UI components
+import {
+ Box,
+ Grid,
+ Button,
+ Dialog,
+ TextField,
+ Typography,
+ DialogContent,
+ DialogActions,
+ IconButton,
+ Fade,
+ FormControl,
+ FormHelperText,
+ Switch,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Paper,
+ Select,
+ MenuItem
+} from '@mui/material'
+
+// Import custom components
+import Icon from '@/components/Icon'
+
+// Import Redux hooks and actions
+import { useAppDispatch } from '@/lib/hooks/useStore'
+import { createTable, updateTable } from '@/lib/store/metalakes'
+
+// Import form validation libraries
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+// Import utility functions and constants
+import { groupBy } from 'lodash-es'
+import { genUpdates } from '@/lib/utils'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
+import { useSearchParams } from 'next/navigation'
+import { relationalTypes } from '@/lib/utils/initial'
+
+// Default form values
+const defaultFormValues = {
+ name: '',
+ comment: '',
+ columns: [],
+ propItems: []
+}
+
+// Form validation schema
+const schema = yup.object().shape({
+ name: yup.string().required().matches(nameRegex, nameRegexDesc),
+ columns: yup.array().of(
+yup.object().shape({
+ name: yup.string().required(),
+ type: yup.string().required(),
+ nullable: yup.boolean(),
+ comment: yup.string()
+})
+ ),
+ propItems: yup.array().of(
+yup.object().shape({
+ required: yup.boolean(),
+ key: yup.string().required(),
+ value: yup.string().when('required', {
+is: true,
+then: schema => schema.required()
+ })
+})
+ )
+})
+
+// Dialog transition component
+const Transition = forwardRef(function Transition(props, ref) {
+ return
+})
+
+/**
+ * Main CreateTableDialog component
+ * Handles creation and editing of tables with columns and properties
+ */
+const CreateTableDialog = props => {
+ // Destructure props
+ const { open, setOpen, type = 'create', data = {} } = props
+
+ // Get URL parameters
+ const searchParams = useSearchParams()
+ const metalake = searchParams.get('metalake')
+ const catalog = searchParams.get('catalog')
+ const catalogType = searchParams.get('type')
+ const schemaName = searchParams.get('schema')
+
+ // Component state
+ const [innerProps, setInnerProps] = useState([])
+ const [tableColumns, setTableColumns] = useState([{ name: '', type: '',
nullable: true, comment: '' }])
+ const [initialTableData, setInitialTableData] = useState()
+ const dispatch = useAppDispatch()
+
+ // Initialize form with react-hook-form
+ const {
+control,
+reset,
+setValue,
+getValues,
+handleSubmit,
+trigger,
+formState: { errors }
+ } = useForm({
+defaultValues: defaultFormValues,
+mode: 'all',
+resolver: yupResolver(schema)
+ })
+
+ /**
+ * Handle changes to property form fields
+ * Validates keys and checks for duplicates
+ */
+ const handlePropertyChange = ({ index, event })
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
orenccl commented on PR #5524: URL: https://github.com/apache/gravitino/pull/5524#issuecomment-2472685160 @LauraXia123 Apologies—I should have tested the table creation feature after the latest commit. I've corrected the issue and added functionality to hide the delete button when there is only one column. Additionally, I set a default value for the column. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
LauraXia123 commented on PR #5524: URL: https://github.com/apache/gravitino/pull/5524#issuecomment-2472538086 https://github.com/user-attachments/assets/a8b727dc-b1fa-486b-b2c8-6cb834441f05";> Failed to create, probably because the submitted data should be deleted `hasDuplicateName` field. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
orenccl commented on code in PR #5524:
URL: https://github.com/apache/gravitino/pull/5524#discussion_r1837616085
##
web/web/src/app/metalakes/metalake/rightContent/CreateTableDialog.js:
##
@@ -0,0 +1,643 @@
+/*
+ * 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.
+ */
+
+/**
+ * CreateTableDialog component
+ *
+ * A dialog component for creating and editing tables in a metalake catalog.
+ *
+ * Features:
+ * - Create new tables or edit existing ones
+ * - Configure table name, comment and properties
+ * - Add/edit/remove table columns with name, type, nullable, and comment
fields
+ * - Add/edit/remove custom table properties
+ * - Form validation using yup schema
+ * - Responsive dialog layout
+ *
+ * Props:
+ * @param {boolean} open - Controls dialog visibility
+ * @param {function} setOpen - Function to update dialog visibility
+ * @param {string} type - Dialog mode: 'create' or 'edit'
+ * @param {object} data - Table data for edit mode
+ */
+
+'use client'
+
+// Import required React hooks
+import { useState, forwardRef, useEffect, Fragment } from 'react'
+
+// Import Material UI components
+import {
+ Box,
+ Grid,
+ Button,
+ Dialog,
+ TextField,
+ Typography,
+ DialogContent,
+ DialogActions,
+ IconButton,
+ Fade,
+ FormControl,
+ FormHelperText,
+ Switch,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Paper,
+ Select,
+ MenuItem
+} from '@mui/material'
+
+// Import custom components
+import Icon from '@/components/Icon'
+
+// Import Redux hooks and actions
+import { useAppDispatch } from '@/lib/hooks/useStore'
+import { createTable, updateTable } from '@/lib/store/metalakes'
+
+// Import form validation libraries
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+// Import utility functions and constants
+import { groupBy } from 'lodash-es'
+import { genUpdates } from '@/lib/utils'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
+import { useSearchParams } from 'next/navigation'
+import { relationalTypes } from '@/lib/utils/initial'
+
+// Default form values
+const defaultFormValues = {
+ name: '',
+ comment: '',
+ columns: [],
+ propItems: []
+}
+
+// Form validation schema
+const schema = yup.object().shape({
+ name: yup.string().required().matches(nameRegex, nameRegexDesc),
+ columns: yup.array().of(
+yup.object().shape({
+ name: yup.string().required(),
+ type: yup.string().required(),
+ nullable: yup.boolean(),
+ comment: yup.string()
+})
+ ),
+ propItems: yup.array().of(
+yup.object().shape({
+ required: yup.boolean(),
+ key: yup.string().required(),
+ value: yup.string().when('required', {
+is: true,
+then: schema => schema.required()
+ })
+})
+ )
+})
+
+// Dialog transition component
+const Transition = forwardRef(function Transition(props, ref) {
+ return
+})
+
+/**
+ * Main CreateTableDialog component
+ * Handles creation and editing of tables with columns and properties
+ */
+const CreateTableDialog = props => {
+ // Destructure props
+ const { open, setOpen, type = 'create', data = {} } = props
+
+ // Get URL parameters
+ const searchParams = useSearchParams()
+ const metalake = searchParams.get('metalake')
+ const catalog = searchParams.get('catalog')
+ const catalogType = searchParams.get('type')
+ const schemaName = searchParams.get('schema')
+
+ // Component state
+ const [innerProps, setInnerProps] = useState([])
+ const [tableColumns, setTableColumns] = useState([])
+ const [initialTableData, setInitialTableData] = useState()
+ const dispatch = useAppDispatch()
+
+ // Initialize form with react-hook-form
+ const {
+control,
+reset,
+setValue,
+getValues,
+handleSubmit,
+trigger,
+formState: { errors }
+ } = useForm({
+defaultValues: defaultFormValues,
+mode: 'all',
+resolver: yupResolver(schema)
+ })
+
+ /**
+ * Handle changes to property form fields
+ * Validates keys and checks for duplicates
+ */
+ const handlePropertyChange = ({ index, event }) => {
+let updatedProps = [...innerProps]
+updat
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
orenccl commented on code in PR #5524:
URL: https://github.com/apache/gravitino/pull/5524#discussion_r1837616085
##
web/web/src/app/metalakes/metalake/rightContent/CreateTableDialog.js:
##
@@ -0,0 +1,643 @@
+/*
+ * 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.
+ */
+
+/**
+ * CreateTableDialog component
+ *
+ * A dialog component for creating and editing tables in a metalake catalog.
+ *
+ * Features:
+ * - Create new tables or edit existing ones
+ * - Configure table name, comment and properties
+ * - Add/edit/remove table columns with name, type, nullable, and comment
fields
+ * - Add/edit/remove custom table properties
+ * - Form validation using yup schema
+ * - Responsive dialog layout
+ *
+ * Props:
+ * @param {boolean} open - Controls dialog visibility
+ * @param {function} setOpen - Function to update dialog visibility
+ * @param {string} type - Dialog mode: 'create' or 'edit'
+ * @param {object} data - Table data for edit mode
+ */
+
+'use client'
+
+// Import required React hooks
+import { useState, forwardRef, useEffect, Fragment } from 'react'
+
+// Import Material UI components
+import {
+ Box,
+ Grid,
+ Button,
+ Dialog,
+ TextField,
+ Typography,
+ DialogContent,
+ DialogActions,
+ IconButton,
+ Fade,
+ FormControl,
+ FormHelperText,
+ Switch,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Paper,
+ Select,
+ MenuItem
+} from '@mui/material'
+
+// Import custom components
+import Icon from '@/components/Icon'
+
+// Import Redux hooks and actions
+import { useAppDispatch } from '@/lib/hooks/useStore'
+import { createTable, updateTable } from '@/lib/store/metalakes'
+
+// Import form validation libraries
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+// Import utility functions and constants
+import { groupBy } from 'lodash-es'
+import { genUpdates } from '@/lib/utils'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
+import { useSearchParams } from 'next/navigation'
+import { relationalTypes } from '@/lib/utils/initial'
+
+// Default form values
+const defaultFormValues = {
+ name: '',
+ comment: '',
+ columns: [],
+ propItems: []
+}
+
+// Form validation schema
+const schema = yup.object().shape({
+ name: yup.string().required().matches(nameRegex, nameRegexDesc),
+ columns: yup.array().of(
+yup.object().shape({
+ name: yup.string().required(),
+ type: yup.string().required(),
+ nullable: yup.boolean(),
+ comment: yup.string()
+})
+ ),
+ propItems: yup.array().of(
+yup.object().shape({
+ required: yup.boolean(),
+ key: yup.string().required(),
+ value: yup.string().when('required', {
+is: true,
+then: schema => schema.required()
+ })
+})
+ )
+})
+
+// Dialog transition component
+const Transition = forwardRef(function Transition(props, ref) {
+ return
+})
+
+/**
+ * Main CreateTableDialog component
+ * Handles creation and editing of tables with columns and properties
+ */
+const CreateTableDialog = props => {
+ // Destructure props
+ const { open, setOpen, type = 'create', data = {} } = props
+
+ // Get URL parameters
+ const searchParams = useSearchParams()
+ const metalake = searchParams.get('metalake')
+ const catalog = searchParams.get('catalog')
+ const catalogType = searchParams.get('type')
+ const schemaName = searchParams.get('schema')
+
+ // Component state
+ const [innerProps, setInnerProps] = useState([])
+ const [tableColumns, setTableColumns] = useState([])
+ const [initialTableData, setInitialTableData] = useState()
+ const dispatch = useAppDispatch()
+
+ // Initialize form with react-hook-form
+ const {
+control,
+reset,
+setValue,
+getValues,
+handleSubmit,
+trigger,
+formState: { errors }
+ } = useForm({
+defaultValues: defaultFormValues,
+mode: 'all',
+resolver: yupResolver(schema)
+ })
+
+ /**
+ * Handle changes to property form fields
+ * Validates keys and checks for duplicates
+ */
+ const handlePropertyChange = ({ index, event }) => {
+let updatedProps = [...innerProps]
+updat
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
orenccl commented on code in PR #5524:
URL: https://github.com/apache/gravitino/pull/5524#discussion_r1837617562
##
web/web/src/app/metalakes/metalake/rightContent/CreateTableDialog.js:
##
@@ -0,0 +1,650 @@
+/*
+ * 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.
+ */
+
+/**
+ * CreateTableDialog component
+ *
+ * A dialog component for creating and editing tables in a metalake catalog.
+ *
+ * Features:
+ * - Create new tables or edit existing ones
+ * - Configure table name, comment and properties
+ * - Add/edit/remove table columns with name, type, nullable, and comment
fields
+ * - Add/edit/remove custom table properties
+ * - Form validation using yup schema
+ * - Responsive dialog layout
+ *
+ * Props:
+ * @param {boolean} open - Controls dialog visibility
+ * @param {function} setOpen - Function to update dialog visibility
+ * @param {string} type - Dialog mode: 'create' or 'edit'
+ * @param {object} data - Table data for edit mode
+ */
+
+'use client'
+
+// Import required React hooks
+import { useState, forwardRef, useEffect, Fragment } from 'react'
+
+// Import Material UI components
+import {
+ Box,
+ Grid,
+ Button,
+ Dialog,
+ TextField,
+ Typography,
+ DialogContent,
+ DialogActions,
+ IconButton,
+ Fade,
+ FormControl,
+ FormHelperText,
+ Switch,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Paper,
+ Select,
+ MenuItem
+} from '@mui/material'
+
+// Import custom components
+import Icon from '@/components/Icon'
+
+// Import Redux hooks and actions
+import { useAppDispatch } from '@/lib/hooks/useStore'
+import { createTable, updateTable } from '@/lib/store/metalakes'
+
+// Import form validation libraries
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+// Import utility functions and constants
+import { groupBy } from 'lodash-es'
+import { genUpdates } from '@/lib/utils'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
+import { useSearchParams } from 'next/navigation'
+import { relationalTypes } from '@/lib/utils/initial'
+
+// Default form values
+const defaultFormValues = {
+ name: '',
+ comment: '',
+ columns: [],
+ propItems: []
+}
+
+// Form validation schema
+const schema = yup.object().shape({
+ name: yup.string().required().matches(nameRegex, nameRegexDesc),
+ columns: yup.array().of(
+yup.object().shape({
+ name: yup.string().required(),
+ type: yup.string().required(),
+ nullable: yup.boolean(),
+ comment: yup.string()
+})
+ ),
+ propItems: yup.array().of(
+yup.object().shape({
+ required: yup.boolean(),
+ key: yup.string().required(),
+ value: yup.string().when('required', {
+is: true,
+then: schema => schema.required()
+ })
+})
+ )
+})
+
+// Dialog transition component
+const Transition = forwardRef(function Transition(props, ref) {
+ return
+})
+
+/**
+ * Main CreateTableDialog component
+ * Handles creation and editing of tables with columns and properties
+ */
+const CreateTableDialog = props => {
+ // Destructure props
+ const { open, setOpen, type = 'create', data = {} } = props
+
+ // Get URL parameters
+ const searchParams = useSearchParams()
+ const metalake = searchParams.get('metalake')
+ const catalog = searchParams.get('catalog')
+ const catalogType = searchParams.get('type')
+ const schemaName = searchParams.get('schema')
+
+ // Component state
+ const [innerProps, setInnerProps] = useState([])
+ const [tableColumns, setTableColumns] = useState([])
+ const [initialTableData, setInitialTableData] = useState()
+ const dispatch = useAppDispatch()
+
+ // Initialize form with react-hook-form
+ const {
+control,
+reset,
+setValue,
+getValues,
+handleSubmit,
+trigger,
+formState: { errors }
+ } = useForm({
+defaultValues: defaultFormValues,
+mode: 'all',
+resolver: yupResolver(schema)
+ })
+
+ /**
+ * Handle changes to property form fields
+ * Validates keys and checks for duplicates
+ */
+ const handlePropertyChange = ({ index, event }) => {
+let updatedProps = [...innerProps]
+updat
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
LauraXia123 commented on code in PR #5524:
URL: https://github.com/apache/gravitino/pull/5524#discussion_r1837560213
##
web/web/src/app/metalakes/metalake/rightContent/CreateTableDialog.js:
##
@@ -0,0 +1,643 @@
+/*
+ * 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.
+ */
+
+/**
+ * CreateTableDialog component
+ *
+ * A dialog component for creating and editing tables in a metalake catalog.
+ *
+ * Features:
+ * - Create new tables or edit existing ones
+ * - Configure table name, comment and properties
+ * - Add/edit/remove table columns with name, type, nullable, and comment
fields
+ * - Add/edit/remove custom table properties
+ * - Form validation using yup schema
+ * - Responsive dialog layout
+ *
+ * Props:
+ * @param {boolean} open - Controls dialog visibility
+ * @param {function} setOpen - Function to update dialog visibility
+ * @param {string} type - Dialog mode: 'create' or 'edit'
+ * @param {object} data - Table data for edit mode
+ */
+
+'use client'
+
+// Import required React hooks
+import { useState, forwardRef, useEffect, Fragment } from 'react'
+
+// Import Material UI components
+import {
+ Box,
+ Grid,
+ Button,
+ Dialog,
+ TextField,
+ Typography,
+ DialogContent,
+ DialogActions,
+ IconButton,
+ Fade,
+ FormControl,
+ FormHelperText,
+ Switch,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Paper,
+ Select,
+ MenuItem
+} from '@mui/material'
+
+// Import custom components
+import Icon from '@/components/Icon'
+
+// Import Redux hooks and actions
+import { useAppDispatch } from '@/lib/hooks/useStore'
+import { createTable, updateTable } from '@/lib/store/metalakes'
+
+// Import form validation libraries
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+// Import utility functions and constants
+import { groupBy } from 'lodash-es'
+import { genUpdates } from '@/lib/utils'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
+import { useSearchParams } from 'next/navigation'
+import { relationalTypes } from '@/lib/utils/initial'
+
+// Default form values
+const defaultFormValues = {
+ name: '',
+ comment: '',
+ columns: [],
+ propItems: []
+}
+
+// Form validation schema
+const schema = yup.object().shape({
+ name: yup.string().required().matches(nameRegex, nameRegexDesc),
+ columns: yup.array().of(
+yup.object().shape({
+ name: yup.string().required(),
+ type: yup.string().required(),
+ nullable: yup.boolean(),
+ comment: yup.string()
+})
+ ),
+ propItems: yup.array().of(
+yup.object().shape({
+ required: yup.boolean(),
+ key: yup.string().required(),
+ value: yup.string().when('required', {
+is: true,
+then: schema => schema.required()
+ })
+})
+ )
+})
+
+// Dialog transition component
+const Transition = forwardRef(function Transition(props, ref) {
+ return
+})
+
+/**
+ * Main CreateTableDialog component
+ * Handles creation and editing of tables with columns and properties
+ */
+const CreateTableDialog = props => {
+ // Destructure props
+ const { open, setOpen, type = 'create', data = {} } = props
+
+ // Get URL parameters
+ const searchParams = useSearchParams()
+ const metalake = searchParams.get('metalake')
+ const catalog = searchParams.get('catalog')
+ const catalogType = searchParams.get('type')
+ const schemaName = searchParams.get('schema')
+
+ // Component state
+ const [innerProps, setInnerProps] = useState([])
+ const [tableColumns, setTableColumns] = useState([])
+ const [initialTableData, setInitialTableData] = useState()
+ const dispatch = useAppDispatch()
+
+ // Initialize form with react-hook-form
+ const {
+control,
+reset,
+setValue,
+getValues,
+handleSubmit,
+trigger,
+formState: { errors }
+ } = useForm({
+defaultValues: defaultFormValues,
+mode: 'all',
+resolver: yupResolver(schema)
+ })
+
+ /**
+ * Handle changes to property form fields
+ * Validates keys and checks for duplicates
+ */
+ const handlePropertyChange = ({ index, event }) => {
+let updatedProps = [...innerProps]
+u
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
LauraXia123 commented on code in PR #5524:
URL: https://github.com/apache/gravitino/pull/5524#discussion_r1837563514
##
web/web/src/app/metalakes/metalake/rightContent/CreateTableDialog.js:
##
@@ -0,0 +1,650 @@
+/*
+ * 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.
+ */
+
+/**
+ * CreateTableDialog component
+ *
+ * A dialog component for creating and editing tables in a metalake catalog.
+ *
+ * Features:
+ * - Create new tables or edit existing ones
+ * - Configure table name, comment and properties
+ * - Add/edit/remove table columns with name, type, nullable, and comment
fields
+ * - Add/edit/remove custom table properties
+ * - Form validation using yup schema
+ * - Responsive dialog layout
+ *
+ * Props:
+ * @param {boolean} open - Controls dialog visibility
+ * @param {function} setOpen - Function to update dialog visibility
+ * @param {string} type - Dialog mode: 'create' or 'edit'
+ * @param {object} data - Table data for edit mode
+ */
+
+'use client'
+
+// Import required React hooks
+import { useState, forwardRef, useEffect, Fragment } from 'react'
+
+// Import Material UI components
+import {
+ Box,
+ Grid,
+ Button,
+ Dialog,
+ TextField,
+ Typography,
+ DialogContent,
+ DialogActions,
+ IconButton,
+ Fade,
+ FormControl,
+ FormHelperText,
+ Switch,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Paper,
+ Select,
+ MenuItem
+} from '@mui/material'
+
+// Import custom components
+import Icon from '@/components/Icon'
+
+// Import Redux hooks and actions
+import { useAppDispatch } from '@/lib/hooks/useStore'
+import { createTable, updateTable } from '@/lib/store/metalakes'
+
+// Import form validation libraries
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+// Import utility functions and constants
+import { groupBy } from 'lodash-es'
+import { genUpdates } from '@/lib/utils'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
+import { useSearchParams } from 'next/navigation'
+import { relationalTypes } from '@/lib/utils/initial'
+
+// Default form values
+const defaultFormValues = {
+ name: '',
+ comment: '',
+ columns: [],
+ propItems: []
+}
+
+// Form validation schema
+const schema = yup.object().shape({
+ name: yup.string().required().matches(nameRegex, nameRegexDesc),
+ columns: yup.array().of(
+yup.object().shape({
+ name: yup.string().required(),
+ type: yup.string().required(),
+ nullable: yup.boolean(),
+ comment: yup.string()
+})
+ ),
+ propItems: yup.array().of(
+yup.object().shape({
+ required: yup.boolean(),
+ key: yup.string().required(),
+ value: yup.string().when('required', {
+is: true,
+then: schema => schema.required()
+ })
+})
+ )
+})
+
+// Dialog transition component
+const Transition = forwardRef(function Transition(props, ref) {
+ return
+})
+
+/**
+ * Main CreateTableDialog component
+ * Handles creation and editing of tables with columns and properties
+ */
+const CreateTableDialog = props => {
+ // Destructure props
+ const { open, setOpen, type = 'create', data = {} } = props
+
+ // Get URL parameters
+ const searchParams = useSearchParams()
+ const metalake = searchParams.get('metalake')
+ const catalog = searchParams.get('catalog')
+ const catalogType = searchParams.get('type')
+ const schemaName = searchParams.get('schema')
+
+ // Component state
+ const [innerProps, setInnerProps] = useState([])
+ const [tableColumns, setTableColumns] = useState([])
+ const [initialTableData, setInitialTableData] = useState()
+ const dispatch = useAppDispatch()
+
+ // Initialize form with react-hook-form
+ const {
+control,
+reset,
+setValue,
+getValues,
+handleSubmit,
+trigger,
+formState: { errors }
+ } = useForm({
+defaultValues: defaultFormValues,
+mode: 'all',
+resolver: yupResolver(schema)
+ })
+
+ /**
+ * Handle changes to property form fields
+ * Validates keys and checks for duplicates
+ */
+ const handlePropertyChange = ({ index, event }) => {
+let updatedProps = [...innerProps]
+u
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
orenccl commented on code in PR #5524:
URL: https://github.com/apache/gravitino/pull/5524#discussion_r1837469843
##
web/web/src/app/metalakes/metalake/rightContent/CreateTableDialog.js:
##
@@ -0,0 +1,643 @@
+/*
+ * 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.
+ */
+
+/**
+ * CreateTableDialog component
+ *
+ * A dialog component for creating and editing tables in a metalake catalog.
+ *
+ * Features:
+ * - Create new tables or edit existing ones
+ * - Configure table name, comment and properties
+ * - Add/edit/remove table columns with name, type, nullable, and comment
fields
+ * - Add/edit/remove custom table properties
+ * - Form validation using yup schema
+ * - Responsive dialog layout
+ *
+ * Props:
+ * @param {boolean} open - Controls dialog visibility
+ * @param {function} setOpen - Function to update dialog visibility
+ * @param {string} type - Dialog mode: 'create' or 'edit'
+ * @param {object} data - Table data for edit mode
+ */
+
+'use client'
+
+// Import required React hooks
+import { useState, forwardRef, useEffect, Fragment } from 'react'
+
+// Import Material UI components
+import {
+ Box,
+ Grid,
+ Button,
+ Dialog,
+ TextField,
+ Typography,
+ DialogContent,
+ DialogActions,
+ IconButton,
+ Fade,
+ FormControl,
+ FormHelperText,
+ Switch,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Paper,
+ Select,
+ MenuItem
+} from '@mui/material'
+
+// Import custom components
+import Icon from '@/components/Icon'
+
+// Import Redux hooks and actions
+import { useAppDispatch } from '@/lib/hooks/useStore'
+import { createTable, updateTable } from '@/lib/store/metalakes'
+
+// Import form validation libraries
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+// Import utility functions and constants
+import { groupBy } from 'lodash-es'
+import { genUpdates } from '@/lib/utils'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
+import { useSearchParams } from 'next/navigation'
+import { relationalTypes } from '@/lib/utils/initial'
+
+// Default form values
+const defaultFormValues = {
+ name: '',
+ comment: '',
+ columns: [],
+ propItems: []
+}
+
+// Form validation schema
+const schema = yup.object().shape({
+ name: yup.string().required().matches(nameRegex, nameRegexDesc),
+ columns: yup.array().of(
+yup.object().shape({
+ name: yup.string().required(),
+ type: yup.string().required(),
+ nullable: yup.boolean(),
+ comment: yup.string()
+})
+ ),
+ propItems: yup.array().of(
+yup.object().shape({
+ required: yup.boolean(),
+ key: yup.string().required(),
+ value: yup.string().when('required', {
+is: true,
+then: schema => schema.required()
+ })
+})
+ )
+})
+
+// Dialog transition component
+const Transition = forwardRef(function Transition(props, ref) {
+ return
+})
+
+/**
+ * Main CreateTableDialog component
+ * Handles creation and editing of tables with columns and properties
+ */
+const CreateTableDialog = props => {
+ // Destructure props
+ const { open, setOpen, type = 'create', data = {} } = props
+
+ // Get URL parameters
+ const searchParams = useSearchParams()
+ const metalake = searchParams.get('metalake')
+ const catalog = searchParams.get('catalog')
+ const catalogType = searchParams.get('type')
+ const schemaName = searchParams.get('schema')
+
+ // Component state
+ const [innerProps, setInnerProps] = useState([])
+ const [tableColumns, setTableColumns] = useState([])
+ const [initialTableData, setInitialTableData] = useState()
+ const dispatch = useAppDispatch()
+
+ // Initialize form with react-hook-form
+ const {
+control,
+reset,
+setValue,
+getValues,
+handleSubmit,
+trigger,
+formState: { errors }
+ } = useForm({
+defaultValues: defaultFormValues,
+mode: 'all',
+resolver: yupResolver(schema)
+ })
+
+ /**
+ * Handle changes to property form fields
+ * Validates keys and checks for duplicates
+ */
+ const handlePropertyChange = ({ index, event }) => {
+let updatedProps = [...innerProps]
+updat
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
orenccl commented on code in PR #5524:
URL: https://github.com/apache/gravitino/pull/5524#discussion_r1836894003
##
web/web/src/app/metalakes/metalake/rightContent/CreateTableDialog.js:
##
@@ -0,0 +1,643 @@
+/*
+ * 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.
+ */
+
+/**
+ * CreateTableDialog component
+ *
+ * A dialog component for creating and editing tables in a metalake catalog.
+ *
+ * Features:
+ * - Create new tables or edit existing ones
+ * - Configure table name, comment and properties
+ * - Add/edit/remove table columns with name, type, nullable, and comment
fields
+ * - Add/edit/remove custom table properties
+ * - Form validation using yup schema
+ * - Responsive dialog layout
+ *
+ * Props:
+ * @param {boolean} open - Controls dialog visibility
+ * @param {function} setOpen - Function to update dialog visibility
+ * @param {string} type - Dialog mode: 'create' or 'edit'
+ * @param {object} data - Table data for edit mode
+ */
+
+'use client'
+
+// Import required React hooks
+import { useState, forwardRef, useEffect, Fragment } from 'react'
+
+// Import Material UI components
+import {
+ Box,
+ Grid,
+ Button,
+ Dialog,
+ TextField,
+ Typography,
+ DialogContent,
+ DialogActions,
+ IconButton,
+ Fade,
+ FormControl,
+ FormHelperText,
+ Switch,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Paper,
+ Select,
+ MenuItem
+} from '@mui/material'
+
+// Import custom components
+import Icon from '@/components/Icon'
+
+// Import Redux hooks and actions
+import { useAppDispatch } from '@/lib/hooks/useStore'
+import { createTable, updateTable } from '@/lib/store/metalakes'
+
+// Import form validation libraries
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+// Import utility functions and constants
+import { groupBy } from 'lodash-es'
+import { genUpdates } from '@/lib/utils'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
+import { useSearchParams } from 'next/navigation'
+import { relationalTypes } from '@/lib/utils/initial'
+
+// Default form values
+const defaultFormValues = {
+ name: '',
+ comment: '',
+ columns: [],
+ propItems: []
+}
+
+// Form validation schema
+const schema = yup.object().shape({
+ name: yup.string().required().matches(nameRegex, nameRegexDesc),
+ columns: yup.array().of(
+yup.object().shape({
+ name: yup.string().required(),
+ type: yup.string().required(),
+ nullable: yup.boolean(),
+ comment: yup.string()
+})
+ ),
+ propItems: yup.array().of(
+yup.object().shape({
+ required: yup.boolean(),
+ key: yup.string().required(),
+ value: yup.string().when('required', {
+is: true,
+then: schema => schema.required()
+ })
+})
+ )
+})
+
+// Dialog transition component
+const Transition = forwardRef(function Transition(props, ref) {
+ return
+})
+
+/**
+ * Main CreateTableDialog component
+ * Handles creation and editing of tables with columns and properties
+ */
+const CreateTableDialog = props => {
+ // Destructure props
+ const { open, setOpen, type = 'create', data = {} } = props
+
+ // Get URL parameters
+ const searchParams = useSearchParams()
+ const metalake = searchParams.get('metalake')
+ const catalog = searchParams.get('catalog')
+ const catalogType = searchParams.get('type')
+ const schemaName = searchParams.get('schema')
+
+ // Component state
+ const [innerProps, setInnerProps] = useState([])
+ const [tableColumns, setTableColumns] = useState([])
+ const [initialTableData, setInitialTableData] = useState()
+ const dispatch = useAppDispatch()
+
+ // Initialize form with react-hook-form
+ const {
+control,
+reset,
+setValue,
+getValues,
+handleSubmit,
+trigger,
+formState: { errors }
+ } = useForm({
+defaultValues: defaultFormValues,
+mode: 'all',
+resolver: yupResolver(schema)
+ })
+
+ /**
+ * Handle changes to property form fields
+ * Validates keys and checks for duplicates
+ */
+ const handlePropertyChange = ({ index, event }) => {
+let updatedProps = [...innerProps]
+updat
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
orenccl commented on code in PR #5524:
URL: https://github.com/apache/gravitino/pull/5524#discussion_r1835932363
##
web/web/src/app/metalakes/metalake/rightContent/CreateTableDialog.js:
##
@@ -0,0 +1,643 @@
+/*
+ * 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.
+ */
+
+/**
+ * CreateTableDialog component
+ *
+ * A dialog component for creating and editing tables in a metalake catalog.
+ *
+ * Features:
+ * - Create new tables or edit existing ones
+ * - Configure table name, comment and properties
+ * - Add/edit/remove table columns with name, type, nullable, and comment
fields
+ * - Add/edit/remove custom table properties
+ * - Form validation using yup schema
+ * - Responsive dialog layout
+ *
+ * Props:
+ * @param {boolean} open - Controls dialog visibility
+ * @param {function} setOpen - Function to update dialog visibility
+ * @param {string} type - Dialog mode: 'create' or 'edit'
+ * @param {object} data - Table data for edit mode
+ */
+
+'use client'
+
+// Import required React hooks
+import { useState, forwardRef, useEffect, Fragment } from 'react'
+
+// Import Material UI components
+import {
+ Box,
+ Grid,
+ Button,
+ Dialog,
+ TextField,
+ Typography,
+ DialogContent,
+ DialogActions,
+ IconButton,
+ Fade,
+ FormControl,
+ FormHelperText,
+ Switch,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Paper,
+ Select,
+ MenuItem
+} from '@mui/material'
+
+// Import custom components
+import Icon from '@/components/Icon'
+
+// Import Redux hooks and actions
+import { useAppDispatch } from '@/lib/hooks/useStore'
+import { createTable, updateTable } from '@/lib/store/metalakes'
+
+// Import form validation libraries
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+// Import utility functions and constants
+import { groupBy } from 'lodash-es'
+import { genUpdates } from '@/lib/utils'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
+import { useSearchParams } from 'next/navigation'
+import { relationalTypes } from '@/lib/utils/initial'
+
+// Default form values
+const defaultFormValues = {
+ name: '',
+ comment: '',
+ columns: [],
+ propItems: []
+}
+
+// Form validation schema
+const schema = yup.object().shape({
+ name: yup.string().required().matches(nameRegex, nameRegexDesc),
+ columns: yup.array().of(
+yup.object().shape({
+ name: yup.string().required(),
+ type: yup.string().required(),
+ nullable: yup.boolean(),
+ comment: yup.string()
+})
+ ),
+ propItems: yup.array().of(
+yup.object().shape({
+ required: yup.boolean(),
+ key: yup.string().required(),
+ value: yup.string().when('required', {
+is: true,
+then: schema => schema.required()
+ })
+})
+ )
+})
+
+// Dialog transition component
+const Transition = forwardRef(function Transition(props, ref) {
+ return
+})
+
+/**
+ * Main CreateTableDialog component
+ * Handles creation and editing of tables with columns and properties
+ */
+const CreateTableDialog = props => {
+ // Destructure props
+ const { open, setOpen, type = 'create', data = {} } = props
+
+ // Get URL parameters
+ const searchParams = useSearchParams()
+ const metalake = searchParams.get('metalake')
+ const catalog = searchParams.get('catalog')
+ const catalogType = searchParams.get('type')
+ const schemaName = searchParams.get('schema')
+
+ // Component state
+ const [innerProps, setInnerProps] = useState([])
+ const [tableColumns, setTableColumns] = useState([])
+ const [initialTableData, setInitialTableData] = useState()
+ const dispatch = useAppDispatch()
+
+ // Initialize form with react-hook-form
+ const {
+control,
+reset,
+setValue,
+getValues,
+handleSubmit,
+trigger,
+formState: { errors }
+ } = useForm({
+defaultValues: defaultFormValues,
+mode: 'all',
+resolver: yupResolver(schema)
+ })
+
+ /**
+ * Handle changes to property form fields
+ * Validates keys and checks for duplicates
+ */
+ const handlePropertyChange = ({ index, event }) => {
+let updatedProps = [...innerProps]
+updat
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
orenccl commented on code in PR #5524:
URL: https://github.com/apache/gravitino/pull/5524#discussion_r1835932363
##
web/web/src/app/metalakes/metalake/rightContent/CreateTableDialog.js:
##
@@ -0,0 +1,643 @@
+/*
+ * 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.
+ */
+
+/**
+ * CreateTableDialog component
+ *
+ * A dialog component for creating and editing tables in a metalake catalog.
+ *
+ * Features:
+ * - Create new tables or edit existing ones
+ * - Configure table name, comment and properties
+ * - Add/edit/remove table columns with name, type, nullable, and comment
fields
+ * - Add/edit/remove custom table properties
+ * - Form validation using yup schema
+ * - Responsive dialog layout
+ *
+ * Props:
+ * @param {boolean} open - Controls dialog visibility
+ * @param {function} setOpen - Function to update dialog visibility
+ * @param {string} type - Dialog mode: 'create' or 'edit'
+ * @param {object} data - Table data for edit mode
+ */
+
+'use client'
+
+// Import required React hooks
+import { useState, forwardRef, useEffect, Fragment } from 'react'
+
+// Import Material UI components
+import {
+ Box,
+ Grid,
+ Button,
+ Dialog,
+ TextField,
+ Typography,
+ DialogContent,
+ DialogActions,
+ IconButton,
+ Fade,
+ FormControl,
+ FormHelperText,
+ Switch,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Paper,
+ Select,
+ MenuItem
+} from '@mui/material'
+
+// Import custom components
+import Icon from '@/components/Icon'
+
+// Import Redux hooks and actions
+import { useAppDispatch } from '@/lib/hooks/useStore'
+import { createTable, updateTable } from '@/lib/store/metalakes'
+
+// Import form validation libraries
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+// Import utility functions and constants
+import { groupBy } from 'lodash-es'
+import { genUpdates } from '@/lib/utils'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
+import { useSearchParams } from 'next/navigation'
+import { relationalTypes } from '@/lib/utils/initial'
+
+// Default form values
+const defaultFormValues = {
+ name: '',
+ comment: '',
+ columns: [],
+ propItems: []
+}
+
+// Form validation schema
+const schema = yup.object().shape({
+ name: yup.string().required().matches(nameRegex, nameRegexDesc),
+ columns: yup.array().of(
+yup.object().shape({
+ name: yup.string().required(),
+ type: yup.string().required(),
+ nullable: yup.boolean(),
+ comment: yup.string()
+})
+ ),
+ propItems: yup.array().of(
+yup.object().shape({
+ required: yup.boolean(),
+ key: yup.string().required(),
+ value: yup.string().when('required', {
+is: true,
+then: schema => schema.required()
+ })
+})
+ )
+})
+
+// Dialog transition component
+const Transition = forwardRef(function Transition(props, ref) {
+ return
+})
+
+/**
+ * Main CreateTableDialog component
+ * Handles creation and editing of tables with columns and properties
+ */
+const CreateTableDialog = props => {
+ // Destructure props
+ const { open, setOpen, type = 'create', data = {} } = props
+
+ // Get URL parameters
+ const searchParams = useSearchParams()
+ const metalake = searchParams.get('metalake')
+ const catalog = searchParams.get('catalog')
+ const catalogType = searchParams.get('type')
+ const schemaName = searchParams.get('schema')
+
+ // Component state
+ const [innerProps, setInnerProps] = useState([])
+ const [tableColumns, setTableColumns] = useState([])
+ const [initialTableData, setInitialTableData] = useState()
+ const dispatch = useAppDispatch()
+
+ // Initialize form with react-hook-form
+ const {
+control,
+reset,
+setValue,
+getValues,
+handleSubmit,
+trigger,
+formState: { errors }
+ } = useForm({
+defaultValues: defaultFormValues,
+mode: 'all',
+resolver: yupResolver(schema)
+ })
+
+ /**
+ * Handle changes to property form fields
+ * Validates keys and checks for duplicates
+ */
+ const handlePropertyChange = ({ index, event }) => {
+let updatedProps = [...innerProps]
+updat
Re: [PR] [#5450] subtask(web): support web ui for creating table (basic column type) [gravitino]
LauraXia123 commented on code in PR #5524:
URL: https://github.com/apache/gravitino/pull/5524#discussion_r1835913759
##
web/web/src/app/metalakes/metalake/rightContent/CreateTableDialog.js:
##
@@ -0,0 +1,643 @@
+/*
+ * 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.
+ */
+
+/**
+ * CreateTableDialog component
+ *
+ * A dialog component for creating and editing tables in a metalake catalog.
+ *
+ * Features:
+ * - Create new tables or edit existing ones
+ * - Configure table name, comment and properties
+ * - Add/edit/remove table columns with name, type, nullable, and comment
fields
+ * - Add/edit/remove custom table properties
+ * - Form validation using yup schema
+ * - Responsive dialog layout
+ *
+ * Props:
+ * @param {boolean} open - Controls dialog visibility
+ * @param {function} setOpen - Function to update dialog visibility
+ * @param {string} type - Dialog mode: 'create' or 'edit'
+ * @param {object} data - Table data for edit mode
+ */
+
+'use client'
+
+// Import required React hooks
+import { useState, forwardRef, useEffect, Fragment } from 'react'
+
+// Import Material UI components
+import {
+ Box,
+ Grid,
+ Button,
+ Dialog,
+ TextField,
+ Typography,
+ DialogContent,
+ DialogActions,
+ IconButton,
+ Fade,
+ FormControl,
+ FormHelperText,
+ Switch,
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow,
+ Paper,
+ Select,
+ MenuItem
+} from '@mui/material'
+
+// Import custom components
+import Icon from '@/components/Icon'
+
+// Import Redux hooks and actions
+import { useAppDispatch } from '@/lib/hooks/useStore'
+import { createTable, updateTable } from '@/lib/store/metalakes'
+
+// Import form validation libraries
+import * as yup from 'yup'
+import { useForm, Controller } from 'react-hook-form'
+import { yupResolver } from '@hookform/resolvers/yup'
+
+// Import utility functions and constants
+import { groupBy } from 'lodash-es'
+import { genUpdates } from '@/lib/utils'
+import { nameRegex, nameRegexDesc, keyRegex } from '@/lib/utils/regex'
+import { useSearchParams } from 'next/navigation'
+import { relationalTypes } from '@/lib/utils/initial'
+
+// Default form values
+const defaultFormValues = {
+ name: '',
+ comment: '',
+ columns: [],
+ propItems: []
+}
+
+// Form validation schema
+const schema = yup.object().shape({
+ name: yup.string().required().matches(nameRegex, nameRegexDesc),
+ columns: yup.array().of(
+yup.object().shape({
+ name: yup.string().required(),
+ type: yup.string().required(),
+ nullable: yup.boolean(),
+ comment: yup.string()
+})
+ ),
+ propItems: yup.array().of(
+yup.object().shape({
+ required: yup.boolean(),
+ key: yup.string().required(),
+ value: yup.string().when('required', {
+is: true,
+then: schema => schema.required()
+ })
+})
+ )
+})
+
+// Dialog transition component
+const Transition = forwardRef(function Transition(props, ref) {
+ return
+})
+
+/**
+ * Main CreateTableDialog component
+ * Handles creation and editing of tables with columns and properties
+ */
+const CreateTableDialog = props => {
+ // Destructure props
+ const { open, setOpen, type = 'create', data = {} } = props
+
+ // Get URL parameters
+ const searchParams = useSearchParams()
+ const metalake = searchParams.get('metalake')
+ const catalog = searchParams.get('catalog')
+ const catalogType = searchParams.get('type')
+ const schemaName = searchParams.get('schema')
+
+ // Component state
+ const [innerProps, setInnerProps] = useState([])
+ const [tableColumns, setTableColumns] = useState([])
+ const [initialTableData, setInitialTableData] = useState()
+ const dispatch = useAppDispatch()
+
+ // Initialize form with react-hook-form
+ const {
+control,
+reset,
+setValue,
+getValues,
+handleSubmit,
+trigger,
+formState: { errors }
+ } = useForm({
+defaultValues: defaultFormValues,
+mode: 'all',
+resolver: yupResolver(schema)
+ })
+
+ /**
+ * Handle changes to property form fields
+ * Validates keys and checks for duplicates
+ */
+ const handlePropertyChange = ({ index, event }) => {
+let updatedProps = [...innerProps]
+u
