Skip to content

Commit

Permalink
feat(add-schema-in-query-view): Add the full schema details to the sc…
Browse files Browse the repository at this point in the history
…hema query page (#66)

Co-authored-by: Broknloop <[email protected]>
  • Loading branch information
pfrybar and broknloop authored Jan 11, 2024
1 parent e200013 commit 7c43859
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/main/js/routes/schema/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import {useOutletContext, useParams} from "react-router-dom";
import TabView from "../../components/tabs/tab-view";
import Preview from "./preview";
import Query from "./query";
import SyntaxHighlighter from "react-syntax-highlighter";
import {androidstudio} from "react-syntax-highlighter/dist/cjs/styles/hljs";

function Schema() {
const vespaState = useOutletContext()
const params = useParams()
const containerUrl = getQueryableContainer(vespaState)
const schema = params.schema
const schemaDetails = findSchemaDetails(vespaState, schema)

return (<>
<TabView tabs={[
Expand All @@ -19,7 +22,14 @@ function Schema() {
{
"header": "Data preview",
"content": <Preview containerUrl={containerUrl} schema={schema}/>
},]} />
},
{
"header": "Schema",
"content": <SyntaxHighlighter language="yaml" style={androidstudio}>
{schemaDetails}
</SyntaxHighlighter>
}
]} />
</>)

/* finds a valid container to issue the query */
Expand All @@ -35,6 +45,16 @@ function Schema() {
return ""
}
}

function findSchemaDetails(vespaState, schema) {
for (let cluster of vespaState.content.clusters) {
for (let data of cluster.contentData) {
if (data.schema.schemaName === schema) {
return data.schema.schemaContent
}
}
}
}
}


Expand Down

0 comments on commit 7c43859

Please sign in to comment.