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 14 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -228,7 +228,7 @@ export interface EnvConfigurationsNavProps {
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 @@ -21,8 +21,7 @@ import {
BASE_CONFIGURATION_ENV_ID,
} from '@devtron-labs/devtron-fe-common-lib'

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

import { URLS, DOCUMENTATION, getAppComposeURL, APP_COMPOSE_STAGE } from '@Config/index'
import { AppConfigStatusItemType, EnvConfigDTO } from '../../service.types'
import { AppConfigState, AppStageUnlockedType, CustomNavItemsType, EnvConfigType, STAGE_NAME } from './AppConfig.types'

Expand Down Expand Up @@ -145,15 +144,15 @@ export const getNavItems = ({
},
{
title: 'ConfigMaps & Secrets',
href: `/job/${appId}/edit/configmap`,
href: getAppComposeURL(appId, APP_COMPOSE_STAGE.CONFIG_MAPS, true),
stage: STAGE_NAME.REDIRECT_ITEM,
isLocked: !_isUnlocked.configmap,
isProtectionAllowed: true,
required: true,
},
{
title: 'ConfigMaps',
href: `/job/${appId}/edit/configmap`,
href: getAppComposeURL(appId, APP_COMPOSE_STAGE.CONFIG_MAPS, true),
stage: STAGE_NAME.CONFIGMAP,
isLocked: !_isUnlocked.configmap,
supportDocumentURL: DOCUMENTATION.APP_CREATE_CONFIG_MAP,
Expand All @@ -165,7 +164,7 @@ export const getNavItems = ({
},
{
title: 'Secrets',
href: `/job/${appId}/edit/secrets`,
href: getAppComposeURL(appId, APP_COMPOSE_STAGE.SECRETS, true),
stage: STAGE_NAME.SECRETS,
isLocked: !_isUnlocked.secret,
supportDocumentURL: DOCUMENTATION.APP_CREATE_SECRET,
Expand Down Expand Up @@ -211,7 +210,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 All @@ -220,7 +219,7 @@ export const getNavItems = ({
},
{
title: 'Deployment Template',
href: `/app/${appId}/edit/deployment-template`,
href: getAppComposeURL(appId, APP_COMPOSE_STAGE.DEPLOYMENT_TEMPLATE),
stage: STAGE_NAME.DEPLOYMENT_TEMPLATE,
isLocked: !_isUnlocked.deploymentTemplate,
supportDocumentURL: DOCUMENTATION.APP_DEPLOYMENT_TEMPLATE,
Expand Down Expand Up @@ -251,7 +250,7 @@ export const getNavItems = ({
},
{
title: 'ConfigMaps',
href: `/app/${appId}/edit/configmap`,
href: getAppComposeURL(appId, APP_COMPOSE_STAGE.CONFIG_MAPS),
stage: STAGE_NAME.CONFIGMAP,
isLocked: !_isUnlocked.configmap,
supportDocumentURL: DOCUMENTATION.APP_CREATE_CONFIG_MAP,
Expand All @@ -263,7 +262,7 @@ export const getNavItems = ({
},
{
title: 'Secrets',
href: `/app/${appId}/edit/secrets`,
href: getAppComposeURL(appId, APP_COMPOSE_STAGE.SECRETS),
stage: STAGE_NAME.SECRETS,
isLocked: !_isUnlocked.secret,
supportDocumentURL: DOCUMENTATION.APP_CREATE_SECRET,
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 @@ -134,7 +134,10 @@ const AppComposeRouter = () => {
reloadEnvironments={reloadEnvironments}
/>
</Route>,
<Route key={`${path}/${URLS.APP_CM_CONFIG}`} path={`${path}/${URLS.APP_CM_CONFIG}/:name?`}>
<Route
key={`${path}/${URLS.BASE_CONFIG}/${URLS.APP_CM_CONFIG}`}
path={`${path}/${URLS.BASE_CONFIG}/${URLS.APP_CM_CONFIG}/:name?`}
>
<ConfigMapSecretWrapper
isJob
isApprovalPolicyConfigured={false}
Expand All @@ -146,7 +149,10 @@ const AppComposeRouter = () => {
envName=""
/>
</Route>,
<Route key={`${path}/${URLS.APP_CS_CONFIG}`} path={`${path}/${URLS.APP_CS_CONFIG}/:name?`}>
<Route
key={`${path}/${URLS.BASE_CONFIG}/${URLS.APP_CS_CONFIG}`}
path={`${path}/${URLS.BASE_CONFIG}/${URLS.APP_CS_CONFIG}/:name?`}
>
<ConfigMapSecretWrapper
isJob
isApprovalPolicyConfigured={false}
Expand Down Expand Up @@ -196,6 +202,7 @@ const AppComposeRouter = () => {
/>
</>
</Route>

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

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

{isUnlocked.deploymentTemplate && (
<Route path={`${path}/${URLS.APP_DEPLOYMENT_CONFIG}`}>
<Route path={`${path}/${URLS.BASE_CONFIG}/${URLS.APP_DEPLOYMENT_CONFIG}`}>
<DeploymentTemplate
respondOnSuccess={respondOnSuccess}
isCiPipeline={isCiPipeline}
Expand Down Expand Up @@ -247,7 +261,10 @@ const AppComposeRouter = () => {
reloadAppConfig={reloadAppConfig}
/>
</Route>,
<Route key={`${path}/${URLS.APP_CM_CONFIG}`} path={`${path}/${URLS.APP_CM_CONFIG}/:name?`}>
<Route
key={`${path}/${URLS.BASE_CONFIG}/${URLS.APP_CM_CONFIG}`}
path={`${path}/${URLS.BASE_CONFIG}/${URLS.APP_CM_CONFIG}/:name?`}
>
<ConfigMapSecretWrapper
isApprovalPolicyConfigured={getIsApprovalPolicyConfigured(
approvalConfigMapForBaseConfiguration?.[ApprovalConfigDataKindType.configMap],
Expand All @@ -260,7 +277,10 @@ const AppComposeRouter = () => {
envName=""
/>
</Route>,
<Route key={`${path}/${URLS.APP_CS_CONFIG}`} path={`${path}/${URLS.APP_CS_CONFIG}/:name?`}>
<Route
key={`${path}/${URLS.BASE_CONFIG}/${URLS.APP_CS_CONFIG}`}
path={`${path}/${URLS.BASE_CONFIG}/${URLS.APP_CS_CONFIG}/:name?`}
>
<ConfigMapSecretWrapper
isApprovalPolicyConfigured={getIsApprovalPolicyConfigured(
approvalConfigMapForBaseConfiguration?.[ApprovalConfigDataKindType.configSecret],
Expand Down Expand Up @@ -293,13 +313,13 @@ 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?`}
path={`${path}/:envId(\\d+)?/${URLS.APP_ENV_CONFIG_COMPARE}/:compareTo?/${DEPLOYMENT_CONFIGURATION_RESOURCE_TYPE_ROUTE}/:resourceName?`}
>
{({ match }) => {
const basePath = generatePath(path, match.params)
const envOverridePath = match.params.envId
? `/${URLS.APP_ENV_OVERRIDE_CONFIG}/${match.params.envId}`
: ''
: `/${URLS.BASE_CONFIG}`
// Set the resourceTypePath based on the resourceType from the URL parameters.
// If the resourceType is 'Manifest' or 'PipelineStrategy', use 'deployment-template' as the back URL.
// Otherwise, use the actual resourceType from the URL, which could be 'deployment-template', 'configmap', or 'secrets'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import { Prompt, useLocation, useParams } from 'react-router-dom'
import YAML from 'yaml'
import { importComponentFromFELibrary } from '@Components/common'
import { getModuleInfo } from '@Components/v2/devtronStackManager/DevtronStackManager.service'
import { URLS } from '@Config/routes'
import { APP_COMPOSE_STAGE, getAppComposeURL } from '@Config/routes'
import { ReactComponent as ICClose } from '@Icons/ic-close.svg'
import { ReactComponent as ICInfoOutlineGrey } from '@Icons/ic-info-outline-grey.svg'
import deleteOverrideEmptyStateImage from '@Images/no-artifact.webp'
Expand Down Expand Up @@ -255,7 +255,7 @@ const DeploymentTemplate = ({

const isGuiSupported = isEditMode && !showDeleteOverrideDraftEmptyState

const baseDeploymentTemplateURL = `${URLS.APP}/${appId}/${URLS.APP_CONFIG}/${URLS.APP_DEPLOYMENT_CONFIG}`
const baseDeploymentTemplateURL = getAppComposeURL(appId, APP_COMPOSE_STAGE.DEPLOYMENT_TEMPLATE)

/**
* Means has no global config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ import {
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 @@ -115,9 +114,11 @@ export const AppNavigation = () => {
)

const getValidBackURL = () => {
const isBackURLLocked = location.pathname === lastUnlockedStage
const secondLastUnlockedStage = isBackURLLocked
? navItems.reduce(
const isCurrentPathLastUnlockedStage = location.pathname === lastUnlockedStage
const eligibleNavItems = navItems.filter((navItem) => navItem.stage !== STAGE_NAME.REDIRECT_ITEM)

const secondLastUnlockedStage = isCurrentPathLastUnlockedStage
? eligibleNavItems.reduce(
(acc, curr) => {
if (curr.href === lastUnlockedStage) {
acc.found = true
Expand Down Expand Up @@ -145,8 +146,8 @@ export const AppNavigation = () => {
<Switch>
<Route
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add key here as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

path={[
`${path}/:resourceType(${Object.values(EnvResourceType).join('|')})`,
`${path}/${URLS.APP_ENV_OVERRIDE_CONFIG}/:envId(\\d+)/:resourceType(${Object.values(EnvResourceType).join('|')})`,
`${path}/${URLS.BASE_CONFIG}/${DEPLOYMENT_CONFIGURATION_RESOURCE_TYPE_ROUTE}?`,
`${path}/${URLS.APP_ENV_OVERRIDE_CONFIG}/:envId(\\d+)/${DEPLOYMENT_CONFIGURATION_RESOURCE_TYPE_ROUTE}?`,
]}
>
{({ match }) => (
Expand All @@ -168,6 +169,7 @@ export const AppNavigation = () => {
/>
)}
</Route>

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