Path: blob/main/components/dashboard/src/teams/onboarding/OrganizationJoinModal.tsx
2501 views
/**1* Copyright (c) 2025 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import { OnboardingSettings_WelcomeMessage } from "@gitpod/public-api/lib/gitpod/v1/organization_pb";7import { Button } from "@podkit/buttons/Button";8import { useCallback, useEffect, useMemo, useState } from "react";9import { Modal, ModalBody, ModalFooter, ModalHeader } from "../../components/Modal";10import { storageAvailable } from "../../utils";11import { WelcomeMessagePreview } from "./WelcomeMessagePreview";12import { User } from "@gitpod/public-api/lib/gitpod/v1/user_pb";1314type Props = {15user: User;16welcomeMessage: OnboardingSettings_WelcomeMessage;17};18export const OrganizationJoinModal = ({ welcomeMessage, user }: Props) => {19const initialOrgOnboardingPending = useMemo(() => {20if (!storageAvailable("localStorage")) {21return false;22}2324const alreadyOnboarded = localStorage.getItem("newUserOnboardingDone") === "true";25if (alreadyOnboarded) {26return false;27}2829// We want to show this message to users who just signed up, so we select the "new-ish" users here30const oneWeekSeconds = 7 * 24 * 60 * 60;31const userCreatedWithinLast7Days =32user.createdAt && user.createdAt.seconds >= Date.now() / 1000 - oneWeekSeconds;33return userCreatedWithinLast7Days;34}, [user.createdAt]);35const dismissOrgOnboarding = useCallback(() => {36if (storageAvailable("localStorage")) {37localStorage.setItem("newUserOnboardingDone", "true");38}3940setOrgOnboardingPending(false);41}, []);42const [orgOnboardingPending, setOrgOnboardingPending] = useState(initialOrgOnboardingPending ?? false);4344// if the org-wide welcome message is not enabled, prevent showing it in the future45useEffect(() => {46if (!welcomeMessage.enabled) {47dismissOrgOnboarding();48}49}, [welcomeMessage.enabled, dismissOrgOnboarding]);5051if (!welcomeMessage.enabled || !orgOnboardingPending) {52return null;53}5455return (56<Modal57visible={orgOnboardingPending}58onClose={dismissOrgOnboarding}59containerClassName="min-[576px]:max-w-[650px]"60>61<ModalHeader>Welcome to Gitpod</ModalHeader>62<ModalBody>63<WelcomeMessagePreview hideHeader />64</ModalBody>65<ModalFooter>66<Button onClick={dismissOrgOnboarding}>Get Started</Button>67</ModalFooter>68</Modal>69);70};717273