Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add useUser hook to EnsureCompatiblePipelineServer component #2705

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions frontend/src/concepts/pipelines/EnsureCompatiblePipelineServer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ExclamationTriangleIcon } from '@patternfly/react-icons';
import DeletePipelineServerModal from '~/concepts/pipelines/content/DeletePipelineServerModal';
import ExternalLink from '~/components/ExternalLink';
import NoPipelineServer from '~/concepts/pipelines/NoPipelineServer';
import { useUser } from '~/redux/selectors';
import { usePipelinesAPI } from './context';

// TODO: Fix doc link to go to more docs on v2
Expand All @@ -29,8 +30,13 @@ const EnsureCompatiblePipelineServer: React.FC<EnsureCompatiblePipelineServerPro
children,
}) => {
const { pipelinesServer } = usePipelinesAPI();
const { isAdmin } = useUser();
const [isDeleting, setIsDeleting] = React.useState(false);

const bodyText = isAdmin
? "Rendering of this pipeline version in the UI is no longer supported, but it can still be accessed via the API or OpenShift Console. To remove unsupported versions, delete this project's pipeline server and create a new one."
: 'Rendering of this pipeline version in the UI is no longer supported. To access this pipeline, contact your administrator.';

if (pipelinesServer.initializing) {
return (
<Bullseye>
Expand All @@ -49,7 +55,7 @@ const EnsureCompatiblePipelineServer: React.FC<EnsureCompatiblePipelineServerPro
<Bullseye data-testid="incompatible-pipelines-server">
<EmptyState variant={EmptyStateVariant.lg}>
<EmptyStateHeader
titleText="This pipeline version is no longer supported"
titleText="Pipeline version cannot be rendered"
icon={
<EmptyStateIcon
color="var(--pf-v5-global--warning-color--100)"
Expand All @@ -58,20 +64,21 @@ const EnsureCompatiblePipelineServer: React.FC<EnsureCompatiblePipelineServerPro
}
/>
<EmptyStateBody>
To remove unsupported versions, delete this project&lsquo;s pipeline server and create
a new one.{' '}
<p>{bodyText}</p>
<ExternalLink
text="Learn more about supported versions and data recovery"
to={DOCS_LINK}
/>
</EmptyStateBody>
<EmptyStateFooter>
<EmptyStateActions>
<Button variant="primary" onClick={() => setIsDeleting(true)}>
Delete pipeline server
</Button>
</EmptyStateActions>
</EmptyStateFooter>
{isAdmin && (
<EmptyStateFooter>
<EmptyStateActions>
<Button variant="primary" onClick={() => setIsDeleting(true)}>
Delete pipeline server
</Button>
</EmptyStateActions>
</EmptyStateFooter>
)}
</EmptyState>
</Bullseye>
<DeletePipelineServerModal isOpen={isDeleting} onClose={() => setIsDeleting(false)} />
Expand Down
Loading