mirror of https://github.com/portainer/portainer
fix(home): link to correct env route [EE-4877] (#8295)
parent
329e8bcad5
commit
d3bed3072b
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue