Skip to content

Commit 01b1b59

Browse files
committed
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-lib into feat/theming-v2
2 parents 7edda7d + 90753ff commit 01b1b59

18 files changed

+279
-101
lines changed

package-lock.json

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

package.json

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

src/Common/RJSF/templates/ObjectFieldTemplate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export const ObjectFieldTemplate = (props: ObjectFieldTemplateProps<any, RJSFFor
134134
schema.properties && !hasAdditionalProperties && idSchema.$id !== 'root'
135135
? 'dc__border-left pl-12'
136136
: ''
137-
} flexbox-col dc__gap-8`}
137+
} ${idSchema.$id === 'root' ? 'dc__separated-flexbox dc__separated-flexbox--vertical' : 'flexbox-col dc__gap-8'}`}
138138
>
139139
<Field {...props} />
140140
</div>

src/Common/RJSF/templates/TitleField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const TitleField = ({
2323
required,
2424
description,
2525
}: TitleFieldProps & Partial<Record<'description', string>>) => (
26-
<legend className="fs-13 fw-6 cn-9 lh-20 dc__no-border py-9 mb-0" id={id}>
26+
<legend className="fs-13 fw-6 cn-9 lh-20 dc__no-border pb-9 mb-0" id={id}>
2727
<Tooltip alwaysShowTippyOnHover={!!description} content={description}>
2828
<span className={`${description ? 'text-underline-dashed-300' : ''}`}>{title}</span>
2929
</Tooltip>

src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/DeploymentHistoryConfigDiff.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ export const DeploymentHistoryConfigDiff = ({
4747
const isPreviousDeploymentConfigAvailable = !!previousWfrId
4848

4949
// URL FILTERS
50-
const { compareWfrId } = useUrlFilters<string, DeploymentHistoryConfigDiffQueryParams>({
50+
const urlFilters = useUrlFilters<string, DeploymentHistoryConfigDiffQueryParams>({
5151
parseSearchParams: parseDeploymentHistoryDiffSearchParams(previousWfrId),
5252
})
53+
const { compareWfrId, sortBy, sortOrder } = urlFilters
5354

5455
// STATES
5556
const [convertVariables, setConvertVariables] = useState(false)
@@ -125,12 +126,20 @@ export const DeploymentHistoryConfigDiff = ({
125126
compareList,
126127
getNavItemHref,
127128
convertVariables,
129+
sortingConfig: { sortBy, sortOrder },
128130
})
129131
return configData
130132
}
131133

132134
return null
133-
}, [isPreviousDeploymentConfigAvailable, compareDeploymentConfigLoader, compareDeploymentConfig, convertVariables])
135+
}, [
136+
isPreviousDeploymentConfigAvailable,
137+
compareDeploymentConfigLoader,
138+
compareDeploymentConfig,
139+
convertVariables,
140+
sortBy,
141+
sortOrder,
142+
])
134143

