Move the notification settings onto the general settings page
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
Bell,
|
|
||||||
BookOpen,
|
BookOpen,
|
||||||
Bot,
|
Bot,
|
||||||
CpuAi,
|
CpuAi,
|
||||||
@@ -47,11 +46,6 @@ export const SettingsPages: SettingsPage[] = [
|
|||||||
Icon: SlidersHorizontal,
|
Icon: SlidersHorizontal,
|
||||||
},
|
},
|
||||||
{ title: "Profile", url: "/admin/settings/profile", Icon: UserRound },
|
{ title: "Profile", url: "/admin/settings/profile", Icon: UserRound },
|
||||||
{
|
|
||||||
title: "Notifications",
|
|
||||||
url: "/admin/settings/notifications",
|
|
||||||
Icon: Bell,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: "Change password",
|
title: "Change password",
|
||||||
url: "/admin/settings/change-password",
|
url: "/admin/settings/change-password",
|
||||||
|
|||||||
@@ -1,7 +1,27 @@
|
|||||||
import type { PagePropsType } from "@/src/types";
|
import type { PagePropsType } from "@/src/types";
|
||||||
import type { BunextPageServerFn } from "@moduletrace/bunext/types";
|
import type { BunextPageServerFn } from "@moduletrace/bunext/types";
|
||||||
|
import grabPushOverview from "@/src/functions/backend/db/push/grab-push-overview";
|
||||||
|
import { ensureVapidKeys } from "@/src/push/vapid";
|
||||||
import grabSettingsServerProps from "../(functions)/grab-settings-server-props";
|
import grabSettingsServerProps from "../(functions)/grab-settings-server-props";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The General page: app appearance and behavior, plus this user's
|
||||||
|
* notification devices and the public key a new device subscribes with.
|
||||||
|
*/
|
||||||
export const server: BunextPageServerFn<PagePropsType> = async (params) => {
|
export const server: BunextPageServerFn<PagePropsType> = async (params) => {
|
||||||
return await grabSettingsServerProps(params);
|
const settings = await grabSettingsServerProps(params);
|
||||||
|
|
||||||
|
if (!settings.props?.person?.id) return settings;
|
||||||
|
|
||||||
|
const keys = await ensureVapidKeys().catch(() => null);
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
...settings.props,
|
||||||
|
push_overview: await grabPushOverview({
|
||||||
|
user_id: settings.props.person.id,
|
||||||
|
public_key: keys?.public_key || null,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import AppearanceSection from "./(sections)/appearance-section";
|
import AppearanceSection from "./(sections)/appearance-section";
|
||||||
|
import NotificationsSection from "./(sections)/notifications-section";
|
||||||
import PromptSection from "./(sections)/prompt-section";
|
import PromptSection from "./(sections)/prompt-section";
|
||||||
import StorageSection from "./(sections)/storage-section";
|
import StorageSection from "./(sections)/storage-section";
|
||||||
import VersionSection from "./(sections)/version-section";
|
import VersionSection from "./(sections)/version-section";
|
||||||
@@ -12,6 +13,7 @@ export default function AdminSettingsGeneralPage() {
|
|||||||
description="How the app looks and behaves."
|
description="How the app looks and behaves."
|
||||||
>
|
>
|
||||||
<AppearanceSection />
|
<AppearanceSection />
|
||||||
|
<NotificationsSection />
|
||||||
<PromptSection />
|
<PromptSection />
|
||||||
<StorageSection />
|
<StorageSection />
|
||||||
<VersionSection />
|
<VersionSection />
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
import type { PagePropsType } from "@/src/types";
|
|
||||||
import type { BunextPageServerFn } from "@moduletrace/bunext/types";
|
|
||||||
import grabPushOverview from "@/src/functions/backend/db/push/grab-push-overview";
|
|
||||||
import { ensureVapidKeys } from "@/src/push/vapid";
|
|
||||||
import grabSettingsServerProps from "../(functions)/grab-settings-server-props";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Notifications page: this user's devices and the public key a new
|
|
||||||
* device subscribes with.
|
|
||||||
*/
|
|
||||||
export const server: BunextPageServerFn<PagePropsType> = async (params) => {
|
|
||||||
const settings = await grabSettingsServerProps(params);
|
|
||||||
|
|
||||||
if (!settings.props?.person?.id) return settings;
|
|
||||||
|
|
||||||
const keys = await ensureVapidKeys().catch(() => null);
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
...settings.props,
|
|
||||||
push_overview: await grabPushOverview({
|
|
||||||
user_id: settings.props.person.id,
|
|
||||||
public_key: keys?.public_key || null,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import NotificationsSection from "./(sections)/notifications-section";
|
|
||||||
import SettingsShell from "../(partials)/settings-shell";
|
|
||||||
import settingsPageMeta from "../(functions)/settings-page-meta";
|
|
||||||
|
|
||||||
export default function AdminSettingsNotificationsPage() {
|
|
||||||
return (
|
|
||||||
<SettingsShell
|
|
||||||
title="Notifications"
|
|
||||||
description="When a bot needs you, and which devices hear about it."
|
|
||||||
>
|
|
||||||
<NotificationsSection />
|
|
||||||
</SettingsShell>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const meta = settingsPageMeta({ label: "Notifications" });
|
|
||||||
@@ -42,7 +42,7 @@ export const handler: BunextAPIRouteHandler<APIResponseObject> = async ({
|
|||||||
payload: {
|
payload: {
|
||||||
title: `${SiteData["SiteName"]} notifications are on`,
|
title: `${SiteData["SiteName"]} notifications are on`,
|
||||||
body: "This is what a bot's message will look like.",
|
body: "This is what a bot's message will look like.",
|
||||||
url: "/admin/settings/notifications",
|
url: "/admin/settings/general",
|
||||||
tag: "cobble-test",
|
tag: "cobble-test",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user