Skip to content

Commit 7d63331

Browse files
authored
Merge pull request #2076 from devtron-labs/fix/create-app-redirect
fix: redirect on previous url on closing create devtron app modal
2 parents 563a31d + 21ff1f4 commit 7d63331

File tree

6 files changed

+31
-37
lines changed

6 files changed

+31
-37
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "0.3.10",
7+
"@devtron-labs/devtron-fe-common-lib": "0.3.11",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/components/app/list-new/AppList.tsx

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import React, { useState, useEffect, useMemo } from 'react'
19-
import { Switch, Route, useLocation, useHistory, useParams } from 'react-router-dom'
19+
import { Switch, Route, useHistory, useParams, useRouteMatch, useLocation } from 'react-router-dom'
2020
import {
2121
Progressing,
2222
stopPropagation,
@@ -36,13 +36,13 @@ import {
3636
import { getCommonAppFilters } from '@Services/service'
3737
import { Cluster } from '@Services/service.types'
3838
import { useAppContext } from '../../common'
39-
import { SERVER_MODE, DOCUMENTATION, URLS } from '../../../config'
39+
import { SERVER_MODE, DOCUMENTATION } from '../../../config'
4040
import HelmAppList from './HelmAppList'
4141
import { AppListPropType } from '../list/types'
4242
import { AddNewApp } from '../create/CreateApp'
4343
import '../list/list.scss'
4444
import EAEmptyState, { EAEmptyStateType } from '../../common/eaEmptyState/EAEmptyState'
45-
import { FLUX_CD_HELM_RELEASE_LABEL } from './Constants'
45+
import { APP_LISTING_URLS, FLUX_CD_HELM_RELEASE_LABEL } from './Constants'
4646
import { getModuleInfo } from '../../v2/devtronStackManager/DevtronStackManager.service'
4747
import {
4848
getAppStatusFormattedValue,
@@ -64,8 +64,9 @@ import AppListFilters from './AppListFilters'
6464
let interval
6565

6666
const AppList = ({ isArgoInstalled }: AppListPropType) => {
67-
const location = useLocation()
6867
const history = useHistory()
68+
const location = useLocation()
69+
const { url } = useRouteMatch()
6970
const params = useParams<{ appType: string }>()
7071
const { serverMode } = useMainContext()
7172
const { setCurrentAppName } = useAppContext()
@@ -396,36 +397,26 @@ const AppList = ({ isArgoInstalled }: AppListPropType) => {
396397

397398
const closeDevtronAppCreateModal = (e) => {
398399
stopPropagation(e)
399-
const _urlPrefix =
400-
params.appType === AppListConstants.AppType.DEVTRON_APPS ? URLS.DEVTRON_APP_LIST : URLS.HELM_APP_LIST
401-
history.push(`${_urlPrefix}${location.search}`)
400+
history.push(`${url}${location.search}`)
402401
}
403402

404403
function renderAppCreateRouter() {
405404
return (
406405
<Switch>
407-
<Route
408-
path={`${URLS.DEVTRON_APP_LIST}/${AppListConstants.CREATE_DEVTRON_APP_URL}`}
409-
render={(props) => (
410-
<AddNewApp
411-
close={closeDevtronAppCreateModal}
412-
match={props.match}
413-
location={props.location}
414-
history={props.history}
415-
/>
416-
)}
417-
/>
418-
<Route
419-
path={`${URLS.HELM_APP_LIST}/${AppListConstants.CREATE_DEVTRON_APP_URL}`}
420-
render={(props) => (
421-
<AddNewApp
422-
close={closeDevtronAppCreateModal}
423-
match={props.match}
424-
location={props.location}
425-
history={props.history}
426-
/>
427-
)}
428-
/>
406+
{APP_LISTING_URLS.map((currentUrl) => (
407+
<Route
408+
path={`${currentUrl}/${AppListConstants.CREATE_DEVTRON_APP_URL}`}
409+
key={currentUrl}
410+
render={(props) => (
411+
<AddNewApp
412+
close={closeDevtronAppCreateModal}
413+
match={props.match}
414+
location={props.location}
415+
history={props.history}
416+
/>
417+
)}
418+
/>
419+
))}
429420
</Switch>
430421
)
431422
}

src/components/app/list-new/Constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import { OptionType, SelectPickerOptionType } from '@devtron-labs/devtron-fe-common-lib'
18+
import { URLS } from '@Config/routes'
1819
import { AppStatuses, AppStatusesDTO, FluxCDTemplateType } from './AppListType'
1920

2021
export const APP_LIST_HEADERS = {
@@ -95,3 +96,5 @@ export const APPS_WITH_NO_PROJECT_OPTION: OptionType = {
9596
label: 'Apps with no project',
9697
value: '0',
9798
}
99+
100+
export const APP_LISTING_URLS = [URLS.DEVTRON_APP_LIST, URLS.HELM_APP_LIST, URLS.ARGO_APP_LIST, URLS.FLUX_APP_LIST]

src/components/app/list-new/list.utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export const useFilterOptions = ({
117117

118118
const clusterGroupedEnvOptions: GroupedOptionsType[] = useMemo(
119119
() =>
120-
appListFiltersResponse?.appListFilters.result.environments.reduce((prev, curr) => {
120+
appListFiltersResponse?.appListFilters?.result.environments.reduce((prev, curr) => {
121121
if (!prev.find((clusterItem) => clusterItem.label === curr.cluster_id)) {
122122
prev.push({ label: curr.cluster_id, options: [] })
123123
}
@@ -159,7 +159,7 @@ export const useFilterOptions = ({
159159
appListFiltersResponse?.isFullMode
160160
? getClusterOptions(appListFiltersResponse?.appListFilters.result.clusters)
161161
: getClusterOptions(appListFiltersResponse?.clusterList.result),
162-
[appListFiltersResponse],
162+
[appListFiltersResponse, isExternalArgo, isExternalFlux],
163163
)
164164

165165
const namespaceOptions: GroupedOptionsType[] = useMemo(

src/components/v2/appDetails/k8Resource/nodeDetail/NodeDetailTabs/Manifest.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ const ManifestComponent = ({
486486
cleanData={showManifestCompareView}
487487
diffView={showManifestCompareView}
488488
theme="vs-dark--dt"
489-
height={isResourceBrowserView ? 'calc(100vh - 151px)' : 'calc(100vh - 77px)'}
489+
height={isResourceBrowserView ? 'calc(100vh - 119px)' : 'calc(100vh - 77px)'}
490490
value={trimedManifestEditorData}
491491
mode={MODES.YAML}
492492
readOnly={showManifestCompareView || !isEditMode}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,10 +1369,10 @@
13691369
dependencies:
13701370
"@jridgewell/trace-mapping" "0.3.9"
13711371

1372-
"@devtron-labs/[email protected].10":
1373-
version "0.3.10"
1374-
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-0.3.10.tgz#30c12adc09ae91f836730889f45382d7a7281d34"
1375-
integrity sha512-3HCfN2BGd2sQIaWNqV4Tb9uK22zgIQjvTX6MWEZoSFxscj4KvIwheIm9b9uMiC9uz64ztf8Rab/JL6CeYmWw4Q==
1372+
"@devtron-labs/[email protected].11":
1373+
version "0.3.11"
1374+
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-0.3.11.tgz#3e5ecf873210376dc46f60739753b7cd2788ff87"
1375+
integrity sha512-PxGZC7QvWGcV8lO73usoFB/AGjJJ/xLGJG4AnuruEE7zgHPHlcQoLS+hcUOtJatlIpyQ5hn+fD+zlovHT3MxoA==
13761376
dependencies:
13771377
"@types/react-dates" "^21.8.6"
13781378
ansi_up "^5.2.1"

0 commit comments

Comments
 (0)