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

Add Support form #9717

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ NEXT_PUBLIC_IMAGE_URL=https://opengraph.replay.io/
FRONTEND_API_SECRET=
# API Key to source icons from Figma
FIGMA_TOKEN=
# Support feedback form
FORM_CARRY_TOKEN=
# API keys used by e2e tests
AUTOMATED_TEST_SECRET=
AUTHENTICATED_TESTS_WORKSPACE_API_KEY=
AUTHENTICATED_TESTS_WORKSPACE_API_KEY=
5 changes: 5 additions & 0 deletions packages/replay-next/components/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export type IconType =
| "remove-alternate"
| "rewind"
| "save"
| "screenshot"
| "search"
| "set-focus-end"
| "set-focus-start"
Expand Down Expand Up @@ -392,6 +393,10 @@ export default function Icon({
path =
"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3zm3-10H5V5h10v4z";
break;
case "screenshot":
path =
"M3 4V1H5V4H8V6H5V9H3V6H0V4M6 10V7H9V4H16L17.8 6H21C22.1 6 23 6.9 23 8V20C23 21.1 22.1 22 21 22H5C3.9 22 3 21.1 3 20V10M13 19C17.45 19 19.69 13.62 16.54 10.46C13.39 7.31 8 9.55 8 14C8 16.76 10.24 19 13 19M9.8 14C9.8 16.85 13.25 18.28 15.26 16.26C17.28 14.25 15.85 10.8 13 10.8C11.24 10.8 9.8 12.24 9.8 14Z";
break;
case "search":
path =
"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z";
Expand Down
3 changes: 0 additions & 3 deletions packages/replay-next/pages/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -1198,11 +1198,8 @@
/* menu styles */
--context-menu-background-color: var(--context-menu-bgcolor);
--context-menu-border-color: var(--context-menu-border-color);
--context-menu-border-radius: 0.5rem;
--context-menu-border-size: 1px;
--context-menu-filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.5));
--context-menu-font-family: var(--font-family-default);
--context-menu-padding: 0.25rem 0;
--context-menu-transition-duration: 250ms;
--context-menu-z-index: 25;

Expand Down
29 changes: 29 additions & 0 deletions pages/api/feedback.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { NextApiRequest, NextApiResponse } from "next";

const { FORM_CARRY_TOKEN } = process.env;

export default async function handler(request: NextApiRequest, response: NextApiResponse) {
try {
console.log("[/api/feedback] posting:\n\n", request.body);

// https://formcarry.com/form/nextjs-contact-form
const apiResponse = await fetch(`https://formcarry.com/s/${FORM_CARRY_TOKEN}`, {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This token is in 1Password (for anyone who wants to test locally)

method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(request.body),
});

const text = await apiResponse.text();

console.log("[/api/feedback] response:\n\n", text);

response.status(200).send({ success: true });
} catch (error) {
console.error(error);

response.status(500).send({ error: true });
}
}
6 changes: 6 additions & 0 deletions src/ui/actions/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type SetSelectedPrimaryPanelAction = Action<"set_selected_primary_panel"> & {
panel: PrimaryPanelName;
};
type SetShowCommandPaletteAction = Action<"set_show_command_palette"> & { value: boolean };
type SetShowSupportForm = Action<"set_show_support_form"> & { value: boolean };

