-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add pages for individual Features to the Feast UI (#2850)
* Add feature page functionality Signed-off-by: Daniel Kim <danielk@twitter.com> * Add links in feature view and feature pages Signed-off-by: Daniel Kim <danielk@twitter.com> * Modify Feast provider test to include new Feature pages Signed-off-by: Daniel Kim <danielk@twitter.com> * Add initial version of test Signed-off-by: Daniel Kim <danielk@twitter.com> * Make some changes to test and remove feature tab functionality from ondemand FVs Signed-off-by: Daniel Kim <danielk@twitter.com> * Change feature link EuiLinks to EuiCustomLinks Signed-off-by: Daniel Kim <danielk@twitter.com> * Change other links to EuiCustomLinks Signed-off-by: Daniel Kim <danielk@twitter.com>
- Loading branch information
Showing
19 changed files
with
556 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import React from "react"; | ||
|
||
import { | ||
// Feature View Custom Tabs will get these props | ||
FeatureCustomTabProps, | ||
} from "../types"; | ||
|
||
import { | ||
EuiLoadingContent, | ||
EuiEmptyPrompt, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiCode, | ||
EuiSpacer, | ||
} from "@elastic/eui"; | ||
|
||
// Separating out the query is not required, | ||
// but encouraged for code readability | ||
import useDemoQuery from "./useDemoQuery"; | ||
|
||
const DemoCustomTab = ({ id, feastObjectQuery }: FeatureCustomTabProps) => { | ||
// Use React Query to fetch data | ||
// that is custom to this tab. | ||
// See: https://react-query.tanstack.com/guides/queries | ||
|
||
const { isLoading, isError, isSuccess, data } = useDemoQuery({ | ||
featureView: id, | ||
}); | ||
|
||
if (isLoading) { | ||
// Handle Loading State | ||
// https://elastic.github.io/eui/#/display/loading | ||
return <EuiLoadingContent lines={3} />; | ||
} | ||
|
||
if (isError) { | ||
// Handle Data Fetching Error | ||
// https://elastic.github.io/eui/#/display/empty-prompt | ||
return ( | ||
<EuiEmptyPrompt | ||
iconType="alert" | ||
color="danger" | ||
title={<h2>Unable to load your demo page</h2>} | ||
body={ | ||
<p> | ||
There was an error loading the Dashboard application. Contact your | ||
administrator for help. | ||
</p> | ||
} | ||
/> | ||
); | ||
} | ||
|
||
// Feast UI uses the Elastic UI component system. | ||
// <EuiFlexGroup> and <EuiFlexItem> are particularly | ||
// useful for layouts. | ||
return ( | ||
<React.Fragment> | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={1}> | ||
<p>Hello World. The following is fetched data.</p> | ||
<EuiSpacer /> | ||
{isSuccess && data && ( | ||
<EuiCode> | ||
<pre>{JSON.stringify(data, null, 2)}</pre> | ||
</EuiCode> | ||
)} | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={2}> | ||
<p>... and this is data from Feast UI’s own query.</p> | ||
<EuiSpacer /> | ||
{feastObjectQuery.isSuccess && feastObjectQuery.featureData && ( | ||
<EuiCode> | ||
<pre>{JSON.stringify(feastObjectQuery.featureData, null, 2)}</pre> | ||
</EuiCode> | ||
)} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default DemoCustomTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useQuery } from "react-query"; | ||
import { z } from "zod"; | ||
|
||
// Use Zod to check the shape of the | ||
// json object being loaded | ||
const demoSchema = z.object({ | ||
hello: z.string(), | ||
name: z.string().optional(), | ||
}); | ||
|
||
// Make the type of the object available | ||
type DemoDataType = z.infer<typeof demoSchema>; | ||
|
||
interface DemoQueryInterface { | ||
featureView: string | undefined; | ||
} | ||
|
||
const useDemoQuery = ({ featureView }: DemoQueryInterface) => { | ||
// React Query manages caching for you based on query keys | ||
// See: https://react-query.tanstack.com/guides/query-keys | ||
const queryKey = `demo-tab-namespace:${featureView}`; | ||
|
||
// Pass the type to useQuery | ||
// so that components consuming the | ||
// result gets nice type hints | ||
// on the other side. | ||
return useQuery<DemoDataType>( | ||
queryKey, | ||
() => { | ||
// Customizing the URL based on your needs | ||
const url = `/demo-custom-tabs/demo.json`; | ||
|
||
return fetch(url) | ||
.then((res) => res.json()) | ||
.then((data) => demoSchema.parse(data)); // Use zod to parse results | ||
}, | ||
{ | ||
enabled: !!featureView, // Only start the query when the variable is not undefined | ||
} | ||
); | ||
}; | ||
|
||
export default useDemoQuery; | ||
export type { DemoDataType }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.