fix(home): link to correct env route [EE-4877] (#8295)

pull/8308/head
Chaim Lev-Ari 2023-01-12 15:02:37 +02:00 committed by GitHub
parent 329e8bcad5
commit d3bed3072b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 21 deletions

View File

@ -23,6 +23,8 @@ export function EnvironmentBrowseButtons({
}) { }) {
const isEdgeAsync = checkEdgeAsync(environment); const isEdgeAsync = checkEdgeAsync(environment);
const browseStatus = getStatus(isActive, isEdgeAsync); const browseStatus = getStatus(isActive, isEdgeAsync);
const dashboardRoute = getDashboardRoute(environment);
return ( return (
<div className="flex flex-col gap-1 justify-center [&>*]:h-1/3 h-24"> <div className="flex flex-col gap-1 justify-center [&>*]:h-1/3 h-24">
{isBE && ( {isBE && (
@ -44,10 +46,8 @@ export function EnvironmentBrowseButtons({
title="Live connection is not available for async environments" title="Live connection is not available for async environments"
icon={Wifi} icon={Wifi}
disabled={isEdgeAsync || browseStatus === 'connected'} disabled={isEdgeAsync || browseStatus === 'connected'}
to={getDashboardRoute(environment)} to={dashboardRoute.to}
params={{ params={dashboardRoute.params}
endpointId: environment.Id,
}}
onClick={onClickBrowse} onClick={onClickBrowse}
color="primary" color="primary"
className="w-full !py-0 !m-0" className="w-full !py-0 !m-0"

View File

@ -47,15 +47,13 @@ export function EnvironmentItem({
const snapshotTime = getSnapshotTime(environment); const snapshotTime = getSnapshotTime(environment);
const tags = useEnvironmentTagNames(environment.TagIds); const tags = useEnvironmentTagNames(environment.TagIds);
const dashboardRoute = getDashboardRoute(environment);
return ( return (
<div className="relative"> <div className="relative">
<Link <Link
to={getDashboardRoute(environment)} to={dashboardRoute.to}
params={{ params={dashboardRoute.params}
endpointId: environment.Id,
environmentId: environment.Id,
}}
className="no-link" className="no-link"
> >
<button <button

View File

@ -70,16 +70,27 @@ export function isLocalEnvironment(environment: Environment) {
export function getDashboardRoute(environment: Environment) { export function getDashboardRoute(environment: Environment) {
if (isEdgeEnvironment(environment.Type)) { if (isEdgeEnvironment(environment.Type)) {
if (!environment.EdgeID) { if (!environment.EdgeID) {
return 'portainer.endpoints.endpoint'; return {
to: 'portainer.endpoints.endpoint',
params: { id: environment.Id },
};
} }
if (isEdgeAsync(environment)) { if (isEdgeAsync(environment)) {
return 'edge.browse.dashboard'; return {
to: 'edge.browse.dashboard',
params: { environmentId: environment.EdgeID },
};
} }
} }
const params = { endpointId: environment.Id };
const to = getPlatformRoute();
return { to, params };
function getPlatformRoute() {
const platform = getPlatformType(environment.Type); const platform = getPlatformType(environment.Type);
switch (platform) { switch (platform) {
case PlatformType.Azure: case PlatformType.Azure:
return 'azure.dashboard'; return 'azure.dashboard';
@ -87,7 +98,10 @@ export function getDashboardRoute(environment: Environment) {
return 'docker.dashboard'; return 'docker.dashboard';
case PlatformType.Kubernetes: case PlatformType.Kubernetes:
return 'kubernetes.dashboard'; return 'kubernetes.dashboard';
case PlatformType.Nomad:
return 'nomad.dashboard';
default: default:
return ''; throw new Error(`Unsupported platform ${platform}`);
}
} }
} }