Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add yaml validator util #543

Merged
merged 28 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4151d87
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Jan 23, 2025
af7524c
feat: add support for uploadedBy in deployment chart list api
arunjaindev Jan 23, 2025
ed87255
feat: add deployment chart uploaded by devtron in service
arunjaindev Jan 23, 2025
16dab12
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Jan 24, 2025
c455a76
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Jan 27, 2025
38b1ff4
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Jan 27, 2025
9db3e13
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Jan 29, 2025
258225c
feat: add yaml validator util
arunjaindev Jan 29, 2025
6a0ec69
fix: add null check for validator schema in code editor
arunjaindev Jan 29, 2025
d16b485
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Jan 31, 2025
e255b70
Merge branch 'feat/revamp-deployments-charts' of https://github.com/d…
arunjaindev Jan 31, 2025
7a76975
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Feb 3, 2025
0cc3333
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Feb 4, 2025
5390c46
feat: add parsing in chart list api
arunjaindev Feb 4, 2025
0c8efa3
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Feb 5, 2025
dbd7ae6
feat: add param required in yaml validator util
arunjaindev Feb 5, 2025
d499def
chore: use reuiredField util
arunjaindev Feb 5, 2025
12f7c8a
chore: revert validator
arunjaindev Feb 5, 2025
23ecf17
chore: version bump
arunjaindev Feb 5, 2025
2093099
fix: remove fallback for isUserUploaded key
arunjaindev Feb 5, 2025
b44314a
chore: version bump
arunjaindev Feb 6, 2025
bc91cc1
Merge branch 'develop' into feat/hibernation-patch
AbhishekA1509 Feb 15, 2025
b26dd56
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Feb 17, 2025
653e4e4
chore: version bump
arunjaindev Feb 17, 2025
26c44ab
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Feb 18, 2025
c187ec4
feat: add animation in tippy customized
arunjaindev Feb 18, 2025
c8504c9
Merge branch 'develop' of https://github.com/devtron-labs/devtron-fe-…
arunjaindev Feb 20, 2025
5e54311
feat: remove hide app group feature flag
arunjaindev Feb 20, 2025
File filter

Filter by extension

Filter by extension


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

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtron-labs/devtron-fe-common-lib",
"version": "1.7.9",
"version": "1.7.10",
"description": "Supporting common component library",
"type": "module",
"main": "dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions src/Common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const URLS = {
DEPLOYMENT_HISTORY_CONFIGURATIONS: '/configuration',
GLOBAL_CONFIG_SCOPED_VARIABLES: '/global-config/scoped-variables',
GLOBAL_CONFIG_DEPLOYMENT_CHARTS_LIST: '/global-config/deployment-charts',
GLOBAL_CONFIG_DEPLOYMENT_CHARTS_UPLOAD_CHART: '/global-config/deployment-charts/upload-chart',
NETWORK_STATUS_INTERFACE: '/network-status-interface',
RESOURCE_BROWSER: '/resource-browser',
COMPARE_CLUSTERS: '/compare-clusters',
Expand Down
1 change: 1 addition & 0 deletions src/Common/TippyCustomized.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ReactComponent as Help } from '../Assets/Icon/ic-help.svg'
import { ReactComponent as ICHelpOutline } from '../Assets/Icon/ic-help-outline.svg'
import { ReactComponent as ICOpenInNew } from '../Assets/Icon/ic-open-in-new.svg'
import 'tippy.js/animations/shift-toward-subtle.css'
import 'tippy.js/animations/shift-toward.css'
import { TippyCustomizedProps, TippyTheme } from './Types'
import { not, stopPropagation } from './Helper'

Expand Down
16 changes: 8 additions & 8 deletions src/Pages/GlobalConfigurations/DeploymentCharts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@
* limitations under the License.
*/

export type DeploymentChartListDTO = Array<{
interface DeploymentChartInfo {
id: number
chartDescription?: string
isUserUploaded: boolean
name: string
version: string
}>
uploadedBy: string
}

