Skip to content

Commit

Permalink
Merge branch 'master' into feat/v3-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Amzani authored Aug 7, 2023
2 parents 64832de + ea2b1e4 commit b988777
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 141 deletions.
4 changes: 2 additions & 2 deletions apps/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@
},
"devDependencies": {
"@asyncapi/dotnet-nats-template": "^0.11.0",
"@asyncapi/go-watermill-template": "^0.2.34",
"@asyncapi/go-watermill-template": "^0.2.35",
"@asyncapi/html-template": "^0.28.3",
"@asyncapi/java-spring-cloud-stream-template": "^0.13.4",
"@asyncapi/java-spring-template": "^0.29.0",
"@asyncapi/java-template": "^0.2.1",
"@asyncapi/markdown-template": "^1.2.2",
"@asyncapi/markdown-template": "^1.3.2",
"@asyncapi/nodejs-template": "^0.13.1",
"@asyncapi/nodejs-ws-template": "^0.9.33",
"@asyncapi/python-paho-template": "^0.2.13",
Expand Down
3 changes: 2 additions & 1 deletion apps/studio/src/components/Editor/EditorDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const EditorDropdown: React.FunctionComponent<EditorDropdownProps> = () =
>
<input
type="file"
accept='.yaml, .yml, .json'
style={{ position: 'fixed', top: '-100em' }}
onChange={event => {
toast.promise(editorSvc.importFile(event.target.files), {
Expand All @@ -53,7 +54,7 @@ export const EditorDropdown: React.FunctionComponent<EditorDropdownProps> = () =
error: (
<div>
<span className="block text-bold text-red-400">
Failed to import document.
Failed to import document. Maybe the file type is invalid.
</span>
</div>
),
Expand Down
9 changes: 9 additions & 0 deletions apps/studio/src/services/editor.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ export class EditorService extends AbstractService {
if (!file) {
return;
}

// Check if file is valid (only JSON and YAML are allowed currently) ----Change afterwards as per the requirement
if (
file.type !== 'application/json' &&
file.type !== 'application/x-yaml' &&
file.type !== 'application/yaml'
) {
throw new Error('Invalid file type');
}

const fileReader = new FileReader();
fileReader.onload = fileLoadedEvent => {
Expand Down
Loading

0 comments on commit b988777

Please sign in to comment.