Skip to content

Commit

Permalink
refactor: rename db field
Browse files Browse the repository at this point in the history
  • Loading branch information
mxkaske committed Oct 21, 2024
1 parent 9b09fc1 commit 9192aff
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/app/status-page/[domain]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default async function Page({ params }: Props) {
statusReports={page.statusReports}
incidents={page.incidents}
maintenances={page.maintenances}
displayNumbers={!!page.displayRequestNumbers}
showMonitorValues={!!page.showMonitorValues}
/>
) : (
<EmptyState
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/data-table/monitor/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export const columns: ColumnDef<{
<Bar
key={tracker.day}
className="h-5"
displayNumbers={true}
showValues={true}
{...tracker}
/>
))}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/forms/status-page/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function StatusPageForm({
icon: defaultValues?.icon || "",
password: defaultValues?.password || "",
passwordProtected: defaultValues?.passwordProtected || false,
displayRequestNumbers: defaultValues?.displayRequestNumbers || true,
showMonitorValues: defaultValues?.showMonitorValues || true,
monitors:
checkAllMonitors && allMonitors
? allMonitors.map(({ id }) => ({ monitorId: id, order: 0 }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ export function SectionAdvanced({ form }: Props) {
day={new Date().toISOString()}
count={5600}
ok={5569}
displayNumbers={!!form.getValues("displayRequestNumbers")}
showValues={!!form.getValues("showMonitorValues")}
barClassName="bg-status-operational"
className="md:col-span-1 bg-popover text-popover-foreground rounded-md border p-2 shadow-md"
/>
</div>
</div>
<FormField
control={form.control}
name="displayRequestNumbers"
name="showMonitorValues"
render={({ field }) => (
<FormItem className="flex flex-row items-start space-x-3 space-y-0 md:col-span-2">
<FormControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export function SectionVisibility({ form, plan, workspaceSlug }: Props) {
</p>
<div className="flex flex-wrap items-center gap-2">
<p className="text-foreground">{link} </p>
{/* TODO: think of building a better shadcn like "CopyToClipboardButton" */}
<CopyToClipboardButton
text={link}
tooltipText="Copy to clipboard"
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/status-page/monitor-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export const MonitorList = ({
statusReports,
incidents,
maintenances,
displayNumbers,
showMonitorValues,
}: {
monitors: PublicMonitor[];
statusReports: z.infer<typeof selectPublicStatusReportSchemaWithRelation>[];
incidents: Incident[];
maintenances: Maintenance[];
displayNumbers?: boolean;
showMonitorValues?: boolean;
}) => {
return (
<div className="grid gap-4">
Expand All @@ -43,7 +43,7 @@ export const MonitorList = ({
statusReports={monitorStatusReport}
incidents={monitorIncidents}
maintenances={monitorMaintenances}
displayNumbers={displayNumbers}
showValues={showMonitorValues}
/>
);
})}
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/status-page/monitor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export const Monitor = async ({
statusReports,
incidents,
maintenances,
displayNumbers,
showValues,
}: {
monitor: PublicMonitor;
statusReports: z.infer<typeof selectPublicStatusReportSchemaWithRelation>[];
incidents: Incident[];
maintenances: Maintenance[];
displayNumbers?: boolean;
showValues?: boolean;
}) => {
const data = await tb.endpointStatusPeriod("45d")({
monitorId: String(monitor.id),
Expand All @@ -40,7 +40,7 @@ export const Monitor = async ({
reports={statusReports}
incidents={incidents}
maintenances={maintenances}
displayNumbers={displayNumbers}
showValues={showValues}
{...monitor}
/>
);
Expand Down
18 changes: 9 additions & 9 deletions apps/web/src/components/tracker/tracker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ interface TrackerProps {
reports?: (StatusReport & { statusReportUpdates: StatusReportUpdate[] })[];
incidents?: Incident[];
maintenances?: Maintenance[];
displayNumbers?: boolean;
showValues?: boolean;
}

export function Tracker({
Expand All @@ -73,7 +73,7 @@ export function Tracker({
reports,
incidents,
maintenances,
displayNumbers,
showValues,
}: TrackerProps) {
const tracker = new OSTracker({
data,
Expand Down Expand Up @@ -110,7 +110,7 @@ export function Tracker({
<div className="flex flex-row-reverse gap-px sm:gap-0.5">
{tracker.days.map((props, i) => {
// biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
return <Bar key={i} displayNumbers={displayNumbers} {...props} />;
return <Bar key={i} showValues={showValues} {...props} />;
})}
</div>
</div>
Expand All @@ -124,7 +124,7 @@ export function Tracker({

type BarProps = OSTracker["days"][number] & {
className?: string;
displayNumbers?: boolean;
showValues?: boolean;
};

export const Bar = ({
Expand All @@ -136,7 +136,7 @@ export const Bar = ({
blacklist,
statusReports,
incidents,
displayNumbers,
showValues,
className,
}: BarProps) => {
const [open, setOpen] = React.useState(false);
Expand Down Expand Up @@ -181,7 +181,7 @@ export const Bar = ({
count={count}
ok={ok}
barClassName={rootClassName}
displayNumbers={displayNumbers}
showValues={showValues}
/>
{statusReports && statusReports.length > 0 ? (
<>
Expand All @@ -207,15 +207,15 @@ export function BarDescription({
day,
count,
ok,
displayNumbers,
showValues,
barClassName,
className,
}: {
label: string;
day: string;
count: number;
ok: number;
displayNumbers?: boolean;
showValues?: boolean;
barClassName?: string;
className?: string;
}) {
Expand All @@ -229,7 +229,7 @@ export function BarDescription({
{format(new Date(day), "MMM d")}
</p>
</div>
{displayNumbers ? (
{showValues ? (
<div className="flex justify-between gap-8 font-light text-muted-foreground text-xs">
<p>
<code className="text-status-operational">{count}</code> requests
Expand Down
1 change: 0 additions & 1 deletion packages/db/drizzle/0037_calm_bastion.sql

This file was deleted.

1 change: 1 addition & 0 deletions packages/db/drizzle/0037_equal_beyonder.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `page` ADD `show_monitor_values` integer DEFAULT true;
6 changes: 3 additions & 3 deletions packages/db/drizzle/meta/0037_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "085ab8c6-eb64-404d-9f8c-e90ce4c3fa34",
"id": "09d93b56-dcc3-4148-934a-a490ab04bab9",
"prevId": "7321a546-31be-4313-8e3f-235db16ddee4",
"tables": {
"status_report_to_monitors": {
Expand Down Expand Up @@ -388,8 +388,8 @@
"autoincrement": false,
"default": false
},
"display_request_numbers": {
"name": "display_request_numbers",
"show_monitor_values": {
"name": "show_monitor_values",
"type": "integer",
"primaryKey": false,
"notNull": false,
Expand Down
4 changes: 2 additions & 2 deletions packages/db/drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@
{
"idx": 37,
"version": "6",
"when": 1729427362671,
"tag": "0037_calm_bastion",
"when": 1729533101998,
"tag": "0037_equal_beyonder",
"breakpoints": true
}
]
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/schema/pages/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const page = sqliteTable("page", {
/**
* Displays the total and failed request numbers for each monitor
*/
displayRequestNumbers: integer("display_request_numbers", {
showMonitorValues: integer("show_monitor_values", {
mode: "boolean",
}).default(true),

Expand Down

0 comments on commit 9192aff

Please sign in to comment.