Skip to content

Commit

Permalink
Merge pull request #2752 from jeff-phillips-18/home-page-hint
Browse files Browse the repository at this point in the history
[RHOAIENG-5496] Landing page: New home page hint
  • Loading branch information
openshift-merge-bot[bot] authored Apr 30, 2024
2 parents 84ac502 + f838b34 commit ab0d1b5
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 15 deletions.
4 changes: 3 additions & 1 deletion frontend/src/__mocks__/mockDashboardConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type MockDashboardConfigType = {
disablePipelineExperiments?: boolean;
disableDistributedWorkloads?: boolean;
disableModelRegistry?: boolean;
disableNotebookController?: boolean;
};

export const mockDashboardConfig = ({
Expand All @@ -48,6 +49,7 @@ export const mockDashboardConfig = ({
disablePipelineExperiments = true,
disableDistributedWorkloads = false,
disableModelRegistry = true,
disableNotebookController = false,
}: MockDashboardConfigType): DashboardConfigKind => ({
apiVersion: 'opendatahub.io/v1alpha',
kind: 'OdhDashboardConfig',
Expand Down Expand Up @@ -86,7 +88,7 @@ export const mockDashboardConfig = ({
disableModelRegistry,
},
notebookController: {
enabled: true,
enabled: !disableNotebookController,
notebookNamespace: 'openshift-ai-notebooks',
notebookTolerationSettings: {
enabled: true,
Expand Down
41 changes: 41 additions & 0 deletions frontend/src/__tests__/cypress/cypress/e2e/home/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,45 @@ describe('Home page', () => {
cy.interceptOdh('GET /api/components', { query: { installed: 'true' } }, mockComponents());
enabledPage.visit(true);
});
it('should show the home page hint', () => {
initHomeIntercepts({ disableHome: false });
cy.interceptOdh('GET /api/components', { query: { installed: 'true' } }, mockComponents());

cy.visit('/');
cy.findByTestId('home-page-hint').should('be.visible');

cy.findByTestId('jupyter-hint-icon').should('be.visible');
cy.findByTestId('hint-body-text').should('contain', 'Jupyter');

// enabled applications page is still navigable
cy.findByTestId('home-page-hint-navigate').click();

cy.findByTestId('enabled-application').should('be.visible');
});
it('should hide the home page hint when the notebook controller is disabled.', () => {
initHomeIntercepts({ disableHome: false, disableNotebookController: true });
cy.interceptOdh('GET /api/components', { query: { installed: 'true' } }, mockComponents());

cy.visit('/');

cy.findByTestId('home-page-hint').should('not.exist');
});
it('should hide the home page hint when closed', () => {
initHomeIntercepts({ disableHome: false });
cy.interceptOdh('GET /api/components', { query: { installed: 'true' } }, mockComponents());

cy.visit('/');
cy.findByTestId('home-page-hint').should('be.visible');

// enabled applications page is still navigable
cy.findByTestId('home-page-hint-close').click();

cy.findByTestId('home-page-hint').should('not.exist');

cy.visit('/enabled');
cy.findByTestId('enabled-application').should('be.visible');

cy.visit('/');
cy.findByTestId('home-page-hint').should('not.exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ describe('Home page Resources section', () => {
initHomeIntercepts({ disableHome: false });
cy.visit('/');

cy.findByTestId('landing-page-resources').should('be.visible');
cy.findByTestId('landing-page-resources').scrollIntoView();
cy.findByTestId('resource-card-create-jupyter-notebook').should('be.visible');
});
it('should hide the the resource section if none are available', () => {
cy.interceptOdh('GET /api/quickstarts', []);
Expand All @@ -25,7 +26,7 @@ describe('Home page Resources section', () => {

cy.findByTestId('landing-page-resources').should('not.exist');
});
it('should navigate to the project list', () => {
it('should navigate to the resources page', () => {
initHomeIntercepts({ disableHome: false });
cy.visit('/');

Expand Down
27 changes: 16 additions & 11 deletions frontend/src/pages/home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import ProjectsSection from './projects/ProjectsSection';
import { useAIFlows } from './aiFlows/useAIFlows';
import { useResourcesSection } from './resources/useResourcesSection';
import { useEnableTeamSection } from './useEnableTeamSection';
import HomeHint from './HomeHint';

const Home: React.FC = () => {
const { status: projectsAvailable } = useIsAreaAvailable(SupportedArea.DS_PROJECTS_VIEW);
Expand All @@ -25,22 +26,26 @@ const Home: React.FC = () => {

if (!projectsAvailable && !aiFlows && !resourcesSection && !enableTeamSection) {
return (
<PageSection data-testid="home-page-empty" variant={PageSectionVariants.default}>
<Bullseye>
<EmptyState variant="full">
<EmptyStateHeader
titleText={`Welcome to ${ODH_PRODUCT_NAME}`}
headingLevel="h4"
icon={<EmptyStateIcon icon={HomeIcon} />}
/>
</EmptyState>
</Bullseye>
</PageSection>
<>
<HomeHint />
<PageSection data-testid="home-page-empty" variant={PageSectionVariants.default}>
<Bullseye>
<EmptyState variant="full">
<EmptyStateHeader
titleText={`Welcome to ${ODH_PRODUCT_NAME}`}
headingLevel="h4"
icon={<EmptyStateIcon icon={HomeIcon} />}
/>
</EmptyState>
</Bullseye>
</PageSection>
</>
);
}

return (
<div data-testid="home-page">
<HomeHint />
<ProjectsSection />
{aiFlows}
{resourcesSection}
Expand Down
96 changes: 96 additions & 0 deletions frontend/src/pages/home/HomeHint.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import * as React from 'react';
import {
Button,
Card,
CardBody,
CardHeader,
Flex,
FlexItem,
PageSection,
Text,
TextContent,
} from '@patternfly/react-core';
import { TimesIcon } from '@patternfly/react-icons';
import { useNavigate } from 'react-router-dom';
import jupyterImg from '~/images/jupyter.svg';
import { useBrowserStorage } from '~/components/browserStorage';
import { ODH_PRODUCT_NAME } from '~/utilities/const';
import { useCheckJupyterEnabled } from '~/utilities/notebookControllerUtils';

const HomeHint: React.FC = () => {
const navigate = useNavigate();
const [hintHidden, setHintHidden] = useBrowserStorage<boolean>(
'odh.dashboard.landing.hint',
false,
);
const jupyterEnabled = useCheckJupyterEnabled();

if (hintHidden || !jupyterEnabled) {
return null;
}

return (
<PageSection>
<Card data-testid="home-page-hint" style={{ borderRadius: 16 }}>
<CardHeader>
<Flex
alignItems={{ default: 'alignItemsCenter' }}
justifyContent={{ default: 'justifyContentSpaceBetween' }}
>
<FlexItem>
<TextContent>
<Text component="h2">Looking for the previous landing page?</Text>
</TextContent>
</FlexItem>
<FlexItem>
<Button
data-testid="home-page-hint-close"
aria-label="close landing page hint"
isInline
variant="plain"
onClick={() => setHintHidden(true)}
>
<TimesIcon />
</Button>
</FlexItem>
</Flex>
</CardHeader>
<CardBody style={{ maxWidth: 880 }}>
<Flex
alignItems={{ default: 'alignItemsCenter' }}
gap={{ default: 'gapMd' }}
flexWrap={{ default: 'nowrap' }}
>
<img
data-testid="jupyter-hint-icon"
src={jupyterImg}
alt="Jupyter"
style={{ height: 42, maxWidth: 'unset' }}
/>
<FlexItem>
<TextContent>
<Text component="p" data-testid="hint-body-text">
{ODH_PRODUCT_NAME} has a new landing page. You can access applications that are
enabled for your organization, such as Jupyter, from the{' '}
<Button
data-testid="home-page-hint-navigate"
variant="link"
isInline
component="a"
style={{ fontSize: 'var(--pf-v5-global--FontSize--md)' }}
onClick={() => navigate('/enabled')}
>
Enabled applications
</Button>{' '}
page.
</Text>
</TextContent>
</FlexItem>
</Flex>
</CardBody>
</Card>
</PageSection>
);
};

export default HomeHint;
2 changes: 1 addition & 1 deletion frontend/src/pages/home/projects/EmptyProjectsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type EmptyProjectsCardProps = {
};

const EmptyProjectsCard: React.FC<EmptyProjectsCardProps> = ({ allowCreate, onCreateProject }) => (
<Card data-testid="landing-page-projects-empty">
<Card data-testid="landing-page-projects-empty" style={{ borderRadius: 16 }}>
<CardBody>
<Flex
gap={{ default: 'gapLg' }}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/pages/home/resources/useResourcesSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export const useResourcesSection = (): React.ReactNode => {
key={`${doc.metadata.name}`}
odhDoc={doc as unknown as OdhDocument}
showFavorite={false}
style={{
border: '1px solid var(--pf-v5-global--BorderColor--100)',
borderRadius: 16,
}}
/>
))}
</ScrolledGallery>
Expand Down

0 comments on commit ab0d1b5

Please sign in to comment.