Skip to content

Commit 22c0a0e

Browse files
committed
Minor fix around env override redirection and deployment metrics
1 parent 281f506 commit 22c0a0e

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

src/components/EnvironmentOverride/EnvironmentOverride.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function EnvironmentOverride({
1919
}: EnvironmentOverrideComponentProps) {
2020
const params = useParams<{ appId: string; envId: string }>()
2121
const [viewState, setViewState] = useState<ComponentStates>(null)
22-
const { path } = useRouteMatch()
22+
const { path, url } = useRouteMatch()
2323
const { push } = useHistory()
2424
const location = useLocation()
2525
const { environmentId, setEnvironmentId } = useAppContext()
@@ -69,6 +69,14 @@ export default function EnvironmentOverride({
6969
)
7070
}
7171

72+
if (params.envId && !environmentsMap.has(+params.envId) && environments.length) {
73+
const newUrl = url.replace(
74+
`${URLS.APP_ENV_OVERRIDE_CONFIG}/${params.envId}`,
75+
`${URLS.APP_ENV_OVERRIDE_CONFIG}/${environments[0].environmentId}`,
76+
)
77+
push(newUrl)
78+
}
79+
7280
const getParentName = (): string => {
7381
if (appList?.length) {
7482
return appMap.get(+params.appId).name

src/components/app/details/appConfig/EnvironmentOverrideRouter.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ const EnvOverrideRoute = ({
6969
const [deletePipeline, setDeletePipeline] = useState()
7070

7171
useEffect(() => {
72-
if (!location.pathname.includes(`${LINK}/`) && !collapsed) {
73-
toggleCollapsed(true)
74-
}
72+
toggleCollapsed(!location.pathname.includes(`${LINK}/`))
7573
}, [location.pathname])
7674

7775
const handleNavItemClick = () => {

src/components/app/details/metrics/DeploymentMetrics.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -147,24 +147,26 @@ export default class DeploymentMetrics extends Component<DeploymentMetricsProps,
147147
value: env.environmentId,
148148
deploymentAppDeleteRequest: env.deploymentAppDeleteRequest,
149149
}
150-
})
151-
allEnv = allEnv || []
152-
let callAPIOnEnvOfPrevApp = prevEnvId && allEnv.find((e) => Number(e.value) === Number(prevEnvId))
153-
this.setState({
154-
environments: allEnv,
155-
filteredEnvironment: allEnv.filter((_env) => !_env.deploymentAppDeleteRequest),
156-
view: this.props.match.params.envId || callAPIOnEnvOfPrevApp ? ViewType.LOADING : ViewType.FORM,
157-
})
158-
if (prevEnvId) {
159-
const isEnvExist = allEnv.find((e) => Number(e.value) === Number(prevEnvId))
160-
let url = generatePath(this.props.match.path, {
161-
appId: this.props.match.params.appId,
162-
envId: isEnvExist ? prevEnvId : allEnv[0].value,
163-
})
164-
this.props.history.push(url)
165-
} else if (this.props.match.params.envId) {
166-
this.callGetDeploymentMetricsAPI(this.props.match.params.appId, this.props.match.params.envId)
150+
}) || []
151+
let hideLoader = true
152+
if (allEnv.length) {
153+
if (prevEnvId && prevEnvId !== this.props.match.params.envId) {
154+
const isEnvExist = allEnv.find((e) => Number(e.value) === Number(prevEnvId))
155+
let url = generatePath(this.props.match.path, {
156+
appId: this.props.match.params.appId,
157+
envId: isEnvExist ? prevEnvId : allEnv[0].value,
158+
})
159+
this.props.history.push(url)
160+
} else if (this.props.match.params.envId) {
161+
hideLoader = false
162+
this.callGetDeploymentMetricsAPI(this.props.match.params.appId, this.props.match.params.envId)
163+
}
167164
}
165+
this.setState({
166+
environments: allEnv,
167+
filteredEnvironment: allEnv.filter((_env) => !_env.deploymentAppDeleteRequest),
168+
view: hideLoader ? ViewType.FORM: ViewType.LOADING,
169+
})
168170
})
169171
.catch((error) => {
170172
showError(error)

0 commit comments

Comments
 (0)