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

Laushinka/error form 10062 #10071

Merged
merged 1 commit into from
May 25, 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
13 changes: 2 additions & 11 deletions components/dashboard/src/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import fresh from "./images/welcome/fresh.svg";
import prebuild from "./images/welcome/prebuild.svg";
import exclamation from "./images/exclamation.svg";
import { getURLHash } from "./App";
import ErrorMessage from "./components/ErrorMessage";

function Item(props: { icon: string; iconSize?: string; text: string }) {
const iconSize = props.iconSize || 28;
Expand Down Expand Up @@ -225,17 +226,7 @@ export function Login() {
))
)}
</div>

{errorMessage && (
<div className="mt-16 flex space-x-2 py-6 px-6 w-96 justify-between bg-gitpod-kumquat-light rounded-xl">
<div className="pr-3 self-center w-6">
<img src={exclamation} />
</div>
<div className="flex-1 flex flex-col">
<p className="text-gitpod-red text-sm">{errorMessage}</p>
</div>
</div>
)}
{errorMessage && <ErrorMessage imgSrc={exclamation} message={errorMessage} />}
</div>
</div>
<div className="flex-none mx-auto h-20 text-center">
Expand Down
30 changes: 30 additions & 0 deletions components/dashboard/src/components/ErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/

import FeedbackComponent from "../feedback-form/FeedbackComponent";

function ErrorMessage(props: { imgSrc: string; imgAlt?: string; message: string }) {
return (
<>
<div className="mt-16 flex space-x-2 py-6 px-6 w-96 justify-between bg-gitpod-kumquat-light rounded-xl">
<div className="pr-3 self-center w-6">
<img src={props.imgSrc} alt={props.imgAlt || "An error message"} />
</div>
<div className="flex-1 flex flex-col">
<p className="text-gitpod-red text-sm">{props.message}</p>
</div>
</div>
<FeedbackComponent
message={"Was this error message helpful?"}
initialSize={24}
isError={true}
isModal={false}
/>
</>
);
}

export default ErrorMessage;
86 changes: 64 additions & 22 deletions components/dashboard/src/feedback-form/FeedbackComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,23 @@ import meh from "../images/feedback/meh-emoji.svg";
import crying from "../images/feedback/crying-emoji.svg";
import { trackEvent } from "../Analytics";

