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 patch merge strategy in deployment template #369

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
4a2ff35
feat: add support for other strategies in OverrideStrategyTippyContent
AbhishekA1509 Oct 24, 2024
0c96409
feat: add Enterprise Tag
AbhishekA1509 Oct 24, 2024
468f212
feat: add patch merge strategy type
AbhishekA1509 Oct 24, 2024
81d14a9
feat: add non-scaling-stroke on icons related to dt
AbhishekA1509 Oct 24, 2024
6d0697c
feat: add UNPROCESSABLE_CONTENT in API_STATUS_CODE
AbhishekA1509 Oct 24, 2024
caaa07c
refactor: update CodeEditor component to use schemaURI instead of cha…
AbhishekA1509 Oct 24, 2024
8794393
feat: add mergeTemplate as mandatory key in case of override
AbhishekA1509 Oct 25, 2024
b4cd5da
fix: use useEffectAfterMount to setCode instead of useEffect
Elessar1802 Nov 8, 2024
18e0a80
Merge branch 'develop' into feat/patch-dt
AbhishekA1509 Nov 12, 2024
9bd8bf6
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-l…
Elessar1802 Nov 12, 2024
9ffc7a4
feat: add getNullValueFromType util func
Elessar1802 Nov 12, 2024
bb7d1dc
chore: version bump
Elessar1802 Nov 12, 2024
95a6b2c
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-l…
Elessar1802 Nov 12, 2024
a2684bf
chore: use type format for exporting types
Elessar1802 Nov 12, 2024
5d6210b
Merge branch 'develop' into feat/patch-dt
AbhishekA1509 Nov 13, 2024
8bdd2ca
chore: update version to 1.0.3-beta-2 in package.json and package-loc…
AbhishekA1509 Nov 13, 2024
c7dd2a8
feat: add DEFAULT_JSON_SCHEMA_URI constant and set default schemaURI …
AbhishekA1509 Nov 13, 2024
8483915
Merge branch 'feat/patch-dt' of github.com:devtron-labs/devtron-fe-co…
Elessar1802 Nov 13, 2024
b905a42
Merge branch 'feat/patch-dt' of github.com:devtron-labs/devtron-fe-co…
Elessar1802 Nov 13, 2024
0f364b4
refactor: streamline DeploymentTemplateConfigCommonState by consolida…
AbhishekA1509 Nov 13, 2024
44dabaa
chore: update version to 1.0.3-beta-7 in package.json and package-loc…
AbhishekA1509 Nov 13, 2024
422657a
Merge branch 'feat/patch-dt' of github.com:devtron-labs/devtron-fe-co…
Elessar1802 Nov 14, 2024
541d111
Merge branch 'feat/patch-dt' of github.com:devtron-labs/devtron-fe-co…
RohitRaj011 Nov 14, 2024
2218fe4
chore: remove unused imports in code editor
Elessar1802 Nov 14, 2024
46a83b3
feat: add default merge strategy flag
AbhishekA1509 Nov 14, 2024
e04a58e
fix: allow mergedTemplate to be null in DeploymentTemplateConfigCommo…
AbhishekA1509 Nov 14, 2024
fb89c7f
refactor: useForm - triggerDirty reset option, ConfigDatum - types add
RohitRaj011 Nov 15, 2024
7ee317d
Merge branch 'feat/patch-dt' of github.com:devtron-labs/devtron-fe-co…
RohitRaj011 Nov 15, 2024
e4ab2c2
chore: version bump
RohitRaj011 Nov 15, 2024
fa4f2f5
fix: review comments
Elessar1802 Nov 21, 2024
46e17ff
Merge pull request #393 from devtron-labs/feat/rjsf-field-selector
Elessar1802 Nov 21, 2024
74cf9f4
feat: add types to support loading merged template and mergedTemplate…
AbhishekA1509 Nov 22, 2024
48f792a
Merge branch 'feat/patch-dt' of github.com:devtron-labs/devtron-fe-co…
RohitRaj011 Nov 22, 2024
81d80f7
Merge branch 'develop' into feat/patch-dt
AbhishekA1509 Nov 22, 2024
77d9bc9
Merge branch 'feat/patch-dt' of github.com:devtron-labs/devtron-fe-co…
RohitRaj011 Nov 22, 2024
96becb8
chore: version bump
RohitRaj011 Nov 22, 2024
284495f
fix: await post in getDeploymentManifest to showError
AbhishekA1509 Nov 24, 2024
a5b3e9e
feat: Collapsible List - add support to clear query params while navi…
RohitRaj011 Nov 26, 2024
6b0214a
fix: applyCompareDiffOnUneditedDocument - function updating original …
RohitRaj011 Nov 27, 2024
310e5bf
chore: version bump
RohitRaj011 Nov 27, 2024
b831f31
Merge branch 'feat/patch-dt' of github.com:devtron-labs/devtron-fe-co…
RohitRaj011 Nov 29, 2024
914b3d4
chore: version bump
RohitRaj011 Nov 29, 2024
4b4dfbc
fix: ResizableTagTextArea - incorrect null check for dependentRef pro…
RohitRaj011 Nov 29, 2024
9e48d0d
chore: version bump
RohitRaj011 Nov 29, 2024
6050954
refactor: types update
RohitRaj011 Dec 2, 2024
ea4eb30
chore: version bump
RohitRaj011 Dec 2, 2024
7e65cdf
Merge branch 'develop' into feat/patch-dt
AbhishekA1509 Dec 3, 2024
713af0d
Merge branch 'feat/patch-dt' of github.com:devtron-labs/devtron-fe-co…
RohitRaj011 Dec 3, 2024
601fe08
chore: version bump
RohitRaj011 Dec 3, 2024
07a0abd
fix: add null check for markdown
AbhishekA1509 Dec 3, 2024
375c291
Merge pull request #434 from devtron-labs/fix/markdown-null-check
AbhishekA1509 Dec 4, 2024
80e3dff
Merge pull request #421 from devtron-labs/feat/cm-secret-patch-dry-run
RohitRaj011 Dec 4, 2024
c70dbf8
chore: version bump
RohitRaj011 Dec 4, 2024
1f2fd13
Merge branch 'develop' into feat/patch-dt
AbhishekA1509 Dec 5, 2024
293d1e8
bump version to 1.2.3-beta-2 in package.json and package-lock.json
AbhishekA1509 Dec 5, 2024
17f9e15
chore: update to common beta-6
AbhishekA1509 Dec 5, 2024
651787c
bump version to 1.2.3-beta-7 in package.json
AbhishekA1509 Dec 5, 2024
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.2.3",
"version": "1.2.3-beta-7",
"description": "Supporting common component library",
"type": "module",
"main": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions src/Assets/Icon/ic-file-code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/Assets/Icon/ic-medal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions src/Assets/Icon/ic-stamp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 0 additions & 20 deletions src/Assets/Icon/ic-visibility-on.svg

