Skip to content

Commit a219b58

Browse files
authored
Merge pull request #543 from devtron-labs/feat/hibernation-patch
feat: add yaml validator util
2 parents 41d2add + 5e54311 commit a219b58

File tree

10 files changed

+58
-22
lines changed

10 files changed

+58
-22
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.7.9",
3+
"version": "1.7.10",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const URLS = {
7474
DEPLOYMENT_HISTORY_CONFIGURATIONS: '/configuration',
7575
GLOBAL_CONFIG_SCOPED_VARIABLES: '/global-config/scoped-variables',
7676
GLOBAL_CONFIG_DEPLOYMENT_CHARTS_LIST: '/global-config/deployment-charts',
77+
GLOBAL_CONFIG_DEPLOYMENT_CHARTS_UPLOAD_CHART: '/global-config/deployment-charts/upload-chart',
7778
NETWORK_STATUS_INTERFACE: '/network-status-interface',
7879
RESOURCE_BROWSER: '/resource-browser',
7980
COMPARE_CLUSTERS: '/compare-clusters',

src/Common/TippyCustomized.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { ReactComponent as Help } from '../Assets/Icon/ic-help.svg'
2121
import { ReactComponent as ICHelpOutline } from '../Assets/Icon/ic-help-outline.svg'
2222
import { ReactComponent as ICOpenInNew } from '../Assets/Icon/ic-open-in-new.svg'
2323
import 'tippy.js/animations/shift-toward-subtle.css'
24+
import 'tippy.js/animations/shift-toward.css'
2425
import { TippyCustomizedProps, TippyTheme } from './Types'
2526
import { not, stopPropagation } from './Helper'
2627

src/Pages/GlobalConfigurations/DeploymentCharts/types.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
* limitations under the License.
1515
*/
1616

17-
export type DeploymentChartListDTO = Array<{
17+
interface DeploymentChartInfo {
1818
id: number
1919
chartDescription?: string
2020
isUserUploaded: boolean
2121
name: string
2222
version: string
23-
}>
23+
uploadedBy: string
24+
}
2425

25-
interface DeploymentChartVersionsType {
26-
id: number
27-
version: string
26+
export type DeploymentChartListDTO = DeploymentChartInfo[]
27+
28+
export interface DeploymentChartVersionsType
29+
extends Pick<DeploymentChartInfo, 'id' | 'version' | 'uploadedBy' | 'isUserUploaded'> {
2830
description: string
2931
}
3032

31-
export interface DeploymentChartType {
32-
name: string
33-
isUserUploaded: boolean
33+
export interface DeploymentChartType extends Pick<DeploymentChartInfo, 'name'> {
3434
versions: DeploymentChartVersionsType[]
3535
}
3636

src/Pages/GlobalConfigurations/DeploymentCharts/utils.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,37 @@
1515
*/
1616

1717
import { versionComparatorBySortOrder } from '@Shared/Helpers'
18-
import { DeploymentChartListDTO, DeploymentChartType, DEVTRON_DEPLOYMENT_CHART_NAMES } from './types'
18+
import {
19+
DeploymentChartListDTO,
20+
DeploymentChartType,
21+
DeploymentChartVersionsType,
22+
DEVTRON_DEPLOYMENT_CHART_NAMES,
23+
} from './types'
1924
import fallbackGuiSchema from './basicViewSchema.json'
2025

2126
export const convertDeploymentChartListToChartType = (data: DeploymentChartListDTO): DeploymentChartType[] => {
2227
if (!data) {
2328
return []
2429
}
25-
const chartMap = data.reduce(
26-
(acc, { id, version, chartDescription: description = '', name, isUserUploaded = true }) => {
30+
const chartMap = data.reduce<Record<string, DeploymentChartType>>(
31+
(acc, { id, version, chartDescription, name, isUserUploaded, uploadedBy }) => {
2732
if (!name || !id || !version) {
2833
return acc
2934
}
35+
const currVersionDetail: DeploymentChartVersionsType = {
36+
id,
37+
version,
38+
description: chartDescription || '',
39+
uploadedBy: isUserUploaded ? uploadedBy || '' : 'Devtron',
40+
isUserUploaded,
41+
}
3042
const detail = acc[name]
3143
if (detail) {
32-
detail.versions.push({
33-
id,
34-
version,
35-
description,
36-
})
44+
detail.versions.push(currVersionDetail)
3745
} else {
3846
acc[name] = {
3947
name,
40-
isUserUploaded,
41-
versions: [{ id, version, description }],
48+
versions: [currVersionDetail],
4249
}
4350
}
4451
return acc

src/Shared/Components/InfoIconTippy/InfoIconTippy.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ const InfoIconTippy = ({
4747
documentationLink={documentationLink}
4848
documentationLinkText={documentationLinkText}
4949
additionalContent={additionalContent}
50+
animation="shift-toward"
51+
duration={400}
5052
>
5153
{children || (
5254
<button

src/Shared/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,3 +1012,8 @@ export interface BorderConfigType {
10121012
*/
10131013
left?: boolean
10141014
}
1015+
1016+
export interface AppEnvIdType {
1017+
appId: number
1018+
envId: number
1019+
}

src/Shared/validations.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { getSanitizedIframe } from '@Common/Helper'
1818
import { customizeValidator } from '@rjsf/validator-ajv8'
1919
import { PATTERNS } from '@Common/Constants'
20+
import { parse } from 'yaml'
2021
import { URLProtocolType } from './types'
2122
import { SKIP_LABEL_KEY_VALIDATION_PREFIX } from './constants'
2223

@@ -472,3 +473,23 @@ export const validateCMVolumeMountPath = (value: string): { isValid: boolean; me
472473
}
473474
return { isValid: true, message: '' }
474475
}
476+
477+
export const validateYAML = (yamlString: string, isRequired?: boolean): ValidationResponseType => {
478+
try {
479+
if (!yamlString && isRequired) {
480+
return {
481+
isValid: false,
482+
message: 'This field is required',
483+
}
484+
}
485+
parse(yamlString)
486+
return {
487+
isValid: true,
488+
}
489+
} catch (err) {
490+
return {
491+
isValid: false,
492+
message: err.message,
493+
}
494+
}
495+
}

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export interface customEnv {
4646
CENTRAL_API_ENDPOINT?: string
4747
HIDE_GITOPS_OR_HELM_OPTION?: boolean
4848
CONFIGURABLE_TIMEOUT?: string
49-
HIDE_APPLICATION_GROUPS?: boolean
5049
K8S_CLIENT?: boolean
5150
CLUSTER_TERMINAL_CONNECTION_POLLING_INTERVAL?: number
5251
CLUSTER_TERMINAL_CONNECTION_RETRY_COUNT?: number

0 commit comments

Comments
 (0)