Skip to content

Commit

Permalink
feat: enable v3 documentation rendering (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni authored Oct 5, 2023
1 parent f19bed7 commit 7fd77f8
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 209 deletions.
4 changes: 2 additions & 2 deletions apps/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"@asyncapi/avro-schema-parser": "^3.0.2",
"@asyncapi/converter": "^1.3.1",
"@asyncapi/openapi-schema-parser": "^3.0.4",
"@asyncapi/parser": "^3.0.0-next-major-spec.2",
"@asyncapi/react-component": "^1.0.0-next.54",
"@asyncapi/parser": "^3.0.0-next-major-spec.3",
"@asyncapi/react-component": "^1.0.2",
"@asyncapi/specs": "^6.0.0-next-major-spec.6",
"@ebay/nice-modal-react": "^1.2.10",
"@headlessui/react": "^1.7.4",
Expand Down
2 changes: 1 addition & 1 deletion apps/studio/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const Sidebar: FunctionComponent<SidebarProps> = () => {
onClick: () => updateState('secondaryPanel', 'template'),
icon: <VscOpenPreview className="w-5 h-5" />,
tooltip: 'HTML preview',
enabled: !isV3
enabled: true
},
// visuliser
{
Expand Down
18 changes: 4 additions & 14 deletions apps/studio/src/components/Template/HTMLWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { AsyncApiComponentWP } from '@asyncapi/react-component';
import { useServices } from '../../services';
import { appState, useDocumentsState, useSettingsState, useOtherState, otherState } from '../../state';

import { OldAsyncAPIDocument as AsyncAPIDocument, convertToOldAPI } from '@asyncapi/parser/cjs';
import { AsyncAPIDocumentInterface } from '@asyncapi/parser/cjs';

interface HTMLWrapperProps {}

export const HTMLWrapper: React.FunctionComponent<HTMLWrapperProps> = () => {
const [parsedSpec, setParsedSpec] = useState<AsyncAPIDocument | null>(null);
const [parsedSpec, setParsedSpec] = useState<AsyncAPIDocumentInterface | null>(null);
const { navigationSvc } = useServices();
const document = useDocumentsState(state => state.documents['asyncapi']?.document) || null;

Expand All @@ -22,15 +22,13 @@ export const HTMLWrapper: React.FunctionComponent<HTMLWrapperProps> = () => {

useEffect(() => {
if (autoRendering || parsedSpec === null) {
const oldDocument = document !== null ? convertToOldAPI(document) : null;
setParsedSpec(oldDocument);
setParsedSpec(document);
}
}, [document]); // eslint-disable-line

useEffect(() => {
if (templateRerender) {
const oldDocument = document !== null ? convertToOldAPI(document) : null;
setParsedSpec(oldDocument);
setParsedSpec(document);
otherState.setState({ templateRerender: false });
}
}, [templateRerender]); // eslint-disable-line
Expand All @@ -43,14 +41,6 @@ export const HTMLWrapper: React.FunctionComponent<HTMLWrapperProps> = () => {
);
}

if (document?.version() === '3.0.0') {
return (
<div className="flex flex-1 overflow-hidden h-full justify-center items-center text-2xl mx-auto px-6 text-center">
<p>Documentation preview is not supported yet for v3.0.0 specifications.</p>
</div>
);
}

return (
parsedSpec && (
<div className="flex flex-1 flex-col h-full overflow-hidden">
Expand Down
Loading

0 comments on commit 7fd77f8

Please sign in to comment.