This file was deleted.

27 changes: 26 additions & 1 deletion src/Common/CodeEditor/CodeEditor.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

import YAML from 'yaml'
import { noop, YAMLStringify } from '@Common/Helper'
import { MODES } from '../Constants'
import { Action, CodeEditorInitialValueType, CodeEditorState, CodeEditorThemesKeys } from './types'

Expand All @@ -34,16 +36,39 @@ export const CodeEditorReducer = (state: CodeEditorState, action: Action) => {
}
}

export const parseValueToCode = (value: string, mode: string, tabSize: number) => {
let obj = null

try {
obj = JSON.parse(value)
} catch {
try {
obj = YAML.parse(value)
} catch {
noop()
}
}

let final = value

if (obj) {
final = mode === MODES.JSON ? JSON.stringify(obj, null, tabSize) : YAMLStringify(obj)
}

return final
}

export const initialState = ({
mode,
theme,
value,
diffView,
noParsing,
tabSize,
}: CodeEditorInitialValueType): CodeEditorState => ({
mode: mode as MODES,
theme: (theme || CodeEditorThemesKeys.vs) as CodeEditorThemesKeys,
code: value,
code: parseValueToCode(value, mode, tabSize),
diffMode: diffView,
noParsing: [MODES.JSON, MODES.YAML].includes(mode as MODES) ? noParsing : true,
})
38 changes: 12 additions & 26 deletions src/Common/CodeEditor/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import React, { useEffect, useMemo, useReducer, useRef, useState } from 'react'
import MonacoEditor, { MonacoDiffEditor } from 'react-monaco-editor'
import YAML from 'yaml'
import ReactGA from 'react-ga4'
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'
import { configureMonacoYaml } from 'monaco-yaml'
Expand All @@ -27,7 +26,7 @@ import { ReactComponent as ErrorIcon } from '../../Assets/Icon/ic-error-exclamat
import './codeEditor.scss'
import 'monaco-editor'

