Skip to content

Commit

Permalink
chore: Add newsletter signup to bottom banner (SCE-29) (#1116)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloster authored Oct 1, 2024
1 parent 563a03c commit 1f0048f
Show file tree
Hide file tree
Showing 16 changed files with 515 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .infra/rdev/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ stack:
services:
explorer:
image:
tag: sha-a694292f
tag: sha-e352565b
replicaCount: 1
env:
# env vars common to all deployment stages
Expand Down
24 changes: 24 additions & 0 deletions client/__tests__/e2e/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,30 @@ for (const testDataset of testDatasets) {
testInfo
);
});

test("newsletter signup modal opens and closes", async ({ page }) => {
await goToPage(page, url);

await page.getByTestId("newsletter-modal-open-button").click();

await expect(
page.getByTestId("newsletter-modal-content")
).toBeVisible();

await page.getByTestId("newsletter-email-input").fill("test");

await page.getByTestId("newsletter-subscribe-button").click();

await expect(
page.getByText("Please provide a valid email address.")
).toBeVisible();

await page.getByTestId("newsletter-modal-close-button").click();

await expect(
page.getByTestId("newsletter-modal-content")
).not.toBeVisible();
});
});

test("resize graph", async ({ page }, testInfo) => {
Expand Down
5 changes: 5 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,10 @@
data-template="<%= OBSOLETE_TEMPLATE %>"
data-regex="<%= OBSOLETE_REGEX %>"
></script>
<!-- Hubspot -->
<script>
var _hsq = (window._hsq = window._hsq || []);
_hsq.push(["doNotTrack"]);
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions client/index_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
data-template="<%= OBSOLETE_TEMPLATE %>"
data-regex="<%= OBSOLETE_REGEX %>"
></script>
<!-- Hubspot -->
<script>
var _hsq = (window._hsq = window._hsq || []);
_hsq.push(["doNotTrack"]);
</script>
{% for script in SCRIPTS -%}
<script type="text/javascript"
{{ ('integrity="%s"' % script.integrity) | safe if script.integrity }}
Expand Down
6 changes: 6 additions & 0 deletions client/src/analytics/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,10 @@ export enum EVENTS {
DOCUMENTATION_CLICK_NAV = "DOCUMENTATION_CLICK_NAV",
CELL_GUIDE_CLICK_NAV = "CELL_GUIDE_CLICK_NAV",
DE_CLICK_NAV = "DE_CLICK_NAV",

NEWSLETTER_SIGNUP_SUCCESS = "NEWSLETTER_SIGNUP_SUCCESS",
NEWSLETTER_SIGNUP_FAILURE = "NEWSLETTER_SIGNUP_FAILURE",
NEWSLETTER_OPEN_MODAL_CLICKED = "NEWSLETTER_OPEN_MODAL_CLICKED",
NEWSLETTER_EMAIL_SUBMITTED = "NEWSLETTER_EMAIL_SUBMITTED",
NEWSLETTER_SUBSCRIBE_BUTTON_AVAILABLE = "NEWSLETTER_SUBSCRIBE_BUTTON_AVAILABLE",
}
4 changes: 4 additions & 0 deletions client/src/assets.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "*.svg" {
const content: string;
export default content;
}
10 changes: 10 additions & 0 deletions client/src/assets/img/CellxGene.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions client/src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { selectIsSeamlessEnabled } from "../../selectors/datasetMetadata";
import Graph from "../Graph/Graph";
import Scatterplot from "../scatterplot/scatterplot";
import PanelEmbedding from "../PanelEmbedding/PanelEmbedding";
import { BANNER_FEEDBACK_SURVEY_LINK } from "../BottomBanner/constants";

interface StateProps {
loading: RootState["controls"]["loading"];
Expand Down Expand Up @@ -125,7 +124,7 @@ class App extends React.Component<StateProps & { dispatch: AppDispatch }> {
<LeftSideBar />
<RightSideBar />
</Layout>
<BottomBanner surveyLink={BANNER_FEEDBACK_SURVEY_LINK} />
<BottomBanner />
</>
)}
</ThemeProvider>
Expand Down
76 changes: 52 additions & 24 deletions client/src/components/BottomBanner/BottomBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import React, { memo } from "react";
import { connect } from "react-redux";

import { AppDispatch, RootState } from "reducers";

import {
BOTTOM_BANNER_ID,
StyledBanner,
StyledBottomBannerWrapper,
StyledLink,
HiddenHubspotForm,
} from "./style";
import {
BOTTOM_BANNER_SURVEY_LINK_TEXT,
BOTTOM_BANNER_SURVEY_TEXT,
BANNER_FEEDBACK_SURVEY_LINK,
BOTTOM_BANNER_NEWSLETTER_LINK_TEXT,
BOTTOM_BANNER_NEWSLETTER_TEXT,
FORM_CONTAINER_ID,
} from "./constants";
import { NewsletterSignup } from "./components/NewsletterSignup/NewsletterSignup";
import { useConnect } from "./connect";

export interface BottomBannerProps {
surveyLink: string;
showBottomBanner: boolean;
dispatch: AppDispatch;
}
Expand All @@ -26,19 +34,7 @@ const mapDispatchToProps = (dispatch: AppDispatch) => ({
dispatch,
});

function BannerContent({ surveyLink }: { surveyLink: string }): JSX.Element {
return (
<span>
{BOTTOM_BANNER_SURVEY_TEXT}
<StyledLink href={surveyLink} target="_blank" rel="noopener">
{BOTTOM_BANNER_SURVEY_LINK_TEXT}
</StyledLink>
</span>
);
}

function BottomBanner({
surveyLink,
showBottomBanner,
dispatch,
}: BottomBannerProps): JSX.Element | null {
Expand All @@ -49,21 +45,53 @@ function BottomBanner({
});
};

const { toggleNewsletterSignupModal, newsletterModalIsOpen } = useConnect();

if (!showBottomBanner) return null;

return (
<StyledBottomBannerWrapper
id={BOTTOM_BANNER_ID}
data-testid={BOTTOM_BANNER_ID}
>
<StyledBanner
dismissible
sdsType="primary"
onClose={setBottomBannerLastClosedTime}
<>
<HiddenHubspotForm id={FORM_CONTAINER_ID} />
<StyledBottomBannerWrapper
id={BOTTOM_BANNER_ID}
data-testid={BOTTOM_BANNER_ID}
>
<BannerContent surveyLink={surveyLink} />
</StyledBanner>
</StyledBottomBannerWrapper>
<StyledBanner
dismissible
sdsType="primary"
onClose={setBottomBannerLastClosedTime}
>
<span>
<span>
<StyledLink
onClick={() => {
toggleNewsletterSignupModal();
}}
data-testid="newsletter-modal-open-button"
>
{" "}
{BOTTOM_BANNER_NEWSLETTER_LINK_TEXT}
</StyledLink>
{BOTTOM_BANNER_NEWSLETTER_TEXT}{" "}
</span>
<span>
{BOTTOM_BANNER_SURVEY_TEXT}
<StyledLink
href={BANNER_FEEDBACK_SURVEY_LINK}
target="_blank"
rel="noopener"
>
{BOTTOM_BANNER_SURVEY_LINK_TEXT}
</StyledLink>
</span>
</span>{" "}
</StyledBanner>
<NewsletterSignup
isOpen={newsletterModalIsOpen}
toggleModal={toggleNewsletterSignupModal}
/>
</StyledBottomBannerWrapper>
</>
);
}

Expand Down
Loading

0 comments on commit 1f0048f

Please sign in to comment.