Skip to content

Commit 0ee4545

Browse files
committed
Merge branch 'develop' into feat/create-plugin
2 parents a53e8ba + 730088a commit 0ee4545

File tree

136 files changed

+4392
-1392
lines changed

Some content is hidden

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

136 files changed

+4392
-1392
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: 5 additions & 5 deletions
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.2-beta-9",
3+
"version": "0.2.16",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
@@ -23,12 +23,12 @@
2323
],
2424
"scripts": {
2525
"prepare": "node -e \"try { require('husky').install() } catch (e) {}\"",
26-
"lint": "tsc --noEmit && NODE_OPTIONS=--max_old_space_size=8192 eslint 'src/**/*.{js,jsx,ts,tsx}' --max-warnings 0",
26+
"lint": "tsc --noEmit && NODE_OPTIONS=--max_old_space_size=3072 eslint 'src/**/*.{js,jsx,ts,tsx}' --max-warnings 0",
2727
"lint-fix": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
2828
"test": "exit 0",
29-
"dev": "NODE_OPTIONS=--max_old_space_size=8192 vite",
30-
"build": "NODE_OPTIONS=--max_old_space_size=8192 vite build --sourcemap",
31-
"build-watch": "NODE_OPTIONS=--max_old_space_size=8192 vite build --sourcemap --watch",
29+
"dev": "NODE_OPTIONS=--max_old_space_size=3072 vite",
30+
"build": "NODE_OPTIONS=--max_old_space_size=3072 vite build --sourcemap",
31+
"build-watch": "NODE_OPTIONS=--max_old_space_size=3072 vite build --sourcemap --watch",
3232
"build-lib": "vite build",
3333
"preview": "vite preview",
3434
"lint-staged": "lint-staged"

src/Assets/Icon/ic-aborted.svg

Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Loading

src/Assets/Icon/ic-expand.svg

Lines changed: 19 additions & 0 deletions
Loading

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

Lines changed: 3 additions & 3 deletions
Loading

src/Assets/Icon/ic-filter.svg

Lines changed: 2 additions & 2 deletions
Loading

src/Assets/Icon/ic-lines.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Assets/Icon/ic-pulsate-status.svg

Lines changed: 21 additions & 0 deletions
Loading

src/Assets/Icon/ic-stamp.svg

Lines changed: 9 additions & 0 deletions
Loading

src/Assets/Img/delete-medium.svg

Lines changed: 9 additions & 13 deletions
Loading

src/Common/AppStatus/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
*/
1616

1717
export { default as AppStatus } from './AppStatus'
18-
export * from './utils'
18+
export * from './utils'

src/Common/AppStatus/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { TIMELINE_STATUS } from "../../Shared/constants"
17+
import { TIMELINE_STATUS } from '../../Shared/constants'
1818

1919
export const triggerStatus = (triggerDetailStatus: string): string => {
2020
const triggerStatus = triggerDetailStatus?.toUpperCase()

src/Common/ClipboardButton/ClipboardButton.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ export default function ClipboardButton({
4242
const [copied, setCopied] = useState<boolean>(false)
4343
const [enableTippy, setEnableTippy] = useState<boolean>(false)
4444

45-
const handleTextCopied = () => {setCopied(true)}
45+
const handleTextCopied = () => {
46+
setCopied(true)
47+
}
4648
const handleEnableTippy = () => setEnableTippy(true)
4749
const handleDisableTippy = () => setEnableTippy(false)
4850
const handleCopyContent = useCallback(
4951
(e?) => {
50-
if(e) stopPropagation(e)
52+
if (e) stopPropagation(e)
5153
copyToClipboard(content, handleTextCopied)
5254
},
5355
[content],

src/Common/CodeEditor/CodeEditor.tsx

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,19 @@
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'
2121
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'
2222
import { configureMonacoYaml } from 'monaco-yaml'
2323

24-
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
2524
import { ReactComponent as Info } from '../../Assets/Icon/ic-info-filled.svg'
2625
import { ReactComponent as ErrorIcon } from '../../Assets/Icon/ic-error-exclamation.svg'
2726
import { ReactComponent as WarningIcon } from '../../Assets/Icon/ic-warning.svg'
2827
import './codeEditor.scss'
2928
import 'monaco-editor'
3029

31-
import YamlWorker from '../../yaml.worker.js?worker'
3230
import { YAMLStringify, cleanKubeManifest, useJsonYaml } from '../Helper'
3331
import { useWindowSize } from '../Hooks'
3432
import Select from '../Select/Select'
@@ -46,15 +44,6 @@ import {
4644
import { CodeEditorReducer, initialState } from './CodeEditor.reducer'
4745
import { MODES } from '../Constants'
4846

49-
self.MonacoEnvironment = {
50-
getWorker(_, label) {
51-
if (label === MODES.YAML) {
52-
return new YamlWorker()
53-
}
54-
return new editorWorker()
55-
},
56-
}
57-
5847
const CodeEditorContext = React.createContext(null)
5948

6049
function useCodeEditorContext() {
@@ -66,14 +55,11 @@ function useCodeEditorContext() {
6655
}
6756

6857
/**
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-
*/
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+
* */
7561
const _onChange = {
76-
onChange: null
62+
onChange: null,
7763
}
7864

7965
const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.memo(
@@ -101,6 +87,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
10187
cleanData = false,
10288
onBlur,
10389
onFocus,
90+
adjustEditorHeightToContent = false,
10491
}) => {
10592
if (cleanData) {
10693
value = cleanKubeManifest(value)
@@ -114,6 +101,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
114101
const [state, dispatch] = useReducer(memoisedReducer, initialState({ mode, theme, value, diffView, noParsing }))
115102
const [, json, yamlCode, error] = useJsonYaml(state.code, tabSize, state.mode, !state.noParsing)
116103
const [, originalJson, originlaYaml] = useJsonYaml(defaultValue, tabSize, state.mode, !state.noParsing)
104+
const [contentHeight, setContentHeight] = useState(height)
117105
monaco.editor.defineTheme(CodeEditorThemesKeys.vsDarkDT, {
118106
base: 'vs-dark',
119107
inherit: true,
@@ -126,6 +114,18 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
126114
},
127115
})
128116

117+
monaco.editor.defineTheme(CodeEditorThemesKeys.networkStatusInterface, {
118+
base: 'vs-dark',
119+
inherit: true,
120+
rules: [
121+
// @ts-ignore
122+
{ background: '#1A1A1A' },
123+
],
124+
colors: {
125+
'editor.background': '#1A1A1A',
126+
},
127+
})
128+
129129
monaco.editor.defineTheme(CodeEditorThemesKeys.deleteDraft, {
130130
base: 'vs',
131131
inherit: true,
@@ -166,10 +166,24 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
166166
}
167167
}
168168

169+
if (adjustEditorHeightToContent) {
170+
setContentHeight(editor.getContentHeight())
171+
editor.onDidContentSizeChange(() => {
172+
setContentHeight(editor.getContentHeight())
173+
})
174+
}
175+
169176
editorRef.current = editor
170177
monacoRef.current = monaco
171178
}
172179

180+
const editorHeight = useMemo(() => {
181+
if (!adjustEditorHeightToContent) {
182+
return height
183+
}
184+
return contentHeight
185+
}, [height, contentHeight, adjustEditorHeightToContent])
186+
173187
useEffect(() => {
174188
if (!validatorSchema) {
175189
return
@@ -282,7 +296,9 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
282296
}
283297

284298
return (
285-
<CodeEditorContext.Provider value={{ dispatch, state, handleLanguageChange, error, defaultValue, height }}>
299+
<CodeEditorContext.Provider
300+
value={{ dispatch, state, handleLanguageChange, error, defaultValue, height: editorHeight }}
301+
>
286302
{children}
287303
{loading ? (
288304
<CodeEditorPlaceholder customLoader={customLoader} />
@@ -300,7 +316,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
300316
options={diffViewOptions}
301317
theme={state.theme.toLowerCase().split(' ').join('-')}
302318
editorDidMount={editorDidMount}
303-
height={height}
319+
height={editorHeight}
304320
width="100%"
305321
/>
306322
) : (
@@ -311,7 +327,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
311327
options={options}
312328
onChange={handleOnChange}
313329
editorDidMount={editorDidMount}
314-
height={height}
330+
height={editorHeight}
315331
width="100%"
316332
/>
317333
)}

src/Common/CodeEditor/codeEditor.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
overflow: hidden;
2626
}
2727

28-
.radio-group input[type=checkbox]:checked+.radio__item-label {
28+
.radio-group input[type='checkbox']:checked + .radio__item-label {
2929
background: var(--N700);
3030
border-radius: 0;
3131
color: var(--white);
@@ -165,3 +165,9 @@
165165
.monaco-editor-hover {
166166
margin-left: 40px;
167167
}
168+
169+
.monaco-scrollable-element {
170+
& > .visible {
171+
z-index: 9;
172+
}
173+
}

0 commit comments

Comments
 (0)