import { YAMLStringify, cleanKubeManifest, useJsonYaml } from '../Helper'
import { cleanKubeManifest, useEffectAfterMount, useJsonYaml } from '../Helper'
import { useWindowSize } from '../Hooks'
import Select from '../Select/Select'
import RadioGroup from '../RadioGroup/RadioGroup'
Expand All @@ -41,8 +40,8 @@ import {
CodeEditorThemesKeys,
InformationBarProps,
} from './types'
import { CodeEditorReducer, initialState } from './CodeEditor.reducer'
import { MODES } from '../Constants'
import { CodeEditorReducer, initialState, parseValueToCode } from './CodeEditor.reducer'
import { DEFAULT_JSON_SCHEMA_URI, MODES } from '../Constants'

const CodeEditorContext = React.createContext(null)

Expand Down Expand Up @@ -76,7 +75,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
customLoader,
focus,
validatorSchema,
chartVersion,
schemaURI = DEFAULT_JSON_SCHEMA_URI,
isKubernetes = true,
cleanData = false,
onBlur,
Expand All @@ -93,16 +92,13 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
const monacoRef = useRef(null)
const { width, height: windowHeight } = useWindowSize()
const memoisedReducer = React.useCallback(CodeEditorReducer, [])
const [state, dispatch] = useReducer(memoisedReducer, initialState({ mode, theme, value, diffView, noParsing }))
const [state, dispatch] = useReducer(memoisedReducer, initialState({ mode, theme, value, diffView, noParsing, tabSize }))
const [, json, yamlCode, error] = useJsonYaml(state.code, tabSize, state.mode, !state.noParsing)
const [, originalJson, originlaYaml] = useJsonYaml(defaultValue, tabSize, state.mode, !state.noParsing)
const [contentHeight, setContentHeight] = useState(
adjustEditorHeightToContent ? INITIAL_HEIGHT_WHEN_DYNAMIC_HEIGHT : height,
)
/**
* TODO: can be removed with this new merge into react-monaco-editor :)
* see: https://github.com/react-monaco-editor/react-monaco-editor/pull/955
* */
// TODO: upgrade to 0.56.2 to remove this
const onChangeRef = useRef(onChange)
onChangeRef.current = onChange
monaco.editor.defineTheme(CodeEditorThemesKeys.vsDarkDT, {
Expand Down Expand Up @@ -230,7 +226,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
isKubernetes,
schemas: [
{
uri: `https://github.com/devtron-labs/devtron/tree/main/scripts/devtron-reference-helm-charts/reference-chart_${chartVersion}/schema.json`, // id of the first schema
uri: schemaURI,
fileMatch: ['*'], // associate with our model
schema: validatorSchema,
},
Expand All @@ -240,7 +236,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
config.dispose()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [validatorSchema, chartVersion])
}, [validatorSchema, schemaURI])
useEffect(() => {
if (!editorRef.current) {
return
Expand All @@ -260,28 +256,18 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
onChangeRef.current?.(value)
}

useEffect(() => {
useEffectAfterMount(() => {
if (noParsing) {
setCode(value)

return
}
let obj

if (value === state.code) {
return
}
try {
obj = JSON.parse(value)
} catch (err) {
try {
obj = YAML.parse(value)
} catch (err) {}
}
let final = value
if (obj) {
final = state.mode === 'json' ? JSON.stringify(obj, null, tabSize) : YAMLStringify(obj)
}
setCode(final)

setCode(parseValueToCode(value, state.mode, tabSize))
}, [value, noParsing])

useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/Common/CodeEditor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ interface CodeEditorBaseInterface {
validatorSchema?: any
isKubernetes?: boolean
cleanData?: boolean
chartVersion?: any
schemaURI?: string
/**
* If true, disable the in-built search of monaco editor
* @default false
Expand Down Expand Up @@ -109,6 +109,7 @@ export interface CodeEditorInitialValueType {
theme?: string
value: string
noParsing?: boolean
tabSize: number
}

export interface CodeEditorState {
Expand Down
2 changes: 2 additions & 0 deletions src/Common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const Host = window?.__ORCHESTRATOR_ROOT__ ?? '/orchestrator'
export const DOCUMENTATION_HOME_PAGE = 'https://docs.devtron.ai'
export const DOCUMENTATION_VERSION = '/v/v0.7'
export const DISCORD_LINK = 'https://discord.devtron.ai/'
export const DEFAULT_JSON_SCHEMA_URI = 'https://json-schema.org/draft/2020-12/schema'
export const DOCUMENTATION = {
APP_METRICS: `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/usage/applications/app-details/app-metrics`,
APP_TAGS: `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/usage/applications/create-application#tags`,
Expand Down Expand Up @@ -514,6 +515,7 @@ export const API_STATUS_CODES = {
EXPECTATION_FAILED: 417,
UNPROCESSABLE_ENTITY: 422,
LOCKED: 423,
UNPROCESSABLE_CONTENT: 422,
}

export enum SERVER_MODE {
Expand Down
6 changes: 3 additions & 3 deletions src/Common/CustomTagSelector/ResizableTagTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export const ResizableTagTextArea = ({

const reInitHeight = () => {
refVar.current.style.height = `${minHeight}px`
if (dependentRef) {
if (dependentRef?.current) {
dependentRef.current.style.height = `${minHeight}px`
}
let nextHeight = refVar.current.scrollHeight
if (dependentRef && nextHeight < dependentRef.current.scrollHeight) {
if (dependentRef?.current && nextHeight < dependentRef.current.scrollHeight) {
nextHeight = dependentRef.current.scrollHeight
}
if (minHeight && nextHeight < minHeight) {
Expand All @@ -62,7 +62,7 @@ export const ResizableTagTextArea = ({
nextHeight = maxHeight
}
refVar.current.style.height = `${nextHeight}px`
if (dependentRef) {
if (dependentRef?.current) {
dependentRef.current.style.height = `${nextHeight}px`
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import React, { SyntheticEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import DOMPurify from 'dompurify'
import { JSONPath, JSONPathOptions } from 'jsonpath-plus'
import { compare as compareJSON, applyPatch, unescapePathComponent } from 'fast-json-patch'
import { compare as compareJSON, applyPatch, unescapePathComponent,deepClone } from 'fast-json-patch'
import { components } from 'react-select'
import * as Sentry from '@sentry/browser'
import moment from 'moment'
Expand Down Expand Up @@ -667,7 +667,7 @@ export const flatMapOfJSONPaths = (

export const applyCompareDiffOnUneditedDocument = (uneditedDocument: object, editedDocument: object) => {
const patch = compareJSON(uneditedDocument, editedDocument)
return applyPatch(uneditedDocument, patch).newDocument
return applyPatch(deepClone(uneditedDocument), patch).newDocument
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/Common/Markdown/MarkDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ import './markdown.scss'

const renderer = new marked.Renderer()

const MarkDown = ({ setExpandableIcon, markdown, className, breaks, disableEscapedText, ...props }: MarkDownProps) => {
const MarkDown = ({
setExpandableIcon,
markdown: markdownProp,
className,
breaks,
disableEscapedText,
...props
}: MarkDownProps) => {
const markdown = markdownProp || ''
const mdeRef = useRef(null)

const getHeight = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/Common/RJSF/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
*/

export { RJSFForm } from './Form'
export * from './types'
export type * from './types'
export { getInferredTypeFromValueType, getRedirectionProps } from './utils'
export { HIDE_SUBMIT_BUTTON_UI_SCHEMA } from './constants'
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { ViewError as GUIViewError } from './utils'
export type { ViewErrorType as GUIViewErrorType } from './types'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export interface ViewErrorType extends Record<'title' | 'subTitle', string> {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ViewErrorType } from './types'

export class ViewError implements ViewErrorType {
title: string = ''

subTitle: string = ''

constructor(title: string, subTitle: string) {
this.title = title
this.subTitle = subTitle
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './GUIView'
1 change: 1 addition & 0 deletions src/Pages/App/AppConfiguration/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './DeploymentTemplate'
1 change: 1 addition & 0 deletions src/Pages/App/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './AppConfiguration'
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export const getDeploymentManifest = async (
valuesAndManifestFlag: ValuesAndManifestFlagDTO.MANIFEST,
}

return post<ResolvedDeploymentTemplateDTO>(ROUTES.APP_TEMPLATE_DATA, payload, { signal: abortSignal })
const response = await post<ResolvedDeploymentTemplateDTO>(ROUTES.APP_TEMPLATE_DATA, payload, {
signal: abortSignal,
})

return response
} catch (error) {
if (!getIsRequestAborted(error)) {
showError(error)
Expand Down
Loading
Loading