Skip to content
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

fix: Disable the generators that are not yet supported in V3 #984

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion apps/studio/src/components/Modals/Generator/GeneratorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,25 @@

import templates from './template-parameters.json';

export const GeneratorModal = create(() => {

Check warning on line 15 in apps/studio/src/components/Modals/Generator/GeneratorModal.tsx

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed
const modal = useModal();
const [template, setTemplate] = useState('');
const { serverAPISvc } = useServices();
const [warning, setwarning] = useState(false);
const [problem, setProblem] = useState<ServerAPIProblem & { validationErrors: any[] } | null>(null);
const [confirmDisabled, setConfirmDisabled] = useState(true);
const templateParamsRef = useRef<TemplateParametersHandle>(null);
const generatable = ['@asyncapi/dotnet-nats-template',
'@asyncapi/go-watermill-template',

Check failure on line 24 in apps/studio/src/components/Modals/Generator/GeneratorModal.tsx

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 4 spaces but found 2
'@asyncapi/html-template',

Check failure on line 25 in apps/studio/src/components/Modals/Generator/GeneratorModal.tsx

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 4 spaces but found 2
'@asyncapi/java-spring-cloud-stream-template',

Check failure on line 26 in apps/studio/src/components/Modals/Generator/GeneratorModal.tsx

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 4 spaces but found 2
'@asyncapi/java-spring-template',

Check failure on line 27 in apps/studio/src/components/Modals/Generator/GeneratorModal.tsx

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 4 spaces but found 2
'@asyncapi/java-template',

Check failure on line 28 in apps/studio/src/components/Modals/Generator/GeneratorModal.tsx

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 4 spaces but found 2
'@asyncapi/markdown-template',

Check failure on line 29 in apps/studio/src/components/Modals/Generator/GeneratorModal.tsx

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 4 spaces but found 2
'@asyncapi/nodejs-template',

Check failure on line 30 in apps/studio/src/components/Modals/Generator/GeneratorModal.tsx

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 4 spaces but found 2
'@asyncapi/nodejs-ws-template',

Check failure on line 31 in apps/studio/src/components/Modals/Generator/GeneratorModal.tsx

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 4 spaces but found 2
'@asyncapi/python-paho-template',

Check failure on line 32 in apps/studio/src/components/Modals/Generator/GeneratorModal.tsx

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 4 spaces but found 2
'@asyncapi/ts-nats-template']

Check failure on line 33 in apps/studio/src/components/Modals/Generator/GeneratorModal.tsx

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Expected indentation of 4 spaces but found 2

useEffect(() => {
const required = template ? (templates as Record<string, any>)[String(template)].schema.required : [];
Expand Down Expand Up @@ -82,6 +94,9 @@
onCancel={onCancel}
closeAfterSumbit={false}
>
{warning && (
<h3 className='block text-bold text-red-400'>Sorry! This project is under development</h3>
)}
<div>
<div className="flex flex-row content-center justify-between text-sm">
<label
Expand All @@ -94,7 +109,12 @@
name="generate"
className="shadow-sm focus:ring-pink-500 focus:border-pink-500 w-1/2 block sm:text-sm rounded-md py-1 text-gray-700 border-pink-300 border-2"
onChange={e => {
setTemplate(e.target.value);
if (!generatable.includes(e.target.value)){
setTemplate(e.target.value);
}else{
setTemplate(e.target.value);
setwarning(true);
}
}}
value={template}
>
Expand Down
20 changes: 18 additions & 2 deletions apps/studio/src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export const Navigation: React.FunctionComponent<NavigationProps> = ({
className = '',
}) => {
const [hash, setHash] = useState(window.location.hash);
const [loading,setloading] = useState(false);

const { navigationSvc } = useServices();
const rawSpec = useFilesState(state => state.files['asyncapi']?.content);
Expand All @@ -269,11 +270,26 @@ export const Navigation: React.FunctionComponent<NavigationProps> = ({
window.removeEventListener('hashchange', fn);
};
}, []);

useEffect(() => {
if (!document) {
setloading(true);
const timer = setTimeout(() => {
setloading(false);
}, 1000);
return () => clearTimeout(timer);
}
},[document])

if (!rawSpec || !document) {
return (
<div className="flex overflow-hidden bg-gray-800 h-full justify-center items-center text-center text-white text-md px-6">
Empty or invalid document. Please fix errors/define AsyncAPI document.
<div className="flex flex-1 overflow-hidden h-full justify-center items-center text-2xl mx-auto px-6 text-center" style={{ backgroundColor: 'black' }}>
{loading ?(
<div className="rotating-wheel"></div>
) : (
<p style={{ color: 'white' }}>Empty or invalid document. Please fix errors/define AsyncAPI document.</p>
)
}
</div>
);
}
Expand Down
1 change: 0 additions & 1 deletion apps/studio/src/components/Template/HTMLWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const HTMLWrapper: React.FunctionComponent<HTMLWrapperProps> = () => {
const [parsedSpec, setParsedSpec] = useState<AsyncAPIDocumentInterface | null>(null);
const { navigationSvc } = useServices();
const document = useDocumentsState(state => state.documents['asyncapi']?.document) || null;

const autoRendering = useSettingsState(state => state.templates.autoRendering);
const templateRerender = useOtherState(state => state.templateRerender);

Expand Down
Loading