hunk.code_window:             if (endpoint.Type === PortainerEndpointTypes.EdgeAgentOnKubernetesEnvironment && endpoint.Status === EnvironmentStatus.Down) {
                 throw new Error('Unable to contact Edge agent, please ensure that the agent is properly running on the remote environment.');
               }
               await KubernetesNamespaceService.get();
             } catch (e) {
               let params = {};
               if (endpoint.Type == PortainerEndpointTypes.EdgeAgentOnKubernetesEnvironment) {
                 params = { redirect: true, environmentId: endpoint.Id, environmentName: endpoint.Name, route: 'kubernetes.dashboard' };
  
hunk.labels: keep keep keep keep keep replace keep keep keep keep keep
hunk.after_edit:             // use selfsubject access review to check if we can connect to the kubernetes environment
               // because it's gets a fast response, and is accessible to all users
               try {
                 await getSelfSubjectAccessReview(endpoint.Id, 'default');
               } catch (e) {
                 throw new Error('Environment is unreachable.');
               }
  
hunk.file_path: app/kubernetes/__module.js
hunk.type: replace
file: package registries
  
  import (
  	"net/http"
  
  	httperror "github.com/portainer/libhttp/error"
  	"github.com/portainer/libhttp/request"
  	"github.com/portainer/libhttp/response"
  	portainer "github.com/portainer/portainer/api"
  	httperrors "github.com/portainer/portainer/api/http/errors"
  	"github.com/portainer/portainer/api/http/security"
  )
  
  // @id RegistryDelete
  // @summary Remove a registry
  // @description Remove a registry
  // @description **Access policy**: restricted
  // @tags registries
  // @security ApiKeyAuth
  // @security jwt
  // @param id path int true "Registry identifier"
  // @success 204 "Success"
  // @failure 400 "Invalid request"
  // @failure 404 "Registry not found"
  // @failure 500 "Server error"
  // @router /registries/{id} [delete]
  func (handler *Handler) registryDelete(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
  	securityContext, err := security.RetrieveRestrictedRequestContext(r)
  	if err != nil {
  		return httperror.InternalServerError("Unable to retrieve info from request context", err)
  	}
  	if !securityContext.IsAdmin {
  		return httperror.Forbidden("Permission denied to delete registry", httperrors.ErrResourceAccessDenied)
  	}
  
  	registryID, err := request.RetrieveNumericRouteVariableValue(r, "id")
  	if err != nil {
  		return httperror.BadRequest("Invalid registry identifier route variable", err)
  	}
  
  	_, err = handler.DataStore.Registry().Registry(portainer.RegistryID(registryID))
  	if handler.DataStore.IsErrObjectNotFound(err) {
  		return httperror.NotFound("Unable to find a registry with the specified identifier inside the database", err)
  	} else if err != nil {
  		return httperror.InternalServerError("Unable to find a registry with the specified identifier inside the database", err)
  	}
  
  	err = handler.DataStore.Registry().DeleteRegistry(portainer.RegistryID(registryID))
  	if err != nil {
  		return httperror.InternalServerError("Unable to remove the registry from the database", err)
  	}
  
  	return response.Empty(w)
  }
  