import React from 'react'; import { useParams } from 'react-router-dom'; import { Bullseye, EmptyStateBody, Spinner, Content, ContentVariants, } from '@patternfly/react-core'; import emptyStateImgUrl from '~/assets/Components.svg'; import { FeatureFlagIndicator } from '~/feature-flags/FeatureFlagIndicator'; import { FLAGS } from '~/feature-flags/flags'; import { IfFeature } from '~/feature-flags/hooks'; import { useComponentV2 } from '~/hooks/useComponentsV2'; import { COMPONENTS_PATH, COMPONENT_DETAILS_V2_PATH, COMPONENT_VERSIONS_PATH, COMPONENT_VERSION_DETAILS_PATH, } from '~/routes/paths'; import { RouterParams } from '~/routes/utils'; import AppEmptyState from '~/shared/components/empty-state/AppEmptyState'; import { useNamespace } from '~/shared/providers/Namespace/useNamespaceInfo'; import { getErrorState } from '~/shared/utils/error-utils'; import { getComponentVersion } from '~/utils/version-utils'; import { DetailsPage } from '../DetailsPage'; const ComponentVersionDetailsView: React.FC = () => { const { componentName, versionRevision } = useParams(); const namespace = useNamespace(); const [component, loaded, componentError] = useComponentV2(namespace, componentName); if (!loaded) { return ( ); } if (componentError) { return getErrorState(componentError, loaded, 'Component version'); } const version = getComponentVersion(component, versionRevision); if (!version) { return getErrorState({ code: 404 }, true, `Component version '${versionRevision}'`); } return ( {`To view this page, enable the "${FLAGS['component-model'].description}" feature flag.`} } > {component.metadata.name} } breadcrumbs={[ { path: COMPONENTS_PATH.createPath({ workspaceName: namespace }), name: 'Components', }, { path: COMPONENT_DETAILS_V2_PATH.createPath({ workspaceName: namespace, componentName, }), name: component.spec.componentName || componentName, }, { path: COMPONENT_VERSIONS_PATH.createPath({ workspaceName: namespace, componentName }), name: 'Versions', }, { path: COMPONENT_VERSION_DETAILS_PATH.createPath({ workspaceName: namespace, componentName, versionRevision, }), name: version.name, }, ]} baseURL={COMPONENT_VERSION_DETAILS_PATH.createPath({ workspaceName: namespace, componentName, versionRevision, })} tabs={[ { key: 'index', label: 'Overview', isFilled: true, }, { key: 'activity', label: 'Activity', }, ]} /> ); }; export default ComponentVersionDetailsView;