Skip to content

Commit

Permalink
Merge branch 'master' into feat/support-typed-array-unmarshal-in-type…
Browse files Browse the repository at this point in the history
…script
  • Loading branch information
jonaslagoni authored Dec 10, 2024
2 parents 86f1379 + 8374586 commit dd498d0
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 21 deletions.
32 changes: 18 additions & 14 deletions examples/integrate-with-react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions modelina-website/src/components/contexts/PlaygroundContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ interface PlaygroundContextProps {
setHasLoadedQuery: Dispatch<SetStateAction<boolean>>;
renderModels: React.ReactNode | null;
setRenderModels: (models: React.ReactNode) => void;
outputLoading: boolean;
setOutputLoading: Dispatch<SetStateAction<boolean>>;
}

const PlaygroundContext = createContext<PlaygroundContextProps | undefined>(undefined);
Expand Down Expand Up @@ -104,6 +106,7 @@ export const PlaygroundContextProvider: React.FC<{
const [isLoaded, setIsLoaded] = useState(false);
const [hasLoadedQuery, setHasLoadedQuery] = useState(false);
const [renderModels, setRenderModels] = React.useState<React.ReactNode | null>(null);
const [outputLoading, setOutputLoading] = useState(true);

const contextValue = useMemo(
() => ({
Expand All @@ -130,7 +133,9 @@ export const PlaygroundContextProvider: React.FC<{
hasLoadedQuery,
setHasLoadedQuery,
renderModels,
setRenderModels
setRenderModels,
outputLoading,
setOutputLoading
}),
[
config,
Expand All @@ -156,7 +161,9 @@ export const PlaygroundContextProvider: React.FC<{
hasLoadedQuery,
setHasLoadedQuery,
renderModels,
setRenderModels
setRenderModels,
outputLoading,
setOutputLoading
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const GeneratedModelsComponent: React.FC<GeneratedModelsComponentProps> = ({ sho
const context = useContext(PlaygroundGeneratedContext);
const [selectedModel, setSelectedModel] = useState<string>('');
const { setRenderModels, generatorCode, showGeneratorCode, setShowGeneratorCode } = usePlaygroundContext();
const { outputLoading } = usePlaygroundContext();

const toShow = () => {
let selectedCode = '';
Expand Down Expand Up @@ -90,11 +91,17 @@ const GeneratedModelsComponent: React.FC<GeneratedModelsComponentProps> = ({ sho
return (
<div className='h-full'>
<div className='col-span-2 h-full rounded-b bg-code-editor-dark font-bold text-white shadow-lg'>
<MonacoEditorWrapper
{
outputLoading ?
<div className = 'loading-text'>
<div>Loading...</div>
</div> :
<MonacoEditorWrapper
options={{ readOnly: true }}
language={context?.language}
value={showGeneratorCode ? generatorCode : selectedCode}
/>
}
</div>
</div>
);
Expand Down
7 changes: 6 additions & 1 deletion modelina-website/src/components/playground/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ const Playground: React.FC<ModelinaPlaygroundProps> = (props) => {
isLoaded,
setIsLoaded,
hasLoadedQuery,
setHasLoadedQuery
setHasLoadedQuery,
outputLoading,
setOutputLoading
} = usePlaygroundContext();

// To avoid hydration error
Expand All @@ -53,6 +55,8 @@ const Playground: React.FC<ModelinaPlaygroundProps> = (props) => {
* Tell the socket io server that we want some code
*/
const generateNewCode = (inputArgs: string) => {
setOutputLoading(true);

try {
const message: GenerateMessage = {
...config,
Expand Down Expand Up @@ -102,6 +106,7 @@ const Playground: React.FC<ModelinaPlaygroundProps> = (props) => {
setError(false);
setStatusCode(200);
setErrorMessage('');
setOutputLoading(false);
})
.catch((error) => {
console.error(error);
Expand Down
10 changes: 10 additions & 0 deletions modelina-website/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,13 @@ abbr[title] {
scroll-margin-top: 155px;
}
}

.loading-text {
position: relative;
width: 100%;
height: 100%;
z-index: 9999;
display: flex;
justify-content: center;
align-items: center;
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@asyncapi/modelina",
"version": "3.8.0",
"version": "3.9.0",
"description": "Library for generating data models based on inputs such as AsyncAPI, OpenAPI, or JSON Schema documents",
"license": "Apache-2.0",
"homepage": "https://www.modelina.org",
Expand Down

0 comments on commit dd498d0

Please sign in to comment.