Skip to content

Commit 3a45dd9

Browse files
Merge pull request #1329 from devtron-labs/env_filter_build_deploy_build_history
feat: Env filter build deploy build history
2 parents 32e3177 + 496a9a1 commit 3a45dd9

File tree

12 files changed

+57
-23
lines changed

12 files changed

+57
-23
lines changed

src/components/app/details/appConfig/AppComposeRouter.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export default function AppComposeRouter({
5959
isBaseConfigProtected,
6060
reloadEnvironments,
6161
configProtectionData,
62+
filteredEnvIds
6263
}: AppComposeRouterProps) {
6364
const { path } = useRouteMatch()
6465
const renderJobViewRoutes = (): JSX.Element => {
@@ -190,6 +191,7 @@ export default function AppComposeRouter({
190191
isCDPipeline={isCDPipeline}
191192
respondOnSuccess={respondOnSuccess}
192193
getWorkflows={getWorkflows}
194+
filteredEnvIds={filteredEnvIds}
193195
/>
194196
)}
195197
/>,

src/components/app/details/appConfig/AppConfig.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default function AppConfig({ appName, isJobView, filteredEnvIds }: AppCon
8989
useEffect(() => {
9090
Promise.all([
9191
getAppConfigStatus(+appId, isJobView),
92-
getWorkflowList(appId),
92+
getWorkflowList(appId, filteredEnvIds),
9393
getAppOtherEnvironmentMin(appId),
9494
typeof getConfigProtections === 'function' && !isJobView
9595
? getConfigProtections(Number(appId))
@@ -421,6 +421,7 @@ export default function AppConfig({ appName, isJobView, filteredEnvIds }: AppCon
421421
isBaseConfigProtected={state.isBaseConfigProtected}
422422
reloadEnvironments={reloadEnvironments}
423423
configProtectionData={state.configProtectionData}
424+
filteredEnvIds={filteredEnvIds}
424425
/>
425426
</div>
426427
</div>

src/components/app/details/appConfig/appConfig.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export interface AppComposeRouterProps {
9595
isBaseConfigProtected?: boolean
9696
reloadEnvironments:()=> void
9797
configProtectionData: any[]
98+
filteredEnvIds?: string
9899
}
99100

100101
export interface EnvironmentOverridesProps {

src/components/app/details/cIDetails/CIDetails.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { ScannedByToolModal } from '../../../common/security/ScannedByToolModal'
2626
const terminalStatus = new Set(['succeeded', 'failed', 'error', 'cancelled', 'nottriggered', 'notbuilt'])
2727
let statusSet = new Set(['starting', 'running', 'pending'])
2828

29-
export default function CIDetails({ isJobView }: { isJobView?: boolean }) {
29+
export default function CIDetails({ isJobView, filteredEnvIds }: { isJobView?: boolean, filteredEnvIds?: string }) {
3030
const { appId, pipelineId, buildId } = useParams<{
3131
appId: string
3232
pipelineId: string
@@ -45,11 +45,11 @@ export default function CIDetails({ isJobView }: { isJobView?: boolean }) {
4545
const [initDataLoading, initDataResults] = useAsync(
4646
() =>
4747
Promise.allSettled([
48-
getCIPipelines(+appId),
48+
getCIPipelines(+appId, filteredEnvIds),
4949
getModuleInfo(ModuleNameMap.SECURITY),
5050
getModuleConfigured(ModuleNameMap.BLOB_STORAGE),
5151
]),
52-
[appId],
52+
[appId, filteredEnvIds],
5353
)
5454
const [loading, triggerHistoryResult, , , , dependencyState] = useAsync(
5555
() => getTriggerHistory(+pipelineId, pagination),
@@ -152,7 +152,8 @@ export default function CIDetails({ isJobView }: { isJobView?: boolean }) {
152152
const pipelines: CIPipeline[] = (initDataResults[0]?.['value']?.['result'] || [])?.filter(
153153
(pipeline) => pipeline.pipelineType !== 'EXTERNAL',
154154
) // external pipelines not visible in dropdown
155-
if (pipelines.length === 1 && !pipelineId) {
155+
const selectedPipelineExist = !pipelineId || pipelines.find((pipeline) => pipeline.id === +pipelineId)
156+
if ((pipelines.length === 1 && !pipelineId) || (!selectedPipelineExist)) {
156157
replace(generatePath(path, { appId, pipelineId: pipelines[0].id }))
157158
}
158159
const pipelineOptions: CICDSidebarFilterOptionType[] = (pipelines || []).map((item) => {

src/components/app/details/main.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ export default function AppDetailsPage({ isV2 }: AppDetailsProps) {
217217
<Route path={`${path}/${URLS.APP_OVERVIEW}`}>
218218
<Overview appMetaInfo={appMetaInfo} getAppMetaInfoRes={getAppMetaInfoRes} filteredEnvIds={_filteredEnvIds} />
219219
</Route>
220-
<Route path={`${path}/${URLS.APP_TRIGGER}`} render={(props) => <TriggerView />} />
220+
<Route path={`${path}/${URLS.APP_TRIGGER}`} render={(props) => <TriggerView filteredEnvIds={_filteredEnvIds}/>} />
221221
<Route path={`${path}/${URLS.APP_CI_DETAILS}/:pipelineId(\\d+)?/:buildId(\\d+)?`}>
222-
<CIDetails key={appId} />
222+
<CIDetails key={appId} filteredEnvIds={_filteredEnvIds} />
223223
</Route>
224224
<Route
225225
path={`${path}/${URLS.APP_DEPLOYMENT_METRICS}/:envId(\\d+)?`}

src/components/app/details/triggerView/TriggerView.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class TriggerView extends Component<TriggerViewProps, TriggerViewState> {
161161
}
162162

163163
getWorkflows = (isFromOnMount?: boolean) => {
164-
getTriggerWorkflows(this.props.match.params.appId, !this.props.isJobView, this.props.isJobView)
164+
getTriggerWorkflows(this.props.match.params.appId, !this.props.isJobView, this.props.isJobView, this.props.filteredEnvIds)
165165
.then((result) => {
166166
const _filteredCIPipelines = result.filteredCIPipelines || []
167167
const wf = result.workflows || []
@@ -214,7 +214,10 @@ class TriggerView extends Component<TriggerViewProps, TriggerViewState> {
214214
}
215215

216216
componentDidUpdate(prevProps) {
217-
if (this.props.match.params.appId !== prevProps.match.params.appId) {
217+
if (
218+
this.props.match.params.appId !== prevProps.match.params.appId ||
219+
prevProps.filteredEnvIds !== this.props.filteredEnvIds
220+
) {
218221
this.setState({
219222
showCIModal: false,
220223
showMaterialRegexModal: false,

src/components/app/details/triggerView/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ export interface TriggerViewProps extends RouteComponentProps<{
287287
envId: string
288288
}> {
289289
isJobView?: boolean
290+
filteredEnvIds?: string
290291
}
291292

292293
export interface WorkflowType {
@@ -544,7 +545,7 @@ export interface CDStageConfigMapSecretNames {
544545
secrets: any[]
545546
}
546547

547-
export interface PrePostDeployStageType {
548+
export interface PrePostDeployStageType {
548549
isValid: boolean;
549550
steps: TaskErrorObj[];
550551
triggerType: string

src/components/app/details/triggerView/workflow.service.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,17 @@ export const getTriggerWorkflows = (
2222
appId,
2323
useAppWfViewAPI: boolean,
2424
isJobView: boolean,
25+
filteredEnvIds?: string
2526
): Promise<{ appName: string; workflows: WorkflowType[]; filteredCIPipelines }> => {
26-
return getInitialWorkflows(appId, WorkflowTrigger, WorkflowTrigger.workflow, useAppWfViewAPI, isJobView)
27+
return getInitialWorkflows(appId, WorkflowTrigger, WorkflowTrigger.workflow, useAppWfViewAPI, isJobView, filteredEnvIds)
2728
}
2829

2930
export const getCreateWorkflows = (
3031
appId,
3132
isJobView: boolean,
33+
filteredEnvIds?: string
3234
): Promise<{ appName: string; workflows: WorkflowType[], filteredCIPipelines }> => {
33-
return getInitialWorkflows(appId, WorkflowCreate, WorkflowCreate.workflow, false, isJobView)
35+
return getInitialWorkflows(appId, WorkflowCreate, WorkflowCreate.workflow, false, isJobView, filteredEnvIds)
3436
}
3537

3638
const getInitialWorkflows = (
@@ -39,9 +41,10 @@ const getInitialWorkflows = (
3941
workflowOffset: Offset,
4042
useAppWfViewAPI?: boolean,
4143
isJobView?: boolean,
44+
filteredEnvIds?: string
4245
): Promise<{ appName: string; workflows: WorkflowType[]; filteredCIPipelines }> => {
4346
if (useAppWfViewAPI) {
44-
return getWorkflowViewList(id).then((response) => {
47+
return getWorkflowViewList(id, filteredEnvIds).then((response) => {
4548
const workflows = {
4649
appId: id,
4750
workflows: response.result?.workflows as Workflow[],
@@ -74,7 +77,7 @@ const getInitialWorkflows = (
7477
)
7578
})
7679
} else {
77-
return Promise.all([getWorkflowList(id), getCIConfig(id), getCDConfig(id), getExternalCIList(id)]).then(
80+
return Promise.all([getWorkflowList(id, filteredEnvIds), getCIConfig(id), getCDConfig(id), getExternalCIList(id)]).then(
7881
([workflow, ciConfig, cdConfig, externalCIConfig]) => {
7982
return processWorkflow(
8083
workflow.result as WorkflowResult,

src/components/app/service.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,13 @@ export const getWorkflowStatus = (appId: string) => {
496496
return get(URL)
497497
}
498498

499-
export const getCIPipelines = (appId) => {
500-
let URL = `${Routes.APP}/${appId}/${Routes.APP_CI_PIPELINE}`
501-
return get(URL)
499+
export const getCIPipelines = (appId, filteredEnvIds?: string) => {
500+
let filteredEnvParams = ''
501+
if (filteredEnvIds) {
502+
filteredEnvParams = `?envIds=${filteredEnvIds}`
503+
}
504+
const URL = `${Routes.APP}/${appId}/${Routes.APP_CI_PIPELINE}${filteredEnvParams}`
505+
return get(URL)
502506
}
503507

504508
export function refreshGitMaterial(gitMaterialId: string, abortSignal: AbortSignal) {

src/components/workflowEditor/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface WorkflowEditProps
4343
isJobView?: boolean
4444
envList?: any[]
4545
ciPipelines?: any[]
46+
filteredEnvIds?: string
4647
}
4748

4849
export interface AddWorkflowState {
@@ -191,6 +192,6 @@ export interface PipelineContext {
191192
getPrePostStageInEnv?: (isVirtualEnvironment: boolean, isRunPrePostStageInEnv: boolean) => boolean
192193
isVirtualEnvironment?: boolean
193194
globalVariables: {
194-
stageType?: string, label: string; value: string; format: string; description?: string; variableType?: string
195+
stageType?: string, label: string; value: string; format: string; description?: string; variableType?: string
195196
}[]
196197
}

0 commit comments

Comments
 (0)