Skip to content

Commit c9a287d

Browse files
authored
feat: Add wait for trigger to release pipelines (#5523)
1 parent 7cb3758 commit c9a287d

File tree

13 files changed

+383
-248
lines changed

13 files changed

+383
-248
lines changed

frontend/common/services/useReleasePipelines.ts

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,19 @@ export const releasePipelinesService = service
77
.enhanceEndpoints({ addTagTypes: ['ReleasePipelines'] })
88
.injectEndpoints({
99
endpoints: (builder) => ({
10-
createPipelineStages: builder.mutation<
11-
Res['pipelineStage'],
12-
Req['createPipelineStage']
13-
>({
14-
invalidatesTags: [{ id: 'LIST', type: 'ReleasePipelines' }],
15-
query: (query: Req['createPipelineStage']) => ({
16-
body: {
17-
actions: query.actions,
18-
environment: query.environment,
19-
name: query.name,
20-
order: query.order,
21-
trigger: query.trigger,
22-
},
23-
method: 'POST',
24-
url: `projects/${query.project}/release-pipelines/${query.pipeline}/stages/`,
25-
}),
26-
}),
2710
createReleasePipeline: builder.mutation<
2811
Res['releasePipeline'],
2912
Req['createReleasePipeline']
3013
>({
3114
invalidatesTags: [{ id: 'LIST', type: 'ReleasePipelines' }],
3215
query: (query: Req['createReleasePipeline']) => ({
33-
body: { name: query.name },
16+
body: {
17+
description: query.description,
18+
name: query.name,
19+
stages: query.stages,
20+
},
3421
method: 'POST',
35-
url: `projects/${query.projectId}/release-pipelines/`,
22+
url: `projects/${query.project}/release-pipelines/`,
3623
}),
3724
}),
3825
deleteReleasePipeline: builder.mutation<{}, Req['deleteReleasePipeline']>(
@@ -131,25 +118,9 @@ export async function getPipelineStages(
131118
)
132119
}
133120

134-
export async function createPipelineStages(
135-
store: any,
136-
data: Req['createPipelineStage'],
137-
options?: Parameters<
138-
typeof releasePipelinesService.endpoints.createPipelineStages.initiate
139-
>[1],
140-
) {
141-
return store.dispatch(
142-
releasePipelinesService.endpoints.createPipelineStages.initiate(
143-
data,
144-
options,
145-
),
146-
)
147-
}
148-
149121
// END OF FUNCTION_EXPORTS
150122

151123
export const {
152-
useCreatePipelineStagesMutation,
153124
useCreateReleasePipelineMutation,
154125
useDeleteReleasePipelineMutation,
155126
useGetPipelineStageQuery,

frontend/common/types/requests.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,16 @@ export interface StageActionRequest {
7878
action_body: { enabled: boolean; segment_id?: number }
7979
}
8080

81+
export type ReleasePipelineRequest = {
82+
project: number
83+
name: string
84+
description?: string
85+
stages: PipelineStageRequest[]
86+
}
87+
8188
export type PipelineStageRequest = {
8289
name: string
83-
project: number
8490
environment: number
85-
pipeline: number
8691
order: number
8792
trigger: StageTrigger
8893
actions: StageActionRequest[]
@@ -698,11 +703,7 @@ export type Req = {
698703
updateOnboarding: Partial<Onboarding>
699704
getReleasePipelines: PagedRequest<{ projectId: number }>
700705
getReleasePipeline: { projectId: number; pipelineId: number }
701-
createReleasePipeline: {
702-
projectId: number
703-
name: string
704-
status: PipelineStatus
705-
}
706+
createReleasePipeline: ReleasePipelineRequest
706707
getPipelineStages: PagedRequest<{
707708
projectId: number
708709
pipelineId: number
@@ -712,7 +713,6 @@ export type Req = {
712713
pipelineId: number
713714
stageId: number
714715
}
715-
createPipelineStage: PipelineStageRequest
716716
deleteReleasePipeline: {
717717
projectId: number
718718
pipelineId: number

frontend/common/types/responses.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
2-
3-
import { StageActionRequest } from './requests'
4-
51
export type EdgePagedResponse<T> = PagedResponse<T> & {
62
last_evaluated_key?: string
73
pages?: (string | undefined)[]
@@ -817,21 +813,28 @@ export enum PipelineStatus {
817813
ACTIVE = 'ACTIVE',
818814
}
819815

820-
export type ReleasePipeline = {
816+
export interface ReleasePipeline {
821817
id: number
822-
status: PipelineStatus
823-
stages_count: number
824-
flags_count: number
825818
name: string
826819
project: number
820+
description: string
821+
stages_count: number
822+
published_at: string
823+
published_by: number
824+
features_count: number
825+
}
826+
827+
export interface SingleReleasePipeline extends ReleasePipeline {
828+
stages: PipelineStage[]
829+
completed_features: number[]
827830
}
828831

829832
export enum StageTriggerType {
830833
ON_ENTER = 'ON_ENTER',
831834
WAIT_FOR = 'WAIT_FOR',
832835
}
833836

834-
export type StageTriggerBody = string | null
837+
export type StageTriggerBody = { wait_for?: string } | null
835838

836839
export type StageTrigger = {
837840
trigger_type: StageTriggerType
@@ -842,20 +845,23 @@ export enum StageActionType {
842845
TOGGLE_FEATURE = 'TOGGLE_FEATURE',
843846
TOGGLE_FEATURE_FOR_SEGMENT = 'TOGGLE_FEATURE_FOR_SEGMENT',
844847
}
845-
// TODO: Check if this is correct
846-
export interface StageActionResponse
847-
extends Omit<StageActionRequest, 'action_body'> {
848-
action_body: string
848+
849+
export type StageActionBody = { enabled: boolean; segment_id?: number }
850+
export interface StageAction {
851+
id: number
852+
action_type: StageActionType
853+
action_body: StageActionBody
849854
}
850855

851-
export interface PipelineStage {
856+
export type PipelineStage = {
852857
id: number
853858
name: string
854859
pipeline: number
855860
environment: number
856861
order: number
857862
trigger: StageTrigger
858-
actions: StageActionResponse[]
863+
actions: StageAction[]
864+
features: number[]
859865
}
860866

861867
export type Res = {
@@ -1008,7 +1014,7 @@ export type Res = {
10081014
onboarding: {}
10091015
userPermissions: UserPermissions
10101016
releasePipelines: PagedResponse<ReleasePipeline>
1011-
releasePipeline: ReleasePipeline
1017+
releasePipeline: SingleReleasePipeline
10121018
pipelineStages: PagedResponse<PipelineStage>
10131019
pipelineStage: PipelineStage
10141020
// END OF TYPES
Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
import CreateReleasePipeline from 'components/release-pipelines/CreateReleasePipeline'
22

3-
type CreateReleasePipelinePageType = {
4-
match: {
5-
params: {
6-
projectId: string
7-
}
8-
}
9-
}
10-
11-
export default function CreateReleasePipelinePage({
12-
match,
13-
}: CreateReleasePipelinePageType) {
14-
const { projectId } = match.params
15-
return <CreateReleasePipeline projectId={projectId} />
3+
export default function CreateReleasePipelinePage() {
4+
return <CreateReleasePipeline />
165
}
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
import ReleasePipelineDetail from 'components/release-pipelines/ReleasePipelineDetail'
22

3-
type ReleasePipelineDetailPageType = {
4-
match: {
5-
params: {
6-
projectId: string
7-
id: string
8-
}
9-
}
10-
}
11-
12-
export default function ReleasePipelineDetailPage({
13-
match,
14-
}: ReleasePipelineDetailPageType) {
15-
const { projectId } = match.params
16-
return <ReleasePipelineDetail projectId={projectId} id={match.params.id} />
3+
export default function ReleasePipelineDetailPage() {
4+
return <ReleasePipelineDetail />
175
}

0 commit comments

Comments
 (0)