type SetToolboxLayoutAction = Action<"set_toolbox_layout"> & {
layout: ToolboxLayout;
Expand All @@ -33,10 +34,15 @@ export type LayoutAction =
| SetSelectedPanelAction
| SetSelectedPrimaryPanelAction
| SetShowCommandPaletteAction
| SetShowSupportForm
| SetToolboxLayoutAction
| SetViewModeAction
| DismissLocalNagAction;

export function setShowSupportForm(value: boolean): SetShowSupportForm {
return { type: "set_show_support_form", value };
}

export function setShowCommandPalette(value: boolean): SetShowCommandPaletteAction {
return { type: "set_show_command_palette", value };
}
Expand Down
4 changes: 4 additions & 0 deletions src/ui/components/DevTools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { DevToolsDynamicLoadingMessage } from "ui/components/DevToolsDynamicLoad
import { DevToolsProcessingScreen } from "ui/components/DevToolsProcessingScreen";
import { RecordingDocumentTitle } from "ui/components/RecordingDocumentTitle";
import TerminalContextAdapter from "ui/components/SecondaryToolbox/TerminalContextAdapter";
import { SupportForm } from "ui/components/SupportForm";
import { TestSuiteContextRoot } from "ui/components/TestSuite/views/TestSuiteContext";
import { useGetRecording, useGetRecordingId } from "ui/hooks/recordings";
import { useTrackLoadingIdleTime } from "ui/hooks/tracking";
Expand Down Expand Up @@ -145,6 +146,7 @@ function _DevTools({
loadingFinished,
sessionId,
showCommandPalette,
showSupportForm,
uploadComplete,
}: DevToolsProps) {
const { isAuthenticated } = useAuth0();
Expand Down Expand Up @@ -273,6 +275,7 @@ function _DevTools({
<Header />
<Body />
{showCommandPalette ? <CommandPaletteModal /> : null}
{showSupportForm ? <SupportForm /> : null}
<KeyboardShortcuts />
</KeyModifiers>
</LayoutContextAdapter>
Expand All @@ -294,6 +297,7 @@ const connector = connect(
loadingFinished: selectors.getLoadingFinished(state),
sessionId: selectors.getSessionId(state),
showCommandPalette: selectors.getShowCommandPalette(state),
showSupportForm: selectors.getShowSupportForm(state),
}),
{
createSocket,
Expand Down
14 changes: 10 additions & 4 deletions src/ui/components/Header/UserOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { recordingCapabilitiesCache } from "replay-next/src/suspense/BuildIdCach
import { ReplayClientContext } from "shared/client/ReplayClientContext";
import useLocalStorageUserData from "shared/user-data/LocalStorage/useLocalStorageUserData";
import { setModal } from "ui/actions/app";
import { setToolboxLayout } from "ui/actions/layout";
import { setShowSupportForm, setToolboxLayout } from "ui/actions/layout";
import LoginButton from "ui/components/LoginButton";
import Dropdown from "ui/components/shared/Dropdown";
import Icon from "ui/components/shared/Icon";
Expand Down Expand Up @@ -171,6 +171,11 @@ export default function UserOptions() {
trackEvent(`layout.settings.set_${orientation}`);
};

const onSupportClick = () => {
dispatch(setShowSupportForm(true));
setExpanded(false);
};

const onVideoPanelCollapseChange = (collapsed: boolean) => {
setVideoPanelCollapsed(collapsed);
trackEvent(collapsed ? "video.settings.set_collapsed" : "video.settings.set_expanded");
Expand Down Expand Up @@ -203,10 +208,11 @@ export default function UserOptions() {
<span className="flex-1 text-left">Docs</span>
<Icon filename="docs" className="bg-iconColor" />
</button>
<ExternalLink className="row group" href="https://discord.gg/n2dTK6kcRX">
<span className="flex-1 text-left">Chat with us</span>

<button className="row group" onClick={onSupportClick}>
<span className="flex-1 text-left">Support</span>
<Icon filename="help" className="bg-iconColor" />
</ExternalLink>
</button>

<LoginButton iconPosition="right" />
</Dropdown>
Expand Down
140 changes: 140 additions & 0 deletions src/ui/components/SupportForm.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
.Background {
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
z-index: var(--context-menu-z-index);
}

.Modal {
background-color: var(--context-menu-background-color);
border: 1px solid var(--context-menu-border-color);
border-radius: 0.5rem;
filter: var(--context-menu-filter);
padding: 0.5rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
font-size: var(--font-size-regular);
font-family: var(--font-family-default);
width: 20rem;
}
.Modal[data-confirmation] {
align-items: center;
padding: 1rem;
}

.Header {
font-size: var(--font-size-large);
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
font-weight: bold;
}

.TextArea {
height: 8rem;
resize: none;
border-radius: 0.25rem;
border: 1px solid var(--theme-border);
padding: 0.25rem 0.5rem;
font-size: var(--font-size-regular);
background-color: var(--theme-console-input-bgcolor);
}
.TextArea:focus {
box-shadow: none;
outline-offset: 0;
outline: 1px solid var(--primary-accent);
border: 1px solid var(--primary-accent);
}
.TextArea::placeholder {
color: var(--color-dimmer);
}

.FormActions {
border-bottom: 1px solid var(--context-menu-border-color);
padding-bottom: 0.5rem;
display: flex;
flex-direction: row;
align-items: center;
gap: 1ch;
}

.CloseButton:focus {
outline-offset: 2px;
outline: 2px solid var(--primary-accent);
border-radius: 0.25rem;
}

.CloseButtonIcon {
width: 1rem;
height: 1rem;
}

.ScreenshotButton {
flex: 0 0 auto;
align-items: center;
justify-content: center;
height: 2rem;
width: 2rem;
padding: 0;
}
.ScreenshotButton:focus {
border-color: transparent;
box-shadow: none;
outline-offset: 2px;
outline: 2px solid var(--primary-accent);
}
.ScreenshotButtonIcon {
width: 1rem;
height: 1rem;
color: var(--primary-accent);
}

.SubmitButton {
flex: 1 1 auto;
justify-content: center;
}
.SubmitButton:focus {
border-color: transparent;
box-shadow: none;
outline-offset: 2px;
outline: 2px solid var(--primary-accent);
}

.Footer {
display: flex;
flex-direction: row;
align-items: center;
gap: 1ch;
padding: 0 0.125rem;
user-select: none;
}
.Footer[data-confirmation] {
margin-top: 1rem;
}
.Footer:focus {
outline-offset: 2px;
outline: 2px solid var(--primary-accent);
border-radius: 2px;
}

.FooterIcon {
fill: currentColor;
}

.FooterButton:focus {
border-color: transparent;
box-shadow: none;
outline-offset: 2px;
outline: 2px solid var(--primary-accent);
}

.ConfirmationMessage {
margin-bottom: 1rem;
}
Loading
Loading