-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: toggle hardcoded schema versions #5
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,58 +1,98 @@ | ||
import Box from "@mui/material/Box"; | ||
import Typography from "@mui/material/Typography"; | ||
import { useQueryClient } from "@tanstack/react-query"; | ||
|
||
import { JsonSchemaViewer } from "@stoplight/json-schema-viewer"; | ||
import { Provider as MosaicProvider, injectStyles } from "@stoplight/mosaic"; | ||
import { injectStyles } from "@stoplight/mosaic"; | ||
import { useFormik } from "formik"; | ||
import useQuerySchemas from "./../api/useQuerySchemas"; | ||
|
||
import InputLabel from "@mui/material/InputLabel"; | ||
import MenuItem from "@mui/material/MenuItem"; | ||
import Select from "@mui/material/Select"; | ||
import { useState } from "react"; | ||
import Header from "./components/Header"; | ||
|
||
// TODO: grab this programatically instead of hard-coding | ||
const LATEST_WORKING_VERSION = "v0.7.0"; | ||
|
||
const App = () => { | ||
injectStyles(); | ||
const queryClient = useQueryClient(); | ||
const [selectedVersion, setSelectedVersion] = useState( | ||
LATEST_WORKING_VERSION | ||
); | ||
|
||
const { data: schema, isLoading, isError } = useQuerySchemas(); | ||
const { | ||
data: schema, | ||
isLoading, | ||
isError, | ||
} = useQuerySchemas(selectedVersion, { retry: false }); | ||
|
||
const formik = useFormik({ | ||
initialValues: { | ||
version: selectedVersion, | ||
}, | ||
onSubmit: (values) => setSelectedVersion(values.version), | ||
}); | ||
|
||
return ( | ||
<Box py={2} style={{ maxWidth: 1000 }} mx="auto"> | ||
<Typography textAlign="center" variant="h2"> | ||
Digital planning data schemas | ||
</Typography> | ||
<Typography pt={4} maxWidth={800} mx='auto'> | ||
Digital Planning Data schemas aim to encourage more interoperability and | ||
consistency between systems by offering a central, version controlled | ||
specification for documenting and validating planning data. | ||
</Typography> | ||
<MosaicProvider> | ||
<Box | ||
p={6} | ||
my={4} | ||
maxWidth={800} | ||
style={{ | ||
borderRadius: 2, | ||
backgroundColor: "#fff5ef", | ||
}} | ||
mx="auto" | ||
> | ||
{isLoading ? ( | ||
<Typography>Loading...</Typography> | ||
) : ( | ||
<> | ||
<Typography pb={2}>{schema.$id}</Typography> | ||
<JsonSchemaViewer | ||
name="Digital planning data schemas" | ||
schema={schema} | ||
hideTopBar={false} | ||
emptyText="No schema defined" | ||
expanded={true} | ||
defaultExpandedDepth={0} | ||
renderRootTreeLines={true} | ||
/> | ||
</> | ||
)} | ||
{isError && ( | ||
<Typography pt={4}>Sorry, please try again later.</Typography> | ||
<Header> | ||
{isLoading ? ( | ||
<Typography>Loading...</Typography> | ||
) : ( | ||
<> | ||
<form onSubmit={formik.handleSubmit}> | ||
<InputLabel shrink id="select-version-label"> | ||
Version | ||
</InputLabel> | ||
<Select | ||
sx={{ marginBottom: 4 }} | ||
labelId="select-version-label" | ||
defaultValue={selectedVersion} | ||
id="select-version" | ||
onChange={(e) => { | ||
queryClient.invalidateQueries({ | ||
queryKey: ["schemas", selectedVersion], | ||
}); | ||
formik.setFieldValue("version", e.target.value, false); | ||
formik.submitForm(); | ||
}} | ||
value={formik.values.version} | ||
> | ||
// TODO: add query to populate with a list of possible versions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
<MenuItem value={"v0.7.1"}>v0.7.1</MenuItem> | ||
<MenuItem value={"v0.7.0"}>v0.7.0</MenuItem> | ||
<MenuItem value={"v0.6.0"}>v0.6.0</MenuItem> | ||
<MenuItem value={"v0.5.0"}>v0.5.0</MenuItem> | ||
<MenuItem value={"v0.4.0"}>v0.4.0</MenuItem> | ||
<MenuItem value={"v0.4.1"}>v0.4.1</MenuItem> | ||
<MenuItem value={"v0.3.0"}>v0.3.0</MenuItem> | ||
<MenuItem value={"v0.2.3"}>v0.2.3</MenuItem> | ||
<MenuItem value={"v0.2.2"}>v0.2.2</MenuItem> | ||
<MenuItem value={"v0.2.1"}>v0.2.1</MenuItem> | ||
<MenuItem value={"v0.2.0"}>v0.2.0</MenuItem> | ||
<MenuItem value={"v0.1.2"}>v0.1.2</MenuItem> | ||
<MenuItem value={"v0.1.1"}>v0.1.1</MenuItem> | ||
<MenuItem value={"v0.1.0"}>v0.1.0</MenuItem> | ||
</Select> | ||
</form> | ||
{!isError && ( | ||
<JsonSchemaViewer | ||
name="Digital planning data schemas" | ||
schema={schema} | ||
hideTopBar={false} | ||
emptyText="No schema defined" | ||
expanded={true} | ||
defaultExpandedDepth={0} | ||
renderRootTreeLines={true} | ||
/> | ||
)} | ||
</Box> | ||
</MosaicProvider> | ||
</Box> | ||
</> | ||
)} | ||
{isError && ( | ||
<Typography pt={4}>Sorry, please try again later.</Typography> | ||
)} | ||
</Header> | ||
); | ||
}; | ||
|
||
|
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,39 @@ | ||
import Box from "@mui/material/Box"; | ||
import Typography from "@mui/material/Typography"; | ||
|
||
import { Provider as MosaicProvider, injectStyles } from "@stoplight/mosaic"; | ||
|
||
import { ComponentProps } from "react"; | ||
|
||
const Header = ({ children }: ComponentProps<"header">) => { | ||
injectStyles(); | ||
|
||
return ( | ||
<Box p={2} style={{ maxWidth: 1000 }} mx="auto"> | ||
<Typography textAlign="center" variant="h2"> | ||
Digital planning data schemas | ||
</Typography> | ||
<Typography pt={4} maxWidth={800} mx="auto"> | ||
Digital Planning Data schemas aim to encourage more interoperability and | ||
consistency between systems by offering a central, version controlled | ||
specification for documenting and validating planning data. | ||
</Typography> | ||
<MosaicProvider> | ||
<Box | ||
p={6} | ||
my={4} | ||
maxWidth={800} | ||
style={{ | ||
borderRadius: 2, | ||
backgroundColor: "#fff5ef", | ||
}} | ||
mx="auto" | ||
> | ||
{children} | ||
</Box> | ||
</MosaicProvider> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default Header; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So something tricky to highlight here - since the latest release (v0.7.1), this URL now accounts for a
/schemas
subdirectory and each released version may have multiple schemas published within in (egapplication.json
,prototypeApplication.json
,preApplication.json
,decision.json
and so on).In my mind, the meaningful things to toggle here are:
/dist
are nice audit history but no longer in active use for any integrations!latest
&@next
dist folders though! See Smooth out CI build process for@next
&latest
/dist branch folders digital-planning-data-schemas#242)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok cool! There's some groundwork here which will apply to future work but sounds like next steps are:
Let me know if there is anything that should be changed implementation wise for this current PR, otherwise I feel like it could be merged as an incremental step towards the above goals 🥅