Skip to content

Commit ea00c4a

Browse files
Merge branch 'main' into feat/skip-bulk-ci
2 parents 073abd5 + db7b408 commit ea00c4a

Some content is hidden

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

41 files changed

+423
-284
lines changed

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "0.0.43",
7+
"@devtron-labs/devtron-fe-common-lib": "0.0.45",
8+
"@rjsf/core": "^5.13.3",
9+
"@rjsf/utils": "^5.13.3",
10+
"@rjsf/validator-ajv8": "^5.13.3",
811
"@sentry/browser": "^7.3.1",
912
"@sentry/integrations": "^7.3.1",
1013
"@sentry/tracing": "^7.3.1",
@@ -48,7 +51,8 @@
4851
"xterm-addon-search": "^0.9.0",
4952
"xterm-webfont": "^2.0.0",
5053
"yaml": "^1.7.2",
51-
"yamljs": "^0.3.0"
54+
"yamljs": "^0.3.0",
55+
"tippy.js": "^6.3.7"
5256
},
5357
"scripts": {
5458
"lint": "eslint src/**/*.tsx",

src/assets/img/cluster-redirect.png

-97.4 KB
Binary file not shown.

src/components/ApplicationGroup/AppGroup.service.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,23 @@ export const getWorkflows = (envID: string, appIds: string): Promise<WorkflowsRe
7979
for (const _ciConfig of ciConfig.result) {
8080
_ciConfigMap.set(_ciConfig.appId, _ciConfig)
8181
}
82-
for (const workflowResult of workflow.result.workflows) {
83-
const processWorkflowData = processWorkflow(
84-
{
85-
...workflowResult,
86-
workflows: [workflowResult],
87-
} as WorkflowResult,
88-
_ciConfigMap.get(workflowResult.appId),
89-
cdConfig.result as CdPipelineResult,
90-
externalCIConfig.result,
91-
WorkflowTrigger,
92-
WorkflowTrigger.workflow,
93-
filterChildAndSiblingCD(envID),
94-
)
95-
_workflows.push(...processWorkflowData.workflows)
96-
_filteredCIPipelines.set(workflowResult.appId, processWorkflowData.filteredCIPipelines)
82+
if (workflow?.result?.workflows) {
83+
for (const workflowResult of workflow.result.workflows) {
84+
const processWorkflowData = processWorkflow(
85+
{
86+
...workflowResult,
87+
workflows: [workflowResult],
88+
} as WorkflowResult,
89+
_ciConfigMap.get(workflowResult.appId),
90+
cdConfig.result as CdPipelineResult,
91+
externalCIConfig.result,
92+
WorkflowTrigger,
93+
WorkflowTrigger.workflow,
94+
filterChildAndSiblingCD(envID),
95+
)
96+
_workflows.push(...processWorkflowData.workflows)
97+
_filteredCIPipelines.set(workflowResult.appId, processWorkflowData.filteredCIPipelines)
98+
}
9799
}
98100
return { workflows: _workflows, filteredCIPipelines: _filteredCIPipelines }
99101
})

