From 27cb01c318c5b854a13e44825ede2c3a082bf786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cintia=20S=C3=A1nchez=20Garc=C3=ADa?= Date: Tue, 7 Jan 2025 11:26:56 +0100 Subject: [PATCH] Update Helm installation instructions modal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4172 Signed-off-by: Cintia Sánchez García --- .../installation/ContentInstall.module.css | 4 + .../package/installation/HelmInstall.test.tsx | 11 ++- .../package/installation/HelmInstall.tsx | 45 +++++++---- .../__snapshots__/HelmInstall.test.tsx.snap | 2 +- .../__snapshots__/Modal.test.tsx.snap | 2 +- web/src/utils/getInstallMethods.test.tsx | 78 +++++++++++++++++++ 6 files changed, 123 insertions(+), 19 deletions(-) diff --git a/web/src/layout/package/installation/ContentInstall.module.css b/web/src/layout/package/installation/ContentInstall.module.css index 3249ee19e3..77d82cd3be 100644 --- a/web/src/layout/package/installation/ContentInstall.module.css +++ b/web/src/layout/package/installation/ContentInstall.module.css @@ -62,6 +62,10 @@ height: 335px; } +.ociBadge { + font-size: 95%; +} + @media only screen and (max-width: 767.98px) { .blockWrapper { font-size: 0.9rem; diff --git a/web/src/layout/package/installation/HelmInstall.test.tsx b/web/src/layout/package/installation/HelmInstall.test.tsx index e920073542..6f4704324e 100644 --- a/web/src/layout/package/installation/HelmInstall.test.tsx +++ b/web/src/layout/package/installation/HelmInstall.test.tsx @@ -48,13 +48,20 @@ describe('HelmInstall', () => { it('renders component with content url', () => { render(); - expect(screen.getByText(/You can also download this package's content directly using/)).toBeInTheDocument(); - const contentUrl = screen.getAllByRole('button')[3]; + expect(screen.getByText(/You can also download this package's content using/)).toBeInTheDocument(); + const contentUrl = screen.getAllByRole('button')[2]; expect(contentUrl).toBeInTheDocument(); expect(contentUrl).toHaveTextContent('this link'); expect(contentUrl).toHaveProperty('href', 'http://content.url/'); }); + it('renders component with oci url', async () => { + render(); + + expect(screen.getByText(/You can also download this package's content using/)).toBeInTheDocument(); + expect(await screen.findByText('helm pull oci://content.url --version 0.0.1')).toBeInTheDocument(); + }); + it('renders private repo', () => { render(); diff --git a/web/src/layout/package/installation/HelmInstall.tsx b/web/src/layout/package/installation/HelmInstall.tsx index c5aec7c2c5..7cb8e63111 100644 --- a/web/src/layout/package/installation/HelmInstall.tsx +++ b/web/src/layout/package/installation/HelmInstall.tsx @@ -1,4 +1,5 @@ import { Repository } from '../../../types'; +import { OCI_PREFIX } from '../../../utils/data'; import ExternalLink from '../../common/ExternalLink'; import CommandBlock from './CommandBlock'; import styles from './ContentInstall.module.css'; @@ -14,6 +15,11 @@ interface Props { const HelmInstall = (props: Props) => { const getInstallationVersionInfo = (installCmd: string) => { + const compoundOCICommand = (contentUrl: string): string => { + const index = contentUrl.lastIndexOf(':'); + return `helm pull ${contentUrl.substring(0, index)} --version ${contentUrl.substring(index + 1)}`; + }; + return ( <> { command if you need to. -
- - Need Helm? - - - {props.contentUrl && ( -
- - You can also download this package's content directly using{' '} + {props.contentUrl && ( +
+ {props.contentUrl.startsWith(OCI_PREFIX) ? ( +
+ +
+ ) : ( + + You can also download this package's content using{' '} { . -
- )} + )} +
+ )} + +
+ + Need Helm? +
); diff --git a/web/src/layout/package/installation/__snapshots__/HelmInstall.test.tsx.snap b/web/src/layout/package/installation/__snapshots__/HelmInstall.test.tsx.snap index 959458e55d..4919385d34 100644 --- a/web/src/layout/package/installation/__snapshots__/HelmInstall.test.tsx.snap +++ b/web/src/layout/package/installation/__snapshots__/HelmInstall.test.tsx.snap @@ -157,7 +157,7 @@ exports[`HelmInstall creates snapshot 1`] = ` command if you need to.