Path: blob/main/components/dashboard/src/user-settings/AuthEntryItem.tsx
2500 views
/**1* Copyright (c) 2023 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 { useState } from "react";7import { ContextMenuEntry } from "../components/ContextMenu";8import { Item, ItemFieldIcon, ItemField, ItemFieldContextMenu } from "../components/ItemsList";9import { AuthProviderDescription } from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb";10import { toAuthProviderLabel } from "../provider-utils";11import { getScopeNameForScope } from "@gitpod/public-api-common/lib/auth-providers";1213interface AuthEntryItemParams {14ap: AuthProviderDescription;15isConnected: (authProviderId: string) => boolean;16getUsername: (authProviderId: string) => string | undefined;17getPermissions: (authProviderId: string) => string[] | undefined;18gitProviderMenu: (provider: AuthProviderDescription) => ContextMenuEntry[];19}2021export const AuthEntryItem = (props: AuthEntryItemParams) => {22const [menuVisible, setMenuVisible] = useState<boolean>(false);2324const changeMenuState = (state: boolean) => {25setMenuVisible(state);26};2728return (29<Item key={"ap-" + props.ap.id} className="h-16" solid={menuVisible}>30<ItemFieldIcon>31<div32className={33"rounded-full w-3 h-3 text-sm align-middle m-auto " +34(props.isConnected(props.ap.id) ? "bg-green-500" : "bg-gray-400")35}36>37 38</div>39</ItemFieldIcon>40<ItemField className="w-4/12 xl:w-3/12 flex flex-col my-auto">41<span className="my-auto font-medium truncate overflow-ellipsis">42{toAuthProviderLabel(props.ap.type)}43</span>44<span className="text-sm my-auto text-gray-400 truncate overflow-ellipsis dark:text-gray-500">45{props.ap.host}46</span>47</ItemField>48<ItemField className="w-6/12 xl:w-3/12 flex flex-col my-auto">49<span className="my-auto truncate text-gray-500 overflow-ellipsis dark:text-gray-400">50{props.getUsername(props.ap.id) || "–"}51</span>52<span className="text-sm my-auto text-gray-400 dark:text-gray-500">Username</span>53</ItemField>54<ItemField className="hidden xl:w-1/3 xl:flex xl:flex-col my-auto">55<span className="my-auto truncate text-gray-500 overflow-ellipsis dark:text-gray-400">56{props.getPermissions(props.ap.id)?.map(getScopeNameForScope)?.join(", ") || "–"}57</span>58<span className="text-sm my-auto text-gray-400 dark:text-gray-500">Permissions</span>59</ItemField>60<ItemFieldContextMenu changeMenuState={changeMenuState} menuEntries={props.gitProviderMenu(props.ap)} />61</Item>62);63};646566