interface DeploymentChartVersionsType {
id: number
version: string
export type DeploymentChartListDTO = DeploymentChartInfo[]

export interface DeploymentChartVersionsType
extends Pick<DeploymentChartInfo, 'id' | 'version' | 'uploadedBy' | 'isUserUploaded'> {
description: string
}

export interface DeploymentChartType {
name: string
isUserUploaded: boolean
export interface DeploymentChartType extends Pick<DeploymentChartInfo, 'name'> {
versions: DeploymentChartVersionsType[]
}

Expand Down
27 changes: 17 additions & 10 deletions src/Pages/GlobalConfigurations/DeploymentCharts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,37 @@
*/

import { versionComparatorBySortOrder } from '@Shared/Helpers'
import { DeploymentChartListDTO, DeploymentChartType, DEVTRON_DEPLOYMENT_CHART_NAMES } from './types'
import {
DeploymentChartListDTO,
DeploymentChartType,
DeploymentChartVersionsType,
DEVTRON_DEPLOYMENT_CHART_NAMES,
} from './types'
import fallbackGuiSchema from './basicViewSchema.json'

export const convertDeploymentChartListToChartType = (data: DeploymentChartListDTO): DeploymentChartType[] => {
if (!data) {
return []
}
const chartMap = data.reduce(
(acc, { id, version, chartDescription: description = '', name, isUserUploaded = true }) => {
const chartMap = data.reduce<Record<string, DeploymentChartType>>(
(acc, { id, version, chartDescription, name, isUserUploaded, uploadedBy }) => {
if (!name || !id || !version) {
return acc
}
const currVersionDetail: DeploymentChartVersionsType = {
id,
version,
description: chartDescription || '',
uploadedBy: isUserUploaded ? uploadedBy || '' : 'Devtron',
isUserUploaded,
}
const detail = acc[name]
if (detail) {
detail.versions.push({
id,
version,
description,
})
detail.versions.push(currVersionDetail)
} else {
acc[name] = {
name,
isUserUploaded,
versions: [{ id, version, description }],
versions: [currVersionDetail],
}
}
return acc
Expand Down
2 changes: 2 additions & 0 deletions src/Shared/Components/InfoIconTippy/InfoIconTippy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const InfoIconTippy = ({
documentationLink={documentationLink}
documentationLinkText={documentationLinkText}
additionalContent={additionalContent}
animation="shift-toward"
duration={400}
>
{children || (
<button
Expand Down
5 changes: 5 additions & 0 deletions src/Shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1012,3 +1012,8 @@ export interface BorderConfigType {
*/
left?: boolean
}

export interface AppEnvIdType {
appId: number
envId: number
}
21 changes: 21 additions & 0 deletions src/Shared/validations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { getSanitizedIframe } from '@Common/Helper'
import { customizeValidator } from '@rjsf/validator-ajv8'
import { PATTERNS } from '@Common/Constants'
import { parse } from 'yaml'
import { URLProtocolType } from './types'
import { SKIP_LABEL_KEY_VALIDATION_PREFIX } from './constants'

Expand Down Expand Up @@ -472,3 +473,23 @@ export const validateCMVolumeMountPath = (value: string): { isValid: boolean; me
}
return { isValid: true, message: '' }
}

export const validateYAML = (yamlString: string, isRequired?: boolean): ValidationResponseType => {
try {
if (!yamlString && isRequired) {
return {
isValid: false,
message: 'This field is required',
}
}
parse(yamlString)
return {
isValid: true,
}
} catch (err) {
return {
isValid: false,
message: err.message,
}
}
}
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export interface customEnv {
CENTRAL_API_ENDPOINT?: string
HIDE_GITOPS_OR_HELM_OPTION?: boolean
CONFIGURABLE_TIMEOUT?: string
HIDE_APPLICATION_GROUPS?: boolean
K8S_CLIENT?: boolean
CLUSTER_TERMINAL_CONNECTION_POLLING_INTERVAL?: number
CLUSTER_TERMINAL_CONNECTION_RETRY_COUNT?: number
Expand Down
Loading