Skip to content

Commit b0bfab8

Browse files
committed
fixup public-api user utils moved to public-api-common
1 parent f3a1cc4 commit b0bfab8

File tree

8 files changed

+11
-13
lines changed

8 files changed

+11
-13
lines changed

components/dashboard/src/menu/Menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { getAdminTabs } from "../admin/admin.routes";
2020
import classNames from "classnames";
2121
import { useAuthenticatedUser } from "../data/current-user/authenticated-user-query";
2222
import { User, User_RoleOrPermission } from "@gitpod/public-api/lib/gitpod/v1/user_pb";
23-
import { getPrimaryEmail } from "@gitpod/gitpod-protocol/lib/public-api-utils";
23+
import { getPrimaryEmail } from "@gitpod/public-api-common/lib/user-utils";
2424

2525
interface Entry {
2626
title: string;

components/dashboard/src/menu/OrganizationSelector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import ContextMenu, { ContextMenuEntry } from "../components/ContextMenu";
99
import { OrgIcon, OrgIconProps } from "../components/org-icon/OrgIcon";
1010
import { useCurrentOrg, useOrganizations } from "../data/organizations/orgs-query";
1111
import { useLocation } from "react-router";
12-
import { User } from "@gitpod/gitpod-protocol";
1312
import { useOrgBillingMode } from "../data/billing-mode/org-billing-mode-query";
1413
import { useFeatureFlag } from "../data/featureflag-query";
1514
import { useIsOwner, useListOrganizationMembers } from "../data/organizations/members-query";
1615
import { useAuthenticatedUser } from "../data/current-user/authenticated-user-query";
16+
import { isOrganizationOwned } from "@gitpod/public-api-common/lib/user-utils";
1717

1818
export default function OrganizationSelector() {
1919
const { data: user } = useAuthenticatedUser();
@@ -26,7 +26,7 @@ export default function OrganizationSelector() {
2626
const repoConfigListAndDetail = useFeatureFlag("repoConfigListAndDetail");
2727

2828
// we should have an API to ask for permissions, until then we duplicate the logic here
29-
const canCreateOrgs = user && !User.isOrganizationOwned(user);
29+
const canCreateOrgs = user && !isOrganizationOwned(user);
3030

3131
const userFullName = user?.name || "...";
3232

components/dashboard/src/onboarding/StepUserInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { OnboardingStep } from "./OnboardingStep";
1313
import { LinkedInBanner } from "./LinkedInBanner";
1414
import { useFeatureFlag } from "../data/featureflag-query";
1515
import { User } from "@gitpod/public-api/lib/gitpod/v1/user_pb";
16-
import { getPrimaryEmail } from "@gitpod/gitpod-protocol/lib/public-api-utils";
16+
import { getPrimaryEmail } from "@gitpod/public-api-common/lib/user-utils";
1717

1818
type Props = {
1919
user: User;

components/dashboard/src/onboarding/use-show-user-onboarding.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44
* See License.AGPL.txt in the project root for license information.
55
*/
66

7-
import { User } from "@gitpod/gitpod-protocol";
87
import { useQueryParams } from "../hooks/use-query-params";
98
import { FORCE_ONBOARDING_PARAM, FORCE_ONBOARDING_PARAM_VALUE } from "./UserOnboarding";
109
import { useAuthenticatedUser } from "../data/current-user/authenticated-user-query";
11-
import { isOnboardingUser } from "@gitpod/gitpod-protocol/lib/public-api-utils";
10+
import { isOnboardingUser, isOrganizationOwned } from "@gitpod/public-api-common/lib/user-utils";
1211

1312
export const useShowUserOnboarding = () => {
1413
const { data: user } = useAuthenticatedUser();
1514
const search = useQueryParams();
1615

17-
if (!user || User.isOrganizationOwned(user)) {
16+
if (!user || isOrganizationOwned(user)) {
1817
return false;
1918
}
2019

components/dashboard/src/user-settings/Account.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { useToast } from "../components/toasts/Toasts";
1717
import { InputWithCopy } from "../components/InputWithCopy";
1818
import { InputField } from "../components/forms/InputField";
1919
import { useAuthenticatedUser } from "../data/current-user/authenticated-user-query";
20-
import { getPrimaryEmail, getProfile, isOrganizationOwned } from "@gitpod/gitpod-protocol/lib/public-api-utils";
20+
import { getPrimaryEmail, getProfile, isOrganizationOwned } from "@gitpod/public-api-common/lib/user-utils";
2121
import { User } from "@gitpod/public-api/lib/gitpod/v1/user_pb";
2222
import { User as UserProtocol } from "@gitpod/gitpod-protocol";
2323
import { useUpdateCurrentUserMutation } from "../data/current-user/update-mutation";

components/dashboard/src/user-settings/Integrations.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* See License.AGPL.txt in the project root for license information.
55
*/
66

7-
import { User } from "@gitpod/gitpod-protocol";
87
import { getScopesForAuthProviderType } from "@gitpod/public-api-common/lib/auth-providers";
98
import { SelectAccountPayload } from "@gitpod/gitpod-protocol/lib/auth";
109
import { useQuery } from "@tanstack/react-query";
@@ -41,6 +40,7 @@ import { useUpdateUserAuthProviderMutation } from "../data/auth-providers/update
4140
import { useDeleteUserAuthProviderMutation } from "../data/auth-providers/delete-user-auth-provider-mutation";
4241
import { Button } from "@podkit/buttons/Button";
4342
import { useAuthenticatedUser } from "../data/current-user/authenticated-user-query";
43+
import { isOrganizationOwned } from "@gitpod/public-api-common/lib/user-utils";
4444

4545
export default function Integrations() {
4646
return (
@@ -124,7 +124,7 @@ function GitProviders() {
124124
});
125125
}
126126
const canDisconnect =
127-
(user && User.isOrganizationOwned(user)) ||
127+
(user && isOrganizationOwned(user)) ||
128128
authProviders.data?.some((p) => p.id !== provider.id && isConnected(p.id));
129129
if (canDisconnect) {
130130
result.push({

components/gitpod-protocol/src/protocol.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { RoleOrPermission } from "./permission";
99
import { Project } from "./teams-projects-protocol";
1010
import { createHash } from "crypto";
1111
import { WorkspaceRegion } from "./workspace-cluster";
12-
import * as papi from "@gitpod/public-api/lib/gitpod/v1/user_pb";
1312

1413
export interface UserInfo {
1514
name?: string;
@@ -143,7 +142,7 @@ export namespace User {
143142
return !hasPreferredIde(user);
144143
}
145144

146-
export function isOrganizationOwned(user: User | papi.User) {
145+
export function isOrganizationOwned(user: User) {
147146
return !!user.organizationId;
148147
}
149148

components/gitpod-protocol/src/public-api-utils.ts renamed to components/public-api/typescript-common/src/user-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { User } from "@gitpod/public-api/lib/gitpod/v1/user_pb";
8-
import { User as UserProtocol } from "./protocol";
8+
import { User as UserProtocol } from "@gitpod/gitpod-protocol/lib/protocol";
99

1010
/**
1111
* Returns a primary email address of a user.

0 commit comments

Comments
 (0)