import React from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import { Bullseye, ButtonVariant, Spinner, Content, ContentVariants } from '@patternfly/react-core'; import isFunction from 'lodash/isFunction'; import isObject from 'lodash/isObject'; import { FeatureFlagIndicator } from '~/feature-flags/FeatureFlagIndicator'; import { getErrorState } from '~/shared/utils/error-utils'; import pipelineImg from '../../../assets/Pipeline.svg'; import { useComponent } from '../../../hooks/useComponents'; import { ComponentModel } from '../../../models'; import { COMPONENT_LIST_PATH, COMPONENT_DETAILS_PATH } from '../../../routes/paths'; import { RouterParams } from '../../../routes/utils'; import { useNamespace } from '../../../shared/providers/Namespace/useNamespaceInfo'; import { useAccessReviewForModel } from '../../../utils/rbac'; import { useApplicationBreadcrumbs } from '../../Applications/breadcrumbs/breadcrumb-utils'; import { ButtonWithAccessTooltip } from '../../ButtonWithAccessTooltip'; import { createCustomizeComponentPipelineModalLauncher } from '../../CustomizedPipeline/CustomizePipelinesModal'; import { DetailsPage } from '../../DetailsPage'; import { Action } from '../../DetailsPage/types'; import { GettingStartedCard } from '../../GettingStartedCard/GettingStartedCard'; import { useModalLauncher } from '../../modal/ModalProvider'; import { useComponentActions } from '../component-actions'; import './ComponentDetailsView.scss'; export const COMPONENTS_GS_LOCAL_STORAGE_KEY = 'components-getting-started-modal'; const ComponentDetailsView: React.FC = () => { const { componentName, applicationName } = useParams(); const navigate = useNavigate(); const namespace = useNamespace(); const applicationBreadcrumbs = useApplicationBreadcrumbs(); const showModal = useModalLauncher(); const [component, loaded, componentError] = useComponent(namespace, componentName); const [canPatchComponent] = useAccessReviewForModel(ComponentModel, 'patch'); const componentActions = useComponentActions(loaded ? component : undefined, componentName); const actions: Action[] = React.useMemo( () => componentActions.map((compAction) => ({ key: compAction.id, label: compAction.label, isDisabled: compAction.disabled, disabledTooltip: compAction.disabledTooltip, onClick: () => { if (isFunction(compAction.cta)) { compAction.cta(); } else if (isObject(compAction.cta)) { if (!compAction.cta.external) { navigate(compAction.cta.href); } } }, })), [componentActions, navigate], ); if (!loaded) { return ( ); } if (componentError) { return getErrorState(componentError, loaded, 'component'); } return ( <>
Using the Advanced or Custom build pipeline, you can enable all additional tasks for added security.
showModal( createCustomizeComponentPipelineModalLauncher( component.metadata.name, component.metadata.namespace, ), ) } > Edit build pipeline plan } breadcrumbs={[ ...applicationBreadcrumbs, { path: COMPONENT_LIST_PATH.createPath({ workspaceName: namespace, applicationName, }), name: 'components', }, { path: COMPONENT_DETAILS_PATH.createPath({ workspaceName: namespace, applicationName, componentName, }), name: component.spec.componentName, }, ]} title={ {component.spec.componentName} } actions={actions} baseURL={COMPONENT_DETAILS_PATH.createPath({ workspaceName: namespace, applicationName, componentName, })} tabs={[ { key: 'index', label: 'Component details', isFilled: true, }, { key: 'activity', label: 'Activity', }, { key: 'dep-updates', label: 'Dependency updates', }, ]} /> ); }; export default ComponentDetailsView;