Skip to content

Commit 9633a18

Browse files
authored
Merge branch 'master' into samz/v3-examples
2 parents 74675d4 + cf39abf commit 9633a18

File tree

6 files changed

+45
-136
lines changed

6 files changed

+45
-136
lines changed

.github/workflows/add-scope-to-bet.yml

-119
This file was deleted.

.github/workflows/automerge.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
env:
4646
GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}"
4747
GITHUB_LOGIN: asyncapi-bot
48-
MERGE_LABELS: ""
48+
MERGE_LABELS: "!do-not-merge"
4949
MERGE_METHOD: "squash"
5050
MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})"
5151
MERGE_RETRIES: "20"
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
# This invalid file exists solely for educational purposes, and if you come across it, here is the tutorial: https://www.asyncapi.com/docs/tutorials/studio-document-validation
22

3-
asyncapi: '1.0.0'
3+
asyncapi: 3.0.0
44
info:
55
title: Streetlights API
66
version: '1.0.0'
7+
description: |
8+
The Smartylighting Streetlights API allows you
9+
to remotely manage the city lights.
710
license:
811
name: Apache 2.0
912
url: 'https://www.apache.org/licenses/LICENSE-2.0'
13+
1014
servers:
1115
mosquitto:
12-
url: mqtt://test.mosquitto.org
16+
url: test.mosquitto.org
1317
protocol: mqtt
18+
1419
channels:
15-
light/measured:
16-
publish:
17-
summary: Inform about environmental lighting conditions for a particular streetlight.
18-
operationId: onLightMeasured
19-
message:
20+
lightMeasured:
21+
address: 'light/measured'
22+
messages:
23+
lightMeasuredMessage:
2024
name: LightMeasured
2125
payload:
2226
type: object
@@ -30,6 +34,13 @@ channels:
3034
minimum: 0
3135
description: Light intensity measured in lumens.
3236
sentAt:
33-
type: integer
37+
type: string
3438
format: date-time
3539
description: Date and time when the message was sent.
40+
41+
operations:
42+
onLightMeasured:
43+
action: 'receive'
44+
summary: Inform about environmental lighting conditions for a particular streetlight.
45+
channel:
46+
$ref: '#/channels/lightMeasured'

apps/studio/src/services/app.service.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@ export class ApplicationService extends AbstractService {
1111
// subscribe to state to hide preloader
1212
this.hidePreloader();
1313

14-
const { readOnly, url, base64 } = this.svcs.navigationSvc.getUrlParameters();
14+
const { readOnly, url, base64 } =
15+
this.svcs.navigationSvc.getUrlParameters();
1516
// readOnly state should be only set to true when someone pass also url or base64 parameter
1617
const isStrictReadonly = Boolean(readOnly && (url || base64));
1718

18-
let error: any;
19+
let error: any;
1920
try {
2021
await this.fetchResource(url, base64);
2122
} catch (err) {
2223
error = err;
2324
console.error(err);
2425
}
2526

27+
if (error) {
28+
appState.setState({ initErrors: [error] });
29+
}
30+
2631
if (isStrictReadonly && !error) {
2732
appState.setState({
2833
readOnly,
@@ -32,7 +37,8 @@ export class ApplicationService extends AbstractService {
3237
}
3338

3439
public async afterAppInit() {
35-
const { readOnly, url, base64, redirectedFrom } = this.svcs.navigationSvc.getUrlParameters();
40+
const { readOnly, url, base64, redirectedFrom } =
41+
this.svcs.navigationSvc.getUrlParameters();
3642
const isStrictReadonly = Boolean(readOnly && (url || base64));
3743

3844
// show RedirectedModal modal if the redirectedFrom is set (only when readOnly state is set to false)
@@ -45,11 +51,11 @@ export class ApplicationService extends AbstractService {
4551
if (!url && !base64) {
4652
return;
4753
}
48-
54+
4955
const { updateFile } = filesState.getState();
5056
let content = '';
5157
if (url) {
52-
content = await fetch(url).then(res => res.text());
58+
content = await fetch(url).then((res) => res.text());
5359
} else if (base64) {
5460
content = this.svcs.formatSvc.decodeBase64(base64);
5561
}
@@ -79,4 +85,4 @@ export class ApplicationService extends AbstractService {
7985
}
8086
});
8187
}
82-
}
88+
}

apps/studio/src/state/app.state.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ export type AppState = {
44
initialized: boolean;
55
readOnly: boolean;
66
liveServer: boolean;
7+
initErrors: any[],
78
}
89

910
export const appState = create<AppState>(() => ({
1011
initialized: false,
1112
readOnly: false,
1213
liveServer: false,
14+
initErrors: [],
1315
}));
1416

1517
export const useAppState = appState;

apps/studio/src/studio.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect } from 'react';
2-
import { Toaster } from 'react-hot-toast';
2+
import toast, { Toaster } from 'react-hot-toast';
33

44
import { Content, Sidebar, Template, Toolbar } from './components';
55

@@ -8,7 +8,9 @@ import { appState } from './state';
88

99
export interface AsyncAPIStudioProps {}
1010

11-
export const AsyncAPIStudio: React.FunctionComponent<AsyncAPIStudioProps> = () => {
11+
export const AsyncAPIStudio: React.FunctionComponent<
12+
AsyncAPIStudioProps
13+
> = () => {
1214
const services = useServices();
1315

1416
useEffect(() => {
@@ -24,6 +26,13 @@ export const AsyncAPIStudio: React.FunctionComponent<AsyncAPIStudioProps> = () =
2426
</div>
2527
);
2628
}
29+
const unsubscribe = appState.subscribe((state) => {
30+
state.initErrors.forEach((e) => {
31+
toast.error(e.message);
32+
});
33+
unsubscribe();
34+
appState.setState({ initErrors: [] });
35+
});
2736

2837
return (
2938
<div className="flex flex-col h-full w-full h-screen">

0 commit comments

Comments
 (0)