Skip to content

Commit

Permalink
Merge pull request #2244 from devtron-labs/chore/misc-enhancements
Browse files Browse the repository at this point in the history
feat: misc enhancements
  • Loading branch information
vivek-devtron authored Dec 2, 2024
2 parents 2cf2702 + 979fa42 commit 0267af3
Show file tree
Hide file tree
Showing 18 changed files with 198 additions and 96 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ FEATURE_PROMO_EMBEDDED_BUTTON_TEXT=
FEATURE_PROMO_EMBEDDED_MODAL_TITLE=
FEATURE_PROMO_EMBEDDED_IFRAME_URL=
FEATURE_BULK_RESTART_WORKLOADS_FROM_RB=deployment,rollout,daemonset,statefulset
FEATURE_DEFAULT_LANDING_RB_ENABLE=false
1 change: 1 addition & 0 deletions .github/workflows/pr-issue-validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
branches:
- 'main'
- 'release-**'
- 'develop'

jobs:
validate-PR-issue:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"homepage": "/dashboard",
"dependencies": {
"@devtron-labs/devtron-fe-common-lib": "1.1.6",
"@devtron-labs/devtron-fe-common-lib": "1.1.7",
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
"@rjsf/core": "^5.13.3",
"@rjsf/utils": "^5.13.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,13 @@ const ConfigHeader = ({
showNoOverride,
parsingError,
restoreLastSavedYAML,
hideDryRunTab = false,
hideTabs = {},
}: ConfigHeaderProps) => {
const validTabKeys = isOverridable
? CONFIG_HEADER_TAB_VALUES.OVERRIDE
: CONFIG_HEADER_TAB_VALUES.BASE_DEPLOYMENT_TEMPLATE

const filteredTabKeys = validTabKeys.filter(
(currentTab: ConfigHeaderTabType) => !hideDryRunTab || currentTab !== ConfigHeaderTabType.DRY_RUN,
)
const filteredTabKeys = validTabKeys.filter((tab) => !hideTabs[tab])

const activeTabIndex = filteredTabKeys.indexOf(configHeaderTab)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useMemo, useState } from 'react'
import { generatePath, useHistory, useRouteMatch } from 'react-router-dom'
import { useEffect, useMemo, useRef, useState } from 'react'
import { generatePath, useHistory, useLocation, useRouteMatch } from 'react-router-dom'

