mirror of
https://github.com/harness/drone.git
synced 2025-05-06 16:29:40 +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
|
webhookPRClosed: string
|
||||||
webhookPRCommentCreated: string
|
webhookPRCommentCreated: string
|
||||||
webhookPRCreated: string
|
webhookPRCreated: string
|
||||||
|
webhookPRLabelAssigned: string
|
||||||
webhookPRMerged: string
|
webhookPRMerged: string
|
||||||
webhookPRReopened: string
|
webhookPRReopened: string
|
||||||
webhookPRUpdated: string
|
webhookPRUpdated: string
|
||||||
|
@ -432,6 +432,7 @@ webhookPRReopened: PR reopened
|
|||||||
webhookPRClosed: PR closed
|
webhookPRClosed: PR closed
|
||||||
webhookPRCommentCreated: PR comment created
|
webhookPRCommentCreated: PR comment created
|
||||||
webhookPRMerged: PR merged
|
webhookPRMerged: PR merged
|
||||||
|
webhookPRLabelAssigned: PR label assigned
|
||||||
nameYourWebhook: Name your webhook
|
nameYourWebhook: Name your webhook
|
||||||
noExecutionsFound: No Executions found
|
noExecutionsFound: No Executions found
|
||||||
noExecutionsFoundForWebhook: No executions found for the given webhook
|
noExecutionsFoundForWebhook: No executions found for the given webhook
|
||||||
|
@ -63,6 +63,7 @@ interface FormData {
|
|||||||
prClosed: boolean
|
prClosed: boolean
|
||||||
prCommentCreated: boolean
|
prCommentCreated: boolean
|
||||||
prMerged: boolean
|
prMerged: boolean
|
||||||
|
prLabelAssigned: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface WebHookFormProps extends Pick<GitInfoProps, 'repoMetadata'> {
|
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,
|
prClosed: webhook?.triggers?.includes(WebhookIndividualEvent.PR_CLOSED) || false,
|
||||||
prCommentCreated: webhook?.triggers?.includes(WebhookIndividualEvent.PR_COMMENT_CREATED) || false,
|
prCommentCreated: webhook?.triggers?.includes(WebhookIndividualEvent.PR_COMMENT_CREATED) || false,
|
||||||
prMerged: webhook?.triggers?.includes(WebhookIndividualEvent.PR_MERGED) || 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
|
events: (webhook?.triggers?.length || 0) > 0 ? WebhookEventType.INDIVIDUAL : WebhookEventType.ALL
|
||||||
}}
|
}}
|
||||||
formName="create-webhook-form"
|
formName="create-webhook-form"
|
||||||
@ -170,6 +172,9 @@ export function WehookForm({ repoMetadata, isEdit, webhook }: WebHookFormProps)
|
|||||||
if (formData.prMerged) {
|
if (formData.prMerged) {
|
||||||
triggers.push(WebhookIndividualEvent.PR_MERGED)
|
triggers.push(WebhookIndividualEvent.PR_MERGED)
|
||||||
}
|
}
|
||||||
|
if (formData.prLabelAssigned) {
|
||||||
|
triggers.push(WebhookIndividualEvent.PR_LABEL_ASSIGNED)
|
||||||
|
}
|
||||||
if (!triggers.length) {
|
if (!triggers.length) {
|
||||||
return showError(getString('oneMustBeSelected'))
|
return showError(getString('oneMustBeSelected'))
|
||||||
}
|
}
|
||||||
@ -318,6 +323,11 @@ export function WehookForm({ repoMetadata, isEdit, webhook }: WebHookFormProps)
|
|||||||
name="prMerged"
|
name="prMerged"
|
||||||
className={css.checkbox}
|
className={css.checkbox}
|
||||||
/>
|
/>
|
||||||
|
<FormInput.CheckBox
|
||||||
|
label={getString('webhookPRLabelAssigned')}
|
||||||
|
name="prLabelAssigned"
|
||||||
|
className={css.checkbox}
|
||||||
|
/>
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</article>
|
||||||
) : null}
|
) : null}
|
||||||
|
@ -610,7 +610,8 @@ export enum WebhookIndividualEvent {
|
|||||||
PR_BRANCH_UPDATED = 'pullreq_branch_updated',
|
PR_BRANCH_UPDATED = 'pullreq_branch_updated',
|
||||||
PR_CLOSED = 'pullreq_closed',
|
PR_CLOSED = 'pullreq_closed',
|
||||||
PR_COMMENT_CREATED = 'pullreq_comment_created',
|
PR_COMMENT_CREATED = 'pullreq_comment_created',
|
||||||
PR_MERGED = 'pullreq_merged'
|
PR_MERGED = 'pullreq_merged',
|
||||||
|
PR_LABEL_ASSIGNED = 'pullreq_label_assigned'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum WebhookEventMap {
|
export enum WebhookEventMap {
|
||||||
@ -626,7 +627,8 @@ export enum WebhookEventMap {
|
|||||||
PR_BRANCH_UPDATED = 'PR branch updated',
|
PR_BRANCH_UPDATED = 'PR branch updated',
|
||||||
PR_CLOSED = 'PR closed',
|
PR_CLOSED = 'PR closed',
|
||||||
PR_COMMENT_CREATED = 'PR comment created',
|
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> = {
|
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_BRANCH_UPDATED]: WebhookEventMap.PR_BRANCH_UPDATED,
|
||||||
[WebhookIndividualEvent.PR_CLOSED]: WebhookEventMap.PR_CLOSED,
|
[WebhookIndividualEvent.PR_CLOSED]: WebhookEventMap.PR_CLOSED,
|
||||||
[WebhookIndividualEvent.PR_COMMENT_CREATED]: WebhookEventMap.PR_COMMENT_CREATED,
|
[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 {
|
export function getEventDescription(event: WebhookIndividualEvent): string {
|
||||||
|
Loading…
Reference in New Issue
Block a user