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

feat: plugin policy v2 #2174

Merged
merged 11 commits into from
Nov 15, 2024
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"homepage": "/dashboard",
"dependencies": {
"@devtron-labs/devtron-fe-common-lib": "1.0.4",
"@devtron-labs/devtron-fe-common-lib": "1.0.5",
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
"@rjsf/core": "^5.13.3",
"@rjsf/utils": "^5.13.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ const BulkCITrigger = ({
}
}

return () => getCIBlockState(appDetails.ciPipelineId, appDetails.appId, branchNames, appDetails.name)
return !branchNames
? () => null
: () => getCIBlockState(appDetails.ciPipelineId, appDetails.appId, branchNames, appDetails.name)
})

if (policyPromiseFunctionList?.length) {
Expand Down
5 changes: 3 additions & 2 deletions src/components/CIPipelineN/CIPipeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,16 @@ export default function CIPipeline({
}
}

const areMandatoryPluginPossible = !isJobCard && !!processPluginData
// mandatory plugins are applicable for job ci but not jobs
const areMandatoryPluginPossible = !isJobView && !!processPluginData

// NOTE: Wrap this method in try catch block to handle error
const getMandatoryPluginData = async (
_formData: PipelineFormType,
/**
* ids required to fetch in case we have a plugin in step
*/
requiredPluginIds?: PluginDetailPayloadType['pluginId'],
requiredPluginIds?: PluginDetailPayloadType['pluginIds'],
): Promise<void> => {
if (areMandatoryPluginPossible) {
let branchName = ''
Expand Down
3 changes: 2 additions & 1 deletion src/components/CIPipelineN/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export const Sidebar = ({
const showMandatoryWarning = (): boolean => {
return (
!!MandatoryPluginWarning &&
!isJobCard &&
// mandatory plugins are applicable for Job CI but not Jobs
!isJobView &&
mandatoryPluginData &&
((isPreBuildTab && !mandatoryPluginData.isValidPre) ||
(activeStageName === BuildStageVariable.PostBuild && !mandatoryPluginData.isValidPost))
Expand Down
3 changes: 2 additions & 1 deletion src/components/app/details/triggerView/TriggerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
ToastVariantType,
TOAST_ACCESS_DENIED,
BlockedStateData,
getEnvironmentListMinPublic,
} from '@devtron-labs/devtron-fe-common-lib'
import ReactGA from 'react-ga4'
import { withRouter, NavLink, Route, Switch } from 'react-router-dom'
Expand Down Expand Up @@ -65,7 +66,7 @@ import {
NO_COMMIT_SELECTED,
} from '../../../../config'
import { AppNotConfigured } from '../appDetails/AppDetails'
import { getEnvironmentListMinPublic, getHostURLConfiguration } from '../../../../services/service'
import { getHostURLConfiguration } from '../../../../services/service'
import { ReactComponent as ICError } from '../../../../assets/icons/ic-error-exclamation.svg'
import { ReactComponent as CloseIcon } from '../../../../assets/icons/ic-close.svg'
import { getCIWebhookRes } from './ciWebhook.service'
Expand Down
14 changes: 12 additions & 2 deletions src/components/app/details/triggerView/ciMaterial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class CIMaterial extends Component<CIMaterialProps, CIMaterialState> {
showTriggerButton
onTrigger={this.handleStartBuildAction}
nodeType={nodeType}
isJobView={this.props.isJobCI}
>
<ButtonWithLoader
rootClassName="cta-with-img cta-with-img--ci-trigger-btn"
Expand All @@ -238,8 +239,17 @@ class CIMaterial extends Component<CIMaterialProps, CIMaterialState> {
isLoading={this.props.isLoading}
onClick={noop}
>
<Play className="trigger-btn__icon" />
Start Build
{this.props.isJobCI ? (
<>
<RunIcon className="trigger-job-btn__icon" />
Run Job
</>
) : (
<>
<Play className="trigger-btn__icon" />
Start Build
</>
)}
</ButtonWithLoader>
</AllowedWithWarningTippy>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/cdPipeline/CDPipeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
ProcessPluginDataParamsType,
ProcessPluginDataReturnType,
ResourceKindType,
getEnvironmentListMinPublic,
} from '@devtron-labs/devtron-fe-common-lib'
import { useEffect, useMemo, useRef, useState } from 'react'
import { Redirect, Route, Switch, useParams, useRouteMatch } from 'react-router-dom'
Expand All @@ -71,7 +72,6 @@ import {
saveCDPipeline,
updateCDPipeline,
} from './cdPipeline.service'
import { getEnvironmentListMinPublic } from '../../services/service'
import { Sidebar } from '../CIPipelineN/Sidebar'
import DeleteCDNode from './DeleteCDNode'
import { PreBuild } from '../CIPipelineN/PreBuild'
Expand Down
4 changes: 2 additions & 2 deletions src/components/cdPipeline/cdPipeline.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

import { post, get, sortCallback } from '@devtron-labs/devtron-fe-common-lib'
import { post, get, sortCallback, getEnvironmentListMinPublic } from '@devtron-labs/devtron-fe-common-lib'
import { Routes, TriggerType } from '../../config'
import { getEnvironmentSecrets, getEnvironmentListMinPublic, getEnvironmentConfigs } from '../../services/service'
import { getEnvironmentSecrets, getEnvironmentConfigs } from '../../services/service'

export function getCDPipelineNameSuggestion(appId: string | number): Promise<any> {
const URL = `app/pipeline/suggest/cd/${appId}`
Expand Down
2 changes: 1 addition & 1 deletion src/components/cdPipeline/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ export interface BuildCDProps
releaseMode: ReleaseMode
getMandatoryPluginData: (
form: PipelineFormType,
requiredPluginIds?: PluginDetailPayloadType['pluginId'],
requiredPluginIds?: PluginDetailPayloadType['pluginIds'],
) => Promise<void>
}
6 changes: 5 additions & 1 deletion src/components/common/GitInfoMaterial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,11 @@ export default function GitInfoMaterial({
<>
{(!fromBulkCITrigger || showWebhookModal) && renderMaterialHeader()}
{MissingPluginBlockState && isCITriggerBlocked ? (
<MissingPluginBlockState configurePluginURL={getCIPipelineURL(appId, workflowId, true, pipelineId, false, isJobCI)} nodeType={nodeType} />
<MissingPluginBlockState
configurePluginURL={getCIPipelineURL(appId, workflowId, true, pipelineId, false, isJobCI)}
nodeType={nodeType}
isJobView={isJobCI}
/>
) : (
<div className={`m-lr-0 ${showWebhookModal || fromBulkCITrigger ? '' : 'flexbox'}`}>
{showWebhookModal == true ? (
Expand Down
10 changes: 8 additions & 2 deletions src/components/security/SecurityPolicyEnvironment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@

import React, { Component } from 'react'
import { RouteComponentProps, NavLink } from 'react-router-dom'
import { showError, Progressing, sortCallback, Reload, SearchBar } from '@devtron-labs/devtron-fe-common-lib'
import {
showError,
Progressing,
sortCallback,
Reload,
SearchBar,
getEnvironmentListMinPublic,
} from '@devtron-labs/devtron-fe-common-lib'
import { SecurityPolicyEdit } from './SecurityPolicyEdit'
import { getEnvironmentListMinPublic } from '../../services/service'
import { ViewType } from '../../config'
import { SecurityPolicyEnvironmentState } from './security.types'

Expand Down
9 changes: 0 additions & 9 deletions src/services/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,6 @@ export const getAppFilters = (): Promise<ResponseType<ClusterEnvTeams>> =>
},
}))

/**
* @deprecated Use getEnvironmentListMinPublic form common lib instead
*/
export function getEnvironmentListMinPublic(includeAllowedDeploymentTypes?: boolean) {
return get(
`${Routes.ENVIRONMENT_LIST_MIN}?auth=false${includeAllowedDeploymentTypes ? '&showDeploymentOptions=true' : ''}`,
)
}

export function getDockerRegistryStatus(isStorageActionPush?: boolean): Promise<ResponseType> {
const URL = `${Routes.DOCKER_REGISTRY_CONFIG}/configure/status${isStorageActionPush ? '?storageType=CHART&storageAction=PUSH' : ''}`
return get(URL)
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -974,10 +974,10 @@
dependencies:
"@jridgewell/trace-mapping" "0.3.9"

"@devtron-labs/[email protected].4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-1.0.4.tgz#0fdb512afe4567ca5424d28718b638bed2e687d0"
integrity sha512-3wNFvPJUAYwpNnamXoaMqFKsxbphJbZiUIsxL5ErLHxqP0+cPF1NC5PShZBxGMr5IBnzZBhj5TM6aMI9Jswp9A==
"@devtron-labs/[email protected].5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-1.0.5.tgz#0da88fc1b5db524388018ca1c4f7cefd46612c4f"
integrity sha512-bYvOBj/lckFS+8sC25x1ue5/68rQEW4nQzXZZMKluMYmTXQQRAUnM/2M4vWddmk0WradA+3AkW4KjnxHXsnfQQ==
dependencies:
"@types/react-dates" "^21.8.6"
ansi_up "^5.2.1"
Expand Down
Loading