-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Configuration coachmark #19413
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
Configuration coachmark #19413
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f57bee4
Add repo migrate coachmark
filiptronicek 8692570
Public API: `coachmarksDismissals`
filiptronicek 5e9eaad
Early exit for new signups
filiptronicek 1d24e77
Try to inject dismissal to link
filiptronicek 62db19d
Dismiss on path visit
filiptronicek 16b7c8c
Align to the left
filiptronicek 86ba16e
Dismiss on trigger
filiptronicek ce59ff5
Simplify show logic
filiptronicek 1a3dad2
Merge remote-tracking branch 'origin/main' into ft/configurations-coa…
filiptronicek b39bddc
Consider `showPrebuildsMenuItem` when hiding projects
filiptronicek bbee981
update tests
filiptronicek ae81faf
Adjust date for testing
filiptronicek 3b2e8cb
fix projects hide condition
filiptronicek 5cabd1d
Fix repo link id ref
filiptronicek 33dfa11
Do not dismiss accidentally
filiptronicek 35aeb0f
Merge branch 'main' into ft/configurations-coachmark
filiptronicek d904f2b
up-date
filiptronicek 348b1b3
move prebuild detail to correct folder
filiptronicek 2a4a543
Make sure errors are displayed properly for prebuilds list
filiptronicek 2f33646
don't throw
filiptronicek db0bca5
Report dismiss
filiptronicek 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
34 changes: 34 additions & 0 deletions
34
components/dashboard/src/components/podkit/popover/Popover.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,34 @@ | ||
| /** | ||
| * Copyright (c) 2024 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 * as React from "react"; | ||
| import * as PopoverPrimitive from "@radix-ui/react-popover"; | ||
| import { cn } from "@podkit/lib/cn"; | ||
|
|
||
| const Popover = PopoverPrimitive.Root; | ||
| const PopoverTrigger = PopoverPrimitive.Trigger; | ||
| const PopoverArrow = PopoverPrimitive.Arrow; | ||
|
|
||
| const PopoverContent = React.forwardRef< | ||
| React.ElementRef<typeof PopoverPrimitive.Content>, | ||
| React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> | ||
| >(({ className, align = "center", sideOffset = 4, ...props }, ref) => ( | ||
| <PopoverPrimitive.Portal> | ||
| <PopoverPrimitive.Content | ||
| ref={ref} | ||
| align={align} | ||
| sideOffset={sideOffset} | ||
| className={cn( | ||
| "z-50 w-96 rounded-md border border-surface-secondary bg-pk-surface-primary py-4 px-6 text-base text-pk-content-primary shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", | ||
| className, | ||
| )} | ||
| {...props} | ||
| /> | ||
| </PopoverPrimitive.Portal> | ||
| )); | ||
| PopoverContent.displayName = PopoverPrimitive.Content.displayName; | ||
|
|
||
| export { Popover, PopoverTrigger, PopoverContent, PopoverArrow }; |
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
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
104 changes: 104 additions & 0 deletions
104
components/dashboard/src/repositories/coachmarks/MigrationCoachmark.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,104 @@ | ||
| /** | ||
| * Copyright (c) 2024 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 { Button } from "@podkit/buttons/Button"; | ||
| import { Popover, PopoverArrow, PopoverContent, PopoverTrigger } from "@podkit/popover/Popover"; | ||
| import { Text } from "@podkit/typography/Text"; | ||
| import { Truck } from "lucide-react"; | ||
| import { PropsWithChildren, useCallback, useMemo, useState } from "react"; | ||
| import { Link, useHistory } from "react-router-dom"; | ||
| import { useFeatureFlag, useHasConfigurationsAndPrebuildsEnabled } from "../../data/featureflag-query"; | ||
| import { useUserLoader } from "../../hooks/use-user-loader"; | ||
| import { useUpdateCurrentUserMutation } from "../../data/current-user/update-mutation"; | ||
| import dayjs from "dayjs"; | ||
| import { trackEvent } from "../../Analytics"; | ||
|
|
||
| const COACHMARK_KEY = "projects_configuration_migration"; | ||
|
|
||
| type Props = PropsWithChildren<{}>; | ||
| export const ConfigurationsMigrationCoachmark = ({ children }: Props) => { | ||
| const [isOpen, setIsOpen] = useState(true); | ||
|
|
||
| const configurationsAndPrebuildsEnabled = useHasConfigurationsAndPrebuildsEnabled(); | ||
| const prebuildsInMenu = useFeatureFlag("showPrebuildsMenuItem"); | ||
|
|
||
| const history = useHistory(); | ||
|
|
||
| const { user } = useUserLoader(); | ||
| const { mutate: updateUser } = useUpdateCurrentUserMutation(); | ||
|
|
||
| const dismiss = useCallback(() => { | ||
| updateUser( | ||
| { | ||
| additionalData: { profile: { coachmarksDismissals: { [COACHMARK_KEY]: dayjs().toISOString() } } }, | ||
| }, | ||
| { | ||
| onSettled: (_, error) => { | ||
| trackEvent("coachmark_dismissed", { | ||
| name: COACHMARK_KEY, | ||
| success: !(error instanceof Error), | ||
| }); | ||
| }, | ||
| }, | ||
| ); | ||
| }, [updateUser]); | ||
|
|
||
| const show = useMemo<boolean>(() => { | ||
| if (!isOpen || !user) { | ||
| return false; | ||
| } | ||
|
|
||
| // For the users signing up after our launch of configurations, don't show it | ||
| if (user.createdAt && user.createdAt.toDate() > new Date("2/21/2024")) { | ||
| return false; | ||
| } | ||
|
|
||
| // User already knows about the feature | ||
| if (history.location.pathname.startsWith("/repositories")) { | ||
| dismiss(); | ||
| return false; | ||
| } | ||
|
|
||
| return ( | ||
| configurationsAndPrebuildsEnabled && prebuildsInMenu && !user.profile?.coachmarksDismissals[COACHMARK_KEY] | ||
| ); | ||
| }, [configurationsAndPrebuildsEnabled, dismiss, history.location.pathname, isOpen, prebuildsInMenu, user]); | ||
|
|
||
| const handleClose = useCallback(() => { | ||
| setIsOpen(false); | ||
| // do not store the dismissal if the popover is not shown | ||
| if (show) { | ||
| dismiss(); | ||
| } | ||
| }, [dismiss, show]); | ||
|
|
||
| return ( | ||
| <Popover open={show}> | ||
| <PopoverTrigger onClick={handleClose}>{children}</PopoverTrigger> | ||
| <PopoverContent align={"start"} className="border-pk-border-base relative flex flex-col"> | ||
| <PopoverArrow asChild> | ||
| <div className="mb-[6px] ml-2 inline-block overflow-hidden rotate-180 relative"> | ||
| <div className="h-3 w-5 origin-bottom-left rotate-45 transform border border-pk-border-base bg-pk-surface-primary before:absolute before:bottom-0 before:left-0 before:w-full before:h-[1px] before:bg-pk-surface-primary" /> | ||
| </div> | ||
| </PopoverArrow> | ||
|
|
||
| <Text className="flex flex-row gap-2 text-lg font-bold items-center pt-3"> | ||
| <Truck /> Projects have moved | ||
| </Text> | ||
| <Text className="text-pk-content-secondary text-base pb-4 pt-2"> | ||
| Projects are now called “ | ||
| <Link to={"/repositories"} className="gp-link"> | ||
| Imported Repositories. | ||
| </Link> | ||
| ” You can find them in your organization menu. | ||
| </Text> | ||
| <Button className="self-end" variant={"secondary"} onClick={handleClose}> | ||
| Dismiss | ||
| </Button> | ||
| </PopoverContent> | ||
| </Popover> | ||
| ); | ||
| }; | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,7 @@ message UpdateUserRequest { | |
| optional string signup_goals_other = 10; | ||
| optional string onboarded_timestamp = 11; | ||
| optional string company_size = 12; | ||
| map<string, string> coachmarks_dismissals = 13; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope to use this for future dialogs of this nature to not bloat the profile object. |
||
| } | ||
| optional string email_address = 5; | ||
| optional EditorReference editor_settings = 6; | ||
|
|
@@ -265,6 +266,11 @@ message User { | |
| // | ||
| // +optional | ||
| string company_size = 12; | ||
|
|
||
| // key-value pairs of dialogs in the UI which should only appear once. The value usually is a timestamp of the last dismissal | ||
| // | ||
| // +optional | ||
| map<string, string> coachmarks_dismissals = 13; | ||
| } | ||
|
|
||
| // remembered workspace auto start options | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also dismiss automatically if a user visits
/prebuilds. No strong opinion here.