135144
const compareDeploymentConfigErr = useMemo(
136145
() =>
@@ -180,7 +189,7 @@ export const DeploymentHistoryConfigDiff = ({
180189
errorConfig={errorConfig}
181190
envName={envName}
182191
wfrId={wfrId}
183-
previousWfrId={previousWfrId}
192+
urlFilters={urlFilters}
184193
pipelineDeployments={pipelineDeployments}
185194
setFullScreenView={setFullScreenView}
186195
convertVariables={convertVariables}

src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/DeploymentHistoryConfigDiffCompare.tsx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { useEffect, useState } from 'react'
22
import { generatePath, useRouteMatch } from 'react-router-dom'
33

4-
import { DeploymentConfigDiff, DeploymentConfigDiffProps } from '@Shared/Components/DeploymentConfigDiff'
4+
import {
5+
DEPLOYMENT_CONFIG_DIFF_SORT_KEY,
6+
DeploymentConfigDiff,
7+
DeploymentConfigDiffProps,
8+
} from '@Shared/Components/DeploymentConfigDiff'
59
import { DEFAULT_BASE_PAGE_SIZE, SortingOrder } from '@Common/Constants'
6-
import { useUrlFilters } from '@Common/Hooks'
710
import {
811
getSelectPickerOptionByValue,
912
SelectPickerOptionType,
@@ -12,20 +15,16 @@ import {
1215
import { ComponentSizeType } from '@Shared/constants'
1316
import { Button, ButtonVariantType } from '@Shared/Components/Button'
1417

15-
import {
16-
DeploymentHistoryDiffDetailedProps,
17-
DeploymentHistoryConfigDiffQueryParams,
18-
DeploymentHistoryConfigDiffRouteParams,
19-
} from './types'
20-
import { getPipelineDeployments, getPipelineDeploymentsOptions, parseDeploymentHistoryDiffSearchParams } from './utils'
18+
import { DeploymentHistoryDiffDetailedProps, DeploymentHistoryConfigDiffRouteParams } from './types'
19+
import { getPipelineDeployments, getPipelineDeploymentsOptions } from './utils'
2120
import { getTriggerHistory } from '../service'
2221

2322
export const DeploymentHistoryConfigDiffCompare = ({
2423
envName,
2524
setFullScreenView,
2625
pipelineDeployments: initialPipelineDeployments,
2726
wfrId,
28-
previousWfrId,
27+
urlFilters,
2928
convertVariables,
3029
setConvertVariables,
3130
triggerHistory: initialTriggerHistory,
@@ -39,12 +38,7 @@ export const DeploymentHistoryConfigDiffCompare = ({
3938
const { resourceType, resourceName, appId, envId } = params
4039

4140
// URL FILTERS
42-
const { compareWfrId, updateSearchParams, sortBy, sortOrder, handleSorting } = useUrlFilters<
43-
string,
44-
DeploymentHistoryConfigDiffQueryParams
45-
>({
46-
parseSearchParams: parseDeploymentHistoryDiffSearchParams(previousWfrId),
47-
})
41+
const { compareWfrId, updateSearchParams, sortBy, sortOrder, handleSorting } = urlFilters
4842

4943
// STATES
5044
const [triggerHistory, setTriggerHistory] = useState({
@@ -59,6 +53,8 @@ export const DeploymentHistoryConfigDiffCompare = ({
5953
updateSearchParams({ compareWfrId })
6054
// Set fullscreen for comparing deployment history config
6155
setFullScreenView(true)
56+
// Set default initial sorting
57+
handleSorting(DEPLOYMENT_CONFIG_DIFF_SORT_KEY)
6258

6359
return () => {
6460
setConvertVariables(false)
@@ -170,7 +166,7 @@ export const DeploymentHistoryConfigDiffCompare = ({
170166
return null
171167
}
172168

173-
const onSorting = () => handleSorting(sortOrder !== SortingOrder.DESC ? 'sort-config' : '')
169+
const onSorting = () => handleSorting(sortOrder !== SortingOrder.DESC ? DEPLOYMENT_CONFIG_DIFF_SORT_KEY : '')
174170

175171
const sortingConfig: DeploymentConfigDiffProps['sortingConfig'] = {
176172
handleSorting: onSorting,

src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/DeploymentHistoryDiffView.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import { useParams } from 'react-router-dom'
1818
import { useMemo, useState } from 'react'
1919
import Tippy from '@tippyjs/react'
20-
import { yamlComparatorBySortOrder } from '@Shared/Helpers'
2120
import { DiffViewer } from '@Shared/Components/DiffViewer'
2221
import { renderDiffViewNoDifferenceState } from '@Shared/Components/DeploymentConfigDiff'
2322
import { MODES, Toggle, YAMLStringify } from '../../../../Common'
@@ -34,11 +33,9 @@ const DeploymentHistoryDiffView = ({
3433
baseTemplateConfiguration,
3534
previousConfigAvailable,
3635
rootClassName,
37-
sortingConfig,
3836
codeEditorKey,
3937
}: DeploymentTemplateHistoryType) => {
4038
const { historyComponent, historyComponentName } = useParams<DeploymentHistoryParamsType>()
41-
const { sortBy, sortOrder } = sortingConfig ?? { sortBy: '', sortOrder: null }
4239

4340
const [convertVariables, setConvertVariables] = useState(false)
4441

@@ -56,10 +53,8 @@ const DeploymentHistoryDiffView = ({
5653
? baseTemplateConfiguration?.codeEditorValue?.resolvedValue
5754
: baseTemplateConfiguration?.codeEditorValue?.value
5855

59-
return YAMLStringify(JSON.parse(editorValue), {
60-
sortMapEntries: sortBy ? (a, b) => yamlComparatorBySortOrder(a, b, sortOrder) : null,
61-
})
62-
}, [convertVariables, baseTemplateConfiguration, sortOrder])
56+
return YAMLStringify(JSON.parse(editorValue))
57+
}, [convertVariables, baseTemplateConfiguration])
6358

6459
const editorValuesLHS = useMemo(() => {
6560
if (!currentConfiguration?.codeEditorValue?.value) {
@@ -70,10 +65,8 @@ const DeploymentHistoryDiffView = ({
7065
? currentConfiguration?.codeEditorValue?.resolvedValue
7166
: currentConfiguration?.codeEditorValue?.value
7267

73-
return YAMLStringify(JSON.parse(editorValue), {
74-
sortMapEntries: sortBy ? (a, b) => yamlComparatorBySortOrder(a, b, sortOrder) : null,
75-
})
76-
}, [convertVariables, currentConfiguration, sortOrder])
68+
return YAMLStringify(JSON.parse(editorValue))
69+
}, [convertVariables, currentConfiguration])
7770

7871
const renderDeploymentDiffViaCodeEditor = () =>
7972
previousConfigAvailable ? (

src/Shared/Components/CICDHistory/DeploymentHistoryConfigDiff/types.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import { Dispatch, SetStateAction } from 'react'
33
import { DeploymentConfigDiffProps } from '@Shared/Components/DeploymentConfigDiff'
44
import { EnvResourceType } from '@Shared/Services'
55

6+
import { UseUrlFiltersReturnType } from '@Common/Hooks'
67
import { History, HistoryLogsProps } from '../types'
78

9+
export interface DeploymentHistoryConfigDiffQueryParams {
10+
compareWfrId: number
11+
}
12+
813
export interface DeploymentHistoryConfigDiffProps
914
extends Required<Pick<HistoryLogsProps, 'renderRunSource' | 'resourceId'>> {
1015
appName: string
@@ -26,16 +31,12 @@ export type DeploymentHistoryDiffDetailedProps = Pick<
2631
>
2732
> & {
2833
pipelineDeployments: History[]
29-
previousWfrId: number
3034
convertVariables: boolean
3135
setConvertVariables: Dispatch<SetStateAction<boolean>>
3236
isCompareDeploymentConfigNotAvailable?: boolean
37+
urlFilters: UseUrlFiltersReturnType<string, DeploymentHistoryConfigDiffQueryParams>
3338
}
3439

35-
export interface DeploymentHistoryConfigDiffQueryParams {
36-
compareWfrId: number
37-
}
38-
3940
export interface DeploymentHistoryConfigDiffRouteParams {
4041
appId: string
4142
envId: string

src/Shared/Components/CICDHistory/types.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
ResponseType,
2828
PaginationProps,
2929
useScrollable,
30-
SortingOrder,
3130
} from '../../../Common'
3231
import { DeploymentStageType } from '../../constants'
3332
import { AggregationKeys, GitTriggers, Node, NodeType, ResourceKindType, ResourceVersionType } from '../../types'
@@ -487,10 +486,6 @@ export interface DeploymentTemplateHistoryType {
487486
previousConfigAvailable: boolean
488487
rootClassName?: string
489488
codeEditorKey?: React.Key
490-
sortingConfig?: {
491-
sortBy: string
492-
sortOrder: SortingOrder
493-
}
494489
}
495490
export interface DeploymentHistoryDetailRes extends ResponseType {
496491
result?: DeploymentHistoryDetail

src/Shared/Components/DeploymentConfigDiff/DeploymentConfigDiff.constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ export const diffStateTextColorMap: Record<DeploymentConfigDiffState, `c${string
3333
deleted: 'cr-5',
3434
noDiff: 'cn-7',
3535
}
36+
37+
export const DEPLOYMENT_CONFIG_DIFF_SORT_KEY = 'sort-config'

0 commit comments

Comments
 (0)