Skip to content

Commit 139121e

Browse files
committed
Merge branch 'main' of github.com:devtron-labs/devtron-fe-common-lib into feat/lock-deployment-configuration
2 parents 11e8db3 + d312cce commit 139121e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1833
-263
lines changed

package-lock.json

Lines changed: 50 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: 2 additions & 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.1.11-beta-7",
3+
"version": "0.1.15-beta-5",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
@@ -95,6 +95,7 @@
9595
"ansi_up": "^5.2.1",
9696
"fast-json-patch": "^3.1.1",
9797
"react-dates": "^21.8.0",
98+
"jsonpath-plus": "^9.0.0",
9899
"react-monaco-editor": "^0.54.0",
99100
"sass": "^1.69.7",
100101
"tslib": "^2.4.1"

src/Assets/Icon/ic-book-open.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Assets/Icon/ic-filter-applied.svg

Lines changed: 4 additions & 0 deletions
Loading

src/Assets/Icon/ic-filter.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Assets/Icon/ic-lego-block.svg

Lines changed: 20 additions & 0 deletions
Loading

src/Assets/Icon/ic-visibility-on.svg

Lines changed: 20 additions & 0 deletions
Loading

src/Common/CIPipeline.Types.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,3 @@ export interface FormErrorObjectType {
280280
steps: TaskErrorObj[]
281281
}
282282
}
283-
284-
export interface PluginDetailType {
285-
id: number
286-
name: string
287-
type: string
288-
description: string
289-
icon: string
290-
tags: string[]
291-
inputVariables?: VariableType[]
292-
outputVariables?: VariableType[]
293-
}

src/Common/CodeEditor/CodeEditor.tsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ function useCodeEditorContext() {
6565
return context
6666
}
6767

68+
/**
69+
* NOTE: once monaco editor mounts it doesn't update it's internal onChange state.
70+
* Since most of the time onChange methods are declared inside the render body of a component
71+
* we should use the latest references of onChange.
72+
* Please see: https://github.com/react-monaco-editor/react-monaco-editor/issues/704
73+
* Thus as a hack we are using this objects reference to call the latest onChange reference
74+
*/
75+
const _onChange = {
76+
onChange: null
77+
}
78+
6879
const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.memo(
6980
({
7081
value,
@@ -100,7 +111,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
100111
const monacoRef = useRef(null)
101112
const { width, height: windowHeight } = useWindowSize()
102113
const memoisedReducer = React.useCallback(CodeEditorReducer, [])
103-
const [state, dispatch] = useReducer(memoisedReducer, initialState({mode, theme, value, diffView, noParsing}))
114+
const [state, dispatch] = useReducer(memoisedReducer, initialState({ mode, theme, value, diffView, noParsing }))
104115
const [, json, yamlCode, error] = useJsonYaml(state.code, tabSize, state.mode, !state.noParsing)
105116
const [, originalJson, originlaYaml] = useJsonYaml(defaultValue, tabSize, state.mode, !state.noParsing)
106117
monaco.editor.defineTheme(CodeEditorThemesKeys.vsDarkDT, {
@@ -193,15 +204,19 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
193204
editorRef.current.layout()
194205
}, [width, windowHeight])
195206

196-
useEffect(() => {
197-
if (onChange) {
198-
onChange(state.code)
199-
}
200-
}, [state.code])
207+
/**
208+
* NOTE: Please see @_onChange variable
209+
*/
210+
_onChange.onChange = onChange
211+
212+
const setCode = (value: string) => {
213+
dispatch({ type: 'setCode', value })
214+
_onChange.onChange?.(value)
215+
}
201216

202217
useEffect(() => {
203218
if (noParsing) {
204-
dispatch({ type: 'setCode', value })
219+
setCode(value)
205220

206221
return
207222
}
@@ -220,7 +235,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
220235
if (obj) {
221236
final = state.mode === 'json' ? JSON.stringify(obj, null, tabSize) : YAMLStringify(obj)
222237
}
223-
dispatch({ type: 'setCode', value: final })
238+
setCode(final)
224239
}, [value, noParsing])
225240

226241
useEffect(() => {
@@ -234,12 +249,12 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
234249
}, [focus])
235250

236251
function handleOnChange(newValue, e) {
237-
dispatch({ type: 'setCode', value: newValue })
252+
setCode(newValue)
238253
}
239254

240255
function handleLanguageChange(mode: 'json' | 'yaml') {
241256
dispatch({ type: 'changeLanguage', value: mode })
242-
dispatch({ type: 'setCode', value: mode === 'json' ? json : yamlCode })
257+
setCode(mode === 'json' ? json : yamlCode)
243258
}
244259

245260
const options: monaco.editor.IEditorConstructionOptions = {

src/Common/Constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const DOCUMENTATION = {
2626
APP_TAGS: `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/usage/applications/create-application#tags`,
2727
APP_OVERVIEW_TAGS: `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/usage/applications/overview#manage-tags`,
2828
BLOB_STORAGE: `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/getting-started/install/installation-configuration#configuration-of-blob-storage`,
29+
GLOBAL_CONFIG_BUILD_INFRA: `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/global-configurations/build-infra`,
2930
}
3031

3132
export const PATTERNS = {
@@ -96,6 +97,9 @@ export const ROUTES = {
9697
RESOURCE_HISTORY_DEPLOYMENT: 'resource/history/deployment',
9798
APP_LIST_MIN: 'app/min',
9899
CLUSTER_LIST_MIN: 'cluster/autocomplete',
100+
PLUGIN_GLOBAL_LIST_DETAIL_V2: 'plugin/global/list/detail/v2',
101+
PLUGIN_GLOBAL_LIST_V2: 'plugin/global/list/v2',
102+
PLUGIN_GLOBAL_LIST_TAGS: 'plugin/global/list/tags',
99103
}
100104

101105
export enum KEY_VALUE {
@@ -478,6 +482,8 @@ export const ZERO_TIME_STRING = '0001-01-01T00:00:00Z'
478482
export const EXCLUDED_FALSY_VALUES = [undefined, null, '', NaN] as const
479483

480484
export const API_STATUS_CODES = {
485+
OK: 200,
486+
NO_CONTENT: 204,
481487
BAD_REQUEST: 400,
482488
UNAUTHORIZED: 401,
483489
PERMISSION_DENIED: 403,

0 commit comments

Comments
 (0)