Skip to content

Commit

Permalink
feat: add infra update banner
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeday committed Mar 21, 2024
1 parent 9490d26 commit b02be9c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
23 changes: 21 additions & 2 deletions features/ipfs/security-status-banner/security-status-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const warningContent = ({
canClose: false,
};
// we can show this banner on both infra and IPFS
case isVersionUnsafe && (!isIpfs || !isUpdateAvailable):
case isVersionUnsafe && !isUpdateAvailable:
return {
content: (
<WarningText>
Expand All @@ -61,6 +61,17 @@ const warningContent = ({
canClose: false,
showTwitterLink: true,
};
case isVersionUnsafe && isUpdateAvailable:
return {
content: (
<WarningText>
This version of Lido staking widget has issues that could impact
your experience.
</WarningText>
),
canClose: false,
showTwitterLink: false,
};
// outdated IPFS
case isIpfs && isUpdateAvailable:
return {
Expand Down Expand Up @@ -119,7 +130,15 @@ export const SecurityStatusBanner = () => {
)}
{isUpdateAvailable && (
<a
href={data.remoteCidLink}
href={data.remoteCidLink ?? window.location.href}
onClick={
dynamics.ipfsMode
? undefined
: (e) => {
e.preventDefault();
window.location.reload();
}
}
target="_self"
rel="noopener noreferrer"
>
Expand Down
10 changes: 7 additions & 3 deletions features/ipfs/security-status-banner/use-version-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const useVersionCheck = () => {
const { forceDisconnect } = useForceDisconnect();
const [areConditionsAccepted, setConditionsAccepted] = useState(false);

// local cid extraction
// only IPFS: local cid extraction
const currentCidSWR = useLidoSWR(
['swr:ipfs-cid-extraction'],
async () => {
Expand All @@ -42,11 +42,15 @@ export const useVersionCheck = () => {
// ens cid extraction
const remoteVersionSWR = useRemoteVersion();

// update is available
// for INFRA - leastSafeVersion is not NO_SAFE_VERSION
// for IPFS - ^this and current cid doesn't match
const isUpdateAvailable = overrideWithQAMockBoolean(
Boolean(
remoteVersionSWR.data &&
currentCidSWR.data &&
remoteVersionSWR.data.cid !== currentCidSWR.data &&
((currentCidSWR.data &&
remoteVersionSWR.data.cid !== currentCidSWR.data) ||
!dynamics.ipfsMode) &&
remoteVersionSWR.data.leastSafeVersion !== NO_SAFE_VERSION,
),
'mock-qa-helpers-security-banner-is-update-available',
Expand Down

0 comments on commit b02be9c

Please sign in to comment.