Skip to content

Commit 51d3253

Browse files
committed
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-lib into fix/runtime-params
2 parents de8fd78 + e97ee17 commit 51d3253

File tree

15 files changed

+214
-161
lines changed

15 files changed

+214
-161
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,4 @@ typings/
105105

106106
.DS_Store
107107
.npmrc
108+
.build-cache

package-lock.json

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

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.2.4-beta-16",
3+
"version": "1.2.7",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
@@ -48,7 +48,7 @@
4848
"@typescript-eslint/eslint-plugin": "8.3.0",
4949
"@typescript-eslint/parser": "8.3.0",
5050
"@vitejs/plugin-react": "4.3.1",
51-
"eslint": "^8.56.0",
51+
"eslint": "^8.57.1",
5252
"eslint-config-airbnb": "^19.0.4",
5353
"eslint-config-prettier": "^9.1.0",
5454
"eslint-import-resolver-typescript": "^3.6.1",
@@ -107,6 +107,7 @@
107107
"tslib": "2.7.0"
108108
},
109109
"overrides": {
110+
"cross-spawn": "^7.0.5",
110111
"react-dates": {
111112
"react": "^17.0.2",
112113
"react-dom": "^17.0.2"

src/Common/Api.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,14 @@ async function fetchAPI<K = object>(
150150
})
151151
} else {
152152
handleLogout()
153-
return { code: 401, status: 'Unauthorized', result: [] }
153+
// Using this way to ensure that the user is redirected to the login page
154+
// and the component has enough time to get unmounted otherwise the component re-renders
155+
// and try to access some property of a variable and log exception to sentry
156+
return await new Promise((resolve) => {
157+
setTimeout(() => {
158+
resolve({ code: 401, status: 'Unauthorized', result: [] })
159+
}, 1000)
160+
})
154161
}
155162
} else if (response.status >= 300 && response.status <= 599) {
156163
return await handleServerError(contentType, response)

src/Common/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export const ROUTES = {
120120
K8S_RESOURCE_LIST: 'k8s/resource/list',
121121
FILE_UPLOAD: 'file/upload',
122122
PLUGIN_GLOBAL_VARIABLES: 'plugin/global/list/global-variable',
123+
CONFIG_COMPARE_SECRET: 'config/compare/secret',
123124
}
124125

125126
export enum KEY_VALUE {

src/Common/Helper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ export const getUrlWithSearchParams = <T extends string | number = string | numb
511511
/**
512512
* Custom exception logger function for logging errors to sentry
513513
*/
514-
export const logExceptionToSentry = Sentry.captureException.bind(window)
514+
export const logExceptionToSentry: typeof Sentry.captureException = Sentry.captureException.bind(window)
515515

516516
export const customStyles = {
517517
control: (base, state) => ({

src/Common/Markdown/MarkDown.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ const MarkDown = ({ setExpandableIcon, markdown, className, breaks, disableEscap
4747
if (task) {
4848
return `<li style="list-style: none">
4949
<input disabled type="checkbox" ${checked ? 'checked' : ''} class="dc__vertical-align-middle" style="margin: 0 0.2em 0.25em -1.4em">
50-
${text}
50+
${marked(text)}
5151
</li>`
5252
}
53-
return `<li>${text}</li>`
53+
return `<li>${marked(text)}</li>`
5454
}
5555

5656
renderer.image = ({ href, title, text }: Tokens.Image) =>
@@ -60,7 +60,7 @@ const MarkDown = ({ setExpandableIcon, markdown, className, breaks, disableEscap
6060
<div class="table-container">
6161
<table>
6262
<thead>
63-
<tr>${header.map((headerCell) => `<th align="${headerCell.align}">${headerCell.text}</th>`).join('')}</tr>
63+
<tr>${header.map((headerCell) => `<th align="${headerCell.align}">${marked(headerCell.text)}</th>`).join('')}</tr>
6464
</thead>
6565
<tbody>
6666
${rows.map((row) => renderTableRow(row)).join('')}

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

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import { generatePath, Route, Switch, useLocation, useRouteMatch } from 'react-r
44
import { ReactComponent as ICError } from '@Icons/ic-error.svg'
55
import { getAppEnvDeploymentConfigList } from '@Shared/Components/DeploymentConfigDiff'
66
import { useAsync } from '@Common/Helper'
7-
import { EnvResourceType, getAppEnvDeploymentConfig } from '@Shared/Services'
7+
import { EnvResourceType, getAppEnvDeploymentConfig, getCompareSecretsData } from '@Shared/Services'
88
import { groupArrayByObjectKey } from '@Shared/Helpers'
99
import ErrorScreenManager from '@Common/ErrorScreenManager'
1010
import { Progressing } from '@Common/Progressing'
1111
import { useUrlFilters } from '@Common/Hooks'
1212
import { GenericEmptyState, InfoColourBar } from '@Common/index'
1313

14+
import { useMainContext } from '@Shared/Providers'
1415
import { DeploymentHistoryConfigDiffCompare } from './DeploymentHistoryConfigDiffCompare'
1516
import { DeploymentHistoryConfigDiffProps, DeploymentHistoryConfigDiffQueryParams } from './types'
1617
import {
@@ -35,6 +36,7 @@ export const DeploymentHistoryConfigDiff = ({
3536
// HOOKS
3637
const { path, params } = useRouteMatch()
3738
const { pathname, search } = useLocation()
39+
const { isSuperAdmin } = useMainContext()
3840

3941
// CONSTANTS
4042
const pipelineDeployments = useMemo(() => getPipelineDeployments(triggerHistory), [triggerHistory])
@@ -54,32 +56,49 @@ export const DeploymentHistoryConfigDiff = ({
5456

5557
// ASYNC CALLS
5658
// Load comparison deployment data
57-
const [compareDeploymentConfigLoader, compareDeploymentConfig, , reloadCompareDeploymentConfig] = useAsync(
58-
() =>
59-
Promise.allSettled([
60-
getAppEnvDeploymentConfig({
61-
params: {
62-
appName,
63-
envName,
64-
configArea: 'DeploymentHistory',
65-
pipelineId,
66-
wfrId: currentWfrId,
67-
},
68-
}),
59+
const [compareDeploymentConfigLoader, compareDeploymentConfig, , reloadCompareDeploymentConfig] =
60+
useAsync(async () => {
61+
const payloads = [
62+
{
63+
appName,
64+
envName,
65+
configArea: 'DeploymentHistory',
66+
pipelineId,
67+
wfrId: currentWfrId,
68+
} as const,
6969
isPreviousDeploymentConfigAvailable
70-
? getAppEnvDeploymentConfig({
71-
params: {
72-
appName,
73-
envName,
74-
configArea: 'DeploymentHistory',
75-
pipelineId,
76-
wfrId: compareWfrId,
77-
},
78-
})
70+
? ({
71+
appName,
72+
envName,
73+
configArea: 'DeploymentHistory',
74+
pipelineId,
75+
wfrId: compareWfrId,
76+
} as const)
7977
: null,
80-
]),
81-
[currentWfrId, compareWfrId],
82-
)
78+
] as const
79+
80+
const [secretsData, ...configDatas] = await Promise.allSettled([
81+
!isSuperAdmin ? getCompareSecretsData([...payloads]) : null,
82+
...payloads.map((payload) => payload && getAppEnvDeploymentConfig({ params: payload })),
83+
])
84+
85+
if (secretsData.status !== 'fulfilled' || !secretsData.value) {
86+
return configDatas
87+
}
88+
89+
secretsData.value.forEach((data, index) => {
90+
if (
91+
configDatas[index].status !== 'fulfilled' ||
92+
!configDatas[index].value ||
93+
configDatas[index].value.result.isAppAdmin
94+
) {
95+
return
96+
}
97+
configDatas[index].value.result.secretsData = data.secretsData
98+
})
99+
100+
return configDatas
101+
}, [currentWfrId, compareWfrId])
83102

84103
// METHODS
85104
const getNavItemHref = (resourceType: EnvResourceType, resourceName: string) =>

0 commit comments

Comments
 (0)