⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
move worker page to worker-console page
daniel31x13e3de382739a6
diff --git a/apps/web/components/SettingsSidebar.tsx b/apps/web/components/SettingsSidebar.tsxindex 31879fd5..919f7d63 100644--- a/apps/web/components/SettingsSidebar.tsx+++ b/apps/web/components/SettingsSidebar.tsx@@ -126,22 +126,20 @@ export default function SettingsSidebar({ className }: { className?: string }) {</div></Link>- {isAdmin && (- <Link href="/settings/worker">- <div- className={`${- active === "/settings/worker"- ? "bg-primary/20"- : "hover:bg-neutral/20"- } duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}- >- <i className="bi-gear-wide-connected text-primary text-xl drop-shadow"></i>- <p className="truncate w-full font-semibold text-sm">- {t("worker")}- </p>- </div>- </Link>- )}+ <Link href="/settings/worker-console">+ <div+ className={`${+ active === "/settings/worker-console"+ ? "bg-primary/20"+ : "hover:bg-neutral/20"+ } duration-200 cursor-pointer flex items-center gap-2 rounded-lg px-3 py-1`}+ >+ <i className="bi-gear-wide-connected text-primary text-xl drop-shadow"></i>+ <p className="truncate w-full font-semibold text-sm">+ {t("worker_console")}+ </p>+ </div>+ </Link>{process.env.NEXT_PUBLIC_STRIPE && !user?.parentSubscriptionId && (<Link href="/settings/billing">diff --git a/apps/web/pages/settings/worker-console.tsx b/apps/web/pages/settings/worker-console.tsxnew file mode 100644index 00000000..b1323f9d--- /dev/null+++ b/apps/web/pages/settings/worker-console.tsx@@ -0,0 +1,133 @@+import SettingsLayout from "@/layouts/SettingsLayout";+import { useTranslation } from "next-i18next";+import getServerSideProps from "@/lib/client/getServerSideProps";+import { ReactElement, useEffect, useState } from "react";+import ConfirmationModal from "@/components/ConfirmationModal";+import { LinkArchiveActionSchemaType } from "@linkwarden/lib/schemaValidation";+import toast from "react-hot-toast";+import { useArchiveAction } from "@linkwarden/router/links";+import { Button } from "@/components/ui/button";+import { Separator } from "@/components/ui/separator";+import { NextPageWithLayout } from "../_app";++const Page: NextPageWithLayout = () => {+ const { t } = useTranslation();+ const archiveAction = useArchiveAction();+ const [showModal, setShowModal] = useState(false);+ const [submitLoader, setSubmitLoader] = useState(false);+ const [action, setAction] = useState<+ LinkArchiveActionSchemaType["action"] | undefined+ >();++ useEffect(() => {+ if (showModal === false) {+ setAction(undefined);+ }+ }, [showModal]);++ const submit = async (action: LinkArchiveActionSchemaType["action"]) => {+ if (!action || submitLoader) return;+ setSubmitLoader(true);++ const load = toast.loading(t("deleting"));++ await archiveAction.mutateAsync(+ { action },+ {+ onSettled: (data, error) => {+ setSubmitLoader(false);+ toast.dismiss(load);++ if (error) {+ toast.error(error.message);+ } else {+ if (action === "allAndIgnore") {+ toast.success(t("deleted"));+ } else {+ toast.success(t("links_are_being_represerved"));+ }+ }+ },+ }+ );+ };++ return (+ <>+ <div className="flex items-center gap-2">+ <i className="bi-gear-wide-connected text-primary text-2xl"></i>+ <p className="capitalize text-3xl font-thin inline">+ {t("worker_console")}+ </p>+ </div>++ <Separator className="my-3" />++ <div className="w-full flex flex-col gap-6 justify-between">+ <div className="flex flex-col sm:flex-row sm:items-center gap-3">+ <span>{t("regenerate_broken_preservations")}</span>+ <Button+ onClick={() => submit("allBroken")}+ className="ml-auto"+ variant="primary"+ >+ {t("confirm")}+ </Button>+ </div>+ <div className="flex flex-col sm:flex-row sm:items-center gap-3">+ <span>{t("delete_all_preservations_and_regenerate")}</span>+ <Button+ className="ml-auto"+ variant="destructive"+ onClick={() => {+ setAction("allAndRePreserve");+ setShowModal(true);+ }}+ >+ {t("confirm")}+ </Button>+ </div>+ <div className="flex flex-col sm:flex-row sm:items-center gap-3">+ <span>{t("delete_all_preservations")}</span>+ <Button+ className="ml-auto"+ variant="destructive"+ onClick={() => {+ setAction("allAndIgnore");+ setShowModal(true);+ }}+ >+ {t("confirm")}+ </Button>+ </div>+ </div>+ {showModal && action && (+ <ConfirmationModal+ title={+ action === "allAndIgnore"+ ? t("delete_all_preservations")+ : t("delete_all_preservations_and_regenerate")+ }+ onConfirmed={() => submit(action)}+ toggleModal={setShowModal}+ >+ <p>{t("delete_all_preservation_warning")}</p>+ <div role="alert" className="alert alert-warning mt-3">+ <i className="bi-exclamation-triangle text-xl" />+ <span>+ <b>{t("warning")}:</b> {t("irreversible_action_warning")}+ </span>+ </div>+ </ConfirmationModal>+ )}+ </>+ );+};++Page.getLayout = function getLayout(page: ReactElement) {+ return <SettingsLayout>{page}</SettingsLayout>;+};++export default Page;++export { getServerSideProps };diff --git a/apps/web/pages/settings/worker.tsx b/apps/web/pages/settings/worker.tsxindex 94cbf94d..f572ebed 100644--- a/apps/web/pages/settings/worker.tsx+++ b/apps/web/pages/settings/worker.tsx@@ -1,131 +1,22 @@-import SettingsLayout from "@/layouts/SettingsLayout";-import { useTranslation } from "next-i18next";-import getServerSideProps from "@/lib/client/getServerSideProps";-import { ReactElement, useEffect, useState } from "react";-import ConfirmationModal from "@/components/ConfirmationModal";-import { LinkArchiveActionSchemaType } from "@linkwarden/lib/schemaValidation";-import toast from "react-hot-toast";-import { useArchiveAction } from "@linkwarden/router/links";-import { Button } from "@/components/ui/button";-import { Separator } from "@/components/ui/separator";+// Redirect to /settings/worker-console page, thats it!++import { ReactElement } from "react";import { NextPageWithLayout } from "../_app";+import { useRouter } from "next/router";+import { useEffect } from "react";const Page: NextPageWithLayout = () => {- const { t } = useTranslation();- const archiveAction = useArchiveAction();- const [showModal, setShowModal] = useState(false);- const [submitLoader, setSubmitLoader] = useState(false);- const [action, setAction] = useState<- LinkArchiveActionSchemaType["action"] | undefined- >();+ const router = useRouter();useEffect(() => {- if (showModal === false) {- setAction(undefined);- }- }, [showModal]);-- const submit = async (action: LinkArchiveActionSchemaType["action"]) => {- if (!action || submitLoader) return;- setSubmitLoader(true);-- const load = toast.loading(t("deleting"));-- await archiveAction.mutateAsync(- { action },- {- onSettled: (data, error) => {- setSubmitLoader(false);- toast.dismiss(load);-- if (error) {- toast.error(error.message);- } else {- if (action === "allAndIgnore") {- toast.success(t("deleted"));- } else {- toast.success(t("links_are_being_represerved"));- }- }- },- }- );- };-- return (- <>- <div className="flex items-center gap-2">- <i className="bi-gear-wide-connected text-primary text-2xl"></i>- <p className="capitalize text-3xl font-thin inline">{t("worker")}</p>- </div>+ router.replace("/settings/worker-console");+ }, [router]);- <Separator className="my-3" />-- <div className="w-full flex flex-col gap-6 justify-between">- <div className="flex flex-col sm:flex-row sm:items-center gap-3">- <span>{t("regenerate_broken_preservations")}</span>- <Button- onClick={() => submit("allBroken")}- className="ml-auto"- variant="primary"- >- {t("confirm")}- </Button>- </div>- <div className="flex flex-col sm:flex-row sm:items-center gap-3">- <span>{t("delete_all_preservations_and_regenerate")}</span>- <Button- className="ml-auto"- variant="destructive"- onClick={() => {- setAction("allAndRePreserve");- setShowModal(true);- }}- >- {t("confirm")}- </Button>- </div>- <div className="flex flex-col sm:flex-row sm:items-center gap-3">- <span>{t("delete_all_preservations")}</span>- <Button- className="ml-auto"- variant="destructive"- onClick={() => {- setAction("allAndIgnore");- setShowModal(true);- }}- >- {t("confirm")}- </Button>- </div>- </div>- {showModal && action && (- <ConfirmationModal- title={- action === "allAndIgnore"- ? t("delete_all_preservations")- : t("delete_all_preservations_and_regenerate")- }- onConfirmed={() => submit(action)}- toggleModal={setShowModal}- >- <p>{t("delete_all_preservation_warning")}</p>- <div role="alert" className="alert alert-warning mt-3">- <i className="bi-exclamation-triangle text-xl" />- <span>- <b>{t("warning")}:</b> {t("irreversible_action_warning")}- </span>- </div>- </ConfirmationModal>- )}- </>- );-};--Page.getLayout = function getLayout(page: ReactElement) {- return <SettingsLayout>{page}</SettingsLayout>;+ return null;};export default Page;-export { getServerSideProps };+Page.getLayout = function getLayout(page: ReactElement) {+ return page;+};diff --git a/apps/web/public/locales/en/common.json b/apps/web/public/locales/en/common.jsonindex 5e2cf25a..3a560241 100644--- a/apps/web/public/locales/en/common.json+++ b/apps/web/public/locales/en/common.json@@ -528,5 +528,6 @@"trial_left_singular": "Trial ends in 1 day. Subscribe.","apply_members_roles_to_subcollections": "Apply members and roles to subcollections","apply_members_roles_to_subcollections_desc": "This will apply the members and their roles to all existing subcollections.",- "back_to_dashboard": "Back to Dashboard"+ "back_to_dashboard": "Back to Dashboard",+ "worker_console": "Worker Console"}