From 79a0fa9a9779487d193d8a375a6637cf236b3429 Mon Sep 17 00:00:00 2001 From: Jaco Date: Sun, 16 Apr 2023 15:16:47 +0300 Subject: [PATCH] Link to IPFS version from development URL (#9337) --- CHANGELOG.md | 7 +++ packages/apps/src/Apps.tsx | 2 + packages/apps/src/overlays/Base.tsx | 27 ++++++++-- packages/apps/src/overlays/DotApps.tsx | 68 ++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 packages/apps/src/overlays/DotApps.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index edcdbf6bb9..2cabf36c9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG +## master + +Changes: + +- Link to IPFS version from development URL + + ## 0.127.1 Apr 16, 2023 Contributed: diff --git a/packages/apps/src/Apps.tsx b/packages/apps/src/Apps.tsx index a114c7b8cc..5f850b36d5 100644 --- a/packages/apps/src/Apps.tsx +++ b/packages/apps/src/Apps.tsx @@ -14,6 +14,7 @@ import Signer from '@polkadot/react-signer'; import Content from './Content/index.js'; import Menu from './Menu/index.js'; import ConnectingOverlay from './overlays/Connecting.js'; +import DotAppsOverlay from './overlays/DotApps.js'; import WarmUp from './WarmUp.js'; export const PORTAL_ID = 'portals'; @@ -39,6 +40,7 @@ function Apps ({ className = '' }: Props): React.ReactElement { +
diff --git a/packages/apps/src/overlays/Base.tsx b/packages/apps/src/overlays/Base.tsx index a17ae26e46..85856b4e4f 100644 --- a/packages/apps/src/overlays/Base.tsx +++ b/packages/apps/src/overlays/Base.tsx @@ -12,10 +12,12 @@ interface Props { children: React.ReactNode; className?: string; icon: IconName; + isBottom?: boolean; + isFull?: boolean; type: 'error' | 'info'; } -function BaseOverlay ({ children, className = '', icon, type }: Props): React.ReactElement | null { +function BaseOverlay ({ children, className = '', icon, isBottom = false, isFull = false, type }: Props): React.ReactElement | null { const [isHidden, toggleHidden] = useToggle(); if (isHidden) { @@ -23,7 +25,7 @@ function BaseOverlay ({ children, className = '', icon, type }: Props): React.Re } return ( - +
'') + .map((e) => e.dnslink) + .reduce((all: string[], dnslink) => { + if (dnslink && !all.includes(dnslink)) { + all.push(dnslink); + } + + return all; + }, []); + +interface Props { + className?: string; +} + +function DotApps ({ className }: Props): React.ReactElement | null { + const { t } = useTranslation(); + const { systemChain } = useApi(); + + const appsUrl = useMemo( + () => { + const lowerChain = systemChain?.toLowerCase(); + + return (lowerChain && dnsLinks.includes(lowerChain)) + ? `https://${lowerChain}.dotapps.io` + : 'https://dotapps.io'; + }, + [systemChain] + ); + + if (isDev) { + return ( + +
+ {t('You are connected to the development instance of the UI. For a fully decentralized experience, you are encouraged to use the IPFS deployed version as the canonical URL: ')} + + {appsUrl.replace('https://', '')} + +
+
+ ); + } + + return null; +} + +export default React.memo(DotApps);