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-5496] Landing page: New home page hint #2752

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
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,
}}
andrewballantyne marked this conversation as resolved.
Show resolved Hide resolved
/>
))}
</ScrolledGallery>
Expand Down
Loading