fixed minor socket connection issues
This commit is contained in:
1 parent
9a26fc46d5
commit
ea86f7f763
4 files changed
+76
-10
No files matched your search
@@ -20,7 +20,7 @@ const { make, componentMeta } = makeStory({
|
||||
api={useMockApiService(args.automations ?? [], !args.automations)}
|
||||
haEntities={useMockHAEntities(haEntities)}
|
||||
onAutomationStateChange={(eid, on) => {
|
||||
if (!haEntities.loading) {
|
||||
if (!haEntities.loading && !haEntities.error) {
|
||||
setHAE({
|
||||
...haEntities,
|
||||
entities: {
|
||||
@@ -49,7 +49,7 @@ const { make, componentMeta } = makeStory({
|
||||
|
||||
export default componentMeta;
|
||||
export const Loading = make({});
|
||||
export const Errored = make({
|
||||
export const ErroredByAPI = make({
|
||||
automations: undefined,
|
||||
haProps: {
|
||||
loading: false,
|
||||
@@ -57,6 +57,16 @@ export const Errored = make({
|
||||
entitySource: {},
|
||||
},
|
||||
});
|
||||
export const ErroredByWS = make({
|
||||
automations: [],
|
||||
haProps: {
|
||||
loading: false,
|
||||
error: {
|
||||
entities: { originalError: "1", message: "Failed to connect" },
|
||||
entitySource: { originalError: "1", message: "Failed to connect" },
|
||||
},
|
||||
},
|
||||
});
|
||||
export const Empty = make({
|
||||
automations: [],
|
||||
haProps: {
|
||||
|
||||
@@ -25,6 +25,19 @@ export const AutomationManager: FC<AutomationManagerProps> = ({
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
|
||||
// handle bad states
|
||||
if (!haEntities.ready && haEntities.error) {
|
||||
return (
|
||||
<div className="automation-manager error">
|
||||
<Alert color="error">
|
||||
Failed to connect to websocket, please check that your access token is
|
||||
properly setup
|
||||
</Alert>{" "}
|
||||
<br />
|
||||
<code>{JSON.stringify(haEntities.error)}</code>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!haEntities.ready || !api.state.automations.ready) {
|
||||
return (
|
||||
<div className="automation-manager loading">
|
||||
|
||||
Reference in new issue
Block a user