Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
49ee3bd
Merge branch 'main' into feat/webhook-ui
shivani170 Oct 17, 2024
58eba54
chore: wip received playload
shivani170 Oct 17, 2024
cbcc969
feat: ui for tag & PR info card
shivani170 Oct 18, 2024
dc1b079
feat: commit info card ui modification
shivani170 Oct 18, 2024
0bda2bb
chore: code refactoring
shivani170 Oct 21, 2024
81a597a
Merge branch 'develop' into feat/webhook-ui
shivani170 Oct 21, 2024
b1c724d
chore: hrlpers utils refactoring
shivani170 Oct 21, 2024
3de590e
chore: code refactoring
shivani170 Oct 22, 2024
0464aa4
chore: getFormattedSchema added
shivani170 Oct 22, 2024
7cf8784
Merge branch 'develop' into feat/webhook-ui
shivani170 Oct 22, 2024
18aa6d6
chore: version bump
shivani170 Oct 22, 2024
96ddc7f
chore: version bump
shivani170 Oct 22, 2024
64e213c
chore: hash icon added
shivani170 Nov 4, 2024
e037f5b
Merge branch 'develop' into feat/webhook-ui
shivani170 Nov 4, 2024
3d74f3f
chore: version bump
shivani170 Nov 5, 2024
f2ff268
chore: version bump
shivani170 Nov 5, 2024
12b10e9
Merge branch 'develop' into feat/webhook-ui
shivani170 Nov 6, 2024
18d50f0
chore: version bump
shivani170 Nov 6, 2024
d9dcd51
chore: ui fixes for commint card in git info
shivani170 Nov 7, 2024
36f3a51
chore: version bump
shivani170 Nov 7, 2024
f5aff4c
Merge branch 'develop' into feat/webhook-ui
shivani170 Nov 7, 2024
e1efe70
Merge branch 'develop' into feat/webhook-ui
shivani170 Nov 8, 2024
212190e
chore: code refactoring
shivani170 Nov 8, 2024
378bae3
chore: version bump
shivani170 Nov 8, 2024
1191329
chore: overflow-issue fix
shivani170 Nov 11, 2024
47039cc
version bump
shivani170 Nov 11, 2024
ae81e5b
Merge branch 'develop' into feat/webhook-ui
shivani170 Nov 12, 2024
046e893
chore: version bump
shivani170 Nov 12, 2024
6251625
chore: copy icon added in pr tag
shivani170 Nov 12, 2024
51f0f41
chore: version bump
shivani170 Nov 12, 2024
f86f5cb
Merge branch 'develop' into feat/webhook-ui
shivani170 Nov 13, 2024
9dbcdc1
chore: version bump
shivani170 Nov 13, 2024
95013f6
Merge branch 'develop' into feat/webhook-ui
shivani170 Nov 14, 2024
dd84db6
chore: version bump
shivani170 Nov 14, 2024
65e2cb9
chore: version bump
shivani170 Nov 14, 2024
a740210
chore: removed see more see less view in info card
shivani170 Nov 15, 2024
0571ac0
chore: git info fix
shivani170 Nov 15, 2024
9781e4c
Merge branch 'develop' into feat/webhook-ui
shivani170 Nov 18, 2024
3bdfedc
chore: version bump to 1.0.5-beta-3
shivani170 Nov 18, 2024
3fdf3fc
chore: version bump 1.0.6
shivani170 Nov 18, 2024
f375263
chore: version bump to 1.0.7
shivani170 Nov 18, 2024
1e25064
Merge branch 'develop' into feat/webhook-ui
shivani170 Nov 18, 2024
d02d2c5
chore: version bump
shivani170 Nov 18, 2024
8ca0002
chore: version bump to 1.0.7
shivani170 Nov 18, 2024
343d223
chore: removed unused code
shivani170 Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtron-labs/devtron-fe-common-lib",
"version": "0.5.8",
"version": "0.5.8-beta-4",
"description": "Supporting common component library",
"type": "module",
"main": "dist/index.js",
Expand Down
20 changes: 18 additions & 2 deletions src/Common/Common.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import moment from 'moment'
import { RuntimeParamsAPIResponseType, RuntimeParamsListItemType } from '@Shared/types'
import { getIsManualApprovalSpecific, sanitizeUserApprovalConfig, stringComparatorBySortOrder } from '@Shared/Helpers'
import { get, post } from './Api'
import { ROUTES } from './Constants'
import { GitProviderType, ROUTES } from './Constants'
import { getUrlWithSearchParams, sortCallback } from './Helper'
import {
TeamList,
Expand Down Expand Up @@ -250,7 +250,7 @@ const getImageApprovalPolicyDetailsFromMaterialResult = (cdMaterialsResult): Ima
const validGroups = userApprovalConfig.userGroups.map((group) => group.identifier)

// Have moved from Object.keys(imageApprovalUsersInfo) to approvalUsers since backend is not filtering out the users without approval
// TODO: This check should be on BE. Need to remove this once BE is updated
// TODO: This check should be on BE. Need to remove this once BE is updated
const usersList = approvalUsers.filter((user) => user !== DefaultUserKey.system)
const groupIdentifierToUsersMap = usersList.reduce(
(acc, user) => {
Expand Down Expand Up @@ -511,3 +511,19 @@ export function getWebhookEventsForEventId(eventId: string | number) {
const URL = `${ROUTES.GIT_HOST_EVENT}/${eventId}`
return get(URL)
}

/**
*
* @param gitUrl Git URL of the repository
* @param branchName Branch name
* @returns URL to the branch in the Git repository
*/
export const getGitBranchUrl = (gitUrl: string, branchName: string): string | null => {
if (!gitUrl) return null
const trimmedGitUrl = gitUrl.trim().replace(/\/$/, '') // Remove any trailing slash
if (trimmedGitUrl.includes(GitProviderType.GITLAB)) return `${trimmedGitUrl}/-/tree/${branchName}`
else if (trimmedGitUrl.includes(GitProviderType.GITHUB)) return `${trimmedGitUrl}/tree/${branchName}`
else if (trimmedGitUrl.includes(GitProviderType.BITBUCKET)) return `${trimmedGitUrl}/branch/${branchName}`
else if (trimmedGitUrl.includes(GitProviderType.AZURE)) return `${trimmedGitUrl}/src/branch/${branchName}`
return null
}
17 changes: 17 additions & 0 deletions src/Common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,20 @@ export const VULNERABILITIES_SORT_PRIORITY = {

// TODO: might not work need to verify
export const IS_PLATFORM_MAC_OS = window.navigator.userAgent.toUpperCase().includes('MAC')

/**
* Git provider types
*/

export enum GitProviderType {
GITHUB = 'github',
GITLAB = 'gitlab',
BITBUCKET = 'bitbucket',
AZURE = 'azure',
GITEA = 'gitea',
}

/**
* Formats the schema removing any irregularity in the existing schema
*/
export const getFormattedSchema = (schema?: string) => JSON.stringify(JSON.parse(schema ?? '{}'), null, 2)
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const CiPipelineSourceConfig = ({
</>
)}
{baseText && (
<span className="cursor" style={{ borderBottom: '1px solid #3b444c' }}>
<span className="cursor dc__border-dashed--n3-bottom fw-6 lh-20 fs-13">
{baseText}
</span>
)}
Expand Down
268 changes: 109 additions & 159 deletions src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/Shared/Components/KeyValueTable/KeyValueTable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
gap: 1px;

&.two-columns-top-row {
grid-template-columns: 20% 1fr;
grid-template-columns: 30% 1fr;
}

&.two-columns {
grid-template-columns: 20% 1fr;
grid-template-columns: 30% 1fr;

.key-value-table__row:last-of-type {
.key-value-table__cell:first-child,
Expand All @@ -41,7 +41,7 @@
}

&.three-columns {
grid-template-columns: 20% 1fr 32px;
grid-template-columns: 30% 1fr 32px;

.key-value-table__row:last-of-type {
.key-value-table__cell:first-child,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* limitations under the License.
*/

import { getWebhookDate } from '@Shared/Helpers'
import { MaterialHistoryType } from '@Shared/Services'
import { useMemo } from 'react'
import { SourceTypeMap } from '../../../Common'
import { GitCommitInfoGeneric } from '../GitCommitInfoGeneric'
import { MaterialHistoryProps } from './types'
Expand All @@ -32,22 +35,23 @@ const MaterialHistory = ({
}
}

const getMaterialHistoryMapWithTime = () => {
const historyTimeMap = {}

material.history?.forEach((history) => {
const newDate = history.date.substring(0, 16)

if (!historyTimeMap[newDate]) {
historyTimeMap[newDate] = []
}
historyTimeMap[newDate].push(history)
})
const materialHistoryMapWithTime = useMemo(
() =>
material.history.reduce<Record<string, MaterialHistoryType[]>>((acc, historyElem: MaterialHistoryType) => {
const isWebhook = material.type === SourceTypeMap.WEBHOOK
const newDate = isWebhook
? getWebhookDate(material.type, historyElem).substring(0, 16)
: historyElem.date.substring(0, 16)
if (!acc[newDate]) {
acc[newDate] = []
}
acc[newDate].push(historyElem)
return acc
}, {}),
[material.history, material.type],
)

return historyTimeMap
}
// Retrieve the history map
const materialHistoryMapWithTime = getMaterialHistoryMapWithTime()
// Retrieve the keys of the history map
const dateKeys = Object.keys(materialHistoryMapWithTime)

Expand All @@ -58,8 +62,8 @@ const MaterialHistory = ({
{dateKeys.map((date) => {
const historyList = materialHistoryMapWithTime[date]
return (
<>
{!isCommitInfoModal && material.type !== SourceTypeMap.WEBHOOK && (
<div key={date} className="flexbox-col dc__gap-12 py-12 px-16">
{!isCommitInfoModal && (
<div className="flex left dc__gap-8">
<span className="fs-12 lh-18 cn-7 fw-6 w-130">{date}</span>
<div className="h-1 bcn-2 w-100" />
Expand Down Expand Up @@ -87,13 +91,12 @@ const MaterialHistory = ({
materialSourceType={material.type}
selectedCommitInfo={selectCommit}
materialSourceValue={material.value}
canTriggerBuild={!history.excluded}
isExcluded={history.excluded}
/>
</div>
)
})}
</>
</div>
)
})}
</>
Expand Down
40 changes: 40 additions & 0 deletions src/Shared/Helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useEffect, useRef, useState, ReactElement } from 'react'
import Tippy from '@tippyjs/react'
import { Pair } from 'yaml'
import moment from 'moment'
import { MaterialHistoryType } from '@Shared/Services/app.types'
import {
handleUTCTime,
ManualApprovalType,
Expand All @@ -30,6 +31,8 @@ import {
PATTERNS,
ZERO_TIME_STRING,
noop,
SourceTypeMap,
DATE_TIME_FORMATS,
} from '../Common'
import {
AggregationKeys,
Expand Down Expand Up @@ -852,3 +855,40 @@ export const groupArrayByObjectKey = <T extends Record<string, any>, K extends k
},
{} as Record<string, T[]>,
)

/**
* @description - Function to get the lower case object
* @param input - The input object
* @returns Record<string, any>
*/
export const getLowerCaseObject = (input): Record<string, any> => {
if (!input || typeof input !== 'object') {
return input
}
return Object.keys(input).reduce((acc, key) => {
const modifiedKey = key.toLowerCase()
const value = input[key]
if (value && typeof value === 'object') {
acc[modifiedKey] = getLowerCaseObject(value)
} else {
acc[modifiedKey] = value
}
return acc
}, {})
}

/**
* @description - Function to get the webhook date
* @param materialSourceType - The type of material source (e.g., WEBHOOK)
* @param history - The history object containing commit information
* @returns - Formatted webhook date if available, otherwise an empty string
*/

export const getWebhookDate = (materialSourceType: string, history: MaterialHistoryType): string => {
const lowerCaseCommitInfo = getLowerCaseObject(history)
const isWebhook = materialSourceType === SourceTypeMap.WEBHOOK || lowerCaseCommitInfo?.webhookdata?.id !== 0
const webhookData = isWebhook ? lowerCaseCommitInfo.webhookdata : {}

const _moment = moment(webhookData.data.date, 'YYYY-MM-DDTHH:mm:ssZ')
return _moment.isValid() ? _moment.format(DATE_TIME_FORMATS.TWELVE_HOURS_FORMAT) : webhookData.data.date
}
3 changes: 2 additions & 1 deletion src/Shared/Services/app.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface MaterialHistoryDTO {
WebhookData: WebhookDataType
}

interface MaterialHistoryType {
export interface MaterialHistoryType {
commitURL: string
commit: MaterialHistoryDTO['Commit']
author: MaterialHistoryDTO['Author']
Expand Down Expand Up @@ -84,6 +84,7 @@ export interface CIMaterialType
gitURL: CIMaterialDTO['url']
history: MaterialHistoryType[]
isSelected: boolean
gitMaterialUrl?: string
}

interface ImageCommentDTO {
Expand Down