{data.provider_display_name}
@@ -1952,10 +2051,11 @@ function ConnectionActions({
onRefresh: () => void;
principal?: string;
}) {
+ const router = useRouter();
const [open, setOpen] = useState(false);
const [working, setWorking] = useState(false);
const [globalWorking, setGlobalWorking] = useState(false);
- const [globalMessage, setGlobalMessage] = useState("");
+ const [globalMessage, setGlobalMessage] = useState<{ text: string; tone: "error" | "success" } | null>(null);
async function logout() {
setWorking(true);
@@ -1963,20 +2063,29 @@ function ConnectionActions({
await logoutConnection(data.provider, data.connection_name, principal);
setOpen(false);
onRefresh();
+ router.replace("/connections");
} finally {
setWorking(false);
}
}
- async function makeGlobal() {
+ async function toggleGlobal() {
setGlobalWorking(true);
- setGlobalMessage("");
+ setGlobalMessage(null);
try {
- await setGlobalConnection(data.provider, data.connection_name);
- setGlobalMessage("Global connection updated.");
+ if (data.is_global) {
+ await unsetGlobalConnection(data.provider);
+ setGlobalMessage({ text: "Global connection removed.", tone: "success" });
+ } else {
+ await setGlobalConnection(data.provider, data.connection_name);
+ setGlobalMessage({ text: "Global connection updated.", tone: "success" });
+ }
onRefresh();
} catch (error) {
- setGlobalMessage(error instanceof Error ? error.message : "Global connection could not be updated.");
+ setGlobalMessage({
+ text: error instanceof Error ? error.message : "Global connection could not be updated.",
+ tone: "error",
+ });
} finally {
setGlobalWorking(false);
}
@@ -1984,31 +2093,41 @@ function ConnectionActions({
return (
<>
-
- {data.can_set_default ? (
-