Skip to content

Commit

Permalink
Merge pull request #2846 from rsun19/configure-eslint-product-name
Browse files Browse the repository at this point in the history
[RHOAIENG-7531] eslint rule to flag hard coded product name usage instead of variable
  • Loading branch information
openshift-merge-bot[bot] authored May 28, 2024
2 parents 371793a + 97d6c8a commit ca66b42
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
17 changes: 17 additions & 0 deletions frontend/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,23 @@
"prettier",
"plugin:cypress/recommended"
]
},
{
"files": ["*.ts", "*.tsx"],
"excludedFiles": ["src/__mocks__/**", "src/__tests__/**"],
"rules": {
"no-restricted-syntax": [
"error",
{
"selector": "Literal[value=/\\bRed Hat OpenShift AI\\b/i],JSXText[value=/\\bRed Hat OpenShift AI\\b/i]",
"message": "Do not hard code product name `Red Hat OpenShift AI`. Use `~/utilities/const#ODH_PRODUCT_NAME` instead."
},
{
"selector": "Literal[value=/\\bOpen Data Hub\\b/i],JSXText[value=/\\bOpen Data Hub\\b/i]",
"message": "Do not hard code product name `Open Data Hub`. Use `~/utilities/const#ODH_PRODUCT_NAME` instead."
}
]
}
}
]
}
4 changes: 4 additions & 0 deletions frontend/src/__tests__/cypress/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import coverage from '@cypress/code-coverage/task';
import { interceptSnapshotFile } from '~/__tests__/cypress/cypress/utils/snapshotUtils';
import { setup as setupWebsockets } from '~/__tests__/cypress/cypress/support/websockets';

dotenv.config({
path: path.resolve(__dirname, '../../../.env'),
});
dotenv.config({
path: path.resolve(__dirname, `../../../.env.cypress${process.env.MOCK ? '.mock' : ''}`),
});
Expand All @@ -28,6 +31,7 @@ export default defineConfig({
codeCoverage: {
exclude: [path.resolve(__dirname, '../../third_party/**')],
},
ODH_PRODUCT_NAME: process.env.ODH_PRODUCT_NAME,
},
defaultCommandTimeout: 10000,
e2e: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class AdministrationTab {
shouldHaveManageUsersAlert() {
cy.findByTestId('manage-users-alert').should(
'have.text',
'Custom alert:Manage users in OpenShiftCreate, delete, and manage permissions for Red Hat OpenShift AI users in OpenShift. Learn more about OpenShift user management',
`Custom alert:Manage users in OpenShiftCreate, delete, and manage permissions for ${Cypress.env(
'ODH_PRODUCT_NAME',
)} users in OpenShift. Learn more about OpenShift user management`,
);
return this;
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/OdhExploreCardTypeBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { Tooltip } from '@patternfly/react-core';
import { OdhApplicationCategory } from '~/types';
import { ODH_PRODUCT_NAME } from '~/utilities/const';

type OdhExploreCardTypeBadgeProps = {
category: OdhApplicationCategory | string;
Expand All @@ -14,8 +15,7 @@ const OdhExploreCardTypeBadge: React.FC<OdhExploreCardTypeBadgeProps> = ({ categ
} else if (category === OdhApplicationCategory.PartnerManaged) {
content = 'Partner managed software is hosted on the ISV’s cloud service';
} else if (category === OdhApplicationCategory.SelfManaged) {
content =
'Self-managed software is installed to a Red Hat OpenShift AI cluster, but does not support upgrade testing, alerting, or other features of externally managed software';
content = `Self-managed software is installed to a ${ODH_PRODUCT_NAME} cluster, but does not support upgrade testing, alerting, or other features of externally managed software`;
}

if (!content) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac
import React from 'react';
import { useBrowserStorage } from '~/components/browserStorage';
import { useIsAreaAvailable, SupportedArea } from '~/concepts/areas';
import { ODH_PRODUCT_NAME } from '~/utilities/const';

const INVALID_ARGO_DEPLOYMENT_CLOUD_DOCUMENTATION_URL =
'https://access.redhat.com/documentation/en-us/red_hat_openshift_ai_self-managed/2.9/html/release_notes/new-features-and-enhancements_relnotes';
Expand Down Expand Up @@ -55,7 +56,7 @@ export const InvalidArgoDeploymentAlert: React.FC = () => {
title="Data Science Pipelines enablement failed"
>
Data Science Pipelines could not be enabled because a version of Argo Workflows that is not
managed by Red Hat is installed on your cluster. To learn more, view the Red Hat Openshift AI
managed by Red Hat is installed on your cluster. To learn more, view the {ODH_PRODUCT_NAME}
2.9 documentation.
</Alert>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ExternalLink from '~/components/ExternalLink';
import ApplicationsPage from '~/pages/ApplicationsPage';
import StopServerModal from '~/pages/notebookController/screens/server/StopServerModal';
import { Notebook } from '~/types';
import { ODH_PRODUCT_NAME } from '~/utilities/const';
import { columns } from './data';
import StopAllServersButton from './StopAllServersButton';
import UserTableCellTransform from './UserTableCellTransform';
Expand Down Expand Up @@ -55,7 +56,7 @@ const NotebookAdminControl: React.FC = () => {
isInline
data-testid="manage-users-alert"
>
Create, delete, and manage permissions for Red Hat OpenShift AI users in OpenShift.{' '}
Create, delete, and manage permissions for {ODH_PRODUCT_NAME} users in OpenShift.{' '}
<ExternalLink
text="Learn more about OpenShift user management"
to="https://access.redhat.com/documentation/en-us/red_hat_openshift_data_science/1/html/managing_users_and_user_resources/index"
Expand Down

0 comments on commit ca66b42

Please sign in to comment.