function FeedbackComponent(props: { onClose: () => void; onSubmit: () => void; isModal: boolean }) {
function FeedbackComponent(props: {
onClose?: () => void;
isModal: boolean;
isError: boolean;
message?: string;
initialSize?: number;
}) {
const [text, setText] = useState<string>("");
const [selectedEmoji, setSelectedEmoji] = useState<number | undefined>();
const [isFeedbackSubmitted, setIsFeedbackSubmitted] = useState<boolean>(false);

const height = props.isModal ? "300px" : "";
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Coming to this line triggered from the comment in #10071 (comment). Although non-blocking and a minor issue, is there a technical limitation that led us to remove this?

Copy link
Contributor Author

@laushinka laushinka May 24, 2022

Choose a reason for hiding this comment

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

Made a comment here Ah you already linked it. Yes that was the technical limitation from my end - would love some pointers here!

Copy link
Contributor

@gtsiolis gtsiolis May 24, 2022

Choose a reason for hiding this comment

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

@laushinka Haven't checked this in-depth, but I was thinking we could explicitly and conditionally set padding using utility classes for having a fixed modal height in the case of the modal, as we do now in https://github.com/gitpod-io/gitpod/pull/10071/files#diff-51811862e7996f416f9f7d73ff24341eecd96f3c083fb46d1b00b6cf94b50686R139. Since we're using a specific typography and spacing scale system, there must be a padding values that could help us set a modal height exactly as it the step 2 of the feedback modal.


const onClose = () => {
if (props.onClose) {
props.onClose();
}
Comment on lines +26 to +28
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use optional chaining here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review, @andrew-farries! I tried that but the linter still didn't like it 🙈

setSelectedEmoji(undefined);
};
const onSubmit = () => {
if (selectedEmoji) {
const feedbackObj = {
Expand All @@ -28,7 +39,7 @@ function FeedbackComponent(props: { onClose: () => void; onSubmit: () => void; i
trackEvent("feedback_submitted", feedbackObj);
}

props.onSubmit();
setIsFeedbackSubmitted(true);
};

const handleClick = (emojiScore: number) => {
Expand All @@ -54,12 +65,42 @@ function FeedbackComponent(props: { onClose: () => void; onSubmit: () => void; i
</button>
));
};

const minimisedFirstView = !selectedEmoji && !isFeedbackSubmitted;
const expandedWithTextView = selectedEmoji && !isFeedbackSubmitted;

return (
<>
<h3 className="mb-4">Send Feedback</h3>
{selectedEmoji ? (
{props.isModal && !isFeedbackSubmitted && <h3 className="mb-4">Send Feedback</h3>}
{minimisedFirstView && (
<div
className={
"flex flex-col justify-center px-6 py-4 border-gray-200 dark:border-gray-800 " +
(props.isError ? "mt-20 bg-gray-100 dark:bg-gray-800 rounded-xl" : "border-t")
}
>
<p
className={
"text-center text-base mb-3 dark:text-gray-400 " +
(props.isError ? "text-gray-400" : "text-gray-500")
}
>
{props.message}
</p>

<div className="flex items-center justify-center w-full">{emojiGroup(props.initialSize || 50)}</div>
</div>
)}
{expandedWithTextView && (
<>
<div className="flex flex-col -mx-6 px-6 py-4 border-t border-b border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900">
<div
className={
"flex flex-col px-6 py-4 border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 " +
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Minor color background and padding fix.

Suggested change
"flex flex-col px-6 py-4 border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 " +
"flex flex-col px-4 py-4 border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-800 " +

(props.isError
? "w-96 mt-6 bg-gray-100 dark:bg-gray-800 rounded-xl"
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Minor bottom margin to always have some whitespace around the modal.

Suggested change
? "w-96 mt-6 bg-gray-100 dark:bg-gray-800 rounded-xl"
? "w-96 mt-6 bg-gray-50 dark:bg-gray-800 rounded-xl mb-4"

: "-mx-6 border-t border-b")
}
>
<div className="relative">
<div className="absolute flex bottom-5 right-5 -space-x-3">{emojiGroup(24)}</div>
<textarea
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Some class changes to restore some color changes as I cannot add this code suggestion directly on the line.

For https://github.com/gitpod-io/gitpod/pull/10071/files#diff-51811862e7996f416f9f7d73ff24341eecd96f3c083fb46d1b00b6cf94b50686R109:

w-full resize-none text-gray-600 dark:text-gray-300 focus:ring-0 focus:border-gray-400 dark:focus:border-gray-400 rounded-md border dark:bg-gray-800 dark:border-gray-500 border-gray-300

Expand All @@ -82,26 +123,27 @@ function FeedbackComponent(props: { onClose: () => void; onSubmit: () => void; i
.
</p>
</div>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

<div className="flex justify-end mt-6">
<button className="secondary" onClick={props.onClose}>
Cancel
</button>
<button className="ml-2" onClick={onSubmit}>
Send Feedback
</button>
<div className="flex justify-end mt-6">
<button className="secondary" onClick={onClose}>
Cancel
</button>
<button className="ml-2" onClick={onSubmit}>
Send Feedback
</button>
</div>
Comment on lines +126 to +133
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Just realized you're trying to reuse the same component in both cases, however, this is breaking the modal structure (see line separator below action buttons) and the padding bug now has moved to the first step of the feedback step.

Feedback Modal (Step 1) Feedback Modal (Step 2)
Screenshot 2022-05-24 at 5 43 22 PM Screenshot 2022-05-24 at 5 43 12 PM

</div>
</>
) : (
)}
{isFeedbackSubmitted && (
<div
className="flex flex-col justify-center -mx-6 px-6 py-4 border-t border-gray-200 dark:border-gray-800"
style={{ height: height }}
className={
"flex flex-col px-6 py-4 border-gray-200 dark:border-gray-800 " +
(props.isError ? "mt-20 bg-gray-100 dark:bg-gray-800 rounded-xl" : "")
}
>
<p className="text-center text-lg mb-8 text-gray-500 dark:text-gray-400">
We'd love to know what you think!
<p className={"text-center text-base " + (props.isError ? "text-gray-400" : "text-gray-500")}>
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: In both cases, being able to dismiss the thanks message at the last step would be great to keep.

Thanks for your feedback, we appreciate it.
laushinka marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: Thanks for also including this step in the feedback modal used in the dashboard pages! 🙏

Copy link
Contributor

@gtsiolis gtsiolis May 24, 2022

Choose a reason for hiding this comment

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

suggestion: Since this PR now also includes the last step of the feedback widget, we could also align the designs to include the 🙏 emoji? You can grab the SVG from the specs included in #10124. Going with a simple inline structure sounds good. WDYT?

Closable last step Non-closable last step
Screenshot 2022-05-24 at 9 33 20 PM Screenshot 2022-05-24 at 9 40 44 PM

In case this sounds interesting to you, we could also reuse the alert component for this which now supports opting in for closable option and an icon, but let's skip this for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Removing the modal header could confuse users and introduces an inconsistent behavior of the feedback action. Maybe we could skip the header altogether moving away from the modal component as we want to introduce so many customizations here.

Thanks (Modal) Thanks (Error)
Screenshot 2022-05-24 at 5 48 08 PM Screenshot 2022-05-24 at 5 48 13 PM

</p>

<div className="flex items-center justify-center w-full space-x-3">{emojiGroup(50)}</div>
</div>
)}
</>
Expand Down
11 changes: 6 additions & 5 deletions components/dashboard/src/feedback-form/FeedbackModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ function FeedbackFormModal(props: { onClose: () => void }) {
props.onClose();
};

const onSubmit = () => {
props.onClose();
};

return (
<Modal visible={true} onClose={onClose}>
<FeedbackComponent onClose={onClose} onSubmit={onSubmit} isModal={true} />
<FeedbackComponent
laushinka marked this conversation as resolved.
Show resolved Hide resolved
onClose={onClose}
isModal={true}
isError={false}
message="We'd love to know what you think!"
/>
</Modal>
);
}
Expand Down
12 changes: 2 additions & 10 deletions components/dashboard/src/projects/NewProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import moment from "moment";
import { UserContext } from "../user-context";
import { trackEvent } from "../Analytics";
import exclamation from "../images/exclamation.svg";
import ErrorMessage from "../components/ErrorMessage";

export default function NewProject() {
const location = useLocation();
Expand Down Expand Up @@ -744,16 +745,7 @@ function GitProviders(props: {
})}
</div>

{errorMessage && (
<div className="mt-16 flex space-x-2 py-6 px-6 w-96 justify-between bg-gitpod-kumquat-light rounded-xl">
<div className="pr-3 self-center w-6">
<img src={exclamation} />
</div>
<div className="flex-1 flex flex-col">
<p className="text-gitpod-red text-sm">{errorMessage}</p>
</div>
</div>
)}
{errorMessage && <ErrorMessage imgSrc={exclamation} message={errorMessage} />}
</div>
</div>
);
Expand Down
9 changes: 9 additions & 0 deletions components/dashboard/src/start/CreateWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { SelectAccountPayload } from "@gitpod/gitpod-protocol/lib/auth";
import { SelectAccountModal } from "../settings/SelectAccountModal";
import { watchHeadlessLogs } from "../components/PrebuildLogs";
import CodeText from "../components/CodeText";
import FeedbackComponent from "../feedback-form/FeedbackComponent";

const WorkspaceLogs = React.lazy(() => import("../components/WorkspaceLogs"));

Expand Down Expand Up @@ -432,6 +433,14 @@ function RepositoryNotFoundView(p: { error: StartWorkspaceError }) {
<CodeText>{repoFullName}</CodeText>
</p>
{statusMessage}
{p.error && (
<FeedbackComponent
isModal={false}
message={"Was this error message helpful?"}
isError={true}
initialSize={24}
/>
)}
</StartPage>
);
}
Expand Down