-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[dashboard] implement feedback modal 9928 #10061
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
components/dashboard/src/feedback-form/FeedbackComponent.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/** | ||
* 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 { useState } from "react"; | ||
import starry from "../images/feedback/starry-emoji.svg"; | ||
import happy from "../images/feedback/happy-emoji.svg"; | ||
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 }) { | ||
const [text, setText] = useState<string>(""); | ||
const [selectedEmoji, setSelectedEmoji] = useState<number | undefined>(); | ||
|
||
const height = props.isModal ? "300px" : ""; | ||
|
||
const onSubmit = () => { | ||
if (selectedEmoji) { | ||
const feedbackObj = { | ||
score: selectedEmoji, | ||
feedback: text, | ||
href: window.location.href, | ||
path: window.location.pathname, | ||
}; | ||
trackEvent("feedback_submitted", feedbackObj); | ||
} | ||
|
||
props.onSubmit(); | ||
}; | ||
|
||
const handleClick = (emojiScore: number) => { | ||
setSelectedEmoji(emojiScore); | ||
}; | ||
|
||
const emojiGroup = (width: number) => { | ||
laushinka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const emojiList = [ | ||
{ id: 4, name: "starry", src: starry }, | ||
{ id: 3, name: "happy", src: happy }, | ||
{ id: 2, name: "meh", src: meh }, | ||
{ id: 1, name: "crying", src: crying }, | ||
]; | ||
return emojiList.map((emoji) => ( | ||
<button | ||
className={ | ||
"hover:scale-150 transform bg-transparent bottom-5 right-5 cursor-pointer " + | ||
(selectedEmoji === emoji.id ? "" : "grayed") | ||
} | ||
onClick={() => handleClick(emoji.id)} | ||
> | ||
<img src={emoji.src} alt={`${emoji.name} emoji`} width={width || "24px"} title={emoji.name} /> | ||
</button> | ||
)); | ||
}; | ||
return ( | ||
<> | ||
<h3 className="mb-4">Send Feedback</h3> | ||
{selectedEmoji ? ( | ||
<> | ||
<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="relative"> | ||
<div className="absolute flex bottom-5 right-5 -space-x-3">{emojiGroup(24)}</div> | ||
laushinka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<textarea | ||
gtsiolis marked this conversation as resolved.
Show resolved
Hide resolved
laushinka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
style={{ height: "160px", borderRadius: "6px" }} | ||
autoFocus | ||
className="w-full resize-none text-gray-400 dark:text-gray-400 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-500" | ||
name="name" | ||
value={text} | ||
placeholder="Have more feedback?" | ||
onChange={(e) => setText(e.target.value)} | ||
/> | ||
</div> | ||
<div> | ||
<p className="text-gray-500"> | ||
{" "} | ||
By submitting this form you acknowledge that you have read and understood our{" "} | ||
<a className="gp-link" target="gitpod-privacy" href="https://www.gitpod.io/privacy/"> | ||
privacy policy | ||
</a> | ||
. | ||
</p> | ||
</div> | ||
</div> | ||
<div className="flex justify-end mt-6"> | ||
<button className="secondary" onClick={props.onClose}> | ||
Cancel | ||
</button> | ||
<button className="ml-2" onClick={onSubmit}> | ||
Send Feedback | ||
gtsiolis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</button> | ||
</div> | ||
</> | ||
) : ( | ||
<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 }} | ||
> | ||
<p className="text-center text-lg mb-8 text-gray-500 dark:text-gray-400"> | ||
We'd love to know what you think! | ||
</p> | ||
|
||
<div className="flex items-center justify-center w-full space-x-3">{emojiGroup(50)}</div> | ||
laushinka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
export default FeedbackComponent; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* 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 Modal from "../components/Modal"; | ||
import FeedbackComponent from "./FeedbackComponent"; | ||
|
||
function FeedbackFormModal(props: { onClose: () => void }) { | ||
const onClose = () => { | ||
props.onClose(); | ||
}; | ||
|
||
const onSubmit = () => { | ||
props.onClose(); | ||
}; | ||
|
||
return ( | ||
<Modal visible={true} onClose={onClose}> | ||
gtsiolis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<FeedbackComponent onClose={onClose} onSubmit={onSubmit} isModal={true} /> | ||
</Modal> | ||
); | ||
} | ||
|
||
export default FeedbackFormModal; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.