Skip to content

[dashboard] add modal_dismiss tracking event #10132

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

Merged
merged 1 commit into from
May 30, 2022
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
1 change: 1 addition & 0 deletions components/dashboard/src/Setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function Setup() {
return (
<div>
{!showModal && (
// TODO: Use title and buttons props
<Modal visible={true} onClose={() => {}} closeable={false}>
<h3 className="pb-2">Welcome to Gitpod 🎉</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">
Expand Down
28 changes: 24 additions & 4 deletions components/dashboard/src/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
*/

import { useEffect } from "react";
import { getGitpodService } from "../service/service";

type CloseModalManner = "esc" | "enter" | "x";

export default function Modal(props: {
// specify a key if having the same title and window.location
specify?: string;
title?: string;
buttons?: React.ReactChild[] | React.ReactChild;
children: React.ReactChild[] | React.ReactChild;
Expand All @@ -16,20 +21,35 @@ export default function Modal(props: {
onClose: () => void;
onEnter?: () => boolean;
}) {
const closeModal = (manner: CloseModalManner) => {
props.onClose();
getGitpodService()
.server.trackEvent({
event: "modal_dismiss",
properties: {
manner,
title: props.title,
specify: props.specify,
path: window.location.pathname,
},
})
.then()
.catch(console.error);
};
const handler = (evt: KeyboardEvent) => {
if (evt.defaultPrevented) {
return;
}
if (evt.key === "Escape") {
props.onClose();
closeModal("esc");
}
if (evt.key === "Enter") {
if (props.onEnter) {
if (props.onEnter()) {
props.onClose();
closeModal("enter");
}
} else {
props.onClose();
closeModal("enter");
}
}
};
Expand Down Expand Up @@ -60,7 +80,7 @@ export default function Modal(props: {
{props.closeable !== false && (
<div
className="absolute right-7 top-6 cursor-pointer text-gray-800 dark:text-gray-100 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-md p-2"
onClick={props.onClose}
onClick={() => closeModal("x")}
>
<svg version="1.1" width="14px" height="14px" viewBox="0 0 100 100">
<line x1="0" y1="0" x2="100" y2="100" stroke="currentColor" strokeWidth="10px" />
Expand Down
1 change: 1 addition & 0 deletions components/dashboard/src/feedback-form/FeedbackModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function FeedbackFormModal(props: { onClose: () => void }) {
};

return (
// TODO: Use title and buttons props
<Modal visible={true} onClose={onClose}>
<FeedbackComponent
onClose={onClose}
Expand Down
1 change: 1 addition & 0 deletions components/dashboard/src/projects/ProjectVariables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function AddVariableModal(props: { project?: Project; onClose: () => void }) {
};

return (
// TODO: Use title and buttons props
<Modal
visible={true}
onClose={props.onClose}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function AddEnvVarModal(p: EnvVarModalProps) {
};

return (
// TODO: Use title and buttons props
<Modal visible={true} onClose={p.onClose} onEnter={save}>
<h3 className="mb-4">{isNew ? "New" : "Edit"} Variable</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 -mx-6 px-6 py-4 flex flex-col">
Expand Down
2 changes: 2 additions & 0 deletions components/dashboard/src/settings/Integrations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ function GitProviders() {
)}

{editModal && (
// TODO: Use title and buttons props
<Modal visible={true} onClose={() => setEditModal(undefined)}>
<h3 className="pb-2">Edit Permissions</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">
Expand Down Expand Up @@ -744,6 +745,7 @@ export function GitIntegrationModal(
};

return (
// TODO: Use title and buttons props
<Modal visible={!!props} onClose={onClose} closeable={props.closeable}>
<h3 className="pb-2">{mode === "new" ? "New Git Integration" : "Git Integration"}</h3>
<div className="space-y-4 border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">
Expand Down
4 changes: 4 additions & 0 deletions components/dashboard/src/settings/Plans.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ export default function () {
</a>
</InfoBox>
{!!confirmUpgradeToPlan && (
// TODO: Use title and buttons props
<Modal visible={true} onClose={() => setConfirmUpgradeToPlan(undefined)}>
<h3>Upgrade to {confirmUpgradeToPlan.name}</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-4 -mx-6 px-6 py-2">
Expand Down Expand Up @@ -755,6 +756,7 @@ export default function () {
</Modal>
)}
{!!confirmDowngradeToPlan && (
// TODO: Use title and buttons props
<Modal visible={true} onClose={() => setConfirmDowngradeToPlan(undefined)}>
<h3>Downgrade to {confirmDowngradeToPlan.name}</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-4 -mx-6 px-6 py-2">
Expand Down Expand Up @@ -784,6 +786,7 @@ export default function () {
</Modal>
)}
{isConfirmCancelDowngrade && (
// TODO: Use title and buttons props
<Modal visible={true} onClose={() => setIsConfirmCancelDowngrade(false)}>
<h3>Cancel downgrade and stay with {currentPlan.name}</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-4 -mx-6 px-6 py-2">
Expand All @@ -800,6 +803,7 @@ export default function () {
</Modal>
)}
{!!teamClaimModal && (
// TODO: Use title and buttons props
<Modal visible={true} onClose={() => setTeamClaimModal(undefined)}>
<h3 className="pb-2">Team Invitation</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">
Expand Down
1 change: 1 addition & 0 deletions components/dashboard/src/settings/SelectAccountModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function SelectAccountModal(
};

return (
// TODO: Use title and buttons props
<Modal visible={true} onClose={props.close}>
<h3 className="pb-2">Select Account</h3>
<div className="border-t border-b border-gray-200 mt-2 -mx-6 px-6 py-4">
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/src/settings/SelectIDE.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default function SelectIDE(props: SelectIDEProps) {
</InfoBox>
)}

<p className="text-left w-full text-gray-500">
<p className="text-left w-full text-gray-500 dark:text-gray-400">
The <strong>JetBrains desktop IDEs</strong> are currently in beta.{" "}
<a
href="https://github.com/gitpod-io/gitpod/issues/6576"
Expand Down
34 changes: 17 additions & 17 deletions components/dashboard/src/settings/SelectIDEModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ export default function (props: SelectIDEModalProps) {
};

return (
<Modal visible={visible} onClose={handleContinue} closeable={true} className="_max-w-xl">
<h3 className="pb-2">Select Editor</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">
<p className="text-gray-500 text-base pb-3">
Choose the editor for opening workspaces. You can always change later the editor in{" "}
<Link to={"/preferences"} className="gp-link">
user preferences
</Link>
.
</p>
<SelectIDE updateUserContext={false} location={props.location} />
</div>
<div className="flex justify-end mt-6">
<button onClick={handleContinue} className="ml-2">
Continue
</button>
</div>
<Modal
title="Select Editor"
specify={props.location}
visible={visible}
onClose={handleContinue}
closeable={true}
className="_max-w-xl"
buttons={<button onClick={handleContinue}>Continue</button>}
>
<p className="text-gray-500 dark:text-gray-400 text-base pb-3">
Choose the editor for opening workspaces. You can always change later the editor in{" "}
<Link to={"/preferences"} className="gp-link">
user preferences
</Link>
.
</p>
<SelectIDE updateUserContext={false} location={props.location} />
</Modal>
);
}
6 changes: 5 additions & 1 deletion components/dashboard/src/settings/Teams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ function AllTeams() {
<a
href="https://www.gitpod.io/docs/teams/"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
className="gp-link"
>
Learn more
Expand Down Expand Up @@ -649,6 +649,7 @@ function InviteMembersModal(props: { sub: TeamSubscription; onClose: () => void
};

return (
// TODO: Use title and buttons props
<Modal visible={true} onClose={props.onClose}>
<h3 className="pb-2">Invite Members</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4 space-y-2">
Expand Down Expand Up @@ -707,6 +708,7 @@ function AddMembersModal(props: {
};

return (
// TODO: Use title and buttons props
<Modal visible={true} onClose={props.onClose}>
<h3 className="pb-2">Add Members</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4">
Expand Down Expand Up @@ -772,6 +774,7 @@ function NewTeamModal(props: {
};

return (
// TODO: Use title and buttons props
<Modal visible={true} onClose={props.onClose}>
<h3 className="pb-2">New Team Plan</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4 space-y-2">
Expand Down Expand Up @@ -851,6 +854,7 @@ function ManageTeamModal(props: { slots: Slot[]; slotInputHandler: SlotInputHand
}, [props.slots]);

return (
// TODO: Use title and buttons props
<Modal visible={true} onClose={props.onClose}>
<h3 className="pb-2">Manage Team</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-2 -mx-6 px-6 py-4 space-y-2">
Expand Down
2 changes: 2 additions & 0 deletions components/dashboard/src/start/CreateWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
return <StartWorkspace {...parseProps(result?.createdWorkspaceId, window.location.search)} />;
} else if (result?.existingWorkspaces) {
statusMessage = (
// TODO: Use title and buttons props
<Modal visible={true} closeable={false} onClose={() => {}}>
<h3>Running Workspaces</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 mt-4 -mx-6 px-6 py-2">
Expand Down Expand Up @@ -294,6 +295,7 @@ export default class CreateWorkspace extends React.Component<CreateWorkspaceProp
function LimitReachedModal(p: { children: React.ReactNode }) {
const { user } = useContext(UserContext);
return (
// TODO: Use title and buttons props
<Modal visible={true} closeable={false} onClose={() => {}}>
<h3 className="flex">
<span className="flex-grow">Limit Reached</span>
Expand Down
1 change: 1 addition & 0 deletions components/dashboard/src/teams/Members.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export default function () {
</ItemsList>
</div>
{genericInvite && showInviteModal && (
// TODO: Use title and buttons props
<Modal visible={true} onClose={() => setShowInviteModal(false)}>
<h3 className="mb-4">Invite Members</h3>
<div className="border-t border-b border-gray-200 dark:border-gray-800 -mx-6 px-6 py-4 flex flex-col">
Expand Down
1 change: 1 addition & 0 deletions components/dashboard/src/whatsnew/WhatsNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export function WhatsNew(props: { onClose: () => void }) {
};

return (
// TODO: Use title and buttons props
<Modal visible={!!visibleEntry} onClose={internalClose}>
<h3 className="pb-4">What's New 🎁</h3>
<>{visibleEntry && user ? visibleEntry.children(user, setUser) : <></>}</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default function ConnectToSSHModal(props: {
onClose: () => void;
}) {
return (
// TODO: Use title and buttons props
<Modal visible={true} onClose={props.onClose}>
<h3 className="mb-4">Connect via SSH</h3>
<SSHView workspaceId={props.workspaceId} ownerToken={props.ownerToken} ideUrl={props.ideUrl} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function StartWorkspaceModal() {
}, [location]);

return (
// TODO: Use title and buttons props
<Modal
onClose={() => setIsStartWorkspaceModalVisible(false)}
onEnter={() => false}
Expand Down
1 change: 1 addition & 0 deletions components/dashboard/src/workspaces/WorkspaceEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export function WorkspaceEntry({ desc, model, isAdmin, stopWorkspace }: Props) {
onConfirm={() => model.deleteWorkspace(ws.id)}
/>
)}
{/* TODO: Use title and buttons props */}
<Modal
visible={isRenameModalVisible}
onClose={() => setRenameModalVisible(false)}
Expand Down