-
@@ -35,9 +35,32 @@ function MessageBannerStyled({ children }) {
export const PageBannerPortal = ({ id, contentsClassName = defaultContentsClassName }) => {
return (
-
-
-
+
);
};
+
+/**
+ * render children into a PageBannerPortal at the top of the page
+ */
+export const PageBanner = ({ children }) => {
+ const pageBannerPortal = document.querySelector(defaultPortalQuerySelector);
+ console.log('in PageBanner component', {
+ pageBannerPortal,
+ children,
+ defaultPortalQuerySelector,
+ found: document.querySelector(defaultPortalQuerySelector),
+ });
+ return (
+ <>
+ {pageBannerPortal &&
+ children &&
+ React.createPortal(
+ <>
+
{children}
+ >,
+ pageBannerPortal
+ )}
+ >
+ );
+};
diff --git a/packages/website/components/w3up-launch.js b/packages/website/components/w3up-launch.js
index 3d88569454..c6d2b04aeb 100644
--- a/packages/website/components/w3up-launch.js
+++ b/packages/website/components/w3up-launch.js
@@ -1,26 +1,55 @@
import * as React from 'react';
+const sunsetStartEnv = process.env.NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_START ?? '2023-01-09T00:00:00Z';
+const sunsetStartDate = new Date(Date.parse(sunsetStartEnv));
+
+/**
+ * If this isn't set, no announcements will appear
+ */
+const sunsetAnnouncementStartEnv = process.env.NEXT_PUBLIC_W3UP_LAUNCH_SUNSET_ANNOUNCEMENT_START;
+
+/**
+ * after this datetime, show announcements that web3.storage is sunset
+ * and end-users should switch to w3up/console.web3.storage
+ */
+const sunsetAnnouncementStartDate = sunsetAnnouncementStartEnv
+ ? new Date(Date.parse(sunsetAnnouncementStartEnv))
+ : undefined;
+
+export const w3upLaunchContextDefaults = {
+ stages: {
+ sunsetAnnouncement: {
+ start: sunsetAnnouncementStartDate,
+ },
+ },
+};
+
+/**
+ * Return whether sunset announcements related to w3up-launch should be shown.
+ * An announcement date must be explicitly configured via env var, and now must be after that date.
+ * @param {Date} at - time at which to return whether to show the announcement
+ * @param {Date|undefined} [announcementStartDate] - when to begin showing announcements.
+ * If not provided, always return false.
+ */
+export const shouldShowSunsetAnnouncement = (at = new Date(), announcementStartDate = sunsetAnnouncementStartDate) => {
+ return announcementStartDate && at > announcementStartDate;
+};
+
/**
* copy for banner message across top of some web3.storage pages when w3up ships
*/
export const W3upMigrationRecommendationCopy = () => {
+ console.log('rendering W3upMigrationRecommendationCopy', w3upLaunchContextDefaults);
const createNewAccountHref = 'https://console.web3.storage/?intent=create-account';
const learnWhatsNewHref = 'https://console.web3.storage/?intent=learn-new-web3storage-experience';
+ const sunsetDateFormatter = new Intl.DateTimeFormat(undefined, { dateStyle: 'long' });
return (
<>
- This web3.storage product will sunset on January 9, 2024. We recommend migrating your usage of web3.storage to the
- new web3.storage.
Click here to create a new account and
+ This web3.storage product will sunset on {sunsetDateFormatter.format(sunsetStartDate)}. We recommend migrating
+ your usage of web3.storage to the new web3.storage.
+
+
Click here to create a new account and
here to read about what’s awesome about the new web3.storage experience.
>
);
};
-
-const prelaunchStartEnv = process.env.NEXT_PUBLIC_W3UP_PRELAUNCH_START;
-
-export const w3upLaunchContextDefaults = {
- stages: {
- prelaunch: {
- start: prelaunchStartEnv ? new Date(Date.parse(prelaunchStartEnv)) : undefined,
- },
- },
-};
diff --git a/packages/website/pages/account/payment.js b/packages/website/pages/account/payment.js
index 4b76d901e3..babdf3ebec 100644
--- a/packages/website/pages/account/payment.js
+++ b/packages/website/pages/account/payment.js
@@ -5,7 +5,6 @@
import { parse as queryParse } from 'querystring';
import { useState, useEffect, useMemo } from 'react';
-import { createPortal } from 'react-dom';
import { Elements, ElementsConsumer } from '@stripe/react-stripe-js';
import { loadStripe } from '@stripe/stripe-js';
@@ -19,7 +18,7 @@ import { plans, freePlan } from '../../components/contexts/plansContext';
import { userBillingSettings } from '../../lib/api';
import GeneralPageData from '../../content/pages/general.json';
import constants from '../../lib/constants.js';
-import { W3upMigrationRecommendationCopy } from '../../components/w3up-launch.js';
+import { W3upMigrationRecommendationCopy, shouldShowSunsetAnnouncement } from '../../components/w3up-launch.js';
import * as PageBannerPortal from '../../components/page-banner/page-banner-portal.js';
/**
@@ -126,19 +125,13 @@ const PaymentSettingsPage = props => {
const savedPaymentMethod = useMemo(() => {
return paymentSettings?.paymentMethod;
}, [paymentSettings]);
- const pageBannerPortal = document.querySelector(
- `#${PageBannerPortal.defaultPortalElementId} .${PageBannerPortal.defaultContentsClassName}`
- );
return (
<>
- {pageBannerPortal &&
- createPortal(
- <>
-
- >,
- pageBannerPortal
- )}
-
+ {shouldShowSunsetAnnouncement() && (
+
+
+
+ )}
<>