Skip to content

[dashboard] Don't show User Notifications and Feedback on Dedicated #20583

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 5 commits into from
Feb 7, 2025
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
2 changes: 1 addition & 1 deletion components/dashboard/src/Insights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { useTemporaryState } from "./hooks/use-temporary-value";
import { DownloadIcon } from "lucide-react";
import { Button } from "@podkit/buttons/Button";
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from "@podkit/dropdown/DropDown";
import { useInstallationConfiguration } from "./data/installation/default-workspace-image-query";
import { useInstallationConfiguration } from "./data/installation/installation-config-query";

export const Insights = () => {
const toDate = useMemo(() => Timestamp.fromDate(new Date()), []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,3 @@ export const useInstallationDefaultWorkspaceImageQuery = () => {
},
});
};

export const useInstallationConfiguration = () => {
return useQuery({
queryKey: ["installation-configuration"],
staleTime: 1000 * 60 * 10, // 10 minute
queryFn: async () => {
const response = await installationClient.getInstallationConfiguration({});
return response.configuration;
},
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright (c) 2025 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 { useQuery } from "@tanstack/react-query";
import { installationClient } from "../../service/public-api";

export const useInstallationConfiguration = () => {
return useQuery({
queryKey: ["installation-configuration"],
staleTime: 1000 * 60 * 30, // 30 minutes
cacheTime: 1000 * 60 * 60 * 24, // 24 hours
queryFn: async () => {
const response = await installationClient.getInstallationConfiguration({});
return response.configuration;
},
});
};
4 changes: 2 additions & 2 deletions components/dashboard/src/dedicated-setup/use-needs-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { useQuery } from "@tanstack/react-query";
import { noPersistence } from "../data/setup";
import { installationClient } from "../service/public-api";
import { GetOnboardingStateRequest } from "@gitpod/public-api/lib/gitpod/v1/installation_pb";
import { useInstallationConfiguration } from "../data/installation/default-workspace-image-query";
import { useInstallationConfiguration } from "../data/installation/installation-config-query";

/**
* @description Returns a flage stating if the current installation still needs setup before it can be used. Also returns an isLoading indicator as the check is async
* @description Returns a flag stating if the current installation still needs setup before it can be used. Also returns an isLoading indicator as the check is async
*/
export const useNeedsSetup = () => {
const { data: onboardingState, isLoading } = useOnboardingState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { useQueryParams } from "../hooks/use-query-params";
import { useCallback, useState } from "react";
import { isCurrentHostExcludedFromSetup, useNeedsSetup } from "./use-needs-setup";
import { useInstallationConfiguration } from "../data/installation/default-workspace-image-query";
import { useInstallationConfiguration } from "../data/installation/installation-config-query";

const FORCE_SETUP_PARAM = "dedicated-setup";
const FORCE_SETUP_PARAM_VALUE = "force";
Expand Down
14 changes: 10 additions & 4 deletions components/dashboard/src/menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import { Separator } from "../components/Separator";
import PillMenuItem from "../components/PillMenuItem";
import { PaymentContext } from "../payment-context";
import FeedbackFormModal from "../feedback-form/FeedbackModal";
import { isGitpodIo } from "../utils";
import OrganizationSelector from "./OrganizationSelector";
import { getAdminTabs } from "../admin/admin.routes";
import classNames from "classnames";
import { User, RoleOrPermission } from "@gitpod/public-api/lib/gitpod/v1/user_pb";
import { getPrimaryEmail } from "@gitpod/public-api-common/lib/user-utils";
import { ConfigurationsMigrationCoachmark } from "../repositories/coachmarks/MigrationCoachmark";
import { useInstallationConfiguration } from "../data/installation/installation-config-query";

interface Entry {
title: string;
Expand All @@ -35,6 +35,9 @@ export default function Menu() {
const { setCurrency } = useContext(PaymentContext);
const [isFeedbackFormVisible, setFeedbackFormVisible] = useState<boolean>(false);

const { data: installationConfig, isLoading: isInstallationConfigLoading } = useInstallationConfiguration();
const isGitpodIo = isInstallationConfigLoading ? false : !installationConfig?.isDedicatedInstallation;

useEffect(() => {
const { server } = getGitpodService();
server.getClientRegion().then((v) => {
Expand Down Expand Up @@ -95,7 +98,7 @@ export default function Menu() {
/>
</li>
)}
{isGitpodIo() && (
{isGitpodIo && (
<li className="cursor-pointer">
<PillMenuItem name="Feedback" onClick={handleFeedbackFormClick} />
</li>
Expand Down Expand Up @@ -163,6 +166,9 @@ type UserMenuProps = {
onFeedback?: () => void;
};
const UserMenu: FC<UserMenuProps> = ({ user, className, withAdminLink, withFeedbackLink, onFeedback }) => {
const { data: installationConfig, isLoading: isInstallationConfigLoading } = useInstallationConfiguration();
const isGitpodIo = isInstallationConfigLoading ? false : !installationConfig?.isDedicatedInstallation;

const extraSection = useMemo(() => {
const items: ContextMenuEntry[] = [];

Expand All @@ -172,7 +178,7 @@ const UserMenu: FC<UserMenuProps> = ({ user, className, withAdminLink, withFeedb
link: "/admin",
});
}
if (withFeedbackLink && isGitpodIo()) {
if (withFeedbackLink && isGitpodIo) {
items.push({
title: "Feedback",
onClick: onFeedback,
Expand All @@ -185,7 +191,7 @@ const UserMenu: FC<UserMenuProps> = ({ user, className, withAdminLink, withFeedb
}

return items;
}, [onFeedback, user?.rolesOrPermissions, withAdminLink, withFeedbackLink]);
}, [isGitpodIo, onFeedback, user?.rolesOrPermissions, withAdminLink, withFeedbackLink]);

const menuEntries = useMemo(() => {
return [
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/src/menu/OrganizationSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { useOrgBillingMode } from "../data/billing-mode/org-billing-mode-query";
import { useIsOwner, useListOrganizationMembers, useHasRolePermission } from "../data/organizations/members-query";
import { isAllowedToCreateOrganization } from "@gitpod/public-api-common/lib/user-utils";
import { OrganizationRole } from "@gitpod/public-api/lib/gitpod/v1/organization_pb";
import { useInstallationConfiguration } from "../data/installation/default-workspace-image-query";
import { useFeatureFlag } from "../data/featureflag-query";
import { PlusIcon } from "lucide-react";
import { useInstallationConfiguration } from "../data/installation/installation-config-query";

export default function OrganizationSelector() {
const user = useCurrentUser();
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/src/teams/OrgSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useCurrentOrg } from "../data/organizations/orgs-query";
import { useFeatureFlag } from "../data/featureflag-query";
import { Organization } from "@gitpod/public-api/lib/gitpod/v1/organization_pb";
import { useIsOwner } from "../data/organizations/members-query";
import { useInstallationConfiguration } from "../data/installation/default-workspace-image-query";
import { useInstallationConfiguration } from "../data/installation/installation-config-query";

export interface OrgSettingsPageProps {
children: React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { NumberInput } from "../../components/forms/TextInputField";
import { LoadingButton } from "@podkit/buttons/LoadingButton";
import { MAX_PARALLEL_WORKSPACES_FREE, MAX_PARALLEL_WORKSPACES_PAID } from "@gitpod/gitpod-protocol";
import { PlainMessage } from "@bufbuild/protobuf";
import { useInstallationConfiguration } from "../../data/installation/default-workspace-image-query";
import { useInstallationConfiguration } from "../../data/installation/installation-config-query";

type Props = {
isOwner: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { PageWithSubMenu } from "../components/PageWithSubMenu";
import { useInstallationConfiguration } from "../data/installation/installation-config-query";
import {
settingsPathAccount,
settingsPathIntegrations,
Expand All @@ -23,24 +24,31 @@ export interface PageWithAdminSubMenuProps {
}

export function PageWithSettingsSubMenu({ children }: PageWithAdminSubMenuProps) {
const settingsMenu = getSettingsMenu();
const settingsMenu = useUserSettingsMenu();
return (
<PageWithSubMenu subMenu={settingsMenu} title="User Settings" subtitle="Manage your personal account settings.">
{children}
</PageWithSubMenu>
);
}

function getSettingsMenu() {
function useUserSettingsMenu() {
const { data: installationConfig } = useInstallationConfiguration();
const isGitpodIo = installationConfig?.isDedicatedInstallation === false;

return [
{
title: "Account",
link: [settingsPathAccount, settingsPathMain],
},
{
title: "Notifications",
link: [settingsPathNotifications],
},
...(isGitpodIo
? [
{
title: "Notifications",
link: [settingsPathNotifications],
},
]
: []),
{
title: "Variables",
link: [settingsPathVariables],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { flattenPagedConfigurations } from "../data/git-providers/unified-reposi
import { Configuration } from "@gitpod/public-api/lib/gitpod/v1/configuration_pb";
import { useMemberRole } from "../data/organizations/members-query";
import { OrganizationPermission } from "@gitpod/public-api/lib/gitpod/v1/organization_pb";
import { useInstallationConfiguration } from "../data/installation/default-workspace-image-query";
import { useInstallationConfiguration } from "../data/installation/installation-config-query";

type NextLoadOption = "searchParams" | "autoStart" | "allDone";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Heading2, Subheading } from "@podkit/typography/Headings";
import { StartWorkspaceModalKeyBinding } from "../App";
import { VideoSection } from "../onboarding/VideoSection";
import { trackVideoClick } from "../Analytics";
import { useInstallationConfiguration } from "../data/installation/default-workspace-image-query";
import { useInstallationConfiguration } from "../data/installation/installation-config-query";

export const EmptyWorkspacesContent = () => {
const { data: installationConfig } = useInstallationConfiguration();
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/src/workspaces/Workspaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import Modal, { ModalBaseFooter, ModalBody, ModalHeader } from "../components/Mo
import { VideoSection } from "../onboarding/VideoSection";
import { trackVideoClick } from "../Analytics";
import { cn } from "@podkit/lib/cn";
import { useInstallationConfiguration } from "../data/installation/default-workspace-image-query";
import { useUpdateCurrentUserMutation } from "../data/current-user/update-mutation";
import { useUserLoader } from "../hooks/use-user-loader";
import Tooltip from "../components/Tooltip";
import { useFeatureFlag } from "../data/featureflag-query";
import { useInstallationConfiguration } from "../data/installation/installation-config-query";
import { SuggestedOrgRepository, useOrgSuggestedRepos } from "../data/organizations/suggested-repositories-query";
import { useSuggestedRepositories } from "../data/git-providers/suggested-repositories-query";
import PillLabel from "../components/PillLabel";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { StartWorkspaceModalKeyBinding } from "../App";
import DropDown from "../components/DropDown";
import search from "../icons/search.svg";
import { LinkButton } from "@podkit/buttons/LinkButton";
import { useInstallationConfiguration } from "../data/installation/default-workspace-image-query";
import { useInstallationConfiguration } from "../data/installation/installation-config-query";

type WorkspacesSearchBarProps = {
searchTerm: string;
Expand Down
Loading