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

View File

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

View File

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