Polish the create and link to table

This commit is contained in:
Owen
2026-04-20 20:14:25 -07:00
parent f938e9c3c0
commit d7a9e1a517
5 changed files with 19 additions and 7 deletions

View File

@@ -31,6 +31,8 @@ import { useDebouncedCallback } from "use-debounce";
type AlertingRulesTableProps = {
orgId: string;
siteId?: number;
resourceId?: number;
};
type AlertRuleRow = {
@@ -99,7 +101,7 @@ function triggerLabel(
}
}
export default function AlertingRulesTable({ orgId }: AlertingRulesTableProps) {
export default function AlertingRulesTable({ orgId, siteId, resourceId }: AlertingRulesTableProps) {
const router = useRouter();
const t = useTranslations();
const api = createApiClient(useEnvContext());
@@ -127,7 +129,7 @@ export default function AlertingRulesTable({ orgId }: AlertingRulesTableProps) {
isLoading,
refetch,
isRefetching
} = useQuery(orgQueries.alertRules({ orgId, limit: pageSize, offset: pageIndex * pageSize, query }));
} = useQuery(orgQueries.alertRules({ orgId, limit: pageSize, offset: pageIndex * pageSize, query, siteId, resourceId }));
const rows = data?.alertRules ?? [];
const total = data?.pagination.total ?? 0;

View File

@@ -35,6 +35,7 @@ import { orgQueries } from "@app/lib/queries";
interface UptimeAlertSectionProps {
orgId: string;
siteId?: number;
startingName?: string;
resourceId?: number;
days?: number;
}
@@ -42,6 +43,7 @@ interface UptimeAlertSectionProps {
export default function UptimeAlertSection({
orgId,
siteId,
startingName,
resourceId,
days = 90
}: UptimeAlertSectionProps) {
@@ -49,7 +51,7 @@ export default function UptimeAlertSection({
const queryClient = useQueryClient();
const [open, setOpen] = useState(false);
const [name, setName] = useState("Uptime Alert");
const [name, setName] = useState(`${siteId ? "Site" : "Resource"} ${startingName} Alert`);
const [userTags, setUserTags] = useState<Tag[]>([]);
const [roleTags, setRoleTags] = useState<Tag[]>([]);
const [emailTags, setEmailTags] = useState<Tag[]>([]);
@@ -156,7 +158,7 @@ export default function UptimeAlertSection({
const alertButton = alertRulesLoading ? null : hasRules ? (
<Button variant="outline" size="sm" asChild>
<Link href={`/${orgId}/settings/alerting`}>
<Link href={`/${orgId}/settings/alerting?siteId=${siteId}&resourceId=${resourceId}`}>
<BellRing className="size-4 mr-2" />
View Alerts
</Link>
@@ -297,4 +299,4 @@ export default function UptimeAlertSection({
</Credenza>
</>
);
}
}