Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add newsletter signup to bottom banner (SCE-29) #1116

Merged
merged 14 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-7d92494d
tag: sha-ae2edd43
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
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you have a reminder to add events to Plausible already 👍 Thanks so much!

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
Loading