World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#2480][#2698]feat(web): add metalake select to the right-up corner (#2679)
Qian Xiaf6c46a08c05e
diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageTest.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageTest.javaindex e439977152..749c605c78 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageTest.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/CatalogsPageTest.java@@ -28,6 +28,7 @@ public class CatalogsPageTest extends AbstractWebIT {CatalogsPage catalogsPage = new CatalogsPage();private static final String metalakeName = "metalake_name";+ private static final String metalakeSelectName = "metalake_select_name";String catalogName = "catalog_name";String modifiedCatalogName = catalogName + "_edited";String schemaName = "default";@@ -63,6 +64,12 @@ public class CatalogsPageTest extends AbstractWebIT {clickAndWait(metalakePage.createMetalakeBtn);metalakePage.setMetalakeNameField(metalakeName);clickAndWait(metalakePage.submitHandleMetalakeBtn);++ // Create another metalake for select option+ clickAndWait(metalakePage.createMetalakeBtn);+ metalakePage.setMetalakeNameField(metalakeSelectName);+ clickAndWait(metalakePage.submitHandleMetalakeBtn);+metalakePage.clickMetalakeLink(metalakeName);// Create catalogclickAndWait(catalogsPage.createCatalogBtn);@@ -145,6 +152,16 @@ public class CatalogsPageTest extends AbstractWebIT {@Test@Order(9)+ public void testSelectMetalake() throws InterruptedException {+ catalogsPage.metalakeSelectChange(metalakeSelectName);+ Assertions.assertTrue(catalogsPage.verifyEmptyCatalog());++ catalogsPage.metalakeSelectChange(metalakeName);+ Assertions.assertTrue(catalogsPage.verifyCreateHiveCatalog(modifiedCatalogName));+ }++ @Test+ @Order(10)public void testDeleteCatalog() throws InterruptedException {catalogsPage.clickBreadCrumbsToCatalogs();catalogsPage.clickDeleteCatalogBtn(modifiedCatalogName);@@ -153,7 +170,7 @@ public class CatalogsPageTest extends AbstractWebIT {}@Test- @Order(10)+ @Order(11)public void testBackHomePage() throws InterruptedException {clickAndWait(catalogsPage.backHomeBtn);Assertions.assertTrue(catalogsPage.verifyBackHomePage());diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/pages/CatalogsPage.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/pages/CatalogsPage.javaindex 5c22a9be22..4df998edf2 100644--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/pages/CatalogsPage.java+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/pages/CatalogsPage.java@@ -23,6 +23,9 @@ public class CatalogsPage extends AbstractWebIT {@FindBy(xpath = "//*[@data-refer='back-home-btn']")public WebElement backHomeBtn;+ @FindBy(xpath = "//*[@data-refer='select-metalake']")+ public WebElement metalakeSelect;+@FindBy(xpath = "//div[@data-refer='table-grid']")public WebElement tableGrid;@@ -90,6 +93,17 @@ public class CatalogsPage extends AbstractWebIT {PageFactory.initElements(driver, this);}+ public void metalakeSelectChange(String metalakeName) {+ try {+ clickAndWait(metalakeSelect);+ String keyPath = "//li[@data-refer='select-option-" + metalakeName + "']";+ WebElement selectOption = driver.findElement(By.xpath(keyPath));+ clickAndWait(selectOption);+ } catch (Exception e) {+ LOG.error(e.getMessage(), e);+ }+ }+public void setCatalogNameField(String nameField) {try {WebElement catalogNameFieldInput = catalogNameField.findElement(By.tagName("input"));diff --git a/web/src/app/rootLayout/AppBar.js b/web/src/app/rootLayout/AppBar.jsindex 20bab9b451..765fb47050 100644--- a/web/src/app/rootLayout/AppBar.js+++ b/web/src/app/rootLayout/AppBar.js@@ -8,12 +8,43 @@import Link from 'next/link'import Image from 'next/image'-import { Box, AppBar as MuiAppBar, Toolbar, Stack, Typography } from '@mui/material'+import {+ Box,+ AppBar as MuiAppBar,+ Toolbar,+ Stack,+ Typography,+ FormControl,+ InputLabel,+ Select,+ MenuItem+} from '@mui/material'import VersionView from './VersionView'import LogoutButton from './Logout'+import { useSearchParams } from 'next/navigation'+import { useRouter } from 'next/navigation'+import { useAppSelector, useAppDispatch } from '@/lib/hooks/useStore'+import { fetchMetalakes } from '@/lib/store/metalakes'++import { useState, useEffect } from 'react'const AppBar = () => {+ const searchParams = useSearchParams()+ const metalake = searchParams.get('metalake')+ const store = useAppSelector(state => state.metalakes)+ const dispatch = useAppDispatch()+ const [metalakes, setMetalakes] = useState([])+ const router = useRouter()++ useEffect(() => {+ if (!store.metalakes.length) {+ dispatch(fetchMetalakes())+ }+ const metalakeItems = store.metalakes.map(i => i.name)+ setMetalakes(metalakeItems)+ }, [store.metalakes])+return (<MuiAppBarelevation={6}@@ -43,6 +74,31 @@ const AppBar = () => {</Link><Box className={'app-bar-content-right twc-flex twc-items-center'}><Stack direction='row' spacing={2} alignItems='center'>+ {metalake ? (+ <FormControl fullWidth size='small'>+ <InputLabel id='select-metalake'>Metalake</InputLabel>+ <Select+ labelId='select-metalake'+ id='select-metalake'+ data-refer='select-metalake'+ value={metalake}+ label='Metalake'+ >+ {metalakes.map(item => {+ return (+ <MenuItem+ value={item}+ key={item}+ data-refer={'select-option-' + item}+ onClick={() => router.push('/metalakes?metalake=' + item)}+ >+ {item}+ </MenuItem>+ )+ })}+ </Select>+ </FormControl>+ ) : null}<VersionView /><LogoutButton /></Stack>diff --git a/web/src/app/rootLayout/VersionView.js b/web/src/app/rootLayout/VersionView.jsindex 583797ff43..8cde1aad75 100644--- a/web/src/app/rootLayout/VersionView.js+++ b/web/src/app/rootLayout/VersionView.js@@ -12,7 +12,7 @@ const VersionView = () => {const store = useAppSelector(state => state.sys)return (- <Typography variant='subtitle2' id='gravitino_version'>+ <Typography variant='subtitle2' id='gravitino_version' className={'twc-flex twc-justify-end'} sx={{ width: 200 }}>{store.version}</Typography>)diff --git a/web/src/lib/store/metalakes/index.js b/web/src/lib/store/metalakes/index.jsindex 6e26399657..3e03140e38 100644--- a/web/src/lib/store/metalakes/index.js+++ b/web/src/lib/store/metalakes/index.js@@ -176,6 +176,7 @@ export const fetchCatalogs = createAsyncThunk('appMetalakes/fetchCatalogs',async ({ init, update, page, metalake }, { getState, dispatch }) => {if (init) {+ dispatch(resetTree())dispatch(resetTableData())dispatch(setTableLoading(true))}