diff --git a/web/package.json b/web/package.json index 85444706b..b4d8668e0 100644 --- a/web/package.json +++ b/web/package.json @@ -51,7 +51,7 @@ "@codemirror/view": "^6.9.6", "@harnessio/design-system": "^2.1.1", "@harnessio/icons": "^2.1.9", - "@harnessio/react-har-service-client": "^0.13.0", + "@harnessio/react-har-service-client": "^0.14.0", "@harnessio/react-ssca-manager-client": "^0.65.0", "@harnessio/uicore": "^4.1.2", "@tanstack/react-query": "4.20.4", diff --git a/web/src/ar/MFEAppTypes.ts b/web/src/ar/MFEAppTypes.ts index 1f8e09320..a41959232 100644 --- a/web/src/ar/MFEAppTypes.ts +++ b/web/src/ar/MFEAppTypes.ts @@ -135,5 +135,6 @@ export interface MFEAppProps { export enum FeatureFlags { HAR_TRIGGERS = 'HAR_TRIGGERS', HAR_NPM_PACKAGE_TYPE_ENABLED = 'HAR_NPM_PACKAGE_TYPE_ENABLED', - HAR_PYTHON_PACKAGE_TYPE_ENABLED = 'HAR_PYTHON_PACKAGE_TYPE_ENABLED' + HAR_PYTHON_PACKAGE_TYPE_ENABLED = 'HAR_PYTHON_PACKAGE_TYPE_ENABLED', + HAR_NUGET_PACKAGE_TYPE_ENABLED = 'HAR_NUGET_PACKAGE_TYPE_ENABLED' } diff --git a/web/src/ar/hooks/useGetRepositoryTypes.ts b/web/src/ar/hooks/useGetRepositoryTypes.ts index 1358203aa..9961071fd 100644 --- a/web/src/ar/hooks/useGetRepositoryTypes.ts +++ b/web/src/ar/hooks/useGetRepositoryTypes.ts @@ -86,6 +86,7 @@ const RepositoryTypes: RepositoryTypeListItem[] = [ value: RepositoryPackageType.NUGET, icon: 'nuget-repository-type', tooltip: 'Coming Soon!', + featureFlag: FeatureFlags.HAR_NUGET_PACKAGE_TYPE_ENABLED, disabled: true } ] diff --git a/web/src/ar/hooks/useGetUpstreamRepositoryPackageTypes.ts b/web/src/ar/hooks/useGetUpstreamRepositoryPackageTypes.ts index 0df33e235..a4d1be193 100644 --- a/web/src/ar/hooks/useGetUpstreamRepositoryPackageTypes.ts +++ b/web/src/ar/hooks/useGetUpstreamRepositoryPackageTypes.ts @@ -77,5 +77,13 @@ export const UpstreamProxyPackageTypeList: UpstreamRepositoryPackageTypeListItem tooltip: 'Coming Soon!', featureFlag: FeatureFlags.HAR_PYTHON_PACKAGE_TYPE_ENABLED, disabled: true + }, + { + label: 'repositoryTypes.nuget', + value: UpstreamProxyPackageType.NUGET, + icon: 'nuget-repository-type', + tooltip: 'Coming Soon!', + featureFlag: FeatureFlags.HAR_NUGET_PACKAGE_TYPE_ENABLED, + disabled: true } ] diff --git a/web/src/ar/pages/repository-details/NuGetRepository/NuGetRepositoryType.tsx b/web/src/ar/pages/repository-details/NuGetRepository/NuGetRepositoryType.tsx new file mode 100644 index 000000000..be25a6993 --- /dev/null +++ b/web/src/ar/pages/repository-details/NuGetRepository/NuGetRepositoryType.tsx @@ -0,0 +1,130 @@ +/* + * Copyright 2024 Harness, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React from 'react' +import type { IconName } from '@harnessio/icons' + +import { RepositoryConfigType, RepositoryPackageType } from '@ar/common/types' +import UpstreamProxyActions from '@ar/pages/upstream-proxy-details/components/UpstreamProxyActions/UpstreamProxyActions' +import UpstreamProxyConfigurationForm from '@ar/pages/upstream-proxy-details/components/Forms/UpstreamProxyConfigurationForm' +import UpstreamProxyCreateFormContent from '@ar/pages/upstream-proxy-details/components/FormContent/UpstreamProxyCreateFormContent' +import UpstreamProxyDetailsHeader from '@ar/pages/upstream-proxy-details/components/UpstreamProxyDetailsHeader/UpstreamProxyDetailsHeader' +import { + type CreateRepositoryFormProps, + type RepositoryActionsProps, + type RepositoryConfigurationFormProps, + type RepositoryDetailsHeaderProps, + RepositoryStep, + type RepositoySetupClientProps +} from '@ar/frameworks/RepositoryStep/Repository' +import { + UpstreamProxyAuthenticationMode, + type UpstreamRegistryRequest, + UpstreamRepositoryURLInputSource +} from '@ar/pages/upstream-proxy-details/types' + +import type { Repository, VirtualRegistryRequest } from '../types' +import RepositoryActions from '../components/Actions/RepositoryActions' +import RedirectPageView from '../components/RedirectPageView/RedirectPageView' +import SetupClientContent from '../components/SetupClientContent/SetupClientContent' +import RepositoryConfigurationForm from '../components/Forms/RepositoryConfigurationForm' +import RepositoryCreateFormContent from '../components/FormContent/RepositoryCreateFormContent' +import RepositoryDetailsHeader from '../components/RepositoryDetailsHeader/RepositoryDetailsHeader' + +export class NuGetRepositoryType extends RepositoryStep { + protected packageType = RepositoryPackageType.NUGET + protected repositoryName = 'NuGet Repository' + protected repositoryIcon: IconName = 'nuget-repository-type' + protected supportedScanners = [] + protected supportsUpstreamProxy = true + protected supportedUpstreamURLSources = [ + UpstreamRepositoryURLInputSource.NuGetorg, + UpstreamRepositoryURLInputSource.Custom + ] + + protected defaultValues: VirtualRegistryRequest = { + packageType: RepositoryPackageType.NUGET, + identifier: '', + config: { + type: RepositoryConfigType.VIRTUAL + }, + scanners: [] + } + + protected defaultUpstreamProxyValues: UpstreamRegistryRequest = { + packageType: RepositoryPackageType.NUGET, + identifier: '', + config: { + type: RepositoryConfigType.UPSTREAM, + source: UpstreamRepositoryURLInputSource.NuGetorg, + authType: UpstreamProxyAuthenticationMode.ANONYMOUS, + url: '' + }, + cleanupPolicy: [], + scanners: [] + } + + renderCreateForm(props: CreateRepositoryFormProps): JSX.Element { + const { type } = props + if (type === RepositoryConfigType.VIRTUAL) { + return + } else { + return + } + } + + renderCofigurationForm(props: RepositoryConfigurationFormProps): JSX.Element { + const { type } = props + if (type === RepositoryConfigType.VIRTUAL) { + return + } else { + return + } + } + + renderActions(props: RepositoryActionsProps): JSX.Element { + if (props.type === RepositoryConfigType.VIRTUAL) { + return + } + return + } + + renderSetupClient(props: RepositoySetupClientProps): JSX.Element { + const { repoKey, onClose, artifactKey, versionKey } = props + return ( + + ) + } + + renderRepositoryDetailsHeader(props: RepositoryDetailsHeaderProps): JSX.Element { + const { type } = props + if (type === RepositoryConfigType.VIRTUAL) { + return + } else { + return + } + } + + renderRedirectPage(): JSX.Element { + return + } +} diff --git a/web/src/ar/pages/repository-details/RepositoryFactory.tsx b/web/src/ar/pages/repository-details/RepositoryFactory.tsx index 5c045c611..7902b7ac2 100644 --- a/web/src/ar/pages/repository-details/RepositoryFactory.tsx +++ b/web/src/ar/pages/repository-details/RepositoryFactory.tsx @@ -21,6 +21,7 @@ import { HelmRepositoryType } from './HelmRepository/HelmRepositoryType' import { GenericRepositoryType } from './GenericRepository/GenericRepositoryType' import { NpmRepositoryType } from './NpmRepository/NpmRepositoryType' import { PythonRepositoryType } from './PythonRepository/PythonRepositoryType' +import { NuGetRepositoryType } from './NuGetRepository/NuGetRepositoryType' repositoryFactory.registerStep(new DockerRepositoryType()) repositoryFactory.registerStep(new HelmRepositoryType()) @@ -28,3 +29,4 @@ repositoryFactory.registerStep(new GenericRepositoryType()) repositoryFactory.registerStep(new MavenRepositoryType()) repositoryFactory.registerStep(new NpmRepositoryType()) repositoryFactory.registerStep(new PythonRepositoryType()) +repositoryFactory.registerStep(new NuGetRepositoryType()) diff --git a/web/src/ar/pages/upstream-proxy-details/components/AuthenticationFormInput/constants.tsx b/web/src/ar/pages/upstream-proxy-details/components/AuthenticationFormInput/constants.tsx index e1e842c1c..67a8c4d4c 100644 --- a/web/src/ar/pages/upstream-proxy-details/components/AuthenticationFormInput/constants.tsx +++ b/web/src/ar/pages/upstream-proxy-details/components/AuthenticationFormInput/constants.tsx @@ -66,5 +66,9 @@ export const URLSourceToSupportedAuthTypesMapping: Record< [UpstreamRepositoryURLInputSource.PyPi]: [ UpstreamProxyAuthenticationMode.USER_NAME_AND_PASSWORD, UpstreamProxyAuthenticationMode.ANONYMOUS + ], + [UpstreamRepositoryURLInputSource.NuGetorg]: [ + UpstreamProxyAuthenticationMode.USER_NAME_AND_PASSWORD, + UpstreamProxyAuthenticationMode.ANONYMOUS ] } diff --git a/web/src/ar/pages/upstream-proxy-details/components/RepositoryUrlInput/constants.ts b/web/src/ar/pages/upstream-proxy-details/components/RepositoryUrlInput/constants.ts index 3b7ccdd3b..020195fa9 100644 --- a/web/src/ar/pages/upstream-proxy-details/components/RepositoryUrlInput/constants.ts +++ b/web/src/ar/pages/upstream-proxy-details/components/RepositoryUrlInput/constants.ts @@ -45,5 +45,9 @@ export const UpstreamURLSourceConfig: Record