src/components/CIPipelineN/CustomImageTags.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ function CustomImageTags({
270270
</div>
271271
<div className="" style={{ width: '32px', height: '20px' }}>
272272
<Toggle
273-
disabled={window._env_.FORCE_SECURITY_SCANNING && formData.enableCustomTag}
274273
selected={formData.enableCustomTag}
275274
onSelect={handleCustomTagToggle}
276275
dataTestId="create-build-pipeline-custom-tag-enabled-toggle"

src/components/ClusterNodes/ClusterManifest.tsx

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ReactComponent as WarningIcon } from '../../assets/icons/ic-warning.svg
1111
import { ReactComponent as Close } from '../../assets/icons/ic-cross.svg'
1212
import { defaultManifestErrorText, manifestCommentsRegex } from './constants'
1313
import { EditModeType } from '../v2/appDetails/k8Resource/nodeDetail/NodeDetailTabs/terminal/constants'
14+
import { getTrimmedManifestData } from '../v2/appDetails/k8Resource/nodeDetail/nodeDetail.util'
1415

1516
export default function ClusterManifest({
1617
terminalAccessId,
@@ -19,8 +20,12 @@ export default function ClusterManifest({
1920
setManifestData,
2021
errorMessage,
2122
setManifestAvailable,
22-
selectTerminalTab
23+
selectTerminalTab,
24+
hideManagedFields,
2325
}: ClusterManifestType) {
26+
// Manifest data with managed fields
27+
const [originalManifest, setOriginalManifest] = useState('')
28+
// Manifest data that we would be comparing with the edited manifest
2429
const [defaultManifest, setDefaultManifest] = useState('')
2530
const [manifestValue, setManifest] = useState('')
2631
const [loading, setLoading] = useState<boolean>(true)
@@ -32,8 +37,16 @@ export default function ClusterManifest({
3237
getClusterManifest(terminalAccessId)
3338
.then((response) => {
3439
const _manifest = YAML.stringify(response.result?.manifest)
35-
setDefaultManifest(_manifest)
36-
setManifest(_manifest)
40+
setOriginalManifest(_manifest)
41+
const trimmedManifest = YAML.stringify(getTrimmedManifestData(response.result?.manifest))
42+
setDefaultManifest(trimmedManifest)
43+
// Ideally should have been setManifest(trimmedManifest).
44+
if (hideManagedFields) {
45+
setManifest(trimmedManifest)
46+
}
47+
else {
48+
setManifest(_manifest)
49+
}
3750
setLoading(false)
3851
setManifestAvailable(true)
3952
})
@@ -51,10 +64,14 @@ export default function ClusterManifest({
5164
}
5265
}, [terminalAccessId])
5366

67+
// NOTE: Need to remove this useEffect since manifestMode changes on events only.
68+
// Since there can be alot of ways this useEffect interferes with other handlers, causing bugs.
69+
// Plus it might be a case when this useEffect will run before we have manifest, which will cause issues.
5470
useEffect(() => {
5571
const regex = manifestCommentsRegex
5672
if (manifestMode === EditModeType.NON_EDIT) {
57-
setManifest(defaultManifest)
73+
const _manifest = hideManagedFields ? defaultManifest : originalManifest
74+
setManifest(_manifest)
5875
} else if (manifestMode === EditModeType.APPLY) {
5976
const _manifestValue = manifestValue.replace(regex, 'apiVersion:')
6077
if (_manifestValue !== defaultManifest) {
@@ -63,21 +80,35 @@ export default function ClusterManifest({
6380
setManifestData(JSON.stringify(YAML.parse(_manifestValue)))
6481
} else {
6582
setManifest(defaultManifestErrorText)
83+
setManifestMode(EditModeType.EDIT)
6684
}
6785
} catch (error) {
68-
setManifest(defaultManifestErrorText + '# ' + error + '\n#\n' + _manifestValue)
86+
// Since we check error in edit as well, we can ignore this error and somehow infinite loop is created if we setManifest here.
6987
setManifestMode(EditModeType.EDIT)
7088
}
7189
} else {
7290
selectTerminalTab()
7391
setManifestMode(EditModeType.NON_EDIT)
7492
}
7593
} else if (manifestMode === EditModeType.EDIT) {
76-
if (errorMessage?.length) {
77-
setManifest(defaultManifestErrorText + '# ' + errorMessage + '\n#\n' + manifestValue)
94+
try {
95+
// Parsing will remove earlier comments, which will fix internal issues of code, currently the errorMessage is not getting cleared due to line 83.
96+
const parsedManifest = YAML.parse(manifestValue)
97+
if (parsedManifest) {
98+
const trimmedManifest = YAML.stringify(getTrimmedManifestData(parsedManifest))
99+
const errorDetails = errorMessage?.length ? defaultManifestErrorText + '# ' + errorMessage + '\n#\n' : ''
100+
setManifest(errorDetails + trimmedManifest)
101+
}
102+
else {
103+
setManifest(defaultManifestErrorText)
104+
}
105+
}
106+
catch (error) {
107+
// Should we directly use error object here?
108+
setManifest(defaultManifestErrorText + '# ' + error + '\n#\n' + manifestValue)
78109
}
79110
}
80-
}, [manifestMode])
111+
}, [manifestMode, hideManagedFields])
81112

82113
const switchToEditMode = (): void => {
83114
setManifestMode(EditModeType.EDIT)

src/components/ClusterNodes/ClusterNodeContainer.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/components/ClusterNodes/ClusterOverview.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import { ReactComponent as ClusterOverviewIcon } from '../../assets/icons/cluste
2424
import { MAX_LENGTH_350, SOME_ERROR_MSG } from '../../config/constantMessaging'
2525
import ConnectingToClusterState from '../ResourceBrowser/ResourceList/ConnectingToClusterState'
2626
import { EditableTextArea } from '../common/EditableTextArea/EditableTextArea'
27+
import { importComponentFromFELibrary } from '../common'
28+
29+
const Catalog = importComponentFromFELibrary('Catalog')
2730

2831
function ClusterOverview({
2932
isSuperAdmin,
@@ -567,12 +570,13 @@ function ClusterOverview({
567570
return (
568571
<div
569572
className="pl-20 pt-20 pr-20 dc__column-gap-32 h-100 dc__overflow-auto flexbox flex-justify-center"
570-
style={{ backgroundImage: 'linear-gradient(249deg, #D4E6F7 0%, var(--N50)50.58%)' }}
573+
style={{ backgroundImage: 'linear-gradient(249deg, #D4E6F7 0%, var(--N0)50.58%)' }}
571574
>
572575
{renderSideInfoData()}
573-
<div className="dc__mxw-1068 flex-grow-1">
576+
<div className="dc__mxw-1068 flex-grow-1 mw-none">
574577
{renderCardDetails()}
575578
{renderClusterError()}
579+
{Catalog && <Catalog resourceId={clusterId} resourceType="cluster" />}
576580
<GenericDescription
577581
isClusterTerminal={true}
578582
clusterId={clusterId}

src/components/ClusterNodes/ClusterTerminal.tsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from './clusterNodes.service'
1212
import { GroupHeading, menuComponentForImage, Option } from '../../components/v2/common/ReactSelect.utils'
1313
import { clusterImageDescription, convertToOptionsList } from '../common'
14-
import { get, ServerErrors, showError } from '@devtron-labs/devtron-fe-common-lib'
14+
import { Checkbox, CHECKBOX_VALUE, get, ServerErrors, showError } from '@devtron-labs/devtron-fe-common-lib'
1515
import ClusterManifest, { ManifestPopupMenu } from './ClusterManifest'
1616
import ClusterEvents from './ClusterEvents'
1717
import { ClusterTerminalType, NodeTaintType } from './types'
@@ -99,6 +99,7 @@ export default function ClusterTerminal({
9999
const [manifestErrors, setManifestErrors] = useState<string[]>()
100100
const [debugMode, setDebugMode] = useState<boolean>(false)
101101
const [isManifestAvailable, setManifestAvailable] = useState<boolean>()
102+
const [hideManagedFields, setHideManagedFields] = useState<boolean>(true)
102103
const isShellSwitched = useRef<boolean>(false)
103104
const autoSelectNodeRef = useRef(null)
104105
const terminalRef = useRef(null)
@@ -179,6 +180,7 @@ export default function ClusterTerminal({
179180
}
180181
const namespace = result.namespace
181182
setNamespace(namespace ? { label: namespace, value: namespace } : defaultNameSpace)
183+
setHideManagedFields(true)
182184
setManifestButtonState(EditModeType.NON_EDIT)
183185
terminalAccessIdRef.current = result.terminalAccessId
184186
socketConnecting()
@@ -337,6 +339,7 @@ export default function ClusterTerminal({
337339
function getNewSession() {
338340
if (!terminalAccessIdRef.current) return
339341
setSocketConnection(SocketConnectionType.CONNECTING)
342+
// It might be that we dont have resourceData.
340343
getClusterData(
341344
`user/terminal/get?namespace=${selectedNamespace.value}&shellName=${
342345
selectedTerminalType.value
@@ -627,6 +630,10 @@ export default function ClusterTerminal({
627630
setTerminalCleared(!terminalCleared)
628631
}
629632

633+
const handleToggleManagedFields = () => {
634+
setHideManagedFields(!hideManagedFields)
635+
}
636+
630637
const renderRegisterLinkMatcher = (terminal) => {
631638
const linkMatcherRegex = new RegExp(`${POD_LINKS.POD_MANIFEST}|${POD_LINKS.POD_EVENTS}`)
632639
terminal.registerLinkMatcher(linkMatcherRegex, (_event, text) => {
@@ -704,6 +711,7 @@ export default function ClusterTerminal({
704711
errorMessage={manifestErrors}
705712
setManifestAvailable={setManifestAvailable}
706713
selectTerminalTab={selectTerminalTab}
714+
hideManagedFields={hideManagedFields}
707715
/>
708716
</div>
709717
)}
@@ -815,13 +823,30 @@ export default function ClusterTerminal({
815823
}
816824
}
817825

826+
const renderHideManagedFields = () => (
827+
<div className="pt-6 pb-6 pl-12 pr-8 top">
828+
<Checkbox
829+
rootClassName="mb-0-imp h-18"
830+
isChecked={hideManagedFields}
831+
value={CHECKBOX_VALUE.CHECKED}
832+
onChange={handleToggleManagedFields}
833+
>
834+
<span className="mr-5 cn-9 fs-12 lh-18" data-testid="hide-pods-managed-fields">
835+
Hide Managed Fields
836+
</span>
837+
</Checkbox>
838+
</div>
839+
)
840+
818841
const closeManifetsPopup = (isClose: boolean): void => {
819842
setManifestButtonState(EditModeType.REVIEW)
820843
setManifestData('')
821844
setShowPodExistPopup(isClose)
822845
}
823846

824847
const hideShell: boolean = !(connectTerminal && isPodCreated && !selectedTabIndex)
848+
const showManagedFieldsCheckbox: boolean =
849+
selectedTabIndex === 2 && isManifestAvailable && manifestButtonState === EditModeType.NON_EDIT
825850

826851
const fullScreenClassWrapper = isFullScreen ? 'cluster-full_screen' : 'cluster-terminal-view-container'
827852
const nodeDetailsPageClassWrapper = isNodeDetailsPage || isClusterDetailsPage ? '' : 'node-terminal'
@@ -951,6 +976,14 @@ export default function ClusterTerminal({
951976
buttonSelectionState: manifestButtonState,
952977
setManifestButtonState: setManifestButtonState,
953978
},
979+
...(showManagedFieldsCheckbox
980+
? [
981+
{
982+
type: TerminalWrapperType.CUSTOM_COMPONENT,
983+
customComponent: renderHideManagedFields,
984+
},
985+
]
986+
: []),
954987
],
955988
tabSwitcher: {
956989
terminalTabWrapper: terminalTabWrapper,

src/components/ClusterNodes/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ export interface ClusterManifestType {
351351
errorMessage?: string[]
352352
setManifestAvailable: (isManifestAvailable: boolean) => void
353353
selectTerminalTab: () => void
354+
hideManagedFields: boolean
354355
}
355356

356357
export interface ClusterEditManifestType {

0 commit comments

Comments
 (0)