Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/web/src/app/maintenance/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useParams, useNavigate } from "react-router-dom";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { BackButton } from "@/components/back-button";
import {
getMaintenancesByIdOptions,
getMaintenancesByIdQueryKey,
Expand Down Expand Up @@ -151,6 +152,7 @@ const EditMaintenance = () => {

return (
<Layout pageName={`Edit Maintenance: ${maintenance?.title}`}>
<BackButton to="/maintenances" />
<CreateEditMaintenance
initialValues={initialValues}
mode="edit"
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/app/maintenance/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Layout from "@/layout";
import CreateEditMaintenance, {
type MaintenanceFormValues,
} from "../components/create-edit-form";
import { BackButton } from "@/components/back-button";
import {
getMaintenancesQueryKey,
postMaintenancesMutation,
Expand Down Expand Up @@ -82,6 +83,7 @@ const NewMaintenance = () => {

return (
<Layout pageName="Schedule Maintenance">
<BackButton to="/maintenances" />
<CreateEditMaintenance onSubmit={handleSubmit} />
</Layout>
);
Expand Down
4 changes: 3 additions & 1 deletion apps/web/src/app/monitors/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import CreateEditForm from "../components/create-edit-form";
import type { NotificationChannelModel, ProxyModel } from "@/api";
import CreateProxy from "@/app/proxies/components/create-proxy";
import CreateNotificationChannel from "@/app/notification-channels/components/create-notification-channel";
import { BackButton } from "@/components/back-button";

const EditMonitorForm = () => {
const {
Expand All @@ -29,7 +30,8 @@ const EditMonitorForm = () => {
if (!monitor) return null;

return (
<Layout pageName={`Edit Monitor | ${monitor?.data?.name}`}>
<Layout pageName={`Edit Monitor: ${monitor?.data?.name}`}>
<BackButton to={`/monitors/${monitor?.data?.id}`} />
<div className="flex flex-col gap-4">
<p className="text-gray-500">
Create a new monitor to start tracking your website's performance.
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/app/monitors/new/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Layout from "@/layout";
import { Sheet, SheetContent } from "@/components/ui/sheet";
import { BackButton } from "@/components/back-button";
import {
MonitorFormProvider,
useMonitorFormContext,
Expand All @@ -24,6 +25,7 @@ const NewMonitorContent = () => {

return (
<Layout pageName="New Monitor">
<BackButton to="/monitors" />
<div className="flex flex-col gap-4">
<p className="text-gray-500">
Create a new monitor to start tracking your website's performance.
Expand Down
15 changes: 3 additions & 12 deletions apps/web/src/app/monitors/view/page.tsx
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

back button should be replaced with component

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { useWebSocket, WebSocketStatus } from "@/context/websocket-context";
import Layout from "@/layout";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import {
ArrowLeft,
Copy,
Edit,
Loader2,
Expand All @@ -43,6 +42,7 @@ import { useNavigate, useParams } from "react-router-dom";
import { toast } from "sonner";
import { cn, commonMutationErrorHandler } from "@/lib/utils";
import ImportantNotificationsList from "../components/important-notifications-list";
import { BackButton } from "@/components/back-button";

const MonitorPage = () => {
const { id } = useParams();
Expand Down Expand Up @@ -295,21 +295,12 @@ const MonitorPage = () => {

return (
<Layout
pageName={`Monitors > ${monitor?.name ?? ""}`}
pageName={`Monitors: ${monitor?.name ?? ""}`}
isLoading={isLoading}
error={error && <div>Error: {error.message}</div>}
>
<div>
<div>
<Button
variant="ghost"
onClick={() => navigate("/monitors")}
className="mb-4 "
>
<ArrowLeft />
Back
</Button>
</div>
<BackButton to="/monitors" />
<div className="pl-4">
<span className="text-sm text-muted-foreground mr-2">
{monitor?.type} monitor for
Expand Down
4 changes: 3 additions & 1 deletion apps/web/src/app/notification-channels/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useParams, useNavigate } from "react-router-dom";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { BackButton } from "@/components/back-button";
import {
getNotificationChannelsByIdOptions,
getNotificationChannelsByIdQueryKey,
Expand Down Expand Up @@ -65,7 +66,8 @@ const EditNotificationChannel = () => {
};

return (
<Layout pageName={`Edit Notifier: ${notifier.name}`}>
<Layout pageName={`Edit Notification Channel: ${notifier.name}`}>
<BackButton to="/notification-channels" />
<CreateEditNotificationChannel
initialValues={initialValues}
onSubmit={handleSubmit}
Expand Down
4 changes: 3 additions & 1 deletion apps/web/src/app/notification-channels/new/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import Layout from "@/layout";
import { useNavigate } from "react-router-dom";
import CreateNotificationChannel from "../components/create-notification-channel";
import { BackButton } from "@/components/back-button";

const NewNotificationChannel = () => {
const navigate = useNavigate();

return (
<Layout pageName="New Notification channel">
<Layout pageName="New Notification Channel">
<BackButton to="/notification-channels" />
<CreateNotificationChannel onSuccess={() => navigate("/notification-channels")} />
</Layout>
);
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/app/proxies/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useParams, useNavigate } from "react-router-dom";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { BackButton } from "@/components/back-button";
import {
getProxiesByIdOptions,
putProxiesByIdMutation,
Expand Down Expand Up @@ -79,6 +80,7 @@ const EditProxy = () => {

return (
<Layout pageName={`Edit Proxy: ${proxy.host}:${proxy.port}`}>
<BackButton to="/proxies" />
<CreateEditProxy
initialValues={initialValues}
onSubmit={handleSubmit}
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/app/proxies/new/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import Layout from "@/layout";
import { useNavigate } from "react-router-dom";
import CreateProxy from "../components/create-proxy";
import { BackButton } from "@/components/back-button";

const NewProxy = () => {
const navigate = useNavigate();

return (
<Layout pageName="New Proxy">
<BackButton to="/proxies" />
<CreateProxy onSuccess={() => navigate("/proxies")} />
</Layout>
);
Expand Down
16 changes: 13 additions & 3 deletions apps/web/src/app/status-pages/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Layout from "@/layout";
import CreateEditForm, { type StatusPageForm } from "../components/create-edit-form";
import { useNavigate, useParams } from "react-router-dom";
import { BackButton } from "@/components/back-button";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import {
getMonitorsBatchOptions,
Expand Down Expand Up @@ -62,17 +63,26 @@ const EditStatusPageContent = () => {
});

if (statusPageIsLoading || monitorsDataIsLoading) {
return <div>Loading...</div>;
return (
<Layout pageName="Edit Status Page">
<div>Loading...</div>
</Layout>
);
}

if (!statusPage?.data) {
return <div>Status page not found</div>;
return (
<Layout pageName="Edit Status Page">
<div>Status page not found</div>
</Layout>
);
}

const statusPageData = statusPage?.data;

return (
<Layout pageName="Edit Status Page">
<Layout pageName={`Edit Status Page: ${statusPageData.title}`}>
<BackButton to="/status-pages" />
<div className="flex flex-col gap-4">
<p className="text-gray-500">
Update your status page settings and configuration.
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/app/status-pages/new/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Layout from "@/layout";
import CreateEditForm, { type StatusPageForm } from "../components/create-edit-form";
import { BackButton } from "@/components/back-button";
import {
getStatusPagesInfiniteQueryKey,
postStatusPagesMutation,
Expand Down Expand Up @@ -37,6 +38,7 @@ const NewStatusPageContent = () => {

return (
<Layout pageName="New Status Page">
<BackButton to="/status-pages" />
<div className="flex flex-col gap-4">
<p className="text-gray-500">
Create a new status page to share your service status with users.
Expand Down
34 changes: 34 additions & 0 deletions apps/web/src/components/back-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Button } from "@/components/ui/button";
import { ArrowLeft } from "lucide-react";
import { useNavigate } from "react-router-dom";

interface BackButtonProps {
to?: string;
onClick?: () => void;
className?: string;
}

export function BackButton({ to, onClick, className = "mb-4" }: BackButtonProps) {
const navigate = useNavigate();

const handleClick = () => {
if (onClick) {
onClick();
} else if (to) {
navigate(to);
} else {
navigate(-1);
}
};

return (
<Button
variant="ghost"
onClick={handleClick}
className={className}
>
<ArrowLeft />
Back
</Button>
);
}
Loading