Skip to content

Commit 8571a2f

Browse files
committed
Merge branch 'feat/release' of https://github.com/devtron-labs/devtron-fe-common-lib into feat/button-with-selector
2 parents 2eb5b89 + e3a2f97 commit 8571a2f

File tree

15 files changed

+105
-11
lines changed

15 files changed

+105
-11
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.0.79-beta-4",
3+
"version": "0.0.79-beta-8",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Assets/Icon/ic-pull-request.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Assets/Icon/ic-tag.svg

Lines changed: 4 additions & 0 deletions
Loading

src/Assets/Icon/ic-webhook.svg

Lines changed: 15 additions & 0 deletions
Loading

src/Common/Common.service.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ export function setImageTags(request, pipelineId: number, artifactId: number) {
6262
return post(`${ROUTES.IMAGE_TAGGING}/${pipelineId}/${artifactId}`, request)
6363
}
6464

65-
const cdMaterialListModal = (artifacts: any[], offset: number, artifactId?: number, artifactStatus?: string) => {
65+
const cdMaterialListModal = (artifacts: any[], offset: number, artifactId?: number, artifactStatus?: string, disableDefaultSelection?: boolean) => {
6666
if (!artifacts || !artifacts.length) return []
6767

6868
const markFirstSelected = offset === 0
6969
const startIndex = offset
70-
let isImageMarked = false
70+
let isImageMarked = disableDefaultSelection
7171

7272
const materials = artifacts.map((material, index) => {
7373
let artifactStatusValue = ''
@@ -178,8 +178,8 @@ const processCDMaterialsMetaInfo = (cdMaterialsResult): CDMaterialsMetaInfo => {
178178
}
179179

180180
return {
181-
appReleaseTagNames: cdMaterialsResult.appReleaseTagNames,
182-
tagsEditable: cdMaterialsResult.tagsEditable,
181+
appReleaseTagNames: cdMaterialsResult.appReleaseTagNames ?? [],
182+
tagsEditable: cdMaterialsResult.tagsEditable ?? false,
183183
hideImageTaggingHardDelete: cdMaterialsResult.hideImageTaggingHardDelete,
184184
resourceFilters: cdMaterialsResult.resourceFilters ?? [],
185185
totalCount: cdMaterialsResult.totalCount ?? 0,
@@ -201,11 +201,12 @@ const processImagePromotionInfo = (cdMaterialsResult): ImagePromotionMaterialInf
201201
}
202202
}
203203

204-
const processCDMaterialServiceResponse = (
204+
export const processCDMaterialServiceResponse = (
205205
cdMaterialsResult,
206206
stage: DeploymentNodeType,
207207
offset: number,
208208
filter: CDMaterialFilterQuery,
209+
disableDefaultSelection?: boolean,
209210
): CDMaterialResponseType => {
210211
if (!cdMaterialsResult) {
211212
return {
@@ -221,6 +222,7 @@ const processCDMaterialServiceResponse = (
221222
offset ?? 0,
222223
cdMaterialsResult.latest_wf_artifact_id,
223224
cdMaterialsResult.latest_wf_artifact_status,
225+
disableDefaultSelection,
224226
)
225227
const approvalInfo = processCDMaterialsApprovalInfo(
226228
stage === DeploymentNodeType.CD || stage === DeploymentNodeType.APPROVAL,
@@ -251,7 +253,7 @@ const getSanitizedQueryParams = (queryParams: CDMaterialServiceQueryParams): CDM
251253
export const genericCDMaterialsService = (
252254
serviceType: CDMaterialServiceEnum,
253255
/**
254-
* In case of hotfix would be sending it as null
256+
* In case of multiple candidates are there like promotion, would be sending it as null
255257
*/
256258
cdMaterialID: number,
257259
/**
@@ -274,7 +276,6 @@ export const genericCDMaterialsService = (
274276
// Directly sending queryParams since do not need to get queryParams sanitized in case of image promotion
275277
URL = getUrlWithSearchParams(ROUTES.APP_ARTIFACT_PROMOTE_MATERIAL, queryParams)
276278
break
277-
278279
// Meant for handling getCDMaterialList
279280
default:
280281
URL = getUrlWithSearchParams(`${ROUTES.CD_MATERIAL_GET}/${cdMaterialID}/material`, {
@@ -325,3 +326,8 @@ export function fetchChartTemplateVersions() {
325326
export const getDefaultConfig = (): Promise<ResponseType> => {
326327
return get(`${ROUTES.NOTIFIER}/channel/config`)
327328
}
329+
330+
export function getWebhookEventsForEventId(eventId: string | number) {
331+
const URL = `${ROUTES.GIT_HOST_EVENT}/${eventId}`
332+
return get(URL)
333+
}

src/Common/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const ROUTES = {
4949
UPDATE: 'update',
5050
CLUSTER_NOTE: 'cluster/note',
5151
APPLICATION_NOTE: 'app/note',
52+
GIT_HOST_EVENT: 'git/host/event',
5253
}
5354

5455
export enum KEY_VALUE {

src/Shared/Helpers.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { MaterialInfo } from '../Common'
2-
import { GitTriggers } from './types'
2+
import { GitTriggers, WebhookEventNameType } from './types'
3+
import { ReactComponent as ICPullRequest } from '../Assets/Icon/ic-pull-request.svg'
4+
import { ReactComponent as ICTag } from '../Assets/Icon/ic-tag.svg'
5+
import { ReactComponent as ICWebhook } from '../Assets/Icon/ic-webhook.svg'
36

47
interface HighlightSearchTextProps {
58
/**
@@ -69,3 +72,14 @@ export const getGitCommitInfo = (materialInfo: MaterialInfo): GitTriggers => ({
6972

7073
export const caseInsensitiveStringComparator = (a: string, b: string): number =>
7174
a.toLowerCase().localeCompare(b.toLowerCase())
75+
76+
export const getWebhookEventIcon = (eventName: WebhookEventNameType) => {
77+
switch (eventName) {
78+
case WebhookEventNameType.PULL_REQUEST:
79+
return <ICPullRequest className="icon-dim-12" />
80+
case WebhookEventNameType.TAG_CREATION:
81+
return <ICTag className="icon-dim-12" />
82+
default:
83+
return <ICWebhook className="icon-dim-12" />
84+
}
85+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { createContext, useContext, useMemo } from 'react'
2+
import { ImageSelectionUtilityContextType, ImageSelectionUtilityProviderProps } from './types'
3+
4+
export const ImageSelectionUtilityContext = createContext<ImageSelectionUtilityContextType>(null)
5+
export const useImageSelectionUtilityContext = () => {
6+
const context = useContext<ImageSelectionUtilityContextType>(ImageSelectionUtilityContext)
7+
if (!context) {
8+
throw new Error('useImageSelectionUtilityContext must be used within ImageSelectionUtilityProvider')
9+
}
10+
11+
return context
12+
}
13+
14+
export const ImageSelectionUtilityProvider = ({ children, value }: ImageSelectionUtilityProviderProps) => {
15+
const memoizedValue = useMemo(() => value, [value])
16+
17+
return (
18+
<ImageSelectionUtilityContext.Provider value={memoizedValue}>{children}</ImageSelectionUtilityContext.Provider>
19+
)
20+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './ImageSelectionUtility'

0 commit comments

Comments
 (0)