import * as React from 'react'; import { Alert, ClipboardCopy, Content, ContentVariants, Skeleton, Stack, StackItem, } from '@patternfly/react-core'; import { CliAuthMode, KUBECTL_LIST_CONTEXTS_COMMAND } from './cli-login-utils'; import type { CliLoginInfo } from './useCliLogin'; import './CliLoginContent.scss'; const getLoginCommandHeading = (authMode: CliAuthMode, loginCommand: string): string => { if (authMode !== 'kubernetes') { return 'Copy login command to log in with oc:'; } const rest = loginCommand === KUBECTL_LIST_CONTEXTS_COMMAND ? 'list the available kubectl contexts for this cluster:' : 'configure kubectl for this cluster:'; return `Copy login command to ${rest}`; }; type CliLoginContentProps = { cliLogin: CliLoginInfo | null; loaded: boolean; error: unknown; }; export const CliLoginContent: React.FC = ({ cliLogin, loaded, error }) => { if (!loaded) { return ; } if (error && !cliLogin) { return ( Cluster information could not be retrieved. Try again later. ); } if (!cliLogin) { return ( Ask your cluster administrator to configure it. OpenShift UIs at a *.apps.*{' '} hostname derive settings automatically. For Kind or a custom domain, merge{' '} cliLogin into the existing info.json of the{' '} konflux-public-info ConfigMap. konflux-operator overwrites unknown fields on reconcile. ); } return ( {getLoginCommandHeading(cliLogin.authMode, cliLogin.loginCommand)} {cliLogin.loginCommand} {cliLogin.authMode === 'kubernetes' ? ( API server: {cliLogin.apiServerUrl}. Use your existing kubeconfig for this cluster. ) : null} ); };