Skip to content

Commit

Permalink
Add InvalidArgoDeploymentAlert component to AppRoutes
Browse files Browse the repository at this point in the history
Update link text in InvalidArgoDeploymentAlert component
  • Loading branch information
Gkrumbach07 committed Apr 11, 2024
1 parent 65b648d commit 2911814
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
2 changes: 2 additions & 0 deletions frontend/src/app/AppRoutes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Route, Routes } from 'react-router-dom';
import { InvalidArgoDeploymentAlert } from '~/concepts/pipelines/content/InvalidArgoDeploymentAlert';
import ApplicationsPage from '~/pages/ApplicationsPage';
import UnauthorizedError from '~/pages/UnauthorizedError';
import { useUser } from '~/redux/selectors';
Expand Down Expand Up @@ -66,6 +67,7 @@ const AppRoutes: React.FC = () => {

return (
<React.Suspense fallback={<ApplicationsPage title="" description="" loaded={false} empty />}>
<InvalidArgoDeploymentAlert />
<Routes>
<Route path="/" element={<InstalledApplications />} />
<Route path="/explore" element={<ExploreApplications />} />
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/concepts/areas/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { EitherOrBoth } from '~/typeHelpers';
import { DashboardCommonConfig } from '~/k8sTypes';
import {
DashboardCommonConfig,
DashboardConfigKind,
DataScienceClusterInitializationKindStatus,
DataScienceClusterKindStatus,
} from '~/k8sTypes';

// TODO: clean up this definition / update the DashboardConfig to a better state
export type FeatureFlag = keyof Omit<DashboardCommonConfig, 'modelMetricsNamespace'>;
Expand All @@ -12,6 +17,7 @@ export type IsAreaAvailableStatus = {
reliantAreas: { [key in SupportedArea]?: boolean } | null; // only needs 1 to be true
requiredComponents: { [key in StackComponent]?: boolean } | null;
requiredCapabilities: { [key in StackCapability]?: boolean } | null;
customCondition: (conditionFunc: CustomConditionFunction) => boolean;
};

/** All areas that we need to support in some fashion or another */
Expand Down Expand Up @@ -72,6 +78,12 @@ export enum StackCapability {
SERVICE_MESH_AUTHZ = 'CapabilityServiceMeshAuthorization',
}

export type CustomConditionFunction = (state: {
dashboardConfigSpec: DashboardConfigKind['spec'];
dscStatus: DataScienceClusterKindStatus | null;
dsciStatus: DataScienceClusterInitializationKindStatus | null;
}) => boolean;

// TODO: Support extra operators, like the pipelines operator -- maybe as a "external dependency need?"
type SupportedComponentFlagValue = {
/**
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/concepts/areas/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@ export const isAreaAvailable = (
featureFlags: featureFlagState,
requiredComponents: requiredComponentsState,
requiredCapabilities: requiredCapabilitiesState,
customCondition: (conditionFunc) =>
conditionFunc({ dashboardConfigSpec, dscStatus, dsciStatus }),
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/react-core';
import React from 'react';
import { useBrowserStorage } from '~/components/browserStorage';
import { useIsAreaAvailable, SupportedArea } from '~/concepts/areas';

const INVALID_ARGO_DEPLOYMENT_DOCUMENTATION_URL = '';

export const InvalidArgoDeploymentAlert: React.FC = () => {
const [invalidArgoDeploymentAlertDismissed, setInvalidArgoDeploymentAlertDismissed] =
useBrowserStorage('invalidArgoDeploymentAlertDismissed', false, true, true);

const showMessage =
useIsAreaAvailable(SupportedArea.DS_PIPELINES).customCondition(
({ dscStatus }) =>
!!dscStatus?.conditions.some(
(c) => c.type === 'CapabilityDSPv2Argo' && c.status === 'False',
),
) && !invalidArgoDeploymentAlertDismissed;

if (!showMessage) {
return null;
}

return (
<Alert
actionLinks={
<AlertActionLink
component="a"
href={INVALID_ARGO_DEPLOYMENT_DOCUMENTATION_URL}
target="_blank"
rel="noopener noreferrer"
>
View documentation
</AlertActionLink>
}
actionClose={
<AlertActionCloseButton onClose={() => setInvalidArgoDeploymentAlertDismissed(true)} />
}
isInline
variant="warning"
title="Data Science Pipelines enablement failed"
>
Data Science Pipelines could not be enabled because a version of Argo Workflow that is not
managed by Red Hat is installed on your cluster. To learn more, view the Red Hat Openshift AI
2.9 documentation.
</Alert>
);
};

0 comments on commit 2911814

Please sign in to comment.