From 0d04fd7b15958b83bdbea49c2d65bd02323832d7 Mon Sep 17 00:00:00 2001 From: Gage Krumbach Date: Tue, 19 Nov 2024 12:13:26 -0600 Subject: [PATCH] handle workbench not enabled --- frontend/src/components/OdhAppCard.tsx | 8 ++++++-- .../pages/projects/screens/detail/ProjectDetails.tsx | 11 ++++++++++- .../overview/trainModels/TrainModelsSection.tsx | 7 ++++++- .../projects/screens/detail/storage/StorageTable.tsx | 6 ++++++ .../projects/screens/projects/ProjectListView.tsx | 8 +++++++- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/OdhAppCard.tsx b/frontend/src/components/OdhAppCard.tsx index fb4aed3b80..cdabce7c74 100644 --- a/frontend/src/components/OdhAppCard.tsx +++ b/frontend/src/components/OdhAppCard.tsx @@ -23,6 +23,7 @@ import { addNotification, forceComponentsUpdate } from '~/redux/actions/actions' import { ODH_PRODUCT_NAME } from '~/utilities/const'; import { useAppContext } from '~/app/AppContext'; import { useAppDispatch } from '~/redux/hooks'; +import { SupportedArea, useIsAreaAvailable } from '~/concepts/areas'; import { useQuickStartCardSelected } from './useQuickStartCardSelected'; import SupportedAppTitle from './SupportedAppTitle'; import BrandImage from './BrandImage'; @@ -40,6 +41,7 @@ const OdhAppCard: React.FC = ({ odhApp }) => { odhApp.spec.quickStart, odhApp.metadata.name, ); + const workbenchEnabled = useIsAreaAvailable(SupportedArea.WORKBENCHES).status; const disabled = !odhApp.spec.isEnabled; const { dashboardConfig } = useAppContext(); const dispatch = useAppDispatch(); @@ -97,7 +99,7 @@ const OdhAppCard: React.FC = ({ odhApp }) => { const launchClasses = classNames('odh-card__footer__link', { 'm-hidden': !odhApp.spec.link, - 'm-disabled': disabled, + 'm-disabled': disabled || !workbenchEnabled, }); const cardFooter = ( @@ -107,7 +109,9 @@ const OdhAppCard: React.FC = ({ odhApp }) => { Launch application diff --git a/frontend/src/pages/projects/screens/detail/ProjectDetails.tsx b/frontend/src/pages/projects/screens/detail/ProjectDetails.tsx index 2e024443d4..02b07bed8f 100644 --- a/frontend/src/pages/projects/screens/detail/ProjectDetails.tsx +++ b/frontend/src/pages/projects/screens/detail/ProjectDetails.tsx @@ -50,6 +50,7 @@ const ProjectDetails: React.FC = () => { ...accessReviewResource, namespace: currentProject.metadata.name, }); + const workbenchEnabled = useIsAreaAvailable(SupportedArea.WORKBENCHES).status; useCheckLogoutParams(); @@ -80,7 +81,15 @@ const ProjectDetails: React.FC = () => { activeKey={state} sections={[ { id: ProjectSectionID.OVERVIEW, title: 'Overview', component: }, - { id: ProjectSectionID.WORKBENCHES, title: 'Workbenches', component: }, + ...(workbenchEnabled + ? [ + { + id: ProjectSectionID.WORKBENCHES, + title: 'Workbenches', + component: , + }, + ] + : []), ...(pipelinesEnabled ? [ { diff --git a/frontend/src/pages/projects/screens/detail/overview/trainModels/TrainModelsSection.tsx b/frontend/src/pages/projects/screens/detail/overview/trainModels/TrainModelsSection.tsx index 9cb02e1147..56fc3b711f 100644 --- a/frontend/src/pages/projects/screens/detail/overview/trainModels/TrainModelsSection.tsx +++ b/frontend/src/pages/projects/screens/detail/overview/trainModels/TrainModelsSection.tsx @@ -7,6 +7,11 @@ import NotebooksCard from './NotebooksCard'; const TrainModelsSection: React.FC = () => { const pipelinesEnabled = useIsAreaAvailable(SupportedArea.DS_PIPELINES).status; + const workbenchEnabled = useIsAreaAvailable(SupportedArea.WORKBENCHES).status; + + if (!workbenchEnabled && !pipelinesEnabled) { + return null; + } return ( @@ -15,7 +20,7 @@ const TrainModelsSection: React.FC = () => { minWidths={{ default: '100%', lg: pipelinesEnabled ? 'calc(50% - 1rem / 2)' : '100%' }} maxWidths={{ default: '100%', lg: pipelinesEnabled ? 'calc(50% - 1rem / 2)' : '100%' }} > - + {workbenchEnabled ? : null} {pipelinesEnabled ? : null} diff --git a/frontend/src/pages/projects/screens/detail/storage/StorageTable.tsx b/frontend/src/pages/projects/screens/detail/storage/StorageTable.tsx index 8f087e1678..fcb802772f 100644 --- a/frontend/src/pages/projects/screens/detail/storage/StorageTable.tsx +++ b/frontend/src/pages/projects/screens/detail/storage/StorageTable.tsx @@ -37,6 +37,7 @@ const StorageTable: React.FC = ({ pvcs, refresh, onAddPVC }) [storageClassesLoaded, storageTableData], ); const shouldShowAlert = isDeprecatedAlert && !alertDismissed && isStorageClassesAvailable; + const workbenchEnabled = useIsAreaAvailable(SupportedArea.WORKBENCHES).status; const getStorageColumns = () => { let storageColumns = columns; @@ -44,6 +45,11 @@ const StorageTable: React.FC = ({ pvcs, refresh, onAddPVC }) if (!isStorageClassesAvailable) { storageColumns = columns.filter((column) => column.field !== 'storage'); } + + if (!workbenchEnabled) { + storageColumns = storageColumns.filter((column) => column.field !== 'workbench'); + } + return storageColumns; }; diff --git a/frontend/src/pages/projects/screens/projects/ProjectListView.tsx b/frontend/src/pages/projects/screens/projects/ProjectListView.tsx index be0237b541..12d5bfd443 100644 --- a/frontend/src/pages/projects/screens/projects/ProjectListView.tsx +++ b/frontend/src/pages/projects/screens/projects/ProjectListView.tsx @@ -12,6 +12,7 @@ import { initialProjectsFilterData, ProjectsFilterDataType, } from '~/pages/projects/screens/projects/const'; +import { SupportedArea, useIsAreaAvailable } from '~/concepts/areas'; import { columns } from './tableData'; import DeleteProjectModal from './DeleteProjectModal'; import ManageProjectModal from './ManageProjectModal'; @@ -60,6 +61,11 @@ const ProjectListView: React.FC = ({ allowCreate }) => { const [deleteData, setDeleteData] = React.useState(); const [editData, setEditData] = React.useState(); const [refreshIds, setRefreshIds] = React.useState([]); + const workbenchEnabled = useIsAreaAvailable(SupportedArea.WORKBENCHES).status; + + const filteredColumns = workbenchEnabled + ? columns + : columns.filter((column) => column.field !== 'Workbenches'); return ( <> @@ -69,7 +75,7 @@ const ProjectListView: React.FC = ({ allowCreate }) => { variant="compact" defaultSortColumn={0} data={filteredProjects} - columns={columns} + columns={filteredColumns} emptyTableView={} data-testid="project-view-table" disableRowRenderSupport