From cbcc969334b74f4bd45832c7bf8112cbb811d2c5 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Fri, 18 Oct 2024 17:40:29 +0530 Subject: [PATCH 01/64] feat: ui for tag & PR info card --- .../Components/CICDHistory/CiPipelineSourceConfig.tsx | 6 +----- src/Shared/Components/KeyValueTable/KeyValueTable.scss | 6 +++--- .../MaterialHistory/MaterialHistory.component.tsx | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx b/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx index da874cb0f..ba981e735 100644 --- a/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx +++ b/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx @@ -169,11 +169,7 @@ export const CiPipelineSourceConfig = ({ )} )} - {baseText && ( - - {baseText} - - )} + {baseText && {baseText}} )} diff --git a/src/Shared/Components/KeyValueTable/KeyValueTable.scss b/src/Shared/Components/KeyValueTable/KeyValueTable.scss index efe43bb85..2aaba811c 100644 --- a/src/Shared/Components/KeyValueTable/KeyValueTable.scss +++ b/src/Shared/Components/KeyValueTable/KeyValueTable.scss @@ -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, @@ -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, diff --git a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx index a1b534ee9..e63c4df9f 100644 --- a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx +++ b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx @@ -35,7 +35,7 @@ const MaterialHistory = ({ const getMaterialHistoryMapWithTime = () => { const historyTimeMap = {} - material.history?.forEach((history) => { + material.history.forEach((history) => { const newDate = history.date.substring(0, 16) if (!historyTimeMap[newDate]) { @@ -59,7 +59,7 @@ const MaterialHistory = ({ const historyList = materialHistoryMapWithTime[date] return ( <> - {!isCommitInfoModal && material.type !== SourceTypeMap.WEBHOOK && ( + {!isCommitInfoModal && (
{date}
From dc1b079f77415c7cd5bc19f6250a07e13a68ea2e Mon Sep 17 00:00:00 2001 From: shivani170 Date: Fri, 18 Oct 2024 18:39:27 +0530 Subject: [PATCH 02/64] feat: commit info card ui modification --- .../GitCommitInfoGeneric.tsx | 232 +++++++++--------- .../MaterialHistory.component.tsx | 1 - 2 files changed, 116 insertions(+), 117 deletions(-) diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index 4da369fef..0721ff964 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -21,17 +21,16 @@ import Tippy from '@tippyjs/react' import ClipboardButton from '@Common/ClipboardButton/ClipboardButton' import { ReactComponent as Circle } from '@Icons/ic-circle.svg' import { ReactComponent as Commit } from '@Icons/ic-commit.svg' -import { ReactComponent as CommitIcon } from '@Icons/ic-code-commit.svg' import { ReactComponent as PersonIcon } from '@Icons/ic-person.svg' import { ReactComponent as CalendarIcon } from '@Icons/ic-calendar.svg' import { ReactComponent as MessageIcon } from '@Icons/ic-message.svg' -import { ReactComponent as BranchIcon } from '@Icons/ic-branch.svg' -import { ReactComponent as BranchMain } from '@Icons/ic-branch-main.svg' +import { ReactComponent as PullRequestIcon } from '@Icons/ic-pull-request.svg' import { ReactComponent as Check } from '@Icons/ic-check-circle.svg' import { ReactComponent as Abort } from '@Icons/ic-abort.svg' import { SourceTypeMap, createGitCommitUrl } from '@Common/Common.service' import { stopPropagation } from '@Common/Helper' import { DATE_TIME_FORMATS } from '@Common/Constants' +import { ReactComponent as Tag } from '@Icons/ic-tag.svg' import GitMaterialInfoHeader from './GitMaterialInfoHeader' import { MATERIAL_EXCLUDE_TIPPY_TEXT } from '../../constants' import { WEBHOOK_EVENT_ACTION_TYPE } from './constants' @@ -44,7 +43,6 @@ const GitCommitInfoGeneric = ({ selectedCommitInfo, materialUrl, showMaterialInfoHeader, - canTriggerBuild = false, index, isExcluded = false, }: GitCommitInfoGenericProps) => { @@ -213,6 +211,118 @@ const GitCommitInfoGeneric = ({ return matSelectionText() } + const renderWebhookTitle = () => + _webhookData.data.title ? {_webhookData.data.title} : null + + const renderPullRequestId = (pullRequestUrl: string) => { + const pullRequestId = pullRequestUrl.split('/').pop() + if (pullRequestId) { + return ( + + # {pullRequestId} + + ) + } + return null + } + + const renderTargetBranch = () => { + if (_webhookData.data['target branch name']) { + return ( +
+ into  + + {_webhookData.data['target branch name']} + +
+ ) + } + return null + } + + const renderSourceBranch = () => { + if (_webhookData.data['source branch name']) { + return ( +
+ from  + + {_webhookData.data['source branch name']} + +
+ ) + } + return null + } + + const renderPRInfoCard = () => + _isWebhook && + _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.MERGED && ( + <> + {renderPullRequestId(_webhookData.data['git url'])} +
+ {renderWebhookTitle()} + {selectedCommitInfo ? ( +
+ {_lowerCaseCommitInfo.isselected ? ( + + ) : ( + + )} +
+ ) : null} +
+ +
+ +
+ Merge 1 commit + {renderTargetBranch()} + {renderSourceBranch()} +
+
+ {renderBasicGitCommitInfoForWebhook()} + {handleMoreDataForWebhook()} + + ) + + const renderTagInfoCard = () => + _isWebhook && + _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.NON_MERGED && ( + <> +
+
+ + {_webhookData.data['target checkout']} +
+ {selectedCommitInfo ? ( +
+ {_lowerCaseCommitInfo.isselected ? : 'Select'} +
+ ) : null} +
+ {renderBasicGitCommitInfoForWebhook()} + {handleMoreDataForWebhook()} + + ) + return (
{showMaterialInfoHeader && (_isWebhook || _lowerCaseCommitInfo.commit) && ( @@ -288,118 +398,8 @@ const GitCommitInfoGeneric = ({ )} - {_isWebhook && _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.MERGED && ( - <> -
-
- {_webhookData.data.title ? ( -
{_webhookData.data.title}
- ) : null} - {_webhookData.data['git url'] ? ( - - View git url - - ) : null} -
- {selectedCommitInfo ? ( -
- {_lowerCaseCommitInfo.isselected ? ( - - ) : ( - - )} -
- ) : null} -
- -
-
- -
-
- {_webhookData.data['source branch name'] ? ( -
- {' '} - {_webhookData.data['source branch name']} -
- ) : null} - {_webhookData.data['source checkout'] ? ( - - ) : null} -
-
-
- {_webhookData.data['target branch name'] ? ( - <> - {' '} - {_webhookData.data['target branch name']}{' '} - - ) : null} -
-
- {canTriggerBuild && ( -
- - HEAD -
- )} - {!canTriggerBuild && ( - - - {_webhookData.data['target checkout']} - - )} -
-
-
-
-
- {renderBasicGitCommitInfoForWebhook()} - {handleMoreDataForWebhook()} - - )} - {_isWebhook && _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.NON_MERGED && ( - <> -
-
{_webhookData.data['target checkout']}
- {selectedCommitInfo ? ( -
- {_lowerCaseCommitInfo.isselected ? : 'Select'} -
- ) : null} -
- {renderBasicGitCommitInfoForWebhook()} - {handleMoreDataForWebhook()} - - )} + {renderPRInfoCard()} + {renderTagInfoCard()}
) diff --git a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx index e63c4df9f..d2f4eba6c 100644 --- a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx +++ b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx @@ -87,7 +87,6 @@ const MaterialHistory = ({ materialSourceType={material.type} selectedCommitInfo={selectCommit} materialSourceValue={material.value} - canTriggerBuild={!history.excluded} isExcluded={history.excluded} />
From 0bda2bba0ac969d3a17a0762ec22e9e93f1eae39 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Mon, 21 Oct 2024 16:15:09 +0530 Subject: [PATCH 03/64] chore: code refactoring --- .../GitCommitInfoGeneric.tsx | 24 ++----------- .../MaterialHistory.component.tsx | 7 +++- src/Shared/Helpers.tsx | 35 +++++++++++++++++++ src/Shared/Services/app.types.ts | 2 +- 4 files changed, 44 insertions(+), 24 deletions(-) diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index 0721ff964..1a2f5050c 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -31,6 +31,7 @@ import { SourceTypeMap, createGitCommitUrl } from '@Common/Common.service' import { stopPropagation } from '@Common/Helper' import { DATE_TIME_FORMATS } from '@Common/Constants' import { ReactComponent as Tag } from '@Icons/ic-tag.svg' +import { _lowerCaseObject, getWebhookDate } from '@Shared/Helpers' import GitMaterialInfoHeader from './GitMaterialInfoHeader' import { MATERIAL_EXCLUDE_TIPPY_TEXT } from '../../constants' import { WEBHOOK_EVENT_ACTION_TYPE } from './constants' @@ -48,23 +49,6 @@ const GitCommitInfoGeneric = ({ }: GitCommitInfoGenericProps) => { const [showSeeMore, setShowSeeMore] = useState(true) - function _lowerCaseObject(input): any { - const _output = {} - if (!input) { - return _output - } - Object.keys(input).forEach((_key) => { - const _modifiedKey = _key.toLowerCase() - const _value = input[_key] - if (_value && typeof _value === 'object') { - _output[_modifiedKey] = _lowerCaseObject(_value) - } else { - _output[_modifiedKey] = _value - } - }) - return _output - } - const _lowerCaseCommitInfo = _lowerCaseObject(commitInfo) const _isWebhook = materialSourceType === SourceTypeMap.WEBHOOK || @@ -78,11 +62,7 @@ const GitCommitInfoGeneric = ({ : createGitCommitUrl(materialUrl, _lowerCaseCommitInfo.commit) function renderBasicGitCommitInfoForWebhook() { - let _date - if (_webhookData.data.date) { - const _moment = moment(_webhookData.data.date, 'YYYY-MM-DDTHH:mm:ssZ') - _date = _moment.isValid() ? _moment.format(DATE_TIME_FORMATS.TWELVE_HOURS_FORMAT) : _webhookData.data.date - } + const _date = getWebhookDate(materialSourceType, commitInfo) return ( <> {_webhookData.data.author ? ( diff --git a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx index d2f4eba6c..d90938526 100644 --- a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx +++ b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx @@ -14,6 +14,7 @@ * limitations under the License. */ +import { getWebhookDate } from '@Shared/Helpers' import { SourceTypeMap } from '../../../Common' import { GitCommitInfoGeneric } from '../GitCommitInfoGeneric' import { MaterialHistoryProps } from './types' @@ -36,7 +37,11 @@ const MaterialHistory = ({ const historyTimeMap = {} material.history.forEach((history) => { - const newDate = history.date.substring(0, 16) + const isWebhook = material.type === SourceTypeMap.WEBHOOK + + const newDate = isWebhook + ? getWebhookDate(material.type, history).substring(0, 16) + : history.date.substring(0, 16) if (!historyTimeMap[newDate]) { historyTimeMap[newDate] = [] diff --git a/src/Shared/Helpers.tsx b/src/Shared/Helpers.tsx index 5eaac04f8..756063b55 100644 --- a/src/Shared/Helpers.tsx +++ b/src/Shared/Helpers.tsx @@ -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, @@ -30,6 +31,8 @@ import { PATTERNS, ZERO_TIME_STRING, noop, + SourceTypeMap, + DATE_TIME_FORMATS, } from '../Common' import { AggregationKeys, @@ -852,3 +855,35 @@ export const groupArrayByObjectKey = , K extends k }, {} as Record, ) + +export const _lowerCaseObject = (input): any => { + const _output = {} + if (!input) { + return _output + } + Object.keys(input).forEach((_key) => { + const _modifiedKey = _key.toLowerCase() + const _value = input[_key] + if (_value && typeof _value === 'object') { + _output[_modifiedKey] = _lowerCaseObject(_value) + } else { + _output[_modifiedKey] = _value + } + }) + return _output +} + +export const getWebhookDate = (materialSourceType: string, history: MaterialHistoryType): string => { + const _lowerCaseCommitInfo = _lowerCaseObject(history) + const _isWebhook = + materialSourceType === SourceTypeMap.WEBHOOK || + (_lowerCaseCommitInfo && _lowerCaseCommitInfo.webhookdata && _lowerCaseCommitInfo.webhookdata.id !== 0) + const _webhookData = _isWebhook ? _lowerCaseCommitInfo.webhookdata : {} + + let _date + if (_webhookData.data.date) { + const _moment = moment(_webhookData.data.date, 'YYYY-MM-DDTHH:mm:ssZ') + _date = _moment.isValid() ? _moment.format(DATE_TIME_FORMATS.TWELVE_HOURS_FORMAT) : _webhookData.data.date + } + return _date +} diff --git a/src/Shared/Services/app.types.ts b/src/Shared/Services/app.types.ts index cf3d4f31a..4fcddce43 100644 --- a/src/Shared/Services/app.types.ts +++ b/src/Shared/Services/app.types.ts @@ -31,7 +31,7 @@ interface MaterialHistoryDTO { WebhookData: WebhookDataType } -interface MaterialHistoryType { +export interface MaterialHistoryType { commitURL: string commit: MaterialHistoryDTO['Commit'] author: MaterialHistoryDTO['Author'] From b1c724dd9801713dea61bd28e894c97c690b2778 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Mon, 21 Oct 2024 17:51:00 +0530 Subject: [PATCH 04/64] chore: hrlpers utils refactoring --- .../GitCommitInfoGeneric.tsx | 36 ++++++------- src/Shared/Helpers.tsx | 53 ++++++++++--------- 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index 1a2f5050c..2c4ec582a 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -31,7 +31,7 @@ import { SourceTypeMap, createGitCommitUrl } from '@Common/Common.service' import { stopPropagation } from '@Common/Helper' import { DATE_TIME_FORMATS } from '@Common/Constants' import { ReactComponent as Tag } from '@Icons/ic-tag.svg' -import { _lowerCaseObject, getWebhookDate } from '@Shared/Helpers' +import { getLowerCaseObject, getWebhookDate } from '@Shared/Helpers' import GitMaterialInfoHeader from './GitMaterialInfoHeader' import { MATERIAL_EXCLUDE_TIPPY_TEXT } from '../../constants' import { WEBHOOK_EVENT_ACTION_TYPE } from './constants' @@ -49,7 +49,7 @@ const GitCommitInfoGeneric = ({ }: GitCommitInfoGenericProps) => { const [showSeeMore, setShowSeeMore] = useState(true) - const _lowerCaseCommitInfo = _lowerCaseObject(commitInfo) + const _lowerCaseCommitInfo = getLowerCaseObject(commitInfo) const _isWebhook = materialSourceType === SourceTypeMap.WEBHOOK || (_lowerCaseCommitInfo && _lowerCaseCommitInfo.webhookdata && _lowerCaseCommitInfo.webhookdata.id !== 0) @@ -196,26 +196,24 @@ const GitCommitInfoGeneric = ({ const renderPullRequestId = (pullRequestUrl: string) => { const pullRequestId = pullRequestUrl.split('/').pop() - if (pullRequestId) { - return ( - - # {pullRequestId} - - ) - } - return null + + return ( + + # {typeof pullRequestId === 'number' ? pullRequestId : 'PR'} + + ) } const renderTargetBranch = () => { if (_webhookData.data['target branch name']) { return ( - +

) } return null @@ -273,7 +271,7 @@ const GitCommitInfoGeneric = ({
- Merge 1 commit + Merge commit {renderTargetBranch()} {renderSourceBranch()}
diff --git a/src/Shared/Helpers.tsx b/src/Shared/Helpers.tsx index 756063b55..8f5e8af10 100644 --- a/src/Shared/Helpers.tsx +++ b/src/Shared/Helpers.tsx @@ -856,34 +856,39 @@ export const groupArrayByObjectKey = , K extends k {} as Record, ) -export const _lowerCaseObject = (input): any => { - const _output = {} - if (!input) { - return _output +/** + * @description - Function to get the lower case object + * @param input - The input object + * @returns Record + */ +export const getLowerCaseObject = (input): Record => { + if (!input || typeof input !== 'object') { + return input } - Object.keys(input).forEach((_key) => { - const _modifiedKey = _key.toLowerCase() - const _value = input[_key] - if (_value && typeof _value === 'object') { - _output[_modifiedKey] = _lowerCaseObject(_value) + 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 { - _output[_modifiedKey] = _value + acc[modifiedKey] = value } - }) - return _output + 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 = _lowerCaseObject(history) - const _isWebhook = - materialSourceType === SourceTypeMap.WEBHOOK || - (_lowerCaseCommitInfo && _lowerCaseCommitInfo.webhookdata && _lowerCaseCommitInfo.webhookdata.id !== 0) - const _webhookData = _isWebhook ? _lowerCaseCommitInfo.webhookdata : {} - - let _date - if (_webhookData.data.date) { - const _moment = moment(_webhookData.data.date, 'YYYY-MM-DDTHH:mm:ssZ') - _date = _moment.isValid() ? _moment.format(DATE_TIME_FORMATS.TWELVE_HOURS_FORMAT) : _webhookData.data.date - } - return _date + 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 } From 3de590ee58bdeeec50469071b4752696a3a14398 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Tue, 22 Oct 2024 09:52:32 +0530 Subject: [PATCH 05/64] chore: code refactoring --- src/Common/Common.service.ts | 21 +++- src/Common/Constants.ts | 8 ++ .../GitCommitInfoGeneric.tsx | 106 +++++++----------- .../MaterialHistory.component.tsx | 35 +++--- src/Shared/Services/app.types.ts | 1 + 5 files changed, 85 insertions(+), 86 deletions(-) diff --git a/src/Common/Common.service.ts b/src/Common/Common.service.ts index 99e28ff6c..fddf52533 100644 --- a/src/Common/Common.service.ts +++ b/src/Common/Common.service.ts @@ -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, @@ -511,3 +511,22 @@ export function getWebhookEventsForEventId(eventId: string | number) { const URL = `${ROUTES.GIT_HOST_EVENT}/${eventId}` return get(URL) } + +export const getGitBranchUrl = (gitUrl: string, branchName: string): string | null => { + if (!gitUrl) return null + + const trimmedGitUrl = gitUrl.trim().replace(/\/$/, '') // Remove any trailing slash + + switch (true) { + case trimmedGitUrl.includes(GitProviderType.GITLAB): + return `${trimmedGitUrl}/-/tree/${branchName}` + case trimmedGitUrl.includes(GitProviderType.GITHUB): + return `${trimmedGitUrl}/tree/${branchName}` + case trimmedGitUrl.includes(GitProviderType.BITBUCKET): + return `${trimmedGitUrl}/branch/${branchName}` + case trimmedGitUrl.includes(GitProviderType.AZURE): + return `${trimmedGitUrl}/src/branch/${branchName}` + default: + return null + } +} \ No newline at end of file diff --git a/src/Common/Constants.ts b/src/Common/Constants.ts index f15e80ef6..db2bfc643 100644 --- a/src/Common/Constants.ts +++ b/src/Common/Constants.ts @@ -554,3 +554,11 @@ export const VULNERABILITIES_SORT_PRIORITY = { // TODO: might not work need to verify export const IS_PLATFORM_MAC_OS = window.navigator.userAgent.toUpperCase().includes('MAC') + +export enum GitProviderType { + GITHUB = 'github', + GITLAB = 'gitlab', + BITBUCKET = 'bitbucket', + AZURE = 'azure', + GITEA = 'gitea', +} diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index 2c4ec582a..b1b7c3387 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -27,7 +27,7 @@ import { ReactComponent as MessageIcon } from '@Icons/ic-message.svg' import { ReactComponent as PullRequestIcon } from '@Icons/ic-pull-request.svg' import { ReactComponent as Check } from '@Icons/ic-check-circle.svg' import { ReactComponent as Abort } from '@Icons/ic-abort.svg' -import { SourceTypeMap, createGitCommitUrl } from '@Common/Common.service' +import { SourceTypeMap, createGitCommitUrl, getGitBranchUrl } from '@Common/Common.service' import { stopPropagation } from '@Common/Helper' import { DATE_TIME_FORMATS } from '@Common/Constants' import { ReactComponent as Tag } from '@Icons/ic-tag.svg' @@ -49,17 +49,17 @@ const GitCommitInfoGeneric = ({ }: GitCommitInfoGenericProps) => { const [showSeeMore, setShowSeeMore] = useState(true) - const _lowerCaseCommitInfo = getLowerCaseObject(commitInfo) + const lowerCaseCommitInfo = getLowerCaseObject(commitInfo) const _isWebhook = materialSourceType === SourceTypeMap.WEBHOOK || - (_lowerCaseCommitInfo && _lowerCaseCommitInfo.webhookdata && _lowerCaseCommitInfo.webhookdata.id !== 0) - const _webhookData = _isWebhook ? _lowerCaseCommitInfo.webhookdata : {} + (lowerCaseCommitInfo && lowerCaseCommitInfo.webhookdata && lowerCaseCommitInfo.webhookdata.id !== 0) + const _webhookData = _isWebhook ? lowerCaseCommitInfo.webhookdata : {} // eslint-disable-next-line no-nested-ternary const _commitUrl = _isWebhook ? null - : _lowerCaseCommitInfo.commiturl - ? _lowerCaseCommitInfo.commiturl - : createGitCommitUrl(materialUrl, _lowerCaseCommitInfo.commit) + : lowerCaseCommitInfo.commiturl + ? lowerCaseCommitInfo.commiturl + : createGitCommitUrl(materialUrl, lowerCaseCommitInfo.commit) function renderBasicGitCommitInfoForWebhook() { const _date = getWebhookDate(materialSourceType, commitInfo) @@ -185,7 +185,7 @@ const GitCommitInfoGeneric = ({ } const renderCommitStatus = () => { - if (_lowerCaseCommitInfo.isselected) { + if (lowerCaseCommitInfo.isselected) { return } return matSelectionText() @@ -202,53 +202,26 @@ const GitCommitInfoGeneric = ({ href={pullRequestUrl} target="_blank" rel="noopener noreferrer" - className="commit-hash fs-14 px-6 mono dc__w-fit-content" + className="commit-hash fs-14 px-6 mono dc__w-fit-content cursor" onClick={stopPropagation} > - # {typeof pullRequestId === 'number' ? pullRequestId : 'PR'} + # {Number.isNaN(pullRequestId) ? 'PR' : pullRequestId} ) } - const renderTargetBranch = () => { - if (_webhookData.data['target branch name']) { - return ( -

- into  - - {_webhookData.data['target branch name']} - -

- ) - } - return null - } - - const renderSourceBranch = () => { - if (_webhookData.data['source branch name']) { - return ( - - ) - } - return null - } + const renderBranchName = (branchName: string) => + branchName ? ( + + {branchName} + + ) : null const renderPRInfoCard = () => _isWebhook && @@ -259,7 +232,7 @@ const GitCommitInfoGeneric = ({ {renderWebhookTitle()} {selectedCommitInfo ? (
- {_lowerCaseCommitInfo.isselected ? ( + {lowerCaseCommitInfo.isselected ? ( ) : ( @@ -271,9 +244,10 @@ const GitCommitInfoGeneric = ({
- Merge commit - {renderTargetBranch()} - {renderSourceBranch()} + Merge commit into  + {renderBranchName(_webhookData.data['target branch name'])} +  from  + {renderBranchName(_webhookData.data['source branch name'])}
{renderBasicGitCommitInfoForWebhook()} @@ -292,7 +266,7 @@ const GitCommitInfoGeneric = ({
{selectedCommitInfo ? (
- {_lowerCaseCommitInfo.isselected ? : 'Select'} + {lowerCaseCommitInfo.isselected ? : 'Select'}
) : null}
@@ -303,7 +277,7 @@ const GitCommitInfoGeneric = ({ return (
- {showMaterialInfoHeader && (_isWebhook || _lowerCaseCommitInfo.commit) && ( + {showMaterialInfoHeader && (_isWebhook || lowerCaseCommitInfo.commit) && ( {!_isWebhook && ( <> - {_lowerCaseCommitInfo.commit && ( + {lowerCaseCommitInfo.commit && (
{_commitUrl ? (
@@ -331,44 +305,42 @@ const GitCommitInfoGeneric = ({ data-testid={`git-commit-credential${index}`} > - {_lowerCaseCommitInfo.commit.slice(0, 7)} + {lowerCaseCommitInfo.commit.slice(0, 7)}
- +
) : null} {selectedCommitInfo ? renderCommitStatus() : null}
)} - {_lowerCaseCommitInfo.message ? ( + {lowerCaseCommitInfo.message ? (
- {_lowerCaseCommitInfo.message} + {lowerCaseCommitInfo.message}
) : null}
- {_lowerCaseCommitInfo.author ? ( + {lowerCaseCommitInfo.author ? (
- {_lowerCaseCommitInfo.author} + {lowerCaseCommitInfo.author}
) : null} - {_lowerCaseCommitInfo.date ? ( + {lowerCaseCommitInfo.date ? (
- {moment(_lowerCaseCommitInfo.date).format( - DATE_TIME_FORMATS.TWELVE_HOURS_FORMAT, - )} + {moment(lowerCaseCommitInfo.date).format(DATE_TIME_FORMATS.TWELVE_HOURS_FORMAT)}
) : null} diff --git a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx index d90938526..bf1eaef44 100644 --- a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx +++ b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx @@ -15,6 +15,8 @@ */ 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' @@ -33,26 +35,23 @@ const MaterialHistory = ({ } } - const getMaterialHistoryMapWithTime = () => { - const historyTimeMap = {} - - material.history.forEach((history) => { - const isWebhook = material.type === SourceTypeMap.WEBHOOK - - const newDate = isWebhook - ? getWebhookDate(material.type, history).substring(0, 16) - : history.date.substring(0, 16) - - if (!historyTimeMap[newDate]) { - historyTimeMap[newDate] = [] - } - historyTimeMap[newDate].push(history) - }) + const materialHistoryMapWithTime = useMemo( + () => + material.history.reduce>((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) diff --git a/src/Shared/Services/app.types.ts b/src/Shared/Services/app.types.ts index 279e9006a..e2192d00d 100644 --- a/src/Shared/Services/app.types.ts +++ b/src/Shared/Services/app.types.ts @@ -84,6 +84,7 @@ export interface CIMaterialType gitURL: CIMaterialDTO['url'] history: MaterialHistoryType[] isSelected: boolean + gitMaterialUrl?: string } interface ImageCommentDTO { From 0464aa4fb4c1e7fd65ad4573eb77640fea5960de Mon Sep 17 00:00:00 2001 From: shivani170 Date: Tue, 22 Oct 2024 10:57:16 +0530 Subject: [PATCH 06/64] chore: getFormattedSchema added --- src/Common/Constants.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Common/Constants.ts b/src/Common/Constants.ts index db2bfc643..7c5aded2d 100644 --- a/src/Common/Constants.ts +++ b/src/Common/Constants.ts @@ -555,6 +555,10 @@ 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', @@ -562,3 +566,8 @@ export enum GitProviderType { 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) From 18aa6d682798ba024b81e750ca46d5fe1759a452 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Tue, 22 Oct 2024 16:21:25 +0530 Subject: [PATCH 07/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- .../Components/CICDHistory/CiPipelineSourceConfig.tsx | 6 +++++- .../GitCommitInfoGeneric/GitCommitInfoGeneric.tsx | 4 ++-- .../MaterialHistory/MaterialHistory.component.tsx | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5b2219979..49904c6b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8", + "version": "0.5.8-beta-3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8", + "version": "0.5.8-beta-3", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 71f17bf42..4320ade74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8", + "version": "0.5.8-beta-3", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx b/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx index ba981e735..2aef84f47 100644 --- a/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx +++ b/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx @@ -169,7 +169,11 @@ export const CiPipelineSourceConfig = ({ )} )} - {baseText && {baseText}} + {baseText && ( + + {baseText} + + )}
)} diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index b1b7c3387..f0f0f82fc 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -192,7 +192,7 @@ const GitCommitInfoGeneric = ({ } const renderWebhookTitle = () => - _webhookData.data.title ? {_webhookData.data.title} : null + _webhookData.data.title ? {_webhookData.data.title} : null const renderPullRequestId = (pullRequestUrl: string) => { const pullRequestId = pullRequestUrl.split('/').pop() @@ -228,7 +228,7 @@ const GitCommitInfoGeneric = ({ _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.MERGED && ( <> {renderPullRequestId(_webhookData.data['git url'])} -
+
{renderWebhookTitle()} {selectedCommitInfo ? (
diff --git a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx index bf1eaef44..c4db340a4 100644 --- a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx +++ b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx @@ -62,7 +62,7 @@ const MaterialHistory = ({ {dateKeys.map((date) => { const historyList = materialHistoryMapWithTime[date] return ( - <> +
{!isCommitInfoModal && (
{date} @@ -96,7 +96,7 @@ const MaterialHistory = ({
) })} - +
) })} From 96ddc7f59fe9ab412ef4c2a9e4d647c22b82c97e Mon Sep 17 00:00:00 2001 From: shivani170 Date: Tue, 22 Oct 2024 18:07:02 +0530 Subject: [PATCH 08/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- src/Common/Common.service.ts | 29 +++++++++++++---------------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 49904c6b1..0892335a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-3", + "version": "0.5.8-beta-4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-3", + "version": "0.5.8-beta-4", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 4320ade74..6cd6a7dee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.5.8-beta-3", + "version": "0.5.8-beta-4", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Common/Common.service.ts b/src/Common/Common.service.ts index fddf52533..c294997b1 100644 --- a/src/Common/Common.service.ts +++ b/src/Common/Common.service.ts @@ -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) => { @@ -512,21 +512,18 @@ export function getWebhookEventsForEventId(eventId: string | number) { 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 - - switch (true) { - case trimmedGitUrl.includes(GitProviderType.GITLAB): - return `${trimmedGitUrl}/-/tree/${branchName}` - case trimmedGitUrl.includes(GitProviderType.GITHUB): - return `${trimmedGitUrl}/tree/${branchName}` - case trimmedGitUrl.includes(GitProviderType.BITBUCKET): - return `${trimmedGitUrl}/branch/${branchName}` - case trimmedGitUrl.includes(GitProviderType.AZURE): - return `${trimmedGitUrl}/src/branch/${branchName}` - default: - return null - } -} \ No newline at end of file + 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 +} From 64e213cd0c672329a0dd4495b3afccc631607e98 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Mon, 4 Nov 2024 16:59:56 +0530 Subject: [PATCH 09/64] chore: hash icon added --- src/Assets/Icon/ic-hash.svg | 3 ++ .../GitCommitInfoGeneric.tsx | 41 ++++++++++--------- 2 files changed, 25 insertions(+), 19 deletions(-) create mode 100644 src/Assets/Icon/ic-hash.svg diff --git a/src/Assets/Icon/ic-hash.svg b/src/Assets/Icon/ic-hash.svg new file mode 100644 index 000000000..8220a82ae --- /dev/null +++ b/src/Assets/Icon/ic-hash.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index f0f0f82fc..4eaf1e83c 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -32,6 +32,7 @@ import { stopPropagation } from '@Common/Helper' import { DATE_TIME_FORMATS } from '@Common/Constants' import { ReactComponent as Tag } from '@Icons/ic-tag.svg' import { getLowerCaseObject, getWebhookDate } from '@Shared/Helpers' +import { ReactComponent as Hash } from '@Icons/ic-hash.svg' import GitMaterialInfoHeader from './GitMaterialInfoHeader' import { MATERIAL_EXCLUDE_TIPPY_TEXT } from '../../constants' import { WEBHOOK_EVENT_ACTION_TYPE } from './constants' @@ -64,25 +65,25 @@ const GitCommitInfoGeneric = ({ function renderBasicGitCommitInfoForWebhook() { const _date = getWebhookDate(materialSourceType, commitInfo) return ( - <> +
{_webhookData.data.author ? ( -
+
{_webhookData.data.author}
) : null} {_date ? ( -
+
) : null} {_webhookData.data.message ? ( -
+
{_webhookData.data.message}
) : null} - +
) } @@ -198,15 +199,17 @@ const GitCommitInfoGeneric = ({ const pullRequestId = pullRequestUrl.split('/').pop() return ( - - # {Number.isNaN(pullRequestId) ? 'PR' : pullRequestId} - + ) } @@ -226,9 +229,9 @@ const GitCommitInfoGeneric = ({ const renderPRInfoCard = () => _isWebhook && _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.MERGED && ( - <> +
{renderPullRequestId(_webhookData.data['git url'])} -
+
{renderWebhookTitle()} {selectedCommitInfo ? (
@@ -241,7 +244,7 @@ const GitCommitInfoGeneric = ({ ) : null}
-
+
Merge commit into  @@ -252,7 +255,7 @@ const GitCommitInfoGeneric = ({
{renderBasicGitCommitInfoForWebhook()} {handleMoreDataForWebhook()} - +
) const renderTagInfoCard = () => @@ -260,7 +263,7 @@ const GitCommitInfoGeneric = ({ _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.NON_MERGED && ( <>
-
+
{_webhookData.data['target checkout']}
From 3d74f3fd1e48ba013ec6897fcbc9f162a42224a7 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Tue, 5 Nov 2024 08:31:25 +0530 Subject: [PATCH 10/64] chore: version bump --- package-lock.json | 4 +- package.json | 2 +- .../GitCommitInfoGeneric.tsx | 51 +++++++++---------- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index a0026053e..988919486 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.4-beta-2", + "version": "0.6.4-beta-3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.4-beta-2", + "version": "0.6.4-beta-3", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 26250d588..9a0153d39 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.4-beta-2", + "version": "0.6.4-beta-3", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index 4eaf1e83c..900fdbaf1 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -62,10 +62,32 @@ const GitCommitInfoGeneric = ({ ? lowerCaseCommitInfo.commiturl : createGitCommitUrl(materialUrl, lowerCaseCommitInfo.commit) + const renderBranchName = (branchName: string) => + branchName ? ( + + {branchName} + + ) : null + function renderBasicGitCommitInfoForWebhook() { const _date = getWebhookDate(materialSourceType, commitInfo) return (
+
+ +
+ Merge commit into  + {renderBranchName(_webhookData.data['target branch name'])} +  from  + {renderBranchName(_webhookData.data['source branch name'])} +
+
{_webhookData.data.author ? (
{_webhookData.data.author} @@ -213,26 +235,12 @@ const GitCommitInfoGeneric = ({ ) } - const renderBranchName = (branchName: string) => - branchName ? ( - - {branchName} - - ) : null - const renderPRInfoCard = () => _isWebhook && _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.MERGED && ( -
- {renderPullRequestId(_webhookData.data['git url'])} +
- {renderWebhookTitle()} + {renderPullRequestId(_webhookData.data['git url'])} {selectedCommitInfo ? (
{lowerCaseCommitInfo.isselected ? ( @@ -243,16 +251,7 @@ const GitCommitInfoGeneric = ({
) : null}
- -
- -
- Merge commit into  - {renderBranchName(_webhookData.data['target branch name'])} -  from  - {renderBranchName(_webhookData.data['source branch name'])} -
-
+ {renderWebhookTitle()} {renderBasicGitCommitInfoForWebhook()} {handleMoreDataForWebhook()}
From f2ff26877459c9c6cfbb2b5582cbc0e8650b7022 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Tue, 5 Nov 2024 08:32:03 +0530 Subject: [PATCH 11/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 988919486..90c894d33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.4-beta-3", + "version": "0.6.4-beta-4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.4-beta-3", + "version": "0.6.4-beta-4", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 9a0153d39..539d3caa1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.4-beta-3", + "version": "0.6.4-beta-4", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From a80a176fdc5628bcffa532f09a429d49c71412a1 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:40:41 +0530 Subject: [PATCH 12/64] fix: payload for getPluginsDetails --- src/Common/Policy.Types.ts | 2 +- src/Shared/Components/Plugin/service.tsx | 21 +++++++++++++++------ src/Shared/Components/Plugin/types.ts | 10 +++++----- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/Common/Policy.Types.ts b/src/Common/Policy.Types.ts index b18617026..c3200e20c 100644 --- a/src/Common/Policy.Types.ts +++ b/src/Common/Policy.Types.ts @@ -95,7 +95,7 @@ export type ProcessPluginDataParamsType = { /** * Would be sent in case we have to get data for steps */ - requiredPluginIds?: PluginDetailPayloadType['pluginId'] + requiredPluginIds?: PluginDetailPayloadType['pluginIds'] } & (ProcessPluginDataCIParamsType | ProcessPluginDataCDParamsType) export enum ConsequenceAction { diff --git a/src/Shared/Components/Plugin/service.tsx b/src/Shared/Components/Plugin/service.tsx index 1dc8ae23f..4ce04b761 100644 --- a/src/Shared/Components/Plugin/service.tsx +++ b/src/Shared/Components/Plugin/service.tsx @@ -14,7 +14,15 @@ * limitations under the License. */ -import { get, getIsRequestAborted, getUrlWithSearchParams, ResponseType, ROUTES, showError } from '../../../Common' +import { + get, + getIsRequestAborted, + getUrlWithSearchParams, + post, + ResponseType, + ROUTES, + showError, +} from '../../../Common' import { stringComparatorBySortOrder } from '../../Helpers' import { GetParentPluginListPayloadType, @@ -41,13 +49,14 @@ export const getPluginsDetail = async ({ try { const payload: PluginDetailPayloadType = { appId, - parentPluginId: parentPluginIds, - pluginId: pluginIds, - parentPluginIdentifier: parentPluginIdentifiers ? `${parentPluginIdentifiers}` : null, + parentPluginIds, + pluginIds, + parentPluginIdentifiers, } - const { result } = await get( - getUrlWithSearchParams(ROUTES.PLUGIN_GLOBAL_LIST_DETAIL_V2, payload), + const { result } = await post( + ROUTES.PLUGIN_GLOBAL_LIST_DETAIL_V2, + payload, { signal }, ) diff --git a/src/Shared/Components/Plugin/types.ts b/src/Shared/Components/Plugin/types.ts index 972c2f8d2..cea743f08 100644 --- a/src/Shared/Components/Plugin/types.ts +++ b/src/Shared/Components/Plugin/types.ts @@ -94,11 +94,11 @@ export interface PluginDetailServiceParamsType { signal?: AbortSignal } -export interface PluginDetailPayloadType extends Pick { - pluginId?: PluginDetailServiceParamsType['pluginIds'] - parentPluginId?: PluginDetailServiceParamsType['parentPluginIds'] - parentPluginIdentifier?: PluginDetailServiceParamsType['parentPluginIdentifiers'][number] -} +export interface PluginDetailPayloadType + extends Pick< + PluginDetailServiceParamsType, + 'appId' | 'parentPluginIds' | 'pluginIds' | 'parentPluginIdentifiers' + > {} export interface PluginListFiltersType extends Pick, 'searchKey'> { selectedTags: string[] From 576353264b2c9cac5e292995c7864b06f5d4a604 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:06:59 +0530 Subject: [PATCH 13/64] chore: bump version to 0.6.4-beta-6 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 988919486..54b54a3aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.4-beta-3", + "version": "0.6.4-beta-6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.4-beta-3", + "version": "0.6.4-beta-6", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 9a0153d39..91bb140d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.4-beta-3", + "version": "0.6.4-beta-6", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 18d50f04fc9b67636b0d511cb6416aea7c636d97 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Wed, 6 Nov 2024 18:26:25 +0530 Subject: [PATCH 14/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- .../CICDHistory/CiPipelineSourceConfig.tsx | 15 +++------------ src/Shared/Components/CICDHistory/types.tsx | 12 ++++++++++++ .../GitCommitInfoGeneric/GitCommitInfoGeneric.tsx | 6 +++--- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4995bef46..1666d9d98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.5", + "version": "0.6.5-beta-1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.5", + "version": "0.6.5-beta-1", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 8b3b3cf5e..728a8b490 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.5", + "version": "0.6.5-beta-1", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx b/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx index 2aef84f47..2215ade6c 100644 --- a/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx +++ b/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx @@ -23,17 +23,7 @@ import branchIcon from '../../../Assets/Icon/ic-branch.svg' import { ReactComponent as Info } from '../../../Assets/Icon/ic-info-outlined.svg' import regexIcon from '../../../Assets/Icon/ic-regex.svg' import { buildHoverHtmlForWebhook } from './utils' - -export interface CIPipelineSourceConfigInterface { - sourceType - sourceValue - showTooltip?: boolean - showIcons?: boolean - baseText?: string - regex?: any - isRegex?: boolean - primaryBranchAfterRegex?: string -} +import { CIPipelineSourceConfigInterface } from './types' export const CiPipelineSourceConfig = ({ sourceType, @@ -44,6 +34,7 @@ export const CiPipelineSourceConfig = ({ regex, isRegex, primaryBranchAfterRegex, + rootClassName = '', }: CIPipelineSourceConfigInterface) => { const _isWebhook = sourceType === SourceTypeMap.WEBHOOK const _isRegex = sourceType === SourceTypeMap.BranchRegex || !!regex || isRegex @@ -133,7 +124,7 @@ export const CiPipelineSourceConfig = ({ const isRegexOrBranchIcon = _isRegex ? regexIcon : branchIcon return ( -
+
{loading && showIcons && loading} {!loading && (
diff --git a/src/Shared/Components/CICDHistory/types.tsx b/src/Shared/Components/CICDHistory/types.tsx index 7c5963fe0..441ff3693 100644 --- a/src/Shared/Components/CICDHistory/types.tsx +++ b/src/Shared/Components/CICDHistory/types.tsx @@ -791,3 +791,15 @@ export type CreateMarkupPropsType = export type TriggerHistoryFilterCriteriaType = `${string}|${string}|${string}`[] export const terminalStatus = new Set(['error', 'healthy', 'succeeded', 'cancelled', 'failed', 'aborted']) export const statusSet = new Set(['starting', 'running', 'pending']) + +export interface CIPipelineSourceConfigInterface { + sourceType + sourceValue + showTooltip?: boolean + showIcons?: boolean + baseText?: string + regex?: any + isRegex?: boolean + primaryBranchAfterRegex?: string + rootClassName?: string +} diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index 900fdbaf1..3077b0661 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -215,7 +215,7 @@ const GitCommitInfoGeneric = ({ } const renderWebhookTitle = () => - _webhookData.data.title ? {_webhookData.data.title} : null + _webhookData.data.title ? {_webhookData.data.title} : null const renderPullRequestId = (pullRequestUrl: string) => { const pullRequestId = pullRequestUrl.split('/').pop() @@ -244,9 +244,9 @@ const GitCommitInfoGeneric = ({ {selectedCommitInfo ? (
{lowerCaseCommitInfo.isselected ? ( - + ) : ( - + )}
) : null} From d9dcd5177649eb401de24afa11704e565fc37108 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Thu, 7 Nov 2024 14:02:01 +0530 Subject: [PATCH 15/64] chore: ui fixes for commint card in git info --- package-lock.json | 4 +-- package.json | 2 +- src/Assets/Icon/ic-pull-request.svg | 4 +-- src/Assets/Icon/ic-tag.svg | 5 ++- src/Common/Helper.tsx | 33 ++++++++++++++++++- .../CICDHistory/CiPipelineSourceConfig.tsx | 15 +++------ src/Shared/Components/CICDHistory/utils.tsx | 22 ++++++------- .../MaterialHistory.component.tsx | 4 +-- 8 files changed, 57 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1666d9d98..f0fa5cb0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.5-beta-1", + "version": "0.6.5-beta-3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.5-beta-1", + "version": "0.6.5-beta-3", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 728a8b490..d57bc2f32 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.5-beta-1", + "version": "0.6.5-beta-3", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Assets/Icon/ic-pull-request.svg b/src/Assets/Icon/ic-pull-request.svg index 9ba5cc629..695951ef5 100644 --- a/src/Assets/Icon/ic-pull-request.svg +++ b/src/Assets/Icon/ic-pull-request.svg @@ -14,6 +14,6 @@ - limitations under the License. --> - - + + \ No newline at end of file diff --git a/src/Assets/Icon/ic-tag.svg b/src/Assets/Icon/ic-tag.svg index f71d3f1f8..65b11a10d 100644 --- a/src/Assets/Icon/ic-tag.svg +++ b/src/Assets/Icon/ic-tag.svg @@ -14,7 +14,6 @@ - limitations under the License. --> - - - + + \ No newline at end of file diff --git a/src/Common/Helper.tsx b/src/Common/Helper.tsx index 2dc8692ea..7ec901d01 100644 --- a/src/Common/Helper.tsx +++ b/src/Common/Helper.tsx @@ -39,8 +39,15 @@ import { ToastManager, ToastVariantType, versionComparatorBySortOrder, + WebhookEventNameType, } from '../Shared' -import { ReactComponent as ArrowDown } from '../Assets/Icon/ic-chevron-down.svg' +import { ReactComponent as ArrowDown } from '@Icons/ic-chevron-down.svg' +import webhookIcon from '@Icons/ic-webhook.svg' +import branchIcon from '@Icons/ic-branch.svg' +import regexIcon from '@Icons/ic-regex.svg' +import pullRequest from '@Icons/ic-pull-request.svg' +import tagIcon from '@Icons/ic-tag.svg' +import { SourceTypeMap } from '@Common/Common.service' export function showError(serverError, showToastOnUnknownError = true, hideAccessError = false) { if (serverError instanceof ServerErrors && Array.isArray(serverError.errors)) { @@ -953,3 +960,27 @@ export const throttle = unknown>( } } } + + +/** + * + * @param sourceType - SourceTypeMap + * @param _isRegex - boolean + * @param webhookEventName - WebhookEventNameType + * @returns - Icon + */ +export const getBranchIcon = (sourceType, _isRegex?: boolean, webhookEventName?: string) => { + if (sourceType === SourceTypeMap.WEBHOOK && webhookEventName === WebhookEventNameType.PULL_REQUEST) { + return pullRequest + } + if (sourceType === SourceTypeMap.WEBHOOK && webhookEventName === WebhookEventNameType.TAG_CREATION) { + return tagIcon + } + if (sourceType === SourceTypeMap.WEBHOOK) { + return webhookIcon + } + if (sourceType === SourceTypeMap.BranchRegex || _isRegex) { + return regexIcon + } + return branchIcon +} diff --git a/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx b/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx index 2215ade6c..5d55a79bd 100644 --- a/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx +++ b/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx @@ -16,12 +16,9 @@ import { useState, useEffect, ReactNode } from 'react' import Tippy from '@tippyjs/react' -import { getWebhookEventsForEventId, SourceTypeMap } from '../../../Common' +import { ReactComponent as Info } from '@Icons/ic-info-outlined.svg' +import { getBranchIcon, getWebhookEventsForEventId, SourceTypeMap } from '../../../Common' import { GIT_BRANCH_NOT_CONFIGURED, DEFAULT_GIT_BRANCH_VALUE } from './constants' -import webhookIcon from '../../../Assets/Icon/ic-webhook.svg' -import branchIcon from '../../../Assets/Icon/ic-branch.svg' -import { ReactComponent as Info } from '../../../Assets/Icon/ic-info-outlined.svg' -import regexIcon from '../../../Assets/Icon/ic-regex.svg' import { buildHoverHtmlForWebhook } from './utils' import { CIPipelineSourceConfigInterface } from './types' @@ -39,7 +36,7 @@ export const CiPipelineSourceConfig = ({ const _isWebhook = sourceType === SourceTypeMap.WEBHOOK const _isRegex = sourceType === SourceTypeMap.BranchRegex || !!regex || isRegex - const [sourceValueBase, setSourceValueBase] = useState('') + const [sourceValueBase, setSourceValueBase] = useState('') const [sourceValueAdv, setSourceValueAdv] = useState('') const [loading, setLoading] = useState(!!_isWebhook) @@ -88,7 +85,7 @@ export const CiPipelineSourceConfig = ({ )} ) - // for non webhook case, data is already set in use state initialisation + // for non webhook case, data is already set in use state initialization function _init() { if (!_isWebhook) { return @@ -121,8 +118,6 @@ export const CiPipelineSourceConfig = ({ regexTippyContent() }, []) - const isRegexOrBranchIcon = _isRegex ? regexIcon : branchIcon - return (
{loading && showIcons && loading} @@ -130,7 +125,7 @@ export const CiPipelineSourceConfig = ({
{showIcons && ( branch diff --git a/src/Shared/Components/CICDHistory/utils.tsx b/src/Shared/Components/CICDHistory/utils.tsx index ab92dab69..69cf27a64 100644 --- a/src/Shared/Components/CICDHistory/utils.tsx +++ b/src/Shared/Components/CICDHistory/utils.tsx @@ -16,6 +16,17 @@ import { TIMELINE_STATUS } from '@Shared/constants' import { ReactComponent as ICAborted } from '@Icons/ic-aborted.svg' import { ReactComponent as ICErrorCross } from '@Icons/ic-error-cross.svg' +import { ReactComponent as Close } from '@Icons/ic-close.svg' +import { ReactComponent as Check } from '@Icons/ic-check-grey.svg' +import { ReactComponent as ICHelpOutline } from '@Icons/ic-help-outline.svg' +import { ReactComponent as Error } from '@Icons/ic-error-exclamation.svg' +import { ReactComponent as Timer } from '@Icons/ic-timer.svg' +import { ReactComponent as Disconnect } from '@Icons/ic-disconnected.svg' +import { ReactComponent as TimeOut } from '@Icons/ic-timeout-red.svg' +import { ReactComponent as ICCheck } from '@Icons/ic-check.svg' +import { ReactComponent as ICInProgress } from '@Icons/ic-in-progress.svg' +import { TERMINAL_STATUS_MAP } from './constants' +import { ResourceKindType } from '../../types' import { TriggerHistoryFilterCriteriaProps, DeploymentHistoryResultObject, @@ -23,17 +34,6 @@ import { TriggerHistoryFilterCriteriaType, StageStatusType, } from './types' -import { ResourceKindType } from '../../types' -import { ReactComponent as Close } from '../../../Assets/Icon/ic-close.svg' -import { ReactComponent as Check } from '../../../Assets/Icon/ic-check-grey.svg' -import { ReactComponent as ICHelpOutline } from '../../../Assets/Icon/ic-help-outline.svg' -import { ReactComponent as Error } from '../../../Assets/Icon/ic-error-exclamation.svg' -import { ReactComponent as Timer } from '../../../Assets/Icon/ic-timer.svg' -import { ReactComponent as Disconnect } from '../../../Assets/Icon/ic-disconnected.svg' -import { ReactComponent as TimeOut } from '../../../Assets/Icon/ic-timeout-red.svg' -import { ReactComponent as ICCheck } from '../../../Assets/Icon/ic-check.svg' -import { ReactComponent as ICInProgress } from '../../../Assets/Icon/ic-in-progress.svg' -import { TERMINAL_STATUS_MAP } from './constants' export const getTriggerHistoryFilterCriteria = ({ appId, diff --git a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx index c4db340a4..6a927a19e 100644 --- a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx +++ b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx @@ -58,7 +58,7 @@ const MaterialHistory = ({ return ( // added for consistent typing // eslint-disable-next-line react/jsx-no-useless-fragment - <> +
{dateKeys.map((date) => { const historyList = materialHistoryMapWithTime[date] return ( @@ -99,7 +99,7 @@ const MaterialHistory = ({
) })} - +
) } export default MaterialHistory From 36f3a51fec22535fee658bd99b094edb90f018d2 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Thu, 7 Nov 2024 14:06:05 +0530 Subject: [PATCH 16/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f0fa5cb0d..ecaf8ca92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.5-beta-3", + "version": "0.6.5-beta-4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.5-beta-3", + "version": "0.6.5-beta-4", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index d57bc2f32..4b899fb43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.6.5-beta-3", + "version": "0.6.5-beta-4", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 212190e41e3c5895fbed64f17503442e8f6095b2 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Fri, 8 Nov 2024 13:43:35 +0530 Subject: [PATCH 17/64] chore: code refactoring --- .../GitCommitInfoGeneric.tsx | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index 3077b0661..a186726a8 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -235,21 +235,30 @@ const GitCommitInfoGeneric = ({ ) } + const renderTagCreationId = ( +
+ + {_webhookData.data['target checkout']} +
+ ) + + const getCheckUncheckIcon = () => { + if (selectedCommitInfo) { + if (lowerCaseCommitInfo.isselected) { + return + } + return + } + return null + } + const renderPRInfoCard = () => _isWebhook && _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.MERGED && (
{renderPullRequestId(_webhookData.data['git url'])} - {selectedCommitInfo ? ( -
- {lowerCaseCommitInfo.isselected ? ( - - ) : ( - - )} -
- ) : null} + {getCheckUncheckIcon()}
{renderWebhookTitle()} {renderBasicGitCommitInfoForWebhook()} @@ -262,15 +271,8 @@ const GitCommitInfoGeneric = ({ _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.NON_MERGED && ( <>
-
- - {_webhookData.data['target checkout']} -
- {selectedCommitInfo ? ( -
- {lowerCaseCommitInfo.isselected ? : 'Select'} -
- ) : null} + {renderTagCreationId} + {getCheckUncheckIcon()}
{renderBasicGitCommitInfoForWebhook()} {handleMoreDataForWebhook()} From 378bae3b8a7cdd8fab715a7b4ca2ccf542971362 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Fri, 8 Nov 2024 16:57:18 +0530 Subject: [PATCH 18/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- src/Common/Helper.tsx | 19 +++++++++++-------- .../GitCommitInfoGeneric.tsx | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index b9bd58d9d..c95324500 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.7.2", + "version": "0.7.2-beta-1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.7.2", + "version": "0.7.2-beta-1", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index d7c35af4f..133cb0153 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.7.2", + "version": "0.7.2-beta-1", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Common/Helper.tsx b/src/Common/Helper.tsx index 7ec901d01..bdd6765c3 100644 --- a/src/Common/Helper.tsx +++ b/src/Common/Helper.tsx @@ -649,7 +649,11 @@ export const powerSetOfSubstringsFromStart = (strings: string[], regex: RegExp) return _keys }) -export const convertJSONPointerToJSONPath = (pointer: string) => pointer.replace(/\/([\*0-9]+)\//g, '[$1].').replace(/\//g, '.').replace(/\./, '$.') +export const convertJSONPointerToJSONPath = (pointer: string) => + pointer + .replace(/\/([\*0-9]+)\//g, '[$1].') + .replace(/\//g, '.') + .replace(/\./, '$.') export const flatMapOfJSONPaths = ( paths: string[], @@ -961,7 +965,6 @@ export const throttle = unknown>( } } - /** * * @param sourceType - SourceTypeMap @@ -970,13 +973,13 @@ export const throttle = unknown>( * @returns - Icon */ export const getBranchIcon = (sourceType, _isRegex?: boolean, webhookEventName?: string) => { - if (sourceType === SourceTypeMap.WEBHOOK && webhookEventName === WebhookEventNameType.PULL_REQUEST) { - return pullRequest - } - if (sourceType === SourceTypeMap.WEBHOOK && webhookEventName === WebhookEventNameType.TAG_CREATION) { - return tagIcon - } if (sourceType === SourceTypeMap.WEBHOOK) { + if (webhookEventName === WebhookEventNameType.PULL_REQUEST) { + return pullRequest + } + if (webhookEventName === WebhookEventNameType.TAG_CREATION) { + return tagIcon + } return webhookIcon } if (sourceType === SourceTypeMap.BranchRegex || _isRegex) { diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index a186726a8..0f3a8dcbc 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -235,7 +235,7 @@ const GitCommitInfoGeneric = ({ ) } - const renderTagCreationId = ( + const renderTagCreationId = () => (
{_webhookData.data['target checkout']} @@ -271,7 +271,7 @@ const GitCommitInfoGeneric = ({ _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.NON_MERGED && ( <>
- {renderTagCreationId} + {renderTagCreationId()} {getCheckUncheckIcon()}
{renderBasicGitCommitInfoForWebhook()} From 119132989ded09bb3f9dbd0c75b2986d279c0b3d Mon Sep 17 00:00:00 2001 From: shivani170 Date: Mon, 11 Nov 2024 12:59:17 +0530 Subject: [PATCH 19/64] chore: overflow-issue fix --- src/Common/Common.service.ts | 2 +- src/Shared/Components/CICDHistory/types.tsx | 4 ++-- .../MaterialHistory/MaterialHistory.component.tsx | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Common/Common.service.ts b/src/Common/Common.service.ts index c294997b1..33fe5796a 100644 --- a/src/Common/Common.service.ts +++ b/src/Common/Common.service.ts @@ -513,7 +513,7 @@ export function getWebhookEventsForEventId(eventId: string | number) { } /** - * + * * @param gitUrl Git URL of the repository * @param branchName Branch name * @returns URL to the branch in the Git repository diff --git a/src/Shared/Components/CICDHistory/types.tsx b/src/Shared/Components/CICDHistory/types.tsx index 441ff3693..ea6bb5936 100644 --- a/src/Shared/Components/CICDHistory/types.tsx +++ b/src/Shared/Components/CICDHistory/types.tsx @@ -793,8 +793,8 @@ export const terminalStatus = new Set(['error', 'healthy', 'succeeded', 'cancell export const statusSet = new Set(['starting', 'running', 'pending']) export interface CIPipelineSourceConfigInterface { - sourceType - sourceValue + sourceType: string + sourceValue: any // TODO: need to make source value consistent showTooltip?: boolean showIcons?: boolean baseText?: string diff --git a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx index 6a927a19e..3d7c84b2c 100644 --- a/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx +++ b/src/Shared/Components/MaterialHistory/MaterialHistory.component.tsx @@ -58,11 +58,11 @@ const MaterialHistory = ({ return ( // added for consistent typing // eslint-disable-next-line react/jsx-no-useless-fragment -
+
{dateKeys.map((date) => { const historyList = materialHistoryMapWithTime[date] return ( -
+ <> {!isCommitInfoModal && (
{date} @@ -96,7 +96,7 @@ const MaterialHistory = ({
) })} -
+ ) })}
From 47039cce65d1178adc20038290a3b74689fb6d19 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Mon, 11 Nov 2024 14:01:00 +0530 Subject: [PATCH 20/64] version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c95324500..61f3efff0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.7.2-beta-1", + "version": "0.7.2-beta-2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.7.2-beta-1", + "version": "0.7.2-beta-2", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 133cb0153..2846fc2ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.7.2-beta-1", + "version": "0.7.2-beta-2", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 046e89358ea88eaa2dbaf79f456946f7cdbcbf20 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Tue, 12 Nov 2024 16:18:52 +0530 Subject: [PATCH 21/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5e5109233..5d271558a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.7.3-beta-1", + "version": "0.7.3-beta-3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.7.3-beta-1", + "version": "0.7.3-beta-3", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 72054132a..2186f6c5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.7.3-beta-1", + "version": "0.7.3-beta-3", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 6251625ab6fcc396f1688111a8946df5a590613b Mon Sep 17 00:00:00 2001 From: shivani170 Date: Tue, 12 Nov 2024 17:50:17 +0530 Subject: [PATCH 22/64] chore: copy icon added in pr tag --- src/Common/Common.service.ts | 2 +- src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx | 4 +--- .../Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx | 5 ++++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Common/Common.service.ts b/src/Common/Common.service.ts index 33fe5796a..9971fc321 100644 --- a/src/Common/Common.service.ts +++ b/src/Common/Common.service.ts @@ -520,7 +520,7 @@ export function getWebhookEventsForEventId(eventId: string | number) { */ export const getGitBranchUrl = (gitUrl: string, branchName: string): string | null => { if (!gitUrl) return null - const trimmedGitUrl = gitUrl.trim().replace(/\/$/, '') // Remove any trailing slash + const trimmedGitUrl = gitUrl.trim().replace('.git', '').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}` diff --git a/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx b/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx index 5d55a79bd..939c5c976 100644 --- a/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx +++ b/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx @@ -156,9 +156,7 @@ export const CiPipelineSourceConfig = ({ )} {baseText && ( - - {baseText} - + {baseText} )}
diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index 0f3a8dcbc..86fdf9db4 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -221,7 +221,7 @@ const GitCommitInfoGeneric = ({ const pullRequestId = pullRequestUrl.split('/').pop() return ( -
+ ) } From 51f0f4156a290a628b649b86691d1a3fe15ceaa6 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Tue, 12 Nov 2024 17:58:35 +0530 Subject: [PATCH 23/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5d271558a..ccf05b513 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.7.3-beta-3", + "version": "0.7.3-beta-5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.7.3-beta-3", + "version": "0.7.3-beta-5", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 2186f6c5e..e9ab7d08f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "0.7.3-beta-3", + "version": "0.7.3-beta-5", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 9dbcdc1b1bc3578273f880ba955c9c037883a1ea Mon Sep 17 00:00:00 2001 From: shivani170 Date: Wed, 13 Nov 2024 12:33:43 +0530 Subject: [PATCH 24/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- .../Components/CICDHistory/CiPipelineSourceConfig.tsx | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9ccbc5bd8..f1f131b12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.3-beta-1", + "version": "1.0.3-beta-3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.3-beta-1", + "version": "1.0.3-beta-3", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 154b081ec..fc8e8f529 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.3-beta-1", + "version": "1.0.3-beta-3", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx b/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx index 939c5c976..a5f42a03f 100644 --- a/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx +++ b/src/Shared/Components/CICDHistory/CiPipelineSourceConfig.tsx @@ -119,7 +119,7 @@ export const CiPipelineSourceConfig = ({ }, []) return ( -
+
{loading && showIcons && loading} {!loading && (
@@ -156,7 +156,9 @@ export const CiPipelineSourceConfig = ({ )} {baseText && ( - {baseText} + + {baseText} + )}
From 31a7d7bb833546a1d29338b4f2fe42c6fc09721e Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:39:52 +0530 Subject: [PATCH 25/64] fix: dirty set for local storage in useUrlFilters --- src/Common/Hooks/useUrlFilters/useUrlFilters.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Common/Hooks/useUrlFilters/useUrlFilters.ts b/src/Common/Hooks/useUrlFilters/useUrlFilters.ts index 6abb0a39e..7fa26fc27 100644 --- a/src/Common/Hooks/useUrlFilters/useUrlFilters.ts +++ b/src/Common/Hooks/useUrlFilters/useUrlFilters.ts @@ -163,7 +163,7 @@ const useUrlFilters = ({ useEffect(() => { // if we have search string, set secondary params in local storage accordingly if (location.search) { - localStorage.setItem(localStorageKey, JSON.stringify(parsedParams)) + setItemInLocalStorageIfKeyExists(localStorageKey, JSON.stringify(parsedParams)) return } const localStorageValue = localStorage.getItem(localStorageKey) From b0da38b031f1af75670536511a9cb9f589eb5a7f Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:52:06 +0530 Subject: [PATCH 26/64] feat: add type for switchedFromTabId --- src/Shared/types.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Shared/types.ts b/src/Shared/types.ts index b6133017c..64b53c305 100644 --- a/src/Shared/types.ts +++ b/src/Shared/types.ts @@ -780,4 +780,8 @@ export interface InitTabType extends CommonTabArgsType { export interface DynamicTabType extends CommonTabArgsType { id: string + /** + * Id of the tab from which the current tab is opened + */ + switchedFromTabId: string | null } From 8ff3a53bd4309eaa40981a36fd073a12430141ff Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:24:03 +0530 Subject: [PATCH 27/64] feat: add shouldRemainMounted prop --- src/Shared/types.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Shared/types.ts b/src/Shared/types.ts index 64b53c305..8cd3496eb 100644 --- a/src/Shared/types.ts +++ b/src/Shared/types.ts @@ -772,6 +772,14 @@ interface CommonTabArgsType { value: string }[] } + /** + * If true, the fixed tab remains mounted on initial load of the component + * + * Note: Not for dynamic tabs atm + * + * @default false + */ + shouldRemainMounted?: boolean } export interface InitTabType extends CommonTabArgsType { From a7c43d737000071ebe01efb26dec7a37813988e2 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Thu, 14 Nov 2024 17:17:33 +0530 Subject: [PATCH 28/64] fix: rename switchedFromTabId to lastActiveTabId --- src/Shared/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shared/types.ts b/src/Shared/types.ts index 8cd3496eb..8ad033743 100644 --- a/src/Shared/types.ts +++ b/src/Shared/types.ts @@ -791,5 +791,5 @@ export interface DynamicTabType extends CommonTabArgsType { /** * Id of the tab from which the current tab is opened */ - switchedFromTabId: string | null + lastActiveTabId: string | null } From dd84db66ff5964d254b96ec1f09d6761fa87fb42 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Thu, 14 Nov 2024 17:38:49 +0530 Subject: [PATCH 29/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- .../GitCommitInfoGeneric.tsx | 22 ++++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index f3e44d5d1..0a508afe8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4-beta-1", + "version": "1.0.4-beta-2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4-beta-1", + "version": "1.0.4-beta-2", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 8277ce163..ac7d586d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4-beta-1", + "version": "1.0.4-beta-2", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index 86fdf9db4..50de4ee49 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -75,19 +75,21 @@ const GitCommitInfoGeneric = ({ ) : null - function renderBasicGitCommitInfoForWebhook() { + function renderBasicGitCommitInfoForWebhook(isPRWebhook?: boolean) { const _date = getWebhookDate(materialSourceType, commitInfo) return (
-
- -
- Merge commit into  - {renderBranchName(_webhookData.data['target branch name'])} -  from  - {renderBranchName(_webhookData.data['source branch name'])} + {isPRWebhook ? ( +
+ +
+ Merge commit into  + {renderBranchName(_webhookData.data['target branch name'])} +  from  + {renderBranchName(_webhookData.data['source branch name'])} +
-
+ ) : null} {_webhookData.data.author ? (
{_webhookData.data.author} @@ -264,7 +266,7 @@ const GitCommitInfoGeneric = ({ {getCheckUncheckIcon()}
{renderWebhookTitle()} - {renderBasicGitCommitInfoForWebhook()} + {renderBasicGitCommitInfoForWebhook(true)} {handleMoreDataForWebhook()}
) From c213386be55ef453f0099236e4790feeef512d57 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Thu, 14 Nov 2024 17:48:26 +0530 Subject: [PATCH 30/64] chore: bump version to 1.0.4-beta-2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0f0db43f0..0a508afe8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4", + "version": "1.0.4-beta-2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4", + "version": "1.0.4-beta-2", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 47a779d86..ac7d586d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4", + "version": "1.0.4-beta-2", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 65e2cb9cba551a82ebed1ac60d27737218255f00 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Thu, 14 Nov 2024 18:02:22 +0530 Subject: [PATCH 31/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0a508afe8..fe6b1f65b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4-beta-2", + "version": "1.0.4-beta-3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4-beta-2", + "version": "1.0.4-beta-3", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index ac7d586d4..68365bfb9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4-beta-2", + "version": "1.0.4-beta-3", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 60ddc72a394e24ed90970ab4238909d81039f0dd Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Thu, 14 Nov 2024 18:51:53 +0530 Subject: [PATCH 32/64] fix: remove short circuit in clipboard button --- package-lock.json | 4 ++-- package.json | 2 +- src/Common/ClipboardButton/ClipboardButton.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0f0db43f0..6ee52b623 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4", + "version": "1.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4", + "version": "1.0.5", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 47a779d86..665da0431 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4", + "version": "1.0.5", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Common/ClipboardButton/ClipboardButton.tsx b/src/Common/ClipboardButton/ClipboardButton.tsx index 878b55a77..e7449b5d9 100644 --- a/src/Common/ClipboardButton/ClipboardButton.tsx +++ b/src/Common/ClipboardButton/ClipboardButton.tsx @@ -88,7 +88,7 @@ export default function ClipboardButton({ className={`dc__outline-none-imp p-0 flex dc__transparent--unstyled dc__no-border ${rootClassName}`} onMouseEnter={handleEnableTippy} onMouseLeave={handleDisableTippy} - onClick={isTriggerUndefined && handleCopyContent} + onClick={isTriggerUndefined ? handleCopyContent : noop} > {copied ? : } From fb64cd3f6db818895f2459d3b71276bcc218328c Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Thu, 14 Nov 2024 18:59:44 +0530 Subject: [PATCH 33/64] feat: add support for abortControllerRef and deprecate signal --- package-lock.json | 4 ++-- package.json | 2 +- src/Common/Api.ts | 17 ++++++++++++++--- src/Common/Types.ts | 8 ++++++-- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0a508afe8..1a626b16b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4-beta-2", + "version": "1.0.4-beta-4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4-beta-2", + "version": "1.0.4-beta-4", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index ac7d586d4..3ace6058e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4-beta-2", + "version": "1.0.4-beta-4", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Common/Api.ts b/src/Common/Api.ts index 485d07f9c..1e1985c8b 100644 --- a/src/Common/Api.ts +++ b/src/Common/Api.ts @@ -192,14 +192,18 @@ function fetchInTime( options?: APIOptions, isMultipartRequest?: boolean, ): Promise { - const controller = new AbortController() - const { signal } = controller + const controller = options?.abortControllerRef?.current ?? new AbortController() + const signal = options?.abortControllerRef?.current?.signal || options?.signal || controller.signal const timeoutPromise: Promise = new Promise((resolve, reject) => { const requestTimeout = (window as any)?._env_?.GLOBAL_API_TIMEOUT || FALLBACK_REQUEST_TIMEOUT const timeout = options?.timeout ? options.timeout : requestTimeout setTimeout(() => { controller.abort() + if (options?.abortControllerRef?.current) { + options.abortControllerRef.current = new AbortController() + } + reject({ code: 408, errors: [{ code: 408, internalMessage: 'Request cancelled', userMessage: 'Request Cancelled' }], @@ -207,7 +211,14 @@ function fetchInTime( }, timeout) }) return Promise.race([ - fetchAPI(url, type, data, options?.signal || signal, options?.preventAutoLogout || false, isMultipartRequest), + fetchAPI( + url, + type, + data, + signal, + options?.preventAutoLogout || false, + isMultipartRequest, + ), timeoutPromise, ]).catch((err) => { if (err instanceof ServerErrors) { diff --git a/src/Common/Types.ts b/src/Common/Types.ts index fbf837099..6071e8c4e 100644 --- a/src/Common/Types.ts +++ b/src/Common/Types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import React, { ReactNode, CSSProperties, ReactElement } from 'react' +import React, { ReactNode, CSSProperties, ReactElement, MutableRefObject } from 'react' import { Placement } from 'tippy.js' import { UserGroupDTO } from '@Pages/GlobalConfigurations' import { ImageComment, ReleaseTag } from './ImageTags.Types' @@ -50,7 +50,11 @@ export interface ResponseType { export interface APIOptions { timeout?: number + /** + * @deprecated Use abortController instead + */ signal?: AbortSignal + abortControllerRef?: MutableRefObject preventAutoLogout?: boolean } @@ -1007,4 +1011,4 @@ export interface WidgetEventDetails { count: number age: string lastSeen: string -} \ No newline at end of file +} From 72c2177408fad692524e66bf65d31cc4094f7ee8 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Fri, 15 Nov 2024 00:24:17 +0530 Subject: [PATCH 34/64] feat: extend support for tab type in InitTabType --- src/Shared/types.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Shared/types.ts b/src/Shared/types.ts index 8ad033743..03657e278 100644 --- a/src/Shared/types.ts +++ b/src/Shared/types.ts @@ -754,7 +754,7 @@ interface CommonTabArgsType { isSelected: boolean title?: string isDeleted?: boolean - position: number + type: 'fixed' | 'dynamic' iconPath?: string dynamicTitle?: string showNameOnSelect?: boolean @@ -782,9 +782,19 @@ interface CommonTabArgsType { shouldRemainMounted?: boolean } -export interface InitTabType extends CommonTabArgsType { - idPrefix: string -} +export type InitTabType = Omit & + ( + | { + type: 'fixed' + id: string + idPrefix?: never + } + | { + type: 'dynamic' + id?: never + idPrefix: string + } + ) export interface DynamicTabType extends CommonTabArgsType { id: string From ecbd2f1b77b2cbc619fc6ba9b7de5522e8fdd011 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:55:50 +0530 Subject: [PATCH 35/64] chore: bump version --- package-lock.json | 4 ++-- package.json | 2 +- src/Shared/types.ts | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1a626b16b..f7a9f6aea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4-beta-4", + "version": "1.0.4-beta-5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4-beta-4", + "version": "1.0.4-beta-5", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 3ace6058e..8725ee36b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.4-beta-4", + "version": "1.0.4-beta-5", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Shared/types.ts b/src/Shared/types.ts index 03657e278..4dc30b97f 100644 --- a/src/Shared/types.ts +++ b/src/Shared/types.ts @@ -786,6 +786,11 @@ export type InitTabType = Omit & ( | { type: 'fixed' + /** + * Unique identifier for the fixed tab + * + * Note: Shouldn't contain '-' + */ id: string idPrefix?: never } @@ -799,7 +804,7 @@ export type InitTabType = Omit & export interface DynamicTabType extends CommonTabArgsType { id: string /** - * Id of the tab from which the current tab is opened + * Id of the last active tab before switching to current tab */ lastActiveTabId: string | null } From a740210a627729b723b44e86f3c5b274199c0772 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Fri, 15 Nov 2024 13:53:24 +0530 Subject: [PATCH 36/64] chore: removed see more see less view in info card --- .../GitCommitInfoGeneric.tsx | 87 +------------------ 1 file changed, 4 insertions(+), 83 deletions(-) diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index 50de4ee49..47d1ba238 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -15,7 +15,6 @@ */ /* eslint-disable eqeqeq */ -import { useState } from 'react' import moment from 'moment' import Tippy from '@tippyjs/react' import ClipboardButton from '@Common/ClipboardButton/ClipboardButton' @@ -48,8 +47,6 @@ const GitCommitInfoGeneric = ({ index, isExcluded = false, }: GitCommitInfoGenericProps) => { - const [showSeeMore, setShowSeeMore] = useState(true) - const lowerCaseCommitInfo = getLowerCaseObject(commitInfo) const _isWebhook = materialSourceType === SourceTypeMap.WEBHOOK || @@ -111,80 +108,6 @@ const GitCommitInfoGeneric = ({ ) } - function renderMoreDataForWebhook(_moreData) { - return !showSeeMore ? ( -
-
- {Object.keys(_moreData).map((_key, idx) => { - let classes - if (idx % 2 == 0) { - classes = 'bcn-1' - } - return ( -
-
{_key}
-
{_moreData[_key]}
-
- ) - })} -
-
- ) : null - } - - function renderSeeMoreButtonForWebhook() { - return ( - - ) - } - - function handleMoreDataForWebhook() { - const _moreData = {} - if (_webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.MERGED) { - Object.keys(_webhookData.data).forEach((_key) => { - if ( - _key != 'author' && - _key != 'date' && - _key != 'git url' && - _key != 'source branch name' && - _key != 'source checkout' && - _key != 'target branch name' && - _key != 'target checkout' && - _key != 'title' - ) { - _moreData[_key] = _webhookData.data[_key] - } - }) - } else if (_webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.NON_MERGED) { - Object.keys(_webhookData.data).forEach((_key) => { - if (_key !== 'author' && _key !== 'date' && _key !== 'target checkout') { - _moreData[_key] = _webhookData.data[_key] - } - }) - } - - const _hasMoreData = Object.keys(_moreData).length > 0 - - return ( - <> - {_hasMoreData && renderMoreDataForWebhook(_moreData)} - {_hasMoreData && renderSeeMoreButtonForWebhook()} - - ) - } - const matSelectionText = (): JSX.Element => { if (isExcluded) { return ( @@ -220,7 +143,7 @@ const GitCommitInfoGeneric = ({ _webhookData.data.title ? {_webhookData.data.title} : null const renderPullRequestId = (pullRequestUrl: string) => { - const pullRequestId = pullRequestUrl.split('/').pop() + const pullRequestId = pullRequestUrl?.split('/').pop() return (
@@ -240,10 +163,10 @@ const GitCommitInfoGeneric = ({ ) } - const renderTagCreationId = () => ( + const renderTagCreationId = (tagRequestUrl: string) => (
- {_webhookData.data['target checkout']} + {tagRequestUrl}
) @@ -267,7 +190,6 @@ const GitCommitInfoGeneric = ({
{renderWebhookTitle()} {renderBasicGitCommitInfoForWebhook(true)} - {handleMoreDataForWebhook()}
) @@ -276,11 +198,10 @@ const GitCommitInfoGeneric = ({ _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.NON_MERGED && ( <>
- {renderTagCreationId()} + {renderTagCreationId(_webhookData.data['target checkout'])} {getCheckUncheckIcon()}
{renderBasicGitCommitInfoForWebhook()} - {handleMoreDataForWebhook()} ) From 0d8767a991368eb3fecf680b8b8617430f088135 Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Fri, 15 Nov 2024 16:21:33 +0530 Subject: [PATCH 37/64] fix!: unable to copy from safari in clipboard button --- .../ClipboardButton/ClipboardButton.tsx | 98 +++++++++++-------- src/Common/ClipboardButton/types.ts | 3 +- src/Common/Helper.tsx | 52 +++++----- 3 files changed, 86 insertions(+), 67 deletions(-) diff --git a/src/Common/ClipboardButton/ClipboardButton.tsx b/src/Common/ClipboardButton/ClipboardButton.tsx index e7449b5d9..411b201d1 100644 --- a/src/Common/ClipboardButton/ClipboardButton.tsx +++ b/src/Common/ClipboardButton/ClipboardButton.tsx @@ -14,9 +14,9 @@ * limitations under the License. */ -import { useState, useEffect, useCallback } from 'react' -import Tippy from '@tippyjs/react' +import { useState, useEffect, useRef } from 'react' import { copyToClipboard, noop, stopPropagation } from '../Helper' +import Tooltip from '@Common/Tooltip/Tooltip' import ClipboardProps from './types' import { ReactComponent as ICCopy } from '../../Assets/Icon/ic-copy.svg' import { ReactComponent as Check } from '../../Assets/Icon/ic-check.svg' @@ -25,8 +25,7 @@ import { ReactComponent as Check } from '../../Assets/Icon/ic-check.svg' * @param content - Content to be copied * @param copiedTippyText - Text to be shown in the tippy when the content is copied, default 'Copied!' * @param duration - Duration for which the tippy should be shown, default 1000 - * @param trigger - To trigger the copy action outside the button, if set to true the content will be copied, use case being triggering the copy action from outside the component - * @param setTrigger - Callback function to set the trigger outside the button + * @param copyToClipboardPromise - the promise returned by copyToClipboard util function * @param rootClassName - additional classes to add to button * @param iconSize - size of svg icon to be shown, default 16 (icon-dim-16) */ @@ -34,64 +33,79 @@ export default function ClipboardButton({ content, copiedTippyText = 'Copied!', duration = 1000, - trigger, - setTrigger = noop, + copyToClipboardPromise, rootClassName = '', iconSize = 16, }: ClipboardProps) { const [copied, setCopied] = useState(false) - const [enableTippy, setEnableTippy] = useState(false) + const setCopiedFalseTimeoutRef = useRef>(-1) - const handleTextCopied = () => { + const handleTriggerCopy = () => { setCopied(true) + + setCopiedFalseTimeoutRef.current = setTimeout(() => { + setCopied(false) + + setCopiedFalseTimeoutRef.current = -1 + }, duration) } - const isTriggerUndefined = typeof trigger === 'undefined' - const handleEnableTippy = () => setEnableTippy(true) - const handleDisableTippy = () => setEnableTippy(false) - const handleCopyContent = useCallback( - (e?) => { - if (e) stopPropagation(e) - copyToClipboard(content, handleTextCopied) - }, - [content], - ) - const iconClassName = `icon-dim-${iconSize} dc__no-shrink` + const handleAwaitCopyToClipboardPromise = async (shouldRunCopy?: boolean) => { + try { + if (shouldRunCopy) { + await copyToClipboard(content) + } else { + await copyToClipboardPromise + } - useEffect(() => { - if (!copied) return + handleTriggerCopy() + } catch { + noop() + } + } - const timeout = setTimeout(() => { - setCopied(false) - setTrigger(false) - }, duration) + const handleCopyContent = async (e?: React.MouseEvent) => { + if (e) { + stopPropagation(e) + } + + await handleAwaitCopyToClipboardPromise(true) + } + + useEffect(() => { + if (!copyToClipboardPromise) { + return + } - return () => clearTimeout(timeout) - }, [copied, duration, setTrigger]) + handleAwaitCopyToClipboardPromise().catch(noop) + }, [copyToClipboardPromise]) useEffect(() => { - if (!isTriggerUndefined && trigger) { - setCopied(true) - handleCopyContent() + return () => { + if (setCopiedFalseTimeoutRef.current > -1) { + clearTimeout(setCopiedFalseTimeoutRef.current) + } } - }, [trigger, handleCopyContent]) + }, []) + + const iconClassName = `icon-dim-${iconSize} dc__no-shrink` + return ( - - + ) } diff --git a/src/Common/ClipboardButton/types.ts b/src/Common/ClipboardButton/types.ts index 94eb73554..c8f02c73c 100644 --- a/src/Common/ClipboardButton/types.ts +++ b/src/Common/ClipboardButton/types.ts @@ -18,8 +18,7 @@ export default interface ClipboardProps { content: string copiedTippyText?: string duration?: number - trigger?: boolean - setTrigger?: React.Dispatch> + copyToClipboardPromise?: Promise rootClassName?: string iconSize?: number } diff --git a/src/Common/Helper.tsx b/src/Common/Helper.tsx index a2667d0cd..d855e0c9e 100644 --- a/src/Common/Helper.tsx +++ b/src/Common/Helper.tsx @@ -346,7 +346,7 @@ export function cleanKubeManifest(manifestJsonString: string): string { return manifestJsonString } } -const unsecureCopyToClipboard = (str, callback = noop) => { +const unsecureCopyToClipboard = (str: string) => { const listener = function (ev) { ev.preventDefault() ev.clipboardData.setData('text/plain', str) @@ -354,35 +354,41 @@ const unsecureCopyToClipboard = (str, callback = noop) => { document.addEventListener('copy', listener) document.execCommand('copy') document.removeEventListener('copy', listener) - callback() } /** - * It will copy the passed content to clipboard and invoke the callback function, in case of error it will show the toast message. - * On HTTP system clipboard is not supported, so it will use the unsecureCopyToClipboard function + * This is a promise that will resolve if str is successfully copied + * On HTTP (other than localhost) system clipboard is not supported, so it will use the unsecureCopyToClipboard function * @param str - * @param callback */ -export function copyToClipboard(str, callback = noop) { - if (!str) { - return - } +export function copyToClipboard(str: string): Promise { + return new Promise((resolve, reject) => { + if (!str) { + resolve() - if (window.isSecureContext && navigator.clipboard) { - navigator.clipboard - .writeText(str) - .then(() => { - callback() - }) - .catch(() => { - ToastManager.showToast({ - variant: ToastVariantType.error, - description: 'Failed to copy to clipboard', + return + } + + if (window.isSecureContext && navigator.clipboard) { + navigator.clipboard + .writeText(str) + .then(() => { + resolve() }) - }) - } else { - unsecureCopyToClipboard(str, callback) - } + .catch(() => { + ToastManager.showToast({ + variant: ToastVariantType.error, + description: 'Failed to copy to clipboard', + }) + + reject() + }) + } else { + unsecureCopyToClipboard(str) + + resolve() + } + }) } export function useAsync( From f1f393a6efd513d4d9af84748a86f3675baf7a95 Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Fri, 15 Nov 2024 16:25:37 +0530 Subject: [PATCH 38/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6ee52b623..c419da36a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.5", + "version": "1.0.5-beta-1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.5", + "version": "1.0.5-beta-1", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 665da0431..03559e6fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.5", + "version": "1.0.5-beta-1", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From c300a1cef1c58283f6520b084f0a7435e542a309 Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Fri, 15 Nov 2024 16:37:23 +0530 Subject: [PATCH 39/64] chore: version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c419da36a..425a9652a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.5-beta-1", + "version": "1.0.5-beta-2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.5-beta-1", + "version": "1.0.5-beta-2", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 03559e6fb..df52c46be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.5-beta-1", + "version": "1.0.5-beta-2", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 2d331fc4c75241cf61f36d14419c638d0cc8f9ad Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Fri, 15 Nov 2024 18:09:34 +0530 Subject: [PATCH 40/64] docs: add doc comments on types --- src/Shared/types.ts | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/Shared/types.ts b/src/Shared/types.ts index 4dc30b97f..7a15c7ef0 100644 --- a/src/Shared/types.ts +++ b/src/Shared/types.ts @@ -748,23 +748,68 @@ export interface CustomRoleAndMeta { } interface CommonTabArgsType { + /** + * Name for the tab. + * + * Note: Used for the title + */ name: string kind?: string + /** + * URL for the tab + */ url: string + /** + * If true, the tab is selected + */ isSelected: boolean + /** + * Title for the tab + */ title?: string isDeleted?: boolean + /** + * Type for the tab + * + * Note: Fixed tabs are always places before dynamic tabs + */ type: 'fixed' | 'dynamic' + /** + * Path of the icon for the tab + * + * @default '' + */ iconPath?: string + /** + * Dynamic title for the tab + * + * @default '' + */ dynamicTitle?: string + /** + * Whether to show the tab name when selected + * + * @default false + */ showNameOnSelect?: boolean /** + * Would remove the title/name from tab heading, but that does not mean name is not required, since it is used in other calculations * @default false */ hideName?: boolean + /** + * Indicates if showNameOnSelect tabs have been selected once + * + * @default false + */ isAlive?: boolean lastSyncMoment?: Dayjs componentKey?: string + /** + * Custom tippy config for the tab + * + * This overrides the tippy being computed from tab title + */ tippyConfig?: { title: string descriptions: { From 0571ac0de26a2c61d63a1b83413004256f9985a9 Mon Sep 17 00:00:00 2001 From: shivani170 Date: Fri, 15 Nov 2024 18:21:40 +0530 Subject: [PATCH 41/64] chore: git info fix --- .../GitCommitInfoGeneric.tsx | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx index 47d1ba238..7f3e60dca 100644 --- a/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx +++ b/src/Shared/Components/GitCommitInfoGeneric/GitCommitInfoGeneric.tsx @@ -28,7 +28,7 @@ import { ReactComponent as Check } from '@Icons/ic-check-circle.svg' import { ReactComponent as Abort } from '@Icons/ic-abort.svg' import { SourceTypeMap, createGitCommitUrl, getGitBranchUrl } from '@Common/Common.service' import { stopPropagation } from '@Common/Helper' -import { DATE_TIME_FORMATS } from '@Common/Constants' +import { DATE_TIME_FORMATS, GitProviderType } from '@Common/Constants' import { ReactComponent as Tag } from '@Icons/ic-tag.svg' import { getLowerCaseObject, getWebhookDate } from '@Shared/Helpers' import { ReactComponent as Hash } from '@Icons/ic-hash.svg' @@ -180,30 +180,38 @@ const GitCommitInfoGeneric = ({ return null } - const renderPRInfoCard = () => - _isWebhook && - _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.MERGED && ( -
-
- {renderPullRequestId(_webhookData.data['git url'])} - {getCheckUncheckIcon()} -
- {renderWebhookTitle()} - {renderBasicGitCommitInfoForWebhook(true)} + const renderPRInfoCard = () => ( +
+
+ {renderPullRequestId(_webhookData.data['git url'])} + {getCheckUncheckIcon()}
- ) + {renderWebhookTitle()} + {renderBasicGitCommitInfoForWebhook(true)} +
+ ) - const renderTagInfoCard = () => - _isWebhook && - _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.NON_MERGED && ( - <> -
- {renderTagCreationId(_webhookData.data['target checkout'])} - {getCheckUncheckIcon()} -
- {renderBasicGitCommitInfoForWebhook()} - - ) + const renderTagInfoCard = () => ( + <> +
+ {renderTagCreationId(_webhookData.data['target checkout'])} + {getCheckUncheckIcon()} +
+ {renderBasicGitCommitInfoForWebhook()} + + ) + + const renderWebhookGitInfoCard = () => { + if (!_isWebhook) return null + + const isMerged = _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.MERGED + + if (materialUrl.includes(GitProviderType.GITLAB)) { + // TODO: This is a temporary fix for the issue where the eventActionType data incorrect + return isMerged ? renderTagInfoCard() : renderPRInfoCard() + } + return isMerged ? renderPRInfoCard() : renderTagInfoCard() + } return (
@@ -277,9 +285,7 @@ const GitCommitInfoGeneric = ({
)} - - {renderPRInfoCard()} - {renderTagInfoCard()} + {renderWebhookGitInfoCard()}
) From 79dcdd7a56ff7c085cfa0cd948503172800b9c90 Mon Sep 17 00:00:00 2001 From: Amrit Kashyap Borah Date: Mon, 18 Nov 2024 12:16:12 +0530 Subject: [PATCH 42/64] chore: review comments --- .eslintignore | 1 - .../ClipboardButton/ClipboardButton.tsx | 21 +++++++++---------- src/Common/CodeEditor/CodeEditor.tsx | 2 +- src/Common/index.ts | 2 +- .../GitCommitInfoGeneric.tsx | 2 +- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.eslintignore b/.eslintignore index e9659cf41..551aa469f 100755 --- a/.eslintignore +++ b/.eslintignore @@ -10,7 +10,6 @@ src/Common/BreadCrumb/BreadcrumbStore.tsx src/Common/CIPipeline.Types.ts src/Common/ChartVersionAndTypeSelector.tsx src/Common/Checkbox.tsx -src/Common/ClipboardButton/ClipboardButton.tsx src/Common/ClipboardButton/__tests__/ClipboardButton.test.tsx src/Common/CodeEditor/CodeEditor.tsx src/Common/Common.service.ts diff --git a/src/Common/ClipboardButton/ClipboardButton.tsx b/src/Common/ClipboardButton/ClipboardButton.tsx index 411b201d1..80122bd5a 100644 --- a/src/Common/ClipboardButton/ClipboardButton.tsx +++ b/src/Common/ClipboardButton/ClipboardButton.tsx @@ -15,8 +15,8 @@ */ import { useState, useEffect, useRef } from 'react' -import { copyToClipboard, noop, stopPropagation } from '../Helper' import Tooltip from '@Common/Tooltip/Tooltip' +import { copyToClipboard, noop, stopPropagation } from '../Helper' import ClipboardProps from './types' import { ReactComponent as ICCopy } from '../../Assets/Icon/ic-copy.svg' import { ReactComponent as Check } from '../../Assets/Icon/ic-check.svg' @@ -29,14 +29,14 @@ import { ReactComponent as Check } from '../../Assets/Icon/ic-check.svg' * @param rootClassName - additional classes to add to button * @param iconSize - size of svg icon to be shown, default 16 (icon-dim-16) */ -export default function ClipboardButton({ +export const ClipboardButton = ({ content, copiedTippyText = 'Copied!', duration = 1000, copyToClipboardPromise, rootClassName = '', iconSize = 16, -}: ClipboardProps) { +}: ClipboardProps) => { const [copied, setCopied] = useState(false) const setCopiedFalseTimeoutRef = useRef>(-1) @@ -80,21 +80,20 @@ export default function ClipboardButton({ handleAwaitCopyToClipboardPromise().catch(noop) }, [copyToClipboardPromise]) - useEffect(() => { - return () => { + useEffect( + () => () => { if (setCopiedFalseTimeoutRef.current > -1) { clearTimeout(setCopiedFalseTimeoutRef.current) } - } - }, []) + }, + [], + ) const iconClassName = `icon-dim-${iconSize} dc__no-shrink` return ( - + + {/* TODO: semantically buttons should not be nested; fix later */}
{(currentConfiguration?.codeEditorValue?.value || baseTemplateConfiguration?.codeEditorValue?.value) && ( -
+
{ const parsedDraftData = JSON.parse(data?.deploymentDraftData?.configData[0].draftMetadata.data || null) @@ -827,3 +829,17 @@ export const getDefaultVersionAndPreviousDeploymentOptions = (data: TemplateList previousDeployments: [], }, ) + +export const renderDiffViewNoDifferenceState = ( + diffState: DeploymentConfigDiffState | null, +): DiffViewerProps['codeFoldMessageRenderer'] => + diffState !== DeploymentConfigDiffState.NO_DIFF + ? () => ( + + ) + : null diff --git a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffMain.tsx b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffMain.tsx index a512705d2..e0beb887f 100644 --- a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffMain.tsx +++ b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffMain.tsx @@ -5,11 +5,11 @@ import { ReactComponent as ICSortArrowDown } from '@Icons/ic-sort-arrow-down.svg import { ReactComponent as ICSort } from '@Icons/ic-arrow-up-down.svg' import { ReactComponent as ICViewVariableToggle } from '@Icons/ic-view-variable-toggle.svg' import { Progressing } from '@Common/Progressing' -import { CodeEditor } from '@Common/CodeEditor' -import { MODES, SortingOrder } from '@Common/Constants' +import { SortingOrder } from '@Common/Constants' import ErrorScreenManager from '@Common/ErrorScreenManager' import Toggle from '@Common/Toggle/Toggle' import { ComponentSizeType } from '@Shared/constants' +import { DiffViewer } from '@Shared/Components/DiffViewer' import { Button, ButtonStyleType, ButtonVariantType } from '../Button' import { SelectPicker } from '../SelectPicker' @@ -21,6 +21,7 @@ import { DeploymentConfigDiffState, DeploymentConfigDiffAccordionProps, } from './DeploymentConfigDiff.types' +import { renderDiffViewNoDifferenceState } from './DeploymentConfigDiff.utils' export const DeploymentConfigDiffMain = ({ isLoading, @@ -190,23 +191,13 @@ export const DeploymentConfigDiffMain = ({ hideDiffState={hideDiffState} > {singleView ? ( - <> -
-
{primaryHeading}
-
{secondaryHeading}
-
- - + ) : (
{primaryHeading && secondaryHeading && ( @@ -222,6 +213,7 @@ export const DeploymentConfigDiffMain = ({ previousConfigAvailable rootClassName={`${primaryHeading && secondaryHeading ? 'dc__no-top-radius dc__no-top-border' : ''}`} sortingConfig={sortingConfig} + diffState={diffState} />
)} diff --git a/src/Shared/Components/DiffViewer/DiffViewer.component.tsx b/src/Shared/Components/DiffViewer/DiffViewer.component.tsx index 7c9687de3..efe1570fb 100644 --- a/src/Shared/Components/DiffViewer/DiffViewer.component.tsx +++ b/src/Shared/Components/DiffViewer/DiffViewer.component.tsx @@ -1,15 +1,18 @@ import ReactDiffViewer, { DiffMethod } from 'react-diff-viewer-continued' import { diffViewerStyles } from './constants' -import { DiffViewerProps } from './types' +import { DiffViewerProps, DiffViewTitleWrapperProps } from './types' -const DiffViewer = ({ oldValue, newValue, leftTitle, rightTitle }: DiffViewerProps) => ( +const DiffViewTitleWrapper = ({ title }: DiffViewTitleWrapperProps) =>
{title}
+ +const DiffViewer = ({ oldValue, newValue, leftTitle, rightTitle, ...props }: DiffViewerProps) => ( : null} + rightTitle={rightTitle ? : null} compareMethod={DiffMethod.WORDS} styles={diffViewerStyles} /> diff --git a/src/Shared/Components/DiffViewer/constants.ts b/src/Shared/Components/DiffViewer/constants.ts index 8691b5857..578e01ab2 100644 --- a/src/Shared/Components/DiffViewer/constants.ts +++ b/src/Shared/Components/DiffViewer/constants.ts @@ -37,8 +37,10 @@ export const diffViewerStyles: ReactDiffViewerProps['styles'] = { lineHeight: '20px', pre: { + fontSize: '13px', lineHeight: '20px', fontFamily: 'Inconsolata, monospace', + wordBreak: 'break-word', }, }, marker: { @@ -49,6 +51,8 @@ export const diffViewerStyles: ReactDiffViewerProps['styles'] = { gutter: { padding: `0 6px`, minWidth: '36px', + // Cursor would be default for all cases in gutter till we don't support highlighting + cursor: 'default', pre: { opacity: 1, @@ -59,9 +63,11 @@ export const diffViewerStyles: ReactDiffViewerProps['styles'] = { }, wordAdded: { paddingInline: '2px', + lineHeight: '16px', }, wordRemoved: { paddingInline: '2px', + lineHeight: '16px', }, codeFold: { fontSize: '13px', @@ -73,6 +79,11 @@ export const diffViewerStyles: ReactDiffViewerProps['styles'] = { textDecoration: 'none !important', }, }, + codeFoldGutter: { + '+ td': { + width: '12px', + }, + }, titleBlock: { padding: '8px 12px', fontSize: '12px', diff --git a/src/Shared/Components/DiffViewer/types.ts b/src/Shared/Components/DiffViewer/types.ts index 996824ade..e27e4cbbf 100644 --- a/src/Shared/Components/DiffViewer/types.ts +++ b/src/Shared/Components/DiffViewer/types.ts @@ -1,4 +1,12 @@ +import { ReactNode } from 'react' import { ReactDiffViewerProps } from 'react-diff-viewer-continued' export interface DiffViewerProps - extends Pick {} + extends Pick { + leftTitle?: ReactDiffViewerProps['leftTitle'] | ReactNode + rightTitle?: ReactDiffViewerProps['rightTitle'] | ReactNode +} + +export interface DiffViewTitleWrapperProps { + title: DiffViewerProps['leftTitle'] +} From 4d4fee3deea84b4159fb3160029df85c4c93a10f Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:07:35 +0530 Subject: [PATCH 57/64] feat: add custom renderer for null state and generic section error state --- src/Assets/Icon/ic-info-outline.svg | 4 +++ .../DeploymentHistoryDiffView.tsx | 3 +- src/Shared/Components/CICDHistory/types.tsx | 2 -- .../DeploymentConfigDiff.utils.tsx | 14 +++++---- .../DeploymentConfigDiffMain.tsx | 6 ++-- .../GenericSectionErrorState.component.tsx | 29 ++++++++++--------- 6 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 src/Assets/Icon/ic-info-outline.svg diff --git a/src/Assets/Icon/ic-info-outline.svg b/src/Assets/Icon/ic-info-outline.svg new file mode 100644 index 000000000..b3912b7dc --- /dev/null +++ b/src/Assets/Icon/ic-info-outline.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/DeploymentHistoryDiffView.tsx b/src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/DeploymentHistoryDiffView.tsx index 77f436f55..cd9c32aa8 100644 --- a/src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/DeploymentHistoryDiffView.tsx +++ b/src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/DeploymentHistoryDiffView.tsx @@ -38,7 +38,6 @@ const DeploymentHistoryDiffView = ({ rootClassName, sortingConfig, codeEditorKey, - diffState, }: DeploymentTemplateHistoryType) => { const { historyComponent, historyComponentName } = useParams() const { sortBy, sortOrder } = sortingConfig ?? { sortBy: '', sortOrder: null } @@ -93,7 +92,7 @@ const DeploymentHistoryDiffView = ({ ) : ( - diffState !== DeploymentConfigDiffState.NO_DIFF + lhsValue === rhsValue ? () => ( ) : null diff --git a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffMain.tsx b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffMain.tsx index e0beb887f..6904f308e 100644 --- a/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffMain.tsx +++ b/src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiffMain.tsx @@ -196,7 +196,10 @@ export const DeploymentConfigDiffMain = ({ newValue={secondaryList.codeEditorValue.value} leftTitle={primaryHeading} rightTitle={secondaryHeading} - codeFoldMessageRenderer={renderDiffViewNoDifferenceState(diffState)} + codeFoldMessageRenderer={renderDiffViewNoDifferenceState( + primaryList.codeEditorValue.value, + secondaryList.codeEditorValue.value, + )} /> ) : (
@@ -213,7 +216,6 @@ export const DeploymentConfigDiffMain = ({ previousConfigAvailable rootClassName={`${primaryHeading && secondaryHeading ? 'dc__no-top-radius dc__no-top-border' : ''}`} sortingConfig={sortingConfig} - diffState={diffState} />
)} diff --git a/src/Shared/Components/GenericSectionErrorState/GenericSectionErrorState.component.tsx b/src/Shared/Components/GenericSectionErrorState/GenericSectionErrorState.component.tsx index 6c0c613f4..747669e70 100644 --- a/src/Shared/Components/GenericSectionErrorState/GenericSectionErrorState.component.tsx +++ b/src/Shared/Components/GenericSectionErrorState/GenericSectionErrorState.component.tsx @@ -14,8 +14,10 @@ * limitations under the License. */ +import { ComponentSizeType } from '@Shared/constants' import { ReactComponent as ErrorIcon } from '../../../Assets/Icon/ic-error-exclamation.svg' -import { ReactComponent as InfoIcon } from '../../../Assets/Icon/ic-exclamation.svg' +import { ReactComponent as ICInfoOutline } from '../../../Assets/Icon/ic-info-outline.svg' +import { Button, ButtonVariantType } from '../Button' import { GenericSectionErrorStateProps } from './types' const GenericSectionErrorState = ({ @@ -30,27 +32,28 @@ const GenericSectionErrorState = ({ }: GenericSectionErrorStateProps) => (
{useInfoIcon ? ( - + ) : ( )}

{title}

-
- {subTitle &&

{subTitle}

} - {description &&

{description}

} -
+ {(subTitle || description) && ( +
+ {subTitle &&

{subTitle}

} + {description &&

{description}

} +
+ )}
{reload && ( - + variant={ButtonVariantType.text} + size={ComponentSizeType.small} + dataTestId="generic-section-reload-button" + /> )}
) From d60e762cad646844d7d40ec26b886f678a7b868d Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:12:05 +0530 Subject: [PATCH 58/64] fix: add reset for styling for pre tag --- package-lock.json | 4 ++-- package.json | 2 +- src/Shared/Components/DiffViewer/constants.ts | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5852b781a..b16dc0d02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.9", + "version": "1.0.9-beta-2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.9", + "version": "1.0.9-beta-2", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 2c0f2524e..78c954de2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.9", + "version": "1.0.9-beta-2", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Shared/Components/DiffViewer/constants.ts b/src/Shared/Components/DiffViewer/constants.ts index 578e01ab2..99dda75a5 100644 --- a/src/Shared/Components/DiffViewer/constants.ts +++ b/src/Shared/Components/DiffViewer/constants.ts @@ -41,6 +41,12 @@ export const diffViewerStyles: ReactDiffViewerProps['styles'] = { lineHeight: '20px', fontFamily: 'Inconsolata, monospace', wordBreak: 'break-word', + // Reset for styling from patternfly + padding: 0, + margin: 0, + backgroundColor: 'transparent', + border: 'none', + borderRadius: 0, }, }, marker: { From ac3deb079cd2366236384a4557bca27a2c1ac74c Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:43:09 +0530 Subject: [PATCH 59/64] fix: class for code editor diff view --- package-lock.json | 4 ++-- package.json | 2 +- src/Shared/Components/CICDHistory/cicdHistory.scss | 8 -------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index b16dc0d02..18880a09c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.9-beta-2", + "version": "1.0.9-beta-3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.9-beta-2", + "version": "1.0.9-beta-3", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 78c954de2..c1b595c99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.9-beta-2", + "version": "1.0.9-beta-3", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Shared/Components/CICDHistory/cicdHistory.scss b/src/Shared/Components/CICDHistory/cicdHistory.scss index 7df3367f4..ce1bcea7b 100644 --- a/src/Shared/Components/CICDHistory/cicdHistory.scss +++ b/src/Shared/Components/CICDHistory/cicdHistory.scss @@ -171,14 +171,6 @@ color: var(--N900) !important; } -.code-editor-green-diff { - background: #eaf1dd; -} - -.code-editor-red-diff { - background: #ffd4d1; -} - .left-50 { left: 50px; } From 293063aa1e97eb104c8a12f1f540f291e4ffc366 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:17:31 +0530 Subject: [PATCH 60/64] fix: update text size to 14px --- package-lock.json | 4 ++-- package.json | 2 +- src/Shared/Components/DiffViewer/constants.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 18880a09c..4149fac33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.9-beta-3", + "version": "1.0.9-beta-4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.9-beta-3", + "version": "1.0.9-beta-4", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index c1b595c99..a7dc295ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.9-beta-3", + "version": "1.0.9-beta-4", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Shared/Components/DiffViewer/constants.ts b/src/Shared/Components/DiffViewer/constants.ts index 99dda75a5..47aa4218c 100644 --- a/src/Shared/Components/DiffViewer/constants.ts +++ b/src/Shared/Components/DiffViewer/constants.ts @@ -32,12 +32,12 @@ export const diffViewerStyles: ReactDiffViewerProps['styles'] = { }, }, diffContainer: { - fontSize: '13px', + fontSize: '14px', fontWeight: 400, lineHeight: '20px', pre: { - fontSize: '13px', + fontSize: '14px', lineHeight: '20px', fontFamily: 'Inconsolata, monospace', wordBreak: 'break-word', @@ -76,7 +76,7 @@ export const diffViewerStyles: ReactDiffViewerProps['styles'] = { lineHeight: '16px', }, codeFold: { - fontSize: '13px', + fontSize: '14px', fontWeight: 400, lineHeight: '20px', height: '32px', From 5b1f1c266c0c1ab19eb8cf8ae739b522f63c9c39 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:32:28 +0530 Subject: [PATCH 61/64] doc: add documentation --- .../DiffViewer/DiffViewer.component.tsx | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/Shared/Components/DiffViewer/DiffViewer.component.tsx b/src/Shared/Components/DiffViewer/DiffViewer.component.tsx index efe1570fb..a3c19e2c4 100644 --- a/src/Shared/Components/DiffViewer/DiffViewer.component.tsx +++ b/src/Shared/Components/DiffViewer/DiffViewer.component.tsx @@ -4,6 +4,44 @@ import { DiffViewerProps, DiffViewTitleWrapperProps } from './types' const DiffViewTitleWrapper = ({ title }: DiffViewTitleWrapperProps) =>
{title}
+/** + * Component for showing diff between two string or object. + * + * Note: Pass down the object as stringified for optimized performance. + * + * @example Usage + * + * ```tsx + * + * ``` + * + * @example With left/right title for lhs/rhs + * + * ```tsx + * Title for RHS + * } + * /> + * ``` + * + * @example With custom message for folded code + * Note: the entire section would be clickable + * + * ```tsx + * Custom text} + * /> + * ``` + */ const DiffViewer = ({ oldValue, newValue, leftTitle, rightTitle, ...props }: DiffViewerProps) => ( Date: Wed, 20 Nov 2024 18:16:44 +0530 Subject: [PATCH 62/64] fix: on change being called in custom input without any change --- package-lock.json | 4 ++-- package.json | 2 +- src/Common/CustomInput/CustomInput.tsx | 10 +++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index cb752893a..8780bc14b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.10", + "version": "1.0.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.10", + "version": "1.0.11", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 02a81b5fa..e38e61d23 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.10", + "version": "1.0.11", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Common/CustomInput/CustomInput.tsx b/src/Common/CustomInput/CustomInput.tsx index 00c71316f..fdc0cbbad 100644 --- a/src/Common/CustomInput/CustomInput.tsx +++ b/src/Common/CustomInput/CustomInput.tsx @@ -69,9 +69,13 @@ export const CustomInput = ({ const handleOnBlur = (event) => { // NOTE: This is to prevent the input from being trimmed when the user do not want to trim the input if (!noTrim) { - event.stopPropagation() - event.target.value = event.target.value?.trim() - onChange(event) + const trimmedValue = event.target.value?.trim() + + if (event.target.value !== trimmedValue) { + event.stopPropagation() + event.target.value = trimmedValue + onChange(event) + } } if (typeof onBlur === 'function') { onBlur(event) From 8515310ed9ece29e1905b26243d9ebfb7cfc8d96 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:04:01 +0530 Subject: [PATCH 63/64] chore: bump version to 1.1.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index cb752893a..cebfda6b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.10", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.10", + "version": "1.1.0", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 02a81b5fa..106daa281 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.10", + "version": "1.1.0", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", From 74cf9f4a301688039d4bf334000f54bb0f227826 Mon Sep 17 00:00:00 2001 From: AbhishekA1509 Date: Fri, 22 Nov 2024 16:52:05 +0530 Subject: [PATCH 64/64] feat: add types to support loading merged template and mergedTemplateError --- .../Details/AppConfigurations/DeploymentTemplate/types.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Pages/Applications/DevtronApps/Details/AppConfigurations/DeploymentTemplate/types.ts b/src/Pages/Applications/DevtronApps/Details/AppConfigurations/DeploymentTemplate/types.ts index 0b3729d0a..f7660c177 100644 --- a/src/Pages/Applications/DevtronApps/Details/AppConfigurations/DeploymentTemplate/types.ts +++ b/src/Pages/Applications/DevtronApps/Details/AppConfigurations/DeploymentTemplate/types.ts @@ -1,4 +1,5 @@ import { DraftMetadataDTO, TemplateListType } from '@Shared/Services' +import { ServerErrors } from '@Common/ServerError' import { OverrideMergeStrategyType } from '../types' export type DeploymentChartOptionkind = 'base' | 'env' | 'chartVersion' | 'deployment' @@ -162,6 +163,9 @@ export interface DeploymentTemplateConfigCommonState extends SelectedChartDetail * In current editor, this may be null initially */ mergedTemplateObject: Record | null + + isLoadingMergedTemplate: boolean + mergedTemplateError: ServerErrors | null } export type DeploymentTemplateConfigState = DeploymentTemplateConfigCommonState &