Skip to content

Commit 31a38fa

Browse files
committed
Merge branch 'develop' into feat/history-ui
2 parents 15b8467 + 82d0b43 commit 31a38fa

File tree

24 files changed

+694
-26
lines changed

24 files changed

+694
-26
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": "0.2.7-beta-1",
3+
"version": "0.2.12",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/CodeEditor/CodeEditor.tsx

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

17-
import React, { useEffect, useReducer, useRef } from 'react'
17+
import React, { useEffect, useMemo, useReducer, useRef, useState } from 'react'
1818
import MonacoEditor, { MonacoDiffEditor } from 'react-monaco-editor'
1919
import YAML from 'yaml'
2020
import ReactGA from 'react-ga4'
@@ -55,12 +55,9 @@ function useCodeEditorContext() {
5555
}
5656

5757
/**
58-
* NOTE: once monaco editor mounts it doesn't update it's internal onChange state.
59-
* Since most of the time onChange methods are declared inside the render body of a component
60-
* we should use the latest references of onChange.
61-
* Please see: https://github.com/react-monaco-editor/react-monaco-editor/issues/704
62-
* Thus as a hack we are using this objects reference to call the latest onChange reference
63-
*/
58+
* TODO: can be removed with this new merge into react-monaco-editor :)
59+
* see: https://github.com/react-monaco-editor/react-monaco-editor/pull/955
60+
* */
6461
const _onChange = {
6562
onChange: null,
6663
}
@@ -90,6 +87,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
9087
cleanData = false,
9188
onBlur,
9289
onFocus,
90+
adjustEditorHeightToContent,
9391
}) => {
9492
if (cleanData) {
9593
value = cleanKubeManifest(value)
@@ -103,6 +101,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
103101
const [state, dispatch] = useReducer(memoisedReducer, initialState({ mode, theme, value, diffView, noParsing }))
104102
const [, json, yamlCode, error] = useJsonYaml(state.code, tabSize, state.mode, !state.noParsing)
105103
const [, originalJson, originlaYaml] = useJsonYaml(defaultValue, tabSize, state.mode, !state.noParsing)
104+
const [contentHeight, setContentHeight] = useState(height)
106105
monaco.editor.defineTheme(CodeEditorThemesKeys.vsDarkDT, {
107106
base: 'vs-dark',
108107
inherit: true,
@@ -167,10 +166,24 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
167166
}
168167
}
169168

169+
if (adjustEditorHeightToContent) {
170+
setContentHeight(editor.getContentHeight())
171+
editor.onDidContentSizeChange(() => {
172+
setContentHeight(editor.getContentHeight())
173+
})
174+
}
175+
170176
editorRef.current = editor
171177
monacoRef.current = monaco
172178
}
173179

180+
const editorHeight = useMemo(() => {
181+
if (!adjustEditorHeightToContent) {
182+
return height
183+
}
184+
return contentHeight
185+
}, [height, contentHeight, adjustEditorHeightToContent])
186+
174187
useEffect(() => {
175188
if (!validatorSchema) {
176189
return
@@ -283,7 +296,9 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
283296
}
284297

285298
return (
286-
<CodeEditorContext.Provider value={{ dispatch, state, handleLanguageChange, error, defaultValue, height }}>
299+
<CodeEditorContext.Provider
300+
value={{ dispatch, state, handleLanguageChange, error, defaultValue, height: editorHeight }}
301+
>
287302
{children}
288303
{loading ? (
289304
<CodeEditorPlaceholder customLoader={customLoader} />
@@ -301,7 +316,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
301316
options={diffViewOptions}
302317
theme={state.theme.toLowerCase().split(' ').join('-')}
303318
editorDidMount={editorDidMount}
304-
height={height}
319+
height={editorHeight}
305320
width="100%"
306321
/>
307322
) : (
@@ -312,7 +327,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
312327
options={options}
313328
onChange={handleOnChange}
314329
editorDidMount={editorDidMount}
315-
height={height}
330+
height={editorHeight}
316331
width="100%"
317332
/>
318333
)}

src/Common/CodeEditor/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export interface CodeEditorInterface {
4848
isKubernetes?: boolean
4949
cleanData?: boolean
5050
chartVersion?: any
51+
adjustEditorHeightToContent?: boolean
5152
}
5253

5354
export interface CodeEditorHeaderInterface {

src/Common/Constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export const URLS = {
6262
GLOBAL_CONFIG_DOCKER: '/global-config/docker',
6363
DEPLOYMENT_HISTORY_CONFIGURATIONS: '/configuration',
6464
GLOBAL_CONFIG_SCOPED_VARIABLES: '/global-config/scoped-variables',
65+
GLOBAL_CONFIG_DEPLOYMENT_CHARTS_LIST: '/global-config/deployment-charts',
6566
NETWORK_STATUS_INTERFACE: '/network-status-interface',
6667
}
6768

@@ -105,6 +106,7 @@ export const ROUTES = {
105106
PLUGIN_GLOBAL_LIST_DETAIL_V2: 'plugin/global/list/detail/v2',
106107
PLUGIN_GLOBAL_LIST_V2: 'plugin/global/list/v2',
107108
PLUGIN_GLOBAL_LIST_TAGS: 'plugin/global/list/tags',
109+
DEPLOYMENT_CHARTS_LIST: 'deployment/template/fetch',
108110
CONFIG_DATA: 'config/data',
109111
}
110112

src/Common/Helper.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,10 @@ export const processDeployedTime = (lastDeployed, isArgoInstalled) => {
562562
* @param url URL to which the search params needs to be added
563563
* @param params Object for the search parameters
564564
*/
565-
export const getUrlWithSearchParams = (url: string, params: Record<string | number, any> = {}) => {
565+
export const getUrlWithSearchParams = <T extends string | number = string | number>(
566+
url: string,
567+
params = {} as Partial<Record<T, any>>,
568+
) => {
566569
const searchParams = new URLSearchParams()
567570
Object.keys(params).forEach((key) => {
568571
if (!EXCLUDED_FALSY_VALUES.includes(params[key])) {

src/Common/RJSF/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ export const PLACEHOLDERS = {
2121
}
2222

2323
export const DEFAULT_FIELD_TITLE = 'Key not available'
24+
25+
export const HIDE_SUBMIT_BUTTON_UI_SCHEMA = {
26+
'ui:submitButtonOptions': {
27+
norender: true,
28+
},
29+
}

src/Common/RJSF/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717
export { RJSFForm } from './Form'
1818
export * from './types'
1919
export { getInferredTypeFromValueType, getRedirectionProps } from './utils'
20+
export { HIDE_SUBMIT_BUTTON_UI_SCHEMA } from './constants'

src/Pages/CDPipeline/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './types'

src/Pages/CDPipeline/types.tsx

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { BuildStageType, FormType } from '@Common/CIPipeline.Types'
2+
import { DeploymentAppTypes } from '@Common/Types'
3+
import { DeploymentStrategy } from '@Shared/Components'
4+
import { EnvListMinDTO } from '@Shared/types'
5+
6+
interface ConfigSecretType {
7+
label: string
8+
value: string
9+
type: string
10+
}
11+
12+
export interface Environment
13+
extends Pick<EnvListMinDTO, 'id' | 'active' | 'namespace' | 'isClusterCdActive'>,
14+
Partial<
15+
Pick<
16+
EnvListMinDTO,
17+
'isVirtualEnvironment' | 'allowedDeploymentTypes' | 'description' | 'isDigestEnforcedForEnv'
18+
>
19+
> {
20+
name: string
21+
clusterName: string
22+
clusterId: string
23+
}
24+
25+
export interface PipelineBuildStageType extends BuildStageType {
26+
triggerType?: string
27+
}
28+
29+
export interface SavedDeploymentStrategy extends DeploymentStrategy {
30+
isCollapsed?: boolean
31+
defaultConfig?: any
32+
yamlStr?: any
33+
jsonStr?: any
34+
}
35+
36+
export interface CustomTagType {
37+
tagPattern: string
38+
counterX: string
39+
}
40+
41+
export enum ReleaseMode {
42+
NEW_DEPLOYMENT = 'create',
43+
MIGRATE_HELM = 'link',
44+
}
45+
46+
export interface CDFormType {
47+
name: string
48+
ciPipelineId: number
49+
environmentId: number
50+
environmentName: string
51+
namespace: string
52+
environments: Environment[]
53+
deploymentAppType: string
54+
deploymentAppName?: string
55+
releaseMode: ReleaseMode
56+
triggerType: string
57+
preBuildStage?: PipelineBuildStageType
58+
postBuildStage?: PipelineBuildStageType
59+
strategies: DeploymentStrategy[]
60+
savedStrategies: SavedDeploymentStrategy[]
61+
preStageConfigMapSecretNames: { configMaps: ConfigSecretType[]; secrets: ConfigSecretType[] }
62+
postStageConfigMapSecretNames: { configMaps: ConfigSecretType[]; secrets: ConfigSecretType[] }
63+
requiredApprovals: string
64+
userApprovalConfig?: {
65+
requiredCount: number
66+
}
67+
isClusterCdActive: boolean
68+
deploymentAppCreated: boolean
69+
clusterId: string
70+
clusterName: string
71+
runPreStageInEnv: boolean
72+
runPostStageInEnv: boolean
73+
allowedDeploymentTypes: DeploymentAppTypes[]
74+
containerRegistryName: string
75+
repoName: string
76+
selectedRegistry: any
77+
generatedHelmPushAction: string
78+
}
79+
80+
export interface PipelineFormType extends Partial<FormType>, Partial<CDFormType> {
81+
name: string
82+
triggerType: string
83+
preBuildStage?: PipelineBuildStageType
84+
postBuildStage?: PipelineBuildStageType
85+
defaultTag?: string[]
86+
customTag?: CustomTagType
87+
enableCustomTag?: boolean
88+
customTagStage?: string
89+
isDigestEnforcedForPipeline?: boolean
90+
isDigestEnforcedForEnv?: boolean
91+
}

0 commit comments

Comments
 (0)