Skip to content

Commit

Permalink
handle workbench not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Gkrumbach07 committed Nov 19, 2024
1 parent 5fccd14 commit 0d04fd7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
8 changes: 6 additions & 2 deletions frontend/src/components/OdhAppCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -40,6 +41,7 @@ const OdhAppCard: React.FC<OdhAppCardProps> = ({ odhApp }) => {
odhApp.spec.quickStart,
odhApp.metadata.name,
);
const workbenchEnabled = useIsAreaAvailable(SupportedArea.WORKBENCHES).status;
const disabled = !odhApp.spec.isEnabled;
const { dashboardConfig } = useAppContext();
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -97,7 +99,7 @@ const OdhAppCard: React.FC<OdhAppCardProps> = ({ odhApp }) => {

const launchClasses = classNames('odh-card__footer__link', {
'm-hidden': !odhApp.spec.link,
'm-disabled': disabled,
'm-disabled': disabled || !workbenchEnabled,
});

const cardFooter = (
Expand All @@ -107,7 +109,9 @@ const OdhAppCard: React.FC<OdhAppCardProps> = ({ odhApp }) => {
<Link
data-testid="jupyter-app-link"
to="/notebookController"
className="odh-card__footer__link"
className={classNames('odh-card__footer__link', {
'm-disabled': !workbenchEnabled,
})}
>
Launch application
</Link>
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/pages/projects/screens/detail/ProjectDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const ProjectDetails: React.FC = () => {
...accessReviewResource,
namespace: currentProject.metadata.name,
});
const workbenchEnabled = useIsAreaAvailable(SupportedArea.WORKBENCHES).status;

useCheckLogoutParams();

Expand Down Expand Up @@ -80,7 +81,15 @@ const ProjectDetails: React.FC = () => {
activeKey={state}
sections={[
{ id: ProjectSectionID.OVERVIEW, title: 'Overview', component: <ProjectOverview /> },
{ id: ProjectSectionID.WORKBENCHES, title: 'Workbenches', component: <NotebookList /> },
...(workbenchEnabled
? [
{
id: ProjectSectionID.WORKBENCHES,
title: 'Workbenches',
component: <NotebookList />,
},
]
: []),
...(pipelinesEnabled
? [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<CollapsibleSection title="Train models">
Expand All @@ -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%' }}
>
<NotebooksCard />
{workbenchEnabled ? <NotebooksCard /> : null}
{pipelinesEnabled ? <PipelinesCard /> : null}
</Gallery>
</CollapsibleSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@ const StorageTable: React.FC<StorageTableProps> = ({ pvcs, refresh, onAddPVC })
[storageClassesLoaded, storageTableData],
);
const shouldShowAlert = isDeprecatedAlert && !alertDismissed && isStorageClassesAvailable;
const workbenchEnabled = useIsAreaAvailable(SupportedArea.WORKBENCHES).status;

const getStorageColumns = () => {
let storageColumns = columns;

if (!isStorageClassesAvailable) {
storageColumns = columns.filter((column) => column.field !== 'storage');
}

if (!workbenchEnabled) {
storageColumns = storageColumns.filter((column) => column.field !== 'workbench');
}

return storageColumns;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -60,6 +61,11 @@ const ProjectListView: React.FC<ProjectListViewProps> = ({ allowCreate }) => {
const [deleteData, setDeleteData] = React.useState<ProjectKind | undefined>();
const [editData, setEditData] = React.useState<ProjectKind | undefined>();
const [refreshIds, setRefreshIds] = React.useState<string[]>([]);
const workbenchEnabled = useIsAreaAvailable(SupportedArea.WORKBENCHES).status;

const filteredColumns = workbenchEnabled
? columns
: columns.filter((column) => column.field !== 'Workbenches');

return (
<>
Expand All @@ -69,7 +75,7 @@ const ProjectListView: React.FC<ProjectListViewProps> = ({ allowCreate }) => {
variant="compact"
defaultSortColumn={0}
data={filteredProjects}
columns={columns}
columns={filteredColumns}
emptyTableView={<DashboardEmptyTableView onClearFilters={resetFilters} />}
data-testid="project-view-table"
disableRowRenderSupport
Expand Down

0 comments on commit 0d04fd7

Please sign in to comment.