mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-30 19:06:23 +02:00
Add query params in URLs for tabs in triggers to route correctly
This commit is contained in:
parent
221d7f992b
commit
e1f87a8db9
7 changed files with 35 additions and 14 deletions
|
|
@ -47,7 +47,7 @@ export function ComposioTriggerDeploymentView({ projectId, deploymentId }: { pro
|
|||
setDeleting(true);
|
||||
try {
|
||||
await deleteComposioTriggerDeployment({ projectId, deploymentId: deployment.id });
|
||||
window.location.href = `/projects/${projectId}/job-rules`;
|
||||
window.location.href = `/projects/${projectId}/job-rules?tab=triggers`;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert('Failed to delete trigger');
|
||||
|
|
@ -62,7 +62,7 @@ export function ComposioTriggerDeploymentView({ projectId, deploymentId }: { pro
|
|||
<Panel
|
||||
title={
|
||||
<div className="flex items-center gap-3">
|
||||
<Link href={`/projects/${projectId}/job-rules`}>
|
||||
<Link href={`/projects/${projectId}/job-rules?tab=triggers`}>
|
||||
<Button variant="secondary" size="sm">
|
||||
<ArrowLeftIcon className="w-4 h-4 mr-2" />
|
||||
Back
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ export function CreateRecurringJobRuleForm({ projectId }: { projectId: string })
|
|||
input: { messages: convertedMessages },
|
||||
cron: cronExpression,
|
||||
});
|
||||
router.push(`/projects/${projectId}/job-rules`);
|
||||
router.push(`/projects/${projectId}/job-rules?tab=recurring`);
|
||||
} catch (error) {
|
||||
console.error("Failed to create recurring job rule:", error);
|
||||
alert("Failed to create recurring job rule");
|
||||
|
|
@ -102,7 +102,7 @@ export function CreateRecurringJobRuleForm({ projectId }: { projectId: string })
|
|||
<Panel
|
||||
title={
|
||||
<div className="flex items-center gap-3">
|
||||
<Link href={`/projects/${projectId}/job-rules`}>
|
||||
<Link href={`/projects/${projectId}/job-rules?tab=recurring`}>
|
||||
<Button variant="secondary" size="sm" startContent={<ArrowLeftIcon className="w-4 h-4" />} className="whitespace-nowrap">
|
||||
Back
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -1,18 +1,35 @@
|
|||
'use client';
|
||||
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||
import { Tabs, Tab } from "@/components/ui/tabs";
|
||||
import { ScheduledJobRulesList } from "../scheduled/components/scheduled-job-rules-list";
|
||||
import { RecurringJobRulesList } from "./recurring-job-rules-list";
|
||||
import { TriggersTab } from "./triggers-tab";
|
||||
|
||||
export function JobRulesTabs({ projectId }: { projectId: string }) {
|
||||
const [activeTab, setActiveTab] = useState<string>("triggers");
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
const initialTab = (searchParams.get('tab') ?? 'triggers');
|
||||
const [activeTab, setActiveTab] = useState<string>(initialTab);
|
||||
|
||||
const handleTabChange = (key: React.Key) => {
|
||||
setActiveTab(key.toString());
|
||||
const nextTab = key.toString();
|
||||
setActiveTab(nextTab);
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
params.set('tab', nextTab);
|
||||
router.replace(`${pathname}?${params.toString()}`);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const current = searchParams.get('tab') ?? 'triggers';
|
||||
if (current !== activeTab) {
|
||||
setActiveTab(current);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [searchParams]);
|
||||
|
||||
return (
|
||||
<div className="h-full flex flex-col">
|
||||
<Tabs
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ export function RecurringJobRuleView({ projectId, ruleId }: { projectId: string;
|
|||
ruleId: rule.id,
|
||||
});
|
||||
// Redirect back to job rules list
|
||||
router.push(`/projects/${projectId}/job-rules`);
|
||||
router.push(`/projects/${projectId}/job-rules?tab=recurring`);
|
||||
} catch (error) {
|
||||
console.error("Failed to delete rule:", error);
|
||||
alert("Failed to delete rule");
|
||||
|
|
@ -133,7 +133,7 @@ export function RecurringJobRuleView({ projectId, ruleId }: { projectId: string;
|
|||
<Panel
|
||||
title={
|
||||
<div className="flex items-center gap-3">
|
||||
<Link href={`/projects/${projectId}/job-rules`}>
|
||||
<Link href={`/projects/${projectId}/job-rules?tab=recurring`}>
|
||||
<Button variant="secondary" size="sm" startContent={<ArrowLeftIcon className="w-4 h-4" />} className="whitespace-nowrap">
|
||||
Back
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -180,7 +180,11 @@ export function TriggersTab({ projectId }: { projectId: string }) {
|
|||
triggerConfig,
|
||||
});
|
||||
|
||||
// Success! Go back to triggers list and reload
|
||||
// Success! Go back to triggers list tab and reload
|
||||
if (typeof window !== 'undefined') {
|
||||
window.location.href = `/projects/${projectId}/job-rules?tab=triggers`;
|
||||
return;
|
||||
}
|
||||
handleBackToList();
|
||||
} catch (err: any) {
|
||||
console.error('Error creating trigger:', err);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ export function CreateScheduledJobRuleForm({ projectId }: { projectId: string })
|
|||
input: { messages: convertedMessages },
|
||||
scheduledTime: scheduledTimeString,
|
||||
});
|
||||
router.push(`/projects/${projectId}/job-rules`);
|
||||
router.push(`/projects/${projectId}/job-rules?tab=scheduled`);
|
||||
} catch (error) {
|
||||
console.error("Failed to create scheduled job rule:", error);
|
||||
alert("Failed to create scheduled job rule");
|
||||
|
|
@ -105,7 +105,7 @@ export function CreateScheduledJobRuleForm({ projectId }: { projectId: string })
|
|||
<Panel
|
||||
title={
|
||||
<div className="flex items-center gap-3">
|
||||
<Link href={`/projects/${projectId}/job-rules`}>
|
||||
<Link href={`/projects/${projectId}/job-rules?tab=scheduled`}>
|
||||
<Button variant="secondary" size="sm" startContent={<ArrowLeftIcon className="w-4 h-4" />} className="whitespace-nowrap">
|
||||
Back
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export function ScheduledJobRuleView({ projectId, ruleId }: { projectId: string;
|
|||
ruleId: rule.id,
|
||||
});
|
||||
// Redirect back to job rules list
|
||||
router.push(`/projects/${projectId}/job-rules`);
|
||||
router.push(`/projects/${projectId}/job-rules?tab=scheduled`);
|
||||
} catch (error) {
|
||||
console.error("Failed to delete rule:", error);
|
||||
alert("Failed to delete rule");
|
||||
|
|
@ -80,7 +80,7 @@ export function ScheduledJobRuleView({ projectId, ruleId }: { projectId: string;
|
|||
<Panel
|
||||
title={
|
||||
<div className="flex items-center gap-3">
|
||||
<Link href={`/projects/${projectId}/job-rules`}>
|
||||
<Link href={`/projects/${projectId}/job-rules?tab=scheduled`}>
|
||||
<Button variant="secondary" size="sm" startContent={<ArrowLeftIcon className="w-4 h-4" />} className="whitespace-nowrap">
|
||||
Back
|
||||
</Button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue