Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions src/components/CIPipelineN/CIPipeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ export default function CIPipeline({
sharedPlugins={sharedPlugins}
isJobView={isJobCard}
mandatoryPluginsMap={mandatoryPluginsMap}
isSecurityModuleInstalled={isSecurityModuleInstalled}
/>
</Route>
)}
Expand All @@ -782,6 +783,7 @@ export default function CIPipeline({
presetPlugins={presetPlugins}
sharedPlugins={sharedPlugins}
mandatoryPluginsMap={mandatoryPluginsMap}
isSecurityModuleInstalled={isSecurityModuleInstalled}
/>
</Route>
)}
Expand Down
51 changes: 28 additions & 23 deletions src/components/CIPipelineN/PluginCardListContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export function PluginCardListContainer({
pluginListTitle,
pluginList,
setPluginType,
isSecurityModuleInstalled
}: {
pluginListTitle: string
pluginList: PluginDetailType[]
Expand All @@ -17,36 +18,40 @@ export function PluginCardListContainer({
inputVariables: VariableType[],
outputVariables: VariableType[],
) => void
isSecurityModuleInstalled: boolean
}) {
return (
pluginList.length > 0 && (
<div className="plugin-container">
<div data-testid="preset-plugin-heading" className="cn-5 fw-6 fs-13 mt-20 mb-8">
{pluginListTitle}
</div>
{pluginList.map((pluginDetails) => (
<div
key={pluginDetails.id}
onClick={() =>
setPluginType(
PluginType.PLUGIN_REF,
pluginDetails.id,
pluginDetails.name,
pluginDetails.description,
pluginDetails.inputVariables ?? [],
pluginDetails.outputVariables ?? [],
)
}
>
<PluginCard
dataTestId={`${pluginDetails.name}-button`}
imgSource={pluginDetails.icon}
title={pluginDetails.name}
subTitle={pluginDetails.description}
tags={pluginDetails.tags}
/>
</div>
))}
{pluginList.map(
(pluginDetails) =>
(pluginDetails.name !== 'Image Scanning' || isSecurityModuleInstalled) && (
<div
key={pluginDetails.id}
onClick={() =>
setPluginType(
PluginType.PLUGIN_REF,
pluginDetails.id,
pluginDetails.name,
pluginDetails.description,
pluginDetails.inputVariables ?? [],
pluginDetails.outputVariables ?? [],
)
}
>
<PluginCard
dataTestId={`${pluginDetails.name}-button`}
imgSource={pluginDetails.icon}
title={pluginDetails.name}
subTitle={pluginDetails.description}
tags={pluginDetails.tags}
/>
</div>
),
)}
</div>
)
)
Expand Down
4 changes: 3 additions & 1 deletion src/components/CIPipelineN/PreBuild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { importComponentFromFELibrary } from '../common'
import { pipelineContext } from '../workflowEditor/workflowEditor'

const isRequired = importComponentFromFELibrary('isRequired', null, 'function')
export function PreBuild({ presetPlugins, sharedPlugins, mandatoryPluginsMap, isJobView }: PreBuildType) {
export function PreBuild({ presetPlugins, sharedPlugins, mandatoryPluginsMap, isJobView, isSecurityModuleInstalled}: PreBuildType) {
const {
formData,
isCdPipeline,
Expand Down Expand Up @@ -151,11 +151,13 @@ export function PreBuild({ presetPlugins, sharedPlugins, mandatoryPluginsMap, is
setPluginType={setPluginType}
pluginListTitle="PRESET PLUGINS"
pluginList={presetPlugins}
isSecurityModuleInstalled={isSecurityModuleInstalled}
/>
<PluginCardListContainer
setPluginType={setPluginType}
pluginListTitle="SHARED PLUGINS"
pluginList={sharedPlugins}
isSecurityModuleInstalled={isSecurityModuleInstalled}
/>
</>
)
Expand Down
20 changes: 17 additions & 3 deletions src/components/cdPipeline/NewCDPipeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import React, { useEffect, useMemo, useRef, useState } from 'react'
import { ReactComponent as Close } from '../../assets/icons/ic-close.svg'
import { NavLink, Redirect, Route, Switch, useParams, useRouteMatch } from 'react-router-dom'
import { CDDeploymentTabText, DELETE_ACTION, SourceTypeMap, TriggerType, ViewType } from '../../config'
import { CDDeploymentTabText, DELETE_ACTION, ModuleNameMap, SourceTypeMap, TriggerType, ViewType } from '../../config'
import { ButtonWithLoader, FloatingVariablesSuggestions, sortObjectArrayAlphabetically } from '../common'
import BuildCD from './BuildCD'
import { CD_PATCH_ACTION, Environment, GeneratedHelmPush } from './cdPipeline.types'
Expand Down Expand Up @@ -52,6 +52,8 @@ import { calculateLastStepDetailsLogic, checkUniqueness, validateTask } from './
import { pipelineContext } from '../workflowEditor/workflowEditor'
import { PipelineFormDataErrorType, PipelineFormType } from '../workflowEditor/types'
import { getDockerRegistryMinAuth } from '../ciConfig/service'
import { getModuleInfo } from '../v2/devtronStackManager/DevtronStackManager.service'
import { ModuleStatus } from '../v2/devtronStackManager/DevtronStackManager.type'

export enum deleteDialogType {
showForceDeleteDialog = 'showForceDeleteDialog',
Expand Down Expand Up @@ -176,6 +178,8 @@ export default function NewCDPipeline({
preBuildStage: Map<string, VariableType>[]
postBuildStage: Map<string, VariableType>[]
}>({ preBuildStage: [], postBuildStage: [] })
const [isSecurityModuleInstalled, setSecurityModuleInstalled] = useState<boolean>(false)


useEffect(() => {
getInit()
Expand All @@ -195,6 +199,7 @@ export default function NewCDPipeline({
}

const getInit = () => {
getSecurityModuleStatus()
Promise.all([
getDeploymentStrategyList(appId),
getGlobalVariable(Number(appId), true),
Expand Down Expand Up @@ -276,6 +281,15 @@ export default function NewCDPipeline({
})
}

const getSecurityModuleStatus = async (): Promise<void> => {
try {
const { result } = await getModuleInfo(ModuleNameMap.SECURITY)
if (result?.status === ModuleStatus.INSTALLED) {
setSecurityModuleInstalled(true)
}
} catch (error) {}
}

const calculateLastStepDetail = (
isFromAddNewTask: boolean,
_formData: PipelineFormType,
Expand Down Expand Up @@ -1028,12 +1042,12 @@ export default function NewCDPipeline({
<Switch>
{isAdvanced && (
<Route path={`${path}/pre-build`}>
<PreBuild presetPlugins={presetPlugins} sharedPlugins={sharedPlugins} />
<PreBuild presetPlugins={presetPlugins} sharedPlugins={sharedPlugins} isSecurityModuleInstalled={isSecurityModuleInstalled} />
</Route>
)}
{isAdvanced && (
<Route path={`${path}/post-build`}>
<PreBuild presetPlugins={presetPlugins} sharedPlugins={sharedPlugins} />
<PreBuild presetPlugins={presetPlugins} sharedPlugins={sharedPlugins} isSecurityModuleInstalled={isSecurityModuleInstalled} />
</Route>
)}
<Route path={`${path}/build`}>
Expand Down
1 change: 1 addition & 0 deletions src/components/ciPipeline/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ export interface PreBuildType {
sharedPlugins: PluginDetailType[]
mandatoryPluginsMap?: Record<number, MandatoryPluginDetailType>
isJobView?: boolean
isSecurityModuleInstalled?: boolean
}

export enum CIPipelineBuildType {
Expand Down