From 3065fe1f141d7013993dc83db7550bd946dfc2de Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Mon, 9 Sep 2024 21:12:52 -0700 Subject: [PATCH] display frontend --- src/App.tsx | 4 ++++ src/build.ts | 1 + src/components/CandidUI.tsx | 10 +++++++--- src/components/DeployModal.tsx | 1 + src/config/actor.ts | 5 +++-- src/node/uploadAsset.js | 1 + 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 4a09569c..7fb9669a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -353,6 +353,10 @@ export function App() { workplaceState.canisters[workplaceState.selectedCanister!] ?.candid } + isFrontend={ + workplaceState.canisters[workplaceState.selectedCanister!] + ?.isFrontend ?? false + } forceUpdate={forceUpdate} onMessage={({ origin, source, message }) => { if (!message.caller) return; diff --git a/src/build.ts b/src/build.ts index 3dc2fca1..1e56e027 100644 --- a/src/build.ts +++ b/src/build.ts @@ -10,6 +10,7 @@ export interface CanisterInfo { name?: string; candid?: string | null; stableSig?: string | null; + isFrontend?: boolean; } /* export function interpret(file: string, logger: ILoggingStore): void { diff --git a/src/components/CandidUI.tsx b/src/components/CandidUI.tsx index 7ba1c628..128b15eb 100644 --- a/src/components/CandidUI.tsx +++ b/src/components/CandidUI.tsx @@ -43,6 +43,7 @@ interface PropTypes { canisterId: string; candid?: string | null | undefined; setCandidWidth?: (width: string) => void; + isFrontend: boolean; forceUpdate?: any; onMessage?: (event: { origin: string; source: Window; message: any }) => void; } @@ -52,6 +53,7 @@ export function CandidUI({ candid, setCandidWidth, forceUpdate, + isFrontend, onMessage, }: PropTypes) { const [isExpanded, setIsExpanded] = useState(true); @@ -61,8 +63,10 @@ export function CandidUI({ ? `&did=${encodeURIComponent(btoa(candid))}` : "&external-config"; - const url = - `${CANDID_UI_CANISTER_URL}/?id=${canisterId}&tag=${forceUpdate}` + didParam; + const url = isFrontend + ? `https://${canisterId}.raw.icp0.io` + : `${CANDID_UI_CANISTER_URL}/?id=${canisterId}&tag=${forceUpdate}` + + didParam; // Handle incoming messages from iframe const handleMessage = useCallback( @@ -177,7 +181,7 @@ export function CandidUI({ src={iconCollapse} alt="Collapse icon" /> - {isExpanded ? "CANDID UI" : null} + {isExpanded ? (isFrontend ? "FRONTEND" : "CANDID UI") : null} {isExpanded ? (