Skip to content

Commit

Permalink
fix: default landing to RB from login and bad url
Browse files Browse the repository at this point in the history
  • Loading branch information
Elessar1802 committed Dec 2, 2024
1 parent 9136060 commit b66e3ca
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
6 changes: 5 additions & 1 deletion src/components/common/navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { getModuleInfo } from '../../v2/devtronStackManager/DevtronStackManager.
import { ReactComponent as ResourceWatcherIcon } from '../../../assets/icons/ic-monitoring.svg'
import { importComponentFromFELibrary } from '../helpers/Helpers'
import { OrganizationFrame, OrganizationTextLogo } from '../../../Pages/Shared'
import { MainContext } from './types'

const hideResourceWatcher = !importComponentFromFELibrary('ResourceWatcherRouter')
const hideSoftwareDistributionHub = !importComponentFromFELibrary('SoftwareDistributionHub', null, 'function')
Expand Down Expand Up @@ -179,6 +180,7 @@ interface NavigationType extends RouteComponentProps<{}> {
installedModuleMap: React.MutableRefObject<Record<string, boolean>>
isSuperAdmin: boolean
isAirgapped: boolean
currentServerInfo: MainContext['currentServerInfo']
}

export default class Navigation extends Component<
Expand Down Expand Up @@ -425,7 +427,9 @@ export default class Navigation extends Component<
return this.renderNavLink(item)
}
})}
{!window._env_.K8S_CLIENT && !this.props.isAirgapped && this.props.serverMode !== SERVER_MODE.EA_ONLY && (
{!window._env_.K8S_CLIENT && !this.props.isAirgapped && (
this.props.serverMode !== SERVER_MODE.EA_ONLY || this.props.currentServerInfo.serverInfo?.installationType !== 'enterprise'
) && (
<>
<div className="short-nav__divider" />
{this.renderNavLink(NavigationStack, 'short-nav__stack-manager')}
Expand Down
27 changes: 10 additions & 17 deletions src/components/common/navigation/NavigationRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
MODES,
DEVTRON_BASE_MAIN_ID,
} from '@devtron-labs/devtron-fe-common-lib'
import { Route, Switch, useRouteMatch, useHistory, useLocation, Redirect } from 'react-router-dom'
import { Route, Switch, useRouteMatch, useHistory, useLocation } from 'react-router-dom'
import * as Sentry from '@sentry/browser'
import ReactGA from 'react-ga4'
import TagManager from 'react-gtm-module'
Expand Down Expand Up @@ -384,6 +384,7 @@ export default function NavigationRoutes() {
<main className={_isOnboardingPage ? 'no-nav' : ''} id={DEVTRON_BASE_MAIN_ID}>
{!_isOnboardingPage && (
<Navigation
currentServerInfo={currentServerInfo}
history={history}
match={match}
location={location}
Expand Down Expand Up @@ -421,7 +422,6 @@ export default function NavigationRoutes() {
isSuperAdmin={isSuperAdmin}
appListCount={appListCount}
loginCount={loginCount}
serverMode={serverMode}
/>
)}
/>,
Expand Down Expand Up @@ -482,7 +482,7 @@ export default function NavigationRoutes() {
</Route>,
]
: []),
...(serverMode !== SERVER_MODE.EA_ONLY
...(serverMode !== SERVER_MODE.EA_ONLY || currentServerInfo.serverInfo?.installationType !== 'enterprise'
? [
<Route key={URLS.STACK_MANAGER} path={URLS.STACK_MANAGER}>
<DevtronStackManager
Expand Down Expand Up @@ -525,7 +525,7 @@ export default function NavigationRoutes() {
)
}

export const AppRouter = ({ isSuperAdmin, appListCount, loginCount, serverMode }: AppRouterType) => {
export const AppRouter = ({ isSuperAdmin, appListCount, loginCount }: AppRouterType) => {
const { path } = useRouteMatch()
const [environmentId, setEnvironmentId] = useState(null)
const [currentAppName, setCurrentAppName] = useState<string>('')
Expand All @@ -541,7 +541,6 @@ export const AppRouter = ({ isSuperAdmin, appListCount, loginCount, serverMode }
isSuperAdmin={isSuperAdmin}
appListCount={appListCount}
loginCount={loginCount}
serverMode={serverMode}
/>
)}
/>
Expand All @@ -563,11 +562,7 @@ export const AppRouter = ({ isSuperAdmin, appListCount, loginCount, serverMode }
<Route path={`${path}/v2/:appId(\\d+)`} render={() => <AppDetailsPage isV2 />} />

<Route exact path="">
{serverMode === SERVER_MODE.EA_ONLY ? (
<Redirect to={URLS.RESOURCE_BROWSER} />
) : (
<RedirectToAppList />
)}
<RedirectToAppList />
</Route>
<Route>
<RedirectUserWithSentry
Expand All @@ -580,21 +575,17 @@ export const AppRouter = ({ isSuperAdmin, appListCount, loginCount, serverMode }
)
}

export const AppListRouter = ({ isSuperAdmin, appListCount, loginCount, serverMode }: AppRouterType) => {
export const AppListRouter = ({ isSuperAdmin, appListCount, loginCount }: AppRouterType) => {
const { path } = useRouteMatch()
const [, argoInfoData] = useAsync(() => getModuleInfo(ModuleNameMap.ARGO_CD))
const isArgoInstalled: boolean = argoInfoData?.result?.status === ModuleStatus.INSTALLED

return (
<ErrorBoundary>
<Switch>
<Route exact path={`${path}/:appType`} render={() => <NewAppList isArgoInstalled={isArgoInstalled} />} />
<Route path={`${path}/:appType`} render={() => <NewAppList isArgoInstalled={isArgoInstalled} />} />
<Route exact path="">
{serverMode === SERVER_MODE.EA_ONLY ? (
<Redirect to={URLS.RESOURCE_BROWSER} />
) : (
<RedirectToAppList />
)}
<RedirectToAppList />
</Route>
<Route>
<RedirectUserWithSentry isFirstLoginUser={isSuperAdmin && loginCount === 0 && appListCount === 0} />
Expand Down Expand Up @@ -624,6 +615,8 @@ export const RedirectUserWithSentry = ({ isFirstLoginUser }) => {
push(URLS.RESOURCE_BROWSER)
} else if (isFirstLoginUser) {
push(URLS.GETTING_STARTED)
} else if (window._env_.FEATURE_DEFAULT_LANDING_RB_ENABLE) {
push(URLS.RESOURCE_BROWSER)
} else {
push(`${URLS.APP}/${URLS.APP_LIST}`)
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Login extends Component<LoginProps, LoginFormState> {
return CommonURL.NETWORK_STATUS_INTERFACE
}

return URLS.APP
return window._env_.FEATURE_DEFAULT_LANDING_RB_ENABLE ? URLS.RESOURCE_BROWSER : URLS.APP
}

login(e): void {
Expand Down
1 change: 0 additions & 1 deletion src/services/service.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ export interface AppRouterType {
isSuperAdmin?: boolean
appListCount: number
loginCount: number
serverMode: SERVER_MODE
}

export interface ConfigOverrideWorkflowDetails {
Expand Down

0 comments on commit b66e3ca

Please sign in to comment.