import {
useUrlFilters,
Expand Down Expand Up @@ -57,9 +57,11 @@ export const DeploymentConfigCompare = ({
const { push } = useHistory()
const { path, params } = useRouteMatch<DeploymentConfigParams>()
const { compareTo, resourceType, resourceName, appId, envId } = params
const location = useLocation()

// STATES
const [convertVariables, setConvertVariables] = useState(false)
const isDefaultLandingPreviousDeploymentSet = useRef<boolean>(false)

// GLOBAL CONSTANTS
const isManifestView = resourceType === EnvResourceType.Manifest
Expand Down Expand Up @@ -133,6 +135,32 @@ export const DeploymentConfigCompare = ({
[options, optionsLoader],
)

useEffect(() => {
if (!compareEnvOptions || isDefaultLandingPreviousDeploymentSet.current) {
return
}

isDefaultLandingPreviousDeploymentSet.current = true

if (!compareEnvOptions.previousDeployments?.length) {
updateSearchParams({
compareWith: null,
})

return
}

const previousDeploymentData = compareEnvOptions.previousDeployments[0]

updateSearchParams({
[AppEnvDeploymentConfigQueryParams.COMPARE_WITH_CONFIG_TYPE]:
AppEnvDeploymentConfigType.PREVIOUS_DEPLOYMENTS,
compareWithIdentifierId: previousDeploymentData.deploymentTemplateHistoryId,
compareWithPipelineId: previousDeploymentData.pipelineId,
compareWithManifestChartRefId: isManifestView ? previousDeploymentData.chartRefId : null,
})
}, [compareEnvOptions])

const fetchManifestData = async () => {
const [{ result: currentList }, { result: compareList }] = await Promise.all([
getDeploymentTemplateData({ type, appName, envName, configType, compareName: compareTo }),
Expand Down Expand Up @@ -480,13 +508,49 @@ export const DeploymentConfigCompare = ({
if (_isManifestView) {
setConvertVariables(false)
}
push(
generatePath(path, {

const currentSearchParams = new URLSearchParams(location.search)

// NOTE: need to find the corresponding chartRefId(s) for compareWith and compareTo
// and set/delete them based on _isManifestView
const _compareWithManifestChartRefId =
currentSearchParams.has('compareWithIdentifierId') && _isManifestView
? compareEnvOptions.previousDeployments.find(
(prev) =>
prev.deploymentTemplateHistoryId ===
Number(currentSearchParams.get('compareWithIdentifierId')),
)?.chartRefId ?? null
: null

const _manifestChartRefId =
currentSearchParams.has('identifierId') && _isManifestView
? currentEnvOptions.previousDeployments.find(
(prev) => prev.deploymentTemplateHistoryId === Number(currentSearchParams.get('identifierId')),
)?.chartRefId ?? null
: null

if (_compareWithManifestChartRefId) {
currentSearchParams.set('compareWithManifestChartRefId', String(_compareWithManifestChartRefId))
} else {
// NOTE: make sure to not set null as URLSearchParams will save the null as string
// i.e suppose we save 'hello' = null, we get ?hello=null as search param
currentSearchParams.delete('compareWithManifestChartRefId')
}

if (_manifestChartRefId) {
currentSearchParams.set('manifestChartRefId', String(_manifestChartRefId))
} else {
currentSearchParams.delete('manifestChartRefId')
}

push({
pathname: generatePath(path, {
...params,
resourceType: _isManifestView ? EnvResourceType.Manifest : EnvResourceType.DeploymentTemplate,
resourceName: null,
}),
)
search: currentSearchParams.toString(),
})
}

const tabConfig: DeploymentConfigDiffProps['tabConfig'] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const parseCompareWithSearchParams =
// If `type` is 'app' (Application), set `compareWith` to the first environment if available,
// otherwise `null` (base configuration).
if (type === 'app') {
compareWith = environments.length && !compareTo ? environments[0].name : null
compareWith = compareTo || (environments.length ? environments[0].name : null)
} else {
// If `type` is 'appGroup' (Application Groups), set `compareWith` to the first application.
// If the application to compare (`compareTo`) is the same as the first application,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ export interface ConfigHeaderProps {
showNoOverride: boolean
parsingError: string
restoreLastSavedYAML: () => void
/**
* This prop hides the dry run tab in the header
* This prop is meant to be removed after patch merge strategy is introduced
* @default - false
*/
hideDryRunTab?: boolean
/** A map indicating which tabs to hide, with their visibility as boolean values */
hideTabs?: Partial<Record<ConfigHeaderTabType, boolean>>
}

export interface ConfigHeaderTabProps
Expand Down
19 changes: 14 additions & 5 deletions src/Pages/Shared/ConfigMapSecret/ConfigMapSecretContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ export const ConfigMapSecretContainer = ({
})
: null,
// Fetch Base Configuration (Inherited Tab Data)
cmSecretStateLabel === CM_SECRET_STATE.INHERITED ||
cmSecretStateLabel === CM_SECRET_STATE.OVERRIDDEN
// Skipped for jobs as API support is unavailable
!isJob &&
(cmSecretStateLabel === CM_SECRET_STATE.INHERITED ||
cmSecretStateLabel === CM_SECRET_STATE.OVERRIDDEN)
? getConfigMapSecretConfigData({
appId: +appId,
appName,
Expand Down Expand Up @@ -372,7 +374,7 @@ export const ConfigMapSecretContainer = ({

// TAB HANDLING
useEffect(() => {
if (cmSecretStateLabel === CM_SECRET_STATE.INHERITED && !draftData) {
if (!isJob && cmSecretStateLabel === CM_SECRET_STATE.INHERITED && !draftData) {
setConfigHeaderTab(ConfigHeaderTabType.INHERITED)
} else {
setConfigHeaderTab(ConfigHeaderTabType.VALUES)
Expand Down Expand Up @@ -430,7 +432,14 @@ export const ConfigMapSecretContainer = ({

const handleClearPopupNode = () => setPopupNodeType(null)

const handleViewInheritedConfig = () => setConfigHeaderTab(ConfigHeaderTabType.INHERITED)
const handleViewInheritedConfig = () => {
if (isJob) {
// Redirecting to the base config URL, since inherited tab is hidden
history.push(baseConfigurationURL)
} else {
setConfigHeaderTab(ConfigHeaderTabType.INHERITED)
}
}

const handleProtectionViewTabChange = (tab: ProtectConfigTabsType) => {
setSelectedProtectionViewTab(tab)
Expand Down Expand Up @@ -746,7 +755,7 @@ export const ConfigMapSecretContainer = ({
}
parsingError={parsingError}
restoreLastSavedYAML={restoreLastSavedYAML}
hideDryRunTab
hideTabs={{ dryRun: true, inherited: isJob }}
/>
{!hideConfigToolbar && (
<ConfigToolbar
Expand Down
8 changes: 7 additions & 1 deletion src/Pages/Shared/ConfigMapSecret/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export const getConfigMapSecretFormInitialValues = ({
defaultMountPath,
subPath,
data,
defaultData,
filePermission,
roleARN,
esoSubPath,
Expand All @@ -242,7 +243,12 @@ export const getConfigMapSecretFormInitialValues = ({
selectedType: type ?? configMapSecretMountDataMap.environment.value,
isFilePermissionChecked: !!filePermission,
isSubPathChecked: !!subPath,
externalSubpathValues: processExternalSubPathValues({ data, external, subPath, esoSubPath }),
externalSubpathValues: processExternalSubPathValues({
data: data || defaultData,
external,
subPath,
esoSubPath,
}),
filePermission: filePermission ?? '',
volumeMountPath: mountPath ?? defaultMountPath ?? '',
roleARN: roleARN ?? '',
Expand Down
2 changes: 2 additions & 0 deletions src/components/ClusterNodes/NodeActions/DeleteNodeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ export default function DeleteNodeModal({ name, version, kind, closePopup }: Nod
delete={deleteAPI}
closeDelete={onClose}
deletePostfix={DELETE_NODE_MODAL_MESSAGING.deletePostfix}
showDeleteConfirmation
apiCallInProgress={apiCallInProgress}
deleteConfirmationText={name}
>
<InfoColourBar
classname="question-bar p-lr-12"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ const DeleteResourcePopup: React.FC<DeleteResourcePopupType> = ({
delete={handleDelete}
closeDelete={toggleDeleteDialog}
apiCallInProgress={apiCallInProgress}
showDeleteConfirmation
deleteConfirmationText={resourceData.name as string}
>
<DeleteDialog.Description>
<p className="mb-12">{DELETE_MODAL_MESSAGING.description}</p>
Expand Down
Loading

0 comments on commit 0267af3

Please sign in to comment.