mirror of
https://github.com/harness/drone.git
synced 2025-05-06 11:01:20 +08:00
feat: [CODE-2467]: add pullreq_label_assigned as a webhook trigger event (#2945)
* fix: [code-2505] lint checks * feat: [code-2467] add pullreq_label_assigned as a webhook trigger event
This commit is contained in:
parent
7704d86db1
commit
aa7bb45eb9
@ -1185,6 +1185,7 @@ export interface StringsMap {
|
||||
webhookPRClosed: string
|
||||
webhookPRCommentCreated: string
|
||||
webhookPRCreated: string
|
||||
webhookPRLabelAssigned: string
|
||||
webhookPRMerged: string
|
||||
webhookPRReopened: string
|
||||
webhookPRUpdated: string
|
||||
|
@ -432,6 +432,7 @@ webhookPRReopened: PR reopened
|
||||
webhookPRClosed: PR closed
|
||||
webhookPRCommentCreated: PR comment created
|
||||
webhookPRMerged: PR merged
|
||||
webhookPRLabelAssigned: PR label assigned
|
||||
nameYourWebhook: Name your webhook
|
||||
noExecutionsFound: No Executions found
|
||||
noExecutionsFoundForWebhook: No executions found for the given webhook
|
||||
|
@ -63,6 +63,7 @@ interface FormData {
|
||||
prClosed: boolean
|
||||
prCommentCreated: boolean
|
||||
prMerged: boolean
|
||||
prLabelAssigned: boolean
|
||||
}
|
||||
|
||||
interface WebHookFormProps extends Pick<GitInfoProps, 'repoMetadata'> {
|
||||
@ -115,6 +116,7 @@ export function WehookForm({ repoMetadata, isEdit, webhook }: WebHookFormProps)
|
||||
prClosed: webhook?.triggers?.includes(WebhookIndividualEvent.PR_CLOSED) || false,
|
||||
prCommentCreated: webhook?.triggers?.includes(WebhookIndividualEvent.PR_COMMENT_CREATED) || false,
|
||||
prMerged: webhook?.triggers?.includes(WebhookIndividualEvent.PR_MERGED) || false,
|
||||
prLabelAssigned: webhook?.triggers?.includes(WebhookIndividualEvent.PR_LABEL_ASSIGNED) || false,
|
||||
events: (webhook?.triggers?.length || 0) > 0 ? WebhookEventType.INDIVIDUAL : WebhookEventType.ALL
|
||||
}}
|
||||
formName="create-webhook-form"
|
||||
@ -170,6 +172,9 @@ export function WehookForm({ repoMetadata, isEdit, webhook }: WebHookFormProps)
|
||||
if (formData.prMerged) {
|
||||
triggers.push(WebhookIndividualEvent.PR_MERGED)
|
||||
}
|
||||
if (formData.prLabelAssigned) {
|
||||
triggers.push(WebhookIndividualEvent.PR_LABEL_ASSIGNED)
|
||||
}
|
||||
if (!triggers.length) {
|
||||
return showError(getString('oneMustBeSelected'))
|
||||
}
|
||||
@ -318,6 +323,11 @@ export function WehookForm({ repoMetadata, isEdit, webhook }: WebHookFormProps)
|
||||
name="prMerged"
|
||||
className={css.checkbox}
|
||||
/>
|
||||
<FormInput.CheckBox
|
||||
label={getString('webhookPRLabelAssigned')}
|
||||
name="prLabelAssigned"
|
||||
className={css.checkbox}
|
||||
/>
|
||||
</section>
|
||||
</article>
|
||||
) : null}
|
||||
|
@ -610,7 +610,8 @@ export enum WebhookIndividualEvent {
|
||||
PR_BRANCH_UPDATED = 'pullreq_branch_updated',
|
||||
PR_CLOSED = 'pullreq_closed',
|
||||
PR_COMMENT_CREATED = 'pullreq_comment_created',
|
||||
PR_MERGED = 'pullreq_merged'
|
||||
PR_MERGED = 'pullreq_merged',
|
||||
PR_LABEL_ASSIGNED = 'pullreq_label_assigned'
|
||||
}
|
||||
|
||||
export enum WebhookEventMap {
|
||||
@ -626,7 +627,8 @@ export enum WebhookEventMap {
|
||||
PR_BRANCH_UPDATED = 'PR branch updated',
|
||||
PR_CLOSED = 'PR closed',
|
||||
PR_COMMENT_CREATED = 'PR comment created',
|
||||
PR_MERGED = 'PR merged'
|
||||
PR_MERGED = 'PR merged',
|
||||
PR_LABEL_ASSIGNED = 'PR label assigned'
|
||||
}
|
||||
|
||||
export const eventMapping: Record<WebhookIndividualEvent, WebhookEventMap> = {
|
||||
@ -642,7 +644,8 @@ export const eventMapping: Record<WebhookIndividualEvent, WebhookEventMap> = {
|
||||
[WebhookIndividualEvent.PR_BRANCH_UPDATED]: WebhookEventMap.PR_BRANCH_UPDATED,
|
||||
[WebhookIndividualEvent.PR_CLOSED]: WebhookEventMap.PR_CLOSED,
|
||||
[WebhookIndividualEvent.PR_COMMENT_CREATED]: WebhookEventMap.PR_COMMENT_CREATED,
|
||||
[WebhookIndividualEvent.PR_MERGED]: WebhookEventMap.PR_MERGED
|
||||
[WebhookIndividualEvent.PR_MERGED]: WebhookEventMap.PR_MERGED,
|
||||
[WebhookIndividualEvent.PR_LABEL_ASSIGNED]: WebhookEventMap.PR_LABEL_ASSIGNED
|
||||
}
|
||||
|
||||
export function getEventDescription(event: WebhookIndividualEvent): string {
|
||||
|
Loading…
Reference in New Issue
Block a user