Skip to content
Merged
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
15 changes: 14 additions & 1 deletion src/DefaultTemplate.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DefaultTemplate } from "./DefaultTemplate";
import React from "react";
import { DefaultTemplate, ConnectionFailureTemplate } from "./DefaultTemplate";

export default {
title: "DefaultTemplate",
Expand All @@ -25,3 +26,15 @@ export const NonEditableValue = {
},
},
};

export const ConnectionFailure = {
name: "Connection Failure (OpenCerts only)",
render: ConnectionFailureTemplate,
decorators: [
(Story: any) =>
React.createElement("div", { style: { padding: "4rem 0", textAlign: "center" } }, React.createElement(Story)),
],
args: {
source: "http://localhost:3000",
},
};
23 changes: 23 additions & 0 deletions src/DefaultTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@ const container = {
const textColor = `#333`;
const paddingBox = `.75rem 1.25rem`;

export interface ConnectionFailureProps {
source?: string;
}

export const ConnectionFailureTemplate: React.FunctionComponent<ConnectionFailureProps> = (props) => {
return (
<div style={{ ...container, fontFamily: "Arial", wordBreak: "break-all" }}>
<div style={{ backgroundColor: "#FDFDEA", borderLeft: "2px solid #8E4B10", padding: "16px 16px 16px 18px" }}>
<p style={{ margin: "0px", lineHeight: "21px", fontSize: "16px", color: "#8E4B10", fontWeight: "700" }}>
This document might be having loading issues
</p>
<p style={{ margin: "0px", lineHeight: "21px", fontSize: "14px", color: "#374151", marginTop: "6px" }}>
Try refreshing the page or check your internet connection. If the issue continues, please contact the issuer
with the information below:
<br />
<br />
<span style={{ fontFamily: "Courier" }}>Template URL: &quot;{props.source}&quot;</span>
Comment thread
rongquan1 marked this conversation as resolved.
</p>
</div>
</div>
);
};

export const DefaultTemplate: React.FunctionComponent<TemplateProps<any>> = (props) => {
return (
<div id="default-template">
Expand Down
15 changes: 11 additions & 4 deletions src/components/frame/FrameConnector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { CSSProperties, FunctionComponent, useEffect, useMemo, useRef, useState } from "react";
import { useChildFrame } from "./useFrame";
import { HostActions, HostActionsHandler, LegacyHostActions } from "./host.actions";
import { ConnectionFailureTemplate } from "../../DefaultTemplate";
import {
FrameActions,
LegacyFrameActions,
Expand Down Expand Up @@ -85,6 +86,8 @@ export const FrameConnector: FunctionComponent<FrameConnectorProps> = ({
};
}, [dispatchProxy]);

const hostname = typeof window !== "undefined" ? window.location.hostname : "";
const isOpenCerts = hostname === "opencerts.io" || hostname.endsWith(".opencerts.io");
const DEFAULT_RENDERER_URL = `https://generic-templates.tradetrust.io`;
const originalIframe = useRef<HTMLIFrameElement>(null);
const fallbackIframe = useRef<HTMLIFrameElement>(null);
Expand Down Expand Up @@ -170,10 +173,14 @@ export const FrameConnector: FunctionComponent<FrameConnectorProps> = ({
<>
{!useFallbackSource ? (
timeout ? (
<>
<h3>Connection timeout on renderer</h3>
<p>Please contact the administrator of {source}.</p>
</>
isOpenCerts ? (
<ConnectionFailureTemplate source={source} />
) : (
<>
<h3>Connection timeout on renderer</h3>
<p>Please contact the administrator of {source}.</p>
</>
)
) : (
<iframe
title="Decentralised Rendered Certificate"
Expand Down