-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9a1de5
commit 0d078e5
Showing
6 changed files
with
102 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./settings/settings"; | ||
export * from "./clusters/routes"; | ||
export * from "./topics/main"; | ||
export * from "./schema-registry/main"; |
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,19 @@ | ||
import { Group } from "@mantine/core"; | ||
import { useState } from "react"; | ||
import { Schema } from "./schema"; | ||
import { SchemaList } from "./schema-list"; | ||
|
||
export const SchemasPage = () => { | ||
const [state, setState] = useState<{ activeSchema?: string }>({}); | ||
const { activeSchema } = state; | ||
return ( | ||
<Group grow={true} align={"stretch"} position={"center"} noWrap={true}> | ||
<SchemaList | ||
onTopicSelected={(activeSchema) => { | ||
setState({ ...state, activeSchema: activeSchema }); | ||
}} | ||
/> | ||
{activeSchema && <Schema schemaName={activeSchema} />} | ||
</Group> | ||
); | ||
}; |
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,50 @@ | ||
import { useMemo, useState } from "react"; | ||
import { Cluster } from "../../models/kafka"; | ||
import { useAppState, notifyAlert, notifySuccess } from "../../providers"; | ||
import { ItemList } from "../common"; | ||
|
||
function getSchemaNamesList(_: Cluster): Promise<string[]> { | ||
return Promise.resolve([]); | ||
//todo: return invoke<TopicInfo[]>("list_schemas", { cluster }); | ||
} | ||
|
||
export const SchemaList = ({ | ||
onTopicSelected, | ||
}: { | ||
onTopicSelected: (topicName: string) => void; | ||
}) => { | ||
const { appState } = useAppState(); | ||
const [state, setState] = useState<{ schemas: string[]; search?: string; loading: boolean }>({ | ||
schemas: [], | ||
loading: true, | ||
}); | ||
|
||
const updateSchemasList = () => { | ||
if (appState.activeCluster) { | ||
setState({ ...state, loading: true }); | ||
getSchemaNamesList(appState.activeCluster) | ||
.then((schemas) => setState({ schemas, loading: false })) | ||
.then((_) => notifySuccess("List of schemas successfully retrieved")) | ||
.catch((err) => { | ||
notifyAlert( | ||
`Unable to retrieve the list of schemas for cluster "${appState.activeCluster?.name}"`, | ||
err | ||
); | ||
setState({ schemas: [], loading: false }); | ||
}); | ||
} | ||
}; | ||
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
useMemo(() => updateSchemasList(), [appState.activeCluster]); | ||
|
||
return ( | ||
<ItemList | ||
title="Schemas" | ||
loading={state.loading} | ||
items={state.schemas} | ||
onItemSelected={onTopicSelected} | ||
onRefreshList={updateSchemasList} | ||
/> | ||
); | ||
}; |
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,18 @@ | ||
import { ActionIcon, Container, Divider, Group, Title, Tooltip } from "@mantine/core"; | ||
import { IconInfoCircle } from "@tabler/icons"; | ||
|
||
export const Schema = ({ schemaName }: { schemaName: string }) => ( | ||
<Container style={{ width: "100%" }}> | ||
<Group position={"apart"}> | ||
<Title>{schemaName}</Title> | ||
<Group> | ||
<Tooltip label="Topic info"> | ||
<ActionIcon> | ||
<IconInfoCircle /> | ||
</ActionIcon> | ||
</Tooltip> | ||
</Group> | ||
</Group> | ||
<Divider mt={10} /> | ||
</Container> | ||
); |