fix: maintain cluster context after adding repo (#616) (#641)

* fix: maintain cluster context after adding repo (#616)

* chore: rollback lock file changes as requested
This commit is contained in:
Vedant Apraj
2026-01-09 23:17:22 +05:30
committed by GitHub
parent 05c7c0b5c4
commit 37af7dfbec
5 changed files with 25 additions and 36 deletions
@@ -23,8 +23,10 @@ const LinkWithSearchParams = ({
let prefixedUrl = to;
if (!clusterMode) {
if (!clusterMode && context) {
prefixedUrl = `/${encodeURIComponent(context)}${to}`;
} else {
prefixedUrl = to;
}
const url = `${prefixedUrl}/?${params.toString()}`;
-1
View File
@@ -18,7 +18,6 @@ export default function Tabs({ tabs, selectedTab }: TabsProps) {
const moveTab = (tab: Tab) => {
upsertSearchParams("tab", tab.value);
};
return (
<div className="flex flex-col">
<div className="flex pb-2">
@@ -5,8 +5,8 @@ import useAlertError from "../../hooks/useAlertError";
import useCustomSearchParams from "../../hooks/useCustomSearchParams";
import { useAppContext } from "../../context/AppContext";
import { useQueryClient } from "@tanstack/react-query";
import { useNavigate } from "react-router";
import apiService from "../../API/apiService";
import useNavigateWithSearchParams from "../../hooks/useNavigateWithSearchParams";
interface FormKeys {
name: string;
@@ -33,7 +33,7 @@ function AddRepositoryModal({ isOpen, onClose }: AddRepositoryModalProps) {
const [isLoading, setIsLoading] = useState(false);
const alertError = useAlertError();
const { setSelectedRepo } = useAppContext();
const navigate = useNavigate();
const navigate = useNavigateWithSearchParams();
const queryClient = useQueryClient();
const addRepository = async () => {
@@ -58,7 +58,8 @@ function AddRepositoryModal({ isOpen, onClose }: AddRepositoryModalProps) {
queryKey: ["helm", "repositories"],
});
setSelectedRepo(formData.name || "");
await navigate(`/repository/${formData.name}`, {
const path = `/repository/${formData.name}`;
await navigate(path, {
replace: true,
});
} catch (err) {
@@ -68,6 +69,13 @@ function AddRepositoryModal({ isOpen, onClose }: AddRepositoryModalProps) {
});
} finally {
setIsLoading(false);
setFormData({
name: "",
url: "",
username: "",
password: "",
});
onClose();
}
};