Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: redirect non super admin to config maps in configuration view instead of Deployment template #2445

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
d008b99
feat: enhance resource type handling and add new configuration interface
AbhishekA1509 Feb 5, 2025
bb329d8
Merge branch 'develop' into feat/redirect-non-super-admin-to-cm
AbhishekA1509 Feb 5, 2025
cd0b849
Merge branch 'develop' into feat/redirect-non-super-admin-to-cm
AbhishekA1509 Feb 7, 2025
5eef58f
fix: revert changes for default redirection and remove resource type …
AbhishekA1509 Feb 7, 2025
3a684d8
Merge branch 'develop' into feat/redirect-non-super-admin-to-cm
AbhishekA1509 Feb 7, 2025
8fb4ff2
feat: add redirection to cm for non super admins in Release, App grou…
AbhishekA1509 Feb 9, 2025
9327e89
feat: update routing to use DEPLOYMENT_CONFIGURATION_RESOURCE_TYPE_RO…
AbhishekA1509 Feb 9, 2025
3acf2a9
fix: add navigation logic for base configurations
AbhishekA1509 Feb 10, 2025
9754c01
refactor: simplify routing logic in EnvConfig component and remove un…
AbhishekA1509 Feb 10, 2025
a0687a6
chore: remove comments
AbhishekA1509 Feb 10, 2025
883eb4c
feat: add base-config path segment in base configurations
AbhishekA1509 Feb 11, 2025
55e2bfb
fix: add base-config segment in job routes as well
AbhishekA1509 Feb 11, 2025
b2d770c
refactor: improve back URL logic by filtering eligible navigation items
AbhishekA1509 Feb 11, 2025
67fd9d8
Merge pull request #2462 from devtron-labs/feat/add-base-config-route
AbhishekA1509 Feb 11, 2025
7c1596c
Merge branch 'develop' into feat/redirect-non-super-admin-to-cm
AbhishekA1509 Feb 14, 2025
ba9d4e2
fix: update goBackURL logic to handle Manifest resource type correctly
AbhishekA1509 Feb 14, 2025
1d90e58
fix: update goBackURL logic to correctly handle resource types for Ma…
AbhishekA1509 Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
ResourceIdToResourceApprovalPolicyConfigMapType,
ConfirmationModal,
ConfirmationModalVariantType,
noop,
} from '@devtron-labs/devtron-fe-common-lib'
import { DeleteComponentsName } from '@Config/constantMessaging'
import { ApplicationDeletionInfo } from '@Pages/Shared/ApplicationDeletionInfo/ApplicationDeletionInfo'
Expand All @@ -40,6 +41,7 @@ import {
AppStageUnlockedType,
STAGE_NAME,
DEFAULT_LANDING_STAGE,
EnvConfigType,
} from './AppConfig.types'
import { getUserRole } from '../../../../GlobalConfigurations/Authorization/authorization.service'
import { isCIPipelineCreated, isCDPipelineCreated, getNavItems, isUnlocked } from './AppConfig.utils'
Expand Down Expand Up @@ -140,12 +142,12 @@ export const AppConfig = ({ appName, resourceKind, filteredEnvIds }: AppConfigPr
*
* @param envId - The ID of the environment for which the configuration is to be fetched.
*/
const fetchEnvConfig = (envId: number) => {
const fetchEnvConfig = (envId: number, callback: (res: EnvConfigType) => void = noop) => {
// Set loading state to true
setState((prevState) => ({ ...prevState, envConfig: { ...prevState.envConfig, isLoading: true } }))

// Fetch environment configuration
getEnvConfig(+appId, envId)
getEnvConfig(+appId, envId, callback)
.then((res) => {
setState((prevState) => ({
...prevState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ interface CommonAppConfigurationProps {
deleteApp: () => void
showCannotDeleteTooltip: boolean
hideConfigHelp: boolean
fetchEnvConfig: (envId: number) => void
fetchEnvConfig: (envId: number, callback?: (res: EnvConfigType) => void) => void
}

export interface AppConfigurationContextType
Expand Down Expand Up @@ -206,7 +206,7 @@ export interface EnvironmentOptionType {

export interface EnvConfigurationsNavProps {
envConfig: EnvConfigurationState
fetchEnvConfig: (envId: number) => void
fetchEnvConfig: AppConfigurationContextType['fetchEnvConfig']
environments: EnvironmentOptionType[]
paramToCheck?: 'appId' | 'envId'
goBackURL: string
Expand All @@ -223,12 +223,16 @@ export interface EnvConfigurationsNavProps {
isCMSecretLocked?: boolean
hideEnvSelector?: boolean
appOrEnvIdToResourceApprovalConfigurationMap: AppConfigState['envIdToEnvApprovalConfigurationMap']
/**
* @default false
*/
removeBaseConfigPath?: boolean
}

export interface EnvConfigRouteParams {
appId: string
envId: string
resourceType: string
resourceType?: EnvResourceType
}

export interface ExtendedCollapsibleListItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import {
stringComparatorBySortOrder,
ConfigResourceType,
BASE_CONFIGURATION_ENV_ID,
EnvResourceType,
} from '@devtron-labs/devtron-fe-common-lib'

import { URLS, DOCUMENTATION } from '@Config/index'

import { AppConfigStatusItemType, EnvConfigDTO } from '../../service.types'
import { AppConfigState, AppStageUnlockedType, CustomNavItemsType, EnvConfigType, STAGE_NAME } from './AppConfig.types'

Expand Down Expand Up @@ -145,7 +145,7 @@ export const getNavItems = ({
},
{
title: 'ConfigMaps & Secrets',
href: `/job/${appId}/edit/configmap`,
href: `/job/${appId}/edit/${EnvResourceType.ConfigMap}`,
stage: STAGE_NAME.REDIRECT_ITEM,
isLocked: !_isUnlocked.configmap,
isProtectionAllowed: true,
Expand Down Expand Up @@ -211,7 +211,7 @@ export const getNavItems = ({
},
{
title: 'Base Configurations',
href: `/app/${appId}/edit/deployment-template`,
href: `${URLS.APP}/${appId}/${URLS.APP_CONFIG}/${URLS.BASE_CONFIG}`,
stage: STAGE_NAME.REDIRECT_ITEM,
isLocked: !_isUnlocked.deploymentTemplate,
isProtectionAllowed:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from '@devtron-labs/devtron-fe-common-lib'

import { ReactComponent as Next } from '@Icons/ic-arrow-forward.svg'
import { URLS } from '@Config/index'
import { DEPLOYMENT_CONFIGURATION_RESOURCE_TYPE_ROUTE, URLS } from '@Config/index'
import { ErrorBoundary, useAppContext } from '@Components/common'
import ExternalLinks from '@Components/externalLinks/ExternalLinks'
import { ConfigMapSecretWrapper } from '@Pages/Shared/ConfigMapSecret/ConfigMapSecret.wrapper'
Expand Down Expand Up @@ -196,6 +196,7 @@ const AppComposeRouter = () => {
/>
</>
</Route>

{isUnlocked.dockerBuildConfig && (
<Route path={`${path}/${URLS.APP_DOCKER_CONFIG}`}>
<CIConfig
Expand All @@ -205,6 +206,13 @@ const AppComposeRouter = () => {
/>
</Route>
)}

{(isUnlocked.deploymentTemplate || isUnlocked.workflowEditor) && (
<Route path={`${path}/${URLS.BASE_CONFIG}`}>
<Progressing pageLoader />
</Route>
)}

{isUnlocked.deploymentTemplate && (
<Route path={`${path}/${URLS.APP_DEPLOYMENT_CONFIG}`}>
<DeploymentTemplate
Expand Down Expand Up @@ -293,7 +301,8 @@ const AppComposeRouter = () => {
</Route>,
<Route
key={`${path}/${URLS.APP_ENV_CONFIG_COMPARE}`}
path={`${path}/:envId(\\d+)?/${URLS.APP_ENV_CONFIG_COMPARE}/:compareTo?/:resourceType(${Object.values(EnvResourceType).join('|')})/:resourceName?`}
// TODO: Check this resourceType should not be optional in compare view
path={`${path}/:envId(\\d+)?/${URLS.APP_ENV_CONFIG_COMPARE}/:compareTo?/${DEPLOYMENT_CONFIGURATION_RESOURCE_TYPE_ROUTE}/:resourceName?`}
>
{({ match }) => {
const basePath = generatePath(path, match.params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,20 @@
*/

import { ReactNode } from 'react'
import { Route, Switch, useLocation, useRouteMatch } from 'react-router-dom'
import { match as matchType, Route, Switch, useLocation, useRouteMatch } from 'react-router-dom'
import {
Button,
ButtonStyleType,
ButtonVariantType,
ComponentSizeType,
ConditionalWrap,
EnvResourceType,
TippyCustomized,
TippyTheme,
} from '@devtron-labs/devtron-fe-common-lib'
import { importComponentFromFELibrary } from '@Components/common'
import { ReactComponent as ICArrowSquareOut } from '@Icons/ic-arrow-square-out.svg'
import { DEVTRON_APPS_STEPS, STAGE_NAME } from '../AppConfig.types'
import { URLS } from '../../../../../../config'
import { DEPLOYMENT_CONFIGURATION_RESOURCE_TYPE_ROUTE, URLS } from '../../../../../../config'
import AppConfigurationCheckBox from './AppConfigurationCheckBox'
import { GIT_MATERIAL_IN_USE_MESSAGE } from '../../../../../../config/constantMessaging'
import DockerFileInUse from '../../../../../../assets/img/ic-dockerfile-in-use.png'
Expand Down Expand Up @@ -141,33 +140,41 @@ export const AppNavigation = () => {
return secondLastUnlockedStage || lastUnlockedStage
}

const renderEnvConfigurationsNav = (match: matchType, isBaseConfig?: boolean) => (
<EnvConfigurationsNav
key={`env-configurations-nav-${'envId' in match.params ? match.params.envId : ''}`}
envConfig={envConfig}
fetchEnvConfig={fetchEnvConfig}
environments={environments.map(({ environmentName, environmentId }) => ({
id: environmentId,
name: environmentName,
}))}
showBaseConfigurations
showDeploymentTemplate={!isJobView}
goBackURL={getValidBackURL()}
compareWithURL={`${path}/:envId(\\d+)?`}
showComparison={!isJobView && isUnlocked.workflowEditor}
isCMSecretLocked={!isUnlocked.workflowEditor}
appOrEnvIdToResourceApprovalConfigurationMap={envIdToEnvApprovalConfigurationMap}
removeBaseConfigPath={isBaseConfig}
/>
)

return (
<Switch>
<Route
AbhishekA1509 marked this conversation as resolved.
Show resolved Hide resolved
path={[
`${path}/:resourceType(${Object.values(EnvResourceType).join('|')})`,
`${path}/${URLS.APP_ENV_OVERRIDE_CONFIG}/:envId(\\d+)/:resourceType(${Object.values(EnvResourceType).join('|')})`,
`${path}/${DEPLOYMENT_CONFIGURATION_RESOURCE_TYPE_ROUTE}`,
`${path}/${URLS.APP_ENV_OVERRIDE_CONFIG}/:envId(\\d+)/${DEPLOYMENT_CONFIGURATION_RESOURCE_TYPE_ROUTE}?`,
]}
>
{({ match }) => (
<EnvConfigurationsNav
key={`env-configurations-nav-${'envId' in match.params ? match.params.envId : ''}`}
envConfig={envConfig}
fetchEnvConfig={fetchEnvConfig}
environments={environments.map(({ environmentName, environmentId }) => ({
id: environmentId,
name: environmentName,
}))}
showBaseConfigurations
showDeploymentTemplate={!isJobView}
goBackURL={getValidBackURL()}
compareWithURL={`${path}/:envId(\\d+)?`}
showComparison={!isJobView && isUnlocked.workflowEditor}
isCMSecretLocked={!isUnlocked.workflowEditor}
appOrEnvIdToResourceApprovalConfigurationMap={envIdToEnvApprovalConfigurationMap}
/>
)}
{({ match }) => renderEnvConfigurationsNav(match)}
</Route>

<Route path={`${path}/${URLS.BASE_CONFIG}`} key={URLS.BASE_CONFIG}>
{({ match }) => renderEnvConfigurationsNav(match, true)}
</Route>

<Route key="default-navigation">
<>
<div className="flexbox-col flex-grow-1 dc__overflow-auto w-100 pt-16 px-12">
Expand Down
Loading