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

[RHOAIENG-5487] Initial "empty state" of home page #2719

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions backend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type DashboardConfig = K8sResourceCommon & {
disableISVBadges: boolean;
disableAppLauncher: boolean;
disableUserManagement: boolean;
disableHome: boolean;
disableProjects: boolean;
disableModelServing: boolean;
disableProjectSharing: boolean;
Expand Down
1 change: 1 addition & 0 deletions backend/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const blankDashboardCR: DashboardConfig = {
disableISVBadges: false,
disableAppLauncher: false,
disableUserManagement: false,
disableHome: true,
disableProjects: false,
disableModelServing: false,
disableProjectSharing: false,
Expand Down
5 changes: 4 additions & 1 deletion docs/dashboard-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ By default the ODH Dashboard comes with a set of core features enabled that are
The following are a list of features that are supported, along with there default settings.

| Feature | Default | Description |
| ---------------------------- | ------- | ---------------------------------------------------------------------------------------------------- |
|------------------------------|---------|------------------------------------------------------------------------------------------------------|
| enablement | true | Enables the ability to enable ISVs to the dashboard |
| disableInfo | false | Removes the information panel in Explore Application section |
| disableSupport | false | Disables components related to support. |
Expand All @@ -19,6 +19,7 @@ The following are a list of features that are supported, along with there defaul
| disableISVBadges | false | Removes the badge that indicate if a product is ISV or not. |
| disableAppLauncher | false | Removes the application launcher that is used in OKD environments |
| disableUserManagement | false | Removes the User Management panel in Settings. |
| disableHome | true | Disables Data Science Home page from the dashboard. |
| disableProjects | false | Disables Data Science Projects from the dashboard. |
| disablePipelines | false | Disables Data Science Pipelines from the dashboard. |
| disableModelServing | false | Disables Model Serving from the dashboard and from Data Science Projects. |
Expand Down Expand Up @@ -50,6 +51,7 @@ spec:
disableISVBadges: false
disableAppLauncher: false
disableUserManagement: false
disableHome: true
disableProjects: false
disablePipelines: false
disableModelServing: false
Expand Down Expand Up @@ -144,6 +146,7 @@ spec:
disableInfo: false
disableSupport: false
disableTracking: true
disableHome: true
disableProjects: true
disablePipelines: true
disableModelServing: true
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/__mocks__/mockDashboardConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type MockDashboardConfigType = {
disableISVBadges?: boolean;
disableAppLauncher?: boolean;
disableUserManagement?: boolean;
disableHome?: boolean;
disableProjects?: boolean;
disablePipelines?: boolean;
disableModelServing?: boolean;
Expand All @@ -33,6 +34,7 @@ export const mockDashboardConfig = ({
disableISVBadges = false,
disableAppLauncher = false,
disableUserManagement = false,
disableHome = true,
disableProjects = false,
disableModelServing = false,
disableCustomServingRuntimes = false,
Expand Down Expand Up @@ -67,6 +69,7 @@ export const mockDashboardConfig = ({
disableISVBadges,
disableAppLauncher,
disableUserManagement,
disableHome,
disableProjects,
disableModelServing,
disableCustomServingRuntimes,
Expand Down
33 changes: 33 additions & 0 deletions frontend/src/__tests__/cypress/cypress/e2e/home/home.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { mockDashboardConfig } from '~/__mocks__/mockDashboardConfig';
import { mockComponents } from '~/__mocks__/mockComponents';
import { enabledPage } from '~/__tests__/cypress/cypress/pages/enabled';

type HandlersProps = {
disableHome?: boolean;
};

const initIntercepts = ({ disableHome }: HandlersProps) => {
cy.interceptOdh(
'GET /api/config',
mockDashboardConfig({
disableHome,
}),
);
cy.interceptOdh('GET /api/components', { query: { installed: 'true' } }, mockComponents());
};

describe('Home page', () => {
it('should not be shown by default', () => {
initIntercepts({});
cy.visit('/');
cy.findByTestId('enabled-application').should('be.visible');
});
it('should be shown when enabled', () => {
initIntercepts({ disableHome: false });
cy.visit('/');
cy.findByTestId('home-page').should('be.visible');

// enabled applications page is still navigable
enabledPage.visit(true);
});
});
4 changes: 2 additions & 2 deletions frontend/src/__tests__/cypress/cypress/pages/enabled.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class EnabledPage {
visit() {
cy.visit('/');
visit(homeEnabled = false) {
cy.visit(homeEnabled ? '/enabled' : '/');
this.wait();
}

Expand Down
14 changes: 13 additions & 1 deletion frontend/src/app/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import UnauthorizedError from '~/pages/UnauthorizedError';
import { useUser } from '~/redux/selectors';
import { globExperimentsAll, globPipelineRunsAll, globPipelinesAll } from '~/routes';
import { useCheckJupyterEnabled } from '~/utilities/notebookControllerUtils';
import { SupportedArea } from '~/concepts/areas';
import useIsAreaAvailable from '~/concepts/areas/useIsAreaAvailable';

const HomePage = React.lazy(() => import('../pages/home/Home'));

const InstalledApplications = React.lazy(
() => import('../pages/enabledApplications/EnabledApplications'),
Expand Down Expand Up @@ -56,6 +60,7 @@ const ModelRegistryRoutes = React.lazy(() => import('../pages/modelRegistry/Mode
const AppRoutes: React.FC = () => {
const { isAdmin, isAllowed } = useUser();
const isJupyterEnabled = useCheckJupyterEnabled();
const isHomeAvailable = useIsAreaAvailable(SupportedArea.HOME).status;

if (!isAllowed) {
return (
Expand All @@ -69,7 +74,14 @@ const AppRoutes: React.FC = () => {
<React.Suspense fallback={<ApplicationsPage title="" description="" loaded={false} empty />}>
<InvalidArgoDeploymentAlert />
<Routes>
<Route path="/" element={<InstalledApplications />} />
{isHomeAvailable ? (
<>
<Route path="/" element={<HomePage />} />
<Route path="/enabled" element={<InstalledApplications />} />
</>
) : (
<Route path="/" element={<InstalledApplications />} />
)}
<Route path="/explore" element={<ExploreApplications />} />
<Route path="/resources" element={<LearningCenterPage />} />

Expand Down
3 changes: 3 additions & 0 deletions frontend/src/concepts/areas/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const SupportedAreasStateMap: SupportedAreasState = {
featureFlags: ['disablePipelines'],
requiredComponents: [StackComponent.DS_PIPELINES],
},
[SupportedArea.HOME]: {
featureFlags: ['disableHome'],
},
[SupportedArea.DS_PROJECTS_VIEW]: {
featureFlags: ['disableProjects'],
},
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/concepts/areas/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export type IsAreaAvailableStatus = {

/** All areas that we need to support in some fashion or another */
export enum SupportedArea {
HOME = 'home',

/* Standalone areas */
DS_PIPELINES = 'ds-pipelines',
// TODO: Jupyter Tile Support? (outside of feature flags today)
Expand Down
1 change: 1 addition & 0 deletions frontend/src/k8sTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ export type DashboardCommonConfig = {
disableISVBadges: boolean;
disableAppLauncher: boolean;
disableUserManagement: boolean;
disableHome: boolean;
disableProjects: boolean;
disableModelServing: boolean;
disableProjectSharing: boolean;
Expand Down
27 changes: 27 additions & 0 deletions frontend/src/pages/home/Home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as React from 'react';
import {
Bullseye,
EmptyState,
EmptyStateHeader,
EmptyStateIcon,
PageSection,
PageSectionVariants,
} from '@patternfly/react-core';
import { HomeIcon } from '@patternfly/react-icons';

const Home: React.FC = () => (
<PageSection data-testid="home-page" variant={PageSectionVariants.light}>
<Bullseye>
<EmptyState variant="full">
<EmptyStateHeader
titleText="Welcome to the home page"
headingLevel="h4"
icon={<EmptyStateIcon icon={HomeIcon} />}
alt=""
/>
</EmptyState>
</Bullseye>
</PageSection>
);

export default Home;
28 changes: 18 additions & 10 deletions frontend/src/utilities/NavData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,23 @@ export const isNavDataGroup = (navData: NavDataItem): navData is NavDataGroup =>
const useAreaCheck = <T,>(area: SupportedArea, success: T[]): T[] =>
useIsAreaAvailable(area).status ? success : [];

const useApplicationsNav = (): NavDataItem[] => [
{
id: 'applications',
group: { id: 'apps', title: 'Applications' },
children: [
{ id: 'apps-installed', label: 'Enabled', href: '/' },
{ id: 'apps-explore', label: 'Explore', href: '/explore' },
],
},
];
const useApplicationsNav = (): NavDataItem[] => {
const isHomeAvailable = useIsAreaAvailable(SupportedArea.HOME).status;

return [
{
id: 'applications',
group: { id: 'apps', title: 'Applications' },
children: [
{ id: 'apps-installed', label: 'Enabled', href: isHomeAvailable ? '/enabled' : '/' },
{ id: 'apps-explore', label: 'Explore', href: '/explore' },
],
},
];
};

const useHomeNav = (): NavDataItem[] =>
useAreaCheck(SupportedArea.HOME, [{ id: 'home', label: 'Home', href: '/' }]);

const useDSProjectsNav = (): NavDataItem[] =>
useAreaCheck(SupportedArea.DS_PROJECTS_VIEW, [
Expand Down Expand Up @@ -171,6 +178,7 @@ const useSettingsNav = (): NavDataGroup[] => {
};

export const useBuildNavData = (): NavDataItem[] => [
...useHomeNav(),
...useApplicationsNav(),
...useDSProjectsNav(),
...useDSPipelinesNav(),
Expand Down
2 changes: 2 additions & 0 deletions manifests/crd/odhdashboardconfigs.opendatahub.io.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ spec:
type: boolean
disableUserManagement:
type: boolean
disableHome:
type: boolean
disableProjects:
type: boolean
disableModelServing:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ spec:
disableSupport: false
disableTracking: true
enablement: true
disableHome: true
disableProjects: true
disablePipelines: true
disablePipelineExperiments: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ spec:
disableSupport: false
disableTracking: false
enablement: true
disableHome: false
disableProjects: false
disablePipelines: false
disableModelServing: false
Expand Down Expand Up @@ -92,4 +93,4 @@ spec:
cpu: "6"
memory: 16Gi
templateOrder: []
templateDisablement: []
templateDisablement: []
Loading