World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[MINOR] fix(web-v2): Normalize service admins configuration (#12046)
gaohong64009ee93c77
diff --git a/web-v2/web/src/app/metalakes/page.js b/web-v2/web/src/app/metalakes/page.jsindex 183b04a329..1f9c468846 100644--- a/web-v2/web/src/app/metalakes/page.js+++ b/web-v2/web/src/app/metalakes/page.js@@ -37,6 +37,7 @@ import {} from '@/lib/store/metalakes'import { to } from '@/lib/utils'import { formatToDateTime } from '@/lib/utils/date'+import { normalizeServiceAdmins } from '@/lib/utils/serviceAdmins'import Icons from '@/components/Icons'import GetOwner from '@/components/GetOwner'import PropertiesContent from '@/components/PropertiesContent'@@ -70,7 +71,7 @@ const MetalakeList = () => {const [ownerRefreshKey, setOwnerRefreshKey] = useState(0)const auth = useAppSelector(state => state.auth)const { serviceAdmins, authUser, anthEnable } = auth- const admins = Array.isArray(serviceAdmins) ? serviceAdmins : (serviceAdmins || '').split(',')+ const admins = normalizeServiceAdmins(serviceAdmins)const isServiceAdmin = admins.includes(authUser?.name)const dispatch = useAppDispatch()const store = useAppSelector(state => state.metalakes)diff --git a/web-v2/web/src/app/rootLayout/UserSetting.js b/web-v2/web/src/app/rootLayout/UserSetting.jsindex d3041ae2a8..a4a8fc251e 100644--- a/web-v2/web/src/app/rootLayout/UserSetting.js+++ b/web-v2/web/src/app/rootLayout/UserSetting.js@@ -24,6 +24,7 @@ import { LogoutOutlined, PlusOutlined, UserOutlined } from '@ant-design/icons'import { Avatar, Dropdown, Tooltip } from 'antd'import { usePathname, useSearchParams, useRouter } from 'next/navigation'import { cn } from '@/lib/utils/tailwind'+import { normalizeServiceAdmins } from '@/lib/utils/serviceAdmins'import { useAppSelector, useAppDispatch } from '@/lib/hooks/useStore'import Loading from '@/components/Loading'import { fetchMetalakes, resetMetalakeStore } from '@/lib/store/metalakes'@@ -41,7 +42,7 @@ export default function UserSetting() {const [showLogoutButton, setShowLogoutButton] = useState(false)const auth = useAppSelector(state => state.auth)const { serviceAdmins, authUser, anthEnable } = auth- const admins = Array.isArray(serviceAdmins) ? serviceAdmins : (serviceAdmins || '').split(',')+ const admins = normalizeServiceAdmins(serviceAdmins)const isServiceAdmin = admins.includes(authUser?.name)const [session, setSession] = useState({})const router = useRouter()diff --git a/web-v2/web/src/lib/utils/serviceAdmins.js b/web-v2/web/src/lib/utils/serviceAdmins.jsnew file mode 100644index 0000000000..43717f9471--- /dev/null+++ b/web-v2/web/src/lib/utils/serviceAdmins.js@@ -0,0 +1,30 @@+/*+ * 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.+ */++export const normalizeServiceAdmins = serviceAdmins => {+ if (Array.isArray(serviceAdmins)) {+ return serviceAdmins+ }++ if (typeof serviceAdmins === 'string') {+ return serviceAdmins.split(',')+ }++ return []+}