mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 12:22:14 +03:00
fix(dashboard): resolve popover overflow, resilience API schema reject (#1039)
This commit is contained in:
@@ -529,7 +529,8 @@ function ModelCompatPopover({
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const panelRef = useRef<HTMLDivElement | null>(null);
|
||||
const [portalPanelRect, setPortalPanelRect] = useState<{
|
||||
top: number;
|
||||
top?: number;
|
||||
bottom?: number;
|
||||
left: number;
|
||||
width: number;
|
||||
} | null>(null);
|
||||
@@ -621,7 +622,16 @@ function ModelCompatPopover({
|
||||
const width = Math.min(window.innerWidth - 2 * margin, 24 * 16);
|
||||
let left = rect.right - width;
|
||||
left = Math.max(margin, Math.min(left, window.innerWidth - width - margin));
|
||||
setPortalPanelRect({ top: rect.bottom + 8, left, width });
|
||||
// Estimated panel height: capped at min(82vh, 42rem=672px)
|
||||
const estimatedPanelHeight = Math.min(window.innerHeight * 0.82, 672);
|
||||
const spaceBelow = window.innerHeight - rect.bottom - margin;
|
||||
const spaceAbove = rect.top - margin;
|
||||
if (spaceBelow < estimatedPanelHeight && spaceAbove > spaceBelow) {
|
||||
// Not enough space below — open upward
|
||||
setPortalPanelRect({ bottom: window.innerHeight - rect.top + 8, left, width });
|
||||
} else {
|
||||
setPortalPanelRect({ top: rect.bottom + 8, left, width });
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
@@ -662,7 +672,9 @@ function ModelCompatPopover({
|
||||
className={panelChromeClass}
|
||||
style={{
|
||||
position: "fixed",
|
||||
top: portalPanelRect.top,
|
||||
...(portalPanelRect.top !== undefined
|
||||
? { top: portalPanelRect.top }
|
||||
: { bottom: portalPanelRect.bottom }),
|
||||
left: portalPanelRect.left,
|
||||
width: portalPanelRect.width,
|
||||
zIndex: 10040,
|
||||
|
||||
@@ -116,11 +116,10 @@ export default function AutoDisableCard() {
|
||||
onChange={(e) =>
|
||||
setDraft((prev) => ({ ...prev, threshold: parseInt(e.target.value) || 1 }))
|
||||
}
|
||||
disabled={!draft.enabled}
|
||||
/>
|
||||
) : (
|
||||
<span className={`text-sm font-mono ${!data.enabled && "opacity-50"}`}>
|
||||
{data.threshold} {t("failures", { count: data.threshold })}
|
||||
{t("failures", { count: data.threshold })}
|
||||
</span>
|
||||
)}
|
||||
<p className="text-xs text-text-muted mt-2">{t("autoDisableThresholdDesc")}</p>
|
||||
|
||||
@@ -79,7 +79,9 @@ function ProviderProfilesCard({ profiles, onSave, saving }) {
|
||||
];
|
||||
|
||||
const handleSave = () => {
|
||||
onSave(draft);
|
||||
// Only send 'oauth' and 'apikey' — the API schema rejects any other keys (e.g. 'local')
|
||||
const { oauth, apikey } = draft ?? {};
|
||||
onSave({ ...(oauth ? { oauth } : {}), ...(apikey ? { apikey } : {}) });
|
||||
setEditMode(false);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user